@@ -2,7 +2,7 @@ use crate::rustc_lint::LintContext;
2
2
use clippy_utils:: diagnostics:: span_lint_and_then;
3
3
use clippy_utils:: macros:: { root_macro_call, FormatArgsExpn } ;
4
4
use clippy_utils:: source:: snippet_with_applicability;
5
- use clippy_utils:: { peel_blocks_with_stmt, span_extract_comment, sugg} ;
5
+ use clippy_utils:: { is_else_clause , peel_blocks_with_stmt, span_extract_comment, sugg} ;
6
6
use rustc_errors:: Applicability ;
7
7
use rustc_hir:: { Expr , ExprKind , UnOp } ;
8
8
use rustc_lint:: { LateContext , LateLintPass } ;
@@ -47,6 +47,10 @@ impl<'tcx> LateLintPass<'tcx> for ManualAssert {
47
47
if cx. tcx. item_name( macro_call. def_id) == sym:: panic;
48
48
if !cx. tcx. sess. source_map( ) . is_multiline( cond. span) ;
49
49
if let Some ( format_args) = FormatArgsExpn :: find_nested( cx, then, macro_call. expn) ;
50
+ // Don't change `else if foo { panic!(..) }` to `else { assert!(foo, ..) }` as it just
51
+ // shuffles the condition around.
52
+ // Should this have a config value?
53
+ if !is_else_clause( cx. tcx, expr) ;
50
54
then {
51
55
let mut applicability = Applicability :: MachineApplicable ;
52
56
let format_args_snip = snippet_with_applicability( cx, format_args. inputs_span( ) , ".." , & mut applicability) ;
0 commit comments