diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /compiler/rustc_parse/src/parser/attr.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.tar.xz rustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_parse/src/parser/attr.rs')
-rw-r--r-- | compiler/rustc_parse/src/parser/attr.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index 686454a8f..e3e7c63e3 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -1,11 +1,15 @@ use crate::errors::{InvalidMetaItem, SuffixedLiteralInAttribute}; +use crate::fluent_generated as fluent; use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle}; use rustc_ast as ast; use rustc_ast::attr; use rustc_ast::token::{self, Delimiter, Nonterminal}; -use rustc_errors::{error_code, fluent, Diagnostic, IntoDiagnostic, PResult}; +use rustc_errors::{error_code, Diagnostic, IntoDiagnostic, PResult}; use rustc_span::{sym, BytePos, Span}; +use std::convert::TryInto; +use thin_vec::ThinVec; +use tracing::debug; // Public for rustfmt usage #[derive(Debug)] @@ -65,10 +69,10 @@ impl<'a> Parser<'a> { token::CommentKind::Block => OuterAttributeType::DocBlockComment, }, ) { - err.note(fluent::note); + err.note(fluent::parse_note); err.span_suggestion_verbose( replacement_span, - fluent::suggestion, + fluent::parse_suggestion, "", rustc_errors::Applicability::MachineApplicable, ); @@ -172,10 +176,10 @@ impl<'a> Parser<'a> { Ok(Some(item)) => { // FIXME(#100717) err.set_arg("item", item.kind.descr()); - err.span_label(item.span, fluent::label_does_not_annotate_this); + err.span_label(item.span, fluent::parse_label_does_not_annotate_this); err.span_suggestion_verbose( replacement_span, - fluent::sugg_change_inner_to_outer, + fluent::parse_sugg_change_inner_to_outer, match attr_type { OuterAttributeType::Attribute => "", OuterAttributeType::DocBlockComment => "*", @@ -201,8 +205,8 @@ impl<'a> Parser<'a> { attr_sp, fluent::parse_inner_attr_not_permitted_after_outer_doc_comment, ); - diag.span_label(attr_sp, fluent::label_attr) - .span_label(prev_doc_comment_span, fluent::label_prev_doc_comment); + diag.span_label(attr_sp, fluent::parse_label_attr) + .span_label(prev_doc_comment_span, fluent::parse_label_prev_doc_comment); diag } Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => { @@ -210,8 +214,8 @@ impl<'a> Parser<'a> { attr_sp, fluent::parse_inner_attr_not_permitted_after_outer_attr, ); - diag.span_label(attr_sp, fluent::label_attr) - .span_label(prev_outer_attr_sp, fluent::label_prev_attr); + diag.span_label(attr_sp, fluent::parse_label_attr) + .span_label(prev_outer_attr_sp, fluent::parse_label_prev_attr); diag } Some(InnerAttrForbiddenReason::InCodeBlock) | None => { @@ -346,9 +350,9 @@ impl<'a> Parser<'a> { } /// Matches `COMMASEP(meta_item_inner)`. - pub(crate) fn parse_meta_seq_top(&mut self) -> PResult<'a, Vec<ast::NestedMetaItem>> { + pub(crate) fn parse_meta_seq_top(&mut self) -> PResult<'a, ThinVec<ast::NestedMetaItem>> { // Presumably, the majority of the time there will only be one attr. - let mut nmis = Vec::with_capacity(1); + let mut nmis = ThinVec::with_capacity(1); while self.token.kind != token::Eof { nmis.push(self.parse_meta_item_inner()?); if !self.eat(&token::Comma) { |