Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1945ce6

Browse files
committedFeb 12, 2022
Auto merge of rust-lang#93922 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports This backports: * Complete removal of #[main] attribute from compiler rust-lang#93753 * Resolve lifetimes for const generic defaults rust-lang#93669 * backport llvm fix for issue 91671. rust-lang#93426 * Fix invalid special casing of the unreachable! macro rust-lang#93179 * Fix hashing for windows paths containing a CurDir component rust-lang#93697 r? `@Mark-Simulacrum`
2 parents f58f0df + 0ac18e7 commit 1945ce6

38 files changed

+434
-72
lines changed
 

‎compiler/rustc_builtin_macros/src/assert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::panic::use_panic_2021;
1+
use crate::edition_panic::use_panic_2021;
22
use rustc_ast::ptr::P;
33
use rustc_ast::token;
44
use rustc_ast::tokenstream::{DelimSpan, TokenStream};

‎compiler/rustc_builtin_macros/src/panic.rs ‎compiler/rustc_builtin_macros/src/edition_panic.rs

+23-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,29 @@ pub fn expand_panic<'cx>(
2020
sp: Span,
2121
tts: TokenStream,
2222
) -> Box<dyn MacResult + 'cx> {
23-
let panic = if use_panic_2021(sp) { sym::panic_2021 } else { sym::panic_2015 };
23+
let mac = if use_panic_2021(sp) { sym::panic_2021 } else { sym::panic_2015 };
24+
expand(mac, cx, sp, tts)
25+
}
2426

27+
// This expands to either
28+
// - `$crate::panic::unreachable_2015!(...)` or
29+
// - `$crate::panic::unreachable_2021!(...)`
30+
// depending on the edition.
31+
pub fn expand_unreachable<'cx>(
32+
cx: &'cx mut ExtCtxt<'_>,
33+
sp: Span,
34+
tts: TokenStream,
35+
) -> Box<dyn MacResult + 'cx> {
36+
let mac = if use_panic_2021(sp) { sym::unreachable_2021 } else { sym::unreachable_2015 };
37+
expand(mac, cx, sp, tts)
38+
}
39+
40+
fn expand<'cx>(
41+
mac: rustc_span::Symbol,
42+
cx: &'cx mut ExtCtxt<'_>,
43+
sp: Span,
44+
tts: TokenStream,
45+
) -> Box<dyn MacResult + 'cx> {
2546
let sp = cx.with_call_site_ctxt(sp);
2647

2748
MacEager::expr(
@@ -31,7 +52,7 @@ pub fn expand_panic<'cx>(
3152
path: Path {
3253
span: sp,
3354
segments: cx
34-
.std_path(&[sym::panic, panic])
55+
.std_path(&[sym::panic, mac])
3556
.into_iter()
3657
.map(|ident| PathSegment::from_ident(ident))
3758
.collect(),

‎compiler/rustc_builtin_macros/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ mod concat_bytes;
2929
mod concat_idents;
3030
mod derive;
3131
mod deriving;
32+
mod edition_panic;
3233
mod env;
3334
mod format;
3435
mod format_foreign;
3536
mod global_allocator;
3637
mod llvm_asm;
3738
mod log_syntax;
38-
mod panic;
3939
mod source_util;
4040
mod test;
4141
mod trace_macros;
@@ -82,8 +82,9 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
8282
log_syntax: log_syntax::expand_log_syntax,
8383
module_path: source_util::expand_mod,
8484
option_env: env::expand_option_env,
85-
core_panic: panic::expand_panic,
86-
std_panic: panic::expand_panic,
85+
core_panic: edition_panic::expand_panic,
86+
std_panic: edition_panic::expand_panic,
87+
unreachable: edition_panic::expand_unreachable,
8788
stringify: source_util::expand_stringify,
8889
trace_macros: trace_macros::expand_trace_macros,
8990
}

‎compiler/rustc_feature/src/builtin_attrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
339339
),
340340

341341
// Entry point:
342-
ungated!(main, Normal, template!(Word), WarnFollowing),
343342
ungated!(start, Normal, template!(Word), WarnFollowing),
344343
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
345344
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),

‎compiler/rustc_hir/src/lang_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ language_item_table! {
285285
Panic, sym::panic, panic_fn, Target::Fn, GenericRequirement::Exact(0);
286286
PanicFmt, sym::panic_fmt, panic_fmt, Target::Fn, GenericRequirement::None;
287287
PanicDisplay, sym::panic_display, panic_display, Target::Fn, GenericRequirement::None;
288-
PanicStr, sym::panic_str, panic_str, Target::Fn, GenericRequirement::None;
289288
ConstPanicFmt, sym::const_panic_fmt, const_panic_fmt, Target::Fn, GenericRequirement::None;
290289
PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, Target::Fn, GenericRequirement::Exact(0);
291290
PanicInfo, sym::panic_info, panic_info, Target::Struct, GenericRequirement::None;

‎compiler/rustc_lint/src/non_fmt_panic.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ impl<'tcx> LateLintPass<'tcx> for NonPanicFmt {
4949
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
5050
if let hir::ExprKind::Call(f, [arg]) = &expr.kind {
5151
if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() {
52+
let f_diagnostic_name = cx.tcx.get_diagnostic_name(def_id);
53+
5254
if Some(def_id) == cx.tcx.lang_items().begin_panic_fn()
5355
|| Some(def_id) == cx.tcx.lang_items().panic_fn()
54-
|| Some(def_id) == cx.tcx.lang_items().panic_str()
56+
|| f_diagnostic_name == Some(sym::panic_str)
5557
{
5658
if let Some(id) = f.span.ctxt().outer_expn_data().macro_def_id {
5759
if matches!(
@@ -61,6 +63,22 @@ impl<'tcx> LateLintPass<'tcx> for NonPanicFmt {
6163
check_panic(cx, f, arg);
6264
}
6365
}
66+
} else if f_diagnostic_name == Some(sym::unreachable_display) {
67+
if let Some(id) = f.span.ctxt().outer_expn_data().macro_def_id {
68+
if cx.tcx.is_diagnostic_item(sym::unreachable_2015_macro, id) {
69+
check_panic(
70+
cx,
71+
f,
72+
// This is safe because we checked above that the callee is indeed
73+
// unreachable_display
74+
match &arg.kind {
75+
// Get the borrowed arg not the borrow
76+
hir::ExprKind::AddrOf(ast::BorrowKind::Ref, _, arg) => arg,
77+
_ => bug!("call to unreachable_display without borrow"),
78+
},
79+
);
80+
}
81+
}
6482
}
6583
}
6684
}
@@ -85,8 +103,8 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
85103
return;
86104
}
87105

88-
// Find the span of the argument to `panic!()`, before expansion in the
89-
// case of `panic!(some_macro!())`.
106+
// Find the span of the argument to `panic!()` or `unreachable!`, before expansion in the
107+
// case of `panic!(some_macro!())` or `unreachable!(some_macro!())`.
90108
// We don't use source_callsite(), because this `panic!(..)` might itself
91109
// be expanded from another macro, in which case we want to stop at that
92110
// expansion.
@@ -319,6 +337,7 @@ fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span,
319337
| sym::std_panic_macro
320338
| sym::assert_macro
321339
| sym::debug_assert_macro
340+
| sym::unreachable_macro
322341
) {
323342
break;
324343
}

‎compiler/rustc_resolve/src/late/lifetimes.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1350,11 +1350,14 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
13501350
this.visit_ty(&ty);
13511351
}
13521352
}
1353-
GenericParamKind::Const { ref ty, .. } => {
1353+
GenericParamKind::Const { ref ty, default } => {
13541354
let was_in_const_generic = this.is_in_const_generic;
13551355
this.is_in_const_generic = true;
13561356
walk_list!(this, visit_param_bound, param.bounds);
13571357
this.visit_ty(&ty);
1358+
if let Some(default) = default {
1359+
this.visit_body(this.tcx.hir().body(default.body));
1360+
}
13581361
this.is_in_const_generic = was_in_const_generic;
13591362
}
13601363
}

‎compiler/rustc_span/src/symbol.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,13 @@ symbols! {
13881388
unmarked_api,
13891389
unpin,
13901390
unreachable,
1391+
unreachable_2015,
1392+
unreachable_2015_macro,
1393+
unreachable_2021,
1394+
unreachable_2021_macro,
13911395
unreachable_code,
1396+
unreachable_display,
1397+
unreachable_macro,
13921398
unrestricted_attribute_tokens,
13931399
unsafe_block_in_unsafe_fn,
13941400
unsafe_cell,

‎library/core/src/macros/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,22 @@ macro_rules! writeln {
587587
/// unreachable!("The loop should always return");
588588
/// }
589589
/// ```
590+
#[cfg(not(bootstrap))]
591+
#[macro_export]
592+
#[rustc_builtin_macro(unreachable)]
593+
#[allow_internal_unstable(edition_panic)]
594+
#[stable(feature = "rust1", since = "1.0.0")]
595+
#[cfg_attr(not(test), rustc_diagnostic_item = "unreachable_macro")]
596+
macro_rules! unreachable {
597+
// Expands to either `$crate::panic::unreachable_2015` or `$crate::panic::unreachable_2021`
598+
// depending on the edition of the caller.
599+
($($arg:tt)*) => {
600+
/* compiler built-in */
601+
};
602+
}
603+
604+
/// unreachable!() macro
605+
#[cfg(bootstrap)]
590606
#[macro_export]
591607
#[stable(feature = "rust1", since = "1.0.0")]
592608
#[allow_internal_unstable(core_panic)]

‎library/core/src/panic.rs

+33
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,39 @@ pub macro panic_2021 {
5858
),
5959
}
6060

61+
#[doc(hidden)]
62+
#[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
63+
#[allow_internal_unstable(core_panic)]
64+
#[rustc_diagnostic_item = "unreachable_2015_macro"]
65+
#[rustc_macro_transparency = "semitransparent"]
66+
pub macro unreachable_2015 {
67+
() => (
68+
$crate::panicking::panic("internal error: entered unreachable code")
69+
),
70+
// Use of `unreachable_display` for non_fmt_panic lint.
71+
// NOTE: the message ("internal error ...") is embeded directly in unreachable_display
72+
($msg:expr $(,)?) => (
73+
$crate::panicking::unreachable_display(&$msg)
74+
),
75+
($fmt:expr, $($arg:tt)*) => (
76+
$crate::panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
77+
),
78+
}
79+
80+
#[doc(hidden)]
81+
#[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
82+
#[allow_internal_unstable(core_panic)]
83+
#[rustc_diagnostic_item = "unreachable_2021_macro"]
84+
#[rustc_macro_transparency = "semitransparent"]
85+
pub macro unreachable_2021 {
86+
() => (
87+
$crate::panicking::panic("internal error: entered unreachable code")
88+
),
89+
($($t:tt)+) => (
90+
$crate::panic!("internal error: entered unreachable code: {}", $crate::format_args!($($t)+))
91+
),
92+
}
93+
6194
/// An internal trait used by libstd to pass data from libstd to `panic_unwind`
6295
/// and other panic runtimes. Not intended to be stabilized any time soon, do
6396
/// not use.

‎library/core/src/panicking.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,20 @@ pub const fn panic(expr: &'static str) -> ! {
5050

5151
#[inline]
5252
#[track_caller]
53-
#[lang = "panic_str"] // needed for `non-fmt-panics` lint
53+
#[rustc_diagnostic_item = "panic_str"]
54+
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
5455
pub const fn panic_str(expr: &str) -> ! {
5556
panic_display(&expr);
5657
}
5758

59+
#[cfg(not(bootstrap))]
60+
#[inline]
61+
#[track_caller]
62+
#[rustc_diagnostic_item = "unreachable_display"] // needed for `non-fmt-panics` lint
63+
pub fn unreachable_display<T: fmt::Display>(x: &T) -> ! {
64+
panic_fmt(format_args!("internal error: entered unreachable code: {}", *x));
65+
}
66+
5867
#[inline]
5968
#[track_caller]
6069
#[lang = "panic_display"] // needed for const-evaluated panics

‎library/std/src/path.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -2899,32 +2899,40 @@ impl cmp::PartialEq for Path {
28992899
impl Hash for Path {
29002900
fn hash<H: Hasher>(&self, h: &mut H) {
29012901
let bytes = self.as_u8_slice();
2902-
let prefix_len = match parse_prefix(&self.inner) {
2902+
let (prefix_len, verbatim) = match parse_prefix(&self.inner) {
29032903
Some(prefix) => {
29042904
prefix.hash(h);
2905-
prefix.len()
2905+
(prefix.len(), prefix.is_verbatim())
29062906
}
2907-
None => 0,
2907+
None => (0, false),
29082908
};
29092909
let bytes = &bytes[prefix_len..];
29102910

29112911
let mut component_start = 0;
29122912
let mut bytes_hashed = 0;
29132913

29142914
for i in 0..bytes.len() {
2915-
if is_sep_byte(bytes[i]) {
2915+
let is_sep = if verbatim { is_verbatim_sep(bytes[i]) } else { is_sep_byte(bytes[i]) };
2916+
if is_sep {
29162917
if i > component_start {
29172918
let to_hash = &bytes[component_start..i];
29182919
h.write(to_hash);
29192920
bytes_hashed += to_hash.len();
29202921
}
29212922

29222923
// skip over separator and optionally a following CurDir item
2923-
// since components() would normalize these away
2924-
component_start = i + match bytes[i..] {
2925-
[_, b'.', b'/', ..] | [_, b'.'] => 2,
2926-
_ => 1,
2927-
};
2924+
// since components() would normalize these away.
2925+
component_start = i + 1;
2926+
2927+
let tail = &bytes[component_start..];
2928+
2929+
if !verbatim {
2930+
component_start += match tail {
2931+
[b'.'] => 1,
2932+
[b'.', sep @ _, ..] if is_sep_byte(*sep) => 1,
2933+
_ => 0,
2934+
};
2935+
}
29282936
}
29292937
}
29302938

‎library/std/src/path/tests.rs

+35
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,20 @@ pub fn test_compare() {
14981498
relative_from: Some("")
14991499
);
15001500

1501+
tc!("foo/.", "foo",
1502+
eq: true,
1503+
starts_with: true,
1504+
ends_with: true,
1505+
relative_from: Some("")
1506+
);
1507+
1508+
tc!("foo/./bar", "foo/bar",
1509+
eq: true,
1510+
starts_with: true,
1511+
ends_with: true,
1512+
relative_from: Some("")
1513+
);
1514+
15011515
tc!("foo/bar", "foo",
15021516
eq: false,
15031517
starts_with: true,
@@ -1541,6 +1555,27 @@ pub fn test_compare() {
15411555
ends_with: true,
15421556
relative_from: Some("")
15431557
);
1558+
1559+
tc!(r"C:\foo\.\bar.txt", r"C:\foo\bar.txt",
1560+
eq: true,
1561+
starts_with: true,
1562+
ends_with: true,
1563+
relative_from: Some("")
1564+
);
1565+
1566+
tc!(r"C:\foo\.", r"C:\foo",
1567+
eq: true,
1568+
starts_with: true,
1569+
ends_with: true,
1570+
relative_from: Some("")
1571+
);
1572+
1573+
tc!(r"\\?\C:\foo\.\bar.txt", r"\\?\C:\foo\bar.txt",
1574+
eq: false,
1575+
starts_with: false,
1576+
ends_with: false,
1577+
relative_from: None
1578+
);
15441579
}
15451580
}
15461581

‎src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
let mut _19: *const T; // in scope 0 at $DIR/issue_76432.rs:9:54: 9:68
2222
let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
2323
let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
24-
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
24+
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
2525
let mut _23: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
2626
scope 1 {
2727
debug v => _2; // in scope 1 at $DIR/issue_76432.rs:7:9: 7:10
@@ -66,16 +66,16 @@
6666
}
6767

6868
bb1: {
69-
StorageLive(_22); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
70-
core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
69+
StorageLive(_22); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
70+
core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
7171
// mir::Constant
72-
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
72+
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
7373
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
7474
// ty::Const
7575
// + ty: &str
7676
// + val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1099511627775], len: Size { raw: 40 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 })
7777
// mir::Constant
78-
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
78+
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
7979
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1099511627775], len: Size { raw: 40 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 }) }
8080
}
8181

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[main] //~ ERROR cannot find attribute `main` in this scope
2+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: cannot find attribute `main` in this scope
2+
--> $DIR/main-removed-1.rs:1:3
3+
|
4+
LL | #[main]
5+
| ^^^^
6+
|
7+
= note: `main` is in scope, but it is a function, not an attribute
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
use proc_macro::TokenStream;
8+
9+
#[proc_macro_attribute]
10+
pub fn main(_: TokenStream, input: TokenStream) -> TokenStream {
11+
"fn main() { println!(\"Hello Tokyo!\"); }".parse().unwrap()
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// run-pass
2+
// aux-build:tokyo.rs
3+
// compile-flags:--extern tokyo
4+
// edition:2021
5+
6+
use tokyo::main;
7+
8+
#[main]
9+
fn main() {
10+
panic!("the #[main] macro should replace this with non-panicking code")
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
struct X<const N: usize = {
2+
(||1usize)()
3+
//~^ ERROR calls in constants are limited to
4+
}>;
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
2+
--> $DIR/issue-93647.rs:2:5
3+
|
4+
LL | (||1usize)()
5+
| ^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0015`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct Foo<
2+
'a,
3+
const N: usize = {
4+
let x: &'a ();
5+
//~^ ERROR use of non-static lifetime `'a` in const generic
6+
3
7+
},
8+
>(&'a ());
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0771]: use of non-static lifetime `'a` in const generic
2+
--> $DIR/outer-lifetime-in-const-generic-default.rs:4:17
3+
|
4+
LL | let x: &'a ();
5+
| ^^
6+
|
7+
= note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0771`.

‎src/test/ui/consts/const-eval/const_panic.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
2020
LL | const Y: () = std::unreachable!();
2121
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
2222
|
23-
= note: this error originates in the macro `std::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
23+
= note: this error originates in the macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
2424

2525
error[E0080]: evaluation of constant value failed
2626
--> $DIR/const_panic.rs:15:15
@@ -68,7 +68,7 @@ error[E0080]: evaluation of constant value failed
6868
LL | const Y_CORE: () = core::unreachable!();
6969
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:30:20
7070
|
71-
= note: this error originates in the macro `core::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
71+
= note: this error originates in the macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
7272

7373
error[E0080]: evaluation of constant value failed
7474
--> $DIR/const_panic.rs:33:20

‎src/test/ui/consts/const-eval/const_panic_2021.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
2020
LL | const C: () = std::unreachable!();
2121
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:12:15
2222
|
23-
= note: this error originates in the macro `std::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
23+
= note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
2424

2525
error[E0080]: evaluation of constant value failed
2626
--> $DIR/const_panic_2021.rs:15:15
@@ -60,7 +60,7 @@ error[E0080]: evaluation of constant value failed
6060
LL | const C_CORE: () = core::unreachable!();
6161
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:27:20
6262
|
63-
= note: this error originates in the macro `core::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
63+
= note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
6464

6565
error[E0080]: evaluation of constant value failed
6666
--> $DIR/const_panic_2021.rs:30:20

‎src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed
1212
LL | const Y: () = unreachable!();
1313
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:11:15
1414
|
15-
= note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
15+
= note: this error originates in the macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
1616

1717
error[E0080]: evaluation of constant value failed
1818
--> $DIR/const_panic_libcore_bin.rs:14:15

‎src/test/ui/issues/issue-23036.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-pass
2+
// ignore-wasm32-bare FIXME(#93923) llvm miscompilation
23

34
use std::collections::HashMap;
45
use std::path::Path;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: format argument must be a string literal
2+
--> $DIR/unreachable-arg.rs:15:18
3+
|
4+
LL | unreachable!(a);
5+
| ^
6+
|
7+
help: you might be missing a string literal to format with
8+
|
9+
LL | unreachable!("{}", a);
10+
| +++++
11+
12+
error: aborting due to previous error
13+

‎src/test/ui/macros/unreachable-arg.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// ignore-emscripten no processes
2+
3+
// revisions: edition_2015 edition_2021
4+
// [edition_2015]edition:2015
5+
// [edition_2021]edition:2021
6+
// [edition_2015]run-fail
7+
// [edition_2021]check-fail
8+
// [edition_2015]error-pattern:internal error: entered unreachable code: hello
9+
// [edition_2021]error-pattern:format argument must be a string literal
10+
11+
#![allow(non_fmt_panics)]
12+
13+
fn main() {
14+
let a = "hello";
15+
unreachable!(a);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// run-fail
2+
// ignore-emscripten no processes
3+
4+
// revisions: edition_2015 edition_2021
5+
// [edition_2015]edition:2015
6+
// [edition_2021]edition:2021
7+
// [edition_2015]error-pattern:internal error: entered unreachable code: x is {x}
8+
// [edition_2021]error-pattern:internal error: entered unreachable code: x is 5
9+
10+
#![allow(non_fmt_panics)]
11+
12+
fn main() {
13+
let x = 5;
14+
unreachable!("x is {x}");
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: there is no argument named `x`
2+
--> $DIR/unreachable-format-args.rs:13:5
3+
|
4+
LL | unreachable!("x is {x} and y is {y}", y = 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: did you intend to capture a variable `x` from the surrounding scope?
8+
= note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
9+
= note: this error originates in the macro `$crate::concat` (in Nightly builds, run with -Z macro-backtrace for more info)
10+
11+
error: aborting due to previous error
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ignore-emscripten no processes
2+
3+
// revisions: edition_2015 edition_2021
4+
// [edition_2015]edition:2015
5+
// [edition_2021]edition:2021
6+
// [edition_2015]check-fail
7+
// [edition_2021]run-fail
8+
// [edition_2015]error-pattern:there is no argument named `x`
9+
// [edition_2021]error-pattern:internal error: entered unreachable code: x is 5 and y is 0
10+
11+
fn main() {
12+
let x = 5;
13+
unreachable!("x is {x} and y is {y}", y = 0);
14+
}

‎src/test/ui/non-fmt-panic.fixed

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ static S: &str = "{bla}";
1111
#[allow(unreachable_code)]
1212
fn main() {
1313
panic!("{}", "here's a brace: {"); //~ WARN panic message contains a brace
14+
unreachable!("{}", "here's a brace: {"); //~ WARN panic message contains a brace
1415
std::panic!("{}", "another one: }"); //~ WARN panic message contains a brace
1516
core::panic!("{}", "Hello {}"); //~ WARN panic message contains an unused formatting placeholder
1617
assert!(false, "{}", "{:03x} {test} bla");
@@ -24,6 +25,8 @@ fn main() {
2425
debug_assert!(false, "{}", "{{}} bla"); //~ WARN panic message contains braces
2526
panic!("{}", C); //~ WARN panic message is not a string literal
2627
panic!("{}", S); //~ WARN panic message is not a string literal
28+
unreachable!("{}", S); //~ WARN panic message is not a string literal
29+
unreachable!("{}", S); //~ WARN panic message is not a string literal
2730
std::panic::panic_any(123); //~ WARN panic message is not a string literal
2831
core::panic!("{}", &*"abc"); //~ WARN panic message is not a string literal
2932
std::panic::panic_any(Some(123)); //~ WARN panic message is not a string literal
@@ -41,8 +44,10 @@ fn main() {
4144
}
4245

4346
std::panic::panic_any(a!()); //~ WARN panic message is not a string literal
47+
unreachable!("{}", a!()); //~ WARN panic message is not a string literal
4448

4549
panic!("{}", 1); //~ WARN panic message is not a string literal
50+
unreachable!("{}", 1); //~ WARN panic message is not a string literal
4651
assert!(false, "{}", 1); //~ WARN panic message is not a string literal
4752
debug_assert!(false, "{}", 1); //~ WARN panic message is not a string literal
4853

‎src/test/ui/non-fmt-panic.rs

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ static S: &str = "{bla}";
1111
#[allow(unreachable_code)]
1212
fn main() {
1313
panic!("here's a brace: {"); //~ WARN panic message contains a brace
14+
unreachable!("here's a brace: {"); //~ WARN panic message contains a brace
1415
std::panic!("another one: }"); //~ WARN panic message contains a brace
1516
core::panic!("Hello {}"); //~ WARN panic message contains an unused formatting placeholder
1617
assert!(false, "{:03x} {test} bla");
@@ -24,6 +25,8 @@ fn main() {
2425
debug_assert!(false, "{{}} bla"); //~ WARN panic message contains braces
2526
panic!(C); //~ WARN panic message is not a string literal
2627
panic!(S); //~ WARN panic message is not a string literal
28+
unreachable!(S); //~ WARN panic message is not a string literal
29+
unreachable!(S); //~ WARN panic message is not a string literal
2730
std::panic!(123); //~ WARN panic message is not a string literal
2831
core::panic!(&*"abc"); //~ WARN panic message is not a string literal
2932
panic!(Some(123)); //~ WARN panic message is not a string literal
@@ -41,8 +44,10 @@ fn main() {
4144
}
4245

4346
panic!(a!()); //~ WARN panic message is not a string literal
47+
unreachable!(a!()); //~ WARN panic message is not a string literal
4448

4549
panic!(format!("{}", 1)); //~ WARN panic message is not a string literal
50+
unreachable!(format!("{}", 1)); //~ WARN panic message is not a string literal
4651
assert!(false, format!("{}", 1)); //~ WARN panic message is not a string literal
4752
debug_assert!(false, format!("{}", 1)); //~ WARN panic message is not a string literal
4853

‎src/test/ui/non-fmt-panic.stderr

+96-30
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,19 @@ LL | panic!("{}", "here's a brace: {");
1212
| +++++
1313

1414
warning: panic message contains a brace
15-
--> $DIR/non-fmt-panic.rs:14:31
15+
--> $DIR/non-fmt-panic.rs:14:35
16+
|
17+
LL | unreachable!("here's a brace: {");
18+
| ^
19+
|
20+
= note: this message is not used as a format string, but will be in Rust 2021
21+
help: add a "{}" format string to use the message literally
22+
|
23+
LL | unreachable!("{}", "here's a brace: {");
24+
| +++++
25+
26+
warning: panic message contains a brace
27+
--> $DIR/non-fmt-panic.rs:15:31
1628
|
1729
LL | std::panic!("another one: }");
1830
| ^
@@ -24,7 +36,7 @@ LL | std::panic!("{}", "another one: }");
2436
| +++++
2537

2638
warning: panic message contains an unused formatting placeholder
27-
--> $DIR/non-fmt-panic.rs:15:25
39+
--> $DIR/non-fmt-panic.rs:16:25
2840
|
2941
LL | core::panic!("Hello {}");
3042
| ^^
@@ -40,7 +52,7 @@ LL | core::panic!("{}", "Hello {}");
4052
| +++++
4153

4254
warning: panic message contains unused formatting placeholders
43-
--> $DIR/non-fmt-panic.rs:16:21
55+
--> $DIR/non-fmt-panic.rs:17:21
4456
|
4557
LL | assert!(false, "{:03x} {test} bla");
4658
| ^^^^^^ ^^^^^^
@@ -56,7 +68,7 @@ LL | assert!(false, "{}", "{:03x} {test} bla");
5668
| +++++
5769

5870
warning: panic message is not a string literal
59-
--> $DIR/non-fmt-panic.rs:18:20
71+
--> $DIR/non-fmt-panic.rs:19:20
6072
|
6173
LL | assert!(false, S);
6274
| ^
@@ -69,7 +81,7 @@ LL | assert!(false, "{}", S);
6981
| +++++
7082

7183
warning: panic message is not a string literal
72-
--> $DIR/non-fmt-panic.rs:20:20
84+
--> $DIR/non-fmt-panic.rs:21:20
7385
|
7486
LL | assert!(false, 123);
7587
| ^^^
@@ -82,7 +94,7 @@ LL | assert!(false, "{}", 123);
8294
| +++++
8395

8496
warning: panic message is not a string literal
85-
--> $DIR/non-fmt-panic.rs:22:20
97+
--> $DIR/non-fmt-panic.rs:23:20
8698
|
8799
LL | assert!(false, Some(123));
88100
| ^^^^^^^^^
@@ -95,7 +107,7 @@ LL | assert!(false, "{:?}", Some(123));
95107
| +++++++
96108

97109
warning: panic message contains braces
98-
--> $DIR/non-fmt-panic.rs:24:27
110+
--> $DIR/non-fmt-panic.rs:25:27
99111
|
100112
LL | debug_assert!(false, "{{}} bla");
101113
| ^^^^
@@ -107,7 +119,7 @@ LL | debug_assert!(false, "{}", "{{}} bla");
107119
| +++++
108120

109121
warning: panic message is not a string literal
110-
--> $DIR/non-fmt-panic.rs:25:12
122+
--> $DIR/non-fmt-panic.rs:26:12
111123
|
112124
LL | panic!(C);
113125
| ^
@@ -120,7 +132,7 @@ LL | panic!("{}", C);
120132
| +++++
121133

122134
warning: panic message is not a string literal
123-
--> $DIR/non-fmt-panic.rs:26:12
135+
--> $DIR/non-fmt-panic.rs:27:12
124136
|
125137
LL | panic!(S);
126138
| ^
@@ -133,7 +145,33 @@ LL | panic!("{}", S);
133145
| +++++
134146

135147
warning: panic message is not a string literal
136-
--> $DIR/non-fmt-panic.rs:27:17
148+
--> $DIR/non-fmt-panic.rs:28:18
149+
|
150+
LL | unreachable!(S);
151+
| ^
152+
|
153+
= note: this usage of unreachable!() is deprecated; it will be a hard error in Rust 2021
154+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
155+
help: add a "{}" format string to Display the message
156+
|
157+
LL | unreachable!("{}", S);
158+
| +++++
159+
160+
warning: panic message is not a string literal
161+
--> $DIR/non-fmt-panic.rs:29:18
162+
|
163+
LL | unreachable!(S);
164+
| ^
165+
|
166+
= note: this usage of unreachable!() is deprecated; it will be a hard error in Rust 2021
167+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
168+
help: add a "{}" format string to Display the message
169+
|
170+
LL | unreachable!("{}", S);
171+
| +++++
172+
173+
warning: panic message is not a string literal
174+
--> $DIR/non-fmt-panic.rs:30:17
137175
|
138176
LL | std::panic!(123);
139177
| ^^^
@@ -150,7 +188,7 @@ LL | std::panic::panic_any(123);
150188
| ~~~~~~~~~~~~~~~~~~~~~
151189

152190
warning: panic message is not a string literal
153-
--> $DIR/non-fmt-panic.rs:28:18
191+
--> $DIR/non-fmt-panic.rs:31:18
154192
|
155193
LL | core::panic!(&*"abc");
156194
| ^^^^^^^
@@ -163,7 +201,7 @@ LL | core::panic!("{}", &*"abc");
163201
| +++++
164202

165203
warning: panic message is not a string literal
166-
--> $DIR/non-fmt-panic.rs:29:12
204+
--> $DIR/non-fmt-panic.rs:32:12
167205
|
168206
LL | panic!(Some(123));
169207
| ^^^^^^^^^
@@ -180,7 +218,7 @@ LL | std::panic::panic_any(Some(123));
180218
| ~~~~~~~~~~~~~~~~~~~~~
181219

182220
warning: panic message contains an unused formatting placeholder
183-
--> $DIR/non-fmt-panic.rs:30:12
221+
--> $DIR/non-fmt-panic.rs:33:12
184222
|
185223
LL | panic!(concat!("{", "}"));
186224
| ^^^^^^^^^^^^^^^^^
@@ -196,7 +234,7 @@ LL | panic!("{}", concat!("{", "}"));
196234
| +++++
197235

198236
warning: panic message contains braces
199-
--> $DIR/non-fmt-panic.rs:31:5
237+
--> $DIR/non-fmt-panic.rs:34:5
200238
|
201239
LL | panic!(concat!("{", "{"));
202240
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -208,15 +246,15 @@ LL | panic!("{}", concat!("{", "{"));
208246
| +++++
209247

210248
warning: panic message contains an unused formatting placeholder
211-
--> $DIR/non-fmt-panic.rs:33:37
249+
--> $DIR/non-fmt-panic.rs:36:37
212250
|
213251
LL | fancy_panic::fancy_panic!("test {} 123");
214252
| ^^
215253
|
216254
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
217255

218256
warning: panic message is not a string literal
219-
--> $DIR/non-fmt-panic.rs:43:12
257+
--> $DIR/non-fmt-panic.rs:46:12
220258
|
221259
LL | panic!(a!());
222260
| ^^^^
@@ -233,7 +271,20 @@ LL | std::panic::panic_any(a!());
233271
| ~~~~~~~~~~~~~~~~~~~~~
234272

235273
warning: panic message is not a string literal
236-
--> $DIR/non-fmt-panic.rs:45:12
274+
--> $DIR/non-fmt-panic.rs:47:18
275+
|
276+
LL | unreachable!(a!());
277+
| ^^^^
278+
|
279+
= note: this usage of unreachable!() is deprecated; it will be a hard error in Rust 2021
280+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
281+
help: add a "{}" format string to Display the message
282+
|
283+
LL | unreachable!("{}", a!());
284+
| +++++
285+
286+
warning: panic message is not a string literal
287+
--> $DIR/non-fmt-panic.rs:49:12
237288
|
238289
LL | panic!(format!("{}", 1));
239290
| ^^^^^^^^^^^^^^^^
@@ -248,7 +299,22 @@ LL + panic!("{}", 1);
248299
|
249300

250301
warning: panic message is not a string literal
251-
--> $DIR/non-fmt-panic.rs:46:20
302+
--> $DIR/non-fmt-panic.rs:50:18
303+
|
304+
LL | unreachable!(format!("{}", 1));
305+
| ^^^^^^^^^^^^^^^^
306+
|
307+
= note: this usage of unreachable!() is deprecated; it will be a hard error in Rust 2021
308+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
309+
= note: the unreachable!() macro supports formatting, so there's no need for the format!() macro here
310+
help: remove the `format!(..)` macro call
311+
|
312+
LL - unreachable!(format!("{}", 1));
313+
LL + unreachable!("{}", 1);
314+
|
315+
316+
warning: panic message is not a string literal
317+
--> $DIR/non-fmt-panic.rs:51:20
252318
|
253319
LL | assert!(false, format!("{}", 1));
254320
| ^^^^^^^^^^^^^^^^
@@ -263,7 +329,7 @@ LL + assert!(false, "{}", 1);
263329
|
264330

265331
warning: panic message is not a string literal
266-
--> $DIR/non-fmt-panic.rs:47:26
332+
--> $DIR/non-fmt-panic.rs:52:26
267333
|
268334
LL | debug_assert!(false, format!("{}", 1));
269335
| ^^^^^^^^^^^^^^^^
@@ -278,7 +344,7 @@ LL + debug_assert!(false, "{}", 1);
278344
|
279345

280346
warning: panic message is not a string literal
281-
--> $DIR/non-fmt-panic.rs:49:12
347+
--> $DIR/non-fmt-panic.rs:54:12
282348
|
283349
LL | panic![123];
284350
| ^^^
@@ -295,7 +361,7 @@ LL | std::panic::panic_any(123);
295361
| ~~~~~~~~~~~~~~~~~~~~~~ ~
296362

297363
warning: panic message is not a string literal
298-
--> $DIR/non-fmt-panic.rs:50:12
364+
--> $DIR/non-fmt-panic.rs:55:12
299365
|
300366
LL | panic!{123};
301367
| ^^^
@@ -312,7 +378,7 @@ LL | std::panic::panic_any(123);
312378
| ~~~~~~~~~~~~~~~~~~~~~~ ~
313379

314380
warning: panic message is not a string literal
315-
--> $DIR/non-fmt-panic.rs:67:12
381+
--> $DIR/non-fmt-panic.rs:72:12
316382
|
317383
LL | panic!(v);
318384
| ------ ^
@@ -323,7 +389,7 @@ LL | panic!(v);
323389
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
324390

325391
warning: panic message is not a string literal
326-
--> $DIR/non-fmt-panic.rs:68:20
392+
--> $DIR/non-fmt-panic.rs:73:20
327393
|
328394
LL | assert!(false, v);
329395
| ^
@@ -332,7 +398,7 @@ LL | assert!(false, v);
332398
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
333399

334400
warning: panic message is not a string literal
335-
--> $DIR/non-fmt-panic.rs:72:12
401+
--> $DIR/non-fmt-panic.rs:77:12
336402
|
337403
LL | panic!(v);
338404
| ^
@@ -349,7 +415,7 @@ LL | std::panic::panic_any(v);
349415
| ~~~~~~~~~~~~~~~~~~~~~
350416

351417
warning: panic message is not a string literal
352-
--> $DIR/non-fmt-panic.rs:73:20
418+
--> $DIR/non-fmt-panic.rs:78:20
353419
|
354420
LL | assert!(false, v);
355421
| ^
@@ -362,7 +428,7 @@ LL | assert!(false, "{:?}", v);
362428
| +++++++
363429

364430
warning: panic message is not a string literal
365-
--> $DIR/non-fmt-panic.rs:77:12
431+
--> $DIR/non-fmt-panic.rs:82:12
366432
|
367433
LL | panic!(v);
368434
| ^
@@ -379,7 +445,7 @@ LL | std::panic::panic_any(v);
379445
| ~~~~~~~~~~~~~~~~~~~~~
380446

381447
warning: panic message is not a string literal
382-
--> $DIR/non-fmt-panic.rs:78:20
448+
--> $DIR/non-fmt-panic.rs:83:20
383449
|
384450
LL | assert!(false, v);
385451
| ^
@@ -392,7 +458,7 @@ LL | assert!(false, "{}", v);
392458
| +++++
393459

394460
warning: panic message is not a string literal
395-
--> $DIR/non-fmt-panic.rs:82:12
461+
--> $DIR/non-fmt-panic.rs:87:12
396462
|
397463
LL | panic!(v);
398464
| ^
@@ -409,7 +475,7 @@ LL | std::panic::panic_any(v);
409475
| ~~~~~~~~~~~~~~~~~~~~~
410476

411477
warning: panic message is not a string literal
412-
--> $DIR/non-fmt-panic.rs:83:20
478+
--> $DIR/non-fmt-panic.rs:88:20
413479
|
414480
LL | assert!(false, v);
415481
| ^
@@ -421,5 +487,5 @@ help: add a "{}" format string to Display the message
421487
LL | assert!(false, "{}", v);
422488
| +++++
423489

424-
warning: 30 warnings emitted
490+
warning: 35 warnings emitted
425491

‎src/test/ui/proc-macro/quote-debug.stdout

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ fn main() {
3535
lit.set_span(crate::Span::recover_proc_macro_span(2));
3636
lit
3737
} else {
38-
{
39-
::core::panicking::panic("internal error: entered unreachable code")
40-
}
38+
::core::panicking::panic("internal error: entered unreachable code")
4139
}
4240
})),
4341
crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3b}',

‎src/tools/clippy/tests/ui/panic_in_result_fn.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ note: return Err() instead of panicking
4848
|
4949
LL | unreachable!();
5050
| ^^^^^^^^^^^^^^
51-
= note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
51+
= note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
5252

5353
error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
5454
--> $DIR/panic_in_result_fn.rs:21:5

‎src/tools/clippy/tests/ui/panicking_macros.stderr

+2-5
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,22 @@ LL | unreachable!();
7575
| ^^^^^^^^^^^^^^
7676
|
7777
= note: `-D clippy::unreachable` implied by `-D warnings`
78-
= note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
7978

8079
error: usage of the `unreachable!` macro
8180
--> $DIR/panicking_macros.rs:33:5
8281
|
8382
LL | unreachable!("message");
8483
| ^^^^^^^^^^^^^^^^^^^^^^^
8584
|
86-
= note: this error originates in the macro `$crate::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
85+
= note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
8786

8887
error: usage of the `unreachable!` macro
8988
--> $DIR/panicking_macros.rs:34:5
9089
|
9190
LL | unreachable!("{} {}", "panic with", "multiple arguments");
9291
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9392
|
94-
= note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
93+
= note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
9594

9695
error: `panic` should not be present in production code
9796
--> $DIR/panicking_macros.rs:40:5
@@ -120,8 +119,6 @@ error: usage of the `unreachable!` macro
120119
|
121120
LL | unreachable!();
122121
| ^^^^^^^^^^^^^^
123-
|
124-
= note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
125122

126123
error: aborting due to 16 previous errors
127124

0 commit comments

Comments
 (0)
Please sign in to comment.