Distinguish between library and lang UB in assert_unsafe_precondition
This commit is contained in:
parent
46b180ec24
commit
5a93a59fd5
47 changed files with 415 additions and 263 deletions
|
@ -915,7 +915,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
NullOp::SizeOf => write!(fmt, "SizeOf({t})"),
|
||||
NullOp::AlignOf => write!(fmt, "AlignOf({t})"),
|
||||
NullOp::OffsetOf(fields) => write!(fmt, "OffsetOf({t}, {fields:?})"),
|
||||
NullOp::DebugAssertions => write!(fmt, "cfg!(debug_assertions)"),
|
||||
NullOp::UbCheck(kind) => write!(fmt, "UbCheck({kind:?})"),
|
||||
}
|
||||
}
|
||||
ThreadLocalRef(did) => ty::tls::with(|tcx| {
|
||||
|
|
|
@ -1366,8 +1366,16 @@ pub enum NullOp<'tcx> {
|
|||
AlignOf,
|
||||
/// Returns the offset of a field
|
||||
OffsetOf(&'tcx List<(VariantIdx, FieldIdx)>),
|
||||
/// cfg!(debug_assertions), but expanded in codegen
|
||||
DebugAssertions,
|
||||
/// Returns whether we want to check for library UB or language UB at monomorphization time.
|
||||
/// Both kinds of UB evaluate to `true` in codegen, and only library UB evalutes to `true` in
|
||||
/// const-eval/Miri, because the interpreter has its own better checks for language UB.
|
||||
UbCheck(UbKind),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
|
||||
pub enum UbKind {
|
||||
LanguageUb,
|
||||
LibraryUb,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
|
|
@ -194,7 +194,7 @@ impl<'tcx> Rvalue<'tcx> {
|
|||
Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(..), _) => {
|
||||
tcx.types.usize
|
||||
}
|
||||
Rvalue::NullaryOp(NullOp::DebugAssertions, _) => tcx.types.bool,
|
||||
Rvalue::NullaryOp(NullOp::UbCheck(_), _) => tcx.types.bool,
|
||||
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
|
||||
AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64),
|
||||
AggregateKind::Tuple => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue