Skip to content

Commit d5e7628

Browse files
committed
Update regression test to account for switch to warning instead of error.
1 parent 3f42796 commit d5e7628

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

src/test/compile-fail/issue-22932.rs

+32-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(rustc_attrs)]
12+
1113
// Issue 22932: `panic!("{}");` should not compile.
1214

1315
pub fn f1() { panic!("this does not work {}");
14-
//~^ ERROR panic! input cannot be format string literal
16+
//~^ WARN unary panic! literal argument contains `{`
17+
//~| NOTE Is it meant to be a `format!` string?
18+
//~| HELP You can wrap the argument in parentheses to sidestep this warning
1519
}
1620

1721
pub fn workaround_1() {
@@ -24,28 +28,49 @@ pub fn workaround_2() {
2428
}
2529

2630
pub fn f2() { panic!("this does not work {");
27-
//~^ ERROR panic! input cannot be format string literal
31+
//~^ WARN unary panic! literal argument contains `{`
32+
//~| NOTE Is it meant to be a `format!` string?
33+
//~| HELP You can wrap the argument in parentheses to sidestep this warning
2834
}
2935

3036
pub fn f3() { panic!("nor this }");
31-
//~^ ERROR panic! input cannot be format string literal
37+
//~^ WARN unary panic! literal argument contains `}`
38+
//~| NOTE Is it meant to be a `format!` string?
39+
//~| HELP You can wrap the argument in parentheses to sidestep this warning
3240
}
3341

3442
pub fn f4() { panic!("nor this {{");
35-
//~^ ERROR panic! input cannot be format string literal
43+
//~^ WARN unary panic! literal argument contains `{`
44+
//~| NOTE Is it meant to be a `format!` string?
45+
//~| HELP You can wrap the argument in parentheses to sidestep this warning
3646
}
3747

3848
pub fn f5() { panic!("nor this }}");
39-
//~^ ERROR panic! input cannot be format string literal
49+
//~^ WARN unary panic! literal argument contains `}`
50+
//~| NOTE Is it meant to be a `format!` string?
51+
//~| HELP You can wrap the argument in parentheses to sidestep this warning
4052
}
4153

4254
pub fn f0_a() {
4355
ensure_not_fmt_string_literal!("`f0_a`", "this does not work {}");
44-
//~^ ERROR `f0_a` input cannot be format string literal
56+
//~^ WARN `f0_a` literal argument contains `{`
57+
//~| NOTE Is it meant to be a `format!` string?
58+
//~| HELP You can wrap the argument in parentheses to sidestep this warning
4559
}
4660

4761
pub fn f0_b() {
4862
println!(ensure_not_fmt_string_literal!("`f0_b`", "this does work"));
4963
}
5064

51-
pub fn main() {}
65+
pub fn f0_c() {
66+
println!("{}",
67+
ensure_not_fmt_string_literal!("`f0_c`", ("so does this {}")));
68+
}
69+
70+
// This test is just checking that we get all the right warnings; none
71+
// of them are outright errors, so use the special `rustc_error`
72+
// attribute to force a compile error.
73+
#[rustc_error]
74+
pub fn main() {
75+
//~^ ERROR compilation successful
76+
}

0 commit comments

Comments
 (0)