rust/compiler/rustc_lint/src
Dylan DPC 547b3adfe4
Rollup merge of #82113 - m-ou-se:panic-format-lint, r=estebank
Improve non_fmt_panic lint.

This change:
- fixes the span used by this lint in the case the panic argument is a single macro expansion (e.g. `panic!(a!())`);
- adds a suggestion for `panic!(format!(..))` to remove `format!()` instead of adding `"{}", ` or using `panic_any` like it does now; and
- fixes the incorrect suggestion to replace `panic![123]` by `panic_any(123]`.

Fixes #82109.
Fixes #82110.
Fixes #82111.

Example output:
```
warning: panic message is not a string literal
 --> src/main.rs:8:12
  |
8 |     panic!(format!("error: {}", "oh no"));
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(non_fmt_panic)]` on by default
  = note: this is no longer accepted in Rust 2021
  = note: the panic!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
  |
8 |     panic!("error: {}", "oh no");
  |           --                  --

```

r? `@estebank`
2021-02-23 16:10:21 +01:00
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs Implement rustc side of report-future-incompat 2020-10-30 20:02:14 -04:00
builtin.rs Only store a LocalDefId in hir::ForeignItem. 2021-02-15 19:32:29 +01:00
context.rs Add --extern-loc to augment unused crate dependency diagnostics 2021-02-07 14:54:20 -08:00
early.rs ast: Stop using Mod in Crate 2021-02-18 13:07:49 +03:00
internal.rs Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
late.rs Index Modules using their LocalDefId. 2021-02-15 19:32:30 +01:00
levels.rs Only store a LocalDefId in hir::MacroDef. 2021-02-15 19:35:55 +01:00
lib.rs Add lint for panic!(123) which is not accepted in Rust 2021. 2021-02-03 22:42:53 +01:00
methods.rs Fix doctest 2020-10-26 18:19:49 -04:00
non_ascii_idents.rs Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco 2020-09-14 21:43:17 +00:00
non_fmt_panic.rs Add comment about how we find the right span in non_fmt_panic. 2021-02-17 10:51:22 +01:00
nonstandard_style.rs review comments 2021-01-30 22:06:10 -08:00
passes.rs ast: Stop using Mod in Crate 2021-02-18 13:07:49 +03:00
redundant_semicolon.rs Lint on redundant trailing semicolon after item 2020-12-29 16:30:02 -05:00
traits.rs Only store a LocalDefId in hir::Item. 2021-02-15 19:32:10 +01:00
types.rs Rollup merge of #79981 - camelid:overflowing_literals-inference-error, r=lcnr 2021-02-17 20:37:48 +01:00
unused.rs Fix an old FIXME in redundant paren lint 2021-01-30 22:39:56 +03:00