Reformat using the new identifier sorting from rustfmt

This commit is contained in:
Michael Goulet 2024-09-22 19:05:04 -04:00
parent 1173204b36
commit c682aa162b
1455 changed files with 7152 additions and 8384 deletions

View file

@ -1116,25 +1116,19 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedIdentifier {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let token_descr = TokenDescription::from_token(&self.token);
let mut diag = Diag::new(
dcx,
level,
match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
fluent::parse_expected_identifier_found_reserved_identifier_str
}
Some(TokenDescription::Keyword) => {
fluent::parse_expected_identifier_found_keyword_str
}
Some(TokenDescription::ReservedKeyword) => {
fluent::parse_expected_identifier_found_reserved_keyword_str
}
Some(TokenDescription::DocComment) => {
fluent::parse_expected_identifier_found_doc_comment_str
}
None => fluent::parse_expected_identifier_found_str,
},
);
let mut diag = Diag::new(dcx, level, match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
fluent::parse_expected_identifier_found_reserved_identifier_str
}
Some(TokenDescription::Keyword) => fluent::parse_expected_identifier_found_keyword_str,
Some(TokenDescription::ReservedKeyword) => {
fluent::parse_expected_identifier_found_reserved_keyword_str
}
Some(TokenDescription::DocComment) => {
fluent::parse_expected_identifier_found_doc_comment_str
}
None => fluent::parse_expected_identifier_found_str,
});
diag.span(self.span);
diag.arg("token", self.token);
@ -1176,23 +1170,17 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for ExpectedSemi {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let token_descr = TokenDescription::from_token(&self.token);
let mut diag = Diag::new(
dcx,
level,
match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
fluent::parse_expected_semi_found_reserved_identifier_str
}
Some(TokenDescription::Keyword) => fluent::parse_expected_semi_found_keyword_str,
Some(TokenDescription::ReservedKeyword) => {
fluent::parse_expected_semi_found_reserved_keyword_str
}
Some(TokenDescription::DocComment) => {
fluent::parse_expected_semi_found_doc_comment_str
}
None => fluent::parse_expected_semi_found_str,
},
);
let mut diag = Diag::new(dcx, level, match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
fluent::parse_expected_semi_found_reserved_identifier_str
}
Some(TokenDescription::Keyword) => fluent::parse_expected_semi_found_keyword_str,
Some(TokenDescription::ReservedKeyword) => {
fluent::parse_expected_semi_found_reserved_keyword_str
}
Some(TokenDescription::DocComment) => fluent::parse_expected_semi_found_doc_comment_str,
None => fluent::parse_expected_semi_found_str,
});
diag.span(self.span);
diag.arg("token", self.token);

View file

@ -1,7 +1,7 @@
use rustc_ast::token::Delimiter;
use rustc_errors::Diag;
use rustc_span::source_map::SourceMap;
use rustc_span::Span;
use rustc_span::source_map::SourceMap;
use super::UnmatchedDelim;

View file

@ -8,10 +8,10 @@ use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, StashKey};
use rustc_lexer::unescape::{self, EscapeError, Mode};
use rustc_lexer::{Base, Cursor, DocStyle, LiteralKind, RawStrError};
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::{
RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
};
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::Symbol;
use rustc_span::{BytePos, Pos, Span};
@ -866,7 +866,7 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
}
pub fn nfc_normalize(string: &str) -> Symbol {
use unicode_normalization::{is_nfc_quick, IsNormalized, UnicodeNormalization};
use unicode_normalization::{IsNormalized, UnicodeNormalization, is_nfc_quick};
match is_nfc_quick(string.chars()) {
IsNormalized::Yes => Symbol::intern(string),
_ => {

View file

@ -5,7 +5,7 @@ use rustc_errors::{Applicability, PErr};
use rustc_span::symbol::kw;
use super::diagnostics::{
report_suspicious_mismatch_block, same_indentation_level, TokenTreeDiagInfo,
TokenTreeDiagInfo, report_suspicious_mismatch_block, same_indentation_level,
};
use super::{StringReader, UnmatchedDelim};
use crate::Parser;

View file

@ -40,8 +40,8 @@ pub(crate) fn emit_unescape_error(
dcx.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: false })
}
EscapeError::MoreThanOneChar => {
use unicode_normalization::char::is_combining_mark;
use unicode_normalization::UnicodeNormalization;
use unicode_normalization::char::is_combining_mark;
let mut sugg = None;
let mut note = None;

View file

@ -18,7 +18,7 @@ use std::path::Path;
use rustc_ast as ast;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{token, AttrItem, Attribute, MetaItem};
use rustc_ast::{AttrItem, Attribute, MetaItem, token};
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Diag, FatalError, PResult};
@ -29,7 +29,7 @@ pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments");
#[macro_use]
pub mod parser;
use parser::{make_unclosed_delims_error, Parser};
use parser::{Parser, make_unclosed_delims_error};
pub mod lexer;
pub mod validate_attr;

View file

@ -10,7 +10,7 @@ use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, HasTokens};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::PResult;
use rustc_session::parse::ParseSess;
use rustc_span::{sym, Span, DUMMY_SP};
use rustc_span::{DUMMY_SP, Span, sym};
use super::{
Capturing, FlatToken, ForceCollect, NodeRange, NodeReplacement, Parser, ParserRange,
@ -485,10 +485,10 @@ fn make_attr_token_stream(
for flat_token in iter {
match flat_token {
FlatToken::Token((Token { kind: TokenKind::OpenDelim(delim), span }, spacing)) => {
stack_rest.push(mem::replace(
&mut stack_top,
FrameData { open_delim_sp: Some((delim, span, spacing)), inner: vec![] },
));
stack_rest.push(mem::replace(&mut stack_top, FrameData {
open_delim_sp: Some((delim, span, spacing)),
inner: vec![],
}));
}
FlatToken::Token((Token { kind: TokenKind::CloseDelim(delim), span }, spacing)) => {
let frame_data = mem::replace(&mut stack_top, stack_rest.pop().unwrap());

View file

@ -15,15 +15,15 @@ use rustc_ast::{
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{
pluralize, Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, PErr, PResult,
Subdiagnostic, Suggestions,
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, PErr, PResult, Subdiagnostic,
Suggestions, pluralize,
};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, AllKeywords, Ident};
use rustc_span::{BytePos, Span, SpanSnippetError, Symbol, DUMMY_SP};
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{AllKeywords, Ident, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Span, SpanSnippetError, Symbol};
use thin_vec::{ThinVec, thin_vec};
use tracing::{debug, trace};
use super::pat::Expected;
@ -721,15 +721,12 @@ impl<'a> Parser<'a> {
let span = self.token.span.with_lo(pos).with_hi(pos);
err.span_suggestion_verbose(
span,
format!(
"add a space before {} to write a regular comment",
match (kind, style) {
(token::CommentKind::Line, ast::AttrStyle::Inner) => "`!`",
(token::CommentKind::Block, ast::AttrStyle::Inner) => "`!`",
(token::CommentKind::Line, ast::AttrStyle::Outer) => "the last `/`",
(token::CommentKind::Block, ast::AttrStyle::Outer) => "the last `*`",
},
),
format!("add a space before {} to write a regular comment", match (kind, style) {
(token::CommentKind::Line, ast::AttrStyle::Inner) => "`!`",
(token::CommentKind::Block, ast::AttrStyle::Inner) => "`!`",
(token::CommentKind::Line, ast::AttrStyle::Outer) => "the last `/`",
(token::CommentKind::Block, ast::AttrStyle::Outer) => "the last `*`",
},),
" ".to_string(),
Applicability::MachineApplicable,
);
@ -1936,14 +1933,13 @@ impl<'a> Parser<'a> {
(token::Eof, None) => (self.prev_token.span, self.token.span),
_ => (self.prev_token.span.shrink_to_hi(), self.token.span),
};
let msg = format!(
"expected `{}`, found {}",
token_str,
match (&self.token.kind, self.subparser_name) {
(token::Eof, Some(origin)) => format!("end of {origin}"),
_ => this_token_str,
},
);
let msg = format!("expected `{}`, found {}", token_str, match (
&self.token.kind,
self.subparser_name
) {
(token::Eof, Some(origin)) => format!("end of {origin}"),
_ => this_token_str,
},);
let mut err = self.dcx().struct_span_err(sp, msg);
let label_exp = format!("expected `{token_str}`");
let sm = self.psess.source_map();
@ -2864,27 +2860,25 @@ impl<'a> Parser<'a> {
PatKind::Ident(BindingMode::NONE, ident, None) => {
match &first_pat.kind {
PatKind::Ident(_, old_ident, _) => {
let path = PatKind::Path(
None,
Path {
span: new_span,
segments: thin_vec![
PathSegment::from_ident(*old_ident),
PathSegment::from_ident(*ident),
],
tokens: None,
},
);
let path = PatKind::Path(None, Path {
span: new_span,
segments: thin_vec![
PathSegment::from_ident(*old_ident),
PathSegment::from_ident(*ident),
],
tokens: None,
});
first_pat = self.mk_pat(new_span, path);
show_sugg = true;
}
PatKind::Path(old_qself, old_path) => {
let mut segments = old_path.segments.clone();
segments.push(PathSegment::from_ident(*ident));
let path = PatKind::Path(
old_qself.clone(),
Path { span: new_span, segments, tokens: None },
);
let path = PatKind::Path(old_qself.clone(), Path {
span: new_span,
segments,
tokens: None,
});
first_pat = self.mk_pat(new_span, path);
show_sugg = true;
}

View file

@ -10,25 +10,25 @@ use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
use rustc_ast::util::case::Case;
use rustc_ast::util::classify;
use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity};
use rustc_ast::visit::{walk_expr, Visitor};
use rustc_ast::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
use rustc_ast::visit::{Visitor, walk_expr};
use rustc_ast::{
self as ast, AnonConst, Arm, AttrStyle, AttrVec, BinOp, BinOpKind, BlockCheckMode, CaptureBy,
ClosureBinder, Expr, ExprField, ExprKind, FnDecl, FnRetTy, Label, MacCall, MetaItemLit,
Movability, Param, RangeLimits, StmtKind, Ty, TyKind, UnOp, DUMMY_NODE_ID,
ClosureBinder, DUMMY_NODE_ID, Expr, ExprField, ExprKind, FnDecl, FnRetTy, Label, MacCall,
MetaItemLit, Movability, Param, RangeLimits, StmtKind, Ty, TyKind, UnOp,
};
use rustc_ast_pretty::pprust;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic};
use rustc_lexer::unescape::unescape_char;
use rustc_macros::Subdiagnostic;
use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_session::errors::{ExprParenthesesNeeded, report_lit_error};
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_span::source_map::{self, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span};
use thin_vec::{thin_vec, ThinVec};
use thin_vec::{ThinVec, thin_vec};
use tracing::instrument;
use super::diagnostics::SnapshotParser;
@ -811,20 +811,17 @@ impl<'a> Parser<'a> {
// Check if an illegal postfix operator has been added after the cast.
// If the resulting expression is not a cast, it is an illegal postfix operator.
if !matches!(with_postfix.kind, ExprKind::Cast(_, _)) {
let msg = format!(
"cast cannot be followed by {}",
match with_postfix.kind {
ExprKind::Index(..) => "indexing",
ExprKind::Try(_) => "`?`",
ExprKind::Field(_, _) => "a field access",
ExprKind::MethodCall(_) => "a method call",
ExprKind::Call(_, _) => "a function call",
ExprKind::Await(_, _) => "`.await`",
ExprKind::Match(_, _, MatchKind::Postfix) => "a postfix match",
ExprKind::Err(_) => return Ok(with_postfix),
_ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"),
}
);
let msg = format!("cast cannot be followed by {}", match with_postfix.kind {
ExprKind::Index(..) => "indexing",
ExprKind::Try(_) => "`?`",
ExprKind::Field(_, _) => "a field access",
ExprKind::MethodCall(_) => "a method call",
ExprKind::Call(_, _) => "a function call",
ExprKind::Await(_, _) => "`.await`",
ExprKind::Match(_, _, MatchKind::Postfix) => "a postfix match",
ExprKind::Err(_) => return Ok(with_postfix),
_ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"),
});
let mut err = self.dcx().struct_span_err(span, msg);
let suggest_parens = |err: &mut Diag<'_>| {
@ -2844,10 +2841,13 @@ impl<'a> Parser<'a> {
.emit_err(errors::MissingExpressionInForLoop { span: expr.span.shrink_to_lo() });
let err_expr = self.mk_expr(expr.span, ExprKind::Err(guar));
let block = self.mk_block(thin_vec![], BlockCheckMode::Default, self.prev_token.span);
return Ok(self.mk_expr(
lo.to(self.prev_token.span),
ExprKind::ForLoop { pat, iter: err_expr, body: block, label: opt_label, kind },
));
return Ok(self.mk_expr(lo.to(self.prev_token.span), ExprKind::ForLoop {
pat,
iter: err_expr,
body: block,
label: opt_label,
kind,
}));
}
let (attrs, loop_block) = self.parse_inner_attrs_and_block()?;

View file

@ -1,10 +1,10 @@
use ast::token::Delimiter;
use rustc_ast::{
self as ast, token, AttrVec, GenericBounds, GenericParam, GenericParamKind, TyKind, WhereClause,
self as ast, AttrVec, GenericBounds, GenericParam, GenericParamKind, TyKind, WhereClause, token,
};
use rustc_errors::{Applicability, PResult};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use rustc_span::symbol::{Ident, kw};
use thin_vec::ThinVec;
use super::{ForceCollect, Parser, Trailing, UsePreAttrPos};

View file

@ -10,15 +10,15 @@ use rustc_ast::util::case::Case;
use rustc_ast::{self as ast};
use rustc_ast_pretty::pprust;
use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, Applicability, PResult, StashKey};
use rustc_errors::{Applicability, PResult, StashKey, struct_span_code_err};
use rustc_span::edit_distance::edit_distance;
use rustc_span::edition::Edition;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{source_map, ErrorGuaranteed, Span, DUMMY_SP};
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, source_map};
use thin_vec::{ThinVec, thin_vec};
use tracing::debug;
use super::diagnostics::{dummy_arg, ConsumeClosingDelim};
use super::diagnostics::{ConsumeClosingDelim, dummy_arg};
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
use super::{
AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Trailing, UsePreAttrPos,
@ -1897,10 +1897,10 @@ impl<'a> Parser<'a> {
// Try to recover extra trailing angle brackets
if let TyKind::Path(_, Path { segments, .. }) = &a_var.ty.kind {
if let Some(last_segment) = segments.last() {
let guar = self.check_trailing_angle_brackets(
last_segment,
&[&token::Comma, &token::CloseDelim(Delimiter::Brace)],
);
let guar = self.check_trailing_angle_brackets(last_segment, &[
&token::Comma,
&token::CloseDelim(Delimiter::Brace),
]);
if let Some(_guar) = guar {
// Handle a case like `Vec<u8>>,` where we can continue parsing fields
// after the comma

View file

@ -27,9 +27,9 @@ use rustc_ast::tokenstream::{
};
use rustc_ast::util::case::Case;
use rustc_ast::{
self as ast, AnonConst, AttrArgs, AttrArgsEq, AttrId, ByRef, Const, CoroutineKind, DelimArgs,
Expr, ExprKind, Extern, HasAttrs, HasTokens, Mutability, Recovered, Safety, StrLit, Visibility,
VisibilityKind, DUMMY_NODE_ID,
self as ast, AnonConst, AttrArgs, AttrArgsEq, AttrId, ByRef, Const, CoroutineKind,
DUMMY_NODE_ID, DelimArgs, Expr, ExprKind, Extern, HasAttrs, HasTokens, Mutability, Recovered,
Safety, StrLit, Visibility, VisibilityKind,
};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
@ -37,8 +37,8 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, Diag, FatalError, MultiSpan, PResult};
use rustc_index::interval::IntervalSet;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Span};
use thin_vec::ThinVec;
use tracing::debug;

View file

@ -1,13 +1,13 @@
use rustc_ast::HasTokens;
use rustc_ast::ptr::P;
use rustc_ast::token::Nonterminal::*;
use rustc_ast::token::NtExprKind::*;
use rustc_ast::token::NtPatKind::*;
use rustc_ast::token::{self, Delimiter, NonterminalKind, Token};
use rustc_ast::HasTokens;
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::PResult;
use rustc_span::symbol::{kw, Ident};
use rustc_span::symbol::{Ident, kw};
use crate::errors::UnexpectedNonterminal;
use crate::parser::pat::{CommaRecoveryMode, RecoverColon, RecoverComma};

View file

@ -10,10 +10,10 @@ use rustc_ast::{
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagArgValue, PResult, StashKey};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::source_map::{Spanned, respan};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Span};
use thin_vec::{thin_vec, ThinVec};
use thin_vec::{ThinVec, thin_vec};
use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing, UsePreAttrPos};
use crate::errors::{
@ -27,7 +27,7 @@ use crate::errors::{
UnexpectedLifetimeInPattern, UnexpectedParenInRangePat, UnexpectedParenInRangePatSugg,
UnexpectedVertVertBeforeFunctionParam, UnexpectedVertVertInPattern, WrapInParens,
};
use crate::parser::expr::{could_be_unclosed_char_literal, DestructuredFloat};
use crate::parser::expr::{DestructuredFloat, could_be_unclosed_char_literal};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
#[derive(PartialEq, Copy, Clone)]

View file

@ -9,7 +9,7 @@ use rustc_ast::{
Path, PathSegment, QSelf,
};
use rustc_errors::{Applicability, Diag, PResult};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, Span};
use thin_vec::ThinVec;
use tracing::debug;
@ -107,10 +107,11 @@ impl<'a> Parser<'a> {
self.parse_path_segments(&mut path.segments, style, None)?;
}
Ok((
qself,
Path { segments: path.segments, span: lo.to(self.prev_token.span), tokens: None },
))
Ok((qself, Path {
segments: path.segments,
span: lo.to(self.prev_token.span),
tokens: None,
}))
}
/// Recover from an invalid single colon, when the user likely meant a qualified path.
@ -487,16 +488,13 @@ impl<'a> Parser<'a> {
error.span_suggestion_verbose(
prev_token_before_parsing.span,
format!(
"consider removing the `::` here to {}",
match style {
PathStyle::Expr => "call the expression",
PathStyle::Pat => "turn this into a tuple struct pattern",
_ => {
return;
}
format!("consider removing the `::` here to {}", match style {
PathStyle::Expr => "call the expression",
PathStyle::Pat => "turn this into a tuple struct pattern",
_ => {
return;
}
),
}),
"",
Applicability::MaybeIncorrect,
);

View file

@ -7,13 +7,13 @@ use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, TokenKind};
use rustc_ast::util::classify::{self, TrailingBrace};
use rustc_ast::{
AttrStyle, AttrVec, Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, LocalKind, MacCall,
MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind, DUMMY_NODE_ID,
AttrStyle, AttrVec, Block, BlockCheckMode, DUMMY_NODE_ID, Expr, ExprKind, HasAttrs, Local,
LocalKind, MacCall, MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind,
};
use rustc_errors::{Applicability, Diag, PResult};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Span};
use thin_vec::{thin_vec, ThinVec};
use thin_vec::{ThinVec, thin_vec};
use super::attr::InnerAttrForbiddenReason;
use super::diagnostics::AttemptLocalParseRecovery;
@ -417,20 +417,14 @@ impl<'a> Parser<'a> {
fn check_let_else_init_trailing_brace(&self, init: &ast::Expr) {
if let Some(trailing) = classify::expr_trailing_brace(init) {
let (span, sugg) = match trailing {
TrailingBrace::MacCall(mac) => (
mac.span(),
errors::WrapInParentheses::MacroArgs {
left: mac.args.dspan.open,
right: mac.args.dspan.close,
},
),
TrailingBrace::Expr(expr) => (
expr.span,
errors::WrapInParentheses::Expression {
left: expr.span.shrink_to_lo(),
right: expr.span.shrink_to_hi(),
},
),
TrailingBrace::MacCall(mac) => (mac.span(), errors::WrapInParentheses::MacroArgs {
left: mac.args.dspan.open,
right: mac.args.dspan.close,
}),
TrailingBrace::Expr(expr) => (expr.span, errors::WrapInParentheses::Expression {
left: expr.span.shrink_to_lo(),
right: expr.span.shrink_to_hi(),
}),
};
self.dcx().emit_err(errors::InvalidCurlyInLetElse {
span: span.with_lo(span.hi() - BytePos(1)),

View file

@ -9,15 +9,15 @@ use ast::token::IdentIsRaw;
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, Token};
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
use rustc_ast::{self as ast, visit, PatKind};
use rustc_ast::{self as ast, PatKind, visit};
use rustc_ast_pretty::pprust::item_to_string;
use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::HumanEmitter;
use rustc_errors::{DiagCtxt, MultiSpan, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{create_default_session_globals_then, BytePos, FileName, Pos, Span};
use rustc_span::symbol::{Symbol, kw, sym};
use rustc_span::{BytePos, FileName, Pos, Span, create_default_session_globals_then};
use termcolor::WriteColor;
use crate::parser::{ForceCollect, Parser};

View file

@ -1,6 +1,6 @@
use rustc_ast::token::{self, IdentIsRaw};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_span::{create_default_session_globals_then, BytePos, Span, Symbol};
use rustc_span::{BytePos, Span, Symbol, create_default_session_globals_then};
use crate::parser::tests::string_to_stream;

View file

@ -2,14 +2,14 @@ use rustc_ast::ptr::P;
use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw, Token, TokenKind};
use rustc_ast::util::case::Case;
use rustc_ast::{
self as ast, BareFnTy, BoundAsyncness, BoundConstness, BoundPolarity, FnRetTy, GenericBound,
GenericBounds, GenericParam, Generics, Lifetime, MacCall, MutTy, Mutability, PolyTraitRef,
PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty, TyKind, DUMMY_NODE_ID,
self as ast, BareFnTy, BoundAsyncness, BoundConstness, BoundPolarity, DUMMY_NODE_ID, FnRetTy,
GenericBound, GenericBounds, GenericParam, Generics, Lifetime, MacCall, MutTy, Mutability,
PolyTraitRef, PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty, TyKind,
};
use rustc_errors::{Applicability, PResult};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{ErrorGuaranteed, Span, Symbol};
use thin_vec::{thin_vec, ThinVec};
use thin_vec::{ThinVec, thin_vec};
use super::{Parser, PathStyle, SeqSep, TokenType, Trailing};
use crate::errors::{

View file

@ -7,12 +7,12 @@ use rustc_ast::{
NestedMetaItem, Safety,
};
use rustc_errors::{Applicability, FatalError, PResult};
use rustc_feature::{AttributeSafety, AttributeTemplate, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
use rustc_feature::{AttributeSafety, AttributeTemplate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute};
use rustc_session::errors::report_lit_error;
use rustc_session::lint::builtin::{ILL_FORMED_ATTRIBUTE_INPUT, UNSAFE_ATTR_OUTSIDE_UNSAFE};
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::{ILL_FORMED_ATTRIBUTE_INPUT, UNSAFE_ATTR_OUTSIDE_UNSAFE};
use rustc_session::parse::ParseSess;
use rustc_span::{sym, BytePos, Span, Symbol};
use rustc_span::{BytePos, Span, Symbol, sym};
use crate::{errors, parse_in};