1
Fork 0
rust/compiler/rustc_builtin_macros/src
bors 74285eb3a8 Auto merge of #78088 - fusion-engineering-forks:panic-fmt-lint, r=estebank
Add lint for panic!("{}")

This adds a lint that warns about `panic!("{}")`.

`panic!(msg)` invocations with a single argument use their argument as panic payload literally, without using it as a format string. The same holds for `assert!(expr, msg)`.

This lints checks if `msg` is a string literal (after expansion), and warns in case it contained braces. It suggests to insert `"{}", ` to use the message literally, or to add arguments to use it as a format string.

![image](https://user-images.githubusercontent.com/783247/96643867-79eb1080-1328-11eb-8d4e-a5586837c70a.png)

This lint is also a good starting point for adding warnings about `panic!(not_a_string)` later, once [`panic_any()`](https://github.com/rust-lang/rust/pull/74622) becomes a stable alternative.
2020-11-20 03:40:20 +00:00
..
deriving expand: Mark some dead code in derive expansion as unreachable 2020-11-19 19:25:20 +03:00
format_foreign mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
asm.rs rustc_parse: Make Parser::unexpected public and use it in built-in macros 2020-10-06 00:23:36 +03:00
assert.rs Small cleanups in assert!() and panic_fmt lint. 2020-10-19 21:14:05 +02:00
cfg.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
cfg_accessible.rs expand: Tell built-in macros whether we are currently in forced expansion mode 2020-11-19 19:25:20 +03:00
cmdline_attrs.rs Unconditionally capture tokens for attributes. 2020-10-21 18:57:29 -04:00
compile_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
concat.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
concat_idents.rs expand: Stop un-interpolating NtIdents before passing them to built-in macros 2020-09-28 23:10:44 +03:00
env.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
format.rs Point at named argument not found when using format_args_capture instead of whole format string 2020-09-08 10:10:45 -07:00
format_foreign.rs Simplify using is_ascii_alphabetic and is_ascii_alphanumeric 2020-10-11 22:27:21 +02:00
global_allocator.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
global_asm.rs Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
lib.rs /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
llvm_asm.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
log_syntax.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
proc_macro_harness.rs rustc_ast: Do not panic by default when visiting macro calls 2020-11-03 20:38:20 +03:00
source_util.rs Remove extra indirection in LitKind::ByteStr 2020-10-04 15:52:15 -06:00
standard_library_imports.rs cleanup: Remove ParseSess::injected_crate_name 2020-11-13 00:59:57 +03:00
test.rs Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
test_harness.rs Changed unwrap_or to unwrap_or_else in some places. 2020-11-10 20:07:47 -08:00
trace_macros.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
util.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00