Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint for panic!("{}") #78088

Merged
merged 28 commits into from
Nov 20, 2020
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
462ee9c
Mark the panic macros as diagnostic items.
m-ou-se Oct 18, 2020
a466790
Add lint to warn about braces in a panic message.
m-ou-se Oct 18, 2020
5b3b80a
Allow #[rustc_diagnostic_item] on macros.
m-ou-se Oct 18, 2020
da66a50
Specialize panic_fmt lint for the {core,std}::panic!() macros.
m-ou-se Oct 18, 2020
f228efc
Make panic_fmt lint work properly for assert!(expr, msg) too.
m-ou-se Oct 18, 2020
3beb2e9
Expand assert!(expr) to panic() function instead of panic!() macro.
m-ou-se Oct 18, 2020
451c986
Add test for the panic_fmt lint.
m-ou-se Oct 18, 2020
ded269f
Improve panic_fmt message for panic!("{}") with a fmt placeholder.
m-ou-se Oct 18, 2020
b8a8b68
Formatting.
m-ou-se Oct 18, 2020
14dcf0a
Test for formating placeholders in panic_fmt lint test.
m-ou-se Oct 18, 2020
dd262e3
Add cfg(not(bootstrap)) on the new rustc_diagnostic_item attributes.
m-ou-se Oct 18, 2020
9615d27
Don't see `{{}}` as placeholder in panic_fmt lint.
m-ou-se Oct 18, 2020
9a840a3
Fix brace problem in panic message in rustc_expand.
m-ou-se Oct 18, 2020
0a9330c
Ignore panic_fmt lint in macro-comma-behavior-rpass ui test.
m-ou-se Oct 18, 2020
d3b4149
Also apply panic_fmt lint suggestions to debug_assert!().
m-ou-se Oct 18, 2020
f1fcc4d
Ignore panic_fmt lint in format-args-capture ui test.
m-ou-se Oct 18, 2020
dd81c91
Update mir-opt test output for new assert macro implementation.
m-ou-se Oct 19, 2020
9e3b949
Fix braces in panic message in test.
m-ou-se Oct 19, 2020
ff8df0b
Add cfg(not(test)) to std_panic_macro rustc_diagnostic_item.
m-ou-se Oct 19, 2020
0f193d1
Small cleanups in assert!() and panic_fmt lint.
m-ou-se Oct 19, 2020
6b44662
Parse the format string for the panic_fmt lint for better warnings.
m-ou-se Oct 20, 2020
190c3ad
Improve panic_fmt error messages for invalid format strings too.
m-ou-se Oct 20, 2020
1993f1e
Test that panic_fmt lint doesn't trigger for custom panic macro.
m-ou-se Oct 24, 2020
5cefc3c
Mark panic_fmt suggestion as machine applicable.
m-ou-se Oct 28, 2020
9743f67
Improve panic_fmt lint messages.
m-ou-se Oct 29, 2020
a922c6b
Add test for panic_fmt lint with external panic!()-calling macro.
m-ou-se Oct 29, 2020
454eaec
Remove the clippy::panic-params lint.
m-ou-se Nov 19, 2020
a125ef2
Clippy: Match on assert!() expansions without an inner block.
m-ou-se Nov 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update mir-opt test output for new assert macro implementation.
  • Loading branch information
m-ou-se committed Oct 19, 2020
commit dd81c9102863a9d8b965628c87cb639430d233f9
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
let mut _8: bool; // in scope 0 at $DIR/inst_combine_deref.rs:60:5: 60:23
let mut _9: bool; // in scope 0 at $DIR/inst_combine_deref.rs:60:13: 60:21
let mut _10: i32; // in scope 0 at $DIR/inst_combine_deref.rs:60:13: 60:15
let mut _11: !; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL
let mut _11: !; // in scope 0 at $DIR/inst_combine_deref.rs:60:5: 60:23
scope 1 {
debug x => _1; // in scope 1 at $DIR/inst_combine_deref.rs:55:9: 55:10
let _2: i32; // in scope 1 at $DIR/inst_combine_deref.rs:56:9: 56:10
@@ -69,11 +69,11 @@
}

bb2: {
StorageLive(_11); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
begin_panic::<&str>(const "assertion failed: *y == 99"); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL
StorageLive(_11); // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23
core::panicking::panic(const "assertion failed: *y == 99"); // scope 4 at $DIR/inst_combine_deref.rs:60:5: 60:23
// mir::Constant
// + span: $SRC_DIR/std/src/macros.rs:LL:COL
// + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
// + span: $DIR/inst_combine_deref.rs:60:5: 60:23
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
// ty::Const
// + ty: &str
// + val: Value(Slice { data: Allocation { bytes: [97, 115, 115, 101, 114, 116, 105, 111, 110, 32, 102, 97, 105, 108, 101, 100, 58, 32, 42, 121, 32, 61, 61, 32, 57, 57], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [67108863], len: Size { raw: 26 } }, size: Size { raw: 26 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 26 })