about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/copies.rs18
-rw-r--r--tests/ui/if_same_then_else.rs3
2 files changed, 20 insertions, 1 deletions
diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs
index 1deff9684a1..6f92caf7391 100644
--- a/clippy_lints/src/copies.rs
+++ b/clippy_lints/src/copies.rs
@@ -12,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::hygiene::walk_chain;
 use rustc_span::source_map::SourceMap;
-use rustc_span::{BytePos, Span, Symbol};
+use rustc_span::{sym, BytePos, Span, Symbol};
 use std::borrow::Cow;
 
 declare_clippy_lint! {
@@ -365,6 +365,21 @@ fn eq_stmts(
         .all(|b| get_stmt(b).map_or(false, |s| eq.eq_stmt(s, stmt)))
 }
 
+fn block_contains_todo_macro(cx: &LateContext<'_>, block: &Block<'_>) -> bool {
+    dbg!(block);
+    if let Some(macro_def_id) = block.span.ctxt().outer_expn_data().macro_def_id {
+        dbg!(macro_def_id);
+        if let Some(diagnostic_name) = cx.tcx.get_diagnostic_name(macro_def_id) {
+            dbg!(diagnostic_name);
+            diagnostic_name == sym::todo_macro
+        } else {
+            false
+        }
+    } else {
+        false
+    }
+}
+
 fn scan_block_for_eq(cx: &LateContext<'_>, _conds: &[&Expr<'_>], block: &Block<'_>, blocks: &[&Block<'_>]) -> BlockEq {
     let mut eq = SpanlessEq::new(cx);
     let mut eq = eq.inter_expr();
@@ -398,6 +413,7 @@ fn scan_block_for_eq(cx: &LateContext<'_>, _conds: &[&Expr<'_>], block: &Block<'
             moved_locals,
         };
     }
+
     let end_search_start = block.stmts[start_end_eq..]
         .iter()
         .rev()
diff --git a/tests/ui/if_same_then_else.rs b/tests/ui/if_same_then_else.rs
index ef956745500..767185c207b 100644
--- a/tests/ui/if_same_then_else.rs
+++ b/tests/ui/if_same_then_else.rs
@@ -126,6 +126,9 @@ fn if_same_then_else() {
             _ => 4,
         };
     }
+
+    // Issue #8836
+    if true { todo!() } else { todo!() }
 }
 
 // Issue #2423. This was causing an ICE.