mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
6982785f18
The `impl_trait_overcaptures` lint is part of the migration to Rust 2024 and the Lifetime Capture Rules 2024. Now that we've stabilized precise capturing (RFC 3617), let's tie this lint to the `rust_2024_compatibility` lint group.
33 lines
989 B
Rust
33 lines
989 B
Rust
//@ run-rustfix
|
|
|
|
#![allow(unused)]
|
|
#![deny(impl_trait_overcaptures)]
|
|
|
|
fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x }
|
|
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
|
|
//~| WARN this changes meaning in Rust 2024
|
|
|
|
fn implicit(x: &i32) -> impl Sized + use<> { *x }
|
|
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
|
|
//~| WARN this changes meaning in Rust 2024
|
|
|
|
struct W;
|
|
impl W {
|
|
fn hello(&self, x: &i32) -> impl Sized + '_ + use<'_> { self }
|
|
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024
|
|
//~| WARN this changes meaning in Rust 2024
|
|
}
|
|
|
|
trait Higher<'a> {
|
|
type Output;
|
|
}
|
|
impl Higher<'_> for () {
|
|
type Output = ();
|
|
}
|
|
|
|
fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized + use<>> {}
|
|
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
|
|
//~| WARN this changes meaning in Rust 2024
|
|
|
|
fn main() {}
|