-
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
fix failure to detect a too-big-type after adding padding #117277
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// build-fail | ||
// compile-flags: --target i686-unknown-linux-gnu --crate-type lib | ||
// needs-llvm-components: x86 | ||
#![feature(no_core, lang_items)] | ||
#![allow(internal_features)] | ||
#![no_std] | ||
#![no_core] | ||
|
||
// 0x7fffffff is fine, but after rounding up it becomes too big | ||
#[repr(C, align(2))] | ||
pub struct Example([u8; 0x7fffffff]); | ||
|
||
pub fn lib(_x: Example) {} //~ERROR: too big for the current architecture | ||
|
||
#[lang = "sized"] | ||
pub trait Sized {} | ||
#[lang = "copy"] | ||
pub trait Copy: Sized {} |
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 @@ | ||
error: values of the type `Example` are too big for the current architecture | ||
--> $DIR/too-big-with-padding.rs:13:1 | ||
| | ||
LL | pub fn lib(_x: Example) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
Oops, something went wrong.
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.
This feels like an arbitrary place. And now we have two of these checks. Can we instead do this in a single place before producing any
LayoutS
? Or maybe even makingalign_to
and other size operations fallible?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 don't understand the structure of this code, so I'm afraid I don't know where else to put it. This is in
univariant
which sounds reasonably canonical? The other one is somewhere in the enum code I think. 🤷 There's a lot of mutable state and important logic hidden in functions many hundred lines long -- the code is very hard to see through and I'm not about to do a complete refactor here.If you can tell me another place to put it I am happy yo move it, but me picking one random place after the other until you are happy does not sound like a good strategy. ;)
Currently Size has two kinds of operations -- some check the obj-size-bound and some don't. I don't know why, but maybe some part of the compiler needs to work with larger sizes? No idea.
I can make
align_to
take adl
so that it can do the check. But that makes little sense when Size implements*
and+
which can't do the check since they don't have adl
.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.
most of these are likely just ad-hoc
😆 I'm not sure where to put it either, needs experimentation. So... just leave a
FIXME(oli-obk): deduplicate and harden these checks
on both checksr=me with fixme comment