ICE `in new_type_param, at rust/ast/rust-ast-builder.cc:655` derive on generic struct
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
#[derive(Debug)]
struct X<T, F: Fn(T) -> T> {
a: [u32; N],
}
original:
// Check that deriving debug on struct with const is permitted.
// run-pass
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
#[derive(Debug)]
struct X<T, F: Fn(T) -> T> {
a: [u32; N],
}
fn main() {
let x = *(Box::new(A) as Box<dyn Foo>);
x.foo();
//~^ERROR the `foo` method cannot be invoked on a trait object
}
Version information:
5c3e2adc695b04a199d37cacd8c23b14fdab914f
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/rust/ast/rust-ast-builder.cc#L649-L661
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.5rIo0TQvVEOL/rustc_testrunner_tmpdir_reporting.0bK56OuhXlhJ/mvce.rs:1:3: warning: derive(Debug) is not fully implemented yet and has no effect - only a stub implementation will be generated
1 | #[derive(Debug)]
| ^~~~~~
crab1: internal compiler error: in new_type_param, at rust/ast/rust-ast-builder.cc:655
0x2fec938 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
../../gcc/diagnostic.cc:1803
0x8fe325 Rust::AST::Builder::new_type_param(Rust::AST::TypeParam&, std::vector<std::unique_ptr<Rust::AST::TypeParamBound, std::default_delete<Rust::AST::TypeParamBound> >, std::allocator<std::unique_ptr<Rust::AST::TypeParamBound, std::default_delete<Rust::AST::TypeParamBound> > > >)
../../gcc/rust/ast/rust-ast-builder.cc:655
0xeae9e0 Rust::AST::DeriveVisitor::setup_impl_generics(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> >, std::allocator<std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> > > > const&, tl::optional<std::unique_ptr<Rust::AST::TypeParamBound, std::default_delete<Rust::AST::TypeParamBound> > >&&) const
../../gcc/rust/expand/rust-derive.cc:115
0xebd07a Rust::AST::DeriveDebug::stub_derive_impl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> >, std::allocator<std::unique_ptr<Rust::AST::GenericParam, std::default_delete<Rust::AST::GenericParam> > > > const&)
../../gcc/rust/expand/rust-derive-debug.cc:86
0xebd6bc Rust::AST::DeriveDebug::visit_struct(Rust::AST::StructStruct&)
../../gcc/rust/expand/rust-derive-debug.cc:96
0xebbea4 Rust::AST::DeriveDebug::go(Rust::AST::Item&)
../../gcc/rust/expand/rust-derive-debug.cc:34
0xeae0c3 Rust::AST::DeriveVisitor::derive(Rust::AST::Item&, Rust::AST::Attribute const&, Rust::BuiltinMacro)
../../gcc/rust/expand/rust-derive.cc:53
0xe9fdda builtin_derive_item
../../gcc/rust/expand/rust-expand-visitor.cc:50
0xe9fdda Rust::ExpandVisitor::expand_inner_items(std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >&)
../../gcc/rust/expand/rust-expand-visitor.cc:194
0xda3933 Rust::Session::expansion(Rust::AST::Crate&, Rust::Resolver2_0::NameResolutionContext&)
../../gcc/rust/rust-session-manager.cc:958
0xdb8e57 Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:620
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with gcc/rust/ast/rust-ast-builder.cc:655, then follow the derive path through gcc/rust/expand/rust-derive.cc and rust-derive-debug.cc. Reproduce the ICE with the reduced Rust example and the provided compiler command. Done means the generic struct with #[derive(Debug)] no longer triggers an internal compiler error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100