diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 2e5ef8daf14..6225b716921 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -327,6 +327,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("safe_packed_borrows", "unaligned_references"); store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures"); store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns"); + store.register_renamed("non_fmt_panic", "non_fmt_panics"); // These were moved to tool lints, but rustc still sees them when compiling normally, before // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 3ea5a3bcc3b..99a88f6bf61 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -9,7 +9,7 @@ use rustc_span::edition::Edition; use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol}; declare_lint! { - /// The `non_fmt_panic` lint detects `panic!(..)` invocations where the first + /// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first /// argument is not a formatting string. /// /// ### Example @@ -29,7 +29,7 @@ declare_lint! { /// an `i32` as message. /// /// Rust 2021 always interprets the first argument as format string. - NON_FMT_PANIC, + NON_FMT_PANICS, Warn, "detect single-argument panic!() invocations in which the argument is not a format string", @future_incompatible = FutureIncompatibleInfo { @@ -39,7 +39,7 @@ declare_lint! { report_in_external_macro } -declare_lint_pass!(NonPanicFmt => [NON_FMT_PANIC]); +declare_lint_pass!(NonPanicFmt => [NON_FMT_PANICS]); impl<'tcx> LateLintPass<'tcx> for NonPanicFmt { 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 arg_span = expn.call_site; } - cx.struct_span_lint(NON_FMT_PANIC, arg_span, |lint| { + cx.struct_span_lint(NON_FMT_PANICS, arg_span, |lint| { let mut l = lint.build("panic message is not a string literal"); l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021"); l.note("for more information, see "); @@ -174,7 +174,7 @@ fn check_panic_str<'tcx>( [] => vec![fmt_span], v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(), }; - cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| { + cx.struct_span_lint(NON_FMT_PANICS, arg_spans, |lint| { let mut l = lint.build(match n_arguments { 1 => "panic message contains an unused formatting placeholder", _ => "panic message contains unused formatting placeholders", @@ -208,7 +208,7 @@ fn check_panic_str<'tcx>( Some(v) if v.len() == 1 => "panic message contains a brace", _ => "panic message contains braces", }; - cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or_else(|| vec![span]), |lint| { + cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| { let mut l = lint.build(msg); l.note("this message is not used as a format string, but will be in Rust 2021"); if span.contains(arg.span) { diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index f0f0ba2e92f..3557dbad90c 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -164,8 +164,8 @@ #![feature(no_niche)] // rust-lang/rust#68303 #![feature(no_coverage)] // rust-lang/rust#84605 #![deny(unsafe_op_in_unsafe_fn)] -#![allow(renamed_and_removed_lints)] -#![deny(or_patterns_back_compat)] +#![cfg_attr(bootstrap, deny(or_patterns_back_compat))] +#![cfg_attr(not(bootstrap), deny(rust_2021_incompatible_or_patterns))] // allow using `core::` in intra-doc links #[allow(unused_extern_crates)] diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs index 5807c5659b6..e4455d86a14 100644 --- a/src/test/ui/consts/const-eval/const_panic.rs +++ b/src/test/ui/consts/const-eval/const_panic.rs @@ -1,5 +1,5 @@ #![feature(const_panic)] -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] #![crate_type = "lib"] const MSG: &str = "hello"; diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs index 6c97a807b05..b30e9a47a13 100644 --- a/src/test/ui/fmt/format-args-capture.rs +++ b/src/test/ui/fmt/format-args-capture.rs @@ -16,13 +16,13 @@ fn main() { fn named_argument_takes_precedence_to_captured() { let foo = "captured"; - let s = format!("{foo}", foo="named"); + let s = format!("{foo}", foo = "named"); assert_eq!(&s, "named"); - let s = format!("{foo}-{foo}-{foo}", foo="named"); + let s = format!("{foo}-{foo}-{foo}", foo = "named"); assert_eq!(&s, "named-named-named"); - let s = format!("{}-{bar}-{foo}", "positional", bar="named"); + let s = format!("{}-{bar}-{foo}", "positional", bar = "named"); assert_eq!(&s, "positional-named-captured"); } @@ -42,10 +42,11 @@ fn panic_with_single_argument_does_not_get_formatted() { // RFC #2795 suggests that this may need to change so that captured arguments are formatted. // For stability reasons this will need to part of an edition change. - #[allow(non_fmt_panic)] + #[allow(non_fmt_panics)] let msg = std::panic::catch_unwind(|| { panic!("{foo}"); - }).unwrap_err(); + }) + .unwrap_err(); assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}")) } @@ -55,8 +56,9 @@ fn panic_with_multiple_arguments_is_formatted() { let foo = "captured"; let msg = std::panic::catch_unwind(|| { - panic!("{}-{bar}-{foo}", "positional", bar="named"); - }).unwrap_err(); + panic!("{}-{bar}-{foo}", "positional", bar = "named"); + }) + .unwrap_err(); assert_eq!(msg.downcast_ref::(), Some(&"positional-named-captured".to_string())) } diff --git a/src/test/ui/macros/assert-macro-owned.rs b/src/test/ui/macros/assert-macro-owned.rs index 2846f2a1f83..753675872b9 100644 --- a/src/test/ui/macros/assert-macro-owned.rs +++ b/src/test/ui/macros/assert-macro-owned.rs @@ -2,7 +2,7 @@ // error-pattern:panicked at 'test-assert-owned' // ignore-emscripten no processes -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] fn main() { assert!(false, "test-assert-owned".to_string()); diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index fd2c590ae5f..780e158fe0b 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -14,11 +14,12 @@ // revisions: std core // ignore-wasm32-bare compiled with panic=abort by default - #![cfg_attr(core, no_std)] -#[cfg(std)] use std::fmt; -#[cfg(core)] use core::fmt; +#[cfg(core)] +use core::fmt; +#[cfg(std)] +use std::fmt; // an easy mistake in the implementation of 'assert!' // would cause this to say "explicit panic" @@ -57,7 +58,7 @@ fn writeln_1arg() { // // (Example: Issue #48042) #[test] -#[allow(non_fmt_panic)] +#[allow(non_fmt_panics)] fn to_format_or_not_to_format() { // ("{}" is the easiest string to test because if this gets // sent to format_args!, it'll simply fail to compile. @@ -80,13 +81,17 @@ fn to_format_or_not_to_format() { // format!("{}",); // see check-fail // format_args!("{}",); // see check-fail - if falsum() { panic!("{}",); } + if falsum() { + panic!("{}",); + } // print!("{}",); // see check-fail // println!("{}",); // see check-fail // unimplemented!("{}",); // see check-fail - if falsum() { unreachable!("{}",); } + if falsum() { + unreachable!("{}",); + } // write!(&mut stdout, "{}",); // see check-fail // writeln!(&mut stdout, "{}",); // see check-fail diff --git a/src/test/ui/non-fmt-panic.stderr b/src/test/ui/non-fmt-panic.stderr index 0f451c1e0a9..6aa2eb174e9 100644 --- a/src/test/ui/non-fmt-panic.stderr +++ b/src/test/ui/non-fmt-panic.stderr @@ -4,7 +4,7 @@ warning: panic message contains a brace LL | panic!("here's a brace: {"); | ^ | - = note: `#[warn(non_fmt_panic)]` on by default + = note: `#[warn(non_fmt_panics)]` on by default = note: this message is not used as a format string, but will be in Rust 2021 help: add a "{}" format string to use the message literally | diff --git a/src/test/ui/panics/explicit-panic-msg.rs b/src/test/ui/panics/explicit-panic-msg.rs index bfcc12cd186..9d803578734 100644 --- a/src/test/ui/panics/explicit-panic-msg.rs +++ b/src/test/ui/panics/explicit-panic-msg.rs @@ -1,6 +1,6 @@ #![allow(unused_assignments)] #![allow(unused_variables)] -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] // run-fail // error-pattern:wooooo diff --git a/src/test/ui/panics/panic-macro-any-wrapped.rs b/src/test/ui/panics/panic-macro-any-wrapped.rs index 100ac10c767..663bf6713d0 100644 --- a/src/test/ui/panics/panic-macro-any-wrapped.rs +++ b/src/test/ui/panics/panic-macro-any-wrapped.rs @@ -2,7 +2,7 @@ // error-pattern:panicked at 'Box' // ignore-emscripten no processes -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] fn main() { panic!(Box::new(612_i64)); diff --git a/src/test/ui/panics/panic-macro-any.rs b/src/test/ui/panics/panic-macro-any.rs index a5ba30220e8..08acc6e8078 100644 --- a/src/test/ui/panics/panic-macro-any.rs +++ b/src/test/ui/panics/panic-macro-any.rs @@ -3,7 +3,7 @@ // ignore-emscripten no processes #![feature(box_syntax)] -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] fn main() { panic!(box 413 as Box); diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index f3a80703238..421614057c5 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -592,7 +592,7 @@ Released 2021-02-11 * Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333) -* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panic` +* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panics` [#6351](https://github.com/rust-lang/rust-clippy/pull/6351) * Move [`map_err_ignore`] to `restriction` [#6416](https://github.com/rust-lang/rust-clippy/pull/6416) diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index e0325738466..c29b3e7c74c 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -2171,7 +2171,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) { ls.register_renamed("clippy::unused_label", "unused_labels"); ls.register_renamed("clippy::drop_bounds", "drop_bounds"); ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr"); - ls.register_renamed("clippy::panic_params", "non_fmt_panic"); + ls.register_renamed("clippy::panic_params", "non_fmt_panics"); ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints"); } diff --git a/src/tools/clippy/tests/ui/assertions_on_constants.rs b/src/tools/clippy/tests/ui/assertions_on_constants.rs index 6617ca183a8..2180f848d62 100644 --- a/src/tools/clippy/tests/ui/assertions_on_constants.rs +++ b/src/tools/clippy/tests/ui/assertions_on_constants.rs @@ -1,4 +1,4 @@ -#![allow(non_fmt_panic)] +#![allow(non_fmt_panics)] macro_rules! assert_const { ($len:expr) => { diff --git a/src/tools/clippy/tests/ui/deprecated.stderr b/src/tools/clippy/tests/ui/deprecated.stderr index 0af6b500115..c0002e53543 100644 --- a/src/tools/clippy/tests/ui/deprecated.stderr +++ b/src/tools/clippy/tests/ui/deprecated.stderr @@ -60,11 +60,11 @@ error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cs LL | #[warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` -error: lint `clippy::panic_params` has been renamed to `non_fmt_panic` +error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` --> $DIR/deprecated.rs:11:8 | LL | #[warn(clippy::panic_params)] - | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panic` + | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` --> $DIR/deprecated.rs:12:8