rust/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.0 KiB
Rust
Raw Normal View History

// issue: #111935
#![allow(unconditional_recursion)]
// Lt indirection is necessary to make the lifetime of the function late-bound,
// in order to bypass some other bugs.
type Lt<'lt> = Option<*mut &'lt ()>;
mod statik {
use super::*;
// invalid defining use: Opaque<'static> := ()
fn foo<'a>(_: Lt<'a>) -> impl Sized + 'a {
let _: () = foo(Lt::<'static>::None);
2024-03-22 08:02:12 +00:00
//~^ ERROR expected generic lifetime parameter, found `'static`
}
}
mod infer {
use super::*;
// invalid defining use: Opaque<'_> := ()
fn foo<'a>(_: Lt<'a>) -> impl Sized + 'a {
let _: () = foo(Lt::<'_>::None);
2024-03-18 16:03:18 +00:00
//~^ ERROR expected generic lifetime parameter, found `'_`
}
}
mod equal {
use super::*;
// invalid defining use: Opaque<'a, 'a> := ()
// because of the use of equal lifetimes in args
fn foo<'a, 'b>(_: Lt<'a>, _: Lt<'b>) -> impl Sized + 'a + 'b {
let _: () = foo(Lt::<'a>::None, Lt::<'a>::None);
2024-03-22 08:02:12 +00:00
//~^ ERROR non-defining opaque type use in defining scope
}
}
fn main() {}