Skip to content

Commit 25babe9

Browse files
committed
export assert_unsafe_precondition macro for std-internal use
1 parent 38ded12 commit 25babe9

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2720,7 +2720,7 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) {
27202720
#[unstable(feature = "core_intrinsics", issue = "none")]
27212721
#[inline(always)]
27222722
#[cfg_attr(not(bootstrap), rustc_intrinsic)] // just make it a regular fn in bootstrap
2723-
pub(crate) const fn ub_checks() -> bool {
2723+
pub const fn ub_checks() -> bool {
27242724
cfg!(debug_assertions)
27252725
}
27262726

library/core/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
#![feature(str_split_inclusive_remainder)]
194194
#![feature(str_split_remainder)]
195195
#![feature(strict_provenance)]
196+
#![feature(ub_checks)]
196197
#![feature(unchecked_shifts)]
197198
#![feature(utf16_extra)]
198199
#![feature(utf16_extra_const)]
@@ -370,7 +371,8 @@ pub mod hint;
370371
pub mod intrinsics;
371372
pub mod mem;
372373
pub mod ptr;
373-
mod ub_checks;
374+
#[unstable(feature = "ub_checks", issue = "none")]
375+
pub mod ub_checks;
374376

375377
/* Core language traits */
376378

library/core/src/ub_checks.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ use crate::intrinsics::{self, const_eval_select};
4646
/// variables cannot be optimized out in MIR, an innocent-looking `let` can produce enough
4747
/// debuginfo to have a measurable compile-time impact on debug builds.
4848
#[allow_internal_unstable(const_ub_checks)] // permit this to be called in stably-const fn
49+
#[macro_export]
50+
#[unstable(feature = "ub_checks", issue = "none")]
4951
macro_rules! assert_unsafe_precondition {
5052
($kind:ident, $message:expr, ($($name:ident:$ty:ty = $arg:expr),*$(,)?) => $e:expr $(,)?) => {
5153
{
@@ -75,11 +77,13 @@ macro_rules! assert_unsafe_precondition {
7577
}
7678
};
7779
}
78-
pub(crate) use assert_unsafe_precondition;
80+
#[unstable(feature = "ub_checks", issue = "none")]
81+
pub use assert_unsafe_precondition;
7982

8083
/// Checking library UB is always enabled when UB-checking is done
8184
/// (and we use a reexport so that there is no unnecessary wrapper function).
82-
pub(crate) use intrinsics::ub_checks as check_library_ub;
85+
#[unstable(feature = "ub_checks", issue = "none")]
86+
pub use intrinsics::ub_checks as check_library_ub;
8387

8488
/// Determines whether we should check for language UB.
8589
///

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@
358358
#![feature(str_internals)]
359359
#![feature(strict_provenance)]
360360
#![feature(strict_provenance_atomic_ptr)]
361+
#![feature(ub_checks)]
361362
// tidy-alphabetical-end
362363
//
363364
// Library features (alloc):

0 commit comments

Comments
 (0)