Skip to content
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

Consider Scalar to be a bool only if its unsigned #80562

Merged
merged 1 commit into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/rustc_target/src/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions src/test/codegen/abi-repr-ext.rs
Original file line number Diff line number Diff line change
@@ -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
}