Skip to content

Commit a5b6d25

Browse files
committed
use get_diagnostic_name for checking macro_call
1 parent 7cb4cef commit a5b6d25

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clippy_lints/src/copies.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ use rustc_lint::{LateContext, LateLintPass};
1313
use rustc_session::{declare_lint_pass, declare_tool_lint};
1414
use rustc_span::hygiene::walk_chain;
1515
use rustc_span::source_map::SourceMap;
16-
use rustc_span::{BytePos, Span, Symbol};
16+
use rustc_span::{sym, BytePos, Span, Symbol};
1717
use std::borrow::Cow;
1818

19-
const ACCEPTABLE_MACRO: [&str; 2] = ["todo", "unimplemented"];
20-
2119
declare_clippy_lint! {
2220
/// ### What it does
2321
/// Checks for consecutive `if`s with the same condition.
@@ -394,7 +392,10 @@ fn acceptable_macro(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
394392
if let ExprKind::Call(call_expr, _) = expr.kind
395393
&& let ExprKind::Path(QPath::Resolved(None, path)) = call_expr.kind
396394
&& macro_backtrace(path.span).any(|macro_call| {
397-
ACCEPTABLE_MACRO.contains(&cx.tcx.item_name(macro_call.def_id).as_str())
395+
matches!(
396+
&cx.tcx.get_diagnostic_name(macro_call.def_id),
397+
Some(sym::todo_macro | sym::unimplemented_macro)
398+
)
398399
}) {
399400
return true;
400401
}

0 commit comments

Comments
 (0)