-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Always error on SizeOverflow
during mir evaluation
#63152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
83b5eb9
58bd878
d3da411
2c56842
db099fb
2340067
387dcff
bdd79b8
f621f89
ce8510a
613c0a8
64469ac
3144b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// error-pattern: reaching this expression at runtime will panic or abort | ||
fn main() { | ||
println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0080]: reaching this expression at runtime will panic or abort | ||
--> $SRC_DIR/libcore/mem/mod.rs:LL:COL | ||
| | ||
LL | intrinsics::size_of::<T>() | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 18446744073709551615]` is too big for the current architecture | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine merging as is with a FIXME in place for adding a useful (not duplicated) note here. It's likely a bit involeved in the const eval engine, since the way I'm imagining it requires annotating every layout_of call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I thought about that too and came to the same conclusion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I have a way to make a separate label that won't be too hacky. What do you think a good wording for this error would be/what the end result should look like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that there are many situations in const eval that compute layouts and could thus fail. I think we should label each with their own message. If we hardcode a message for just this case it will be nonsensical in all other cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just removed the label altogether and left the main message only |
||
| | ||
::: $DIR/issue-55878.rs:3:26 | ||
| | ||
LL | println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>()); | ||
| --------------------------------------------------- | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
error: the type `[u8; 2305843009213693951]` is too big for the current architecture | ||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/issue-56762.rs:19:1 | ||
| | ||
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture | ||
|
||
error: aborting due to previous error | ||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/issue-56762.rs:21:1 | ||
| | ||
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
Uh oh!
There was an error while loading. Please reload this page.