Tracking:
Given this code:
trait AnyL<'x> {}
fn f<'long: 'short, 'short>(
x: *const dyn AnyL<'long>,
) -> *const dyn AnyL<'short> {
x as *const dyn AnyL<'short>
}
Our diagnostic, after #136776, reports:
error: lifetime may not live long enough
--> src/main.rs:7:5
|
4 | fn f<'long: 'short, 'short>(
| ----- ------ lifetime `'short` defined here
| |
| lifetime `'long` defined here
...
7 | x as *const dyn AnyL<'short>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'short` must outlive `'long`
|
= help: consider adding the following bound: `'short: 'long`
note: raw pointer casts of trait objects cannot extend lifetimes
--> src/main.rs:7:5
|
7 | x as *const dyn AnyL<'short>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this was previously accepted by the compiler but was changed recently
= help: see <https://github.com/rust-lang/rust/issues/141402> for more information
It says this was previously accepted, but as far as I know, it never was. I tested it in Rust 1.0, Rust 1.85, and in various other version. It was rejected in the versions I tested.
Related:
cc @BoxyUwU @Darksonn @ehuss
Tracking:
Given this code:
Our diagnostic, after #136776, reports:
It says this was previously accepted, but as far as I know, it never was. I tested it in Rust 1.0, Rust 1.85, and in various other version. It was rejected in the versions I tested.
Related:
cc @BoxyUwU @Darksonn @ehuss