@@ -485,7 +485,13 @@ pub fn provide(providers: &mut Providers<'_>) {
485485}
486486
487487pub fn report_unstable (
488- sess : & Session , feature : Symbol , reason : Option < Symbol > , issue : u32 , is_soft : bool , span : Span
488+ sess : & Session ,
489+ feature : Symbol ,
490+ reason : Option < Symbol > ,
491+ issue : u32 ,
492+ is_soft : bool ,
493+ span : Span ,
494+ soft_handler : impl FnOnce ( & ' static lint:: Lint , Span , & str ) ,
489495) {
490496 let msg = match reason {
491497 Some ( r) => format ! ( "use of unstable library feature '{}': {}" , feature, r) ,
@@ -511,7 +517,7 @@ pub fn report_unstable(
511517 let fresh = sess. one_time_diagnostics . borrow_mut ( ) . insert ( error_id) ;
512518 if fresh {
513519 if is_soft {
514- sess . buffer_lint ( lint:: builtin:: SOFT_UNSTABLE , CRATE_NODE_ID , span, & msg) ;
520+ soft_handler ( lint:: builtin:: SOFT_UNSTABLE , span, & msg)
515521 } else {
516522 emit_feature_err (
517523 & sess. parse_sess , feature, span, GateIssue :: Library ( Some ( issue) ) , & msg
@@ -779,10 +785,12 @@ impl<'tcx> TyCtxt<'tcx> {
779785 /// Additionally, this function will also check if the item is deprecated. If so, and `id` is
780786 /// not `None`, a deprecated lint attached to `id` will be emitted.
781787 pub fn check_stability ( self , def_id : DefId , id : Option < HirId > , span : Span ) {
788+ let soft_handler =
789+ |lint, span, msg : & _ | self . lint_hir ( lint, id. unwrap_or ( hir:: CRATE_HIR_ID ) , span, msg) ;
782790 match self . eval_stability ( def_id, id, span) {
783791 EvalResult :: Allow => { }
784792 EvalResult :: Deny { feature, reason, issue, is_soft } =>
785- report_unstable ( self . sess , feature, reason, issue, is_soft, span) ,
793+ report_unstable ( self . sess , feature, reason, issue, is_soft, span, soft_handler ) ,
786794 EvalResult :: Unmarked => {
787795 // The API could be uncallable for other reasons, for example when a private module
788796 // was referenced.
0 commit comments