Skip to content

Commit bd3c781

Browse files
japaricRalfJung
authored andcommitted
use is_uninhabited in more places
1 parent f9bbb5f commit bd3c781

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/librustc/ty/layout.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
449449
}
450450
}
451451

452-
if sized && fields.iter().any(|f| f.abi == Abi::Uninhabited) {
452+
if sized && fields.iter().any(|f| f.abi.is_uninhabited()) {
453453
abi = Abi::Uninhabited;
454454
}
455455

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

875-
if st.iter().all(|v| v.abi == Abi::Uninhabited) {
875+
if st.iter().all(|v| v.abi.is_uninhabited()) {
876876
abi = Abi::Uninhabited;
877877
}
878878

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

1099-
if layout_variants.iter().all(|v| v.abi == Abi::Uninhabited) {
1099+
if layout_variants.iter().all(|v| v.abi.is_uninhabited()) {
11001100
abi = Abi::Uninhabited;
11011101
}
11021102

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ pub fn create_function_debug_context(
279279
}
280280
None => {}
281281
};
282-
if cx.layout_of(sig.output()).abi == ty::layout::Abi::Uninhabited {
282+
if cx.layout_of(sig.output()).abi.is_uninhabited() {
283283
flags = flags | DIFlags::FlagNoReturn;
284284
}
285285

src/librustc_codegen_llvm/declare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use llvm;
2424
use llvm::AttributePlace::Function;
2525
use rustc::ty::{self, Ty};
26-
use rustc::ty::layout::{self, LayoutOf};
26+
use rustc::ty::layout::LayoutOf;
2727
use rustc::session::config::Sanitizer;
2828
use rustc_data_structures::small_c_str::SmallCStr;
2929
use rustc_target::spec::PanicStrategy;
@@ -137,7 +137,7 @@ pub fn declare_fn(
137137
let fty = FnType::new(cx, sig, &[]);
138138
let llfn = declare_raw_fn(cx, name, fty.llvm_cconv(), fty.llvm_type(cx));
139139

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

src/librustc_codegen_llvm/mir/place.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl PlaceRef<'ll, 'tcx> {
275275
/// Obtain the actual discriminant of a value.
276276
pub fn codegen_get_discr(self, bx: &Builder<'a, 'll, 'tcx>, cast_to: Ty<'tcx>) -> &'ll Value {
277277
let cast_to = bx.cx.layout_of(cast_to).immediate_llvm_type(bx.cx);
278-
if self.layout.abi == layout::Abi::Uninhabited {
278+
if self.layout.abi.is_uninhabited() {
279279
return C_undef(cast_to);
280280
}
281281
match self.layout.variants {
@@ -338,7 +338,7 @@ impl PlaceRef<'ll, 'tcx> {
338338
/// Set the discriminant for a new value of the given case of the given
339339
/// representation.
340340
pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: usize) {
341-
if self.layout.for_variant(bx.cx, variant_index).abi == layout::Abi::Uninhabited {
341+
if self.layout.for_variant(bx.cx, variant_index).abi.is_uninhabited() {
342342
return;
343343
}
344344
match self.layout.variants {

src/librustc_codegen_llvm/mir/rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
290290
mir::CastKind::Misc => {
291291
assert!(cast.is_llvm_immediate());
292292
let ll_t_out = cast.immediate_llvm_type(bx.cx);
293-
if operand.layout.abi == layout::Abi::Uninhabited {
293+
if operand.layout.abi.is_uninhabited() {
294294
return (bx, OperandRef {
295295
val: OperandValue::Immediate(C_undef(ll_t_out)),
296296
layout: cast,

src/librustc_mir/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
514514
rval: OpTy<'tcx>,
515515
) -> EvalResult<'tcx, (u128, usize)> {
516516
trace!("read_discriminant_value {:#?}", rval.layout);
517-
if rval.layout.abi == layout::Abi::Uninhabited {
517+
if rval.layout.abi.is_uninhabited() {
518518
return err!(Unreachable);
519519
}
520520

0 commit comments

Comments
 (0)