@@ -25,14 +25,13 @@ mod try_err;
2525mod wild_in_or_pats;
2626
2727use 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 } ;
3030use rustc_hir:: { Arm , Expr , ExprKind , Local , MatchSource , Pat } ;
31- use rustc_lexer:: TokenKind ;
3231use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
3332use rustc_middle:: lint:: in_external_macro;
3433use rustc_session:: impl_lint_pass;
35- use rustc_span:: { Span , SpanData , SyntaxContext } ;
34+ use rustc_span:: { SpanData , SyntaxContext } ;
3635
3736declare_clippy_lint ! {
3837 /// ### What it does
@@ -1196,28 +1195,3 @@ fn contains_cfg_arm(cx: &LateContext<'_>, e: &Expr<'_>, scrutinee: &Expr<'_>, ar
11961195 Err ( ( ) ) => true ,
11971196 }
11981197}
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