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 f2245c98739..60512038631 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -294,6 +294,13 @@ Late::visit (AST::StructStruct &s) ctx.scoped (Rib::Kind::Item, s.get_node_id (), s_vis); } +void +Late::visit (AST::Enum &s) +{ + auto s_vis = [this, &s] () { AST::DefaultASTVisitor::visit (s); }; + ctx.scoped (Rib::Kind::Item, s.get_node_id (), s_vis); +} + void Late::visit (AST::StructExprStruct &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 98cf09205bf..7260f99507d 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h @@ -52,6 +52,7 @@ class Late : public DefaultResolver void visit (AST::StructExprStructBase &) override; void visit (AST::StructExprStructFields &) override; void visit (AST::StructStruct &) override; + void visit (AST::Enum &) override; void visit (AST::GenericArgs &) override; void visit (AST::GenericArg &); 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 01c5d26f4c1..8fa4809d715 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -332,6 +332,15 @@ TopLevel::visit (AST::EnumItemDiscriminant &variant) void TopLevel::visit (AST::Enum &enum_item) { + auto generic_vis = [this, &enum_item] () { + for (auto &g : enum_item.get_generic_params ()) + { + g->accept_vis (*this); + } + }; + + ctx.scoped (Rib::Kind::Item, enum_item.get_node_id (), generic_vis); + insert_or_error_out (enum_item.get_identifier (), enum_item, Namespace::Types); diff --git a/gcc/testsuite/rust/compile/issue-3304.rs b/gcc/testsuite/rust/compile/issue-3304.rs new file mode 100644 index 00000000000..6ab614fa2d5 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3304.rs @@ -0,0 +1,10 @@ +// { dg-additional-options "-frust-name-resolution-2.0" } +#[lang = "sized"] +trait Sized {} + +pub enum ROption { + RSome(T), + RNone, +} + +fn main() {}