@@ -8,8 +8,7 @@ use rustc_macros::{Decodable, Encodable, HashStable};
8
8
use rustc_session:: Session ;
9
9
use rustc_session:: lint:: builtin:: { self , FORBIDDEN_LINT_GROUPS } ;
10
10
use rustc_session:: lint:: { FutureIncompatibilityReason , Level , Lint , LintExpectationId , LintId } ;
11
- use rustc_span:: hygiene:: { ExpnKind , MacroKind } ;
12
- use rustc_span:: { DUMMY_SP , DesugaringKind , Span , Symbol , kw} ;
11
+ use rustc_span:: { DUMMY_SP , Span , Symbol , kw} ;
13
12
use tracing:: instrument;
14
13
15
14
use crate :: ty:: TyCtxt ;
@@ -201,7 +200,7 @@ impl LintExpectation {
201
200
}
202
201
}
203
202
204
- pub fn explain_lint_level_source (
203
+ fn explain_lint_level_source (
205
204
lint : & ' static Lint ,
206
205
level : Level ,
207
206
src : LintLevelSource ,
@@ -325,7 +324,7 @@ pub fn lint_level(
325
324
// If this code originates in a foreign macro, aka something that this crate
326
325
// did not itself author, then it's likely that there's nothing this crate
327
326
// can do about it. We probably want to skip the lint entirely.
328
- if err. span . primary_spans ( ) . iter ( ) . any ( |s| in_external_macro ( sess, * s ) ) {
327
+ if err. span . primary_spans ( ) . iter ( ) . any ( |s| s . in_external_macro ( sess. source_map ( ) ) ) {
329
328
// Any suggestions made here are likely to be incorrect, so anything we
330
329
// emit shouldn't be automatically fixed by rustfix.
331
330
err. disable_suggestions ( ) ;
@@ -422,36 +421,3 @@ pub fn lint_level(
422
421
}
423
422
lint_level_impl ( sess, lint, level, src, span, Box :: new ( decorate) )
424
423
}
425
-
426
- /// Returns whether `span` originates in a foreign crate's external macro.
427
- ///
428
- /// This is used to test whether a lint should not even begin to figure out whether it should
429
- /// be reported on the current node.
430
- pub fn in_external_macro ( sess : & Session , span : Span ) -> bool {
431
- let expn_data = span. ctxt ( ) . outer_expn_data ( ) ;
432
- match expn_data. kind {
433
- ExpnKind :: Root
434
- | ExpnKind :: Desugaring (
435
- DesugaringKind :: ForLoop
436
- | DesugaringKind :: WhileLoop
437
- | DesugaringKind :: OpaqueTy
438
- | DesugaringKind :: Async
439
- | DesugaringKind :: Await ,
440
- ) => false ,
441
- ExpnKind :: AstPass ( _) | ExpnKind :: Desugaring ( _) => true , // well, it's "external"
442
- ExpnKind :: Macro ( MacroKind :: Bang , _) => {
443
- // Dummy span for the `def_site` means it's an external macro.
444
- expn_data. def_site . is_dummy ( ) || sess. source_map ( ) . is_imported ( expn_data. def_site )
445
- }
446
- ExpnKind :: Macro { .. } => true , // definitely a plugin
447
- }
448
- }
449
-
450
- /// Return whether `span` is generated by `async` or `await`.
451
- pub fn is_from_async_await ( span : Span ) -> bool {
452
- let expn_data = span. ctxt ( ) . outer_expn_data ( ) ;
453
- match expn_data. kind {
454
- ExpnKind :: Desugaring ( DesugaringKind :: Async | DesugaringKind :: Await ) => true ,
455
- _ => false ,
456
- }
457
- }
0 commit comments