-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Explain more clearly why fn() -> T
can't be #[derive(Clone)]
#114029
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
Conversation
r? @scottmcm (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
library/core/src/clone.rs
Outdated
/// struct Generate<T>(fn() -> T); | ||
/// ``` | ||
/// | ||
/// the auto-derived implementation will be **invalid**, because it will become: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "invalid" is a good thing to say here, since that code compiles fine https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=63f01a475d60aa4896f193a3a887044b.
That might not be what you want, but it's not invalid, so I think this section should better elaborate what it's trying to say.
@rustbot author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback! I have now pushed a more fleshed out explanation. Looking forward to your new feedback. Here is how the new version looks when rendered:
@rustbot ready
Thanks, it looks better now. @bors r+ rollup |
Explain more clearly why `fn() -> T` can't be `#[derive(Clone)]` Closes rust-lang#73480 The derived impls were generated with `rustc -Z unpretty=expanded main.rs` and the raw output is: ```rust struct Generate<T>(fn() -> T); #[automatically_derived] impl<T: ::core::marker::Copy> ::core::marker::Copy for Generate<T> { } #[automatically_derived] impl<T: ::core::clone::Clone> ::core::clone::Clone for Generate<T> { #[inline] fn clone(&self) -> Generate<T> { Generate(::core::clone::Clone::clone(&self.0)) } } ```
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#114029 (Explain more clearly why `fn() -> T` can't be `#[derive(Clone)]`) - rust-lang#114248 (Make lint missing-copy-implementations honor negative `Copy` impls) - rust-lang#114498 (Print tidy command with bless tidy check failure) r? `@ghost` `@rustbot` modify labels: rollup
Closes #73480
The derived impls were generated with
rustc -Z unpretty=expanded main.rs
and the raw output is: