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 11use clippy_utils:: diagnostics:: span_lint_and_sugg;
2- use clippy_utils:: in_macro;
32use clippy_utils:: source:: snippet_with_applicability;
43use rustc_errors:: Applicability ;
54use rustc_hir:: { Expr , ExprKind } ;
@@ -46,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
4645 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , e : & ' tcx Expr < ' _ > ) {
4746 if let ExprKind :: Struct ( path, fields, None ) = e. kind {
4847 if !fields. is_empty ( )
49- && !in_macro ( e. span )
48+ && !e. span . from_expansion ( )
5049 && fields
5150 . iter ( )
5251 . all ( |f| f. ident . as_str ( ) . as_bytes ( ) . iter ( ) . all ( u8:: is_ascii_digit) )
Original file line number Diff line number Diff line change 11use clippy_utils:: diagnostics:: span_lint_and_sugg;
2- use clippy_utils:: in_macro;
32use clippy_utils:: source:: snippet;
43use hir:: def:: { DefKind , Res } ;
54use if_chain:: if_chain;
@@ -9,6 +8,7 @@ use rustc_errors::Applicability;
98use rustc_hir as hir;
109use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
1110use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
11+ use rustc_span:: hygiene:: ExpnKind ;
1212use rustc_span:: { edition:: Edition , sym, Span } ;
1313
1414declare_clippy_lint ! {
@@ -214,3 +214,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
214214 }
215215 }
216216}
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 {
147147 } ;
148148}
149149
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-
157150/// Returns `true` if the two spans come from differing expansions (i.e., one is
158151/// from a macro and one isn't).
159152#[ must_use]
You can’t perform that action at this time.
0 commit comments