add another test

This commit is contained in:
Lukas Markeffsky 2024-09-10 21:41:50 +02:00
parent 46ecb23198
commit b52dea8230
2 changed files with 14 additions and 1 deletions

View File

@ -33,5 +33,10 @@ fn change_assoc_1<'a, 'b>(
//~| error: lifetime may not live long enough
}
// This tests the default borrow check error, without the special casing for return values.
fn require_static(_: *const dyn Trait<'static>) {}
fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) {
require_static(ptr as _) //~ error: lifetime may not live long enough
}
fn main() {}

View File

@ -132,5 +132,13 @@ help: `'b` and `'a` must be the same: replace one with the other
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 8 previous errors
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39:20
|
LL | fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) {
| -- lifetime `'a` defined here
LL | require_static(ptr as _)
| ^^^ cast requires that `'a` must outlive `'static`
error: aborting due to 9 previous errors