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 {
515
515
#[ track_caller]
516
516
pub const unsafe fn digit_unchecked ( d : u8 ) -> Self {
517
517
assert_unsafe_precondition ! (
518
- check_language_ub ,
518
+ check_library_ub ,
519
519
"`ascii::Char::digit_unchecked` input cannot exceed 9." ,
520
520
( d: u8 = d) => d < 10
521
521
) ;
Original file line number Diff line number Diff line change @@ -1460,8 +1460,8 @@ macro_rules! int_impl {
1460
1460
#[ inline]
1461
1461
pub const unsafe fn unchecked_exact_shl( self , rhs: u32 ) -> $SelfT {
1462
1462
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 " ) ,
1465
1465
(
1466
1466
zeros: u32 = self . leading_zeros( ) ,
1467
1467
ones: u32 = self . leading_ones( ) ,
@@ -1638,7 +1638,7 @@ macro_rules! int_impl {
1638
1638
#[ inline]
1639
1639
pub const unsafe fn unchecked_exact_shr( self , rhs: u32 ) -> $SelfT {
1640
1640
assert_unsafe_precondition!(
1641
- check_language_ub ,
1641
+ check_library_ub ,
1642
1642
concat!( stringify!( $SelfT) , "::unchecked_exact_shr cannot shift out non-zero bits" ) ,
1643
1643
(
1644
1644
zeros: u32 = self . trailing_zeros( ) ,
Original file line number Diff line number Diff line change @@ -1865,7 +1865,7 @@ macro_rules! uint_impl {
1865
1865
#[ inline]
1866
1866
pub const unsafe fn unchecked_exact_shl( self , rhs: u32 ) -> $SelfT {
1867
1867
assert_unsafe_precondition!(
1868
- check_language_ub ,
1868
+ check_library_ub ,
1869
1869
concat!( stringify!( $SelfT) , "::exact_shl_unchecked cannot shift out non-zero bits" ) ,
1870
1870
(
1871
1871
zeros: u32 = self . leading_zeros( ) ,
@@ -2037,7 +2037,7 @@ macro_rules! uint_impl {
2037
2037
#[ inline]
2038
2038
pub const unsafe fn unchecked_exact_shr( self , rhs: u32 ) -> $SelfT {
2039
2039
assert_unsafe_precondition!(
2040
- check_language_ub ,
2040
+ check_library_ub ,
2041
2041
concat!( stringify!( $SelfT) , "::exact_shr_unchecked cannot shift out non-zero bits" ) ,
2042
2042
(
2043
2043
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 {
233
233
#[ track_caller]
234
234
unsafe fn get_unchecked ( self , slice : * const [ T ] ) -> * const T {
235
235
assert_unsafe_precondition ! (
236
- check_language_ub,
236
+ check_language_ub, // okay because of the `assume` below
237
237
"slice::get_unchecked requires that the index is within the slice" ,
238
238
( this: usize = self , len: usize = slice. len( ) ) => this < len
239
239
) ;
Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ use crate::intrinsics::{self, const_eval_select};
21
21
/// slow down const-eval/Miri and we'll get the panic message instead of the interpreter's nice
22
22
/// diagnostic, but our ability to detect UB is unchanged.
23
23
/// 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.
26
27
///
27
28
/// These checks are behind a condition which is evaluated at codegen time, not expansion time like
28
29
/// [`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