diff options
27 files changed, 40 insertions, 210 deletions
diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 205578c638a..139cebe0e43 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -58,7 +58,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) -> VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>> { opaque_ty_decls .into_iter() - .filter_map(|(opaque_type_key, (concrete_type, decl_span, origin))| { + .map(|(opaque_type_key, (concrete_type, decl_span, origin))| { let substs = opaque_type_key.substs; // FIXME: why are the spans in decl_span often DUMMY_SP? let span = decl_span.substitute_dummy(span); @@ -112,8 +112,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { span, ); - check_opaque_type_parameter_valid(infcx.tcx, opaque_type_key, origin, span) - .then_some((opaque_type_key, remapped_type)) + ( + opaque_type_key, + if check_opaque_type_parameter_valid(infcx.tcx, opaque_type_key, origin, span) { + remapped_type + } else { + infcx.tcx.ty_error() + }, + ) }) .collect() } diff --git a/src/test/ui/generic-associated-types/issue-88595.rs b/src/test/ui/generic-associated-types/issue-88595.rs index c6cde3aa065..ea1bd2be452 100644 --- a/src/test/ui/generic-associated-types/issue-88595.rs +++ b/src/test/ui/generic-associated-types/issue-88595.rs @@ -18,7 +18,6 @@ struct C; impl<'a> A<'a> for C { type B<'b> = impl Clone; //~^ ERROR: lifetime bound not satisfied - //~| ERROR: unconstrained opaque type fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope } diff --git a/src/test/ui/generic-associated-types/issue-88595.stderr b/src/test/ui/generic-associated-types/issue-88595.stderr index 58afc42fdea..e1d55fa228c 100644 --- a/src/test/ui/generic-associated-types/issue-88595.stderr +++ b/src/test/ui/generic-associated-types/issue-88595.stderr @@ -16,7 +16,7 @@ LL | type B<'b> = impl Clone; | ^^ error: non-defining opaque type use in defining scope - --> $DIR/issue-88595.rs:23:35 + --> $DIR/issue-88595.rs:22:35 | LL | fn a(&'a self) -> Self::B<'a> {} | ^^ @@ -29,14 +29,6 @@ LL | impl<'a> A<'a> for C { LL | type B<'b> = impl Clone; | ^^ -error: unconstrained opaque type - --> $DIR/issue-88595.rs:19:18 - | -LL | type B<'b> = impl Clone; - | ^^^^^^^^^^ - | - = note: `B` must be used in combination with a concrete type within the same module - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/type-alias-impl-trait/bound_reduction2.rs b/src/test/ui/type-alias-impl-trait/bound_reduction2.rs index f3d12d02ccd..4d2890b5de5 100644 --- a/src/test/ui/type-alias-impl-trait/bound_reduction2.rs +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.rs @@ -7,7 +7,6 @@ trait TraitWithAssoc { } type Foo<V> = impl Trait<V>; -//~^ ERROR unconstrained opaque type trait Trait<U> {} diff --git a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr index f309fa53b1a..c405b1f6af2 100644 --- a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr @@ -1,5 +1,5 @@ error: non-defining opaque type use in defining scope - --> $DIR/bound_reduction2.rs:17:5 + --> $DIR/bound_reduction2.rs:16:5 | LL | () | ^^ @@ -10,13 +10,5 @@ note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter LL | type Foo<V> = impl Trait<V>; | ^ -error: unconstrained opaque type - --> $DIR/bound_reduction2.rs:9:15 - | -LL | type Foo<V> = impl Trait<V>; - | ^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs b/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs index ce6ed808009..83d22161e4e 100644 --- a/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs +++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs @@ -4,7 +4,6 @@ #![feature(type_alias_impl_trait)] type X<'a> = impl Into<&'static str> + From<&'a str>; -//~^ ERROR unconstrained opaque type fn f<'a: 'static>(t: &'a str) -> X<'a> { //~^ WARNING unnecessary lifetime parameter diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr index 34141c9c8a6..d87ef2ec79c 100644 --- a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr +++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr @@ -1,5 +1,5 @@ warning: unnecessary lifetime parameter `'a` - --> $DIR/bounds-are-checked.rs:9:6 + --> $DIR/bounds-are-checked.rs:8:6 | LL | fn f<'a: 'static>(t: &'a str) -> X<'a> { | ^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | fn f<'a: 'static>(t: &'a str) -> X<'a> { = help: you can use the `'static` lifetime directly, in place of `'a` error: non-defining opaque type use in defining scope - --> $DIR/bounds-are-checked.rs:11:5 + --> $DIR/bounds-are-checked.rs:10:5 | LL | type X<'a> = impl Into<&'static str> + From<&'a str>; | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type @@ -15,13 +15,5 @@ LL | type X<'a> = impl Into<&'static str> + From<&'a str>; LL | t | ^ -error: unconstrained opaque type - --> $DIR/bounds-are-checked.rs:6:14 - | -LL | type X<'a> = impl Into<&'static str> + From<&'a str>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `X` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs index efb681e7e88..c9b9e128f88 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs @@ -3,7 +3,7 @@ fn main() {} type Two<'a, 'b> = impl std::fmt::Debug; -//~^ ERROR unconstrained opaque type + fn one<'a>(t: &'a ()) -> Two<'a, 'a> { t diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr index f68ab3de2ba..222aaea78d9 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr @@ -10,13 +10,5 @@ note: lifetime used multiple times LL | type Two<'a, 'b> = impl std::fmt::Debug; | ^^ ^^ -error: unconstrained opaque type - --> $DIR/generic_duplicate_lifetime_param.rs:5:20 - | -LL | type Two<'a, 'b> = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: `Two` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs index e67ca695585..093c1c23186 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs @@ -6,11 +6,11 @@ fn main() {} // test that unused generic parameters are ok type TwoTys<T, U> = impl Debug; -//~^ ERROR unconstrained opaque type + type TwoLifetimes<'a, 'b> = impl Debug; -//~^ ERROR unconstrained opaque type + type TwoConsts<const X: usize, const Y: usize> = impl Debug; -//~^ ERROR unconstrained opaque type + fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> { t diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index fb0b4104330..922e41e0f68 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -10,14 +10,6 @@ note: type used multiple times LL | type TwoTys<T, U> = impl Debug; | ^ ^ -error: unconstrained opaque type - --> $DIR/generic_duplicate_param_use.rs:8:21 - | -LL | type TwoTys<T, U> = impl Debug; - | ^^^^^^^^^^ - | - = note: `TwoTys` must be used in combination with a concrete type within the same module - error: non-defining opaque type use in defining scope --> $DIR/generic_duplicate_param_use.rs:21:5 | @@ -30,14 +22,6 @@ note: lifetime used multiple times LL | type TwoLifetimes<'a, 'b> = impl Debug; | ^^ ^^ -error: unconstrained opaque type - --> $DIR/generic_duplicate_param_use.rs:10:29 - | -LL | type TwoLifetimes<'a, 'b> = impl Debug; - | ^^^^^^^^^^ - | - = note: `TwoLifetimes` must be used in combination with a concrete type within the same module - error: non-defining opaque type use in defining scope --> $DIR/generic_duplicate_param_use.rs:26:5 | @@ -50,13 +34,5 @@ note: constant used multiple times LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; | ^ ^ -error: unconstrained opaque type - --> $DIR/generic_duplicate_param_use.rs:12:50 - | -LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; - | ^^^^^^^^^^ - | - = note: `TwoConsts` must be used in combination with a concrete type within the same module - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs index da9dd5baa3d..81bf9770d02 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs @@ -8,11 +8,6 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `T` doesn't implement `Debug` -fn one<T: Debug>(t: T) -> Two<T, T> { - t - //~^ ERROR non-defining opaque type use in defining scope -} - fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { t } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr index e62218fe083..84aa260b099 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr @@ -1,15 +1,3 @@ -error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use2.rs:12:5 - | -LL | t - | ^ - | -note: type used multiple times - --> $DIR/generic_duplicate_param_use2.rs:8:10 - | -LL | type Two<T, U> = impl Debug; - | ^ ^ - error[E0277]: `T` doesn't implement `Debug` --> $DIR/generic_duplicate_param_use2.rs:8:18 | @@ -21,6 +9,6 @@ help: consider restricting type parameter `T` LL | type Two<T: std::fmt::Debug, U> = impl Debug; | +++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs index b21280e2db5..c95692182c2 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs @@ -8,11 +8,6 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `T` doesn't implement `Debug` -fn one<T: Debug>(t: T) -> Two<T, T> { - t - //~^ ERROR non-defining opaque type use in defining scope -} - fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { t } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr index cb4e0f04aa1..e5a70fa8ce5 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr @@ -1,23 +1,11 @@ -error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use3.rs:12:5 - | -LL | t - | ^ - | -note: type used multiple times - --> $DIR/generic_duplicate_param_use3.rs:8:10 - | -LL | type Two<T, U> = impl Debug; - | ^ ^ - error: concrete type differs from previous defining opaque type use - --> $DIR/generic_duplicate_param_use3.rs:20:1 + --> $DIR/generic_duplicate_param_use3.rs:15:1 | LL | fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `T`, got `U` | note: previous use here - --> $DIR/generic_duplicate_param_use3.rs:16:1 + --> $DIR/generic_duplicate_param_use3.rs:11:1 | LL | fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,6 +21,6 @@ help: consider restricting type parameter `T` LL | type Two<T: std::fmt::Debug, U> = impl Debug; | +++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs index 1e22930a503..aee2550e907 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs @@ -8,11 +8,6 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `U` doesn't implement `Debug` -fn one<T: Debug>(t: T) -> Two<T, T> { - t - //~^ ERROR non-defining opaque type use in defining scope -} - fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> { u } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr index 64268abce50..0491d61030e 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr @@ -1,15 +1,3 @@ -error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use4.rs:12:5 - | -LL | t - | ^ - | -note: type used multiple times - --> $DIR/generic_duplicate_param_use4.rs:8:10 - | -LL | type Two<T, U> = impl Debug; - | ^ ^ - error[E0277]: `U` doesn't implement `Debug` --> $DIR/generic_duplicate_param_use4.rs:8:18 | @@ -21,6 +9,6 @@ help: consider restricting type parameter `U` LL | type Two<T, U: std::fmt::Debug> = impl Debug; | +++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs index dd7817a8f7d..f39741a6a62 100644 --- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs @@ -5,11 +5,11 @@ use std::fmt::Debug; fn main() {} type OneTy<T> = impl Debug; -//~^ ERROR unconstrained opaque type + type OneLifetime<'a> = impl Debug; -//~^ ERROR unconstrained opaque type + type OneConst<const X: usize> = impl Debug; -//~^ ERROR unconstrained opaque type + // Not defining uses, because they doesn't define *all* possible generics. diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr index 6bc02c2989a..36694900c17 100644 --- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr @@ -10,14 +10,6 @@ note: used non-generic type `u32` for generic parameter LL | type OneTy<T> = impl Debug; | ^ -error: unconstrained opaque type - --> $DIR/generic_nondefining_use.rs:7:17 - | -LL | type OneTy<T> = impl Debug; - | ^^^^^^^^^^ - | - = note: `OneTy` must be used in combination with a concrete type within the same module - error: non-defining opaque type use in defining scope --> $DIR/generic_nondefining_use.rs:22:5 | @@ -27,14 +19,6 @@ LL | type OneLifetime<'a> = impl Debug; LL | 6u32 | ^^^^ -error: unconstrained opaque type - --> $DIR/generic_nondefining_use.rs:9:24 - | -LL | type OneLifetime<'a> = impl Debug; - | ^^^^^^^^^^ - | - = note: `OneLifetime` must be used in combination with a concrete type within the same module - error: non-defining opaque type use in defining scope --> $DIR/generic_nondefining_use.rs:27:5 | @@ -47,13 +31,5 @@ note: used non-generic constant `123_usize` for generic parameter LL | type OneConst<const X: usize> = impl Debug; | ^ -error: unconstrained opaque type - --> $DIR/generic_nondefining_use.rs:11:33 - | -LL | type OneConst<const X: usize> = impl Debug; - | ^^^^^^^^^^ - | - = note: `OneConst` must be used in combination with a concrete type within the same module - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-60564.rs b/src/test/ui/type-alias-impl-trait/issue-60564.rs index fd254724fb5..4fc7679311a 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60564.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60564.rs @@ -6,7 +6,6 @@ trait IterBits { } type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; -//~^ ERROR unconstrained opaque type impl<T: Copy, E> IterBits for T where diff --git a/src/test/ui/type-alias-impl-trait/issue-60564.stderr b/src/test/ui/type-alias-impl-trait/issue-60564.stderr index c5ac477187d..bbc93657be3 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60564.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60564.stderr @@ -1,5 +1,5 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-60564.rs:21:9 + --> $DIR/issue-60564.rs:20:9 | LL | (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,13 +10,5 @@ note: used non-generic type `u8` for generic parameter LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; | ^ -error: unconstrained opaque type - --> $DIR/issue-60564.rs:8:30 - | -LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `IterBitsIter` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs index 7f25d320677..5223fb1c702 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs @@ -5,7 +5,7 @@ #![feature(type_alias_impl_trait)] trait Trait<T> {} type Alias<'a, U> = impl Trait<U>; -//~^ ERROR unconstrained opaque type + fn f<'a>() -> Alias<'a, ()> {} //~^ ERROR non-defining opaque type use in defining scope diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr index 4afa903969f..7fb9a0c410e 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr @@ -10,13 +10,5 @@ note: used non-generic type `()` for generic parameter LL | type Alias<'a, U> = impl Trait<U>; | ^ -error: unconstrained opaque type - --> $DIR/issue-68368-non-defining-use-2.rs:7:21 - | -LL | type Alias<'a, U> = impl Trait<U>; - | ^^^^^^^^^^^^^ - | - = note: `Alias` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs index b2b8a68bd75..b50462bf237 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs @@ -5,7 +5,7 @@ #![feature(type_alias_impl_trait)] trait Trait<T> {} type Alias<'a, U> = impl Trait<U>; -//~^ ERROR unconstrained opaque type + fn f<'a>() -> Alias<'a, ()> {} //~^ ERROR non-defining opaque type use in defining scope diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr index 94dc3b7c2b0..8059621b61a 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr @@ -10,13 +10,5 @@ note: used non-generic type `()` for generic parameter LL | type Alias<'a, U> = impl Trait<U>; | ^ -error: unconstrained opaque type - --> $DIR/issue-68368-non-defining-use.rs:7:21 - | -LL | type Alias<'a, U> = impl Trait<U>; - | ^^^^^^^^^^^^^ - | - = note: `Alias` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs b/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs index cad3ff87749..5b332b8cb6b 100644 --- a/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs +++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs @@ -7,11 +7,6 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `T` doesn't implement `Debug` -fn two<T: Debug>(t: T) -> Two<T, u32> { - (t, 4i8) - //~^ ERROR non-defining opaque type use in defining scope -} - fn three<T: Debug, U>(t: T) -> Two<T, U> { (t, 5i8) } diff --git a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr index aa05f62eb53..f946dc48a4b 100644 --- a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr @@ -1,23 +1,11 @@ -error: non-defining opaque type use in defining scope - --> $DIR/not_a_defining_use.rs:11:5 - | -LL | (t, 4i8) - | ^^^^^^^^ - | -note: used non-generic type `u32` for generic parameter - --> $DIR/not_a_defining_use.rs:7:13 - | -LL | type Two<T, U> = impl Debug; - | ^ - error: concrete type differs from previous defining opaque type use - --> $DIR/not_a_defining_use.rs:29:1 + --> $DIR/not_a_defining_use.rs:24:1 | LL | fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)` | note: previous use here - --> $DIR/not_a_defining_use.rs:15:1 + --> $DIR/not_a_defining_use.rs:10:1 | LL | fn three<T: Debug, U>(t: T) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,6 +22,6 @@ help: consider restricting type parameter `T` LL | type Two<T: std::fmt::Debug, U> = impl Debug; | +++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. |
