Skip to content

Commit 61885df

Browse files
committedAug 12, 2021
Auto merge of #87980 - Manishearth:rollup-vkuix3y, r=Manishearth
Rollup of 4 pull requests Successful merges: - #87916 (Implement `black_box` using intrinsic) - #87922 (Add c_enum_min_bits target spec field, use for arm-none and thumb-none targets) - #87953 (Improve formatting of closure capture migration suggestion for multi-line closures.) - #87965 (Silence non_fmt_panic from external macros.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0fa3190 + 2d27976 commit 61885df

34 files changed

+667
-113
lines changed
 

‎compiler/rustc_lint/src/non_fmt_panic.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::{LateContext, LateLintPass, LintContext};
22
use rustc_ast as ast;
33
use rustc_errors::{pluralize, Applicability};
44
use rustc_hir as hir;
5+
use rustc_middle::lint::in_external_macro;
56
use rustc_middle::ty;
67
use rustc_parse_format::{ParseMode, Parser, Piece};
78
use rustc_session::lint::FutureIncompatibilityReason;
@@ -75,6 +76,11 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
7576

7677
let (span, panic, symbol_str) = panic_call(cx, f);
7778

79+
if in_external_macro(cx.sess(), span) {
80+
// Nothing that can be done about it in the current crate.
81+
return;
82+
}
83+
7884
// Find the span of the argument to `panic!()`, before expansion in the
7985
// case of `panic!(some_macro!())`.
8086
// We don't use source_callsite(), because this `panic!(..)` might itself
@@ -152,6 +158,13 @@ fn check_panic_str<'tcx>(
152158
return;
153159
}
154160

161+
let (span, _, _) = panic_call(cx, f);
162+
163+
if in_external_macro(cx.sess(), span) && in_external_macro(cx.sess(), arg.span) {
164+
// Nothing that can be done about it in the current crate.
165+
return;
166+
}
167+
155168
let fmt_span = arg.span.source_callsite();
156169

157170
let (snippet, style) = match cx.sess().parse_sess.source_map().span_to_snippet(fmt_span) {
@@ -167,8 +180,6 @@ fn check_panic_str<'tcx>(
167180
Parser::new(fmt.as_ref(), style, snippet.clone(), false, ParseMode::Format);
168181
let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count();
169182

170-
let (span, _, _) = panic_call(cx, f);
171-
172183
if n_arguments > 0 && fmt_parser.errors.is_empty() {
173184
let arg_spans: Vec<_> = match &fmt_parser.arg_places[..] {
174185
[] => vec![fmt_span],

‎compiler/rustc_middle/src/ty/layout.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ impl IntegerExt for Integer {
112112
let unsigned_fit = Integer::fit_unsigned(cmp::max(min as u128, max as u128));
113113
let signed_fit = cmp::max(Integer::fit_signed(min), Integer::fit_signed(max));
114114

115-
let mut min_from_extern = None;
116-
let min_default = I8;
117-
118115
if let Some(ity) = repr.int {
119116
let discr = Integer::from_attr(&tcx, ity);
120117
let fit = if ity.is_signed() { signed_fit } else { unsigned_fit };
@@ -128,19 +125,14 @@ impl IntegerExt for Integer {
128125
return (discr, ity.is_signed());
129126
}
130127

131-
if repr.c() {
132-
match &tcx.sess.target.arch[..] {
133-
"hexagon" => min_from_extern = Some(I8),
134-
// WARNING: the ARM EABI has two variants; the one corresponding
135-
// to `at_least == I32` appears to be used on Linux and NetBSD,
136-
// but some systems may use the variant corresponding to no
137-
// lower bound. However, we don't run on those yet...?
138-
"arm" => min_from_extern = Some(I32),
139-
_ => min_from_extern = Some(I32),
140-
}
141-
}
142-
143-
let at_least = min_from_extern.unwrap_or(min_default);
128+
let at_least = if repr.c() {
129+
// This is usually I32, however it can be different on some platforms,
130+
// notably hexagon and arm-none/thumb-none
131+
tcx.data_layout().c_enum_min_size
132+
} else {
133+
// repr(Rust) enums try to be as small as possible
134+
I8
135+
};
144136

145137
// If there are no negative values, we can use the unsigned fit.
146138
if min >= 0 {

‎compiler/rustc_target/src/abi/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub struct TargetDataLayout {
3636
pub vector_align: Vec<(Size, AbiAndPrefAlign)>,
3737

3838
pub instruction_address_space: AddressSpace,
39+
40+
/// Minimum size of #[repr(C)] enums (default I32 bits)
41+
pub c_enum_min_size: Integer,
3942
}
4043

4144
impl Default for TargetDataLayout {
@@ -60,6 +63,7 @@ impl Default for TargetDataLayout {
6063
(Size::from_bits(128), AbiAndPrefAlign::new(align(128))),
6164
],
6265
instruction_address_space: AddressSpace::DATA,
66+
c_enum_min_size: Integer::I32,
6367
}
6468
}
6569
}
@@ -173,6 +177,8 @@ impl TargetDataLayout {
173177
));
174178
}
175179

180+
dl.c_enum_min_size = Integer::from_size(Size::from_bits(target.c_enum_min_bits))?;
181+
176182
Ok(dl)
177183
}
178184

@@ -610,6 +616,17 @@ impl Integer {
610616
}
611617
I8
612618
}
619+
620+
fn from_size(size: Size) -> Result<Self, String> {
621+
match size.bits() {
622+
8 => Ok(Integer::I8),
623+
16 => Ok(Integer::I16),
624+
32 => Ok(Integer::I32),
625+
64 => Ok(Integer::I64),
626+
128 => Ok(Integer::I128),
627+
_ => Err(format!("rust does not support integers with {} bits", size.bits())),
628+
}
629+
}
613630
}
614631

615632
/// Fundamental unit of memory access and layout.

‎compiler/rustc_target/src/spec/armebv7r_none_eabi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn target() -> Target {
2020
panic_strategy: PanicStrategy::Abort,
2121
max_atomic_width: Some(32),
2222
emit_debug_gdb_scripts: false,
23+
// GCC and Clang default to 8 for arm-none here
24+
c_enum_min_bits: 8,
2325
..Default::default()
2426
},
2527
}

‎compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub fn target() -> Target {
2121
features: "+vfp3,-d32,-fp16".to_string(),
2222
max_atomic_width: Some(32),
2323
emit_debug_gdb_scripts: false,
24+
// GCC and Clang default to 8 for arm-none here
25+
c_enum_min_bits: 8,
2426
..Default::default()
2527
},
2628
}

‎compiler/rustc_target/src/spec/armv7a_none_eabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub fn target() -> Target {
2828
max_atomic_width: Some(64),
2929
panic_strategy: PanicStrategy::Abort,
3030
emit_debug_gdb_scripts: false,
31+
c_enum_min_bits: 8,
3132
..Default::default()
3233
};
3334
Target {

‎compiler/rustc_target/src/spec/armv7a_none_eabihf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub fn target() -> Target {
1919
max_atomic_width: Some(64),
2020
panic_strategy: PanicStrategy::Abort,
2121
emit_debug_gdb_scripts: false,
22+
// GCC and Clang default to 8 for arm-none here
23+
c_enum_min_bits: 8,
2224
..Default::default()
2325
};
2426
Target {

‎compiler/rustc_target/src/spec/armv7r_none_eabi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub fn target() -> Target {
1919
panic_strategy: PanicStrategy::Abort,
2020
max_atomic_width: Some(32),
2121
emit_debug_gdb_scripts: false,
22+
// GCC and Clang default to 8 for arm-none here
23+
c_enum_min_bits: 8,
2224
..Default::default()
2325
},
2426
}

‎compiler/rustc_target/src/spec/armv7r_none_eabihf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn target() -> Target {
2020
features: "+vfp3,-d32,-fp16".to_string(),
2121
max_atomic_width: Some(32),
2222
emit_debug_gdb_scripts: false,
23+
// GCC and Clang default to 8 for arm-none here
24+
c_enum_min_bits: 8,
2325
..Default::default()
2426
},
2527
}

‎compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub fn target() -> Target {
1313
base.dynamic_linking = true;
1414
base.executables = true;
1515

16+
base.c_enum_min_bits = 8;
17+
1618
Target {
1719
llvm_target: "hexagon-unknown-linux-musl".to_string(),
1820
pointer_width: 32,

‎compiler/rustc_target/src/spec/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,9 @@ pub struct TargetOptions {
13361336

13371337
/// If present it's a default value to use for adjusting the C ABI.
13381338
pub default_adjusted_cabi: Option<Abi>,
1339+
1340+
/// Minimum number of bits in #[repr(C)] enum. Defaults to 32.
1341+
pub c_enum_min_bits: u64,
13391342
}
13401343

13411344
impl Default for TargetOptions {
@@ -1440,6 +1443,7 @@ impl Default for TargetOptions {
14401443
split_debuginfo: SplitDebuginfo::Off,
14411444
supported_sanitizers: SanitizerSet::empty(),
14421445
default_adjusted_cabi: None,
1446+
c_enum_min_bits: 32,
14431447
}
14441448
}
14451449
}
@@ -1604,6 +1608,12 @@ impl Target {
16041608
base.$key_name = s;
16051609
}
16061610
} );
1611+
($key_name:ident, u64) => ( {
1612+
let name = (stringify!($key_name)).replace("_", "-");
1613+
if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_u64(&j)) {
1614+
base.$key_name = s;
1615+
}
1616+
} );
16071617
($key_name:ident, Option<u32>) => ( {
16081618
let name = (stringify!($key_name)).replace("_", "-");
16091619
if let Some(s) = obj.remove_key(&name).and_then(|j| Json::as_u64(&j)) {
@@ -2017,6 +2027,7 @@ impl Target {
20172027
key!(split_debuginfo, SplitDebuginfo)?;
20182028
key!(supported_sanitizers, SanitizerSet)?;
20192029
key!(default_adjusted_cabi, Option<Abi>)?;
2030+
key!(c_enum_min_bits, u64);
20202031

20212032
if base.is_builtin {
20222033
// This can cause unfortunate ICEs later down the line.
@@ -2255,6 +2266,7 @@ impl ToJson for Target {
22552266
target_option_val!(has_thumb_interworking);
22562267
target_option_val!(split_debuginfo);
22572268
target_option_val!(supported_sanitizers);
2269+
target_option_val!(c_enum_min_bits);
22582270

22592271
if let Some(abi) = self.default_adjusted_cabi {
22602272
d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json());

‎compiler/rustc_target/src/spec/thumb_base.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ pub fn opts() -> TargetOptions {
5353
// LLVM is eager to trash the link register when calling `noreturn` functions, which
5454
// breaks debugging. Preserve LR by default to prevent that from happening.
5555
frame_pointer: FramePointer::Always,
56+
// ARM supports multiple ABIs for enums, the linux one matches the default of 32 here
57+
// but any arm-none or thumb-none target will be defaulted to 8 on GCC and clang
58+
c_enum_min_bits: 8,
5659
..Default::default()
5760
}
5861
}

‎compiler/rustc_typeck/src/check/upvar.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
649649
match self.tcx.sess.source_map().span_to_snippet(closure_body_span) {
650650
Ok(s) => {
651651
let trimmed = s.trim_start();
652+
let mut lines = trimmed.lines();
653+
let line1 = lines.next().unwrap_or_default();
652654

653655
// If the closure contains a block then replace the opening brace
654656
// with "{ let _ = (..); "
655-
let sugg = if let Some('{') = trimmed.chars().next() {
656-
format!("{{ {}; {}", migration_string, &trimmed[1..])
657+
let sugg = if line1.trim_end() == "{" {
658+
// This is a multi-line closure with just a `{` on the first line,
659+
// so we put the `let` on its own line.
660+
// We take the indentation from the next non-empty line.
661+
let line2 = lines.filter(|line| !line.is_empty()).next().unwrap_or_default();
662+
let indent = line2.split_once(|c: char| !c.is_whitespace()).unwrap_or_default().0;
663+
format!("{{\n{}{};{}", indent, migration_string, &trimmed[line1.len()..])
664+
} else if line1.starts_with('{') {
665+
format!("{{ {}; {}", migration_string, &trimmed[1..].trim_start())
657666
} else {
658667
format!("{{ {}; {} }}", migration_string, s)
659668
};

‎src/test/ui/auxiliary/fancy-panic.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#[macro_export]
22
macro_rules! fancy_panic {
3+
() => {
4+
panic!("{}");
5+
};
36
($msg:expr) => {
47
panic!($msg)
58
};

‎src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ impl Clone for U {
5555

5656
fn test_clone_trait() {
5757
let f = U(S(String::from("Hello World")), T(0));
58-
let c = || { let _ = &f;
58+
let c = || {
59+
let _ = &f;
5960
//~^ ERROR: `Clone` trait implementation for closure and drop order
6061
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f.1` does not implement `Clone`
6162
//~| NOTE: for more information, see

‎src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ LL | }
5858
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
5959
help: add a dummy let to cause `f` to be fully captured
6060
|
61-
LL ~ let c = || { let _ = &f;
61+
LL ~ let c = || {
62+
LL + let _ = &f;
6263
LL +
6364
LL +
6465
LL +
6566
LL +
66-
LL + let f_1 = f.1;
6767
...
6868

6969
error: aborting due to 3 previous errors

‎src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ fn test1_all_need_migration() {
1212
let t1 = (String::new(), String::new());
1313
let t2 = (String::new(), String::new());
1414

15-
let c = || { let _ = (&t, &t1, &t2);
15+
let c = || {
16+
let _ = (&t, &t1, &t2);
1617
//~^ ERROR: drop order
1718
//~| NOTE: for more information, see
1819
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
@@ -38,7 +39,8 @@ fn test2_only_precise_paths_need_migration() {
3839
let t1 = (String::new(), String::new());
3940
let t2 = (String::new(), String::new());
4041

41-
let c = || { let _ = (&t, &t1);
42+
let c = || {
43+
let _ = (&t, &t1);
4244
//~^ ERROR: drop order
4345
//~| NOTE: for more information, see
4446
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
@@ -59,7 +61,8 @@ fn test2_only_precise_paths_need_migration() {
5961
fn test3_only_by_value_need_migration() {
6062
let t = (String::new(), String::new());
6163
let t1 = (String::new(), String::new());
62-
let c = || { let _ = &t;
64+
let c = || {
65+
let _ = &t;
6366
//~^ ERROR: drop order
6467
//~| NOTE: for more information, see
6568
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -80,7 +83,8 @@ fn test4_only_non_copy_types_need_migration() {
8083
// `t1` is Copy because all of its elements are Copy
8184
let t1 = (0i32, 0i32);
8285

83-
let c = || { let _ = &t;
86+
let c = || {
87+
let _ = &t;
8488
//~^ ERROR: drop order
8589
//~| NOTE: for more information, see
8690
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -101,7 +105,8 @@ fn test5_only_drop_types_need_migration() {
101105
// `s` doesn't implement Drop or any elements within it, and doesn't need migration
102106
let s = S(0i32, 0i32);
103107

104-
let c = || { let _ = &t;
108+
let c = || {
109+
let _ = &t;
105110
//~^ ERROR: drop order
106111
//~| NOTE: for more information, see
107112
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -119,7 +124,8 @@ fn test5_only_drop_types_need_migration() {
119124
fn test6_move_closures_non_copy_types_might_need_migration() {
120125
let t = (String::new(), String::new());
121126
let t1 = (String::new(), String::new());
122-
let c = move || { let _ = (&t1, &t);
127+
let c = move || {
128+
let _ = (&t1, &t);
123129
//~^ ERROR: drop order
124130
//~| NOTE: for more information, see
125131
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
@@ -139,7 +145,8 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
139145
fn test7_drop_non_drop_aggregate_need_migration() {
140146
let t = (String::new(), String::new(), 0i32);
141147

142-
let c = || { let _ = &t;
148+
let c = || {
149+
let _ = &t;
143150
//~^ ERROR: drop order
144151
//~| NOTE: for more information, see
145152
//~| HELP: add a dummy let to cause `t` to be fully captured

‎src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
2828
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
2929
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
3030
|
31-
LL ~ let c = || { let _ = (&t, &t1, &t2);
31+
LL ~ let c = || {
32+
LL + let _ = (&t, &t1, &t2);
3233
LL +
3334
LL +
3435
LL +
3536
LL +
36-
LL + let _t = t.0;
3737
...
3838

3939
error: changes to closure capture in Rust 2021 will affect drop order
@@ -57,12 +57,12 @@ LL | }
5757
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
5858
help: add a dummy let to cause `t`, `t1` to be fully captured
5959
|
60-
LL ~ let c = || { let _ = (&t, &t1);
60+
LL ~ let c = || {
61+
LL + let _ = (&t, &t1);
6162
LL +
6263
LL +
6364
LL +
6465
LL + let _t = t.0;
65-
LL +
6666
...
6767

6868
error: changes to closure capture in Rust 2021 will affect drop order
@@ -80,12 +80,12 @@ LL | }
8080
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
8181
help: add a dummy let to cause `t` to be fully captured
8282
|
83-
LL ~ let c = || { let _ = &t;
83+
LL ~ let c = || {
84+
LL + let _ = &t;
8485
LL +
8586
LL +
8687
LL +
8788
LL + let _t = t.0;
88-
LL +
8989
...
9090

9191
error: changes to closure capture in Rust 2021 will affect drop order
@@ -103,12 +103,12 @@ LL | }
103103
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
104104
help: add a dummy let to cause `t` to be fully captured
105105
|
106-
LL ~ let c = || { let _ = &t;
106+
LL ~ let c = || {
107+
LL + let _ = &t;
107108
LL +
108109
LL +
109110
LL +
110111
LL + let _t = t.0;
111-
LL +
112112
...
113113

114114
error: changes to closure capture in Rust 2021 will affect drop order
@@ -126,12 +126,12 @@ LL | }
126126
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
127127
help: add a dummy let to cause `t` to be fully captured
128128
|
129-
LL ~ let c = || { let _ = &t;
129+
LL ~ let c = || {
130+
LL + let _ = &t;
130131
LL +
131132
LL +
132133
LL +
133134
LL + let _t = t.0;
134-
LL +
135135
...
136136

137137
error: changes to closure capture in Rust 2021 will affect drop order
@@ -154,12 +154,12 @@ LL | }
154154
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
155155
help: add a dummy let to cause `t1`, `t` to be fully captured
156156
|
157-
LL ~ let c = move || { let _ = (&t1, &t);
157+
LL ~ let c = move || {
158+
LL + let _ = (&t1, &t);
158159
LL +
159160
LL +
160161
LL +
161162
LL + println!("{} {}", t1.1, t.1);
162-
LL +
163163
...
164164

165165
error: changes to closure capture in Rust 2021 will affect drop order
@@ -177,12 +177,12 @@ LL | }
177177
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
178178
help: add a dummy let to cause `t` to be fully captured
179179
|
180-
LL ~ let c = || { let _ = &t;
180+
LL ~ let c = || {
181+
LL + let _ = &t;
181182
LL +
182183
LL +
183184
LL +
184185
LL + let _t = t.0;
185-
LL +
186186
...
187187

188188
error: aborting due to 7 previous errors

‎src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ impl<T> Drop for GenericStruct<T> {
3434
fn significant_drop_needs_migration() {
3535
let t = (SigDrop {}, SigDrop {});
3636

37-
let c = || { let _ = &t;
37+
let c = || {
38+
let _ = &t;
3839
//~^ ERROR: drop order
3940
//~| NOTE: for more information, see
4041
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -54,7 +55,8 @@ fn generic_struct_with_significant_drop_needs_migration() {
5455
let t = Wrapper(GenericStruct(SigDrop {}, SigDrop {}), 5);
5556

5657
// move is used to force i32 to be copied instead of being a ref
57-
let c = move || { let _ = &t;
58+
let c = move || {
59+
let _ = &t;
5860
//~^ ERROR: drop order
5961
//~| NOTE: for more information, see
6062
//~| HELP: add a dummy let to cause `t` to be fully captured

‎src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
1818
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
1919
help: add a dummy let to cause `t` to be fully captured
2020
|
21-
LL ~ let c = || { let _ = &t;
21+
LL ~ let c = || {
22+
LL + let _ = &t;
2223
LL +
2324
LL +
2425
LL +
2526
LL + let _t = t.0;
26-
LL +
2727
...
2828

2929
error: changes to closure capture in Rust 2021 will affect drop order
@@ -41,12 +41,12 @@ LL | }
4141
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
4242
help: add a dummy let to cause `t` to be fully captured
4343
|
44-
LL ~ let c = move || { let _ = &t;
44+
LL ~ let c = move || {
45+
LL + let _ = &t;
4546
LL +
4647
LL +
4748
LL +
4849
LL + let _t = t.1;
49-
LL +
5050
...
5151

5252
error: aborting due to 2 previous errors

‎src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ impl Drop for Foo {
1616

1717
fn closure_contains_block() {
1818
let t = (Foo(0), Foo(0));
19-
let c = || { let _ = &t;
19+
let c = || {
20+
let _ = &t;
2021
//~^ ERROR: drop order
2122
//~| NOTE: for more information, see
2223
//~| HELP: add a dummy let to cause `t` to be fully captured

‎src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
1818
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
1919
help: add a dummy let to cause `t` to be fully captured
2020
|
21-
LL ~ let c = || { let _ = &t;
21+
LL ~ let c = || {
22+
LL + let _ = &t;
2223
LL +
2324
LL +
2425
LL +
2526
LL + let _t = t.0;
26-
LL +
2727
...
2828

2929
error: changes to closure capture in Rust 2021 will affect drop order

‎src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ where
1717
F: FnOnce(),
1818
{
1919
let f = panic::AssertUnwindSafe(f);
20-
let result = panic::catch_unwind(move || { let _ = &f;
20+
let result = panic::catch_unwind(move || {
21+
let _ = &f;
2122
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation for closure
2223
//~| NOTE: in Rust 2018, this closure would implement `UnwindSafe`, `RefUnwindSafe` as `f` implements `UnwindSafe`, `RefUnwindSafe`, but in Rust 2021, this closure would no longer implement `UnwindSafe`, `RefUnwindSafe` as `f.0` does not implement `UnwindSafe`, `RefUnwindSafe`
2324
//~| NOTE: for more information, see

‎src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
1515
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
1616
help: add a dummy let to cause `f` to be fully captured
1717
|
18-
LL ~ let result = panic::catch_unwind(move || { let _ = &f;
18+
LL ~ let result = panic::catch_unwind(move || {
19+
LL + let _ = &f;
1920
LL +
2021
LL +
2122
LL +
2223
LL +
23-
LL + f.0()
2424
...
2525

2626
error: aborting due to previous error

‎src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ impl Clone for U {
2020
fn test_multi_issues() {
2121
let f1 = U(S(String::from("foo")), T(0));
2222
let f2 = U(S(String::from("bar")), T(0));
23-
let c = || { let _ = (&f1, &f2);
23+
let c = || {
24+
let _ = (&f1, &f2);
2425
//~^ ERROR: `Clone` trait implementation for closure and drop order
2526
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
2627
//~| NOTE: for more information, see
@@ -39,7 +40,8 @@ fn test_multi_issues() {
3940

4041
fn test_capturing_all_disjoint_fields_individually() {
4142
let f1 = U(S(String::from("foo")), T(0));
42-
let c = || { let _ = &f1;
43+
let c = || {
44+
let _ = &f1;
4345
//~^ ERROR: `Clone` trait implementation for closure
4446
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
4547
//~| NOTE: for more information, see
@@ -64,7 +66,8 @@ impl Clone for U1 {
6466

6567
fn test_capturing_several_disjoint_fields_individually_1() {
6668
let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar")));
67-
let c = || { let _ = &f1;
69+
let c = || {
70+
let _ = &f1;
6871
//~^ ERROR: `Clone` trait implementation for closure
6972
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
7073
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.2` does not implement `Clone`
@@ -83,7 +86,8 @@ fn test_capturing_several_disjoint_fields_individually_1() {
8386

8487
fn test_capturing_several_disjoint_fields_individually_2() {
8588
let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar")));
86-
let c = || { let _ = &f1;
89+
let c = || {
90+
let _ = &f1;
8791
//~^ ERROR: `Clone` trait implementation for closure and drop order
8892
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
8993
//~| NOTE: for more information, see

‎src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
2121
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
2222
help: add a dummy let to cause `f1`, `f2` to be fully captured
2323
|
24-
LL ~ let c = || { let _ = (&f1, &f2);
24+
LL ~ let c = || {
25+
LL + let _ = (&f1, &f2);
2526
LL +
2627
LL +
2728
LL +
2829
LL +
29-
LL + let _f_1 = f1.0;
3030
...
3131

3232
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure
@@ -41,12 +41,12 @@ LL | let _f_1 = f1.0;
4141
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
4242
help: add a dummy let to cause `f1` to be fully captured
4343
|
44-
LL ~ let c = || { let _ = &f1;
44+
LL ~ let c = || {
45+
LL + let _ = &f1;
4546
LL +
4647
LL +
4748
LL +
4849
LL +
49-
LL + let _f_1 = f1.0;
5050
...
5151

5252
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure
@@ -67,8 +67,8 @@ LL | let _f_2 = f1.2;
6767
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
6868
help: add a dummy let to cause `f1` to be fully captured
6969
|
70-
LL ~ let c = || { let _ = &f1;
71-
LL +
70+
LL ~ let c = || {
71+
LL + let _ = &f1;
7272
LL +
7373
LL +
7474
LL +
@@ -96,12 +96,12 @@ LL | }
9696
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
9797
help: add a dummy let to cause `f1` to be fully captured
9898
|
99-
LL ~ let c = || { let _ = &f1;
99+
LL ~ let c = || {
100+
LL + let _ = &f1;
100101
LL +
101102
LL +
102103
LL +
103104
LL +
104-
LL + let _f_0 = f1.0;
105105
...
106106

107107
error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` trait implementation for closure

‎src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ struct ConstainsDropField(Foo, Foo);
1717
fn test_precise_analysis_drop_paths_not_captured_by_move() {
1818
let t = ConstainsDropField(Foo(10), Foo(20));
1919

20-
let c = || { let _ = &t;
20+
let c = || {
21+
let _ = &t;
2122
//~^ ERROR: drop order
2223
//~| NOTE: for more information, see
2324
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -42,7 +43,8 @@ struct U(T, T);
4243
fn test_precise_analysis_long_path_missing() {
4344
let u = U(T(S, S), T(S, S));
4445

45-
let c = || { let _ = &u;
46+
let c = || {
47+
let _ = &u;
4648
//~^ ERROR: drop order
4749
//~| NOTE: for more information, see
4850
//~| HELP: add a dummy let to cause `u` to be fully captured

‎src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
1818
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
1919
help: add a dummy let to cause `t` to be fully captured
2020
|
21-
LL ~ let c = || { let _ = &t;
21+
LL ~ let c = || {
22+
LL + let _ = &t;
2223
LL +
2324
LL +
2425
LL +
2526
LL + let _t = t.0;
26-
LL +
2727
...
2828

2929
error: changes to closure capture in Rust 2021 will affect drop order
@@ -51,12 +51,12 @@ LL | }
5151
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
5252
help: add a dummy let to cause `u` to be fully captured
5353
|
54-
LL ~ let c = || { let _ = &u;
54+
LL ~ let c = || {
55+
LL + let _ = &u;
5556
LL +
5657
LL +
5758
LL +
5859
LL + let _x = u.0.0;
59-
LL +
6060
...
6161

6262
error: aborting due to 2 previous errors

‎src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fn test1_all_need_migration() {
2222
let t1 = (Foo(0), Foo(0));
2323
let t2 = (Foo(0), Foo(0));
2424

25-
let c = || { let _ = (&t, &t1, &t2);
25+
let c = || {
26+
let _ = (&t, &t1, &t2);
2627
//~^ ERROR: drop order
2728
//~| NOTE: for more information, see
2829
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
@@ -47,7 +48,8 @@ fn test2_only_precise_paths_need_migration() {
4748
let t1 = (Foo(0), Foo(0));
4849
let t2 = (Foo(0), Foo(0));
4950

50-
let c = || { let _ = (&t, &t1);
51+
let c = || {
52+
let _ = (&t, &t1);
5153
//~^ ERROR: drop order
5254
//~| NOTE: for more information, see
5355
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
@@ -68,7 +70,8 @@ fn test2_only_precise_paths_need_migration() {
6870
fn test3_only_by_value_need_migration() {
6971
let t = (Foo(0), Foo(0));
7072
let t1 = (Foo(0), Foo(0));
71-
let c = || { let _ = &t;
73+
let c = || {
74+
let _ = &t;
7275
//~^ ERROR: drop order
7376
//~| NOTE: for more information, see
7477
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -88,7 +91,8 @@ fn test3_only_by_value_need_migration() {
8891
fn test4_type_contains_drop_need_migration() {
8992
let t = ConstainsDropField(Foo(0), Foo(0));
9093

91-
let c = || { let _ = &t;
94+
let c = || {
95+
let _ = &t;
9296
//~^ ERROR: drop order
9397
//~| NOTE: for more information, see
9498
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -106,7 +110,8 @@ fn test4_type_contains_drop_need_migration() {
106110
fn test5_drop_non_drop_aggregate_need_migration() {
107111
let t = (Foo(0), Foo(0), 0i32);
108112

109-
let c = || { let _ = &t;
113+
let c = || {
114+
let _ = &t;
110115
//~^ ERROR: drop order
111116
//~| NOTE: for more information, see
112117
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -122,7 +127,8 @@ fn test5_drop_non_drop_aggregate_need_migration() {
122127
fn test6_significant_insignificant_drop_aggregate_need_migration() {
123128
let t = (Foo(0), String::new());
124129

125-
let c = || { let _ = &t;
130+
let c = || {
131+
let _ = &t;
126132
//~^ ERROR: drop order
127133
//~| NOTE: for more information, see
128134
//~| HELP: add a dummy let to cause `t` to be fully captured
@@ -140,7 +146,8 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
140146
let t = (Foo(0), Foo(0));
141147
let t1 = (Foo(0), Foo(0), Foo(0));
142148

143-
let c = move || { let _ = (&t1, &t);
149+
let c = move || {
150+
let _ = (&t1, &t);
144151
//~^ ERROR: drop order
145152
//~| NOTE: for more information, see
146153
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
@@ -160,7 +167,8 @@ fn test8_drop_order_and_blocks() {
160167
let tuple =
161168
(String::from("foo"), String::from("bar"));
162169
{
163-
let c = || { let _ = &tuple;
170+
let c = || {
171+
let _ = &tuple;
164172
//~^ ERROR: drop order
165173
//~| NOTE: for more information, see
166174
//~| HELP: add a dummy let to cause `tuple` to be fully captured
@@ -178,7 +186,8 @@ fn test9_drop_order_and_nested_closures() {
178186
let tuple =
179187
(String::from("foo"), String::from("bar"));
180188
let b = || {
181-
let c = || { let _ = &tuple;
189+
let c = || {
190+
let _ = &tuple;
182191
//~^ ERROR: drop order
183192
//~| NOTE: for more information, see
184193
//~| HELP: add a dummy let to cause `tuple` to be fully captured

‎src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ LL | #![deny(rust_2021_incompatible_closure_captures)]
2828
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
2929
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
3030
|
31-
LL ~ let c = || { let _ = (&t, &t1, &t2);
31+
LL ~ let c = || {
32+
LL + let _ = (&t, &t1, &t2);
3233
LL +
3334
LL +
3435
LL +
3536
LL + let _t = t.0;
36-
LL +
3737
...
3838

3939
error: changes to closure capture in Rust 2021 will affect drop order
@@ -57,12 +57,12 @@ LL | }
5757
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
5858
help: add a dummy let to cause `t`, `t1` to be fully captured
5959
|
60-
LL ~ let c = || { let _ = (&t, &t1);
60+
LL ~ let c = || {
61+
LL + let _ = (&t, &t1);
6162
LL +
6263
LL +
6364
LL +
6465
LL + let _t = t.0;
65-
LL +
6666
...
6767

6868
error: changes to closure capture in Rust 2021 will affect drop order
@@ -80,12 +80,12 @@ LL | }
8080
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
8181
help: add a dummy let to cause `t` to be fully captured
8282
|
83-
LL ~ let c = || { let _ = &t;
83+
LL ~ let c = || {
84+
LL + let _ = &t;
8485
LL +
8586
LL +
8687
LL +
8788
LL + let _t = t.0;
88-
LL +
8989
...
9090

9191
error: changes to closure capture in Rust 2021 will affect drop order
@@ -103,12 +103,12 @@ LL | }
103103
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
104104
help: add a dummy let to cause `t` to be fully captured
105105
|
106-
LL ~ let c = || { let _ = &t;
106+
LL ~ let c = || {
107+
LL + let _ = &t;
107108
LL +
108109
LL +
109110
LL +
110111
LL + let _t = t.0;
111-
LL +
112112
...
113113

114114
error: changes to closure capture in Rust 2021 will affect drop order
@@ -126,12 +126,12 @@ LL | }
126126
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
127127
help: add a dummy let to cause `t` to be fully captured
128128
|
129-
LL ~ let c = || { let _ = &t;
129+
LL ~ let c = || {
130+
LL + let _ = &t;
130131
LL +
131132
LL +
132133
LL +
133134
LL + let _t = t.0;
134-
LL +
135135
...
136136

137137
error: changes to closure capture in Rust 2021 will affect drop order
@@ -149,12 +149,12 @@ LL | }
149149
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
150150
help: add a dummy let to cause `t` to be fully captured
151151
|
152-
LL ~ let c = || { let _ = &t;
152+
LL ~ let c = || {
153+
LL + let _ = &t;
153154
LL +
154155
LL +
155156
LL +
156157
LL + let _t = t.1;
157-
LL +
158158
...
159159

160160
error: changes to closure capture in Rust 2021 will affect drop order
@@ -177,12 +177,12 @@ LL | }
177177
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
178178
help: add a dummy let to cause `t1`, `t` to be fully captured
179179
|
180-
LL ~ let c = move || { let _ = (&t1, &t);
180+
LL ~ let c = move || {
181+
LL + let _ = (&t1, &t);
181182
LL +
182183
LL +
183184
LL +
184185
LL + println!("{:?} {:?}", t1.1, t.1);
185-
LL +
186186
...
187187

188188
error: changes to closure capture in Rust 2021 will affect drop order
@@ -200,12 +200,12 @@ LL | }
200200
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
201201
help: add a dummy let to cause `tuple` to be fully captured
202202
|
203-
LL ~ let c = || { let _ = &tuple;
203+
LL ~ let c = || {
204+
LL + let _ = &tuple;
204205
LL +
205206
LL +
206207
LL +
207208
LL + tuple.0;
208-
LL +
209209
...
210210

211211
error: changes to closure capture in Rust 2021 will affect drop order
@@ -223,12 +223,12 @@ LL | };
223223
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
224224
help: add a dummy let to cause `tuple` to be fully captured
225225
|
226-
LL ~ let c = || { let _ = &tuple;
226+
LL ~ let c = || {
227+
LL + let _ = &tuple;
227228
LL +
228229
LL +
229230
LL +
230231
LL + tuple.0;
231-
LL +
232232
...
233233

234234
error: aborting due to 9 previous errors

‎src/test/ui/layout/thumb-enum.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// compile-flags: --target thumbv8m.main-none-eabihf
2+
// needs-llvm-components: arm
3+
//
4+
// Verify that thumb targets implement the repr(C) for enums correctly.
5+
//
6+
// See #87917
7+
#![feature(never_type, rustc_attrs, no_core, lang_items)]
8+
#![crate_type = "lib"]
9+
#![no_core]
10+
11+
#[lang="sized"]
12+
trait Sized {}
13+
14+
#[rustc_layout(debug)]
15+
#[repr(C)]
16+
enum A { Apple } //~ ERROR: layout_of
17+
18+
#[rustc_layout(debug)]
19+
#[repr(C)]
20+
enum B { Banana = 255, } //~ ERROR: layout_of
21+
22+
#[rustc_layout(debug)]
23+
#[repr(C)]
24+
enum C { Chaenomeles = 256, } //~ ERROR: layout_of
25+
26+
#[rustc_layout(debug)]
27+
#[repr(C)]
28+
enum P { Peach = 0x1000_0000isize, } //~ ERROR: layout_of
29+
30+
const TANGERINE: usize = 0x8100_0000; // hack to get negative numbers without negation operator!
31+
32+
#[rustc_layout(debug)]
33+
#[repr(C)]
34+
enum T { Tangerine = TANGERINE as isize } //~ ERROR: layout_of

‎src/test/ui/layout/thumb-enum.stderr

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ fn main() {
2626
fancy_panic::fancy_panic!("test {} 123");
2727
//~^ WARN panic message contains an unused formatting placeholder
2828

29-
fancy_panic::fancy_panic!(S);
30-
//~^ WARN panic message is not a string literal
29+
fancy_panic::fancy_panic!(); // OK
30+
fancy_panic::fancy_panic!(S); // OK
3131

3232
macro_rules! a {
3333
() => { 123 };

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,6 @@ LL | fancy_panic::fancy_panic!("test {} 123");
180180
|
181181
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
182182

183-
warning: panic message is not a string literal
184-
--> $DIR/non-fmt-panic.rs:29:31
185-
|
186-
LL | fancy_panic::fancy_panic!(S);
187-
| ^
188-
|
189-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
190-
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
191-
192183
warning: panic message is not a string literal
193184
--> $DIR/non-fmt-panic.rs:36:12
194185
|
@@ -285,5 +276,5 @@ help: or use std::panic::panic_any instead
285276
LL | std::panic::panic_any(123);
286277
| ~~~~~~~~~~~~~~~~~~~~~~ ~
287278

288-
warning: 20 warnings emitted
279+
warning: 19 warnings emitted
289280

0 commit comments

Comments
 (0)
Please sign in to comment.