rust/library/alloc/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
..
alloc Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
collections Auto merge of #82430 - Dylan-DPC:rollup-nu4kfyc, r=Dylan-DPC 2021-02-23 04:31:32 +00:00
prelude mv std libs to library/ 2020-07-27 19:51:13 -05:00
raw_vec Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
rc Re-stabilize Weak::as_ptr &friends for unsized T 2021-01-06 19:30:22 -05:00
sync Rollup merge of #80764 - CAD97:weak-unsized-as-ptr-again, r=RalfJung 2021-01-16 17:29:56 +00:00
vec Rollup merge of #81154 - dylni:improve-design-of-assert-len, r=KodrAus 2021-02-23 02:51:43 +01:00
alloc.rs move WriteCloneIntoRaw into alloc::alloc 2021-01-12 12:24:28 -08:00
borrow.rs a few more diagnostic items 2021-02-16 02:32:21 +00:00
boxed.rs Remove unnecessary lint allow attrs on example 2021-02-12 12:46:02 +03:00
fmt.rs Improve grammar in documentation of format strings 2021-01-01 23:07:35 +01:00
lib.rs Auto merge of #82076 - jyn514:update-bootstrap, r=Mark-Simulacrum 2021-02-23 07:19:41 +00:00
macros.rs Only define rustc_diagnostic_item format_macro in not(test). 2021-02-14 20:03:13 +01:00
raw_vec.rs Auto merge of #79113 - andjo403:raw_vec_ptr, r=m-ou-se 2021-01-26 02:56:37 +00:00
rc.rs Add docs for shared_from_slice From impls 2021-02-12 14:02:23 -07:00
slice.rs Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwco 2021-02-23 02:51:51 +01:00
str.rs Remove many unnecessary manual link resolves from library 2020-12-31 11:54:32 -08:00
string.rs Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwco 2021-02-23 02:51:51 +01:00
sync.rs Add docs for shared_from_slice From impls 2021-02-12 14:02:23 -07:00
task.rs Update the bootstrap compiler 2021-02-20 17:19:30 -05:00
tests.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00