@@ -1275,9 +1275,11 @@ impl<O> AssertKind<O> {
12751275 matches ! ( self , OverflowNeg ( ..) | Overflow ( Add | Sub | Mul | Shl | Shr , ..) )
12761276 }
12771277
1278- /// Getting a description does not require `O` to be printable, and does not
1279- /// require allocation.
1280- /// The caller is expected to handle `BoundsCheck` and `MisalignedPointerDereference` separately.
1278+ /// Get the message that is printed at runtime when this assertion fails.
1279+ ///
1280+ /// The caller is expected to handle `BoundsCheck` and `MisalignedPointerDereference` by
1281+ /// invoking the appropriate lang item (panic_bounds_check/panic_misaligned_pointer_dereference)
1282+ /// instead of printing a static message.
12811283 pub fn description ( & self ) -> & ' static str {
12821284 use AssertKind :: * ;
12831285 match self {
@@ -1303,6 +1305,11 @@ impl<O> AssertKind<O> {
13031305 }
13041306
13051307 /// Format the message arguments for the `assert(cond, msg..)` terminator in MIR printing.
1308+ ///
1309+ /// Needs to be kept in sync with the run-time behavior (which is defined by
1310+ /// `AssertKind::description` and the lang items mentioned in its docs).
1311+ /// Note that we deliberately show more details here than we do at runtime, such as the actual
1312+ /// numbers that overflowed -- it is much easier to do so here than at runtime.
13061313 pub fn fmt_assert_args < W : Write > ( & self , f : & mut W ) -> fmt:: Result
13071314 where
13081315 O : Debug ,
@@ -1358,6 +1365,12 @@ impl<O> AssertKind<O> {
13581365 }
13591366 }
13601367
1368+ /// Format the diagnostic message for use in a lint (e.g. when the assertion fails during const-eval).
1369+ ///
1370+ /// Needs to be kept in sync with the run-time behavior (which is defined by
1371+ /// `AssertKind::description` and the lang items mentioned in its docs).
1372+ /// Note that we deliberately show more details here than we do at runtime, such as the actual
1373+ /// numbers that overflowed -- it is much easier to do so here than at runtime.
13611374 pub fn diagnostic_message ( & self ) -> DiagnosticMessage {
13621375 use crate :: fluent_generated:: * ;
13631376 use AssertKind :: * ;
0 commit comments