-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add even more tests for ptr-to-ptr casts on trait objects
- Loading branch information
Lukas Markeffsky
committed
Sep 27, 2024
1 parent
a3f76a2
commit 8302f2e
Showing
4 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/ptr-to-trait-obj-ok.rs:39:5 | ||
| | ||
LL | fn cast_away_higher_ranked_wrap<'a>(x: *mut dyn for<'b> Trait<'b>) -> *mut Wrapper<dyn Trait<'a>> { | ||
| -- lifetime `'a` defined here | ||
LL | x as _ | ||
| ^^^^^^ returning this value requires that `'a` must outlive `'static` | ||
| | ||
= note: requirement occurs because of a mutable pointer to `Wrapper<dyn Trait<'_>>` | ||
= note: mutable pointers are invariant over their type parameter | ||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/ptr-to-trait-obj-ok.rs:39:5 | ||
| | ||
LL | x as _ | ||
| ^^^^^^ one type is more general than the other | ||
| | ||
= note: expected trait object `dyn for<'b> Trait<'b>` | ||
found trait object `dyn Trait<'_>` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |