-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
single_use_lifetimes
warns when deriving a struct
#53738
Comments
I tried to I'd almost change built-in deriving to not declare the lifetimes explicitly but I suspect that wouldn't work when using |
Add deny(unused_lifetimes) to all the crates that have deny(internal). @Zoxc brought up, regarding #61722, that we don't force the removal of unused lifetimes. Turns out that it's not that bad to enable for compiler crates (I wonder why it's not `warn` by default?). I would've liked to enable `single_use_lifetimes` as well, but #53738 makes it unusable for now. For the `rustfmt` commit, I used rust-lang/rustfmt#1324 (comment), and manually filtered out some noise. r? @oli-obk cc @rust-lang/compiler
cc #44752 |
I don't think this seems high priority. I'll leave it nominated but I'm prioritizing it as P-medium. |
The problem is that the above code expands to something similar to #![feature(in_band_lifetimes)]
#![warn(single_use_lifetimes)]
trait Foo {}
struct Bar<'a>(&'a i32);
impl Foo for Bar<'a> {} which correctly warns for the We may either just want to not trigger in derive expansions or explicitly allow this lint in derives expansions. |
advertised at T-compiler meeting. removing nomination tag. |
I'm going to ping @zackmdavis in the hopes that they have a bit of time to look into this. My sense is that we ought to make a plan to finish up the Rust 2018 idiom lints -- but at the same time it's hard to justify a P-high label just now. |
I tried an approach where I would look at the lifetime span to see if it came from a compiler desugaring, but the derived code doesn't keep any information about their context. A different approach will be needed in the parse step to make sure the debug subparser produced spans are appropriately marked. I won't have time to dig deeper, but wanted to share what I found. |
@estebank AFAIK there's a perma-unstable attribute that is placed on derived @pnkfelix I should've given more context - it'd be good to fix this because it would unblock something like #61735, but likely removing a far larger number of lifetimes, which may simplify e.g. the |
|
in which we decline to lint single-use lifetimes in `derive`d impls Resolves rust-lang#53738. r? @eddyb
in which we decline to lint single-use lifetimes in `derive`d impls Resolves rust-lang#53738. r? @eddyb
in which we decline to lint single-use lifetimes in `derive`d impls Resolves rust-lang#53738. r? @eddyb
in which we decline to lint single-use lifetimes in `derive`d impls Resolves rust-lang#53738. r? @eddyb
@zackmdavis This seems to have regressed.
produces the following warning
|
This causes a spurious single_use_lifetimes warning, see rust-lang/rust#53738
It doesn't work. See: rust-lang/rust#53738 (comment)
* ci: deny multiple allow-by-default lints * chore: add a changelog * fix: wrong indentation * ci: allow `single_use_lifetimes` It doesn't work. See: rust-lang/rust#53738 (comment)
When compiling
this warning is generated:
I think,
#[automatically_derived]
in theDebug
derive does not consider this lint.The text was updated successfully, but these errors were encountered: