Rollup merge of #127350 - veera-sivarajan:bugfix-126311, r=lcnr
Parser: Suggest Placing the Return Type After Function Parameters
Fixes #126311
This PR suggests placing the return type after the function parameters when it's misplaced after a `where` clause.
This also tangentially improves diagnostics for cases like [this](86d6f1312a/tests/ui/parser/issues/misplaced-return-type-without-where-issue-126311.rs (L1C1-L1C28)
) and adds doc comments for `parser::AllowPlus`.
This commit is contained in:
commit
c86e13f330
16 changed files with 215 additions and 39 deletions
|
@ -430,7 +430,7 @@ impl<'a> Parser<'a> {
|
|||
&mut self,
|
||||
edible: &[TokenKind],
|
||||
inedible: &[TokenKind],
|
||||
) -> PResult<'a, Recovered> {
|
||||
) -> PResult<'a, ErrorGuaranteed> {
|
||||
debug!("expected_one_of_not_found(edible: {:?}, inedible: {:?})", edible, inedible);
|
||||
fn tokens_to_string(tokens: &[TokenType]) -> String {
|
||||
let mut i = tokens.iter();
|
||||
|
@ -533,7 +533,7 @@ impl<'a> Parser<'a> {
|
|||
sugg: ExpectedSemiSugg::ChangeToSemi(self.token.span),
|
||||
});
|
||||
self.bump();
|
||||
return Ok(Recovered::Yes(guar));
|
||||
return Ok(guar);
|
||||
} else if self.look_ahead(0, |t| {
|
||||
t == &token::CloseDelim(Delimiter::Brace)
|
||||
|| ((t.can_begin_expr() || t.can_begin_item())
|
||||
|
@ -557,7 +557,7 @@ impl<'a> Parser<'a> {
|
|||
unexpected_token_label: Some(self.token.span),
|
||||
sugg: ExpectedSemiSugg::AddSemi(span),
|
||||
});
|
||||
return Ok(Recovered::Yes(guar));
|
||||
return Ok(guar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -712,7 +712,7 @@ impl<'a> Parser<'a> {
|
|||
if self.check_too_many_raw_str_terminators(&mut err) {
|
||||
if expected.contains(&TokenType::Token(token::Semi)) && self.eat(&token::Semi) {
|
||||
let guar = err.emit();
|
||||
return Ok(Recovered::Yes(guar));
|
||||
return Ok(guar);
|
||||
} else {
|
||||
return Err(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue