@@ -438,6 +438,7 @@ impl<'tcx> Index<'tcx> {
438
438
level : attr:: StabilityLevel :: Unstable {
439
439
reason : Some ( Symbol :: intern ( reason) ) ,
440
440
issue : 27812 ,
441
+ is_soft : false ,
441
442
} ,
442
443
feature : sym:: rustc_private,
443
444
rustc_depr : None ,
@@ -480,7 +481,7 @@ pub fn provide(providers: &mut Providers<'_>) {
480
481
}
481
482
482
483
pub 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
484
485
) {
485
486
let msg = match reason {
486
487
Some ( r) => format ! ( "use of unstable library feature '{}': {}" , feature, r) ,
@@ -505,7 +506,13 @@ pub fn report_unstable(
505
506
let error_id = ( DiagnosticMessageId :: StabilityId ( issue) , span_key, msg. clone ( ) ) ;
506
507
let fresh = sess. one_time_diagnostics . borrow_mut ( ) . insert ( error_id) ;
507
508
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
+ }
509
516
}
510
517
}
511
518
@@ -621,6 +628,7 @@ pub enum EvalResult {
621
628
feature : Symbol ,
622
629
reason : Option < Symbol > ,
623
630
issue : u32 ,
631
+ is_soft : bool ,
624
632
} ,
625
633
/// The item does not have the `#[stable]` or `#[unstable]` marker assigned.
626
634
Unmarked ,
@@ -720,7 +728,9 @@ impl<'tcx> TyCtxt<'tcx> {
720
728
}
721
729
722
730
match stability {
723
- Some ( & Stability { level : attr:: Unstable { reason, issue } , feature, .. } ) => {
731
+ Some ( & Stability {
732
+ level : attr:: Unstable { reason, issue, is_soft } , feature, ..
733
+ } ) => {
724
734
if span. allows_unstable ( feature) {
725
735
debug ! ( "stability: skipping span={:?} since it is internal" , span) ;
726
736
return EvalResult :: Allow ;
@@ -744,7 +754,7 @@ impl<'tcx> TyCtxt<'tcx> {
744
754
}
745
755
}
746
756
747
- EvalResult :: Deny { feature, reason, issue }
757
+ EvalResult :: Deny { feature, reason, issue, is_soft }
748
758
}
749
759
Some ( _) => {
750
760
// Stable APIs are always ok to call and deprecated APIs are
@@ -767,8 +777,8 @@ impl<'tcx> TyCtxt<'tcx> {
767
777
pub fn check_stability ( self , def_id : DefId , id : Option < HirId > , span : Span ) {
768
778
match self . eval_stability ( def_id, id, span) {
769
779
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) ,
772
782
EvalResult :: Unmarked => {
773
783
// The API could be uncallable for other reasons, for example when a private module
774
784
// was referenced.
0 commit comments