Skip to content

Commit 13e6151

Browse files
committed
Try non-const type first
1 parent 9a709c7 commit 13e6151

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎cpp2rust/converter/rules/string_matcher.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,11 @@ Match<TranslationRule::TypeRule> searchType(const std::string &txt) {
327327
RuleRegistry::TypeCandidates(typeKey(txt)), txt);
328328
}
329329

330-
std::string mapTypeString(const std::string &cpp_type) {
331-
auto [rule, subs] = searchType(cpp_type);
330+
std::string mapTypeString(std::string_view cpp_type) {
331+
auto [rule, subs] = searchType(std::string(cpp_type));
332+
if (!rule && cpp_type.starts_with("const ")) {
333+
return mapTypeString(cpp_type.substr(std::string_view("const ").size()));
334+
}
332335
if (!rule) {
333336
llvm::errs() << "cpp_type: " << cpp_type << '\n';
334337
assert(0 && "Type is not present in the registry");

0 commit comments

Comments
 (0)