rustc_lint::impl_trait_overcaptures

Static IMPL_TRAIT_REDUNDANT_CAPTURES

source
pub static IMPL_TRAIT_REDUNDANT_CAPTURES: &Lint
Expand description

The impl_trait_redundant_captures lint warns against cases where use of the precise capturing use<...> syntax is not needed.

In the 2024 edition, impl Traits will capture all lifetimes in scope. If precise-capturing use<...> syntax is used, and the set of parameters that are captures are equal to the set of parameters in scope, then the syntax is redundant, and can be removed.

§Example

fn test<'a>(x: &'a i32) -> impl Sized + use<'a> { x }

{{produces}}

§Explanation

To fix this, remove the use<'a>, since the lifetime is already captured since it is in scope.