Lint overcapturing in impl Trait on 2024 edition #131943
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
(empty)
Desired output
A warning, like one produced by
impl_trait_overcaptures
.Rationale and extra context
Currently,
impl_trait_overcaptures
lints code that would be overcapturing in edition = 2024 on editions < 2024. I think it would be valuable to add a (maybe allow-by-default) lint to detect overcapturing in new, edition 2024 code. Code like this is probably not meant to capture lifetime ofx
, so linting against this may help to avoid too-strict signatures. If the function was meant to be stricter than necessary (e.g. for future-compat reasons), you can always just#[allow]
the lint.Rust Version
Anything else?
Alternatively, this could be a Clippy lint. Having it in rustc could probably allow code reuse with the edition lint though.
The text was updated successfully, but these errors were encountered: