|
1 | 1 | #![allow(clippy::similar_names)] // `expr` and `expn` |
2 | 2 |
|
| 3 | +use crate::get_unique_attr; |
3 | 4 | use crate::visitors::{Descend, for_each_expr_without_closures}; |
4 | 5 |
|
5 | 6 | use arrayvec::ArrayVec; |
6 | 7 | use rustc_ast::{FormatArgs, FormatArgument, FormatPlaceholder}; |
7 | 8 | use rustc_data_structures::fx::FxHashMap; |
8 | 9 | use rustc_data_structures::sync::{Lrc, OnceLock}; |
9 | 10 | use rustc_hir::{self as hir, Expr, ExprKind, HirId, Node, QPath}; |
10 | | -use rustc_lint::LateContext; |
| 11 | +use rustc_lint::{LateContext, LintContext}; |
11 | 12 | use rustc_span::def_id::DefId; |
12 | 13 | use rustc_span::hygiene::{self, MacroKind, SyntaxContext}; |
13 | 14 | use rustc_span::{BytePos, ExpnData, ExpnId, ExpnKind, Span, SpanData, Symbol, sym}; |
@@ -36,7 +37,9 @@ pub fn is_format_macro(cx: &LateContext<'_>, macro_def_id: DefId) -> bool { |
36 | 37 | if let Some(name) = cx.tcx.get_diagnostic_name(macro_def_id) { |
37 | 38 | FORMAT_MACRO_DIAG_ITEMS.contains(&name) |
38 | 39 | } else { |
39 | | - false |
| 40 | + // Allow users to tag any macro as being format!-like |
| 41 | + // TODO: consider deleting FORMAT_MACRO_DIAG_ITEMS and using just this method |
| 42 | + get_unique_attr(cx.sess(), cx.tcx.get_attrs_unchecked(macro_def_id), "format_args").is_some() |
40 | 43 | } |
41 | 44 | } |
42 | 45 |
|
|
0 commit comments