File tree Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 1
1
use clippy_utils:: diagnostics:: span_lint_and_sugg;
2
- use clippy_utils:: in_macro;
3
2
use clippy_utils:: source:: snippet_with_applicability;
4
3
use rustc_errors:: Applicability ;
5
4
use rustc_hir:: { Expr , ExprKind } ;
@@ -46,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
46
45
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , e : & ' tcx Expr < ' _ > ) {
47
46
if let ExprKind :: Struct ( path, fields, None ) = e. kind {
48
47
if !fields. is_empty ( )
49
- && !in_macro ( e. span )
48
+ && !e. span . from_expansion ( )
50
49
&& fields
51
50
. iter ( )
52
51
. all ( |f| f. ident . as_str ( ) . as_bytes ( ) . iter ( ) . all ( u8:: is_ascii_digit) )
Original file line number Diff line number Diff line change 1
1
use clippy_utils:: diagnostics:: span_lint_and_sugg;
2
- use clippy_utils:: in_macro;
3
2
use clippy_utils:: source:: snippet;
4
3
use hir:: def:: { DefKind , Res } ;
5
4
use if_chain:: if_chain;
@@ -9,6 +8,7 @@ use rustc_errors::Applicability;
9
8
use rustc_hir as hir;
10
9
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
11
10
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
11
+ use rustc_span:: hygiene:: ExpnKind ;
12
12
use rustc_span:: { edition:: Edition , sym, Span } ;
13
13
14
14
declare_clippy_lint ! {
@@ -214,3 +214,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
214
214
}
215
215
}
216
216
}
217
+
218
+ fn in_macro ( span : Span ) -> bool {
219
+ span. from_expansion ( ) && !matches ! ( span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Desugaring ( ..) )
220
+ }
Original file line number Diff line number Diff line change @@ -147,13 +147,6 @@ macro_rules! extract_msrv_attr {
147
147
} ;
148
148
}
149
149
150
- /// Returns `true` if the span comes from a macro expansion, no matter if from a
151
- /// macro by example or from a procedural macro
152
- #[ must_use]
153
- pub fn in_macro ( span : Span ) -> bool {
154
- span. from_expansion ( ) && !matches ! ( span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Desugaring ( ..) )
155
- }
156
-
157
150
/// Returns `true` if the two spans come from differing expansions (i.e., one is
158
151
/// from a macro and one isn't).
159
152
#[ must_use]
You can’t perform that action at this time.
0 commit comments