use std::{fmt, env};
+use rustc_error_codes::*;
+
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
pub enum ErrorHandled {
/// Already reported a lint or an error for this evaluation.
UbExperimental(String),
/// Unreachable code was executed.
Unreachable,
+ /// An enum discriminant was set to a value which was outside the range of valid values.
+ InvalidDiscriminant(ScalarMaybeUndef),
}
impl fmt::Debug for UndefinedBehaviorInfo {
write!(f, "{}", msg),
Unreachable =>
write!(f, "entered unreachable code"),
+ InvalidDiscriminant(val) =>
+ write!(f, "encountered invalid enum discriminant {}", val),
}
}
}
/// Free-form case. Only for errors that are never caught!
Unsupported(String),
- /// FIXME(#64506) Error used to work around accessing projections of
- /// uninhabited types.
- UninhabitedValue,
-
// -- Everything below is not categorized yet --
FunctionAbiMismatch(Abi, Abi),
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
InvalidMemoryAccess,
InvalidFunctionPointer,
InvalidBool,
- InvalidDiscriminant(ScalarMaybeUndef),
PointerOutOfBounds {
ptr: Pointer,
msg: CheckInAllocMsg,
write!(f, "incorrect alloc info: expected size {} and align {}, \
got size {} and align {}",
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
- InvalidDiscriminant(val) =>
- write!(f, "encountered invalid enum discriminant {}", val),
InvalidMemoryAccess =>
write!(f, "tried to access memory through an invalid pointer"),
DanglingPointerDeref =>
not a power of two"),
Unsupported(ref msg) =>
write!(f, "{}", msg),
- UninhabitedValue =>
- write!(f, "tried to use an uninhabited value"),
}
}
}