-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Compiler can suggest #[derive(move Trait)]
#55146
Comments
I ran into what I think is a similar problem on stable rust 1.55, MCVE here: https://or.computer.surgery/charles/rust_55146 |
Hey, I've also recently ran into something similar to the above while implementing a macro to generate boilerplate for error types Weird suggestion
Unfortunately I've since fixed the issue, error messages without any span are rarely useful so i wasn't paying much attention at the time. Here is another
Edit: Didn't see that a MCVE was posted above. Just in case it's of any help I encountered these on beta
|
I have a repro case. The output is even worse now:
The suggestion will no longer appear after #109082, but the "closure returned here" note still has an improper span:
|
Do not provide suggestions when the spans come from expanded code that doesn't point at user code Hide invalid proc-macro suggestions and track spans coming from proc-macros pointing at attribute. Effectively, unless the proc-macro keeps user spans, suggestions will not be produced for the code they produce. r? `@ghost` Fix rust-lang#107113, fix rust-lang#107976, fix rust-lang#107977, fix rust-lang#108748, fix rust-lang#106720, fix rust-lang#90557. Could potentially address rust-lang#50141, rust-lang#67373, rust-lang#55146, rust-lang#78862, rust-lang#74043, rust-lang#88514, rust-lang#83320, rust-lang#91520, rust-lang#104071. CC rust-lang#50122, rust-lang#76360.
Do not provide suggestions when the spans come from expanded code that doesn't point at user code Hide invalid proc-macro suggestions and track spans coming from proc-macros pointing at attribute. Effectively, unless the proc-macro keeps user spans, suggestions will not be produced for the code they produce. r? ``@ghost`` Fix rust-lang#107113, fix rust-lang#107976, fix rust-lang#107977, fix rust-lang#108748, fix rust-lang#106720, fix rust-lang#90557. Could potentially address rust-lang#50141, rust-lang#67373, rust-lang#55146, rust-lang#78862, rust-lang#74043, rust-lang#88514, rust-lang#83320, rust-lang#91520, rust-lang#104071. CC rust-lang#50122, rust-lang#76360.
When a custom derive generates a closure, and that closure causes a compiler error because it borrows its environment instead of correctly moving it, rustc suggests to put the
move
keyword into the#[derive]
attribute:Actual error message I just got:
(this is happening in a rather convoluted production codebase, so unfortunately I don't have a test case yet)
If I'm not mistaken, this can only happen when the custom derive macro outputs incorrect code, so the impact is pretty limited.
The text was updated successfully, but these errors were encountered: