@@ -12,51 +12,6 @@ macro_rules! panic {
1212 } ;
1313}
1414
15- /// Helper macro for panicking in a `const fn`.
16- /// Invoke as:
17- /// ```rust,ignore (just an example)
18- /// core::macros::const_panic!("boring message", "flavored message {a} {b:?}", a: u32 = foo.len(), b: Something = bar);
19- /// ```
20- /// where the first message will be printed in const-eval,
21- /// and the second message will be printed at runtime.
22- // All uses of this macro are FIXME(const-hack).
23- #[ unstable( feature = "panic_internals" , issue = "none" ) ]
24- #[ doc( hidden) ]
25- pub macro const_panic {
26- ( $const_msg: literal, $runtime_msg: literal, $( $arg: ident : $ty: ty = $val: expr) , * $( , ) ?) => { {
27- // Wrap call to `const_eval_select` in a function so that we can
28- // add the `rustc_allow_const_fn_unstable`. This is okay to do
29- // because both variants will panic, just with different messages.
30- #[ rustc_allow_const_fn_unstable( const_eval_select) ]
31- #[ inline( always) ]
32- #[ track_caller]
33- #[ cfg_attr( bootstrap, rustc_const_stable( feature = "const_panic" , since = "CURRENT_RUSTC_VERSION" ) ) ]
34- const fn do_panic ( $( $arg: $ty) , * ) -> ! {
35- $crate:: intrinsics:: const_eval_select!(
36- #[ inline]
37- #[ track_caller]
38- ( $( $arg: $ty) , * ) -> !:
39- if const {
40- $crate :: panic!( $const_msg)
41- } else {
42- $crate :: panic!( $runtime_msg)
43- }
44- )
45- }
46-
47- do_panic ( $( $val) , * )
48- } } ,
49- // We support leaving away the `val` expressions for *all* arguments
50- // (but not for *some* arguments, that's too tricky).
51- ( $const_msg: literal, $runtime_msg: literal, $( $arg: ident : $ty: ty) , * $( , ) ?) => {
52- $crate:: macros:: const_panic!(
53- $const_msg,
54- $runtime_msg,
55- $( $arg: $ty = $arg) , *
56- )
57- } ,
58- }
59-
6015/// Asserts that two expressions are equal to each other (using [`PartialEq`]).
6116///
6217/// Assertions are always checked in both debug and release builds, and cannot
@@ -241,19 +196,6 @@ pub macro assert_matches {
241196 } ,
242197}
243198
244- /// A version of `assert` that prints a non-formatting message in const contexts.
245- ///
246- /// See [`const_panic!`].
247- #[ unstable ( feature = "panic_internals" , issue = "none" ) ]
248- #[ doc ( hidden) ]
249- pub macro const_assert {
250- ( $condition: expr, $const_msg: literal, $runtime_msg: literal, $( $arg: tt) * ) => { {
251- if !$crate:: intrinsics:: likely ( $condition) {
252- $crate:: macros:: const_panic!( $const_msg, $runtime_msg, $( $arg) * )
253- }
254- } }
255- }
256-
257199/// A macro for defining `#[cfg]` match-like statements.
258200 ///
259201/// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of
0 commit comments