forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#73965 - davidtwco:issue-73886-non-primitive…
…-slice-cast, r=estebank typeck: check for infer before type impls trait Fixes rust-lang#73886. This PR checks that the target type of the cast (an error related to which is being reported) does not have types to be inferred before checking if it implements the `From` trait. r? @estebank
- Loading branch information
Showing
3 changed files
with
22 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
let _ = &&[0] as &[_]; | ||
//~^ ERROR non-primitive cast: `&&[i32; 1]` as `&[_]` | ||
let _ = 7u32 as Option<_>; | ||
//~^ ERROR non-primitive cast: `u32` as `std::option::Option<_>` | ||
} |
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,15 @@ | ||
error[E0605]: non-primitive cast: `&&[i32; 1]` as `&[_]` | ||
--> $DIR/issue-73886.rs:2:13 | ||
| | ||
LL | let _ = &&[0] as &[_]; | ||
| ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | ||
|
||
error[E0605]: non-primitive cast: `u32` as `std::option::Option<_>` | ||
--> $DIR/issue-73886.rs:4:13 | ||
| | ||
LL | let _ = 7u32 as Option<_>; | ||
| ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0605`. |