File tree Expand file tree Collapse file tree 5 files changed +10
-9
lines changed Expand file tree Collapse file tree 5 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -515,7 +515,7 @@ impl AsciiChar {
515515 #[ track_caller]
516516 pub const unsafe fn digit_unchecked ( d : u8 ) -> Self {
517517 assert_unsafe_precondition ! (
518- check_language_ub ,
518+ check_library_ub ,
519519 "`ascii::Char::digit_unchecked` input cannot exceed 9." ,
520520 ( d: u8 = d) => d < 10
521521 ) ;
Original file line number Diff line number Diff line change @@ -1460,8 +1460,8 @@ macro_rules! int_impl {
14601460 #[ inline]
14611461 pub const unsafe fn unchecked_exact_shl( self , rhs: u32 ) -> $SelfT {
14621462 assert_unsafe_precondition!(
1463- check_language_ub ,
1464- concat!( stringify!( $SelfT) , "::unchecked_exact_shl cannot shift out non-zero bits" ) ,
1463+ check_library_ub ,
1464+ concat!( stringify!( $SelfT) , "::unchecked_exact_shl cannot shift out bits that would change the value of the first bit " ) ,
14651465 (
14661466 zeros: u32 = self . leading_zeros( ) ,
14671467 ones: u32 = self . leading_ones( ) ,
@@ -1638,7 +1638,7 @@ macro_rules! int_impl {
16381638 #[ inline]
16391639 pub const unsafe fn unchecked_exact_shr( self , rhs: u32 ) -> $SelfT {
16401640 assert_unsafe_precondition!(
1641- check_language_ub ,
1641+ check_library_ub ,
16421642 concat!( stringify!( $SelfT) , "::unchecked_exact_shr cannot shift out non-zero bits" ) ,
16431643 (
16441644 zeros: u32 = self . trailing_zeros( ) ,
Original file line number Diff line number Diff line change @@ -1865,7 +1865,7 @@ macro_rules! uint_impl {
18651865 #[ inline]
18661866 pub const unsafe fn unchecked_exact_shl( self , rhs: u32 ) -> $SelfT {
18671867 assert_unsafe_precondition!(
1868- check_language_ub ,
1868+ check_library_ub ,
18691869 concat!( stringify!( $SelfT) , "::exact_shl_unchecked cannot shift out non-zero bits" ) ,
18701870 (
18711871 zeros: u32 = self . leading_zeros( ) ,
@@ -2037,7 +2037,7 @@ macro_rules! uint_impl {
20372037 #[ inline]
20382038 pub const unsafe fn unchecked_exact_shr( self , rhs: u32 ) -> $SelfT {
20392039 assert_unsafe_precondition!(
2040- check_language_ub ,
2040+ check_library_ub ,
20412041 concat!( stringify!( $SelfT) , "::exact_shr_unchecked cannot shift out non-zero bits" ) ,
20422042 (
20432043 zeros: u32 = self . trailing_zeros( ) ,
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ unsafe impl<T> const SliceIndex<[T]> for usize {
233233 #[ track_caller]
234234 unsafe fn get_unchecked ( self , slice : * const [ T ] ) -> * const T {
235235 assert_unsafe_precondition ! (
236- check_language_ub,
236+ check_language_ub, // okay because of the `assume` below
237237 "slice::get_unchecked requires that the index is within the slice" ,
238238 ( this: usize = self , len: usize = slice. len( ) ) => this < len
239239 ) ;
Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ use crate::intrinsics::{self, const_eval_select};
2121/// slow down const-eval/Miri and we'll get the panic message instead of the interpreter's nice
2222/// diagnostic, but our ability to detect UB is unchanged.
2323/// But if `check_language_ub` is used when the check is actually for library UB, the check is
24- /// omitted in const-eval/Miri and thus if we eventually execute language UB which relies on the
25- /// library UB, the backtrace Miri reports may be far removed from original cause.
24+ /// omitted in const-eval/Miri and thus UB might occur undetected. Even if we eventually execute
25+ /// language UB which relies on the library UB, the backtrace Miri reports may be far removed from
26+ /// original cause.
2627///
2728/// These checks are behind a condition which is evaluated at codegen time, not expansion time like
2829/// [`debug_assert`]. This means that a standard library built with optimizations and debug
You can’t perform that action at this time.
0 commit comments