And finally add tests
This commit is contained in:
parent
1529c661e4
commit
052de1da4f
4 changed files with 207 additions and 15 deletions
29
tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs
Normal file
29
tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
//@ run-rustfix
|
||||
|
||||
#![feature(precise_capturing)]
|
||||
#![allow(unused, incomplete_features)]
|
||||
#![deny(impl_trait_overcaptures)]
|
||||
|
||||
fn named<'a>(x: &'a i32) -> impl Sized { *x }
|
||||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
|
||||
|
||||
fn implicit(x: &i32) -> impl Sized { *x }
|
||||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
|
||||
|
||||
struct W;
|
||||
impl W {
|
||||
fn hello(&self, x: &i32) -> impl Sized + '_ { self }
|
||||
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024
|
||||
}
|
||||
|
||||
trait Higher<'a> {
|
||||
type Output;
|
||||
}
|
||||
impl Higher<'_> for () {
|
||||
type Output = ();
|
||||
}
|
||||
|
||||
fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {}
|
||||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue