-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Pick the largest niche even if the largest niche is wrapped around #144577
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 all commits
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 |
---|---|---|
|
@@ -107,8 +107,8 @@ impl abi::Integer { | |
abi::Integer::I8 | ||
}; | ||
|
||
// If there are no negative values, we can use the unsigned fit. | ||
if min >= 0 { | ||
// Pick the smallest fit. | ||
if unsigned_fit <= signed_fit { | ||
Comment on lines
-110
to
+111
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. This affected no tests on its own (but is needed for this PR, as previously it was assumed that min < max), but I think it is strictly better, I'm not expecting signed ops to be slower or anything 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. (Signed ops can actually optimize better, even, since 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. But yeah, if it's the same integer size either way it probably doesn't matter which is chosen. |
||
(cmp::max(unsigned_fit, at_least), false) | ||
} else { | ||
(cmp::max(signed_fit, at_least), true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Test that we produce the same niche range no | ||
//! matter of signendess if the discriminants are the same. | ||
|
||
#![feature(rustc_attrs)] | ||
|
||
#[repr(u16)] | ||
#[rustc_layout(debug)] | ||
enum UnsignedAroundZero { | ||
//~^ ERROR: layout_of | ||
A = 65535, | ||
B = 0, | ||
C = 1, | ||
} | ||
|
||
#[repr(i16)] | ||
#[rustc_layout(debug)] | ||
enum SignedAroundZero { | ||
//~^ ERROR: layout_of | ||
A = -1, | ||
B = 0, | ||
C = 1, | ||
} | ||
|
||
fn main() {} |
Uh oh!
There was an error while loading. Please reload this page.