@@ -25,14 +25,13 @@ mod try_err;
25
25
mod wild_in_or_pats;
26
26
27
27
use clippy_config:: msrvs:: { self , Msrv } ;
28
- use clippy_utils:: source:: { snippet_opt , walk_span_to_context} ;
29
- use clippy_utils:: { higher, in_constant, is_direct_expn_of, is_span_match, tokenize_with_text } ;
28
+ use clippy_utils:: source:: walk_span_to_context;
29
+ use clippy_utils:: { higher, in_constant, is_direct_expn_of, is_span_match, span_contains_cfg } ;
30
30
use rustc_hir:: { Arm , Expr , ExprKind , Local , MatchSource , Pat } ;
31
- use rustc_lexer:: TokenKind ;
32
31
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
33
32
use rustc_middle:: lint:: in_external_macro;
34
33
use rustc_session:: impl_lint_pass;
35
- use rustc_span:: { Span , SpanData , SyntaxContext } ;
34
+ use rustc_span:: { SpanData , SyntaxContext } ;
36
35
37
36
declare_clippy_lint ! {
38
37
/// ### What it does
@@ -1196,28 +1195,3 @@ fn contains_cfg_arm(cx: &LateContext<'_>, e: &Expr<'_>, scrutinee: &Expr<'_>, ar
1196
1195
Err ( ( ) ) => true ,
1197
1196
}
1198
1197
}
1199
-
1200
- /// Checks if the given span contains a `#[cfg(..)]` attribute
1201
- fn span_contains_cfg ( cx : & LateContext < ' _ > , s : Span ) -> bool {
1202
- let Some ( snip) = snippet_opt ( cx, s) else {
1203
- // Assume true. This would require either an invalid span, or one which crosses file boundaries.
1204
- return true ;
1205
- } ;
1206
- let mut iter = tokenize_with_text ( & snip) ;
1207
-
1208
- // Search for the token sequence [`#`, `[`, `cfg`]
1209
- while iter. any ( |( t, _) | matches ! ( t, TokenKind :: Pound ) ) {
1210
- let mut iter = iter. by_ref ( ) . skip_while ( |( t, _) | {
1211
- matches ! (
1212
- t,
1213
- TokenKind :: Whitespace | TokenKind :: LineComment { .. } | TokenKind :: BlockComment { .. }
1214
- )
1215
- } ) ;
1216
- if matches ! ( iter. next( ) , Some ( ( TokenKind :: OpenBracket , _) ) )
1217
- && matches ! ( iter. next( ) , Some ( ( TokenKind :: Ident , "cfg" ) ) )
1218
- {
1219
- return true ;
1220
- }
1221
- }
1222
- false
1223
- }
0 commit comments