Skip to content

Commit

Permalink
use is_uninhabited in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric authored and RalfJung committed Sep 30, 2018
1 parent f9bbb5f commit bd3c781
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/librustc/ty/layout.rs
Expand Up @@ -449,7 +449,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
}
}

if sized && fields.iter().any(|f| f.abi == Abi::Uninhabited) {
if sized && fields.iter().any(|f| f.abi.is_uninhabited()) {
abi = Abi::Uninhabited;
}

Expand Down Expand Up @@ -724,7 +724,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
// See issue #49298 for more details on the need to leave space
// for non-ZST uninhabited data (mostly partial initialization).
let absent = |fields: &[TyLayout<'_>]| {
let uninhabited = fields.iter().any(|f| f.abi == Abi::Uninhabited);
let uninhabited = fields.iter().any(|f| f.abi.is_uninhabited());
let is_zst = fields.iter().all(|f| f.is_zst());
uninhabited && is_zst
};
Expand Down Expand Up @@ -872,7 +872,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
_ => Abi::Aggregate { sized: true },
};

if st.iter().all(|v| v.abi == Abi::Uninhabited) {
if st.iter().all(|v| v.abi.is_uninhabited()) {
abi = Abi::Uninhabited;
}

Expand Down Expand Up @@ -900,7 +900,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
let discr_type = def.repr.discr_type();
let bits = Integer::from_attr(tcx, discr_type).size().bits();
for (i, discr) in def.discriminants(tcx).enumerate() {
if variants[i].iter().any(|f| f.abi == Abi::Uninhabited) {
if variants[i].iter().any(|f| f.abi.is_uninhabited()) {
continue;
}
let mut x = discr.val as i128;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
}
}

if layout_variants.iter().all(|v| v.abi == Abi::Uninhabited) {
if layout_variants.iter().all(|v| v.abi.is_uninhabited()) {
abi = Abi::Uninhabited;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/mod.rs
Expand Up @@ -279,7 +279,7 @@ pub fn create_function_debug_context(
}
None => {}
};
if cx.layout_of(sig.output()).abi == ty::layout::Abi::Uninhabited {
if cx.layout_of(sig.output()).abi.is_uninhabited() {
flags = flags | DIFlags::FlagNoReturn;
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/declare.rs
Expand Up @@ -23,7 +23,7 @@
use llvm;
use llvm::AttributePlace::Function;
use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, LayoutOf};
use rustc::ty::layout::LayoutOf;
use rustc::session::config::Sanitizer;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_target::spec::PanicStrategy;
Expand Down Expand Up @@ -137,7 +137,7 @@ pub fn declare_fn(
let fty = FnType::new(cx, sig, &[]);
let llfn = declare_raw_fn(cx, name, fty.llvm_cconv(), fty.llvm_type(cx));

if cx.layout_of(sig.output()).abi == layout::Abi::Uninhabited {
if cx.layout_of(sig.output()).abi.is_uninhabited() {
llvm::Attribute::NoReturn.apply_llfn(Function, llfn);
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/mir/place.rs
Expand Up @@ -275,7 +275,7 @@ impl PlaceRef<'ll, 'tcx> {
/// Obtain the actual discriminant of a value.
pub fn codegen_get_discr(self, bx: &Builder<'a, 'll, 'tcx>, cast_to: Ty<'tcx>) -> &'ll Value {
let cast_to = bx.cx.layout_of(cast_to).immediate_llvm_type(bx.cx);
if self.layout.abi == layout::Abi::Uninhabited {
if self.layout.abi.is_uninhabited() {
return C_undef(cast_to);
}
match self.layout.variants {
Expand Down Expand Up @@ -338,7 +338,7 @@ impl PlaceRef<'ll, 'tcx> {
/// Set the discriminant for a new value of the given case of the given
/// representation.
pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: usize) {
if self.layout.for_variant(bx.cx, variant_index).abi == layout::Abi::Uninhabited {
if self.layout.for_variant(bx.cx, variant_index).abi.is_uninhabited() {
return;
}
match self.layout.variants {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mir/rvalue.rs
Expand Up @@ -290,7 +290,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
mir::CastKind::Misc => {
assert!(cast.is_llvm_immediate());
let ll_t_out = cast.immediate_llvm_type(bx.cx);
if operand.layout.abi == layout::Abi::Uninhabited {
if operand.layout.abi.is_uninhabited() {
return (bx, OperandRef {
val: OperandValue::Immediate(C_undef(ll_t_out)),
layout: cast,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/operand.rs
Expand Up @@ -514,7 +514,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
rval: OpTy<'tcx>,
) -> EvalResult<'tcx, (u128, usize)> {
trace!("read_discriminant_value {:#?}", rval.layout);
if rval.layout.abi == layout::Abi::Uninhabited {
if rval.layout.abi.is_uninhabited() {
return err!(Unreachable);
}

Expand Down

0 comments on commit bd3c781

Please sign in to comment.