1
1
use crate :: base:: * ;
2
2
use crate :: config:: StripUnconfigured ;
3
3
use crate :: errors:: {
4
- EmptyDelegationList , IncompleteParse , RecursionLimitReached , RemoveExprNotSupported ,
5
- RemoveNodeNotSupported , UnsupportedKeyValue , WrongFragmentKind ,
4
+ CustomAttributesForbidden , EmptyDelegationList , IncompleteParse ,
5
+ NonInlineModuleInProcMacroUnstable , RecursionLimitReached , RemoveExprNotSupported ,
6
+ RemoveNodeNotSupported , StatementOrExpression , UnsupportedKeyValue , WrongFragmentKind ,
6
7
} ;
7
8
use crate :: mbe:: diagnostics:: annotate_err_with_kind;
8
9
use crate :: module:: { mod_dir_path, parse_external_mod, DirOwnership , ParsedExternalMod } ;
@@ -29,7 +30,7 @@ use rustc_parse::parser::{
29
30
use rustc_parse:: validate_attr;
30
31
use rustc_session:: lint:: builtin:: { UNUSED_ATTRIBUTES , UNUSED_DOC_COMMENTS } ;
31
32
use rustc_session:: lint:: BuiltinLintDiag ;
32
- use rustc_session:: parse:: feature_err ;
33
+ use rustc_session:: parse:: get_feature_diagnostics ;
33
34
use rustc_session:: { Limit , Session } ;
34
35
use rustc_span:: hygiene:: SyntaxContext ;
35
36
use rustc_span:: symbol:: { sym, Ident } ;
@@ -796,7 +797,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
796
797
} )
797
798
}
798
799
799
- #[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
800
800
fn gate_proc_macro_attr_item ( & self , span : Span , item : & Annotatable ) {
801
801
let kind = match item {
802
802
Annotatable :: Item ( _)
@@ -810,9 +810,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
810
810
if stmt. is_item ( ) {
811
811
return ;
812
812
}
813
- "statements"
813
+ StatementOrExpression :: Statement
814
814
}
815
- Annotatable :: Expr ( _) => "expressions" ,
815
+ Annotatable :: Expr ( _) => StatementOrExpression :: Expression ,
816
816
Annotatable :: Arm ( ..)
817
817
| Annotatable :: ExprField ( ..)
818
818
| Annotatable :: PatField ( ..)
@@ -824,13 +824,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
824
824
if self . cx . ecfg . features . proc_macro_hygiene {
825
825
return ;
826
826
}
827
- feature_err (
828
- & self . cx . sess ,
829
- sym:: proc_macro_hygiene,
827
+ self . cx . dcx ( ) . emit_err ( CustomAttributesForbidden {
830
828
span,
831
- format ! ( "custom attributes cannot be applied to {kind}" ) ,
832
- )
833
- . emit ( ) ;
829
+ subdiag : get_feature_diagnostics ( & self . cx . sess , sym :: proc_macro_hygiene ) ,
830
+ kind ,
831
+ } ) ;
834
832
}
835
833
836
834
fn gate_proc_macro_input ( & self , annotatable : & Annotatable ) {
@@ -839,19 +837,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
839
837
}
840
838
841
839
impl < ' ast , ' a > Visitor < ' ast > for GateProcMacroInput < ' a > {
842
- #[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
843
840
fn visit_item ( & mut self , item : & ' ast ast:: Item ) {
844
841
match & item. kind {
845
842
ItemKind :: Mod ( _, mod_kind)
846
843
if !matches ! ( mod_kind, ModKind :: Loaded ( _, Inline :: Yes , _) ) =>
847
844
{
848
- feature_err (
849
- self . sess ,
850
- sym:: proc_macro_hygiene,
851
- item. span ,
852
- "non-inline modules in proc macro input are unstable" ,
853
- )
854
- . emit ( ) ;
845
+ self . sess . dcx ( ) . emit_err ( NonInlineModuleInProcMacroUnstable {
846
+ span : item. span ,
847
+ subdiag : get_feature_diagnostics ( self . sess , sym:: proc_macro_hygiene) ,
848
+ } ) ;
855
849
}
856
850
_ => { }
857
851
}
0 commit comments