mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 19:17:43 +00:00
use is_uninhabited in more places
This commit is contained in:
parent
f9bbb5f31d
commit
bd3c7812cb
@ -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;
|
abi = Abi::Uninhabited;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
// See issue #49298 for more details on the need to leave space
|
||||||
// for non-ZST uninhabited data (mostly partial initialization).
|
// for non-ZST uninhabited data (mostly partial initialization).
|
||||||
let absent = |fields: &[TyLayout<'_>]| {
|
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());
|
let is_zst = fields.iter().all(|f| f.is_zst());
|
||||||
uninhabited && is_zst
|
uninhabited && is_zst
|
||||||
};
|
};
|
||||||
@ -872,7 +872,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||||||
_ => Abi::Aggregate { sized: true },
|
_ => 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;
|
abi = Abi::Uninhabited;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,7 +900,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||||||
let discr_type = def.repr.discr_type();
|
let discr_type = def.repr.discr_type();
|
||||||
let bits = Integer::from_attr(tcx, discr_type).size().bits();
|
let bits = Integer::from_attr(tcx, discr_type).size().bits();
|
||||||
for (i, discr) in def.discriminants(tcx).enumerate() {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
let mut x = discr.val as i128;
|
let mut x = discr.val as i128;
|
||||||
@ -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;
|
abi = Abi::Uninhabited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ pub fn create_function_debug_context(
|
|||||||
}
|
}
|
||||||
None => {}
|
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;
|
flags = flags | DIFlags::FlagNoReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
use llvm;
|
use llvm;
|
||||||
use llvm::AttributePlace::Function;
|
use llvm::AttributePlace::Function;
|
||||||
use rustc::ty::{self, Ty};
|
use rustc::ty::{self, Ty};
|
||||||
use rustc::ty::layout::{self, LayoutOf};
|
use rustc::ty::layout::LayoutOf;
|
||||||
use rustc::session::config::Sanitizer;
|
use rustc::session::config::Sanitizer;
|
||||||
use rustc_data_structures::small_c_str::SmallCStr;
|
use rustc_data_structures::small_c_str::SmallCStr;
|
||||||
use rustc_target::spec::PanicStrategy;
|
use rustc_target::spec::PanicStrategy;
|
||||||
@ -137,7 +137,7 @@ pub fn declare_fn(
|
|||||||
let fty = FnType::new(cx, sig, &[]);
|
let fty = FnType::new(cx, sig, &[]);
|
||||||
let llfn = declare_raw_fn(cx, name, fty.llvm_cconv(), fty.llvm_type(cx));
|
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);
|
llvm::Attribute::NoReturn.apply_llfn(Function, llfn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ impl PlaceRef<'ll, 'tcx> {
|
|||||||
/// Obtain the actual discriminant of a value.
|
/// Obtain the actual discriminant of a value.
|
||||||
pub fn codegen_get_discr(self, bx: &Builder<'a, 'll, 'tcx>, cast_to: Ty<'tcx>) -> &'ll 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);
|
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);
|
return C_undef(cast_to);
|
||||||
}
|
}
|
||||||
match self.layout.variants {
|
match self.layout.variants {
|
||||||
@ -338,7 +338,7 @@ impl PlaceRef<'ll, 'tcx> {
|
|||||||
/// Set the discriminant for a new value of the given case of the given
|
/// Set the discriminant for a new value of the given case of the given
|
||||||
/// representation.
|
/// representation.
|
||||||
pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: usize) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
match self.layout.variants {
|
match self.layout.variants {
|
||||||
|
@ -290,7 +290,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||||||
mir::CastKind::Misc => {
|
mir::CastKind::Misc => {
|
||||||
assert!(cast.is_llvm_immediate());
|
assert!(cast.is_llvm_immediate());
|
||||||
let ll_t_out = cast.immediate_llvm_type(bx.cx);
|
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 {
|
return (bx, OperandRef {
|
||||||
val: OperandValue::Immediate(C_undef(ll_t_out)),
|
val: OperandValue::Immediate(C_undef(ll_t_out)),
|
||||||
layout: cast,
|
layout: cast,
|
||||||
|
@ -514,7 +514,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||||||
rval: OpTy<'tcx>,
|
rval: OpTy<'tcx>,
|
||||||
) -> EvalResult<'tcx, (u128, usize)> {
|
) -> EvalResult<'tcx, (u128, usize)> {
|
||||||
trace!("read_discriminant_value {:#?}", rval.layout);
|
trace!("read_discriminant_value {:#?}", rval.layout);
|
||||||
if rval.layout.abi == layout::Abi::Uninhabited {
|
if rval.layout.abi.is_uninhabited() {
|
||||||
return err!(Unreachable);
|
return err!(Unreachable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user