-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Always error on SizeOverflow
during mir evaluation
#63152
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
83b5eb9
Always error on `SizeOverflow` during mir evaluation
estebank 58bd878
Do not lint on SizeOverflow, always error
estebank d3da411
Nicer labels for type layout errors
estebank 2c56842
avoid mutable state and override main message
estebank db099fb
Point to local place span on "type too big" error
estebank 2340067
Simplify change to layout_of
estebank 387dcff
review comments: clean up
estebank bdd79b8
tweak output and tests
estebank f621f89
revert change to single test
estebank ce8510a
fix tests
estebank 613c0a8
move error with diverging output to compile-fail
estebank 64469ac
review comments
estebank 3144b0a
review comment: reword test comment
estebank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,4 @@ | ||
// error-pattern: the type `[u8; 18446744073709551615]` is too big for the current architecture | ||
fn main() { | ||
println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>()); | ||
} |
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,14 @@ | ||
error[E0080]: the type `[u8; 18446744073709551615]` is too big for the current architecture | ||
--> $SRC_DIR/libcore/mem/mod.rs:LL:COL | ||
| | ||
LL | intrinsics::size_of::<T>() | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
::: $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`. |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
error: the type `[u8; N]` is too big for the current architecture | ||
--> $DIR/huge-array-simple.rs:12:9 | ||
| | ||
LL | let _fat : [u8; (1<<61)+(1<<31)] = | ||
| ^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
error: the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture | ||
--> $DIR/huge-array.rs:6:9 | ||
| | ||
LL | let s: [T; 1518600000] = [t; 1518600000]; | ||
| ^ | ||
|
||
error: aborting due to previous error | ||
|
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
// normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE" | ||
estebank marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// normalize-stderr-test "\[u32; \d+\]" -> "TYPE" | ||
|
||
// FIXME https://github.com/rust-lang/rust/issues/59774 | ||
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" | ||
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" | ||
|
||
#[cfg(target_pointer_width = "32")] | ||
fn main() { | ||
let big: Option<[u32; (1<<29)-1]> = None; | ||
} | ||
type BIG = Option<[u32; (1<<29)-1]>; | ||
|
||
#[cfg(target_pointer_width = "64")] | ||
type BIG = Option<[u32; (1<<45)-1]>; | ||
|
||
fn main() { | ||
let big: Option<[u32; (1<<45)-1]> = None; | ||
let big: BIG = None; | ||
//~^ ERROR is too big for the current architecture | ||
} |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
error: the type `TYPE` is too big for the current architecture | ||
error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture | ||
--> $DIR/huge-enum.rs:12:9 | ||
| | ||
LL | let big: BIG = None; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
error: the type `SXX<SXX<SXX<u32>>>` is too big for the current architecture | ||
--> $DIR/huge-struct.rs:49:9 | ||
| | ||
LL | let fat: Option<SXX<SXX<SXX<u32>>>> = None; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
error: the type `[usize; N]` is too big for the current architecture | ||
--> $DIR/issue-15919.rs:15:9 | ||
| | ||
LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; | ||
| ^ | ||
|
||
error: aborting due to previous error | ||
|
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
error: the type `[u8; 2305843009213693951]` is too big for the current architecture | ||
error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture | ||
--> $DIR/issue-56762.rs:19:1 | ||
| | ||
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture | ||
--> $DIR/issue-56762.rs:21:1 | ||
| | ||
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That span isn't ideal, but it's hard to do better in the MIR, especially as there may be no HIR local in the case of temporaries. Not sure what to do about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but at the same time it's a huge improvement over the current "good luck finding where the problem is" state of this error.