From 4745237f73253f342d99e9cdd91d198cfc8a0b95 Mon Sep 17 00:00:00 2001 From: York Xiang Date: Mon, 28 Nov 2022 16:30:43 +0800 Subject: [PATCH 1/4] Support `impl Trait` in where clause --- compiler/rustc_ast_lowering/src/item.rs | 7 ++-- src/test/ui/impl-trait/where-allowed.rs | 6 ++-- src/test/ui/impl-trait/where-allowed.stderr | 40 ++++++++------------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index a1941b5d8d370..3429a94028f07 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1504,12 +1504,9 @@ impl<'hir> LoweringContext<'_, 'hir> { hir_id: self.next_id(), bound_generic_params: self.lower_generic_params(bound_generic_params), bounded_ty: self - .lower_ty(bounded_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type)), + .lower_ty(bounded_ty, &ImplTraitContext::Universal), bounds: self.arena.alloc_from_iter(bounds.iter().map(|bound| { - self.lower_param_bound( - bound, - &ImplTraitContext::Disallowed(ImplTraitPosition::Bound), - ) + self.lower_param_bound(bound, &ImplTraitContext::Universal) })), span: self.lower_span(*span), origin: PredicateOrigin::WhereClause, diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index ff63b04c2680d..05320e7743ae7 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -185,17 +185,15 @@ fn in_fn_where_clause() { } -// Disallowed in where clauses +// Allowed fn in_adt_in_fn_where_clause() where Vec: Debug -//~^ ERROR `impl Trait` only allowed in function and inherent method return types { } -// Disallowed +// Allowed fn in_trait_parameter_in_fn_where_clause() where T: PartialEq -//~^ ERROR `impl Trait` only allowed in function and inherent method return types { } diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 3ad0a9f9d5c8b..8ac4dd6dc5571 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -211,80 +211,68 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t LL | where impl Debug: Debug | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:190:15 - | -LL | where Vec: Debug - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bound - --> $DIR/where-allowed.rs:197:24 - | -LL | where T: PartialEq - | ^^^^^^^^^^ - error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:204:17 + --> $DIR/where-allowed.rs:202:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:211:22 + --> $DIR/where-allowed.rs:209:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:217:40 + --> $DIR/where-allowed.rs:215:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:221:36 + --> $DIR/where-allowed.rs:219:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:225:38 + --> $DIR/where-allowed.rs:223:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:229:41 + --> $DIR/where-allowed.rs:227:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:233:11 + --> $DIR/where-allowed.rs:231:11 | LL | impl T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:240:40 + --> $DIR/where-allowed.rs:238:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding - --> $DIR/where-allowed.rs:246:29 + --> $DIR/where-allowed.rs:244:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return - --> $DIR/where-allowed.rs:248:46 + --> $DIR/where-allowed.rs:246:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:233:7 + --> $DIR/where-allowed.rs:231:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -294,7 +282,7 @@ LL | impl T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:240:36 + --> $DIR/where-allowed.rs:238:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -303,14 +291,14 @@ LL | fn in_method_generic_param_default(_: T) {} = note: for more information, see issue #36887 error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:233:23 + --> $DIR/where-allowed.rs:231:23 | LL | impl T {} | ^ impl requires a nominal type | = note: either implement a trait on it or create a newtype to wrap it instead -error: aborting due to 47 previous errors +error: aborting due to 46 previous errors Some errors have detailed explanations: E0118, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0118`. From baba116a3de6bcca71c34e22ce268428c5dacb09 Mon Sep 17 00:00:00 2001 From: York Xiang Date: Tue, 29 Nov 2022 13:58:18 +0800 Subject: [PATCH 2/4] Update outdated impl-trait error messages --- compiler/rustc_ast_lowering/src/item.rs | 11 +- .../locales/en-US/ast_lowering.ftl | 2 +- .../async-await/in-trait/fn-not-async-err2.rs | 2 +- .../in-trait/fn-not-async-err2.stderr | 2 +- .../feature-gate-associated_type_bounds.rs | 6 +- ...feature-gate-associated_type_bounds.stderr | 6 +- ...ture-gate-impl_trait_in_fn_trait_return.rs | 4 +- ...-gate-impl_trait_in_fn_trait_return.stderr | 4 +- ...ate-return_position_impl_trait_in_trait.rs | 6 +- ...return_position_impl_trait_in_trait.stderr | 6 +- src/test/ui/impl-trait/issues/issue-54600.rs | 2 +- .../ui/impl-trait/issues/issue-54600.stderr | 2 +- src/test/ui/impl-trait/issues/issue-54840.rs | 2 +- .../ui/impl-trait/issues/issue-54840.stderr | 2 +- src/test/ui/impl-trait/issues/issue-58504.rs | 2 +- .../ui/impl-trait/issues/issue-58504.stderr | 2 +- src/test/ui/impl-trait/issues/issue-58956.rs | 4 +- .../ui/impl-trait/issues/issue-58956.stderr | 4 +- src/test/ui/impl-trait/issues/issue-70971.rs | 2 +- .../ui/impl-trait/issues/issue-70971.stderr | 2 +- src/test/ui/impl-trait/issues/issue-79099.rs | 2 +- .../ui/impl-trait/issues/issue-79099.stderr | 2 +- ...sue-83929-impl-trait-in-generic-default.rs | 4 +- ...83929-impl-trait-in-generic-default.stderr | 4 +- src/test/ui/impl-trait/issues/issue-84919.rs | 2 +- .../ui/impl-trait/issues/issue-84919.stderr | 2 +- src/test/ui/impl-trait/issues/issue-86642.rs | 2 +- .../ui/impl-trait/issues/issue-86642.stderr | 2 +- src/test/ui/impl-trait/issues/issue-87295.rs | 2 +- .../ui/impl-trait/issues/issue-87295.stderr | 2 +- src/test/ui/impl-trait/nested_impl_trait.rs | 2 +- .../ui/impl-trait/nested_impl_trait.stderr | 2 +- src/test/ui/impl-trait/where-allowed.rs | 75 ++++++------- src/test/ui/impl-trait/where-allowed.stderr | 106 +++++++++--------- src/test/ui/issues/issue-47715.rs | 8 +- src/test/ui/issues/issue-47715.stderr | 8 +- .../type-alias-impl-trait-fn-type.rs | 2 +- .../type-alias-impl-trait-fn-type.stderr | 2 +- 38 files changed, 148 insertions(+), 154 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 3429a94028f07..741134a631944 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1503,11 +1503,12 @@ impl<'hir> LoweringContext<'_, 'hir> { }) => hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate { hir_id: self.next_id(), bound_generic_params: self.lower_generic_params(bound_generic_params), - bounded_ty: self - .lower_ty(bounded_ty, &ImplTraitContext::Universal), - bounds: self.arena.alloc_from_iter(bounds.iter().map(|bound| { - self.lower_param_bound(bound, &ImplTraitContext::Universal) - })), + bounded_ty: self.lower_ty(bounded_ty, &ImplTraitContext::Universal), + bounds: self.arena.alloc_from_iter( + bounds + .iter() + .map(|bound| self.lower_param_bound(bound, &ImplTraitContext::Universal)), + ), span: self.lower_span(*span), origin: PredicateOrigin::WhereClause, }), diff --git a/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl b/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl index 03c88c6c0ebe5..b6ae52642f371 100644 --- a/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl +++ b/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl @@ -17,7 +17,7 @@ ast_lowering_assoc_ty_parentheses = ast_lowering_remove_parentheses = remove these parentheses ast_lowering_misplaced_impl_trait = - `impl Trait` only allowed in function and inherent method return types, not in {$position} + `impl Trait` not allowed within {$position} ast_lowering_rustc_box_attribute_error = #[rustc_box] requires precisely one argument and no other attributes are allowed diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs b/src/test/ui/async-await/in-trait/fn-not-async-err2.rs index 594baa91ad8ba..6eda11b576f9b 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/src/test/ui/async-await/in-trait/fn-not-async-err2.rs @@ -11,7 +11,7 @@ trait MyTrait { impl MyTrait for i32 { fn foo(&self) -> impl Future { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return [E0562] + //~^ ERROR `impl Trait` not allowed within `impl` method return [E0562] async { *self } diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr b/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr index f591f18477290..f9b798aa96a1b 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr +++ b/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return +error[E0562]: `impl Trait` not allowed within `impl` method return --> $DIR/fn-not-async-err2.rs:13:22 | LL | fn foo(&self) -> impl Future { diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs index 4e020327447ff..518fe4202d23d 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -57,20 +57,20 @@ fn _rpit_dyn() -> Box> { Box::new(S1) } const _cdef: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` not allowed within type [E0562] // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // const _cdef_dyn: &dyn Tr1 = &S1; static _sdef: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` not allowed within type [E0562] // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // static _sdef_dyn: &dyn Tr1 = &S1; fn main() { let _: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable - //~| ERROR `impl Trait` only allowed in function and inherent method return types + //~| ERROR `impl Trait` not allowed within variable binding [E0562] // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // let _: &dyn Tr1 = &S1; } diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index 5be1d97a05985..7fb0f8deb7c2b 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -115,19 +115,19 @@ LL | let _: impl Tr1 = S1; = note: see issue #52662 for more information = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/feature-gate-associated_type_bounds.rs:58:14 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/feature-gate-associated_type_bounds.rs:64:15 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/feature-gate-associated_type_bounds.rs:71:12 | LL | let _: impl Tr1 = S1; diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs index 0db8088f7eea4..7d1c1d6936c14 100644 --- a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -1,6 +1,6 @@ fn f() -> impl Fn() -> impl Sized { || () } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +//~^ ERROR `impl Trait` not allowed within `Fn` trait return fn g() -> &'static dyn Fn() -> impl Sized { &|| () } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +//~^ ERROR `impl Trait` not allowed within `Fn` trait return fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr index c485bc5c3ab90..a7e6c0648a52b 100644 --- a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +error[E0562]: `impl Trait` not allowed within `Fn` trait return --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 | LL | fn f() -> impl Fn() -> impl Sized { || () } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +error[E0562]: `impl Trait` not allowed within `Fn` trait return --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 | LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } diff --git a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs index 637765fff11e4..80b1422b11892 100644 --- a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs @@ -5,14 +5,14 @@ #![feature(async_fn_in_trait)] trait Foo { - fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return - fn baz() -> Box; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return + fn bar() -> impl Sized; //~ ERROR `impl Trait` not allowed within trait method return + fn baz() -> Box; //~ ERROR `impl Trait` not allowed within trait method return } // Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also // feature-gate-async_fn_in_trait.rs) trait AsyncFoo { - async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return + async fn bar() -> impl Sized; //~ ERROR `impl Trait` not allowed within trait method return [E0562] } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr index aeabed4a6ab66..daab3f5a4923f 100644 --- a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr +++ b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return +error[E0562]: `impl Trait` not allowed within trait method return --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 | LL | fn bar() -> impl Sized; @@ -7,7 +7,7 @@ LL | fn bar() -> impl Sized; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return +error[E0562]: `impl Trait` not allowed within trait method return --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 | LL | fn baz() -> Box; @@ -16,7 +16,7 @@ LL | fn baz() -> Box; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return +error[E0562]: `impl Trait` not allowed within trait method return --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 | LL | async fn bar() -> impl Sized; diff --git a/src/test/ui/impl-trait/issues/issue-54600.rs b/src/test/ui/impl-trait/issues/issue-54600.rs index 3024fedf7b5fb..48a039ba2c827 100644 --- a/src/test/ui/impl-trait/issues/issue-54600.rs +++ b/src/test/ui/impl-trait/issues/issue-54600.rs @@ -2,6 +2,6 @@ use std::fmt::Debug; fn main() { let x: Option = Some(44_u32); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding [E0562] println!("{:?}", x); } diff --git a/src/test/ui/impl-trait/issues/issue-54600.stderr b/src/test/ui/impl-trait/issues/issue-54600.stderr index 316566a57a896..eede64456f2a7 100644 --- a/src/test/ui/impl-trait/issues/issue-54600.stderr +++ b/src/test/ui/impl-trait/issues/issue-54600.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-54600.rs:4:19 | LL | let x: Option = Some(44_u32); diff --git a/src/test/ui/impl-trait/issues/issue-54840.rs b/src/test/ui/impl-trait/issues/issue-54840.rs index 8f1e0ece03a62..acd7badbc43f3 100644 --- a/src/test/ui/impl-trait/issues/issue-54840.rs +++ b/src/test/ui/impl-trait/issues/issue-54840.rs @@ -3,5 +3,5 @@ use std::ops::Add; fn main() { let i: i32 = 0; let j: &impl Add = &i; - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding [E0562] } diff --git a/src/test/ui/impl-trait/issues/issue-54840.stderr b/src/test/ui/impl-trait/issues/issue-54840.stderr index 8d82133ac9029..b38aebc6fb75c 100644 --- a/src/test/ui/impl-trait/issues/issue-54840.stderr +++ b/src/test/ui/impl-trait/issues/issue-54840.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-54840.rs:5:13 | LL | let j: &impl Add = &i; diff --git a/src/test/ui/impl-trait/issues/issue-58504.rs b/src/test/ui/impl-trait/issues/issue-58504.rs index e5865d0dfff34..f2f157d807965 100644 --- a/src/test/ui/impl-trait/issues/issue-58504.rs +++ b/src/test/ui/impl-trait/issues/issue-58504.rs @@ -8,5 +8,5 @@ fn mk_gen() -> impl Generator { fn main() { let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding } diff --git a/src/test/ui/impl-trait/issues/issue-58504.stderr b/src/test/ui/impl-trait/issues/issue-58504.stderr index 6656e9fc3fbfc..eb287d1ccfe7d 100644 --- a/src/test/ui/impl-trait/issues/issue-58504.stderr +++ b/src/test/ui/impl-trait/issues/issue-58504.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-58504.rs:10:16 | LL | let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; diff --git a/src/test/ui/impl-trait/issues/issue-58956.rs b/src/test/ui/impl-trait/issues/issue-58956.rs index 68cfcd9ba4f9e..a21f9e2f6fec3 100644 --- a/src/test/ui/impl-trait/issues/issue-58956.rs +++ b/src/test/ui/impl-trait/issues/issue-58956.rs @@ -5,9 +5,9 @@ impl Lam for B {} pub struct Wrap(T); const _A: impl Lam = { - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within type let x: Wrap = Wrap(B); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding x.0 }; diff --git a/src/test/ui/impl-trait/issues/issue-58956.stderr b/src/test/ui/impl-trait/issues/issue-58956.stderr index 123fb4df4b3c8..a314174d19d11 100644 --- a/src/test/ui/impl-trait/issues/issue-58956.stderr +++ b/src/test/ui/impl-trait/issues/issue-58956.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/issue-58956.rs:7:11 | LL | const _A: impl Lam = { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-58956.rs:9:17 | LL | let x: Wrap = Wrap(B); diff --git a/src/test/ui/impl-trait/issues/issue-70971.rs b/src/test/ui/impl-trait/issues/issue-70971.rs index f8ae18bacd67d..b20fdf3252d75 100644 --- a/src/test/ui/impl-trait/issues/issue-70971.rs +++ b/src/test/ui/impl-trait/issues/issue-70971.rs @@ -1,4 +1,4 @@ fn main() { let x : (impl Copy,) = (true,); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding } diff --git a/src/test/ui/impl-trait/issues/issue-70971.stderr b/src/test/ui/impl-trait/issues/issue-70971.stderr index 4dda4c22aa2cf..74a9edda609a1 100644 --- a/src/test/ui/impl-trait/issues/issue-70971.stderr +++ b/src/test/ui/impl-trait/issues/issue-70971.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-70971.rs:2:14 | LL | let x : (impl Copy,) = (true,); diff --git a/src/test/ui/impl-trait/issues/issue-79099.rs b/src/test/ui/impl-trait/issues/issue-79099.rs index da53594f3d091..6f2f2f159e58d 100644 --- a/src/test/ui/impl-trait/issues/issue-79099.rs +++ b/src/test/ui/impl-trait/issues/issue-79099.rs @@ -1,7 +1,7 @@ struct Bug { V1: [(); { let f: impl core::future::Future = async { 1 }; - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding [E0562] //~| expected identifier 1 }], diff --git a/src/test/ui/impl-trait/issues/issue-79099.stderr b/src/test/ui/impl-trait/issues/issue-79099.stderr index 362c67dafd2c5..e8745d8fc868b 100644 --- a/src/test/ui/impl-trait/issues/issue-79099.stderr +++ b/src/test/ui/impl-trait/issues/issue-79099.stderr @@ -9,7 +9,7 @@ LL | let f: impl core::future::Future = async { 1 }; = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-79099.rs:3:16 | LL | let f: impl core::future::Future = async { 1 }; diff --git a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs index 344f359529b61..7bad6b56b2f05 100644 --- a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs +++ b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs @@ -1,8 +1,8 @@ struct Foo(T); -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] type Result = std::result::Result; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // should not cause ICE fn x() -> Foo { diff --git a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr index e635e554e2384..13a55bdb235d1 100644 --- a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr +++ b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16 | LL | struct Foo(T); | ^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20 | LL | type Result = std::result::Result; diff --git a/src/test/ui/impl-trait/issues/issue-84919.rs b/src/test/ui/impl-trait/issues/issue-84919.rs index a0b73743a2b2d..c3a4b6cd9991b 100644 --- a/src/test/ui/impl-trait/issues/issue-84919.rs +++ b/src/test/ui/impl-trait/issues/issue-84919.rs @@ -3,7 +3,7 @@ impl Trait for () {} fn foo<'a: 'a>() { let _x: impl Trait = (); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding [E0562] } fn main() {} diff --git a/src/test/ui/impl-trait/issues/issue-84919.stderr b/src/test/ui/impl-trait/issues/issue-84919.stderr index 5abe1bd877943..1349e3c9b9446 100644 --- a/src/test/ui/impl-trait/issues/issue-84919.stderr +++ b/src/test/ui/impl-trait/issues/issue-84919.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-84919.rs:5:13 | LL | let _x: impl Trait = (); diff --git a/src/test/ui/impl-trait/issues/issue-86642.rs b/src/test/ui/impl-trait/issues/issue-86642.rs index e6e95771400d3..7690f2cfb8ffa 100644 --- a/src/test/ui/impl-trait/issues/issue-86642.rs +++ b/src/test/ui/impl-trait/issues/issue-86642.rs @@ -1,5 +1,5 @@ static x: impl Fn(&str) -> Result<&str, ()> = move |source| { - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within type [E0562] let res = (move |source| Ok(source))(source); let res = res.or((move |source| Ok(source))(source)); res diff --git a/src/test/ui/impl-trait/issues/issue-86642.stderr b/src/test/ui/impl-trait/issues/issue-86642.stderr index 0ec118d5be802..af5e0843e4666 100644 --- a/src/test/ui/impl-trait/issues/issue-86642.stderr +++ b/src/test/ui/impl-trait/issues/issue-86642.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/issue-86642.rs:1:11 | LL | static x: impl Fn(&str) -> Result<&str, ()> = move |source| { diff --git a/src/test/ui/impl-trait/issues/issue-87295.rs b/src/test/ui/impl-trait/issues/issue-87295.rs index aeb8f83326e4d..a7b968a1f9ff8 100644 --- a/src/test/ui/impl-trait/issues/issue-87295.rs +++ b/src/test/ui/impl-trait/issues/issue-87295.rs @@ -14,5 +14,5 @@ impl Struct { fn main() { let _do_not_waste: Struct> = Struct::new(()); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` not allowed within variable binding [E0562] } diff --git a/src/test/ui/impl-trait/issues/issue-87295.stderr b/src/test/ui/impl-trait/issues/issue-87295.stderr index 0b043056b84a6..9d4ccd141b6f2 100644 --- a/src/test/ui/impl-trait/issues/issue-87295.stderr +++ b/src/test/ui/impl-trait/issues/issue-87295.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding +error[E0562]: `impl Trait` not allowed within variable binding --> $DIR/issue-87295.rs:16:31 | LL | let _do_not_waste: Struct> = Struct::new(()); diff --git a/src/test/ui/impl-trait/nested_impl_trait.rs b/src/test/ui/impl-trait/nested_impl_trait.rs index e95fab3b65057..a432fc4a46334 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.rs +++ b/src/test/ui/impl-trait/nested_impl_trait.rs @@ -9,7 +9,7 @@ fn bad_in_ret_position(x: impl Into) -> impl Into { x } fn bad_in_fn_syntax(x: fn() -> impl Into) {} //~^ ERROR nested `impl Trait` is not allowed -//~| `impl Trait` only allowed in function and inherent method return types +//~| `impl Trait` not allowed within `fn` pointer return [E0562] fn bad_in_arg_position(_: impl Into) { } //~^ ERROR nested `impl Trait` is not allowed diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr index 9a8f5a3406813..421b474fcb68a 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.stderr +++ b/src/test/ui/impl-trait/nested_impl_trait.stderr @@ -34,7 +34,7 @@ LL | fn bad(x: impl Into) -> impl Into { x } | | nested `impl Trait` here | outer `impl Trait` -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return +error[E0562]: `impl Trait` not allowed within `fn` pointer return --> $DIR/nested_impl_trait.rs:10:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index 05320e7743ae7..a38e0c1f6b6b7 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -14,47 +14,47 @@ fn in_adt_in_parameters(_: Vec) { panic!() } // Disallowed fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `fn` pointer param [E0562] // Disallowed fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `fn` pointer return [E0562] // Disallowed fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `fn` pointer param [E0562] // Disallowed fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `fn` pointer return [E0562] // Disallowed fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] // Disallowed fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] // Disallowed fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] // Allowed fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } // Disallowed fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] //~^^ ERROR nested `impl Trait` is not allowed // Disallowed fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] // Disallowed fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] //~| ERROR nested `impl Trait` is not allowed // Allowed @@ -62,11 +62,11 @@ fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() // Disallowed fn in_Fn_parameter_in_generics (_: F) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] // Disallowed fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] // Allowed @@ -79,22 +79,22 @@ fn in_impl_Trait_in_return() -> impl IntoIterator { // Disallowed struct InBraceStructField { x: impl Debug } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // Disallowed struct InAdtInBraceStructField { x: Vec } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within path [E0562] // Disallowed struct InTupleStructField(impl Debug); -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // Disallowed enum InEnum { InBraceVariant { x: impl Debug }, - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within type [E0562] InTupleVariant(impl Debug), - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within type [E0562] } // Allowed @@ -105,7 +105,7 @@ trait InTraitDefnParameters { // Disallowed trait InTraitDefnReturn { fn in_return() -> impl Debug; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within trait method return [E0562] } // Allowed and disallowed in trait impls @@ -122,7 +122,7 @@ impl DummyTrait for () { // Allowed fn in_trait_impl_return() -> impl Debug { () } - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within `impl` method return [E0562] } // Allowed @@ -135,10 +135,10 @@ impl DummyType { // Disallowed extern "C" { fn in_foreign_parameters(_: impl Debug); - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within `extern fn` param [E0562] fn in_foreign_return() -> impl Debug; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within `extern fn` return [E0562] } // Allowed @@ -154,34 +154,33 @@ type InTypeAlias = impl Debug; //~^ ERROR `impl Trait` in type aliases is unstable type InReturnInTypeAlias = fn() -> impl Debug; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `fn` pointer return [E0562] //~| ERROR `impl Trait` in type aliases is unstable // Disallowed in impl headers impl PartialEq for () { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within trait [E0562] } // Disallowed in impl headers impl PartialEq<()> for impl Debug { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within type [E0562] } // Disallowed in inherent impls impl impl Debug { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within type [E0562] } // Disallowed in inherent impls struct InInherentImplAdt { t: T } impl InInherentImplAdt { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within type [E0562] } -// Disallowed in where clauses +// Allowed in where clauses fn in_fn_where_clause() where impl Debug: Debug -//~^ ERROR `impl Trait` only allowed in function and inherent method return types { } @@ -200,49 +199,49 @@ fn in_trait_parameter_in_fn_where_clause() // Disallowed fn in_Fn_parameter_in_fn_where_clause() where T: Fn(impl Debug) -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] { } // Disallowed fn in_Fn_return_in_fn_where_clause() where T: Fn() -> impl Debug -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] { } // Disallowed struct InStructGenericParamDefault(T); -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // Disallowed enum InEnumGenericParamDefault { Variant(T) } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // Disallowed trait InTraitGenericParamDefault {} -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // Disallowed type InTypeAliasGenericParamDefault = T; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within type [E0562] // Disallowed impl T {} //~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` not allowed within type [E0562] //~| ERROR no nominal type found // Disallowed fn in_method_generic_param_default(_: T) {} //~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` not allowed within type [E0562] fn main() { let _in_local_variable: impl Fn() = || {}; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within variable binding [E0562] let _in_return_in_local_variable = || -> impl Fn() { || {} }; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within closure return [E0562] } diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 8ac4dd6dc5571..846102b3fbdf9 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -43,109 +43,109 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param +error[E0562]: `impl Trait` not allowed within `fn` pointer param --> $DIR/where-allowed.rs:16:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return +error[E0562]: `impl Trait` not allowed within `fn` pointer return --> $DIR/where-allowed.rs:20:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param +error[E0562]: `impl Trait` not allowed within `fn` pointer param --> $DIR/where-allowed.rs:24:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return +error[E0562]: `impl Trait` not allowed within `fn` pointer return --> $DIR/where-allowed.rs:28:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param +error[E0562]: `impl Trait` not allowed within `Fn` trait param --> $DIR/where-allowed.rs:32:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +error[E0562]: `impl Trait` not allowed within `Fn` trait return --> $DIR/where-allowed.rs:36:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param +error[E0562]: `impl Trait` not allowed within `Fn` trait param --> $DIR/where-allowed.rs:40:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param +error[E0562]: `impl Trait` not allowed within `Fn` trait param --> $DIR/where-allowed.rs:47:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +error[E0562]: `impl Trait` not allowed within `Fn` trait return --> $DIR/where-allowed.rs:52:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param +error[E0562]: `impl Trait` not allowed within `Fn` trait param --> $DIR/where-allowed.rs:56:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param +error[E0562]: `impl Trait` not allowed within `Fn` trait param --> $DIR/where-allowed.rs:64:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +error[E0562]: `impl Trait` not allowed within `Fn` trait return --> $DIR/where-allowed.rs:68:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:81:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in path +error[E0562]: `impl Trait` not allowed within path --> $DIR/where-allowed.rs:85:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:89:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:94:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:96:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return +error[E0562]: `impl Trait` not allowed within trait method return --> $DIR/where-allowed.rs:107:23 | LL | fn in_return() -> impl Debug; @@ -154,7 +154,7 @@ LL | fn in_return() -> impl Debug; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return +error[E0562]: `impl Trait` not allowed within `impl` method return --> $DIR/where-allowed.rs:124:34 | LL | fn in_trait_impl_return() -> impl Debug { () } @@ -163,116 +163,110 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param +error[E0562]: `impl Trait` not allowed within `extern fn` param --> $DIR/where-allowed.rs:137:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return +error[E0562]: `impl Trait` not allowed within `extern fn` return --> $DIR/where-allowed.rs:140:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return +error[E0562]: `impl Trait` not allowed within `fn` pointer return --> $DIR/where-allowed.rs:156:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait +error[E0562]: `impl Trait` not allowed within trait --> $DIR/where-allowed.rs:161:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:166:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:171:6 | LL | impl impl Debug { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type +error[E0562]: `impl Trait` not allowed within type --> $DIR/where-allowed.rs:177:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:183:11 - | -LL | where impl Debug: Debug - | ^^^^^^^^^^ - -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param - --> $DIR/where-allowed.rs:202:17 +error[E0562]: `impl Trait` not allowed within `Fn` trait param + --> $DIR/where-allowed.rs:201:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return - --> $DIR/where-allowed.rs:209:22 +error[E0562]: `impl Trait` not allowed within `Fn` trait return + --> $DIR/where-allowed.rs:208:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:215:40 +error[E0562]: `impl Trait` not allowed within type + --> $DIR/where-allowed.rs:214:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:219:36 +error[E0562]: `impl Trait` not allowed within type + --> $DIR/where-allowed.rs:218:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:223:38 +error[E0562]: `impl Trait` not allowed within type + --> $DIR/where-allowed.rs:222:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:227:41 +error[E0562]: `impl Trait` not allowed within type + --> $DIR/where-allowed.rs:226:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:231:11 +error[E0562]: `impl Trait` not allowed within type + --> $DIR/where-allowed.rs:230:11 | LL | impl T {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type - --> $DIR/where-allowed.rs:238:40 +error[E0562]: `impl Trait` not allowed within type + --> $DIR/where-allowed.rs:237:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding - --> $DIR/where-allowed.rs:244:29 +error[E0562]: `impl Trait` not allowed within variable binding + --> $DIR/where-allowed.rs:243:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return - --> $DIR/where-allowed.rs:246:46 +error[E0562]: `impl Trait` not allowed within closure return + --> $DIR/where-allowed.rs:245:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:231:7 + --> $DIR/where-allowed.rs:230:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -282,7 +276,7 @@ LL | impl T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:238:36 + --> $DIR/where-allowed.rs:237:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -291,14 +285,14 @@ LL | fn in_method_generic_param_default(_: T) {} = note: for more information, see issue #36887 error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:231:23 + --> $DIR/where-allowed.rs:230:23 | LL | impl T {} | ^ impl requires a nominal type | = note: either implement a trait on it or create a newtype to wrap it instead -error: aborting due to 46 previous errors +error: aborting due to 44 previous errors Some errors have detailed explanations: E0118, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0118`. diff --git a/src/test/ui/issues/issue-47715.rs b/src/test/ui/issues/issue-47715.rs index b8088c18dadfe..5c80afe641ec5 100644 --- a/src/test/ui/issues/issue-47715.rs +++ b/src/test/ui/issues/issue-47715.rs @@ -7,22 +7,22 @@ trait Iterable { } struct Container> { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within generic [E0562] field: T } enum Enum> { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within generic [E0562] A(T), } union Union + Copy> { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` not allowed within generic [E0562] x: T, } type Type> = T; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` not allowed within generic [E0562] fn main() { } diff --git a/src/test/ui/issues/issue-47715.stderr b/src/test/ui/issues/issue-47715.stderr index 0ee9388bf2b2c..55deda240bab9 100644 --- a/src/test/ui/issues/issue-47715.stderr +++ b/src/test/ui/issues/issue-47715.stderr @@ -1,22 +1,22 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic +error[E0562]: `impl Trait` not allowed within generic --> $DIR/issue-47715.rs:9:37 | LL | struct Container> { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic +error[E0562]: `impl Trait` not allowed within generic --> $DIR/issue-47715.rs:14:30 | LL | enum Enum> { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic +error[E0562]: `impl Trait` not allowed within generic --> $DIR/issue-47715.rs:19:32 | LL | union Union + Copy> { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic +error[E0562]: `impl Trait` not allowed within generic --> $DIR/issue-47715.rs:24:30 | LL | type Type> = T; diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs index 857066c78c902..0bc8c0a75e861 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs @@ -4,7 +4,7 @@ // FIXME: this is ruled out for now but should work type Foo = fn() -> impl Send; -//~^ ERROR: `impl Trait` only allowed in function and inherent method return types +//~^ ERROR: `impl Trait` not allowed within `fn` pointer return [E0562] fn make_foo() -> Foo { || 15 diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr index a31cf1a51ccd7..2b69acd112554 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return +error[E0562]: `impl Trait` not allowed within `fn` pointer return --> $DIR/type-alias-impl-trait-fn-type.rs:6:20 | LL | type Foo = fn() -> impl Send; From 0860d8b820dbab64f115b1681b08775f87a25f98 Mon Sep 17 00:00:00 2001 From: York Xiang Date: Tue, 29 Nov 2022 15:21:21 +0800 Subject: [PATCH 3/4] Add tests for issue-104526 --- src/test/ui/impl-trait/where-allowed.rs | 18 +++++ src/test/ui/impl-trait/where-allowed.stderr | 88 ++++++++++----------- 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index a38e0c1f6b6b7..4b207cac61870 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -2,6 +2,7 @@ //! impl Trait #![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; +use std::ops::Add; // Allowed fn in_parameters(_: impl Debug) { panic!() } @@ -245,3 +246,20 @@ fn main() { let _in_return_in_local_variable = || -> impl Fn() { || {} }; //~^ ERROR `impl Trait` not allowed within closure return [E0562] } + +// Add tests for issue-104526 + +fn foo>(t: T) {} +fn bar>(t: T) {} + + +fn another_foo(t: T) +where + T: Add, +{ +} +fn another_bar(t: T) +where + T: AsRef, +{ +} diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index 846102b3fbdf9..a6234d5b4ef79 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:47:51 + --> $DIR/where-allowed.rs:48:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | --------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:56:57 + --> $DIR/where-allowed.rs:57:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | --------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | outer `impl Trait` error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:118:16 + --> $DIR/where-allowed.rs:119:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | type Out = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:153:23 + --> $DIR/where-allowed.rs:154:23 | LL | type InTypeAlias = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type InTypeAlias = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:156:39 + --> $DIR/where-allowed.rs:157:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -44,109 +44,109 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed within `fn` pointer param - --> $DIR/where-allowed.rs:16:40 + --> $DIR/where-allowed.rs:17:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `fn` pointer return - --> $DIR/where-allowed.rs:20:42 + --> $DIR/where-allowed.rs:21:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `fn` pointer param - --> $DIR/where-allowed.rs:24:38 + --> $DIR/where-allowed.rs:25:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `fn` pointer return - --> $DIR/where-allowed.rs:28:40 + --> $DIR/where-allowed.rs:29:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait param - --> $DIR/where-allowed.rs:32:49 + --> $DIR/where-allowed.rs:33:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait return - --> $DIR/where-allowed.rs:36:51 + --> $DIR/where-allowed.rs:37:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait param - --> $DIR/where-allowed.rs:40:55 + --> $DIR/where-allowed.rs:41:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait param - --> $DIR/where-allowed.rs:47:51 + --> $DIR/where-allowed.rs:48:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait return - --> $DIR/where-allowed.rs:52:53 + --> $DIR/where-allowed.rs:53:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait param - --> $DIR/where-allowed.rs:56:57 + --> $DIR/where-allowed.rs:57:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait param - --> $DIR/where-allowed.rs:64:38 + --> $DIR/where-allowed.rs:65:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait return - --> $DIR/where-allowed.rs:68:40 + --> $DIR/where-allowed.rs:69:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:81:32 + --> $DIR/where-allowed.rs:82:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within path - --> $DIR/where-allowed.rs:85:41 + --> $DIR/where-allowed.rs:86:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:89:27 + --> $DIR/where-allowed.rs:90:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:94:25 + --> $DIR/where-allowed.rs:95:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:96:20 + --> $DIR/where-allowed.rs:97:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within trait method return - --> $DIR/where-allowed.rs:107:23 + --> $DIR/where-allowed.rs:108:23 | LL | fn in_return() -> impl Debug; | ^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | fn in_return() -> impl Debug; = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed within `impl` method return - --> $DIR/where-allowed.rs:124:34 + --> $DIR/where-allowed.rs:125:34 | LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ @@ -164,109 +164,109 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed within `extern fn` param - --> $DIR/where-allowed.rs:137:33 + --> $DIR/where-allowed.rs:138:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `extern fn` return - --> $DIR/where-allowed.rs:140:31 + --> $DIR/where-allowed.rs:141:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `fn` pointer return - --> $DIR/where-allowed.rs:156:39 + --> $DIR/where-allowed.rs:157:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within trait - --> $DIR/where-allowed.rs:161:16 + --> $DIR/where-allowed.rs:162:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:166:24 + --> $DIR/where-allowed.rs:167:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:171:6 + --> $DIR/where-allowed.rs:172:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:177:24 + --> $DIR/where-allowed.rs:178:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait param - --> $DIR/where-allowed.rs:201:17 + --> $DIR/where-allowed.rs:202:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within `Fn` trait return - --> $DIR/where-allowed.rs:208:22 + --> $DIR/where-allowed.rs:209:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:214:40 + --> $DIR/where-allowed.rs:215:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:218:36 + --> $DIR/where-allowed.rs:219:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:222:38 + --> $DIR/where-allowed.rs:223:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:226:41 + --> $DIR/where-allowed.rs:227:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:230:11 + --> $DIR/where-allowed.rs:231:11 | LL | impl T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within type - --> $DIR/where-allowed.rs:237:40 + --> $DIR/where-allowed.rs:238:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` not allowed within variable binding - --> $DIR/where-allowed.rs:243:29 + --> $DIR/where-allowed.rs:244:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` not allowed within closure return - --> $DIR/where-allowed.rs:245:46 + --> $DIR/where-allowed.rs:246:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:230:7 + --> $DIR/where-allowed.rs:231:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -276,7 +276,7 @@ LL | impl T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:237:36 + --> $DIR/where-allowed.rs:238:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -285,7 +285,7 @@ LL | fn in_method_generic_param_default(_: T) {} = note: for more information, see issue #36887 error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:230:23 + --> $DIR/where-allowed.rs:231:23 | LL | impl T {} | ^ impl requires a nominal type From 458f03b91259ced74b6d954fc5a3210f9cb0a4b1 Mon Sep 17 00:00:00 2001 From: York Xiang Date: Thu, 1 Dec 2022 08:47:28 +0800 Subject: [PATCH 4/4] Improve impl-trait error messages: "not allowed" --> "isn't allowed" --- .../locales/en-US/ast_lowering.ftl | 2 +- .../async-await/in-trait/fn-not-async-err2.rs | 2 +- .../in-trait/fn-not-async-err2.stderr | 2 +- .../feature-gate-associated_type_bounds.rs | 6 +- ...feature-gate-associated_type_bounds.stderr | 6 +- ...ture-gate-impl_trait_in_fn_trait_return.rs | 4 +- ...-gate-impl_trait_in_fn_trait_return.stderr | 4 +- ...ate-return_position_impl_trait_in_trait.rs | 6 +- ...return_position_impl_trait_in_trait.stderr | 6 +- src/test/ui/impl-trait/issues/issue-54600.rs | 2 +- .../ui/impl-trait/issues/issue-54600.stderr | 2 +- src/test/ui/impl-trait/issues/issue-54840.rs | 2 +- .../ui/impl-trait/issues/issue-54840.stderr | 2 +- src/test/ui/impl-trait/issues/issue-58504.rs | 2 +- .../ui/impl-trait/issues/issue-58504.stderr | 2 +- src/test/ui/impl-trait/issues/issue-58956.rs | 4 +- .../ui/impl-trait/issues/issue-58956.stderr | 4 +- src/test/ui/impl-trait/issues/issue-70971.rs | 2 +- .../ui/impl-trait/issues/issue-70971.stderr | 2 +- src/test/ui/impl-trait/issues/issue-79099.rs | 2 +- .../ui/impl-trait/issues/issue-79099.stderr | 2 +- ...sue-83929-impl-trait-in-generic-default.rs | 4 +- ...83929-impl-trait-in-generic-default.stderr | 4 +- src/test/ui/impl-trait/issues/issue-84919.rs | 2 +- .../ui/impl-trait/issues/issue-84919.stderr | 2 +- src/test/ui/impl-trait/issues/issue-86642.rs | 2 +- .../ui/impl-trait/issues/issue-86642.stderr | 2 +- src/test/ui/impl-trait/issues/issue-87295.rs | 2 +- .../ui/impl-trait/issues/issue-87295.stderr | 2 +- src/test/ui/impl-trait/nested_impl_trait.rs | 2 +- .../ui/impl-trait/nested_impl_trait.stderr | 2 +- src/test/ui/impl-trait/where-allowed.rs | 72 +++++++++---------- src/test/ui/impl-trait/where-allowed.stderr | 72 +++++++++---------- src/test/ui/issues/issue-47715.rs | 8 +-- src/test/ui/issues/issue-47715.stderr | 8 +-- .../type-alias-impl-trait-fn-type.rs | 2 +- .../type-alias-impl-trait-fn-type.stderr | 2 +- 37 files changed, 127 insertions(+), 127 deletions(-) diff --git a/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl b/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl index b6ae52642f371..59e02cf4d2b10 100644 --- a/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl +++ b/compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl @@ -17,7 +17,7 @@ ast_lowering_assoc_ty_parentheses = ast_lowering_remove_parentheses = remove these parentheses ast_lowering_misplaced_impl_trait = - `impl Trait` not allowed within {$position} + `impl Trait` isn't allowed within {$position} ast_lowering_rustc_box_attribute_error = #[rustc_box] requires precisely one argument and no other attributes are allowed diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs b/src/test/ui/async-await/in-trait/fn-not-async-err2.rs index 6eda11b576f9b..9325f55ea1e1c 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/src/test/ui/async-await/in-trait/fn-not-async-err2.rs @@ -11,7 +11,7 @@ trait MyTrait { impl MyTrait for i32 { fn foo(&self) -> impl Future { - //~^ ERROR `impl Trait` not allowed within `impl` method return [E0562] + //~^ ERROR `impl Trait` isn't allowed within `impl` method return [E0562] async { *self } diff --git a/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr b/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr index f9b798aa96a1b..3a50f9664de31 100644 --- a/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr +++ b/src/test/ui/async-await/in-trait/fn-not-async-err2.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within `impl` method return +error[E0562]: `impl Trait` isn't allowed within `impl` method return --> $DIR/fn-not-async-err2.rs:13:22 | LL | fn foo(&self) -> impl Future { diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs index 518fe4202d23d..3f1db232f1e05 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -57,20 +57,20 @@ fn _rpit_dyn() -> Box> { Box::new(S1) } const _cdef: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable -//~| ERROR `impl Trait` not allowed within type [E0562] +//~| ERROR `impl Trait` isn't allowed within type [E0562] // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // const _cdef_dyn: &dyn Tr1 = &S1; static _sdef: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable -//~| ERROR `impl Trait` not allowed within type [E0562] +//~| ERROR `impl Trait` isn't allowed within type [E0562] // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // static _sdef_dyn: &dyn Tr1 = &S1; fn main() { let _: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable - //~| ERROR `impl Trait` not allowed within variable binding [E0562] + //~| ERROR `impl Trait` isn't allowed within variable binding [E0562] // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // let _: &dyn Tr1 = &S1; } diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index 7fb0f8deb7c2b..3fa49ab49dc87 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -115,19 +115,19 @@ LL | let _: impl Tr1 = S1; = note: see issue #52662 for more information = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/feature-gate-associated_type_bounds.rs:58:14 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/feature-gate-associated_type_bounds.rs:64:15 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/feature-gate-associated_type_bounds.rs:71:12 | LL | let _: impl Tr1 = S1; diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs index 7d1c1d6936c14..88ac5bd2b30b5 100644 --- a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -1,6 +1,6 @@ fn f() -> impl Fn() -> impl Sized { || () } -//~^ ERROR `impl Trait` not allowed within `Fn` trait return +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait return fn g() -> &'static dyn Fn() -> impl Sized { &|| () } -//~^ ERROR `impl Trait` not allowed within `Fn` trait return +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait return fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr index a7e6c0648a52b..ff5f7179233a8 100644 --- a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` not allowed within `Fn` trait return +error[E0562]: `impl Trait` isn't allowed within `Fn` trait return --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 | LL | fn f() -> impl Fn() -> impl Sized { || () } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait return +error[E0562]: `impl Trait` isn't allowed within `Fn` trait return --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 | LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } diff --git a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs index 80b1422b11892..4c81dc169a368 100644 --- a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs @@ -5,14 +5,14 @@ #![feature(async_fn_in_trait)] trait Foo { - fn bar() -> impl Sized; //~ ERROR `impl Trait` not allowed within trait method return - fn baz() -> Box; //~ ERROR `impl Trait` not allowed within trait method return + fn bar() -> impl Sized; //~ ERROR `impl Trait` isn't allowed within trait method return + fn baz() -> Box; //~ ERROR `impl Trait` isn't allowed within trait method return } // Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also // feature-gate-async_fn_in_trait.rs) trait AsyncFoo { - async fn bar() -> impl Sized; //~ ERROR `impl Trait` not allowed within trait method return [E0562] + async fn bar() -> impl Sized; //~ ERROR `impl Trait` isn't allowed within trait method return [E0562] } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr index daab3f5a4923f..af5eba57be8ec 100644 --- a/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr +++ b/src/test/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within trait method return +error[E0562]: `impl Trait` isn't allowed within trait method return --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 | LL | fn bar() -> impl Sized; @@ -7,7 +7,7 @@ LL | fn bar() -> impl Sized; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` not allowed within trait method return +error[E0562]: `impl Trait` isn't allowed within trait method return --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 | LL | fn baz() -> Box; @@ -16,7 +16,7 @@ LL | fn baz() -> Box; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` not allowed within trait method return +error[E0562]: `impl Trait` isn't allowed within trait method return --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 | LL | async fn bar() -> impl Sized; diff --git a/src/test/ui/impl-trait/issues/issue-54600.rs b/src/test/ui/impl-trait/issues/issue-54600.rs index 48a039ba2c827..f00974acd44b4 100644 --- a/src/test/ui/impl-trait/issues/issue-54600.rs +++ b/src/test/ui/impl-trait/issues/issue-54600.rs @@ -2,6 +2,6 @@ use std::fmt::Debug; fn main() { let x: Option = Some(44_u32); - //~^ `impl Trait` not allowed within variable binding [E0562] + //~^ `impl Trait` isn't allowed within variable binding [E0562] println!("{:?}", x); } diff --git a/src/test/ui/impl-trait/issues/issue-54600.stderr b/src/test/ui/impl-trait/issues/issue-54600.stderr index eede64456f2a7..b8c3de8927299 100644 --- a/src/test/ui/impl-trait/issues/issue-54600.stderr +++ b/src/test/ui/impl-trait/issues/issue-54600.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-54600.rs:4:19 | LL | let x: Option = Some(44_u32); diff --git a/src/test/ui/impl-trait/issues/issue-54840.rs b/src/test/ui/impl-trait/issues/issue-54840.rs index acd7badbc43f3..c8f5e63a11851 100644 --- a/src/test/ui/impl-trait/issues/issue-54840.rs +++ b/src/test/ui/impl-trait/issues/issue-54840.rs @@ -3,5 +3,5 @@ use std::ops::Add; fn main() { let i: i32 = 0; let j: &impl Add = &i; - //~^ `impl Trait` not allowed within variable binding [E0562] + //~^ `impl Trait` isn't allowed within variable binding [E0562] } diff --git a/src/test/ui/impl-trait/issues/issue-54840.stderr b/src/test/ui/impl-trait/issues/issue-54840.stderr index b38aebc6fb75c..9b0fb07248ed0 100644 --- a/src/test/ui/impl-trait/issues/issue-54840.stderr +++ b/src/test/ui/impl-trait/issues/issue-54840.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-54840.rs:5:13 | LL | let j: &impl Add = &i; diff --git a/src/test/ui/impl-trait/issues/issue-58504.rs b/src/test/ui/impl-trait/issues/issue-58504.rs index f2f157d807965..5592af19789b3 100644 --- a/src/test/ui/impl-trait/issues/issue-58504.rs +++ b/src/test/ui/impl-trait/issues/issue-58504.rs @@ -8,5 +8,5 @@ fn mk_gen() -> impl Generator { fn main() { let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; - //~^ `impl Trait` not allowed within variable binding + //~^ `impl Trait` isn't allowed within variable binding } diff --git a/src/test/ui/impl-trait/issues/issue-58504.stderr b/src/test/ui/impl-trait/issues/issue-58504.stderr index eb287d1ccfe7d..bbf18c10c7cde 100644 --- a/src/test/ui/impl-trait/issues/issue-58504.stderr +++ b/src/test/ui/impl-trait/issues/issue-58504.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-58504.rs:10:16 | LL | let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; diff --git a/src/test/ui/impl-trait/issues/issue-58956.rs b/src/test/ui/impl-trait/issues/issue-58956.rs index a21f9e2f6fec3..9b02c4cba52b0 100644 --- a/src/test/ui/impl-trait/issues/issue-58956.rs +++ b/src/test/ui/impl-trait/issues/issue-58956.rs @@ -5,9 +5,9 @@ impl Lam for B {} pub struct Wrap(T); const _A: impl Lam = { - //~^ `impl Trait` not allowed within type + //~^ `impl Trait` isn't allowed within type let x: Wrap = Wrap(B); - //~^ `impl Trait` not allowed within variable binding + //~^ `impl Trait` isn't allowed within variable binding x.0 }; diff --git a/src/test/ui/impl-trait/issues/issue-58956.stderr b/src/test/ui/impl-trait/issues/issue-58956.stderr index a314174d19d11..e914b6266d04f 100644 --- a/src/test/ui/impl-trait/issues/issue-58956.stderr +++ b/src/test/ui/impl-trait/issues/issue-58956.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/issue-58956.rs:7:11 | LL | const _A: impl Lam = { | ^^^^^^^^ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-58956.rs:9:17 | LL | let x: Wrap = Wrap(B); diff --git a/src/test/ui/impl-trait/issues/issue-70971.rs b/src/test/ui/impl-trait/issues/issue-70971.rs index b20fdf3252d75..a849d25ff980c 100644 --- a/src/test/ui/impl-trait/issues/issue-70971.rs +++ b/src/test/ui/impl-trait/issues/issue-70971.rs @@ -1,4 +1,4 @@ fn main() { let x : (impl Copy,) = (true,); - //~^ `impl Trait` not allowed within variable binding + //~^ `impl Trait` isn't allowed within variable binding } diff --git a/src/test/ui/impl-trait/issues/issue-70971.stderr b/src/test/ui/impl-trait/issues/issue-70971.stderr index 74a9edda609a1..d1693655b5d64 100644 --- a/src/test/ui/impl-trait/issues/issue-70971.stderr +++ b/src/test/ui/impl-trait/issues/issue-70971.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-70971.rs:2:14 | LL | let x : (impl Copy,) = (true,); diff --git a/src/test/ui/impl-trait/issues/issue-79099.rs b/src/test/ui/impl-trait/issues/issue-79099.rs index 6f2f2f159e58d..d45706a7360bf 100644 --- a/src/test/ui/impl-trait/issues/issue-79099.rs +++ b/src/test/ui/impl-trait/issues/issue-79099.rs @@ -1,7 +1,7 @@ struct Bug { V1: [(); { let f: impl core::future::Future = async { 1 }; - //~^ `impl Trait` not allowed within variable binding [E0562] + //~^ `impl Trait` isn't allowed within variable binding [E0562] //~| expected identifier 1 }], diff --git a/src/test/ui/impl-trait/issues/issue-79099.stderr b/src/test/ui/impl-trait/issues/issue-79099.stderr index e8745d8fc868b..9dac106ce5211 100644 --- a/src/test/ui/impl-trait/issues/issue-79099.stderr +++ b/src/test/ui/impl-trait/issues/issue-79099.stderr @@ -9,7 +9,7 @@ LL | let f: impl core::future::Future = async { 1 }; = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-79099.rs:3:16 | LL | let f: impl core::future::Future = async { 1 }; diff --git a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs index 7bad6b56b2f05..06b98f24698e5 100644 --- a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs +++ b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs @@ -1,8 +1,8 @@ struct Foo(T); -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] type Result = std::result::Result; -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // should not cause ICE fn x() -> Foo { diff --git a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr index 13a55bdb235d1..72a6405b737b1 100644 --- a/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr +++ b/src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16 | LL | struct Foo(T); | ^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20 | LL | type Result = std::result::Result; diff --git a/src/test/ui/impl-trait/issues/issue-84919.rs b/src/test/ui/impl-trait/issues/issue-84919.rs index c3a4b6cd9991b..8ce137130d114 100644 --- a/src/test/ui/impl-trait/issues/issue-84919.rs +++ b/src/test/ui/impl-trait/issues/issue-84919.rs @@ -3,7 +3,7 @@ impl Trait for () {} fn foo<'a: 'a>() { let _x: impl Trait = (); - //~^ `impl Trait` not allowed within variable binding [E0562] + //~^ `impl Trait` isn't allowed within variable binding [E0562] } fn main() {} diff --git a/src/test/ui/impl-trait/issues/issue-84919.stderr b/src/test/ui/impl-trait/issues/issue-84919.stderr index 1349e3c9b9446..a5c1b7b4ec332 100644 --- a/src/test/ui/impl-trait/issues/issue-84919.stderr +++ b/src/test/ui/impl-trait/issues/issue-84919.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-84919.rs:5:13 | LL | let _x: impl Trait = (); diff --git a/src/test/ui/impl-trait/issues/issue-86642.rs b/src/test/ui/impl-trait/issues/issue-86642.rs index 7690f2cfb8ffa..a1ce701fe7816 100644 --- a/src/test/ui/impl-trait/issues/issue-86642.rs +++ b/src/test/ui/impl-trait/issues/issue-86642.rs @@ -1,5 +1,5 @@ static x: impl Fn(&str) -> Result<&str, ()> = move |source| { - //~^ `impl Trait` not allowed within type [E0562] + //~^ `impl Trait` isn't allowed within type [E0562] let res = (move |source| Ok(source))(source); let res = res.or((move |source| Ok(source))(source)); res diff --git a/src/test/ui/impl-trait/issues/issue-86642.stderr b/src/test/ui/impl-trait/issues/issue-86642.stderr index af5e0843e4666..2da8e3fa30241 100644 --- a/src/test/ui/impl-trait/issues/issue-86642.stderr +++ b/src/test/ui/impl-trait/issues/issue-86642.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/issue-86642.rs:1:11 | LL | static x: impl Fn(&str) -> Result<&str, ()> = move |source| { diff --git a/src/test/ui/impl-trait/issues/issue-87295.rs b/src/test/ui/impl-trait/issues/issue-87295.rs index a7b968a1f9ff8..82d6b0a8887d7 100644 --- a/src/test/ui/impl-trait/issues/issue-87295.rs +++ b/src/test/ui/impl-trait/issues/issue-87295.rs @@ -14,5 +14,5 @@ impl Struct { fn main() { let _do_not_waste: Struct> = Struct::new(()); - //~^ `impl Trait` not allowed within variable binding [E0562] + //~^ `impl Trait` isn't allowed within variable binding [E0562] } diff --git a/src/test/ui/impl-trait/issues/issue-87295.stderr b/src/test/ui/impl-trait/issues/issue-87295.stderr index 9d4ccd141b6f2..8aa2ae89fdffe 100644 --- a/src/test/ui/impl-trait/issues/issue-87295.stderr +++ b/src/test/ui/impl-trait/issues/issue-87295.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/issue-87295.rs:16:31 | LL | let _do_not_waste: Struct> = Struct::new(()); diff --git a/src/test/ui/impl-trait/nested_impl_trait.rs b/src/test/ui/impl-trait/nested_impl_trait.rs index a432fc4a46334..07a8a164fb56e 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.rs +++ b/src/test/ui/impl-trait/nested_impl_trait.rs @@ -9,7 +9,7 @@ fn bad_in_ret_position(x: impl Into) -> impl Into { x } fn bad_in_fn_syntax(x: fn() -> impl Into) {} //~^ ERROR nested `impl Trait` is not allowed -//~| `impl Trait` not allowed within `fn` pointer return [E0562] +//~| `impl Trait` isn't allowed within `fn` pointer return [E0562] fn bad_in_arg_position(_: impl Into) { } //~^ ERROR nested `impl Trait` is not allowed diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr index 421b474fcb68a..05f7f3f5a88cb 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.stderr +++ b/src/test/ui/impl-trait/nested_impl_trait.stderr @@ -34,7 +34,7 @@ LL | fn bad(x: impl Into) -> impl Into { x } | | nested `impl Trait` here | outer `impl Trait` -error[E0562]: `impl Trait` not allowed within `fn` pointer return +error[E0562]: `impl Trait` isn't allowed within `fn` pointer return --> $DIR/nested_impl_trait.rs:10:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} diff --git a/src/test/ui/impl-trait/where-allowed.rs b/src/test/ui/impl-trait/where-allowed.rs index 4b207cac61870..15b43f557adc2 100644 --- a/src/test/ui/impl-trait/where-allowed.rs +++ b/src/test/ui/impl-trait/where-allowed.rs @@ -15,47 +15,47 @@ fn in_adt_in_parameters(_: Vec) { panic!() } // Disallowed fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` not allowed within `fn` pointer param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `fn` pointer param [E0562] // Disallowed fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed within `fn` pointer return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `fn` pointer return [E0562] // Disallowed fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed within `fn` pointer param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `fn` pointer param [E0562] // Disallowed fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` not allowed within `fn` pointer return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `fn` pointer return [E0562] // Disallowed fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait param [E0562] // Disallowed fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait return [E0562] // Disallowed fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait param [E0562] // Allowed fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } // Disallowed fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait param [E0562] //~^^ ERROR nested `impl Trait` is not allowed // Disallowed fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait return [E0562] // Disallowed fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait param [E0562] //~| ERROR nested `impl Trait` is not allowed // Allowed @@ -63,11 +63,11 @@ fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() // Disallowed fn in_Fn_parameter_in_generics (_: F) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait param [E0562] // Disallowed fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } -//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait return [E0562] // Allowed @@ -80,22 +80,22 @@ fn in_impl_Trait_in_return() -> impl IntoIterator { // Disallowed struct InBraceStructField { x: impl Debug } -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // Disallowed struct InAdtInBraceStructField { x: Vec } -//~^ ERROR `impl Trait` not allowed within path [E0562] +//~^ ERROR `impl Trait` isn't allowed within path [E0562] // Disallowed struct InTupleStructField(impl Debug); -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // Disallowed enum InEnum { InBraceVariant { x: impl Debug }, - //~^ ERROR `impl Trait` not allowed within type [E0562] + //~^ ERROR `impl Trait` isn't allowed within type [E0562] InTupleVariant(impl Debug), - //~^ ERROR `impl Trait` not allowed within type [E0562] + //~^ ERROR `impl Trait` isn't allowed within type [E0562] } // Allowed @@ -106,7 +106,7 @@ trait InTraitDefnParameters { // Disallowed trait InTraitDefnReturn { fn in_return() -> impl Debug; - //~^ ERROR `impl Trait` not allowed within trait method return [E0562] + //~^ ERROR `impl Trait` isn't allowed within trait method return [E0562] } // Allowed and disallowed in trait impls @@ -123,7 +123,7 @@ impl DummyTrait for () { // Allowed fn in_trait_impl_return() -> impl Debug { () } - //~^ ERROR `impl Trait` not allowed within `impl` method return [E0562] + //~^ ERROR `impl Trait` isn't allowed within `impl` method return [E0562] } // Allowed @@ -136,10 +136,10 @@ impl DummyType { // Disallowed extern "C" { fn in_foreign_parameters(_: impl Debug); - //~^ ERROR `impl Trait` not allowed within `extern fn` param [E0562] + //~^ ERROR `impl Trait` isn't allowed within `extern fn` param [E0562] fn in_foreign_return() -> impl Debug; - //~^ ERROR `impl Trait` not allowed within `extern fn` return [E0562] + //~^ ERROR `impl Trait` isn't allowed within `extern fn` return [E0562] } // Allowed @@ -155,28 +155,28 @@ type InTypeAlias = impl Debug; //~^ ERROR `impl Trait` in type aliases is unstable type InReturnInTypeAlias = fn() -> impl Debug; -//~^ ERROR `impl Trait` not allowed within `fn` pointer return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `fn` pointer return [E0562] //~| ERROR `impl Trait` in type aliases is unstable // Disallowed in impl headers impl PartialEq for () { - //~^ ERROR `impl Trait` not allowed within trait [E0562] + //~^ ERROR `impl Trait` isn't allowed within trait [E0562] } // Disallowed in impl headers impl PartialEq<()> for impl Debug { - //~^ ERROR `impl Trait` not allowed within type [E0562] + //~^ ERROR `impl Trait` isn't allowed within type [E0562] } // Disallowed in inherent impls impl impl Debug { - //~^ ERROR `impl Trait` not allowed within type [E0562] + //~^ ERROR `impl Trait` isn't allowed within type [E0562] } // Disallowed in inherent impls struct InInherentImplAdt { t: T } impl InInherentImplAdt { - //~^ ERROR `impl Trait` not allowed within type [E0562] + //~^ ERROR `impl Trait` isn't allowed within type [E0562] } // Allowed in where clauses @@ -200,51 +200,51 @@ fn in_trait_parameter_in_fn_where_clause() // Disallowed fn in_Fn_parameter_in_fn_where_clause() where T: Fn(impl Debug) -//~^ ERROR `impl Trait` not allowed within `Fn` trait param [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait param [E0562] { } // Disallowed fn in_Fn_return_in_fn_where_clause() where T: Fn() -> impl Debug -//~^ ERROR `impl Trait` not allowed within `Fn` trait return [E0562] +//~^ ERROR `impl Trait` isn't allowed within `Fn` trait return [E0562] { } // Disallowed struct InStructGenericParamDefault(T); -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // Disallowed enum InEnumGenericParamDefault { Variant(T) } -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // Disallowed trait InTraitGenericParamDefault {} -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // Disallowed type InTypeAliasGenericParamDefault = T; -//~^ ERROR `impl Trait` not allowed within type [E0562] +//~^ ERROR `impl Trait` isn't allowed within type [E0562] // Disallowed impl T {} //~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` not allowed within type [E0562] +//~| ERROR `impl Trait` isn't allowed within type [E0562] //~| ERROR no nominal type found // Disallowed fn in_method_generic_param_default(_: T) {} //~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` not allowed within type [E0562] +//~| ERROR `impl Trait` isn't allowed within type [E0562] fn main() { let _in_local_variable: impl Fn() = || {}; - //~^ ERROR `impl Trait` not allowed within variable binding [E0562] + //~^ ERROR `impl Trait` isn't allowed within variable binding [E0562] let _in_return_in_local_variable = || -> impl Fn() { || {} }; - //~^ ERROR `impl Trait` not allowed within closure return [E0562] + //~^ ERROR `impl Trait` isn't allowed within closure return [E0562] } // Add tests for issue-104526 diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index a6234d5b4ef79..24368e7f0e254 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -43,109 +43,109 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` not allowed within `fn` pointer param +error[E0562]: `impl Trait` isn't allowed within `fn` pointer param --> $DIR/where-allowed.rs:17:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `fn` pointer return +error[E0562]: `impl Trait` isn't allowed within `fn` pointer return --> $DIR/where-allowed.rs:21:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `fn` pointer param +error[E0562]: `impl Trait` isn't allowed within `fn` pointer param --> $DIR/where-allowed.rs:25:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `fn` pointer return +error[E0562]: `impl Trait` isn't allowed within `fn` pointer return --> $DIR/where-allowed.rs:29:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait param +error[E0562]: `impl Trait` isn't allowed within `Fn` trait param --> $DIR/where-allowed.rs:33:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait return +error[E0562]: `impl Trait` isn't allowed within `Fn` trait return --> $DIR/where-allowed.rs:37:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait param +error[E0562]: `impl Trait` isn't allowed within `Fn` trait param --> $DIR/where-allowed.rs:41:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait param +error[E0562]: `impl Trait` isn't allowed within `Fn` trait param --> $DIR/where-allowed.rs:48:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait return +error[E0562]: `impl Trait` isn't allowed within `Fn` trait return --> $DIR/where-allowed.rs:53:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait param +error[E0562]: `impl Trait` isn't allowed within `Fn` trait param --> $DIR/where-allowed.rs:57:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait param +error[E0562]: `impl Trait` isn't allowed within `Fn` trait param --> $DIR/where-allowed.rs:65:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait return +error[E0562]: `impl Trait` isn't allowed within `Fn` trait return --> $DIR/where-allowed.rs:69:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:82:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within path +error[E0562]: `impl Trait` isn't allowed within path --> $DIR/where-allowed.rs:86:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:90:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:95:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:97:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within trait method return +error[E0562]: `impl Trait` isn't allowed within trait method return --> $DIR/where-allowed.rs:108:23 | LL | fn in_return() -> impl Debug; @@ -154,7 +154,7 @@ LL | fn in_return() -> impl Debug; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` not allowed within `impl` method return +error[E0562]: `impl Trait` isn't allowed within `impl` method return --> $DIR/where-allowed.rs:125:34 | LL | fn in_trait_impl_return() -> impl Debug { () } @@ -163,103 +163,103 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` not allowed within `extern fn` param +error[E0562]: `impl Trait` isn't allowed within `extern fn` param --> $DIR/where-allowed.rs:138:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `extern fn` return +error[E0562]: `impl Trait` isn't allowed within `extern fn` return --> $DIR/where-allowed.rs:141:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `fn` pointer return +error[E0562]: `impl Trait` isn't allowed within `fn` pointer return --> $DIR/where-allowed.rs:157:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within trait +error[E0562]: `impl Trait` isn't allowed within trait --> $DIR/where-allowed.rs:162:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:167:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:172:6 | LL | impl impl Debug { | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:178:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait param +error[E0562]: `impl Trait` isn't allowed within `Fn` trait param --> $DIR/where-allowed.rs:202:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within `Fn` trait return +error[E0562]: `impl Trait` isn't allowed within `Fn` trait return --> $DIR/where-allowed.rs:209:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:215:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:219:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:223:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:227:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:231:11 | LL | impl T {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within type +error[E0562]: `impl Trait` isn't allowed within type --> $DIR/where-allowed.rs:238:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within variable binding +error[E0562]: `impl Trait` isn't allowed within variable binding --> $DIR/where-allowed.rs:244:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ -error[E0562]: `impl Trait` not allowed within closure return +error[E0562]: `impl Trait` isn't allowed within closure return --> $DIR/where-allowed.rs:246:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; diff --git a/src/test/ui/issues/issue-47715.rs b/src/test/ui/issues/issue-47715.rs index 5c80afe641ec5..72248b10e53df 100644 --- a/src/test/ui/issues/issue-47715.rs +++ b/src/test/ui/issues/issue-47715.rs @@ -7,22 +7,22 @@ trait Iterable { } struct Container> { - //~^ ERROR `impl Trait` not allowed within generic [E0562] + //~^ ERROR `impl Trait` isn't allowed within generic [E0562] field: T } enum Enum> { - //~^ ERROR `impl Trait` not allowed within generic [E0562] + //~^ ERROR `impl Trait` isn't allowed within generic [E0562] A(T), } union Union + Copy> { - //~^ ERROR `impl Trait` not allowed within generic [E0562] + //~^ ERROR `impl Trait` isn't allowed within generic [E0562] x: T, } type Type> = T; -//~^ ERROR `impl Trait` not allowed within generic [E0562] +//~^ ERROR `impl Trait` isn't allowed within generic [E0562] fn main() { } diff --git a/src/test/ui/issues/issue-47715.stderr b/src/test/ui/issues/issue-47715.stderr index 55deda240bab9..0e6df5ad9c205 100644 --- a/src/test/ui/issues/issue-47715.stderr +++ b/src/test/ui/issues/issue-47715.stderr @@ -1,22 +1,22 @@ -error[E0562]: `impl Trait` not allowed within generic +error[E0562]: `impl Trait` isn't allowed within generic --> $DIR/issue-47715.rs:9:37 | LL | struct Container> { | ^^^^^^^^ -error[E0562]: `impl Trait` not allowed within generic +error[E0562]: `impl Trait` isn't allowed within generic --> $DIR/issue-47715.rs:14:30 | LL | enum Enum> { | ^^^^^^^^ -error[E0562]: `impl Trait` not allowed within generic +error[E0562]: `impl Trait` isn't allowed within generic --> $DIR/issue-47715.rs:19:32 | LL | union Union + Copy> { | ^^^^^^^^ -error[E0562]: `impl Trait` not allowed within generic +error[E0562]: `impl Trait` isn't allowed within generic --> $DIR/issue-47715.rs:24:30 | LL | type Type> = T; diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs index 0bc8c0a75e861..53599a0534b58 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs @@ -4,7 +4,7 @@ // FIXME: this is ruled out for now but should work type Foo = fn() -> impl Send; -//~^ ERROR: `impl Trait` not allowed within `fn` pointer return [E0562] +//~^ ERROR: `impl Trait` isn't allowed within `fn` pointer return [E0562] fn make_foo() -> Foo { || 15 diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr index 2b69acd112554..2645e80d707c6 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` not allowed within `fn` pointer return +error[E0562]: `impl Trait` isn't allowed within `fn` pointer return --> $DIR/type-alias-impl-trait-fn-type.rs:6:20 | LL | type Foo = fn() -> impl Send;