forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#119175 - veera-sivarajan:fix-cast-to-slice, r=WaffleLapkin fix: diagnostic for casting reference to slice fixes: rust-lang#118790 Removes `if self.cast_ty.is_trait()` to produce the same diagnostic for cast to slice and trait.
- Loading branch information
Showing
5 changed files
with
45 additions
and
32 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,8 @@ | ||
fn main() { | ||
"example".as_bytes() as [char]; | ||
//~^ ERROR cast to unsized type | ||
|
||
let arr: &[u8] = &[0, 2, 3]; | ||
arr as [char]; | ||
//~^ ERROR cast to unsized type | ||
} |
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,19 @@ | ||
error[E0620]: cast to unsized type: `&[u8]` as `[char]` | ||
--> $DIR/cast-to-slice.rs:2:5 | ||
| | ||
LL | "example".as_bytes() as [char]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^------ | ||
| | | ||
| help: try casting to a reference instead: `&[char]` | ||
|
||
error[E0620]: cast to unsized type: `&[u8]` as `[char]` | ||
--> $DIR/cast-to-slice.rs:6:5 | ||
| | ||
LL | arr as [char]; | ||
| ^^^^^^^------ | ||
| | | ||
| help: try casting to a reference instead: `&[char]` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0620`. |
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