@@ -281,7 +281,13 @@ impl<'tcx> TyCtxt<'tcx> {
281
281
/// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
282
282
/// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
283
283
/// `id`.
284
- pub fn eval_stability ( self , def_id : DefId , id : Option < HirId > , span : Span ) -> EvalResult {
284
+ pub fn eval_stability (
285
+ self ,
286
+ def_id : DefId ,
287
+ id : Option < HirId > ,
288
+ span : Span ,
289
+ method_span : Option < Span > ,
290
+ ) -> EvalResult {
285
291
// Deprecated attributes apply in-crate and cross-crate.
286
292
if let Some ( id) = id {
287
293
if let Some ( depr_entry) = self . lookup_deprecation_entry ( def_id) {
@@ -300,6 +306,7 @@ impl<'tcx> TyCtxt<'tcx> {
300
306
let path = & with_no_trimmed_paths ( || self . def_path_str ( def_id) ) ;
301
307
let kind = self . def_kind ( def_id) . descr ( def_id) ;
302
308
let ( message, lint) = deprecation_message ( & depr_entry. attr , kind, path) ;
309
+ let span = method_span. unwrap_or ( span) ;
303
310
late_report_deprecation (
304
311
self ,
305
312
& message,
@@ -382,8 +389,14 @@ impl<'tcx> TyCtxt<'tcx> {
382
389
///
383
390
/// This function will also check if the item is deprecated.
384
391
/// If so, and `id` is not `None`, a deprecated lint attached to `id` will be emitted.
385
- pub fn check_stability ( self , def_id : DefId , id : Option < HirId > , span : Span ) {
386
- self . check_optional_stability ( def_id, id, span, |span, def_id| {
392
+ pub fn check_stability (
393
+ self ,
394
+ def_id : DefId ,
395
+ id : Option < HirId > ,
396
+ span : Span ,
397
+ method_span : Option < Span > ,
398
+ ) {
399
+ self . check_optional_stability ( def_id, id, span, method_span, |span, def_id| {
387
400
// The API could be uncallable for other reasons, for example when a private module
388
401
// was referenced.
389
402
self . sess . delay_span_bug ( span, & format ! ( "encountered unmarked API: {:?}" , def_id) ) ;
@@ -399,14 +412,15 @@ impl<'tcx> TyCtxt<'tcx> {
399
412
def_id : DefId ,
400
413
id : Option < HirId > ,
401
414
span : Span ,
415
+ method_span : Option < Span > ,
402
416
unmarked : impl FnOnce ( Span , DefId ) ,
403
417
) {
404
418
let soft_handler = |lint, span, msg : & _ | {
405
419
self . struct_span_lint_hir ( lint, id. unwrap_or ( hir:: CRATE_HIR_ID ) , span, |lint| {
406
420
lint. build ( msg) . emit ( )
407
421
} )
408
422
} ;
409
- match self . eval_stability ( def_id, id, span) {
423
+ match self . eval_stability ( def_id, id, span, method_span ) {
410
424
EvalResult :: Allow => { }
411
425
EvalResult :: Deny { feature, reason, issue, is_soft } => {
412
426
report_unstable ( self . sess , feature, reason, issue, is_soft, span, soft_handler)
0 commit comments