Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics with Enums does not work with name resolution 2.0 #3304

Open
liamnaddell opened this issue Dec 15, 2024 · 3 comments · May be fixed by #3307
Open

Generics with Enums does not work with name resolution 2.0 #3304

liamnaddell opened this issue Dec 15, 2024 · 3 comments · May be fixed by #3307
Labels

Comments

@liamnaddell
Copy link
Contributor

Sorry if this is a duplicate, I tried looking for similar ice patterns or issue names. I didn't find anything.

Code

// Works fine
pub struct Bob<T> {
    Bleh: T,
}

// Causes ICE
pub enum ROption<T> {
    RSome(T),
    RNone,
}

fn main() {}

Meta

daa2977

Error output

None
Backtrace

TRS-E14 gccrs-build $ gccrs -frust-name-resolution-2.0 simple_gen2.rs
crab1: internal compiler error: in visit, at rust/resolve/rust-late-name-resolver-2.0.cc:285
0x189d030 Rust::Resolver2_0::Late::visit(Rust::AST::TypePath&)
  ../../gccrs/gcc/rust/resolve/rust-late-name-resolver-2.0.cc:285
0x163dccb Rust::AST::TypePath::accept_vis(Rust::AST::ASTVisitor&)
  ../../gccrs/gcc/rust/ast/rust-path.cc:363
0x16693a5 void Rust::AST::DefaultASTVisitor::visit<Rust::AST::Type>(Rust::AST::Type&)
  ../../gccrs/gcc/rust/ast/rust-ast-visitor.h:406
0x166583a Rust::AST::DefaultASTVisitor::visit(Rust::AST::TupleField&)
  ../../gccrs/gcc/rust/ast/rust-ast-visitor.cc:884
0x1665aea Rust::AST::DefaultASTVisitor::visit(Rust::AST::EnumItemTuple&)
  ../../gccrs/gcc/rust/ast/rust-ast-visitor.cc:912
0x155abe5 Rust::AST::EnumItemTuple::accept_vis(Rust::AST::ASTVisitor&)
  ../../gccrs/gcc/rust/ast/rust-ast.cc:4759
0x166cc3d void Rust::AST::DefaultASTVisitor::visit<Rust::AST::EnumItem>(std::unique_ptr<Rust::AST::EnumItem, std::default_delete<Rust::AST::EnumItem> >&)
  ../../gccrs/gcc/rust/ast/rust-ast-visitor.h:410
0x1665db9 Rust::AST::DefaultASTVisitor::visit(Rust::AST::Enum&)
  ../../gccrs/gcc/rust/ast/rust-ast-visitor.cc:940
0x187d22a operator()
  ../../gccrs/gcc/rust/resolve/rust-default-resolver.cc:106
0x187f52b __invoke_impl<void, Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Enum&)::<lambda()>&>
  /usr/include/c++/14.2.1/bits/invoke.h:61
0x187ed3c __invoke_r<void, Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Enum&)::<lambda()>&>
  /usr/include/c++/14.2.1/bits/invoke.h:111
0x187e140 _M_invoke
  /usr/include/c++/14.2.1/bits/std_function.h:290
0x1877cdf std::function<void ()>::operator()() const
  /usr/include/c++/14.2.1/bits/std_function.h:591
0x1876a34 Rust::Resolver2_0::NameResolutionContext::scoped(Rust::Resolver2_0::Rib::Kind, unsigned int, std::function<void ()>, tl::optional<Rust::Identifier>)
  ../../gccrs/gcc/rust/resolve/rust-name-resolution-context.cc:115
0x187d2ee Rust::Resolver2_0::DefaultResolver::visit(Rust::AST::Enum&)
  ../../gccrs/gcc/rust/resolve/rust-default-resolver.cc:108
0x155ac81 Rust::AST::Enum::accept_vis(Rust::AST::ASTVisitor&)
  ../../gccrs/gcc/rust/ast/rust-ast.cc:4777
0x189c342 Rust::Resolver2_0::Late::go(Rust::AST::Crate&)
  ../../gccrs/gcc/rust/resolve/rust-late-name-resolver-2.0.cc:114
0x168fcff Rust::Session::compile_crate(char const*)
  ../../gccrs/gcc/rust/rust-session-manager.cc:635
0x168f290 Rust::Session::handle_input_files(int, char const**)
  ../../gccrs/gcc/rust/rust-session-manager.cc:418
0x14fdfc2 grs_langhook_parse_file
  ../../gccrs/gcc/rust/rust-lang.cc:165
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

@liamnaddell
Copy link
Contributor Author

Issue seems to have been introduced by #3171

@liamnaddell
Copy link
Contributor Author

This blocks #3094

@liamnaddell
Copy link
Contributor Author

If I understand, we rust_unreachable() because T was supposed to be resolved, but wasn't. I'm not sure why this works for structs, but doesn't work for enums.

@liamnaddell liamnaddell linked a pull request Dec 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant