diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-01-30 13:36:41 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-30 13:36:41 +0900 |
| commit | a5c12ea75f18232eef4721a1a20210f5f2c25b75 (patch) | |
| tree | ece2235b8f05cfdb3c19abaf74aa3df073f7f44d | |
| parent | ecd7cb1c3ab5d7e7b10f934a561b8a6958bcd1b0 (diff) | |
| parent | 915a04e2a401919d8b0e152331c839df471577b7 (diff) | |
| download | rust-a5c12ea75f18232eef4721a1a20210f5f2c25b75.tar.gz rust-a5c12ea75f18232eef4721a1a20210f5f2c25b75.zip | |
Rollup merge of #80562 - nagisa:nagisa/bools-are-unsigned, r=eddyb
Consider Scalar to be a bool only if its unsigned This seems right, given that conceptually bools are unsigned, but the implications of this change may have more action at distance that I'm not sure how to exhaustively consider. For instance there are a number of cases where code attaches range metadata if `scalar.is_bool()` holds. Supposedly it would no longer be attached to the `repr(i8)` enums? Though I'm not sure why booleans are being special-cased here in the first place... Fixes #80556 cc `@eddyb`
| -rw-r--r-- | compiler/rustc_target/src/abi/call/mod.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_target/src/abi/mod.rs | 2 | ||||
| -rw-r--r-- | src/test/codegen/abi-repr-ext.rs | 13 |
3 files changed, 20 insertions, 2 deletions
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index aa1c31bda54..ce8e56b1949 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -103,7 +103,12 @@ impl ArgAttributes { } pub fn ext(&mut self, ext: ArgExtension) -> &mut Self { - assert!(self.arg_ext == ArgExtension::None || self.arg_ext == ext); + assert!( + self.arg_ext == ArgExtension::None || self.arg_ext == ext, + "cannot set {:?} when {:?} is already set", + ext, + self.arg_ext + ); self.arg_ext = ext; self } diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 88b2923f6c4..b14b1ef00db 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -682,7 +682,7 @@ pub struct Scalar { impl Scalar { pub fn is_bool(&self) -> bool { - if let Int(I8, _) = self.value { self.valid_range == (0..=1) } else { false } + matches!(self.value, Int(I8, false)) && self.valid_range == (0..=1) } /// Returns the valid range as a `x..y` range. diff --git a/src/test/codegen/abi-repr-ext.rs b/src/test/codegen/abi-repr-ext.rs new file mode 100644 index 00000000000..f93ccd79411 --- /dev/null +++ b/src/test/codegen/abi-repr-ext.rs @@ -0,0 +1,13 @@ +#![crate_type="lib"] + +#[repr(i8)] +pub enum Type { + Type1 = 0, + Type2 = 1 +} + +// CHECK: define signext i8 @test() +#[no_mangle] +pub extern "C" fn test() -> Type { + Type::Type1 +} |
