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

Cannot derive both Clone and Copy on an empty struct #2987

Open
CohenArthur opened this issue May 14, 2024 · 0 comments
Open

Cannot derive both Clone and Copy on an empty struct #2987

CohenArthur opened this issue May 14, 2024 · 0 comments

Comments

@CohenArthur
Copy link
Member

I tried this code:

#[lang = "copy"]
trait Copy {}

#[lang = "clone"]
trait Clone {
    fn clone(&self) -> Self;
}

#[derive(Copy, Clone)]
struct Empty;

I expected to see this happen: no error.

Instead, this happened:

crab1: internal compiler error: in go, at rust/expand/rust-derive-clone.cc:106
0x23e9f13 Rust::AST::DeriveClone::go(Rust::AST::Item&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-derive-clone.cc:106
0x23e870c Rust::AST::DeriveVisitor::derive(Rust::AST::Item&, Rust::AST::Attribute const&, Rust::BuiltinMacro)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-derive.cc:37
0x23daaed Rust::builtin_derive_item(Rust::AST::Item&, Rust::AST::Attribute const&, Rust::BuiltinMacro)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:49
0x23da6cd 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> > > >&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:192
0x23dbf80 Rust::ExpandVisitor::visit(Rust::AST::Crate&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:443
0x23d9ff0 Rust::ExpandVisitor::go(Rust::AST::Crate&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:42
0x22ec683 Rust::Session::expansion(Rust::AST::Crate&, Rust::Resolver2_0::NameResolutionContext&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:933
0x22eaf0f Rust::Session::compile_crate(char const*)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:604
0x22ea8b1 Rust::Session::handle_input_files(int, char const**)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:416
0x2144872 grs_langhook_parse_file()
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../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.

if the order of Clone and Copy is switched, then this happens:

crab1: internal compiler error: in go, at rust/expand/rust-derive-copy.cc:34
0x23eb6a3 Rust::AST::DeriveCopy::go(Rust::AST::Item&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-derive-copy.cc:34
0x23e873f Rust::AST::DeriveVisitor::derive(Rust::AST::Item&, Rust::AST::Attribute const&, Rust::BuiltinMacro)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-derive.cc:39
0x23daaed Rust::builtin_derive_item(Rust::AST::Item&, Rust::AST::Attribute const&, Rust::BuiltinMacro)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:49
0x23da6cd 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> > > >&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:192
0x23dbf80 Rust::ExpandVisitor::visit(Rust::AST::Crate&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:443
0x23d9ff0 Rust::ExpandVisitor::go(Rust::AST::Crate&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/expand/rust-expand-visitor.cc:42
0x22ec683 Rust::Session::expansion(Rust::AST::Crate&, Rust::Resolver2_0::NameResolutionContext&)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:933
0x22eaf0f Rust::Session::compile_crate(char const*)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:604
0x22ea8b1 Rust::Session::handle_input_files(int, char const**)
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../gcc/rust/rust-session-manager.cc:416
0x2144872 grs_langhook_parse_file()
	/home/kagounard/Git/rust-gcc/gccrs/build/gcc/../../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.

Meta

8a72566

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant