diff --git a/gcc/rust/ast/rust-ast-visitor.cc b/gcc/rust/ast/rust-ast-visitor.cc index e60f5ca9b85d..7c5117d48dbb 100644 --- a/gcc/rust/ast/rust-ast-visitor.cc +++ b/gcc/rust/ast/rust-ast-visitor.cc @@ -997,6 +997,8 @@ DefaultASTVisitor::visit (AST::Trait &trait) visit_inner_attrs (trait); + visit (trait.get_implicit_self ()); + for (auto &generic : trait.get_generic_params ()) visit (generic); diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index f2245c987397..255ab02c6b7d 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -287,6 +287,16 @@ Late::visit (AST::TypePath &type) DefaultResolver::visit (type); } +void +Late::visit (AST::Trait &trait) +{ + // kind of weird how this is done + ctx.map_usage (Usage (trait.get_implicit_self ().get_node_id ()), + Definition (trait.get_node_id ())); + + DefaultResolver::visit (trait); +} + void Late::visit (AST::StructStruct &s) { diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h b/gcc/rust/resolve/rust-late-name-resolver-2.0.h index 98cf09205bf4..0db21f2a0bd1 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h @@ -48,6 +48,7 @@ class Late : public DefaultResolver void visit (AST::PathInExpression &) override; void visit (AST::LangItemPath &) override; void visit (AST::TypePath &) override; + void visit (AST::Trait &) override; void visit (AST::StructExprStruct &) override; void visit (AST::StructExprStructBase &) override; void visit (AST::StructExprStructFields &) override; diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc index 01c5d26f4c15..b1b303fa649a 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -280,11 +280,8 @@ TopLevel::visit (AST::StructStruct &struct_item) void TopLevel::visit (AST::TypeParam &type_param) { - // Hacky and weird, find a better solution - // We should probably not even insert self in the first place ? - if (type_param.get_type_representation ().as_string () != "Self") - insert_or_error_out (type_param.get_type_representation (), type_param, - Namespace::Types); + insert_or_error_out (type_param.get_type_representation (), type_param, + Namespace::Types); } void diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 797e59a5c580..3a82d1ca900b 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -79,7 +79,6 @@ issue-2190-2.rs issue-2238.rs issue-2304.rs issue-2330.rs -issue-2375.rs issue-2478.rs issue-2479.rs issue-2723-1.rs @@ -182,7 +181,6 @@ issue-2987.rs issue-3045-1.rs issue-3045-2.rs issue-3046.rs -unknown-associated-item.rs issue-3030.rs issue-3035.rs issue-3139-1.rs