1313
1414pub use self :: StabilityLevel :: * ;
1515
16- use lint;
16+ use lint:: { self , Lint } ;
1717use hir:: { self , Item , Generics , StructField , Variant , HirId } ;
1818use hir:: def:: Def ;
1919use hir:: def_id:: { CrateNum , CRATE_DEF_INDEX , DefId , LOCAL_CRATE } ;
@@ -562,18 +562,20 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
562562 return EvalResult :: Allow ;
563563 }
564564
565- let lint_deprecated = |def_id : DefId , id : NodeId , note : Option < Symbol > | {
566- let path = self . item_path_str ( def_id) ;
567-
565+ let lint_deprecated = |def_id : DefId ,
566+ id : NodeId ,
567+ note : Option < Symbol > ,
568+ message : & str ,
569+ lint : & ' static Lint | {
568570 let msg = if let Some ( note) = note {
569- format ! ( "use of deprecated item '{}' : {}" , path , note)
571+ format ! ( "{} : {}" , message , note)
570572 } else {
571- format ! ( "use of deprecated item '{}' " , path )
573+ format ! ( "{} " , message )
572574 } ;
573575
574- self . lint_node ( lint:: builtin :: DEPRECATED , id, span, & msg) ;
576+ self . lint_node ( lint, id, span, & msg) ;
575577 if id == ast:: DUMMY_NODE_ID {
576- span_bug ! ( span, "emitted a deprecated lint with dummy node id: {:?}" , def_id) ;
578+ span_bug ! ( span, "emitted a {} lint with dummy node id: {:?}" , lint . name , def_id) ;
577579 }
578580 } ;
579581
@@ -584,17 +586,40 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
584586 // version, then we should display no warning message.
585587 let deprecated_in_future_version = if let Some ( sym) = depr_entry. attr . since {
586588 let since = sym. as_str ( ) ;
587- !deprecation_in_effect ( & since)
589+ if !deprecation_in_effect ( & since) {
590+ Some ( since)
591+ } else {
592+ None
593+ }
588594 } else {
589- false
595+ None
590596 } ;
591597
592598 let parent_def_id = self . hir ( ) . local_def_id ( self . hir ( ) . get_parent ( id) ) ;
593- let skip = deprecated_in_future_version ||
594- self . lookup_deprecation_entry ( parent_def_id)
599+ let skip = self . lookup_deprecation_entry ( parent_def_id)
595600 . map_or ( false , |parent_depr| parent_depr. same_origin ( & depr_entry) ) ;
596- if !skip {
597- lint_deprecated ( def_id, id, depr_entry. attr . note ) ;
601+
602+
603+ if let Some ( since) = deprecated_in_future_version {
604+ let path = self . item_path_str ( def_id) ;
605+ let message = format ! ( "use of item '{}' \
606+ that will be deprecated in future version {}",
607+ path,
608+ since) ;
609+
610+ lint_deprecated ( def_id,
611+ id,
612+ depr_entry. attr . note ,
613+ & message,
614+ lint:: builtin:: DEPRECATED_IN_FUTURE ) ;
615+ } else if !skip {
616+ let path = self . item_path_str ( def_id) ;
617+ let message = format ! ( "use of deprecated item '{}'" , path) ;
618+ lint_deprecated ( def_id,
619+ id,
620+ depr_entry. attr . note ,
621+ & message,
622+ lint:: builtin:: DEPRECATED ) ;
598623 }
599624 } ;
600625 }
@@ -614,8 +639,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
614639 if let Some ( & Stability { rustc_depr : Some ( attr:: RustcDeprecation { reason, since } ) , ..} )
615640 = stability {
616641 if let Some ( id) = id {
642+ let path = self . item_path_str ( def_id) ;
643+ let message = format ! ( "use of deprecated item '{}'" , path) ;
617644 if deprecation_in_effect ( & since. as_str ( ) ) {
618- lint_deprecated ( def_id, id, Some ( reason) ) ;
645+ lint_deprecated ( def_id,
646+ id,
647+ Some ( reason) ,
648+ & message,
649+ lint:: builtin:: DEPRECATED ) ;
619650 }
620651 }
621652 }
0 commit comments