diff options
| author | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2022-06-17 10:10:40 +0900 |
|---|---|---|
| committer | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2022-06-17 10:10:40 +0900 |
| commit | a5b6d25ca4f1600a158ffb68301dd816c8eda3cf (patch) | |
| tree | 7013f9cad4e9336752c725ab545a99aa9d3bced1 | |
| parent | 7cb4cef123a53534aaaa3956d4edf079d8482c6b (diff) | |
| download | rust-a5b6d25ca4f1600a158ffb68301dd816c8eda3cf.tar.gz rust-a5b6d25ca4f1600a158ffb68301dd816c8eda3cf.zip | |
use get_diagnostic_name for checking macro_call
| -rw-r--r-- | clippy_lints/src/copies.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index a771656c20f..9d1ca3588b3 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -13,11 +13,9 @@ 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; -const ACCEPTABLE_MACRO: [&str; 2] = ["todo", "unimplemented"]; - declare_clippy_lint! { /// ### What it does /// Checks for consecutive `if`s with the same condition. @@ -394,7 +392,10 @@ fn acceptable_macro(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { if let ExprKind::Call(call_expr, _) = expr.kind && let ExprKind::Path(QPath::Resolved(None, path)) = call_expr.kind && macro_backtrace(path.span).any(|macro_call| { - ACCEPTABLE_MACRO.contains(&cx.tcx.item_name(macro_call.def_id).as_str()) + matches!( + &cx.tcx.get_diagnostic_name(macro_call.def_id), + Some(sym::todo_macro | sym::unimplemented_macro) + ) }) { return true; } |
