1
1
use clippy_utils:: diagnostics:: { span_lint_and_note, span_lint_and_then} ;
2
- use clippy_utils:: macros:: macro_backtrace;
3
2
use clippy_utils:: source:: { first_line_of_span, indent_of, reindent_multiline, snippet, snippet_opt} ;
4
3
use clippy_utils:: {
5
4
eq_expr_value, get_enclosing_block, hash_expr, hash_stmt, if_sequence, is_else_clause, is_lint_allowed,
@@ -13,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass};
13
12
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
14
13
use rustc_span:: hygiene:: walk_chain;
15
14
use rustc_span:: source_map:: SourceMap ;
16
- use rustc_span:: { sym , BytePos , Span , Symbol } ;
15
+ use rustc_span:: { BytePos , Span , Symbol } ;
17
16
use std:: borrow:: Cow ;
18
17
19
18
declare_clippy_lint ! {
@@ -197,8 +196,6 @@ fn lint_if_same_then_else(cx: &LateContext<'_>, conds: &[&Expr<'_>], blocks: &[&
197
196
. enumerate ( )
198
197
. fold ( true , |all_eq, ( i, & [ lhs, rhs] ) | {
199
198
if eq. eq_block ( lhs, rhs)
200
- && !contains_acceptable_macro ( cx, lhs)
201
- && !contains_acceptable_macro ( cx, rhs)
202
199
&& !contains_let ( conds[ i] )
203
200
&& conds. get ( i + 1 ) . map_or ( true , |e| !contains_let ( e) )
204
201
{
@@ -371,37 +368,9 @@ fn eq_stmts(
371
368
. all ( |b| get_stmt ( b) . map_or ( false , |s| eq. eq_stmt ( s, stmt) ) )
372
369
}
373
370
374
- fn contains_acceptable_macro ( cx : & LateContext < ' _ > , block : & Block < ' _ > ) -> bool {
375
- if block. stmts . first ( ) . map_or ( false , |stmt|
376
- matches ! (
377
- stmt. kind,
378
- StmtKind :: Semi ( semi_expr) if acceptable_macro( cx, semi_expr)
379
- )
380
- ) {
381
- return true ;
382
- }
383
-
384
- if let Some ( block_expr) = block. expr
385
- && acceptable_macro ( cx, block_expr)
386
- {
387
- return true
388
- }
389
371
390
- false
391
- }
392
372
393
- fn acceptable_macro ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
394
- if macro_backtrace ( expr. span ) . last ( ) . map_or ( false , |macro_call|
395
- matches ! (
396
- & cx. tcx. get_diagnostic_name( macro_call. def_id) ,
397
- Some ( sym:: todo_macro | sym:: unimplemented_macro)
398
- )
399
- ) {
400
- return true ;
401
- }
402
373
403
- false
404
- }
405
374
406
375
fn scan_block_for_eq ( cx : & LateContext < ' _ > , _conds : & [ & Expr < ' _ > ] , block : & Block < ' _ > , blocks : & [ & Block < ' _ > ] ) -> BlockEq {
407
376
let mut eq = SpanlessEq :: new ( cx) ;
0 commit comments