22//! It also serves as an input to the parser itself. 
33
44use  crate :: config:: CheckCfg ; 
5+ use  crate :: errors:: { FeatureDiagnosticForIssue ,  FeatureDiagnosticHelp ,  FeatureGateError } ; 
56use  crate :: lint:: { 
67    builtin:: UNSTABLE_SYNTAX_PRE_EXPANSION ,  BufferedEarlyLint ,  BuiltinLintDiagnostics ,  Lint ,  LintId , 
78} ; 
@@ -11,7 +12,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1112use  rustc_data_structures:: sync:: { Lock ,  Lrc } ; 
1213use  rustc_errors:: { emitter:: SilentEmitter ,  ColorConfig ,  Handler } ; 
1314use  rustc_errors:: { 
14-     error_code ,   fallback_fluent_bundle,  Applicability ,  Diagnostic ,  DiagnosticBuilder ,  DiagnosticId , 
15+     fallback_fluent_bundle,  Applicability ,  Diagnostic ,  DiagnosticBuilder ,  DiagnosticId , 
1516    DiagnosticMessage ,  EmissionGuarantee ,  ErrorGuaranteed ,  MultiSpan ,  StashKey , 
1617} ; 
1718use  rustc_feature:: { find_feature_issue,  GateIssue ,  UnstableFeatures } ; 
@@ -112,7 +113,7 @@ pub fn feature_err_issue<'a>(
112113            . map ( |err| err. cancel ( ) ) ; 
113114    } 
114115
115-     let  mut  err = sess. span_diagnostic . struct_span_err_with_code ( span,  explain,   error_code ! ( E0658 ) ) ; 
116+     let  mut  err = sess. create_err ( FeatureGateError   {   span,  explain  } ) ; 
116117    add_feature_diagnostics_for_issue ( & mut  err,  sess,  feature,  issue) ; 
117118    err
118119} 
@@ -130,6 +131,8 @@ pub fn feature_warn<'a>(sess: &'a ParseSess, feature: Symbol, span: Span, explai
130131/// 
131132/// This variant allows you to control whether it is a library or language feature. 
132133/// Almost always, you want to use this for a language feature. If so, prefer `feature_warn`. 
134+ #[ allow( rustc:: diagnostic_outside_of_impl) ]  
135+ #[ allow( rustc:: untranslatable_diagnostic) ]  
133136pub  fn  feature_warn_issue < ' a > ( 
134137    sess :  & ' a  ParseSess , 
135138    feature :  Symbol , 
@@ -172,14 +175,12 @@ pub fn add_feature_diagnostics_for_issue<'a>(
172175    issue :  GateIssue , 
173176)  { 
174177    if  let  Some ( n)  = find_feature_issue ( feature,  issue)  { 
175-         err. note ( & format ! ( 
176-             "see issue #{n} <https://github.com/rust-lang/rust/issues/{n}> for more information" 
177-         ) ) ; 
178+         err. subdiagnostic ( FeatureDiagnosticForIssue  {  n } ) ; 
178179    } 
179180
180181    // #23973: do not suggest `#![feature(...)]` if we are in beta/stable 
181182    if  sess. unstable_features . is_nightly_build ( )  { 
182-         err. help ( & format ! ( "add `#![feature({ feature})]` to the crate attributes to enable" ) ) ; 
183+         err. subdiagnostic ( FeatureDiagnosticHelp   {   feature  } ) ; 
183184    } 
184185} 
185186
@@ -372,6 +373,8 @@ impl ParseSess {
372373    } 
373374
374375    #[ rustc_lint_diagnostics]  
376+     #[ allow( rustc:: diagnostic_outside_of_impl) ]  
377+     #[ allow( rustc:: untranslatable_diagnostic) ]  
375378    pub  fn  struct_err ( 
376379        & self , 
377380        msg :  impl  Into < DiagnosticMessage > , 
@@ -380,16 +383,22 @@ impl ParseSess {
380383    } 
381384
382385    #[ rustc_lint_diagnostics]  
386+     #[ allow( rustc:: diagnostic_outside_of_impl) ]  
387+     #[ allow( rustc:: untranslatable_diagnostic) ]  
383388    pub  fn  struct_warn ( & self ,  msg :  impl  Into < DiagnosticMessage > )  -> DiagnosticBuilder < ' _ ,  ( ) >  { 
384389        self . span_diagnostic . struct_warn ( msg) 
385390    } 
386391
387392    #[ rustc_lint_diagnostics]  
393+     #[ allow( rustc:: diagnostic_outside_of_impl) ]  
394+     #[ allow( rustc:: untranslatable_diagnostic) ]  
388395    pub  fn  struct_fatal ( & self ,  msg :  impl  Into < DiagnosticMessage > )  -> DiagnosticBuilder < ' _ ,  !>  { 
389396        self . span_diagnostic . struct_fatal ( msg) 
390397    } 
391398
392399    #[ rustc_lint_diagnostics]  
400+     #[ allow( rustc:: diagnostic_outside_of_impl) ]  
401+     #[ allow( rustc:: untranslatable_diagnostic) ]  
393402    pub  fn  struct_diagnostic < G :  EmissionGuarantee > ( 
394403        & self , 
395404        msg :  impl  Into < DiagnosticMessage > , 
0 commit comments