-
Notifications
You must be signed in to change notification settings - Fork 13k
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
clone_from derive macro impl #97528
clone_from derive macro impl #97528
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
6aa7429
to
a401bb0
Compare
Annoyingly, this doubles up a lot of the derive errors. Some tame like `Foo` has derived impls for the traits `Clone` and `Clone`, but these are intentionally ignored during dead code analysis Some just super verbose like error[E0277]: the trait bound `&mut T: Clone` is not satisfied
--> src/lib.rs:50:5
|
48 | #[derive(Clone)]
| ----- in this derive macro expansion
49 | struct Foo<'a, T> {
50 | bar: &'a mut T
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&mut T`
|
= help: the following other types implement trait `Clone`:
&T
*const T
*mut T
= note: `Clone` is implemented for `&T`, but not for `&mut T`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `&'a mut T: Clone` is not satisfied
--> src/lib.rs:50:5
|
48 | #[derive(Clone)]
| ----- in this derive macro expansion
49 | struct Foo<'a, T> {
50 | bar: &'a mut T
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&'a mut T`
|
= help: the following other types implement trait `Clone`:
&T
*const T
*mut T
= note: `Clone` is implemented for `&'a T`, but not for `&'a mut T`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Not really familiar with this code r? rust-lang/compiler |
☔ The latest upstream changes (presumably #98376) made this pull request unmergeable. Please resolve the merge conflicts. |
(WIP,
this is currently ICEing locally)On deep
#[derive(Clone)]
impls, this change adds an impl forclone_from
that tries to efficiently re-use any allocations.This required a bunch of changes to the macro builders to support mut refs 😅