Skip to content

Commit a902e25

Browse files
committed
Add s to non_fmt_panic
1 parent 4e5b78f commit a902e25

File tree

15 files changed

+40
-32
lines changed

15 files changed

+40
-32
lines changed

compiler/rustc_lint/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
327327
store.register_renamed("safe_packed_borrows", "unaligned_references");
328328
store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
329329
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
330+
store.register_renamed("non_fmt_panic", "non_fmt_panics");
330331

331332
// These were moved to tool lints, but rustc still sees them when compiling normally, before
332333
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use

compiler/rustc_lint/src/non_fmt_panic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_span::edition::Edition;
99
use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol};
1010

1111
declare_lint! {
12-
/// The `non_fmt_panic` lint detects `panic!(..)` invocations where the first
12+
/// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first
1313
/// argument is not a formatting string.
1414
///
1515
/// ### Example
@@ -29,7 +29,7 @@ declare_lint! {
2929
/// an `i32` as message.
3030
///
3131
/// Rust 2021 always interprets the first argument as format string.
32-
NON_FMT_PANIC,
32+
NON_FMT_PANICS,
3333
Warn,
3434
"detect single-argument panic!() invocations in which the argument is not a format string",
3535
@future_incompatible = FutureIncompatibleInfo {
@@ -39,7 +39,7 @@ declare_lint! {
3939
report_in_external_macro
4040
}
4141

42-
declare_lint_pass!(NonPanicFmt => [NON_FMT_PANIC]);
42+
declare_lint_pass!(NonPanicFmt => [NON_FMT_PANICS]);
4343

4444
impl<'tcx> LateLintPass<'tcx> for NonPanicFmt {
4545
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
@@ -91,7 +91,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
9191
arg_span = expn.call_site;
9292
}
9393

94-
cx.struct_span_lint(NON_FMT_PANIC, arg_span, |lint| {
94+
cx.struct_span_lint(NON_FMT_PANICS, arg_span, |lint| {
9595
let mut l = lint.build("panic message is not a string literal");
9696
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
9797
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
@@ -174,7 +174,7 @@ fn check_panic_str<'tcx>(
174174
[] => vec![fmt_span],
175175
v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(),
176176
};
177-
cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| {
177+
cx.struct_span_lint(NON_FMT_PANICS, arg_spans, |lint| {
178178
let mut l = lint.build(match n_arguments {
179179
1 => "panic message contains an unused formatting placeholder",
180180
_ => "panic message contains unused formatting placeholders",
@@ -208,7 +208,7 @@ fn check_panic_str<'tcx>(
208208
Some(v) if v.len() == 1 => "panic message contains a brace",
209209
_ => "panic message contains braces",
210210
};
211-
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
211+
cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
212212
let mut l = lint.build(msg);
213213
l.note("this message is not used as a format string, but will be in Rust 2021");
214214
if span.contains(arg.span) {

library/core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@
164164
#![feature(no_niche)] // rust-lang/rust#68303
165165
#![feature(no_coverage)] // rust-lang/rust#84605
166166
#![deny(unsafe_op_in_unsafe_fn)]
167-
#![allow(renamed_and_removed_lints)]
168-
#![deny(or_patterns_back_compat)]
167+
#![cfg_attr(bootstrap, deny(or_patterns_back_compat))]
168+
#![cfg_attr(not(bootstrap), deny(rust_2021_incompatible_or_patterns))]
169169

170170
// allow using `core::` in intra-doc links
171171
#[allow(unused_extern_crates)]

src/test/ui/consts/const-eval/const_panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(const_panic)]
2-
#![allow(non_fmt_panic)]
2+
#![allow(non_fmt_panics)]
33
#![crate_type = "lib"]
44

55
const MSG: &str = "hello";

src/test/ui/fmt/format-args-capture.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ fn main() {
1616

1717
fn named_argument_takes_precedence_to_captured() {
1818
let foo = "captured";
19-
let s = format!("{foo}", foo="named");
19+
let s = format!("{foo}", foo = "named");
2020
assert_eq!(&s, "named");
2121

22-
let s = format!("{foo}-{foo}-{foo}", foo="named");
22+
let s = format!("{foo}-{foo}-{foo}", foo = "named");
2323
assert_eq!(&s, "named-named-named");
2424

25-
let s = format!("{}-{bar}-{foo}", "positional", bar="named");
25+
let s = format!("{}-{bar}-{foo}", "positional", bar = "named");
2626
assert_eq!(&s, "positional-named-captured");
2727
}
2828

@@ -42,10 +42,11 @@ fn panic_with_single_argument_does_not_get_formatted() {
4242
// RFC #2795 suggests that this may need to change so that captured arguments are formatted.
4343
// For stability reasons this will need to part of an edition change.
4444

45-
#[allow(non_fmt_panic)]
45+
#[allow(non_fmt_panics)]
4646
let msg = std::panic::catch_unwind(|| {
4747
panic!("{foo}");
48-
}).unwrap_err();
48+
})
49+
.unwrap_err();
4950

5051
assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}"))
5152
}
@@ -55,8 +56,9 @@ fn panic_with_multiple_arguments_is_formatted() {
5556
let foo = "captured";
5657

5758
let msg = std::panic::catch_unwind(|| {
58-
panic!("{}-{bar}-{foo}", "positional", bar="named");
59-
}).unwrap_err();
59+
panic!("{}-{bar}-{foo}", "positional", bar = "named");
60+
})
61+
.unwrap_err();
6062

6163
assert_eq!(msg.downcast_ref::<String>(), Some(&"positional-named-captured".to_string()))
6264
}

src/test/ui/macros/assert-macro-owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// error-pattern:panicked at 'test-assert-owned'
33
// ignore-emscripten no processes
44

5-
#![allow(non_fmt_panic)]
5+
#![allow(non_fmt_panics)]
66

77
fn main() {
88
assert!(false, "test-assert-owned".to_string());

src/test/ui/macros/macro-comma-behavior-rpass.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
// revisions: std core
1515

1616
// ignore-wasm32-bare compiled with panic=abort by default
17-
1817
#![cfg_attr(core, no_std)]
1918

20-
#[cfg(std)] use std::fmt;
21-
#[cfg(core)] use core::fmt;
19+
#[cfg(core)]
20+
use core::fmt;
21+
#[cfg(std)]
22+
use std::fmt;
2223

2324
// an easy mistake in the implementation of 'assert!'
2425
// would cause this to say "explicit panic"
@@ -57,7 +58,7 @@ fn writeln_1arg() {
5758
//
5859
// (Example: Issue #48042)
5960
#[test]
60-
#[allow(non_fmt_panic)]
61+
#[allow(non_fmt_panics)]
6162
fn to_format_or_not_to_format() {
6263
// ("{}" is the easiest string to test because if this gets
6364
// sent to format_args!, it'll simply fail to compile.
@@ -80,13 +81,17 @@ fn to_format_or_not_to_format() {
8081
// format!("{}",); // see check-fail
8182
// format_args!("{}",); // see check-fail
8283

83-
if falsum() { panic!("{}",); }
84+
if falsum() {
85+
panic!("{}",);
86+
}
8487

8588
// print!("{}",); // see check-fail
8689
// println!("{}",); // see check-fail
8790
// unimplemented!("{}",); // see check-fail
8891

89-
if falsum() { unreachable!("{}",); }
92+
if falsum() {
93+
unreachable!("{}",);
94+
}
9095

9196
// write!(&mut stdout, "{}",); // see check-fail
9297
// writeln!(&mut stdout, "{}",); // see check-fail

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: panic message contains a brace
44
LL | panic!("here's a brace: {");
55
| ^
66
|
7-
= note: `#[warn(non_fmt_panic)]` on by default
7+
= note: `#[warn(non_fmt_panics)]` on by default
88
= note: this message is not used as a format string, but will be in Rust 2021
99
help: add a "{}" format string to use the message literally
1010
|

src/test/ui/panics/explicit-panic-msg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(unused_assignments)]
22
#![allow(unused_variables)]
3-
#![allow(non_fmt_panic)]
3+
#![allow(non_fmt_panics)]
44

55
// run-fail
66
// error-pattern:wooooo

src/test/ui/panics/panic-macro-any-wrapped.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// error-pattern:panicked at 'Box<dyn Any>'
33
// ignore-emscripten no processes
44

5-
#![allow(non_fmt_panic)]
5+
#![allow(non_fmt_panics)]
66

77
fn main() {
88
panic!(Box::new(612_i64));

src/test/ui/panics/panic-macro-any.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ignore-emscripten no processes
44

55
#![feature(box_syntax)]
6-
#![allow(non_fmt_panic)]
6+
#![allow(non_fmt_panics)]
77

88
fn main() {
99
panic!(box 413 as Box<dyn std::any::Any + Send>);

src/tools/clippy/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ Released 2021-02-11
592592

593593
* Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated
594594
as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333)
595-
* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panic`
595+
* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panics`
596596
[#6351](https://github.com/rust-lang/rust-clippy/pull/6351)
597597
* Move [`map_err_ignore`] to `restriction`
598598
[#6416](https://github.com/rust-lang/rust-clippy/pull/6416)

src/tools/clippy/clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
21712171
ls.register_renamed("clippy::unused_label", "unused_labels");
21722172
ls.register_renamed("clippy::drop_bounds", "drop_bounds");
21732173
ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
2174-
ls.register_renamed("clippy::panic_params", "non_fmt_panic");
2174+
ls.register_renamed("clippy::panic_params", "non_fmt_panics");
21752175
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
21762176
}
21772177

src/tools/clippy/tests/ui/assertions_on_constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(non_fmt_panic)]
1+
#![allow(non_fmt_panics)]
22

33
macro_rules! assert_const {
44
($len:expr) => {

src/tools/clippy/tests/ui/deprecated.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cs
6060
LL | #[warn(clippy::temporary_cstring_as_ptr)]
6161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
6262

63-
error: lint `clippy::panic_params` has been renamed to `non_fmt_panic`
63+
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
6464
--> $DIR/deprecated.rs:11:8
6565
|
6666
LL | #[warn(clippy::panic_params)]
67-
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panic`
67+
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
6868

6969
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
7070
--> $DIR/deprecated.rs:12:8

0 commit comments

Comments
 (0)