Rollup merge of #127092 - compiler-errors:rtn-dots-redux, r=estebank
Change return-type-notation to use `(..)` Aligns the syntax with the current wording of [RFC 3654](https://github.com/rust-lang/rfcs/pull/3654). Also implements rustfmt support (along with making a match exhaustive). Tracking: * https://github.com/rust-lang/rust/issues/109417
This commit is contained in:
commit
33e9f25e91
51 changed files with 248 additions and 179 deletions
|
@ -2567,14 +2567,6 @@ pub(crate) struct BadReturnTypeNotationOutput {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_bad_return_type_notation_dotdot)]
|
||||
pub(crate) struct BadReturnTypeNotationDotDot {
|
||||
#[primary_span]
|
||||
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_bad_assoc_type_bounds)]
|
||||
pub(crate) struct BadAssocTypeBounds {
|
||||
|
|
|
@ -353,18 +353,17 @@ impl<'a> Parser<'a> {
|
|||
})?;
|
||||
let span = lo.to(self.prev_token.span);
|
||||
AngleBracketedArgs { args, span }.into()
|
||||
} else if self.may_recover()
|
||||
&& self.token.kind == token::OpenDelim(Delimiter::Parenthesis)
|
||||
} else if self.token.kind == token::OpenDelim(Delimiter::Parenthesis)
|
||||
// FIXME(return_type_notation): Could also recover `...` here.
|
||||
&& self.look_ahead(1, |tok| tok.kind == token::DotDot)
|
||||
{
|
||||
self.bump();
|
||||
self.dcx()
|
||||
.emit_err(errors::BadReturnTypeNotationDotDot { span: self.token.span });
|
||||
self.bump();
|
||||
self.bump(); // (
|
||||
self.bump(); // ..
|
||||
self.expect(&token::CloseDelim(Delimiter::Parenthesis))?;
|
||||
let span = lo.to(self.prev_token.span);
|
||||
|
||||
self.psess.gated_spans.gate(sym::return_type_notation, span);
|
||||
|
||||
if self.eat_noexpect(&token::RArrow) {
|
||||
let lo = self.prev_token.span;
|
||||
let ty = self.parse_ty()?;
|
||||
|
@ -372,13 +371,7 @@ impl<'a> Parser<'a> {
|
|||
.emit_err(errors::BadReturnTypeNotationOutput { span: lo.to(ty.span) });
|
||||
}
|
||||
|
||||
ParenthesizedArgs {
|
||||
span,
|
||||
inputs: ThinVec::new(),
|
||||
inputs_span: span,
|
||||
output: ast::FnRetTy::Default(self.prev_token.span.shrink_to_hi()),
|
||||
}
|
||||
.into()
|
||||
P(ast::GenericArgs::ParenthesizedElided(span))
|
||||
} else {
|
||||
// `(T, U) -> R`
|
||||
|
||||
|
@ -733,14 +726,6 @@ impl<'a> Parser<'a> {
|
|||
|
||||
let span = lo.to(self.prev_token.span);
|
||||
|
||||
if let AssocItemConstraintKind::Bound { .. } = kind
|
||||
&& let Some(ast::GenericArgs::Parenthesized(args)) = &gen_args
|
||||
&& args.inputs.is_empty()
|
||||
&& let ast::FnRetTy::Default(..) = args.output
|
||||
{
|
||||
self.psess.gated_spans.gate(sym::return_type_notation, span);
|
||||
}
|
||||
|
||||
let constraint =
|
||||
AssocItemConstraint { id: ast::DUMMY_NODE_ID, ident, gen_args, kind, span };
|
||||
Ok(Some(AngleBracketedArg::Constraint(constraint)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue