1
Fork 0
rust/tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed

30 lines
861 B
Rust
Raw Normal View History

2024-04-21 11:27:27 -04:00
//@ run-rustfix
#![feature(precise_capturing)]
#![allow(unused, incomplete_features)]
#![deny(impl_trait_overcaptures)]
2024-06-05 16:18:52 -04:00
fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x }
2024-04-21 11:27:27 -04:00
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
2024-06-05 16:18:52 -04:00
fn implicit(x: &i32) -> impl Sized + use<> { *x }
2024-04-21 11:27:27 -04:00
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
struct W;
impl W {
2024-06-05 16:18:52 -04:00
fn hello(&self, x: &i32) -> impl Sized + '_ + use<'_> { self }
2024-04-21 11:27:27 -04:00
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024
}
trait Higher<'a> {
type Output;
}
impl Higher<'_> for () {
type Output = ();
}
2024-06-05 16:18:52 -04:00
fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized + use<>> {}
2024-04-21 11:27:27 -04:00
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
fn main() {}