@@ -438,6 +438,7 @@ impl<'tcx> Index<'tcx> {
438438 level : attr:: StabilityLevel :: Unstable {
439439 reason : Some ( Symbol :: intern ( reason) ) ,
440440 issue : 27812 ,
441+ is_soft : false ,
441442 } ,
442443 feature : sym:: rustc_private,
443444 rustc_depr : None ,
@@ -480,7 +481,7 @@ pub fn provide(providers: &mut Providers<'_>) {
480481}
481482
482483pub fn report_unstable (
483- sess : & Session , feature : Symbol , reason : Option < Symbol > , issue : u32 , span : Span
484+ sess : & Session , feature : Symbol , reason : Option < Symbol > , issue : u32 , is_soft : bool , span : Span
484485) {
485486 let msg = match reason {
486487 Some ( r) => format ! ( "use of unstable library feature '{}': {}" , feature, r) ,
@@ -505,7 +506,13 @@ pub fn report_unstable(
505506 let error_id = ( DiagnosticMessageId :: StabilityId ( issue) , span_key, msg. clone ( ) ) ;
506507 let fresh = sess. one_time_diagnostics . borrow_mut ( ) . insert ( error_id) ;
507508 if fresh {
508- emit_feature_err ( & sess. parse_sess , feature, span, GateIssue :: Library ( Some ( issue) ) , & msg) ;
509+ if is_soft {
510+ sess. buffer_lint ( lint:: builtin:: SOFT_UNSTABLE , CRATE_NODE_ID , span, & msg) ;
511+ } else {
512+ emit_feature_err (
513+ & sess. parse_sess , feature, span, GateIssue :: Library ( Some ( issue) ) , & msg
514+ ) ;
515+ }
509516 }
510517}
511518
@@ -621,6 +628,7 @@ pub enum EvalResult {
621628 feature : Symbol ,
622629 reason : Option < Symbol > ,
623630 issue : u32 ,
631+ is_soft : bool ,
624632 } ,
625633 /// The item does not have the `#[stable]` or `#[unstable]` marker assigned.
626634 Unmarked ,
@@ -720,7 +728,9 @@ impl<'tcx> TyCtxt<'tcx> {
720728 }
721729
722730 match stability {
723- Some ( & Stability { level : attr:: Unstable { reason, issue } , feature, .. } ) => {
731+ Some ( & Stability {
732+ level : attr:: Unstable { reason, issue, is_soft } , feature, ..
733+ } ) => {
724734 if span. allows_unstable ( feature) {
725735 debug ! ( "stability: skipping span={:?} since it is internal" , span) ;
726736 return EvalResult :: Allow ;
@@ -744,7 +754,7 @@ impl<'tcx> TyCtxt<'tcx> {
744754 }
745755 }
746756
747- EvalResult :: Deny { feature, reason, issue }
757+ EvalResult :: Deny { feature, reason, issue, is_soft }
748758 }
749759 Some ( _) => {
750760 // Stable APIs are always ok to call and deprecated APIs are
@@ -767,8 +777,8 @@ impl<'tcx> TyCtxt<'tcx> {
767777 pub fn check_stability ( self , def_id : DefId , id : Option < HirId > , span : Span ) {
768778 match self . eval_stability ( def_id, id, span) {
769779 EvalResult :: Allow => { }
770- EvalResult :: Deny { feature, reason, issue } =>
771- report_unstable ( self . sess , feature, reason, issue, span) ,
780+ EvalResult :: Deny { feature, reason, issue, is_soft } =>
781+ report_unstable ( self . sess , feature, reason, issue, is_soft , span) ,
772782 EvalResult :: Unmarked => {
773783 // The API could be uncallable for other reasons, for example when a private module
774784 // was referenced.
0 commit comments