Skip to content

Commit 51dcf42

Browse files
committed
--wip-- [skip ci]
1 parent c10e769 commit 51dcf42

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

compiler/rustc_parse/src/errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ pub(crate) struct SuggMisplacedGeneric {
890890
pub span: Span,
891891
}
892892

893-
894893
#[derive(Subdiagnostic)]
895894
pub(crate) enum ExpectedIdentifierFound {
896895
#[label(parser_expected_identifier_found_reserved_identifier)]

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use crate::errors::{
1212
IncorrectAwait, IncorrectSemicolon, IncorrectUseOfAwait, ParenthesesInForHead,
1313
ParenthesesInForHeadSugg, PatternMethodParamWithoutBody, QuestionMarkInType,
1414
QuestionMarkInTypeSugg, SelfParamNotFirst, StructLiteralBodyWithoutPath,
15-
StructLiteralBodyWithoutPathSugg, SuggEscapeToUseAsIdentifier, SuggRemoveComma,
16-
UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
17-
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, SuggMisplacedGeneric,
15+
StructLiteralBodyWithoutPathSugg, SuggEscapeToUseAsIdentifier, SuggMisplacedGeneric,
16+
SuggRemoveComma, UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
17+
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead,
1818
};
1919

2020
use crate::lexer::UnmatchedBrace;
@@ -328,35 +328,22 @@ impl<'a> Parser<'a> {
328328

329329
let span = self.token.span;
330330
let token = self.token.clone();
331-
let suggest_misplaced_generic =
332-
if self.token == token::Lt {
333-
// store the span before the generic calculation starts
334-
if self.parse_generics().is_ok() {
335-
// FIXME: need the span of the whole generic.
336-
Some(
337-
SuggMisplacedGeneric {
338-
span: span.until(self.token.span)
339-
}
340-
)
341-
} else {
342-
None
343-
}
331+
let suggest_misplaced_generic = if self.token == token::Lt {
332+
// store the span before the generic calculation starts
333+
if self.parse_generics().is_ok() {
334+
// FIXME: need the span of the whole generic.
335+
Some(SuggMisplacedGeneric { span: span.until(self.token.span) })
344336
} else {
345337
None
346-
};
338+
}
339+
} else {
340+
None
341+
};
347342

348343
// FIXME: write better rust
349344
let err = ExpectedIdentifier {
350-
span: if suggest_misplaced_generic.is_some() {
351-
span
352-
} else {
353-
self.token.span
354-
},
355-
token: if suggest_misplaced_generic.is_some() {
356-
token
357-
} else {
358-
self.token.clone()
359-
},
345+
span: if suggest_misplaced_generic.is_some() { span } else { self.token.span },
346+
token: if suggest_misplaced_generic.is_some() { token } else { self.token.clone() },
360347
suggest_raw,
361348
suggest_remove_comma,
362349
suggest_misplaced_generic,

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,10 @@ impl<'a> Parser<'a> {
540540
self.parse_ident_common(true)
541541
}
542542

543-
fn ident_or_err(&mut self) -> PResult<'a, (Ident, /* is_raw */ bool)> {
543+
fn ident_or_err(&mut self) -> PResult<'a, (Ident, /* is_raw */ bool)> {
544544
debug!("fn ident_or_err");
545545
debug!(?self.token);
546-
debug!(prev = ?self.prev_token);
546+
debug!(prev = ?self.prev_token);
547547
self.token.ident().ok_or_else(|| match self.prev_token.kind {
548548
TokenKind::DocComment(..) => DocCommentDoesNotDocumentAnything {
549549
span: self.prev_token.span,
@@ -553,7 +553,7 @@ impl<'a> Parser<'a> {
553553
_ => self.expected_ident_found(),
554554
})
555555
}
556-
556+
557557
// SHREYS - exits after ident_or_err()?
558558
fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> {
559559
let (ident, is_raw) = self.ident_or_err()?;

0 commit comments

Comments
 (0)