-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #115529 - chenyukang:yukang-fix-115402-overflowsize, r=…
…compiler-errors Fix error report for size overflow from transmute Fixes #115402 The span in the error reporting always points to the `dst`, this is an old issue, I may open another PR to fix it.
- Loading branch information
Showing
6 changed files
with
79 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
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,27 @@ | ||
#![crate_type = "lib"] | ||
#![feature(transmutability)] | ||
mod assert { | ||
use std::mem::BikeshedIntrinsicFrom; | ||
struct Context; | ||
|
||
pub fn is_maybe_transmutable<Src, Dst>() | ||
where | ||
Dst: BikeshedIntrinsicFrom<Src, Context>, | ||
{ | ||
} | ||
} | ||
|
||
fn main() { | ||
pub union Uninit { | ||
a: [u8; usize::MAX], | ||
} | ||
|
||
#[repr(C)] | ||
struct ExplicitlyPadded(Uninit); | ||
|
||
assert::is_maybe_transmutable::<(), ExplicitlyPadded>(); | ||
//~^ ERROR `()` cannot be safely transmuted into `ExplicitlyPadded` | ||
|
||
assert::is_maybe_transmutable::<ExplicitlyPadded, ()>(); | ||
//~^ ERROR `ExplicitlyPadded` cannot be safely transmuted into `()` | ||
} |
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,33 @@ | ||
error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded` in the defining scope of `assert::Context` | ||
--> $DIR/issue-115402-overflow-size.rs:22:41 | ||
| | ||
LL | assert::is_maybe_transmutable::<(), ExplicitlyPadded>(); | ||
| ^^^^^^^^^^^^^^^^ values of the type `ExplicitlyPadded` are too big for the current architecture | ||
| | ||
note: required by a bound in `is_maybe_transmutable` | ||
--> $DIR/issue-115402-overflow-size.rs:9:14 | ||
| | ||
LL | pub fn is_maybe_transmutable<Src, Dst>() | ||
| --------------------- required by a bound in this function | ||
LL | where | ||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` | ||
|
||
error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` in the defining scope of `assert::Context` | ||
--> $DIR/issue-115402-overflow-size.rs:25:55 | ||
| | ||
LL | assert::is_maybe_transmutable::<ExplicitlyPadded, ()>(); | ||
| ^^ values of the type `ExplicitlyPadded` are too big for the current architecture | ||
| | ||
note: required by a bound in `is_maybe_transmutable` | ||
--> $DIR/issue-115402-overflow-size.rs:9:14 | ||
| | ||
LL | pub fn is_maybe_transmutable<Src, Dst>() | ||
| --------------------- required by a bound in this function | ||
LL | where | ||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |