Fix ICE in diagnostics for parenthesized type arguments
This commit is contained in:
parent
7de1a1f6db
commit
eab1f30c29
3 changed files with 54 additions and 21 deletions
|
@ -449,9 +449,13 @@ impl<'a> Parser<'a> {
|
||||||
prev_token_before_parsing: Token,
|
prev_token_before_parsing: Token,
|
||||||
error: &mut Diag<'_>,
|
error: &mut Diag<'_>,
|
||||||
) {
|
) {
|
||||||
if ((style == PathStyle::Expr && self.parse_paren_comma_seq(|p| p.parse_expr()).is_ok())
|
match style {
|
||||||
|| (style == PathStyle::Pat
|
PathStyle::Expr
|
||||||
&& self
|
if let Ok(_) = self
|
||||||
|
.parse_paren_comma_seq(|p| p.parse_expr())
|
||||||
|
.map_err(|error| error.cancel()) => {}
|
||||||
|
PathStyle::Pat
|
||||||
|
if let Ok(_) = self
|
||||||
.parse_paren_comma_seq(|p| {
|
.parse_paren_comma_seq(|p| {
|
||||||
p.parse_pat_allow_top_alt(
|
p.parse_pat_allow_top_alt(
|
||||||
None,
|
None,
|
||||||
|
@ -460,9 +464,16 @@ impl<'a> Parser<'a> {
|
||||||
CommaRecoveryMode::LikelyTuple,
|
CommaRecoveryMode::LikelyTuple,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.is_ok()))
|
.map_err(|error| error.cancel()) => {}
|
||||||
&& !matches!(self.token.kind, token::ModSep | token::RArrow)
|
_ => {
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let token::ModSep | token::RArrow = self.token.kind {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
error.span_suggestion_verbose(
|
error.span_suggestion_verbose(
|
||||||
prev_token_before_parsing.span,
|
prev_token_before_parsing.span,
|
||||||
format!(
|
format!(
|
||||||
|
@ -479,7 +490,6 @@ impl<'a> Parser<'a> {
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Parses generic args (within a path segment) with recovery for extra leading angle brackets.
|
/// Parses generic args (within a path segment) with recovery for extra leading angle brackets.
|
||||||
/// For the purposes of understanding the parsing logic of generic arguments, this function
|
/// For the purposes of understanding the parsing logic of generic arguments, this function
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
fn main() {
|
||||||
|
unsafe {
|
||||||
|
dealloc(ptr2, Layout::(x: !)(1, 1)); //~ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:`
|
||||||
|
//~^ ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
|
||||||
|
//~| while parsing this parenthesized list of type arguments starting here
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:`
|
||||||
|
--> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:3:33
|
||||||
|
|
|
||||||
|
LL | dealloc(ptr2, Layout::(x: !)(1, 1));
|
||||||
|
| --- ^ expected one of 7 possible tokens
|
||||||
|
| |
|
||||||
|
| while parsing this parenthesized list of type arguments starting here
|
||||||
|
|
||||||
|
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
|
||||||
|
--> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:3:43
|
||||||
|
|
|
||||||
|
LL | dealloc(ptr2, Layout::(x: !)(1, 1));
|
||||||
|
| ^ expected one of `.`, `;`, `?`, `}`, or an operator
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue