Skip to content

Remove unreachable code and fix typos in converter.cpp#181

Merged
nunoplopes merged 2 commits into
masterfrom
copilot/remove-unreachable-call
Jun 4, 2026
Merged

Remove unreachable code and fix typos in converter.cpp#181
nunoplopes merged 2 commits into
masterfrom
copilot/remove-unreachable-call

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Three minor correctness/quality fixes in cpp2rust/converter/converter.cpp.

Changes

  • Remove dead std::unreachable() — the call after a switch block where every case (including default) already ends with return true/return false can never be reached.
  • Fix typo in assert message"less that total size""less than total size"
  • Fix typo in comment"Take supress before""Take suppress before"
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The `std::unreachable()` call at line 2357 is unreachable because the `switch` statement covers all non-default cases with explicit `return true` and the `default` case with `return false`. The `std::unreachable()` can never be reached and should be removed.","fixFiles":[{"filePath":"cpp2rust/converter/converter.cpp","diff":"diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp\n--- a/cpp2rust/converter/converter.cpp\n+++ b/cpp2rust/converter/converter.cpp\n@@ -2354,7 +2354,6 @@\n   default:\n     return false;\n   }\n-  std::unreachable();\n }\n \n bool Converter::VisitUnaryOperator(clang::UnaryOperator *expr) {\n"}]},{"message":"The `std::unreachable()` call at line 2357 is unreachable because the `switch` statement covers all non-default cases with explicit `return true` and the `default` case with `return false`. The `std::unreachable()` can never be reached and should be removed.","fixFiles":[{"filePath":"cpp2rust/converter/converter.cpp","diff":"diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp\n--- a/cpp2rust/converter/converter.cpp\n+++ b/cpp2rust/converter/converter.cpp\n@@ -2354,7 +2354,6 @@\n   default:\n     return false;\n   }\n-  std::unreachable();\n }\n \n bool Converter::VisitUnaryOperator(clang::UnaryOperator *expr) {\n"}]},{"message":"Corrected spelling of 'less that' to 'less than'.","fixFiles":[{"filePath":"cpp2rust/converter/converter.cpp","diff":"diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp\n--- a/cpp2rust/converter/converter.cpp\n+++ b/cpp2rust/converter/converter.cpp\n@@ -2814,7 +2814,7 @@\n       if (auto arr_ty = ctx_.getAsConstantArrayType(expr->getType())) {\n         assert(\n             (arr_ty->getSize().getZExtValue() - expr->getNumInits()) &&\n-            \"Number of initializers should be less that total size of array\");\n+            \"Number of initializers should be less than total size of array\");\n         for (unsigned i = 0;\n              i < arr_ty->getSize().getZExtValue() - expr->getNumInits(); ++i) {\n           ConvertVarInit(expr->getArrayFiller()->getType(),\n"}]},{"message":"Corrected spelling of 'supress' to 'suppress'.","fixFiles":[{"filePath":"cpp2rust/converter/converter.cpp","diff":"diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp\n--- a/cpp2rust/converter/converter.cpp\n+++ b/cpp2rust/converter/converter.cpp\n@@ -3002,7 +3002,7 @@\n   if (ctor->isCopyOrMoveConstructor() ||\n       (ctor->isConvertingConstructor(false) && ctor->getNumParams() == 1 &&\n        ctor->getParamDecl(0)->getType()->isRValueReferenceType())) {\n-    // Take supress before recursing into the child.\n+    // Take suppress before recursing into the child.\n     bool suppress = PushSuppressIteratorClone::take(*this);\n     Convert(expr->getArg(0));\n     if (ctor->isCopyConstructor() && !suppress) {\n"}]}]

Copilot AI changed the title [WIP] Remove unreachable std::unreachable() call in converter.cpp Remove unreachable code and fix typos in converter.cpp Jun 4, 2026
Copilot AI requested a review from nunoplopes June 4, 2026 17:33
@nunoplopes nunoplopes marked this pull request as ready for review June 4, 2026 17:34
@nunoplopes nunoplopes merged commit 8009afc into master Jun 4, 2026
9 checks passed
@nunoplopes nunoplopes deleted the copilot/remove-unreachable-call branch June 4, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants