|
| 1 | +error[E0606]: casting `*mut (dyn Trait + Send + 'a)` as `*mut Wrapper<(dyn Send + 'b)>` is invalid |
| 2 | + --> $DIR/ptr-to-ptr-principalless.rs:63:5 |
| 3 | + | |
| 4 | +LL | x as _ |
| 5 | + | ^^^^^^ |
| 6 | + | |
| 7 | + = note: the trait objects may have different vtables |
| 8 | + |
| 9 | +error[E0606]: casting `*mut (dyn Trait + Send + 'a)` as `*mut Wrapper<(dyn Send + 'static)>` is invalid |
| 10 | + --> $DIR/ptr-to-ptr-principalless.rs:70:5 |
| 11 | + | |
| 12 | +LL | x as _ |
| 13 | + | ^^^^^^ |
| 14 | + | |
| 15 | + = note: the trait objects may have different vtables |
| 16 | + |
1 | 17 | error: lifetime may not live long enough |
2 | 18 | --> $DIR/ptr-to-ptr-principalless.rs:8:5 |
3 | 19 | | |
@@ -202,5 +218,57 @@ LL - fn unprincipled_wrap2_static<'a>(x: *mut (dyn Send + 'a)) -> *mut Wrapper<d |
202 | 218 | LL + fn unprincipled_wrap2_static<'a>(x: *mut (dyn Send + 'static)) -> *mut Wrapper<dyn Sync + 'static> { |
203 | 219 | | |
204 | 220 |
|
205 | | -error: aborting due to 8 previous errors |
| 221 | +error: lifetime may not live long enough |
| 222 | + --> $DIR/ptr-to-ptr-principalless.rs:53:5 |
| 223 | + | |
| 224 | +LL | fn unprincipled3<'a, 'b>(x: *mut (dyn Trait + Send + 'a)) -> *mut (dyn Send + 'b) { |
| 225 | + | -- -- lifetime `'b` defined here |
| 226 | + | | |
| 227 | + | lifetime `'a` defined here |
| 228 | +LL | x as _ |
| 229 | + | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` |
| 230 | + | |
| 231 | + = help: consider adding the following bound: `'a: 'b` |
| 232 | + = note: requirement occurs because of a mutable pointer to `dyn Send` |
| 233 | + = note: mutable pointers are invariant over their type parameter |
| 234 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 235 | +note: raw pointer casts of trait objects do not cast away lifetimes |
| 236 | + --> $DIR/ptr-to-ptr-principalless.rs:53:5 |
| 237 | + | |
| 238 | +LL | x as _ |
| 239 | + | ^^^^^^ |
| 240 | + = note: this was previously accepted by the compiler but was changed recently |
| 241 | + = help: see <https://github.com/rust-lang/rust/issues/141402> for more information |
| 242 | + |
| 243 | +error: lifetime may not live long enough |
| 244 | + --> $DIR/ptr-to-ptr-principalless.rs:58:5 |
| 245 | + | |
| 246 | +LL | fn unprincipled3_static<'a>(x: *mut (dyn Trait + Send + 'a)) -> *mut (dyn Send + 'static) { |
| 247 | + | -- lifetime `'a` defined here |
| 248 | +LL | x as _ |
| 249 | + | ^^^^^^ returning this value requires that `'a` must outlive `'static` |
| 250 | + | |
| 251 | + = note: requirement occurs because of a mutable pointer to `dyn Send` |
| 252 | + = note: mutable pointers are invariant over their type parameter |
| 253 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 254 | +note: raw pointer casts of trait objects do not cast away lifetimes |
| 255 | + --> $DIR/ptr-to-ptr-principalless.rs:58:5 |
| 256 | + | |
| 257 | +LL | x as _ |
| 258 | + | ^^^^^^ |
| 259 | + = note: this was previously accepted by the compiler but was changed recently |
| 260 | + = help: see <https://github.com/rust-lang/rust/issues/141402> for more information |
| 261 | +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` |
| 262 | + | |
| 263 | +LL - fn unprincipled3_static<'a>(x: *mut (dyn Trait + Send + 'a)) -> *mut (dyn Send + 'static) { |
| 264 | +LL + fn unprincipled3_static<'a>(x: *mut (dyn Trait + Send + 'a)) -> *mut (dyn Send + 'a) { |
| 265 | + | |
| 266 | +help: alternatively, add an explicit `'static` bound to this reference |
| 267 | + | |
| 268 | +LL - fn unprincipled3_static<'a>(x: *mut (dyn Trait + Send + 'a)) -> *mut (dyn Send + 'static) { |
| 269 | +LL + fn unprincipled3_static<'a>(x: *mut (dyn Trait + Send + 'static)) -> *mut (dyn Send + 'static) { |
| 270 | + | |
| 271 | + |
| 272 | +error: aborting due to 12 previous errors |
206 | 273 |
|
| 274 | +For more information about this error, try `rustc --explain E0606`. |
0 commit comments