-
Notifications
You must be signed in to change notification settings - Fork 155
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
Comments
The same bug occurs if you try to derive Copy twice. I believe the root cause is due to the first derive expanding into a TraitImpl. This moves the second derive to applying to the TraitImpl instead of to the struct. When we try to derive on a traitimpl, nothing happens, then we assert expansion success, which causes the ICE |
The following code triggers an ICE, but @CohenArthur , it might be good to break this out into a separate issue? #[lang = "copy"]
trait Copy {}
#[lang = "clone"]
trait Clone {
fn clone(&self) -> Self;
}
struct Empty;
#[derive(Copy)]
impl Clone for Empty {} |
I'll see if I can fix the first issue, i.e. double-derive = ice problem |
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc: Fix ICE caused by unique_ptr UB and buggy iterator use gcc/testsuite/ChangeLog: * rust/compile/issue-2987.rs: Add test for deriving Clone and Copy at the same time Signed-off-by: Liam Naddell <[email protected]>
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc: Fix ICE caused by unique_ptr UB and buggy iterator use gcc/testsuite/ChangeLog: * rust/compile/issue-2987.rs: Add test for deriving Clone and Copy at the same time Signed-off-by: Liam Naddell <[email protected]>
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc: Fix ICE caused by unique_ptr UB and buggy iterator use gcc/testsuite/ChangeLog: * rust/compile/issue-2987.rs: Add test for deriving Clone and Copy at the same time Signed-off-by: Liam Naddell <[email protected]>
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc: Fix ICE caused by unique_ptr UB and buggy iterator use gcc/testsuite/ChangeLog: * rust/compile/issue-2987.rs: Add test for deriving Clone and Copy at the same time Signed-off-by: Liam Naddell <[email protected]>
This is a known issue that Guillaume Gomez has a PR for, I did a closer search |
I tried this code:
I expected to see this happen: no error.
Instead, this happened:
if the order of
Clone
andCopy
is switched, then this happens:Meta
8a72566
The text was updated successfully, but these errors were encountered: