@@ -53,13 +53,15 @@ use rustc_hir::definitions::{DefKey, DefPathData, Definitions};
53
53
use rustc_hir:: intravisit;
54
54
use rustc_hir:: { ConstArg , GenericArg , ParamName } ;
55
55
use rustc_index:: vec:: { Idx , IndexVec } ;
56
- use rustc_session:: lint:: { builtin:: BARE_TRAIT_OBJECTS , BuiltinLintDiagnostics , LintBuffer } ;
56
+ use rustc_session:: lint:: builtin:: { BARE_TRAIT_OBJECTS , MISSING_ABI } ;
57
+ use rustc_session:: lint:: { BuiltinLintDiagnostics , LintBuffer } ;
57
58
use rustc_session:: parse:: ParseSess ;
58
59
use rustc_session:: Session ;
59
60
use rustc_span:: hygiene:: ExpnId ;
60
61
use rustc_span:: source_map:: { respan, DesugaringKind } ;
61
62
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
62
63
use rustc_span:: Span ;
64
+ use rustc_target:: spec:: abi:: Abi ;
63
65
64
66
use smallvec:: { smallvec, SmallVec } ;
65
67
use std:: collections:: BTreeMap ;
@@ -2777,6 +2779,26 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2777
2779
)
2778
2780
}
2779
2781
}
2782
+
2783
+ fn maybe_lint_missing_abi ( & mut self , span : Span , id : NodeId , default : Abi ) {
2784
+ // FIXME(davidtwco): This is a hack to detect macros which produce spans of the
2785
+ // call site which do not have a macro backtrace. See #61963.
2786
+ let is_macro_callsite = self
2787
+ . sess
2788
+ . source_map ( )
2789
+ . span_to_snippet ( span)
2790
+ . map ( |snippet| snippet. starts_with ( "#[" ) )
2791
+ . unwrap_or ( true ) ;
2792
+ if !is_macro_callsite {
2793
+ self . resolver . lint_buffer ( ) . buffer_lint_with_diagnostic (
2794
+ MISSING_ABI ,
2795
+ id,
2796
+ span,
2797
+ "extern declarations without an explicit ABI are deprecated" ,
2798
+ BuiltinLintDiagnostics :: MissingAbi ( span, default) ,
2799
+ )
2800
+ }
2801
+ }
2780
2802
}
2781
2803
2782
2804
fn body_ids ( bodies : & BTreeMap < hir:: BodyId , hir:: Body < ' _ > > ) -> Vec < hir:: BodyId > {
0 commit comments