-
Notifications
You must be signed in to change notification settings - Fork 13.4k
clone_from derive macro impl #97528
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Closed
Closed
clone_from derive macro impl #97528
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(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 😅