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 +}