document more things as needing to stay in sync
This commit is contained in:
parent
4c53783f3c
commit
ddea3f981e
@ -1275,9 +1275,11 @@ pub fn is_optional_overflow_check(&self) -> bool {
|
|||||||
matches!(self, OverflowNeg(..) | Overflow(Add | Sub | Mul | Shl | Shr, ..))
|
matches!(self, OverflowNeg(..) | Overflow(Add | Sub | Mul | Shl | Shr, ..))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getting a description does not require `O` to be printable, and does not
|
/// Get the message that is printed at runtime when this assertion fails.
|
||||||
/// require allocation.
|
///
|
||||||
/// The caller is expected to handle `BoundsCheck` and `MisalignedPointerDereference` separately.
|
/// The caller is expected to handle `BoundsCheck` and `MisalignedPointerDereference` by
|
||||||
|
/// invoking the appropriate lang item (panic_bounds_check/panic_misaligned_pointer_dereference)
|
||||||
|
/// instead of printing a static message.
|
||||||
pub fn description(&self) -> &'static str {
|
pub fn description(&self) -> &'static str {
|
||||||
use AssertKind::*;
|
use AssertKind::*;
|
||||||
match self {
|
match self {
|
||||||
@ -1303,6 +1305,11 @@ pub fn description(&self) -> &'static str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Format the message arguments for the `assert(cond, msg..)` terminator in MIR printing.
|
/// Format the message arguments for the `assert(cond, msg..)` terminator in MIR printing.
|
||||||
|
///
|
||||||
|
/// Needs to be kept in sync with the run-time behavior (which is defined by
|
||||||
|
/// `AssertKind::description` and the lang items mentioned in its docs).
|
||||||
|
/// Note that we deliberately show more details here than we do at runtime, such as the actual
|
||||||
|
/// numbers that overflowed -- it is much easier to do so here than at runtime.
|
||||||
pub fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
|
pub fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
|
||||||
where
|
where
|
||||||
O: Debug,
|
O: Debug,
|
||||||
@ -1358,6 +1365,12 @@ pub fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Format the diagnostic message for use in a lint (e.g. when the assertion fails during const-eval).
|
||||||
|
///
|
||||||
|
/// Needs to be kept in sync with the run-time behavior (which is defined by
|
||||||
|
/// `AssertKind::description` and the lang items mentioned in its docs).
|
||||||
|
/// Note that we deliberately show more details here than we do at runtime, such as the actual
|
||||||
|
/// numbers that overflowed -- it is much easier to do so here than at runtime.
|
||||||
pub fn diagnostic_message(&self) -> DiagnosticMessage {
|
pub fn diagnostic_message(&self) -> DiagnosticMessage {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
use AssertKind::*;
|
use AssertKind::*;
|
||||||
|
@ -188,6 +188,7 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
|
|||||||
#[lang = "panic_cannot_unwind"] // needed by codegen for panic in nounwind function
|
#[lang = "panic_cannot_unwind"] // needed by codegen for panic in nounwind function
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
fn panic_cannot_unwind() -> ! {
|
fn panic_cannot_unwind() -> ! {
|
||||||
|
// Keep the text in sync with `UnwindTerminateReason::as_str` in `rustc_middle`.
|
||||||
panic_nounwind("panic in a function that cannot unwind")
|
panic_nounwind("panic in a function that cannot unwind")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +204,7 @@ fn panic_cannot_unwind() -> ! {
|
|||||||
#[lang = "panic_in_cleanup"] // needed by codegen for panic in nounwind function
|
#[lang = "panic_in_cleanup"] // needed by codegen for panic in nounwind function
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
fn panic_in_cleanup() -> ! {
|
fn panic_in_cleanup() -> ! {
|
||||||
|
// Keep the text in sync with `UnwindTerminateReason::as_str` in `rustc_middle`.
|
||||||
panic_nounwind("panic in a destructor during cleanup")
|
panic_nounwind("panic in a destructor during cleanup")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user