rust/compiler/rustc_span/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
..
analyze_source_file remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00
lev_distance remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00
source_map Print -Ztime-passes (and misc stats/logs) on stderr, not stdout. 2021-02-18 14:13:38 +02:00
symbol mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
analyze_source_file.rs Fix some clippy lints 2020-12-03 17:08:19 -05:00
caching_source_map_view.rs rustc_span: add span_data_to_lines_and_cols to caching source map view 2020-12-03 18:36:34 -08:00
def_id.rs Only store a LocalDefId in hir::Item. 2021-02-15 19:32:10 +01:00
edition.rs Add edition 2021. 2020-12-31 19:06:09 +01:00
fatal_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
hygiene.rs Use debug log level for developer oriented logs 2021-02-13 00:00:00 +00:00
lev_distance.rs Edit rustc_span documentation 2020-12-25 14:02:52 -08:00
lib.rs rustc_span: Remove obsolete allow_internal_unstable_backcompat_hack 2021-02-14 19:42:55 +03:00
source_map.rs Rollup merge of #81860 - osa1:issue81800, r=estebank 2021-02-17 23:51:14 +01:00
span_encoding.rs Edit rustc_span documentation 2020-12-25 14:02:52 -08:00
symbol.rs Rollup merge of #82113 - m-ou-se:panic-format-lint, r=estebank 2021-02-23 16:10:21 +01:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00