1
- use crate :: errors:: { InvalidMetaItem , SuffixedLiteralInAttribute } ;
2
- use crate :: fluent_generated as fluent;
3
-
4
1
use super :: { AttrWrapper , Capturing , FnParseMode , ForceCollect , Parser , PathStyle } ;
2
+ use crate :: errors:: { InvalidMetaItem , SuffixedLiteralInAttribute } ;
5
3
use rustc_ast as ast;
6
4
use rustc_ast:: attr;
7
5
use rustc_ast:: token:: { self , Delimiter , Nonterminal } ;
@@ -58,9 +56,10 @@ impl<'a> Parser<'a> {
58
56
let span = self . token . span ;
59
57
let mut err = self . sess . span_diagnostic . struct_span_err_with_code (
60
58
span,
61
- fluent :: parse_inner_doc_comment_not_permitted ,
59
+ "expected outer doc comment" ,
62
60
error_code ! ( E0753 ) ,
63
61
) ;
62
+ err. set_arg ( "item_type" , "doc comment" ) ;
64
63
if let Some ( replacement_span) = self . annotate_following_item_if_applicable (
65
64
& mut err,
66
65
span,
@@ -69,10 +68,10 @@ impl<'a> Parser<'a> {
69
68
token:: CommentKind :: Block => OuterAttributeType :: DocBlockComment ,
70
69
} ,
71
70
) {
72
- err. note ( fluent :: parse_note ) ;
71
+ err. note ( "inner doc comments like this (starting with `//!` or `/*!`) can only appear before items" ) ;
73
72
err. span_suggestion_verbose (
74
73
replacement_span,
75
- fluent :: parse_suggestion ,
74
+ "you might have meant to write a regular comment" ,
76
75
"" ,
77
76
rustc_errors:: Applicability :: MachineApplicable ,
78
77
) ;
@@ -176,10 +175,10 @@ impl<'a> Parser<'a> {
176
175
Ok ( Some ( item) ) => {
177
176
// FIXME(#100717)
178
177
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}" ) ;
180
179
err. span_suggestion_verbose (
181
180
replacement_span,
182
- fluent :: parse_sugg_change_inner_to_outer ,
181
+ "to annotate the {$item}, change the {$item_type} from inner to outer style" ,
183
182
match attr_type {
184
183
OuterAttributeType :: Attribute => "" ,
185
184
OuterAttributeType :: DocBlockComment => "*" ,
@@ -203,27 +202,29 @@ impl<'a> Parser<'a> {
203
202
Some ( InnerAttrForbiddenReason :: AfterOuterDocComment { prev_doc_comment_span } ) => {
204
203
let mut diag = self . struct_span_err (
205
204
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" ,
207
206
) ;
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" ) ;
210
209
diag
211
210
}
212
211
Some ( InnerAttrForbiddenReason :: AfterOuterAttribute { prev_outer_attr_sp } ) => {
213
212
let mut diag = self . struct_span_err (
214
213
attr_sp,
215
- fluent :: parse_inner_attr_not_permitted_after_outer_attr ,
214
+ "an inner attribute is not permitted following an outer attribute" ,
216
215
) ;
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" ) ;
219
218
diag
220
219
}
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
+ ) ,
224
224
} ;
225
225
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" ) ;
227
228
if self
228
229
. annotate_following_item_if_applicable (
229
230
& mut diag,
@@ -232,7 +233,7 @@ impl<'a> Parser<'a> {
232
233
)
233
234
. is_some ( )
234
235
{
235
- diag. note ( fluent :: parse_outer_attr_explanation ) ;
236
+ diag. note ( "outer attributes, like `#[test]`, annotate the item following them" ) ;
236
237
} ;
237
238
diag. emit ( ) ;
238
239
}
0 commit comments