-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #103699 - compiler-errors:dyn-star-cast-bad, r=TaKO8Ki
Emit proper error when casting to `dyn*` Fixes #103679
- Loading branch information
Showing
5 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use std::fmt::Debug; | ||
|
||
fn make_dyn_star() { | ||
let i = 42usize; | ||
let dyn_i: dyn* Debug = i as dyn* Debug; | ||
//~^ ERROR casting `usize` as `dyn* Debug` is invalid | ||
//~| ERROR dyn* trait objects are unstable | ||
//~| ERROR dyn* trait objects are unstable | ||
} | ||
|
||
fn main() { | ||
make_dyn_star(); | ||
} |
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,28 @@ | ||
error[E0658]: dyn* trait objects are unstable | ||
--> $DIR/no-explicit-dyn-star-cast.rs:5:16 | ||
| | ||
LL | let dyn_i: dyn* Debug = i as dyn* Debug; | ||
| ^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(dyn_star)]` to the crate attributes to enable | ||
|
||
error[E0658]: dyn* trait objects are unstable | ||
--> $DIR/no-explicit-dyn-star-cast.rs:5:34 | ||
| | ||
LL | let dyn_i: dyn* Debug = i as dyn* Debug; | ||
| ^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= help: add `#![feature(dyn_star)]` to the crate attributes to enable | ||
|
||
error[E0606]: casting `usize` as `dyn* Debug` is invalid | ||
--> $DIR/no-explicit-dyn-star-cast.rs:5:29 | ||
| | ||
LL | let dyn_i: dyn* Debug = i as dyn* Debug; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0606, E0658. | ||
For more information about an error, try `rustc --explain E0606`. |
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,8 @@ | ||
// aux-build:dyn-star-foreign.rs | ||
|
||
extern crate dyn_star_foreign; | ||
|
||
fn main() { | ||
dyn_star_foreign::require_dyn_star_display(1usize as _); | ||
//~^ ERROR casting `usize` as `dyn* std::fmt::Display` is invalid | ||
} |
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,9 @@ | ||
error[E0606]: casting `usize` as `dyn* std::fmt::Display` is invalid | ||
--> $DIR/no-explicit-dyn-star.rs:6:48 | ||
| | ||
LL | dyn_star_foreign::require_dyn_star_display(1usize as _); | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0606`. |