summary refs log tree commit diff
path: root/tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed
blob: 89a3f3136c82ab50d70647a74a3ab5163c79954a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//@ 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() {}