From 24cbf81b8546beb8193217316acf4ded4117b4af Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 10 Apr 2023 22:16:17 +0000 Subject: [PATCH] Remove `..` from return type notation --- compiler/rustc_ast/src/ast.rs | 4 --- compiler/rustc_ast/src/mut_visit.rs | 1 - compiler/rustc_ast/src/visit.rs | 1 - compiler/rustc_ast_lowering/src/errors.rs | 8 +----- compiler/rustc_ast_lowering/src/lib.rs | 27 +++++++++++-------- compiler/rustc_ast_lowering/src/path.rs | 13 --------- .../rustc_ast_passes/src/ast_validation.rs | 2 -- compiler/rustc_ast_passes/src/feature_gate.rs | 19 +++++++------ compiler/rustc_ast_pretty/src/pprust/state.rs | 4 --- compiler/rustc_parse/messages.ftl | 4 +++ compiler/rustc_parse/src/errors.rs | 8 ++++++ compiler/rustc_parse/src/parser/path.rs | 25 ++++++++++------- compiler/rustc_passes/src/hir_stats.rs | 2 +- compiler/rustc_resolve/src/late.rs | 1 - compiler/rustc_resolve/src/lib.rs | 1 - .../bad-inputs-and-output.rs | 8 +++--- .../bad-inputs-and-output.stderr | 24 ++++++++--------- .../return-type-notation/basic.rs | 2 +- .../return-type-notation/equality.rs | 2 +- .../return-type-notation/equality.stderr | 4 +-- .../return-type-notation/missing.rs | 2 +- .../return-type-notation/missing.stderr | 4 +-- .../return-type-notation/non-rpitit.rs | 2 +- .../return-type-notation/non-rpitit.stderr | 4 +-- ...ature-gate-return_type_notation.cfg.stderr | 27 ++++++++++++++----- ...eature-gate-return_type_notation.no.stderr | 25 ++++++++--------- .../feature-gate-return_type_notation.rs | 11 ++++++-- 27 files changed, 126 insertions(+), 109 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index fb9d71b52a8..df1a716755b 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -167,9 +167,6 @@ pub enum GenericArgs { AngleBracketed(AngleBracketedArgs), /// The `(A, B)` and `C` in `Foo(A, B) -> C`. Parenthesized(ParenthesizedArgs), - /// Associated return type bounds, like `T: Trait` - /// which applies the `Send` bound to the return-type of `method`. - ReturnTypeNotation(Span), } impl GenericArgs { @@ -181,7 +178,6 @@ pub fn span(&self) -> Span { match self { AngleBracketed(data) => data.span, Parenthesized(data) => data.span, - ReturnTypeNotation(span) => *span, } } } diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 2424073ae53..694d31d8f1f 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -561,7 +561,6 @@ pub fn noop_visit_generic_args(generic_args: &mut GenericArgs, vi match generic_args { GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data), GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data), - GenericArgs::ReturnTypeNotation(_span) => {} } } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 3b08467fde2..ac9b321b71c 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -482,7 +482,6 @@ pub fn walk_generic_args<'a, V>(visitor: &mut V, generic_args: &'a GenericArgs) walk_list!(visitor, visit_ty, &data.inputs); walk_fn_ret_ty(visitor, &data.output); } - GenericArgs::ReturnTypeNotation(_span) => {} } } diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index f4e55619ebb..4eefd951b24 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -353,13 +353,7 @@ pub enum BadReturnTypeNotation { #[diag(ast_lowering_bad_return_type_notation_inputs)] Inputs { #[primary_span] - #[suggestion(code = "(..)", applicability = "maybe-incorrect")] - span: Span, - }, - #[diag(ast_lowering_bad_return_type_notation_needs_dots)] - NeedsDots { - #[primary_span] - #[suggestion(code = "(..)", applicability = "maybe-incorrect")] + #[suggestion(code = "()", applicability = "maybe-incorrect")] span: Span, }, #[diag(ast_lowering_bad_return_type_notation_output)] diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index ca659db4dbe..f7ae96b7c4a 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -987,15 +987,22 @@ fn lower_assoc_ty_constraint( GenericArgs::AngleBracketed(data) => { self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0 } - &GenericArgs::ReturnTypeNotation(span) => GenericArgsCtor { - args: Default::default(), - bindings: &[], - parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation, - span, - }, GenericArgs::Parenthesized(data) => { - if let Some(start_char) = constraint.ident.as_str().chars().next() - && start_char.is_ascii_lowercase() + if data.inputs.is_empty() && matches!(data.output, FnRetTy::Default(..)) { + let parenthesized = if self.tcx.features().return_type_notation { + hir::GenericArgsParentheses::ReturnTypeNotation + } else { + self.emit_bad_parenthesized_trait_in_assoc_ty(data); + hir::GenericArgsParentheses::No + }; + GenericArgsCtor { + args: Default::default(), + bindings: &[], + parenthesized, + span: data.inputs_span, + } + } else if let Some(first_char) = constraint.ident.as_str().chars().next() + && first_char.is_ascii_lowercase() { let mut err = if !data.inputs.is_empty() { self.tcx.sess.create_err(errors::BadReturnTypeNotation::Inputs { @@ -1006,9 +1013,7 @@ fn lower_assoc_ty_constraint( span: data.inputs_span.shrink_to_hi().to(ty.span), }) } else { - self.tcx.sess.create_err(errors::BadReturnTypeNotation::NeedsDots { - span: data.inputs_span, - }) + unreachable!("inputs are empty and return type is not provided") }; if !self.tcx.features().return_type_notation && self.tcx.sess.is_nightly_build() diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 1c47a969696..8eb84c036a0 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -13,7 +13,6 @@ use rustc_span::{BytePos, Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; -use thin_vec::ThinVec; impl<'a, 'hir> LoweringContext<'a, 'hir> { #[instrument(level = "trace", skip(self))] @@ -219,18 +218,6 @@ pub(crate) fn lower_path_segment( ) } }, - &GenericArgs::ReturnTypeNotation(span) => { - self.tcx.sess.emit_err(GenericTypeWithParentheses { span, sub: None }); - ( - self.lower_angle_bracketed_parameter_data( - &AngleBracketedArgs { span, args: ThinVec::default() }, - param_mode, - itctx, - ) - .0, - false, - ) - } } } else { ( diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 1389acabfcb..c243afdb897 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -1075,7 +1075,6 @@ fn visit_generic_args(&mut self, generic_args: &'a GenericArgs) { self.with_impl_trait(None, |this| this.visit_ty(ty)); } } - GenericArgs::ReturnTypeNotation(_span) => {} } } @@ -1386,7 +1385,6 @@ fn deny_equality_constraints( match &mut assoc_path.segments[len].args { Some(args) => match args.deref_mut() { GenericArgs::Parenthesized(_) => continue, - GenericArgs::ReturnTypeNotation(_span) => continue, GenericArgs::AngleBracketed(args) => { args.args.push(arg); } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 007d64f681f..66d82a26c37 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -485,20 +485,23 @@ fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { fn visit_assoc_constraint(&mut self, constraint: &'a AssocConstraint) { if let AssocConstraintKind::Bound { .. } = constraint.kind { - if let Some(args) = constraint.gen_args.as_ref() - && matches!( - args, - ast::GenericArgs::ReturnTypeNotation(..) - ) + if let Some(ast::GenericArgs::Parenthesized(args)) = constraint.gen_args.as_ref() + && args.inputs.is_empty() + && matches!(args.output, ast::FnRetTy::Default(..)) { - // RTN is gated below with a `gate_all`. + gate_feature_post!( + &self, + return_type_notation, + constraint.span, + "return type notation is experimental" + ); } else { gate_feature_post!( &self, associated_type_bounds, constraint.span, "associated type bounds are unstable" - ) + ); } } visit::walk_assoc_constraint(self, constraint) @@ -589,7 +592,6 @@ macro_rules! gate_all { gate_all!(yeet_expr, "`do yeet` expression is experimental"); gate_all!(dyn_star, "`dyn*` trait objects are experimental"); gate_all!(const_closures, "const closures are experimental"); - gate_all!(return_type_notation, "return type notation is experimental"); // All uses of `gate_all!` below this point were added in #65742, // and subsequently disabled (with the non-early gating readded). @@ -605,6 +607,7 @@ macro_rules! gate_all { gate_all!(trait_alias, "trait aliases are experimental"); gate_all!(associated_type_bounds, "associated type bounds are unstable"); + gate_all!(return_type_notation, "return type notation is experimental"); gate_all!(decl_macro, "`macro` is experimental"); gate_all!(box_patterns, "box pattern syntax is experimental"); gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental"); diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 1f6838a0278..849336c8669 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -936,10 +936,6 @@ fn print_generic_args(&mut self, args: &ast::GenericArgs, colons_before_params: self.word(")"); self.print_fn_ret_ty(&data.output); } - - ast::GenericArgs::ReturnTypeNotation(_span) => { - self.word("(..)"); - } } } } diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index e21bbd0217b..f11d0ed0f01 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -738,3 +738,7 @@ parse_box_syntax_removed = `box_syntax` has been removed parse_bad_return_type_notation_output = return type not allowed with return type notation .suggestion = remove the return type + +parse_bad_return_type_notation_dotdot = + return type notation uses `()` instead of `(..)` for elided arguments + .suggestion = remove the `..` diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index aead216b61c..069217165fa 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2324,3 +2324,11 @@ pub(crate) struct BadReturnTypeNotationOutput { #[suggestion(code = "", applicability = "maybe-incorrect")] 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, +} diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index f1c9f0109f8..c25c23d849f 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -290,16 +290,17 @@ pub(super) fn parse_path_segment( })?; let span = lo.to(self.prev_token.span); AngleBracketedArgs { args, span }.into() - } else if self.token.kind == token::OpenDelim(Delimiter::Parenthesis) + } else if self.may_recover() + && self.token.kind == token::OpenDelim(Delimiter::Parenthesis) // FIXME(return_type_notation): Could also recover `...` here. && self.look_ahead(1, |tok| tok.kind == token::DotDot) { - let lo = self.token.span; self.bump(); + self.sess + .emit_err(errors::BadReturnTypeNotationDotDot { span: self.token.span }); self.bump(); self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; let span = lo.to(self.prev_token.span); - self.sess.gated_spans.gate(sym::return_type_notation, span); if self.eat_noexpect(&token::RArrow) { let lo = self.prev_token.span; @@ -308,7 +309,13 @@ pub(super) fn parse_path_segment( .emit_err(errors::BadReturnTypeNotationOutput { span: lo.to(ty.span) }); } - P(GenericArgs::ReturnTypeNotation(span)) + ParenthesizedArgs { + span, + inputs: ThinVec::new(), + inputs_span: span, + output: ast::FnRetTy::Default(self.prev_token.span.shrink_to_hi()), + } + .into() } else { // `(T, U) -> R` let (inputs, _) = self.parse_paren_comma_seq(|p| p.parse_ty())?; @@ -566,13 +573,13 @@ fn parse_angle_arg( }; let span = lo.to(self.prev_token.span); - // Gate associated type bounds, e.g., `Iterator`. if let AssocConstraintKind::Bound { .. } = kind { - if gen_args.as_ref().map_or(false, |args| { - matches!(args, GenericArgs::ReturnTypeNotation(..)) - }) { - // This is already gated in `parse_path_segment` + if let Some(ast::GenericArgs::Parenthesized(args)) = &gen_args + && args.inputs.is_empty() + && matches!(args.output, ast::FnRetTy::Default(..)) + { + self.sess.gated_spans.gate(sym::return_type_notation, span); } else { self.sess.gated_spans.gate(sym::associated_type_bounds, span); } diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index ce44f709f3b..47e032758f2 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -666,7 +666,7 @@ fn visit_path_segment(&mut self, path_segment: &'v ast::PathSegment) { fn visit_generic_args(&mut self, g: &'v ast::GenericArgs) { record_variants!( (self, g, g, Id::None, ast, GenericArgs, GenericArgs), - [AngleBracketed, Parenthesized, ReturnTypeNotation] + [AngleBracketed, Parenthesized] ); ast_visit::walk_generic_args(self, g) } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 31ac3f1c151..07b14eaf1b3 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1116,7 +1116,6 @@ fn visit_path_segment(&mut self, path_segment: &'ast PathSegment) { } } } - GenericArgs::ReturnTypeNotation(_span) => {} } } } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 99fad22d4a1..0e84432a5b4 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -312,7 +312,6 @@ fn from(seg: &'a ast::PathSegment) -> Segment { (args.span, found_lifetimes) } GenericArgs::Parenthesized(args) => (args.span, true), - GenericArgs::ReturnTypeNotation(span) => (*span, false), } } else { (DUMMY_SP, false) diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 2f9a1d1c76e..79cee55177b 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -12,11 +12,11 @@ fn foo>() {} //~^ ERROR argument types not allowed with return type notation //~| ERROR associated type bounds are unstable -fn bar (): Send>>() {} +fn bar (): Send>>() {} //~^ ERROR return type not allowed with return type notation - -fn baz>() {} -//~^ ERROR return type notation arguments must be elided with `..` //~| ERROR associated type bounds are unstable +fn baz>() {} +//~^ ERROR return type notation uses `()` instead of `(..)` for elided arguments + fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr index b354a6805d6..b23e0f791ea 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -1,8 +1,8 @@ -error: return type not allowed with return type notation - --> $DIR/bad-inputs-and-output.rs:15:28 +error: return type notation uses `()` instead of `(..)` for elided arguments + --> $DIR/bad-inputs-and-output.rs:19:24 | -LL | fn bar (): Send>>() {} - | ^^^^^ help: remove the return type +LL | fn baz>() {} + | ^^ help: remove the `..` error[E0658]: associated type bounds are unstable --> $DIR/bad-inputs-and-output.rs:11:17 @@ -14,10 +14,10 @@ LL | fn foo>() {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/bad-inputs-and-output.rs:18:17 + --> $DIR/bad-inputs-and-output.rs:15:17 | -LL | fn baz>() {} - | ^^^^^^^^^^^^^^ +LL | fn bar (): Send>>() {} + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #52662 for more information = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable @@ -43,13 +43,13 @@ error: argument types not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:11:23 | LL | fn foo>() {} - | ^^^^^ help: remove the input types: `(..)` + | ^^^^^ help: remove the input types: `()` -error: return type notation arguments must be elided with `..` - --> $DIR/bad-inputs-and-output.rs:18:23 +error: return type not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:15:25 | -LL | fn baz>() {} - | ^^ help: add `..`: `(..)` +LL | fn bar (): Send>>() {} + | ^^^^^^ help: remove the return type error: aborting due to 5 previous errors; 2 warnings emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs index 75d1dc745d1..0b7530b65d7 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -18,7 +18,7 @@ async fn foo() -> Result<(), ()> { fn is_send(_: impl Send) {} fn test< - #[cfg(with)] T: Foo, + #[cfg(with)] T: Foo, #[cfg(without)] T: Foo, >() { is_send(foo::()); diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs index c8fc980974e..75f757e9025 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -10,7 +10,7 @@ trait Trait { async fn method() {} } -fn test>>>() {} +fn test>>>() {} //~^ ERROR return type notation is not allowed to use type equality fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr index cd50ff38694..c5b2e5710d4 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -18,8 +18,8 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] error: return type notation is not allowed to use type equality --> $DIR/equality.rs:13:18 | -LL | fn test>>>() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn test>>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error; 2 warnings emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs index 1263cae4477..7b98a5cdafd 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs @@ -8,7 +8,7 @@ trait Trait { async fn method() {} } -fn bar>() {} +fn bar>() {} //~^ ERROR cannot find associated function `methid` in trait `Trait` fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr index 93111b5c36b..34f5bda884d 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr @@ -18,8 +18,8 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] error: cannot find associated function `methid` in trait `Trait` --> $DIR/missing.rs:11:17 | -LL | fn bar>() {} - | ^^^^^^^^^^^^^^^^ +LL | fn bar>() {} + | ^^^^^^^^^^^^^^ error: aborting due to previous error; 2 warnings emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs index d283c6eab37..db5f6fe389e 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs @@ -5,7 +5,7 @@ trait Trait { fn method() {} } -fn test>() {} +fn test>() {} //~^ ERROR return type notation used on function that is not `async` and does not return `impl Trait` fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr index 38c498bc2fb..31b793995f8 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr @@ -13,8 +13,8 @@ error: return type notation used on function that is not `async` and does not re LL | fn method() {} | ----------- this function must be `async` or return `impl Trait` ... -LL | fn test>() {} - | ^^^^^^^^^^^^^^^^ +LL | fn test>() {} + | ^^^^^^^^^^^^^^ | = note: function returns `()`, which is not compatible with associated type return bounds diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr index 85728f8e1ad..c3a371e25e8 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr @@ -1,14 +1,14 @@ error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:12:18 + --> $DIR/feature-gate-return_type_notation.rs:15:17 | -LL | fn foo>() {} - | ^^^^ +LL | fn foo>() {} + | ^^^^^^^^^ | = note: see issue #109417 for more information = help: add `#![feature(return_type_notation)]` to the crate attributes to enable warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/feature-gate-return_type_notation.rs:4:12 + --> $DIR/feature-gate-return_type_notation.rs:7:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -16,6 +16,21 @@ LL | #![feature(async_fn_in_trait)] = note: see issue #91611 for more information = note: `#[warn(incomplete_features)]` on by default -error: aborting due to previous error; 1 warning emitted +error: parenthesized generic arguments cannot be used in associated type constraints + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo>() {} + | ^-- + | | + | help: remove these parentheses -For more information about this error, try `rustc --explain E0658`. +error[E0220]: associated type `m` not found for `Trait` + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo>() {} + | ^ associated type `m` not found + +error: aborting due to 3 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0220, E0658. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr index 85728f8e1ad..52c90c1565c 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr @@ -1,14 +1,5 @@ -error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:12:18 - | -LL | fn foo>() {} - | ^^^^ - | - = note: see issue #109417 for more information - = help: add `#![feature(return_type_notation)]` to the crate attributes to enable - warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/feature-gate-return_type_notation.rs:4:12 + --> $DIR/feature-gate-return_type_notation.rs:7:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -16,6 +7,16 @@ LL | #![feature(async_fn_in_trait)] = note: see issue #91611 for more information = note: `#[warn(incomplete_features)]` on by default -error: aborting due to previous error; 1 warning emitted +warning: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 + +warning: 2 warnings emitted -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs index b75feb130a6..5028b9ec9e3 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -1,6 +1,9 @@ // edition: 2021 // revisions: cfg no +//[no] check-pass +// Since we're not adding new syntax, `cfg`'d out RTN must pass. + #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete @@ -9,7 +12,11 @@ trait Trait { } #[cfg(cfg)] -fn foo>() {} -//~^ ERROR return type notation is experimental +fn foo>() {} +//[cfg]~^ ERROR return type notation is experimental +//[cfg]~| ERROR parenthesized generic arguments cannot be used in associated type constraints +//[cfg]~| ERROR associated type `m` not found for `Trait` +//[no]~^^^^ WARN return type notation is experimental +//[no]~| WARN unstable syntax can change at any point in the future, causing a hard error! fn main() {}