diff --git a/cpp2rust/converter/rules/rules_loader.cpp b/cpp2rust/converter/rules/rules_loader.cpp index a7dcd559ee..1ea5edec66 100644 --- a/cpp2rust/converter/rules/rules_loader.cpp +++ b/cpp2rust/converter/rules/rules_loader.cpp @@ -159,6 +159,7 @@ class RuleUsageCollector AddKey(TypeKey(type)); if (const auto *alias = llvm::dyn_cast(type.getTypePtr())) { + AddKey(DeclKey(alias->getDecl())); if (const auto *record = llvm::dyn_cast( alias->getDecl()->getDeclContext())) { AddKey(ClassKey(record)); diff --git a/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp b/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp index 7879881b79..16dbe5fb7e 100644 --- a/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp +++ b/cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp @@ -215,12 +215,18 @@ std::string ExprKey(clang::ASTContext &ctx, const clang::Decl *rule) { std::string TypeKey(const clang::TypedefNameDecl *rule) { auto type = rule->getUnderlyingType(); + for (auto pointee = type;; pointee = pointee->getPointeeType()) { + if (auto alias = pointee->getAs(); + alias && !pointee->isDependentType()) { + return RulesLoader::DeclKey(alias->getDecl()); + } + if (!pointee->isPointerType() && !pointee->isReferenceType()) { + break; + } + } if (auto key = RulesLoader::TypeKey(type); !key.empty()) { return key; } - if (!type->isDependentType() && type->getAs()) { - return RulesLoader::TypeKey(type); - } while (type->isPointerType() || type->isReferenceType()) { type = type->getPointeeType(); }