From c4b460c77ca3581ab0212e163fa11f2010fa8c64 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 11 Dec 2024 12:04:32 +0100 Subject: [PATCH 1/9] Labels shall be pushed within label namespace Labels were using the wrong namespace. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Change label push function from type rib to label rib. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. (ResolveExternItem::visit): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve.cc (NameResolution::go): Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-ast-resolve-expr.cc | 14 +++++++------- gcc/rust/resolve/rust-ast-resolve-item.cc | 10 +++++----- gcc/rust/resolve/rust-ast-resolve-stmt.h | 2 +- gcc/rust/resolve/rust-ast-resolve.cc | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc index 5936cf2c31ef..1720edc11283 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.cc +++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc @@ -248,7 +248,7 @@ ResolveExpr::visit (AST::IfLetExpr &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // We know expr.get_patterns () has one pattern at most // so there's no reason to handle it like an AltPattern. @@ -278,7 +278,7 @@ ResolveExpr::visit (AST::IfLetExprConseqElse &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // We know expr.get_patterns () has one pattern at most // so there's no reason to handle it like an AltPattern. @@ -307,7 +307,7 @@ ResolveExpr::visit (AST::BlockExpr &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); if (expr.has_label ()) { @@ -615,7 +615,7 @@ ResolveExpr::visit (AST::ForLoopExpr &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // resolve the expression PatternDeclaration::go (expr.get_pattern (), Rib::ItemType::Var); @@ -681,7 +681,7 @@ ResolveExpr::visit (AST::MatchExpr &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // resolve AST::MatchArm &arm = match_case.get_arm (); @@ -750,7 +750,7 @@ ResolveExpr::visit (AST::ClosureExprInner &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); std::vector bindings = {PatternBinding (PatternBoundCtx::Product, std::set ())}; @@ -780,7 +780,7 @@ ResolveExpr::visit (AST::ClosureExprInnerTyped &expr) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); std::vector bindings = {PatternBinding (PatternBoundCtx::Product, std::set ())}; diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 619efb00ac41..2eb86cec906f 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -61,7 +61,7 @@ ResolveTraitItems::visit (AST::Function &function) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) @@ -216,7 +216,7 @@ ResolveItem::visit (AST::Module &module) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // FIXME: Should we reinsert a child here? Any reason we ResolveTopLevel::go // in ResolveTopLevel::visit (AST::Module) as well as here? @@ -473,7 +473,7 @@ ResolveItem::visit (AST::Function &function) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) @@ -648,7 +648,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); if (impl_block.has_generics ()) for (auto &generic : impl_block.get_generic_params ()) @@ -1053,7 +1053,7 @@ ResolveExternItem::visit (AST::Function &function) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // resolve the generics if (function.has_generics ()) diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index 7118b70d7058..45f3283bd4db 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -338,7 +338,7 @@ class ResolveStmt : public ResolverBase resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc index df90cff7815c..75e01ab2b0ce 100644 --- a/gcc/rust/resolve/rust-ast-resolve.cc +++ b/gcc/rust/resolve/rust-ast-resolve.cc @@ -75,7 +75,7 @@ NameResolution::go (AST::Crate &crate) resolver->get_label_scope ().push (scope_node_id); resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); - resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_label_scope ().peek ()); // get the root segment CanonicalPath crate_prefix From d751b2ed7c39fbddbd903124427d8a4b73761534 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 11 Dec 2024 14:19:44 +0100 Subject: [PATCH 2/9] Add debug dump to old name resolver It might be necessary to compare both name resolution' internal states during the transition. This new debug representation could help with that. gcc/rust/ChangeLog: * resolve/rust-name-resolver.h: Add new degug dump for old name resolver. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-name-resolver.h | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h index 5e1901adfd5a..bf5ef7786960 100644 --- a/gcc/rust/resolve/rust-name-resolver.h +++ b/gcc/rust/resolve/rust-name-resolver.h @@ -204,6 +204,41 @@ class Resolver void insert_captured_item (NodeId id); const std::set &get_captures (NodeId id) const; + std::string as_debug_string () const + { + std::stringstream ss; + + ss << "Names:\n"; + for (auto &n : name_ribs) + { + ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str () + << "\n"; + } + ss << "Types:\n"; + for (auto &n : type_ribs) + { + ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str () + << "\n"; + } + ss << "Macros:\n"; + + for (auto &n : macro_ribs) + { + ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str () + << "\n"; + } + + ss << "Labels:\n"; + + for (auto &n : label_ribs) + { + ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str () + << "\n"; + } + + return ss.str (); + } + protected: bool decl_needs_capture (NodeId decl_rib_node_id, NodeId closure_rib_node_id, const Scope &scope); From 17571f225f0162ba34282a690c85bb945cd00600 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 11 Dec 2024 15:12:00 +0100 Subject: [PATCH 3/9] Add unit struct to name namespace in old resolver We missed the name namespace for unit struct in the old resolver. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Add struct to name namespace. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-ast-resolve-toplevel.h | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index ceac7edd3415..491fa690eb50 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -242,14 +242,21 @@ class ResolveTopLevel : public ResolverBase auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); - resolver->get_type_scope ().insert ( - path, struct_decl.get_node_id (), struct_decl.get_locus (), false, - Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, location_t locus) -> void { - rich_location r (line_table, struct_decl.get_locus ()); - r.add_range (locus); - rust_error_at (r, "redefined multiple times"); - }); + auto duplicate_item + = [&] (const CanonicalPath &, NodeId, location_t locus) -> void { + rich_location r (line_table, struct_decl.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); + }; + + resolver->get_type_scope ().insert (path, struct_decl.get_node_id (), + struct_decl.get_locus (), false, + Rib::ItemType::Type, duplicate_item); + + if (struct_decl.is_unit_struct ()) + resolver->get_name_scope ().insert (path, struct_decl.get_node_id (), + struct_decl.get_locus (), false, + Rib::ItemType::Type, duplicate_item); NodeId current_module = resolver->peek_current_module_scope (); mappings.insert_module_child_item (current_module, decl); From ac30ed113e530078e848f68f16ee5abd67549fb4 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 12 Dec 2024 13:16:14 +0100 Subject: [PATCH 4/9] Remove query mode on CompileItem Query mode was a hack to catch up some compile errors early, it was deemed to be removed at some time. Recent changes to NR1 highlighted an incompatibility with it hence it's removal. gcc/rust/ChangeLog: * backend/rust-compile-item.h: Remove query mode. * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/backend/rust-compile-item.h | 6 ++---- gcc/rust/backend/rust-compile-resolve-path.cc | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 1c877fa328dc..70660e16147c 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -31,15 +31,13 @@ class CompileItem : private HIRCompileBase, protected HIR::HIRStmtVisitor public: static tree compile (HIR::Item *item, Context *ctx, TyTy::BaseType *concrete = nullptr, - bool is_query_mode = false, location_t ref_locus = UNDEF_LOCATION) { CompileItem compiler (ctx, concrete, ref_locus); item->accept_vis (compiler); - if (is_query_mode && compiler.reference == error_mark_node) - rust_internal_error_at (ref_locus, "failed to compile item: %s", - item->as_string ().c_str ()); + if (compiler.reference == error_mark_node) + rust_debug ("failed to compile item: %s", item->as_string ().c_str ()); return compiler.reference; } diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 049b0d86b523..47cd034660c8 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -206,11 +206,9 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, if (auto resolved_item = ctx->get_mappings ().lookup_hir_item (ref)) { if (!lookup->has_substitutions_defined ()) - return CompileItem::compile (*resolved_item, ctx, nullptr, true, - expr_locus); + return CompileItem::compile (*resolved_item, ctx, nullptr, expr_locus); else - return CompileItem::compile (*resolved_item, ctx, lookup, true, - expr_locus); + return CompileItem::compile (*resolved_item, ctx, lookup, expr_locus); } else if (auto hir_extern_item = ctx->get_mappings ().lookup_hir_extern_item (ref)) From f71402bd6698761772161a33fc3db4a50ba99974 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 12 Dec 2024 14:39:12 +0100 Subject: [PATCH 5/9] Remove some tests from nr2 exclusion file Those test are now passing. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove passing tests. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/nr2/exclude | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 9b490c18bab4..af46114bf40e 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -8,17 +8,12 @@ macros/builtin/include3.rs macros/builtin/include4.rs canonical_paths1.rs cfg1.rs -cfg3.rs -cfg4.rs -cfg5.rs closure_no_type_anno.rs complex-path1.rs const-issue1440.rs const_generics_3.rs const_generics_4.rs -const_generics_5.rs const_generics_7.rs -derive_empty.rs derive_macro1.rs expected_type_args2.rs feature_rust_attri0.rs @@ -46,7 +41,6 @@ issue-1901.rs issue-1981.rs issue-2036.rs issue-2043.rs -issue-2136-2.rs issue-2142.rs issue-2238.rs issue-2330.rs @@ -62,8 +56,6 @@ issue-852.rs issue-855.rs iterators1.rs lookup_err1.rs -macros/mbe/macro13.rs -macros/mbe/macro15.rs macros/mbe/macro23.rs macros/mbe/macro40.rs macros/mbe/macro43.rs @@ -71,7 +63,6 @@ macros/mbe/macro44.rs macros/mbe/macro50.rs macros/mbe/macro54.rs macros/mbe/macro6.rs -macros/mbe/macro_rules_macro_rules.rs macros/mbe/macro_use1.rs match-never-ltype.rs match-never-rtype.rs @@ -109,7 +100,6 @@ pub_restricted_3.rs redef_error2.rs redef_error4.rs redef_error5.rs -self-path1.rs self-path2.rs sizeof-stray-infer-var-bug.rs struct-expr-parse.rs From a40fcde5e2c27f3d7ff3b0be15466b82109b6962 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 12 Dec 2024 18:30:09 +0100 Subject: [PATCH 6/9] Clone expr instead of taking it We're reusing the value, it could therefore not be taken be should be cloned. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Clone expr instead of taking it. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/typecheck/rust-hir-type-check-enumitem.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc index 7d8f7e4c2655..ac850752f2d2 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc @@ -142,10 +142,11 @@ TypeCheckEnumItem::visit (HIR::EnumItemDiscriminant &item) rust_assert (canonical_path.has_value ()); RustIdent ident{*canonical_path, item.get_locus ()}; - variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (), - item.get_mappings ().get_defid (), - item.get_identifier ().as_string (), ident, - item.take_discriminant_expression ()); + variant + = new TyTy::VariantDef (item.get_mappings ().get_hirid (), + item.get_mappings ().get_defid (), + item.get_identifier ().as_string (), ident, + item.get_discriminant_expression ().clone_expr ()); } void From 864598d5f2372372db0a35bdfbfdb3048e91f283 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 6 Jan 2025 15:53:31 +0100 Subject: [PATCH 7/9] Make foreverstack debug string const Those function should not change anything within the foreverstack, it can therefore be made const. gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Make debug functions const. * resolve/rust-forever-stack.hxx: Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-forever-stack.h | 6 +++--- gcc/rust/resolve/rust-forever-stack.hxx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index 8fc46ad603f5..278c1a885243 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -670,7 +670,7 @@ template class ForeverStack tl::optional to_rib (NodeId rib_id); tl::optional to_rib (NodeId rib_id) const; - std::string as_debug_string (); + std::string as_debug_string () const; /** * Used to check if a module is a descendant of another module @@ -752,9 +752,9 @@ template class ForeverStack std::reference_wrapper cursor_reference; void stream_rib (std::stringstream &stream, const Rib &rib, - const std::string &next, const std::string &next_next); + const std::string &next, const std::string &next_next) const; void stream_node (std::stringstream &stream, unsigned indentation, - const Node &node); + const Node &node) const; /* Helper types and functions for `resolve_path` */ diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 6181c05fc6c5..2b628e44aead 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -699,7 +699,7 @@ template void ForeverStack::stream_rib (std::stringstream &stream, const Rib &rib, const std::string &next, - const std::string &next_next) + const std::string &next_next) const { if (rib.get_values ().empty ()) { @@ -718,7 +718,7 @@ ForeverStack::stream_rib (std::stringstream &stream, const Rib &rib, template void ForeverStack::stream_node (std::stringstream &stream, unsigned indentation, - const ForeverStack::Node &node) + const ForeverStack::Node &node) const { auto indent = std::string (indentation, ' '); auto next = std::string (indentation + 4, ' '); @@ -750,7 +750,7 @@ ForeverStack::stream_node (std::stringstream &stream, unsigned indentation, template std::string -ForeverStack::as_debug_string () +ForeverStack::as_debug_string () const { std::stringstream stream; From d9726c1e7800566a16e477e18a2137b50382a37b Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 6 Jan 2025 15:55:53 +0100 Subject: [PATCH 8/9] Resolved item type shall be differentiated later We need to query all namespaces and error out at a later stage if the retrieved item is wrong. gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Query all namespaces. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/typecheck/rust-hir-trait-resolve.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc index 8b90039f2835..0048ff55b445 100644 --- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc +++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc @@ -127,8 +127,10 @@ TraitResolver::resolve_path_to_trait (const HIR::TypePath &path, } else { - ok = resolver->lookup_resolved_type (path.get_mappings ().get_nodeid (), - &ref); + auto path_nodeid = path.get_mappings ().get_nodeid (); + ok = resolver->lookup_resolved_type (path_nodeid, &ref) + || resolver->lookup_resolved_name (path_nodeid, &ref) + || resolver->lookup_resolved_macro (path_nodeid, &ref); } if (!ok) From bd1b05f11a06b6466c77c3c3228519b89e4f7e50 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Sat, 11 Jan 2025 22:35:08 +0100 Subject: [PATCH 9/9] Remove some passing test from exclude file Those tests are now passing. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove some tests. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/nr2/exclude | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index af46114bf40e..c3d489943353 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -14,7 +14,6 @@ const-issue1440.rs const_generics_3.rs const_generics_4.rs const_generics_7.rs -derive_macro1.rs expected_type_args2.rs feature_rust_attri0.rs format_args_basic_expansion.rs @@ -42,7 +41,6 @@ issue-1981.rs issue-2036.rs issue-2043.rs issue-2142.rs -issue-2238.rs issue-2330.rs issue-2479.rs issue-2723-1.rs @@ -75,8 +73,6 @@ match9.rs method2.rs multiple_bindings1.rs multiple_bindings2.rs -name_resolution2.rs -name_resolution4.rs nested_macro_use1.rs nested_macro_use2.rs nested_macro_use3.rs @@ -131,11 +127,9 @@ issue-3009.rs issue-2953-2.rs issue-1773.rs issue-2905-2.rs -issue-2907.rs issue-2423.rs issue-266.rs additional-trait-bounds2.rs -auto_traits3.rs issue-3140.rs cmp1.rs # please don't delete the trailing newline