Skip to content

Commit 0190f27

Browse files
committed
rustc_trans: check for layout::I1 instead of TyBool.
1 parent abbc1dd commit 0190f27

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/librustc_trans/abi.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -695,17 +695,15 @@ impl<'a, 'tcx> FnType<'tcx> {
695695

696696
let arg_of = |ty: Ty<'tcx>, is_return: bool| {
697697
let mut arg = ArgType::new(ccx.layout_of(ty));
698-
if ty.is_bool() {
698+
if let layout::Abi::Scalar(layout::Int(layout::I1, _)) = arg.layout.abi {
699699
arg.attrs.set(ArgAttribute::ZExt);
700-
} else {
701-
if arg.layout.is_zst() {
702-
// For some forsaken reason, x86_64-pc-windows-gnu
703-
// doesn't ignore zero-sized struct arguments.
704-
// The same is true for s390x-unknown-linux-gnu.
705-
if is_return || rust_abi ||
706-
(!win_x64_gnu && !linux_s390x) {
707-
arg.ignore();
708-
}
700+
} else if arg.layout.is_zst() {
701+
// For some forsaken reason, x86_64-pc-windows-gnu
702+
// doesn't ignore zero-sized struct arguments.
703+
// The same is true for s390x-unknown-linux-gnu.
704+
if is_return || rust_abi ||
705+
(!win_x64_gnu && !linux_s390x) {
706+
arg.ignore();
709707
}
710708
}
711709
arg

src/librustc_trans/mir/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use llvm::{self, ValueRef, BasicBlockRef};
1212
use rustc::middle::lang_items;
1313
use rustc::middle::const_val::{ConstEvalErr, ConstInt, ErrKind};
1414
use rustc::ty::{self, TypeFoldable};
15-
use rustc::ty::layout::LayoutOf;
15+
use rustc::ty::layout::{self, LayoutOf};
1616
use rustc::traits;
1717
use rustc::mir;
1818
use abi::{Abi, FnType, ArgType};
@@ -673,7 +673,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
673673
} else {
674674
llval = bcx.load(llval, align.non_abi());
675675
}
676-
if arg.layout.ty == bcx.tcx().types.bool {
676+
if let layout::Abi::Scalar(layout::Int(layout::I1, _)) = arg.layout.abi {
677677
bcx.range_metadata(llval, 0..2);
678678
// We store bools as i8 so we need to truncate to i1.
679679
llval = base::to_immediate(bcx, llval, arg.layout);

src/librustc_trans/mir/constant.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
454454
span_bug!(span, "dereference of non-constant pointer `{:?}`",
455455
Value(base));
456456
}
457-
if projected_ty.is_bool() {
457+
let layout = self.ccx.layout_of(projected_ty);
458+
if let layout::Abi::Scalar(layout::Int(layout::I1, _)) = layout.abi {
458459
let i1_type = Type::i1(self.ccx);
459460
if val_ty(val) != i1_type {
460461
unsafe {

0 commit comments

Comments
 (0)