@@ -25,7 +25,7 @@ use rustc_parse::parser::{
25
25
use rustc_parse:: validate_attr;
26
26
use rustc_session:: lint:: builtin:: { UNUSED_ATTRIBUTES , UNUSED_DOC_COMMENTS } ;
27
27
use rustc_session:: lint:: BuiltinLintDiag ;
28
- use rustc_session:: parse:: feature_err ;
28
+ use rustc_session:: parse:: get_feature_diagnostics ;
29
29
use rustc_session:: { Limit , Session } ;
30
30
use rustc_span:: hygiene:: SyntaxContext ;
31
31
use rustc_span:: symbol:: { sym, Ident } ;
@@ -35,11 +35,11 @@ use smallvec::SmallVec;
35
35
use crate :: base:: * ;
36
36
use crate :: config:: StripUnconfigured ;
37
37
use crate :: errors:: {
38
- EmptyDelegationMac , GlobDelegationOutsideImpls , GlobDelegationTraitlessQpath , IncompleteParse ,
39
- RecursionLimitReached , RemoveExprNotSupported , RemoveNodeNotSupported , UnsupportedKeyValue ,
40
- WrongFragmentKind ,
38
+ CustomAttributesForbidden , EmptyDelegationMac , GlobDelegationOutsideImpls ,
39
+ GlobDelegationTraitlessQpath , IncompleteParse , NonInlineModuleInProcMacroUnstable ,
40
+ RecursionLimitReached , RemoveExprNotSupported , RemoveNodeNotSupported , StatementOrExpression ,
41
+ UnsupportedKeyValue , WrongFragmentKind ,
41
42
} ;
42
- use crate :: fluent_generated;
43
43
use crate :: mbe:: diagnostics:: annotate_err_with_kind;
44
44
use crate :: module:: { mod_dir_path, parse_external_mod, DirOwnership , ParsedExternalMod } ;
45
45
use crate :: placeholders:: { placeholder, PlaceholderExpander } ;
@@ -841,7 +841,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
841
841
} )
842
842
}
843
843
844
- #[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
845
844
fn gate_proc_macro_attr_item ( & self , span : Span , item : & Annotatable ) {
846
845
let kind = match item {
847
846
Annotatable :: Item ( _)
@@ -854,9 +853,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
854
853
if stmt. is_item ( ) {
855
854
return ;
856
855
}
857
- "statements"
856
+ StatementOrExpression :: Statement
858
857
}
859
- Annotatable :: Expr ( _) => "expressions" ,
858
+ Annotatable :: Expr ( _) => StatementOrExpression :: Expression ,
860
859
Annotatable :: Arm ( ..)
861
860
| Annotatable :: ExprField ( ..)
862
861
| Annotatable :: PatField ( ..)
@@ -868,13 +867,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
868
867
if self . cx . ecfg . features . proc_macro_hygiene {
869
868
return ;
870
869
}
871
- feature_err (
872
- & self . cx . sess ,
873
- sym:: proc_macro_hygiene,
870
+ self . cx . dcx ( ) . emit_err ( CustomAttributesForbidden {
874
871
span,
875
- format ! ( "custom attributes cannot be applied to {kind}" ) ,
876
- )
877
- . emit ( ) ;
872
+ subdiag : get_feature_diagnostics ( & self . cx . sess , sym :: proc_macro_hygiene ) ,
873
+ kind ,
874
+ } ) ;
878
875
}
879
876
880
877
fn gate_proc_macro_input ( & self , annotatable : & Annotatable ) {
@@ -888,13 +885,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
888
885
ItemKind :: Mod ( _, mod_kind)
889
886
if !matches ! ( mod_kind, ModKind :: Loaded ( _, Inline :: Yes , _) ) =>
890
887
{
891
- feature_err (
892
- self . sess ,
893
- sym:: proc_macro_hygiene,
894
- item. span ,
895
- fluent_generated:: expand_non_inline_modules_in_proc_macro_input_are_unstable,
896
- )
897
- . emit ( ) ;
888
+ self . sess . dcx ( ) . emit_err ( NonInlineModuleInProcMacroUnstable {
889
+ span : item. span ,
890
+ subdiag : get_feature_diagnostics ( self . sess , sym:: proc_macro_hygiene) ,
891
+ } ) ;
898
892
}
899
893
_ => { }
900
894
}
0 commit comments