add known-bug test for unsound issue 84533
This commit is contained in:
parent
fbfb620de8
commit
cac62ab2dd
1 changed files with 37 additions and 0 deletions
37
tests/ui/fn/fn-item-lifetime-bounds.rs
Normal file
37
tests/ui/fn/fn-item-lifetime-bounds.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// check-pass
|
||||
// known-bug: #84533
|
||||
|
||||
// Should fail. Lifetimes are checked correctly when `foo` is called, but NOT
|
||||
// when only the lifetime parameters are instantiated.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn foo<'b, 'a>() -> PhantomData<&'b &'a ()> {
|
||||
PhantomData
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(path_statements)]
|
||||
fn caller<'b, 'a>() {
|
||||
foo::<'b, 'a>;
|
||||
}
|
||||
|
||||
// In contrast to above, below code correctly does NOT compile.
|
||||
// fn caller<'b, 'a>() {
|
||||
// foo::<'b, 'a>();
|
||||
// }
|
||||
|
||||
// error: lifetime may not live long enough
|
||||
// --> src/main.rs:22:5
|
||||
// |
|
||||
// 21 | fn caller<'b, 'a>() {
|
||||
// | -- -- lifetime `'a` defined here
|
||||
// | |
|
||||
// | lifetime `'b` defined here
|
||||
// 22 | foo::<'b, 'a>();
|
||||
// | ^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b`
|
||||
// |
|
||||
// = help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Reference in a new issue