1- use crate :: errors:: { InvalidMetaItem , SuffixedLiteralInAttribute } ;
2- use crate :: fluent_generated as fluent;
3-
41use super :: { AttrWrapper , Capturing , FnParseMode , ForceCollect , Parser , PathStyle } ;
2+ use crate :: errors:: { InvalidMetaItem , SuffixedLiteralInAttribute } ;
53use rustc_ast as ast;
64use rustc_ast:: attr;
75use rustc_ast:: token:: { self , Delimiter , Nonterminal } ;
@@ -58,9 +56,10 @@ impl<'a> Parser<'a> {
5856 let span = self . token . span ;
5957 let mut err = self . sess . span_diagnostic . struct_span_err_with_code (
6058 span,
61- fluent :: parse_inner_doc_comment_not_permitted ,
59+ "expected outer doc comment" ,
6260 error_code ! ( E0753 ) ,
6361 ) ;
62+ err. set_arg ( "item_type" , "doc comment" ) ;
6463 if let Some ( replacement_span) = self . annotate_following_item_if_applicable (
6564 & mut err,
6665 span,
@@ -69,10 +68,10 @@ impl<'a> Parser<'a> {
6968 token:: CommentKind :: Block => OuterAttributeType :: DocBlockComment ,
7069 } ,
7170 ) {
72- err. note ( fluent :: parse_note ) ;
71+ err. note ( "inner doc comments like this (starting with `//!` or `/*!`) can only appear before items" ) ;
7372 err. span_suggestion_verbose (
7473 replacement_span,
75- fluent :: parse_suggestion ,
74+ "you might have meant to write a regular comment" ,
7675 "" ,
7776 rustc_errors:: Applicability :: MachineApplicable ,
7877 ) ;
@@ -176,10 +175,10 @@ impl<'a> Parser<'a> {
176175 Ok ( Some ( item) ) => {
177176 // FIXME(#100717)
178177 err. set_arg ( "item" , item. kind . descr ( ) ) ;
179- err. span_label ( item. span , fluent :: parse_label_does_not_annotate_this ) ;
178+ err. span_label ( item. span , "the inner {$item_type} doesn't annotate this {$item}" ) ;
180179 err. span_suggestion_verbose (
181180 replacement_span,
182- fluent :: parse_sugg_change_inner_to_outer ,
181+ "to annotate the {$item}, change the {$item_type} from inner to outer style" ,
183182 match attr_type {
184183 OuterAttributeType :: Attribute => "" ,
185184 OuterAttributeType :: DocBlockComment => "*" ,
@@ -203,27 +202,29 @@ impl<'a> Parser<'a> {
203202 Some ( InnerAttrForbiddenReason :: AfterOuterDocComment { prev_doc_comment_span } ) => {
204203 let mut diag = self . struct_span_err (
205204 attr_sp,
206- fluent :: parse_inner_attr_not_permitted_after_outer_doc_comment ,
205+ "an inner attribute is not permitted following an outer doc comment" ,
207206 ) ;
208- diag. span_label ( attr_sp, fluent :: parse_label_attr )
209- . span_label ( prev_doc_comment_span, fluent :: parse_label_prev_doc_comment ) ;
207+ diag. span_label ( attr_sp, "not permitted following an outer doc comment" )
208+ . span_label ( prev_doc_comment_span, "previous doc comment" ) ;
210209 diag
211210 }
212211 Some ( InnerAttrForbiddenReason :: AfterOuterAttribute { prev_outer_attr_sp } ) => {
213212 let mut diag = self . struct_span_err (
214213 attr_sp,
215- fluent :: parse_inner_attr_not_permitted_after_outer_attr ,
214+ "an inner attribute is not permitted following an outer attribute" ,
216215 ) ;
217- diag. span_label ( attr_sp, fluent :: parse_label_attr )
218- . span_label ( prev_outer_attr_sp, fluent :: parse_label_prev_attr ) ;
216+ diag. span_label ( attr_sp, "not permitted following an outer attribute" )
217+ . span_label ( prev_outer_attr_sp, "previous outer attribute" ) ;
219218 diag
220219 }
221- Some ( InnerAttrForbiddenReason :: InCodeBlock ) | None => {
222- self . struct_span_err ( attr_sp, fluent:: parse_inner_attr_not_permitted)
223- }
220+ Some ( InnerAttrForbiddenReason :: InCodeBlock ) | None => self . struct_span_err (
221+ attr_sp,
222+ "an inner attribute is not permitted in this context" ,
223+ ) ,
224224 } ;
225225
226- diag. note ( fluent:: parse_inner_attr_explanation) ;
226+ diag. set_arg ( "item_type" , "attribute" ) ;
227+ diag. note ( "inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files" ) ;
227228 if self
228229 . annotate_following_item_if_applicable (
229230 & mut diag,
@@ -232,7 +233,7 @@ impl<'a> Parser<'a> {
232233 )
233234 . is_some ( )
234235 {
235- diag. note ( fluent :: parse_outer_attr_explanation ) ;
236+ diag. note ( "outer attributes, like `#[test]`, annotate the item following them" ) ;
236237 } ;
237238 diag. emit ( ) ;
238239 }
0 commit comments