From 1e7db2cd198dbd94e8842c6571a4cf64a92fef19 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 19 May 2024 11:08:21 -0300 Subject: [PATCH 1/2] Add tests for unchecked region constraints for opaque types in dead code --- tests/ui/borrowck/opaque-types-deadcode.rs | 32 +++++++++++++++++++ .../ui/borrowck/opaque-types-deadcode.stderr | 8 +++++ 2 files changed, 40 insertions(+) create mode 100644 tests/ui/borrowck/opaque-types-deadcode.rs create mode 100644 tests/ui/borrowck/opaque-types-deadcode.stderr diff --git a/tests/ui/borrowck/opaque-types-deadcode.rs b/tests/ui/borrowck/opaque-types-deadcode.rs new file mode 100644 index 0000000000000..b8213997b25ad --- /dev/null +++ b/tests/ui/borrowck/opaque-types-deadcode.rs @@ -0,0 +1,32 @@ +//@ compile-flags:-Zverbose-internals + +#![feature(rustc_attrs)] +#![rustc_hidden_type_of_opaques] + +trait CallMeMaybe<'a, 'b> { + fn mk() -> Self; + fn subtype(self, x: &'b T) -> &'a T; +} + +struct Foo<'a, 'b: 'a>(&'a (), &'b ()); +impl<'a, 'b> CallMeMaybe<'a, 'b> for Foo<'a, 'b> { + fn mk() -> Self { + Foo(&(), &()) + } + + fn subtype(self, x: &'b T) -> &'a T { + x + } +} + +fn good_bye() -> ! { + panic!(); +} + +fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> { + //~^ ERROR: Foo<'{erased}, '{erased}> + good_bye(); + Foo(&(), &()) +} + +fn main() {} diff --git a/tests/ui/borrowck/opaque-types-deadcode.stderr b/tests/ui/borrowck/opaque-types-deadcode.stderr new file mode 100644 index 0000000000000..8b1cf8d3f6686 --- /dev/null +++ b/tests/ui/borrowck/opaque-types-deadcode.stderr @@ -0,0 +1,8 @@ +error: Foo<'{erased}, '{erased}> + --> $DIR/opaque-types-deadcode.rs:26:25 + | +LL | fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + From c130bfb4e596c1d5493ddef24c0a562c09e1ef2f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 19 May 2024 11:30:12 -0300 Subject: [PATCH 2/2] If MIR doesn't define the opaque also fail for RPITs --- compiler/rustc_hir_analysis/messages.ftl | 2 + .../src/collect/type_of/opaque.rs | 17 +-- compiler/rustc_hir_analysis/src/errors.rs | 7 ++ tests/ui/borrowck/opaque-types-deadcode.rs | 3 +- .../ui/borrowck/opaque-types-deadcode.stderr | 10 +- tests/ui/delegation/not-supported.rs | 2 + tests/ui/delegation/not-supported.stderr | 42 ++++--- tests/ui/impl-trait/divergence.rs | 3 +- tests/ui/impl-trait/divergence.stderr | 8 ++ tests/ui/impl-trait/impl-fn-hrtb-bounds.rs | 1 + .../ui/impl-trait/impl-fn-hrtb-bounds.stderr | 8 +- .../impl-trait/impl-fn-parsing-ambiguities.rs | 1 + .../impl-fn-parsing-ambiguities.stderr | 8 +- tests/ui/impl-trait/impl_fn_associativity.rs | 5 +- .../impl-trait/impl_fn_associativity.stderr | 26 +++++ tests/ui/impl-trait/impl_trait_projections.rs | 14 ++- .../impl-trait/impl_trait_projections.stderr | 34 +++--- .../in-trait/opaque-and-lifetime-mismatch.rs | 1 + .../opaque-and-lifetime-mismatch.stderr | 8 +- .../in-trait/sibling-function-constraint.rs | 1 + .../sibling-function-constraint.stderr | 8 +- tests/ui/impl-trait/issues/issue-77987.rs | 3 +- tests/ui/impl-trait/issues/issue-77987.stderr | 8 ++ tests/ui/impl-trait/nested-rpit-hrtb.rs | 1 + tests/ui/impl-trait/nested-rpit-hrtb.stderr | 20 ++-- tests/ui/impl-trait/nested_impl_trait.rs | 25 ++-- tests/ui/impl-trait/nested_impl_trait.stderr | 32 ++--- .../recursive-impl-trait-type-direct.rs | 3 +- .../recursive-impl-trait-type-direct.stderr | 8 ++ tests/ui/impl-trait/rpit/early_bound.rs | 1 + tests/ui/impl-trait/rpit/early_bound.stderr | 12 +- tests/ui/impl-trait/stranded-opaque.rs | 3 +- tests/ui/impl-trait/stranded-opaque.stderr | 8 +- tests/ui/impl-trait/trait_resolution.rs | 3 +- tests/ui/impl-trait/trait_resolution.stderr | 8 ++ tests/ui/impl-trait/where-allowed.rs | 1 + tests/ui/impl-trait/where-allowed.stderr | 110 +++++++++--------- tests/ui/lint/unused/unused-supertrait.rs | 2 +- tests/ui/lint/unused/unused-supertrait.stderr | 15 +-- tests/ui/never_type/impl_trait_fallback.rs | 3 +- .../ui/never_type/impl_trait_fallback.stderr | 8 ++ .../ui/typeck/typeck_type_placeholder_item.rs | 1 + .../typeck_type_placeholder_item.stderr | 64 +++++----- 43 files changed, 355 insertions(+), 193 deletions(-) create mode 100644 tests/ui/impl-trait/divergence.stderr create mode 100644 tests/ui/impl-trait/impl_fn_associativity.stderr create mode 100644 tests/ui/impl-trait/issues/issue-77987.stderr create mode 100644 tests/ui/impl-trait/recursive-impl-trait-type-direct.stderr create mode 100644 tests/ui/impl-trait/trait_resolution.stderr create mode 100644 tests/ui/never_type/impl_trait_fallback.stderr diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index 3edea0191faf1..74ffbe3fe172f 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -512,6 +512,8 @@ hir_analysis_typeof_reserved_keyword_used = hir_analysis_unconstrained_opaque_type = unconstrained opaque type .note = `{$name}` must be used in combination with a concrete type within the same {$what} +hir_analysis_undefined_opaque_type = undefined opaque type + hir_analysis_unnamed_fields_repr_field_defined = unnamed field defined here hir_analysis_unnamed_fields_repr_field_missing_repr_c = diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs index 1bec8c496ad1e..736ce1563cfc8 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs @@ -8,7 +8,7 @@ use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::{sym, ErrorGuaranteed, DUMMY_SP}; -use crate::errors::{TaitForwardCompat, TypeOf, UnconstrainedOpaqueType}; +use crate::errors::{TaitForwardCompat, TypeOf, UnconstrainedOpaqueType, UndefinedOpaqueType}; pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> { let mut res = Ok(()); @@ -389,18 +389,9 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>( // the `concrete_opaque_types` table. Ty::new_error(tcx, guar) } else { - // Fall back to the RPIT we inferred during HIR typeck - if let Some(hir_opaque_ty) = hir_opaque_ty { - hir_opaque_ty.ty - } else { - // We failed to resolve the opaque type or it - // resolves to itself. We interpret this as the - // no values of the hidden type ever being constructed, - // so we can just make the hidden type be `!`. - // For backwards compatibility reasons, we fall back to - // `()` until we the diverging default is changed. - Ty::new_diverging_default(tcx) - } + // Error if we couldn't define the RPIT during MIR borrowck + let err = tcx.dcx().emit_err(UndefinedOpaqueType { span: tcx.def_span(def_id) }); + Ty::new_error(tcx, err) } } } diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 1c99713b3ae18..365ba64278728 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -380,6 +380,13 @@ pub struct UnconstrainedOpaqueType { pub what: &'static str, } +#[derive(Diagnostic)] +#[diag(hir_analysis_undefined_opaque_type)] +pub struct UndefinedOpaqueType { + #[primary_span] + pub span: Span, +} + #[derive(Diagnostic)] #[diag(hir_analysis_tait_forward_compat)] #[note] diff --git a/tests/ui/borrowck/opaque-types-deadcode.rs b/tests/ui/borrowck/opaque-types-deadcode.rs index b8213997b25ad..8a7bfdd563e95 100644 --- a/tests/ui/borrowck/opaque-types-deadcode.rs +++ b/tests/ui/borrowck/opaque-types-deadcode.rs @@ -24,7 +24,8 @@ fn good_bye() -> ! { } fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> { - //~^ ERROR: Foo<'{erased}, '{erased}> + //~^ ERROR: {type error} + //~| ERROR: undefined opaque type good_bye(); Foo(&(), &()) } diff --git a/tests/ui/borrowck/opaque-types-deadcode.stderr b/tests/ui/borrowck/opaque-types-deadcode.stderr index 8b1cf8d3f6686..bff7119f07db9 100644 --- a/tests/ui/borrowck/opaque-types-deadcode.stderr +++ b/tests/ui/borrowck/opaque-types-deadcode.stderr @@ -1,8 +1,14 @@ -error: Foo<'{erased}, '{erased}> +error: undefined opaque type --> $DIR/opaque-types-deadcode.rs:26:25 | LL | fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: {type error} + --> $DIR/opaque-types-deadcode.rs:26:25 + | +LL | fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/not-supported.rs b/tests/ui/delegation/not-supported.rs index 5f78de97638b5..3cfb55163c483 100644 --- a/tests/ui/delegation/not-supported.rs +++ b/tests/ui/delegation/not-supported.rs @@ -70,12 +70,14 @@ mod opaque { pub fn opaque_arg(_: impl Trait) -> i32 { 0 } pub fn opaque_ret() -> impl Trait { unimplemented!() } + //~^ ERROR undefined opaque type } reuse to_reuse::opaque_arg; //~^ ERROR delegation with early bound generics is not supported yet trait ToReuse { fn opaque_ret() -> impl Trait { unimplemented!() } + //~^ ERROR undefined opaque type } // FIXME: Inherited `impl Trait`s create query cycles when used inside trait impls. diff --git a/tests/ui/delegation/not-supported.stderr b/tests/ui/delegation/not-supported.stderr index e2cb04f977b1e..4e5998ff9deb4 100644 --- a/tests/ui/delegation/not-supported.stderr +++ b/tests/ui/delegation/not-supported.stderr @@ -107,7 +107,7 @@ LL | reuse Trait::foo2 { &self.0 } | ^^^^ error: delegation with early bound generics is not supported yet - --> $DIR/not-supported.rs:74:21 + --> $DIR/not-supported.rs:75:21 | LL | pub fn opaque_arg(_: impl Trait) -> i32 { 0 } | --------------------------------------- callee defined here @@ -115,46 +115,58 @@ LL | pub fn opaque_arg(_: impl Trait) -> i32 { 0 } LL | reuse to_reuse::opaque_arg; | ^^^^^^^^^^ -error[E0391]: cycle detected when computing type of `opaque::::{synthetic#0}` - --> $DIR/not-supported.rs:83:25 +error: undefined opaque type + --> $DIR/not-supported.rs:79:28 + | +LL | fn opaque_ret() -> impl Trait { unimplemented!() } + | ^^^^^^^^^^ + +error[E0391]: cycle detected when computing type of `opaque::::{synthetic#0}` + --> $DIR/not-supported.rs:85:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/not-supported.rs:83:25 + --> $DIR/not-supported.rs:85:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::::{synthetic#0}`, completing the cycle -note: cycle used when checking that `opaque::` is well-formed - --> $DIR/not-supported.rs:82:5 + = note: ...which again requires computing type of `opaque::::{synthetic#0}`, completing the cycle +note: cycle used when checking that `opaque::` is well-formed + --> $DIR/not-supported.rs:84:5 | LL | impl ToReuse for u8 { | ^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0391]: cycle detected when computing type of `opaque::::{synthetic#0}` - --> $DIR/not-supported.rs:86:24 +error: undefined opaque type + --> $DIR/not-supported.rs:72:32 + | +LL | pub fn opaque_ret() -> impl Trait { unimplemented!() } + | ^^^^^^^^^^ + +error[E0391]: cycle detected when computing type of `opaque::::{synthetic#0}` + --> $DIR/not-supported.rs:88:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/not-supported.rs:86:24 + --> $DIR/not-supported.rs:88:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::::{synthetic#0}`, completing the cycle -note: cycle used when checking that `opaque::` is well-formed - --> $DIR/not-supported.rs:85:5 + = note: ...which again requires computing type of `opaque::::{synthetic#0}`, completing the cycle +note: cycle used when checking that `opaque::` is well-formed + --> $DIR/not-supported.rs:87:5 | LL | impl ToReuse for u16 { | ^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: recursive delegation is not supported yet - --> $DIR/not-supported.rs:99:22 + --> $DIR/not-supported.rs:101:22 | LL | pub reuse to_reuse2::foo; | --- callee defined here @@ -162,7 +174,7 @@ LL | pub reuse to_reuse2::foo; LL | reuse to_reuse1::foo; | ^^^ -error: aborting due to 16 previous errors +error: aborting due to 18 previous errors Some errors have detailed explanations: E0049, E0195, E0391. For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/divergence.rs b/tests/ui/impl-trait/divergence.rs index c243299a51697..2ff6bd3096b18 100644 --- a/tests/ui/impl-trait/divergence.rs +++ b/tests/ui/impl-trait/divergence.rs @@ -1,6 +1,5 @@ -//@ check-pass - fn foo() -> impl MyTrait { + //~^ ERROR undefined opaque type panic!(); MyStruct } diff --git a/tests/ui/impl-trait/divergence.stderr b/tests/ui/impl-trait/divergence.stderr new file mode 100644 index 0000000000000..42089813e5d5e --- /dev/null +++ b/tests/ui/impl-trait/divergence.stderr @@ -0,0 +1,8 @@ +error: undefined opaque type + --> $DIR/divergence.rs:1:13 + | +LL | fn foo() -> impl MyTrait { + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs b/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs index da7530b4e7a8c..e660a98b50ce1 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -18,6 +18,7 @@ fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { fn d() -> impl Fn() -> (impl Debug + '_) { //~^ ERROR missing lifetime specifier + //~| ERROR undefined opaque type || () } diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 7d108b30b76ed..5ad76461aaf86 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -46,7 +46,13 @@ note: lifetime declared here LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { | ^^ -error: aborting due to 4 previous errors +error: undefined opaque type + --> $DIR/impl-fn-hrtb-bounds.rs:19:25 + | +LL | fn d() -> impl Fn() -> (impl Debug + '_) { + | ^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors Some errors have detailed explanations: E0106, E0657. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs index 7679b7ec478f9..e922acb168db3 100644 --- a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs +++ b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs @@ -9,6 +9,7 @@ fn a() -> impl Fn(&u8) -> impl Debug + '_ { fn b() -> impl Fn() -> impl Debug + Send { //~^ ERROR ambiguous `+` in a type + //~| ERROR undefined opaque type || () } diff --git a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr index e0955faac7ca0..5b63b04ba9610 100644 --- a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr +++ b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -22,6 +22,12 @@ note: lifetime declared here LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { | ^ -error: aborting due to 3 previous errors +error: undefined opaque type + --> $DIR/impl-fn-parsing-ambiguities.rs:10:24 + | +LL | fn b() -> impl Fn() -> impl Debug + Send { + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/impl_fn_associativity.rs b/tests/ui/impl-trait/impl_fn_associativity.rs index ad37a96805763..49becd6a39502 100644 --- a/tests/ui/impl-trait/impl_fn_associativity.rs +++ b/tests/ui/impl-trait/impl_fn_associativity.rs @@ -1,16 +1,19 @@ -//@ run-pass #![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; fn f_debug() -> impl Fn() -> impl Debug { + //~^ ERROR undefined opaque type || () } fn ff_debug() -> impl Fn() -> impl Fn() -> impl Debug { + //~^ ERROR undefined opaque type + //~| ERROR undefined opaque type || f_debug() } fn multi() -> impl Fn() -> (impl Debug + Send) { + //~^ ERROR undefined opaque type || () } diff --git a/tests/ui/impl-trait/impl_fn_associativity.stderr b/tests/ui/impl-trait/impl_fn_associativity.stderr new file mode 100644 index 0000000000000..a11c9fea195d2 --- /dev/null +++ b/tests/ui/impl-trait/impl_fn_associativity.stderr @@ -0,0 +1,26 @@ +error: undefined opaque type + --> $DIR/impl_fn_associativity.rs:4:30 + | +LL | fn f_debug() -> impl Fn() -> impl Debug { + | ^^^^^^^^^^ + +error: undefined opaque type + --> $DIR/impl_fn_associativity.rs:9:31 + | +LL | fn ff_debug() -> impl Fn() -> impl Fn() -> impl Debug { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: undefined opaque type + --> $DIR/impl_fn_associativity.rs:9:44 + | +LL | fn ff_debug() -> impl Fn() -> impl Fn() -> impl Debug { + | ^^^^^^^^^^ + +error: undefined opaque type + --> $DIR/impl_fn_associativity.rs:15:29 + | +LL | fn multi() -> impl Fn() -> (impl Debug + Send) { + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/impl-trait/impl_trait_projections.rs b/tests/ui/impl-trait/impl_trait_projections.rs index 365ac85e2f665..8f859cb8b6eb2 100644 --- a/tests/ui/impl-trait/impl_trait_projections.rs +++ b/tests/ui/impl-trait/impl_trait_projections.rs @@ -10,20 +10,21 @@ fn path_parametrized_type_is_allowed() -> option::Option { } fn projection_is_disallowed(x: impl Iterator) -> ::Item { -//~^ ERROR `impl Trait` is not allowed in path parameters -//~| ERROR `impl Trait` is not allowed in path parameters + //~^ ERROR `impl Trait` is not allowed in path parameters + //~| ERROR `impl Trait` is not allowed in path parameters x.next().unwrap() } -fn projection_with_named_trait_is_disallowed(mut x: impl Iterator) - -> ::Item +fn projection_with_named_trait_is_disallowed( + mut x: impl Iterator, +) -> ::Item //~^ ERROR `impl Trait` is not allowed in path parameters { x.next().unwrap() } fn projection_with_named_trait_inside_path_is_disallowed() - -> <::std::ops::Range as Iterator>::Item +-> <::std::ops::Range as Iterator>::Item //~^ ERROR `impl Trait` is not allowed in path parameters //~| ERROR `impl Debug: Step` is not satisfied { @@ -32,8 +33,9 @@ fn projection_with_named_trait_inside_path_is_disallowed() } fn projection_from_impl_trait_inside_dyn_trait_is_disallowed() - -> as Iterator>::Item +-> as Iterator>::Item //~^ ERROR `impl Trait` is not allowed in path parameters +//~| ERROR undefined opaque type { panic!() } diff --git a/tests/ui/impl-trait/impl_trait_projections.stderr b/tests/ui/impl-trait/impl_trait_projections.stderr index d62e3ac4183f5..022b92068de74 100644 --- a/tests/ui/impl-trait/impl_trait_projections.stderr +++ b/tests/ui/impl-trait/impl_trait_projections.stderr @@ -5,22 +5,22 @@ LL | fn projection_is_disallowed(x: impl Iterator) -> ::Item { | ^^^^^^^^^^^^^ error[E0667]: `impl Trait` is not allowed in path parameters - --> $DIR/impl_trait_projections.rs:19:9 + --> $DIR/impl_trait_projections.rs:20:7 | -LL | -> ::Item - | ^^^^^^^^^^^^^ +LL | ) -> ::Item + | ^^^^^^^^^^^^^ error[E0667]: `impl Trait` is not allowed in path parameters - --> $DIR/impl_trait_projections.rs:26:27 + --> $DIR/impl_trait_projections.rs:27:23 | -LL | -> <::std::ops::Range as Iterator>::Item - | ^^^^^^^^^^ +LL | -> <::std::ops::Range as Iterator>::Item + | ^^^^^^^^^^ error[E0667]: `impl Trait` is not allowed in path parameters - --> $DIR/impl_trait_projections.rs:35:29 + --> $DIR/impl_trait_projections.rs:36:25 | -LL | -> as Iterator>::Item - | ^^^^^^^^^^ +LL | -> as Iterator>::Item + | ^^^^^^^^^^ error[E0667]: `impl Trait` is not allowed in path parameters --> $DIR/impl_trait_projections.rs:12:51 @@ -29,10 +29,10 @@ LL | fn projection_is_disallowed(x: impl Iterator) -> ::Item { | ^^^^^^^^^^^^^ error[E0277]: the trait bound `impl Debug: Step` is not satisfied - --> $DIR/impl_trait_projections.rs:26:8 + --> $DIR/impl_trait_projections.rs:27:4 | -LL | -> <::std::ops::Range as Iterator>::Item - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Step` is not implemented for `impl Debug`, which is required by `std::ops::Range: Iterator` +LL | -> <::std::ops::Range as Iterator>::Item + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Step` is not implemented for `impl Debug`, which is required by `std::ops::Range: Iterator` | = help: the following other types implement trait `Step`: Char @@ -47,7 +47,7 @@ LL | -> <::std::ops::Range as Iterator>::Item = note: required for `std::ops::Range` to implement `Iterator` error[E0277]: the trait bound `impl Debug: Step` is not satisfied - --> $DIR/impl_trait_projections.rs:29:1 + --> $DIR/impl_trait_projections.rs:30:1 | LL | / { LL | | @@ -67,7 +67,13 @@ LL | | } and 8 others = note: required for `std::ops::Range` to implement `Iterator` -error: aborting due to 7 previous errors +error: undefined opaque type + --> $DIR/impl_trait_projections.rs:36:25 + | +LL | -> as Iterator>::Item + | ^^^^^^^^^^ + +error: aborting due to 8 previous errors Some errors have detailed explanations: E0277, E0667. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.rs b/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.rs index 21e2fda1c3af9..7b10db7bfe3fc 100644 --- a/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.rs @@ -24,6 +24,7 @@ impl Bar for () { fn foo() -> Wrapper { //~^ ERROR missing lifetime specifier //~| ERROR struct takes 0 generic arguments but 1 generic argument was supplied + //~| ERROR undefined opaque type Wrapper(&()) } } diff --git a/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.stderr b/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.stderr index d7fc40fa3426f..4f1802fe4daae 100644 --- a/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.stderr @@ -102,7 +102,13 @@ note: struct defined here, with 0 generic parameters LL | struct Wrapper<'rom>(&'rom ()); | ^^^^^^^ -error: aborting due to 8 previous errors +error: undefined opaque type + --> $DIR/opaque-and-lifetime-mismatch.rs:24:25 + | +LL | fn foo() -> Wrapper { + | ^^^^^^^^^^ + +error: aborting due to 9 previous errors Some errors have detailed explanations: E0053, E0106, E0107. For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs b/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs index fe162e6cf801e..c8bec5ea3bf94 100644 --- a/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs +++ b/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs @@ -14,6 +14,7 @@ impl Trait for () { } fn bar() -> impl Sized { + //~^ ERROR undefined opaque type loop {} } } diff --git a/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr b/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr index b8ac826adaa9b..e3acb8feb27bf 100644 --- a/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr +++ b/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr @@ -1,3 +1,9 @@ +error: undefined opaque type + --> $DIR/sibling-function-constraint.rs:16:17 + | +LL | fn bar() -> impl Sized { + | ^^^^^^^^^^ + error[E0308]: mismatched types --> $DIR/sibling-function-constraint.rs:12:25 | @@ -12,6 +18,6 @@ LL | fn bar() -> impl Sized { = note: expected struct `String` found opaque type `impl Sized` -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/issues/issue-77987.rs b/tests/ui/impl-trait/issues/issue-77987.rs index b77f993effce1..189733e80d056 100644 --- a/tests/ui/impl-trait/issues/issue-77987.rs +++ b/tests/ui/impl-trait/issues/issue-77987.rs @@ -1,7 +1,5 @@ #![feature(type_alias_impl_trait)] -//@ check-pass - trait Foo {} impl Foo for U {} @@ -14,6 +12,7 @@ fn infer_scope() -> Scope { #[allow(unused)] fn ice() -> impl Foo +//~^ ERROR undefined opaque type { loop {} } diff --git a/tests/ui/impl-trait/issues/issue-77987.stderr b/tests/ui/impl-trait/issues/issue-77987.stderr new file mode 100644 index 0000000000000..391b6c5ecfc41 --- /dev/null +++ b/tests/ui/impl-trait/issues/issue-77987.stderr @@ -0,0 +1,8 @@ +error: undefined opaque type + --> $DIR/issue-77987.rs:14:13 + | +LL | fn ice() -> impl Foo + | ^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.rs b/tests/ui/impl-trait/nested-rpit-hrtb.rs index 9b18aceb4a731..6f1d59bd1fb39 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.rs +++ b/tests/ui/impl-trait/nested-rpit-hrtb.rs @@ -35,6 +35,7 @@ fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a> {} fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` +//~| ERROR undefined opaque type // This should resolve. fn one_hrtb_mention_fn_trait_param<'b>() -> impl for<'a> Foo<'a, Assoc = impl Qux<'b>> {} diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.stderr b/tests/ui/impl-trait/nested-rpit-hrtb.stderr index 2fa036f35fab3..577bb9d06200f 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.stderr +++ b/tests/ui/impl-trait/nested-rpit-hrtb.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/nested-rpit-hrtb.rs:57:77 + --> $DIR/nested-rpit-hrtb.rs:58:77 | LL | fn two_htrb_outlives() -> impl for<'a> Foo<'a, Assoc = impl for<'b> Sized + 'b> {} | ^^ undeclared lifetime @@ -15,7 +15,7 @@ LL | fn two_htrb_outlives<'b>() -> impl for<'a> Foo<'a, Assoc = impl for<'b> Siz | ++++ error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/nested-rpit-hrtb.rs:65:82 + --> $DIR/nested-rpit-hrtb.rs:66:82 | LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Sized + 'b> {} | ^^ undeclared lifetime @@ -86,8 +86,14 @@ note: lifetime declared here LL | fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} | ^^ +error: undefined opaque type + --> $DIR/nested-rpit-hrtb.rs:36:64 + | +LL | fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} + | ^^^^^^^^^^^^ + error[E0277]: the trait bound `for<'a> &'a (): Qux<'b>` is not satisfied - --> $DIR/nested-rpit-hrtb.rs:46:79 + --> $DIR/nested-rpit-hrtb.rs:47:79 | LL | fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Qux<'b>> {} | ^^^^^^^^^^^^ the trait `for<'a> Qux<'b>` is not implemented for `&'a ()` @@ -96,7 +102,7 @@ LL | fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = help: for that trait implementation, expected `()`, found `&'a ()` error: implementation of `Bar` is not general enough - --> $DIR/nested-rpit-hrtb.rs:50:93 + --> $DIR/nested-rpit-hrtb.rs:51:93 | LL | fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'b> {} | ^^ implementation of `Bar` is not general enough @@ -105,7 +111,7 @@ LL | fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = = note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0` error[E0277]: the trait bound `for<'a, 'b> &'a (): Qux<'b>` is not satisfied - --> $DIR/nested-rpit-hrtb.rs:61:64 + --> $DIR/nested-rpit-hrtb.rs:62:64 | LL | fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Qux<'b>> {} | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Qux<'b>` is not implemented for `&'a ()` @@ -114,7 +120,7 @@ LL | fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> = help: for that trait implementation, expected `()`, found `&'a ()` error: implementation of `Bar` is not general enough - --> $DIR/nested-rpit-hrtb.rs:65:86 + --> $DIR/nested-rpit-hrtb.rs:66:86 | LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Sized + 'b> {} | ^^ implementation of `Bar` is not general enough @@ -122,7 +128,7 @@ LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Si = note: `()` must implement `Bar<'a>` = note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0` -error: aborting due to 11 previous errors +error: aborting due to 12 previous errors Some errors have detailed explanations: E0261, E0277, E0657. For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/impl-trait/nested_impl_trait.rs b/tests/ui/impl-trait/nested_impl_trait.rs index 502b2af2bc660..b9ca3dc968ba7 100644 --- a/tests/ui/impl-trait/nested_impl_trait.rs +++ b/tests/ui/impl-trait/nested_impl_trait.rs @@ -1,31 +1,38 @@ #![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; -fn fine(x: impl Into) -> impl Into { x } +fn fine(x: impl Into) -> impl Into { + x +} -fn bad_in_ret_position(x: impl Into) -> impl Into { x } -//~^ ERROR nested `impl Trait` is not allowed -//~| ERROR the trait bound `impl Into: Into` is not satisfied +fn bad_in_ret_position(x: impl Into) -> impl Into { + //~^ ERROR nested `impl Trait` is not allowed + //~| ERROR the trait bound `impl Into: Into` is not satisfied + x +} fn bad_in_fn_syntax(x: fn() -> impl Into) {} //~^ ERROR nested `impl Trait` is not allowed //~| `impl Trait` is not allowed in `fn` pointer -fn bad_in_arg_position(_: impl Into) { } +fn bad_in_arg_position(_: impl Into) {} //~^ ERROR nested `impl Trait` is not allowed struct X; impl X { - fn bad(x: impl Into) -> impl Into { x } - //~^ ERROR nested `impl Trait` is not allowed - //~| ERROR the trait bound `impl Into: Into` is not satisfied + fn bad(x: impl Into) -> impl Into { + //~^ ERROR nested `impl Trait` is not allowed + //~| ERROR the trait bound `impl Into: Into` is not satisfied + x + } } -fn allowed_in_assoc_type() -> impl Iterator { +fn allowed_in_assoc_type() -> impl Iterator { vec![|| println!("woot")].into_iter() } fn allowed_in_ret_type() -> impl Fn() -> impl Into { + //~^ ERROR undefined opaque type || 5u8 } diff --git a/tests/ui/impl-trait/nested_impl_trait.stderr b/tests/ui/impl-trait/nested_impl_trait.stderr index 1f9a2a5e9d600..c78a564eaf9ea 100644 --- a/tests/ui/impl-trait/nested_impl_trait.stderr +++ b/tests/ui/impl-trait/nested_impl_trait.stderr @@ -1,14 +1,14 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:6:56 + --> $DIR/nested_impl_trait.rs:8:56 | -LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } +LL | fn bad_in_ret_position(x: impl Into) -> impl Into { | ----------^^^^^^^^^^- | | | | | nested `impl Trait` here | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:10:42 + --> $DIR/nested_impl_trait.rs:14:42 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} | ----------^^^^^^^^^^- @@ -17,25 +17,25 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:14:37 + --> $DIR/nested_impl_trait.rs:18:37 | -LL | fn bad_in_arg_position(_: impl Into) { } +LL | fn bad_in_arg_position(_: impl Into) {} | ----------^^^^^^^^^^- | | | | | nested `impl Trait` here | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:19:44 + --> $DIR/nested_impl_trait.rs:23:44 | -LL | fn bad(x: impl Into) -> impl Into { x } +LL | fn bad(x: impl Into) -> impl Into { | ----------^^^^^^^^^^- | | | | | nested `impl Trait` here | outer `impl Trait` error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/nested_impl_trait.rs:10:32 + --> $DIR/nested_impl_trait.rs:14:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -43,24 +43,30 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0277]: the trait bound `impl Into: Into` is not satisfied - --> $DIR/nested_impl_trait.rs:6:46 + --> $DIR/nested_impl_trait.rs:8:46 | -LL | fn bad_in_ret_position(x: impl Into) -> impl Into { x } +LL | fn bad_in_ret_position(x: impl Into) -> impl Into { | ^^^^^^^^^^^^^^^^^^^^^ the trait `From>` is not implemented for `impl Into`, which is required by `impl Into: Into` | = help: the trait `Into` is implemented for `T` = note: required for `impl Into` to implement `Into` error[E0277]: the trait bound `impl Into: Into` is not satisfied - --> $DIR/nested_impl_trait.rs:19:34 + --> $DIR/nested_impl_trait.rs:23:34 | -LL | fn bad(x: impl Into) -> impl Into { x } +LL | fn bad(x: impl Into) -> impl Into { | ^^^^^^^^^^^^^^^^^^^^^ the trait `From>` is not implemented for `impl Into`, which is required by `impl Into: Into` | = help: the trait `Into` is implemented for `T` = note: required for `impl Into` to implement `Into` -error: aborting due to 7 previous errors +error: undefined opaque type + --> $DIR/nested_impl_trait.rs:34:42 + | +LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into { + | ^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors Some errors have detailed explanations: E0277, E0562, E0666. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-direct.rs b/tests/ui/impl-trait/recursive-impl-trait-type-direct.rs index 1d82f89d7a1a3..82d3140fa96e1 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-direct.rs +++ b/tests/ui/impl-trait/recursive-impl-trait-type-direct.rs @@ -1,8 +1,7 @@ -//@ check-pass - #![allow(unconditional_recursion)] fn test() -> impl Sized { + //~^ ERROR undefined opaque type test() } diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-direct.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-direct.stderr new file mode 100644 index 0000000000000..c30946f3861c1 --- /dev/null +++ b/tests/ui/impl-trait/recursive-impl-trait-type-direct.stderr @@ -0,0 +1,8 @@ +error: undefined opaque type + --> $DIR/recursive-impl-trait-type-direct.rs:3:14 + | +LL | fn test() -> impl Sized { + | ^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/rpit/early_bound.rs b/tests/ui/impl-trait/rpit/early_bound.rs index 005bcea59f243..45119d9749f1f 100644 --- a/tests/ui/impl-trait/rpit/early_bound.rs +++ b/tests/ui/impl-trait/rpit/early_bound.rs @@ -2,6 +2,7 @@ use std::convert::identity; fn test<'a: 'a>(n: bool) -> impl Sized + 'a { //~^ ERROR concrete type differs from previous defining opaque type use + //~| ERROR undefined opaque type let true = n else { loop {} }; let _ = || { let _ = identity::<&'a ()>(test(false)); diff --git a/tests/ui/impl-trait/rpit/early_bound.stderr b/tests/ui/impl-trait/rpit/early_bound.stderr index b0c7bd4199cc2..7fc5c596cc1f7 100644 --- a/tests/ui/impl-trait/rpit/early_bound.stderr +++ b/tests/ui/impl-trait/rpit/early_bound.stderr @@ -1,5 +1,5 @@ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/early_bound.rs:7:17 + --> $DIR/early_bound.rs:8:17 | LL | fn test<'a: 'a>(n: bool) -> impl Sized + 'a { | -- this generic parameter must be used with a generic lifetime parameter @@ -7,6 +7,12 @@ LL | fn test<'a: 'a>(n: bool) -> impl Sized + 'a { LL | let _ = identity::<&'a ()>(test(false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: undefined opaque type + --> $DIR/early_bound.rs:3:29 + | +LL | fn test<'a: 'a>(n: bool) -> impl Sized + 'a { + | ^^^^^^^^^^^^^^^ + error: concrete type differs from previous defining opaque type use --> $DIR/early_bound.rs:3:29 | @@ -14,11 +20,11 @@ LL | fn test<'a: 'a>(n: bool) -> impl Sized + 'a { | ^^^^^^^^^^^^^^^ expected `&()`, got `()` | note: previous use here - --> $DIR/early_bound.rs:7:36 + --> $DIR/early_bound.rs:8:36 | LL | let _ = identity::<&'a ()>(test(false)); | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/stranded-opaque.rs b/tests/ui/impl-trait/stranded-opaque.rs index 6ce5cbd3b555a..20181c0d78313 100644 --- a/tests/ui/impl-trait/stranded-opaque.rs +++ b/tests/ui/impl-trait/stranded-opaque.rs @@ -8,7 +8,8 @@ impl Trait for i32 {} fn produce() -> impl Trait { //~^ ERROR associated type `Assoc` not found for `Trait` //~| ERROR associated type `Assoc` not found for `Trait` + //~| ERROR undefined opaque type 16 } -fn main () {} +fn main() {} diff --git a/tests/ui/impl-trait/stranded-opaque.stderr b/tests/ui/impl-trait/stranded-opaque.stderr index 5bea3e2af6b30..6eb06d825167b 100644 --- a/tests/ui/impl-trait/stranded-opaque.stderr +++ b/tests/ui/impl-trait/stranded-opaque.stderr @@ -12,6 +12,12 @@ LL | fn produce() -> impl Trait { | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 2 previous errors +error: undefined opaque type + --> $DIR/stranded-opaque.rs:8:39 + | +LL | fn produce() -> impl Trait { + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/impl-trait/trait_resolution.rs b/tests/ui/impl-trait/trait_resolution.rs index ee9853b47880f..f2a783e735760 100644 --- a/tests/ui/impl-trait/trait_resolution.rs +++ b/tests/ui/impl-trait/trait_resolution.rs @@ -1,5 +1,3 @@ -//@ check-pass - use std::fmt::Debug; pub struct EventStream { @@ -8,6 +6,7 @@ pub struct EventStream { impl EventStream { fn into_stream(self) -> impl Debug { + //~^ ERROR undefined opaque type unimplemented!() } diff --git a/tests/ui/impl-trait/trait_resolution.stderr b/tests/ui/impl-trait/trait_resolution.stderr new file mode 100644 index 0000000000000..9cea0f65eafb4 --- /dev/null +++ b/tests/ui/impl-trait/trait_resolution.stderr @@ -0,0 +1,8 @@ +error: undefined opaque type + --> $DIR/trait_resolution.rs:8:29 + | +LL | fn into_stream(self) -> impl Debug { + | ^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs index 72ce617693e40..122f5a5c28b9b 100644 --- a/tests/ui/impl-trait/where-allowed.rs +++ b/tests/ui/impl-trait/where-allowed.rs @@ -10,6 +10,7 @@ fn in_parameters(_: impl Debug) { panic!() } // Allowed fn in_return() -> impl Debug { panic!() } +//~^ ERROR undefined opaque type // Allowed fn in_adt_in_parameters(_: Vec) { panic!() } diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index bffe0447f8bb4..080f28e4a6cf5 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:50:51 + --> $DIR/where-allowed.rs:51: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:59:57 + --> $DIR/where-allowed.rs:60: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 associated types is unstable - --> $DIR/where-allowed.rs:122:16 + --> $DIR/where-allowed.rs:123:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | type Out = impl Debug; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:159:23 + --> $DIR/where-allowed.rs:160:23 | LL | type InTypeAlias = impl Debug; | ^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | type InTypeAlias = impl Debug; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:162:39 + --> $DIR/where-allowed.rs:163:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters - --> $DIR/where-allowed.rs:18:40 + --> $DIR/where-allowed.rs:19:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/where-allowed.rs:22:42 + --> $DIR/where-allowed.rs:23:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ @@ -63,7 +63,7 @@ LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters - --> $DIR/where-allowed.rs:26:38 + --> $DIR/where-allowed.rs:27:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/where-allowed.rs:30:40 + --> $DIR/where-allowed.rs:31:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:34:49 + --> $DIR/where-allowed.rs:35:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ @@ -87,7 +87,7 @@ LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:38:51 + --> $DIR/where-allowed.rs:39:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:42:55 + --> $DIR/where-allowed.rs:43:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!( = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:50:51 + --> $DIR/where-allowed.rs:51:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:55:53 + --> $DIR/where-allowed.rs:56:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:59:57 + --> $DIR/where-allowed.rs:60:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:68:38 + --> $DIR/where-allowed.rs:69:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ @@ -135,7 +135,7 @@ LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:72:40 + --> $DIR/where-allowed.rs:73:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ @@ -143,7 +143,7 @@ LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:86:32 + --> $DIR/where-allowed.rs:87:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ @@ -151,7 +151,7 @@ LL | struct InBraceStructField { x: impl Debug } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:90:41 + --> $DIR/where-allowed.rs:91:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ @@ -159,7 +159,7 @@ LL | struct InAdtInBraceStructField { x: Vec } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:94:27 + --> $DIR/where-allowed.rs:95:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | struct InTupleStructField(impl Debug); = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:99:25 + --> $DIR/where-allowed.rs:100:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ @@ -175,7 +175,7 @@ LL | InBraceVariant { x: impl Debug }, = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in field types - --> $DIR/where-allowed.rs:101:20 + --> $DIR/where-allowed.rs:102:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ @@ -183,7 +183,7 @@ LL | InTupleVariant(impl Debug), = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `extern fn` parameters - --> $DIR/where-allowed.rs:143:33 + --> $DIR/where-allowed.rs:144:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ @@ -191,7 +191,7 @@ LL | fn in_foreign_parameters(_: impl Debug); = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `extern fn` return types - --> $DIR/where-allowed.rs:146:31 + --> $DIR/where-allowed.rs:147:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | fn in_foreign_return() -> impl Debug; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in `fn` pointer return types - --> $DIR/where-allowed.rs:162:39 + --> $DIR/where-allowed.rs:163:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ @@ -207,7 +207,7 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in traits - --> $DIR/where-allowed.rs:167:16 + --> $DIR/where-allowed.rs:168:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ @@ -215,7 +215,7 @@ LL | impl PartialEq for () { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in impl headers - --> $DIR/where-allowed.rs:172:24 + --> $DIR/where-allowed.rs:173:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ @@ -223,7 +223,7 @@ LL | impl PartialEq<()> for impl Debug { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in impl headers - --> $DIR/where-allowed.rs:177:6 + --> $DIR/where-allowed.rs:178:6 | LL | impl impl Debug { | ^^^^^^^^^^ @@ -231,7 +231,7 @@ LL | impl impl Debug { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in impl headers - --> $DIR/where-allowed.rs:183:24 + --> $DIR/where-allowed.rs:184:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ @@ -239,7 +239,7 @@ LL | impl InInherentImplAdt { = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in bounds - --> $DIR/where-allowed.rs:189:11 + --> $DIR/where-allowed.rs:190:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ @@ -247,7 +247,7 @@ LL | where impl Debug: Debug = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in bounds - --> $DIR/where-allowed.rs:196:15 + --> $DIR/where-allowed.rs:197:15 | LL | where Vec: Debug | ^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | where Vec: Debug = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in bounds - --> $DIR/where-allowed.rs:203:24 + --> $DIR/where-allowed.rs:204:24 | LL | where T: PartialEq | ^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | where T: PartialEq = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds - --> $DIR/where-allowed.rs:210:17 + --> $DIR/where-allowed.rs:211:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | where T: Fn(impl Debug) = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds - --> $DIR/where-allowed.rs:217:22 + --> $DIR/where-allowed.rs:218:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | where T: Fn() -> impl Debug = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:223:40 + --> $DIR/where-allowed.rs:224:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ @@ -287,7 +287,7 @@ LL | struct InStructGenericParamDefault(T); = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:227:36 + --> $DIR/where-allowed.rs:228:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ @@ -295,7 +295,7 @@ LL | enum InEnumGenericParamDefault { Variant(T) } = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:231:38 + --> $DIR/where-allowed.rs:232:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ @@ -303,7 +303,7 @@ LL | trait InTraitGenericParamDefault {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:235:41 + --> $DIR/where-allowed.rs:236:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ @@ -311,7 +311,7 @@ LL | type InTypeAliasGenericParamDefault = T; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:239:11 + --> $DIR/where-allowed.rs:240:11 | LL | impl T {} | ^^^^^^^^^^ @@ -319,7 +319,7 @@ LL | impl T {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:246:40 + --> $DIR/where-allowed.rs:247:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ @@ -327,7 +327,7 @@ LL | fn in_method_generic_param_default(_: T) {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/where-allowed.rs:252:29 + --> $DIR/where-allowed.rs:253:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ @@ -335,15 +335,21 @@ LL | let _in_local_variable: impl Fn() = || {}; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in closure return types - --> $DIR/where-allowed.rs:254:46 + --> $DIR/where-allowed.rs:255:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods +error: undefined opaque type + --> $DIR/where-allowed.rs:12:19 + | +LL | fn in_return() -> impl Debug { panic!() } + | ^^^^^^^^^^ + error[E0283]: type annotations needed - --> $DIR/where-allowed.rs:46:57 + --> $DIR/where-allowed.rs:47:57 | LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } | ^^^^^^^^^^ cannot infer type @@ -351,7 +357,7 @@ LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic! = note: cannot satisfy `_: Debug` error[E0283]: type annotations needed - --> $DIR/where-allowed.rs:64:46 + --> $DIR/where-allowed.rs:65:46 | LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type @@ -363,7 +369,7 @@ LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { pani where Args: Tuple, F: Fn, A: Allocator, F: ?Sized; error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:239:7 + --> $DIR/where-allowed.rs:240:7 | LL | impl T {} | ^^^^^^^^^^^^^^ @@ -373,7 +379,7 @@ LL | impl T {} = note: `#[deny(invalid_type_param_default)]` on by default error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:239:1 + --> $DIR/where-allowed.rs:240:1 | LL | impl T {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type @@ -381,7 +387,7 @@ LL | impl T {} = note: either implement a trait on it or create a newtype to wrap it instead error[E0599]: no function or associated item named `into_vec` found for slice `[_]` in the current scope - --> $DIR/where-allowed.rs:81:5 + --> $DIR/where-allowed.rs:82:5 | LL | vec![vec![0; 10], vec![12; 7], vec![8; 3]] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `[_]` @@ -391,7 +397,7 @@ help: there is an associated function `to_vec` with a similar name = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0053]: method `in_trait_impl_return` has an incompatible type for trait - --> $DIR/where-allowed.rs:129:34 + --> $DIR/where-allowed.rs:130:34 | LL | type Out = impl Debug; | ---------- the expected opaque type @@ -403,7 +409,7 @@ LL | fn in_trait_impl_return() -> impl Debug { () } | help: change the output type to match the trait: `<() as DummyTrait>::Out` | note: type in trait - --> $DIR/where-allowed.rs:119:34 + --> $DIR/where-allowed.rs:120:34 | LL | fn in_trait_impl_return() -> Self::Out; | ^^^^^^^^^ @@ -412,7 +418,7 @@ LL | fn in_trait_impl_return() -> Self::Out; = note: distinct uses of `impl Trait` result in different opaque types error: unconstrained opaque type - --> $DIR/where-allowed.rs:122:16 + --> $DIR/where-allowed.rs:123:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ @@ -420,7 +426,7 @@ LL | type Out = impl Debug; = note: `Out` must be used in combination with a concrete type within the same impl error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:246:36 + --> $DIR/where-allowed.rs:247:36 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^^^^^ @@ -428,7 +434,7 @@ LL | fn in_method_generic_param_default(_: T) {} = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #36887 -error: aborting due to 50 previous errors +error: aborting due to 51 previous errors Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666. For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/lint/unused/unused-supertrait.rs b/tests/ui/lint/unused/unused-supertrait.rs index 64a8e5204579c..d28f6505b4124 100644 --- a/tests/ui/lint/unused/unused-supertrait.rs +++ b/tests/ui/lint/unused/unused-supertrait.rs @@ -1,11 +1,11 @@ #![deny(unused_must_use)] fn it() -> impl ExactSizeIterator { + //~^ ERROR undefined opaque type let x: Box> = todo!(); x } fn main() { it(); - //~^ ERROR unused implementer of `Iterator` that must be used } diff --git a/tests/ui/lint/unused/unused-supertrait.stderr b/tests/ui/lint/unused/unused-supertrait.stderr index c7ccf30ea24e7..1b7296a21caf3 100644 --- a/tests/ui/lint/unused/unused-supertrait.stderr +++ b/tests/ui/lint/unused/unused-supertrait.stderr @@ -1,15 +1,8 @@ -error: unused implementer of `Iterator` that must be used - --> $DIR/unused-supertrait.rs:9:5 +error: undefined opaque type + --> $DIR/unused-supertrait.rs:3:12 | -LL | it(); - | ^^^^ - | - = note: iterators are lazy and do nothing unless consumed -note: the lint level is defined here - --> $DIR/unused-supertrait.rs:1:9 - | -LL | #![deny(unused_must_use)] - | ^^^^^^^^^^^^^^^ +LL | fn it() -> impl ExactSizeIterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/never_type/impl_trait_fallback.rs b/tests/ui/never_type/impl_trait_fallback.rs index ce06f8f7817ff..fa13603b0f987 100644 --- a/tests/ui/never_type/impl_trait_fallback.rs +++ b/tests/ui/never_type/impl_trait_fallback.rs @@ -1,10 +1,9 @@ -//@ check-pass - fn main() {} trait T {} impl T for () {} fn should_ret_unit() -> impl T { + //~^ ERROR undefined opaque type panic!() } diff --git a/tests/ui/never_type/impl_trait_fallback.stderr b/tests/ui/never_type/impl_trait_fallback.stderr new file mode 100644 index 0000000000000..23cbfb730362f --- /dev/null +++ b/tests/ui/never_type/impl_trait_fallback.stderr @@ -0,0 +1,8 @@ +error: undefined opaque type + --> $DIR/impl_trait_fallback.rs:6:25 + | +LL | fn should_ret_unit() -> impl T { + | ^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index a95b44e807c5d..0d3abf034df33 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -161,6 +161,7 @@ impl BadTrait<_> for BadStruct<_> {} fn impl_trait() -> impl BadTrait<_> { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for opaque types +//~| ERROR undefined opaque type unimplemented!() } diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 7977504dae1d6..cf00b56932276 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -11,25 +11,25 @@ LL | trait BadTrait<_> {} | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:167:19 + --> $DIR/typeck_type_placeholder_item.rs:168:19 | LL | struct BadStruct1<_, _>(_); | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:167:22 + --> $DIR/typeck_type_placeholder_item.rs:168:22 | LL | struct BadStruct1<_, _>(_); | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:172:19 + --> $DIR/typeck_type_placeholder_item.rs:173:19 | LL | struct BadStruct2<_, T>(_, T); | ^ expected identifier, found reserved identifier error: associated constant in `impl` without body - --> $DIR/typeck_type_placeholder_item.rs:206:5 + --> $DIR/typeck_type_placeholder_item.rs:207:5 | LL | const C: _; | ^^^^^^^^^^- @@ -37,7 +37,7 @@ LL | const C: _; | help: provide a definition for the constant: `= ;` error[E0403]: the name `_` is already used for a generic parameter in this item's generic parameters - --> $DIR/typeck_type_placeholder_item.rs:167:22 + --> $DIR/typeck_type_placeholder_item.rs:168:22 | LL | struct BadStruct1<_, _>(_); | - ^ already used @@ -490,8 +490,14 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | fn impl_trait() -> impl BadTrait<_> { | ^ not allowed in type signatures +error: undefined opaque type + --> $DIR/typeck_type_placeholder_item.rs:162:20 + | +LL | fn impl_trait() -> impl BadTrait<_> { + | ^^^^^^^^^^^^^^^^ + error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:167:25 + --> $DIR/typeck_type_placeholder_item.rs:168:25 | LL | struct BadStruct1<_, _>(_); | ^ not allowed in type signatures @@ -502,7 +508,7 @@ LL | struct BadStruct1(T); | ~ ~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:172:25 + --> $DIR/typeck_type_placeholder_item.rs:173:25 | LL | struct BadStruct2<_, T>(_, T); | ^ not allowed in type signatures @@ -513,13 +519,13 @@ LL | struct BadStruct2(U, T); | ~ ~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases - --> $DIR/typeck_type_placeholder_item.rs:176:14 + --> $DIR/typeck_type_placeholder_item.rs:177:14 | LL | type X = Box<_>; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types - --> $DIR/typeck_type_placeholder_item.rs:182:21 + --> $DIR/typeck_type_placeholder_item.rs:183:21 | LL | type Y = impl Trait<_>; | ^ not allowed in type signatures @@ -547,7 +553,7 @@ LL | fn fn_test10(&self, _x : T) { } | +++ ~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:194:14 + --> $DIR/typeck_type_placeholder_item.rs:195:14 | LL | const D: _ = 42; | ^ @@ -556,7 +562,7 @@ LL | const D: _ = 42; | help: replace with the correct type: `i32` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:217:31 + --> $DIR/typeck_type_placeholder_item.rs:218:31 | LL | fn value() -> Option<&'static _> { | ----------------^- @@ -565,7 +571,7 @@ LL | fn value() -> Option<&'static _> { | help: replace with the correct return type: `Option<&'static u8>` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:222:10 + --> $DIR/typeck_type_placeholder_item.rs:223:10 | LL | const _: Option<_> = map(value); | ^^^^^^^^^ @@ -574,19 +580,19 @@ LL | const _: Option<_> = map(value); | help: replace with the correct type: `Option` error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:206:14 + --> $DIR/typeck_type_placeholder_item.rs:207:14 | LL | const C: _; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:209:14 + --> $DIR/typeck_type_placeholder_item.rs:210:14 | LL | const D: _ = 42; | ^ not allowed in type signatures error[E0046]: not all trait items implemented, missing: `F` - --> $DIR/typeck_type_placeholder_item.rs:200:1 + --> $DIR/typeck_type_placeholder_item.rs:201:1 | LL | type F: std::ops::Fn(_); | ----------------------- `F` from trait @@ -595,7 +601,7 @@ LL | impl Qux for Struct { | ^^^^^^^^^^^^^^^^^^^ missing `F` in implementation error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:225:31 + --> $DIR/typeck_type_placeholder_item.rs:226:31 | LL | fn evens_squared(n: usize) -> _ { | ^ @@ -604,13 +610,13 @@ LL | fn evens_squared(n: usize) -> _ { | help: replace with an appropriate return type: `impl Iterator` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:230:10 + --> $DIR/typeck_type_placeholder_item.rs:231:10 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^ not allowed in type signatures | -note: however, the inferred type `Map, {closure@typeck_type_placeholder_item.rs:230:29}>, {closure@typeck_type_placeholder_item.rs:230:49}>` cannot be named - --> $DIR/typeck_type_placeholder_item.rs:230:14 +note: however, the inferred type `Map, {closure@typeck_type_placeholder_item.rs:231:29}>, {closure@typeck_type_placeholder_item.rs:231:49}>` cannot be named + --> $DIR/typeck_type_placeholder_item.rs:231:14 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -634,37 +640,37 @@ LL | fn fn_test9(&self) -> _ { () } | help: replace with the correct return type: `()` error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:202:14 + --> $DIR/typeck_type_placeholder_item.rs:203:14 | LL | type A = _; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:204:14 + --> $DIR/typeck_type_placeholder_item.rs:205:14 | LL | type B = _; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:190:14 + --> $DIR/typeck_type_placeholder_item.rs:191:14 | LL | type B = _; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:192:14 + --> $DIR/typeck_type_placeholder_item.rs:193:14 | LL | const C: _; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:197:26 + --> $DIR/typeck_type_placeholder_item.rs:198:26 | LL | type F: std::ops::Fn(_); | ^ not allowed in type signatures -error[E0015]: cannot call non-const fn ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}>` in constants - --> $DIR/typeck_type_placeholder_item.rs:230:22 +error[E0015]: cannot call non-const fn ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:231:29: 231:32}>` in constants + --> $DIR/typeck_type_placeholder_item.rs:231:22 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -675,8 +681,8 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0015]: cannot call non-const fn `, {closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}> as Iterator>::map::` in constants - --> $DIR/typeck_type_placeholder_item.rs:230:45 +error[E0015]: cannot call non-const fn `, {closure@$DIR/typeck_type_placeholder_item.rs:231:29: 231:32}> as Iterator>::map::` in constants + --> $DIR/typeck_type_placeholder_item.rs:231:45 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^ @@ -693,7 +699,7 @@ error[E0515]: cannot return reference to function parameter `x` LL | &x | ^^ returns a reference to data owned by the current function -error: aborting due to 75 previous errors +error: aborting due to 76 previous errors Some errors have detailed explanations: E0015, E0046, E0121, E0282, E0403, E0515. For more information about an error, try `rustc --explain E0015`.