about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-11 19:01:15 +0000
committerbors <bors@rust-lang.org>2024-03-11 19:01:15 +0000
commit4ccbb7dc95596c7fc0c5756fdc47a17a56c085d3 (patch)
treeb36a408d7aff94b9359528d7e50ffebef00a66c5 /tests
parent6554a5645a13e4d9331fd028960d69be91d7492d (diff)
parentb0328c20ce75a56879bda08235242c21c1a451a1 (diff)
downloadrust-4ccbb7dc95596c7fc0c5756fdc47a17a56c085d3.tar.gz
rust-4ccbb7dc95596c7fc0c5756fdc47a17a56c085d3.zip
Auto merge of #121796 - oli-obk:eager_opaque_checks3, r=lcnr
Make `DefiningAnchor::Bind` only store the opaque types that may be constrained, instead of the current infcx root item.

This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely (not done in this PR)

The only behaviour change is in diagnostics.

r? `@lcnr` `@compiler-errors`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/generic-associated-types/issue-88595.rs1
-rw-r--r--tests/ui/generic-associated-types/issue-88595.stderr16
-rw-r--r--tests/ui/impl-trait/auto-trait-leak.stderr6
-rw-r--r--tests/ui/impl-trait/issues/issue-78722-2.rs4
-rw-r--r--tests/ui/impl-trait/issues/issue-78722-2.stderr33
-rw-r--r--tests/ui/lint/issue-99387.rs2
-rw-r--r--tests/ui/lint/issue-99387.stderr17
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr24
-rw-r--r--tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr18
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr27
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params2.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr13
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params3.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr26
-rw-r--r--tests/ui/type-alias-impl-trait/implied_bounds_from_types.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr17
-rw-r--r--tests/ui/type-alias-impl-trait/inference-cycle.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092-2.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092-2.stderr20
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092.stderr21
-rw-r--r--tests/ui/type-alias-impl-trait/issue-70121.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-70121.stderr17
-rw-r--r--tests/ui/type-alias-impl-trait/issue-77179.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-77179.stderr36
-rw-r--r--tests/ui/type-alias-impl-trait/multi-error.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/multi-error.stderr11
-rw-r--r--tests/ui/type-alias-impl-trait/non-defining-method.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/non-defining-method.stderr10
-rw-r--r--tests/ui/type-alias-impl-trait/reveal_local.stderr12
32 files changed, 217 insertions, 140 deletions
diff --git a/tests/ui/generic-associated-types/issue-88595.rs b/tests/ui/generic-associated-types/issue-88595.rs
index 5a40a612972..b1fe542a568 100644
--- a/tests/ui/generic-associated-types/issue-88595.rs
+++ b/tests/ui/generic-associated-types/issue-88595.rs
@@ -19,4 +19,5 @@ impl<'a> A<'a> for C {
     type B<'b> = impl Clone;
 
     fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope
+    //~^ ERROR: non-defining opaque type use in defining scope
 }
diff --git a/tests/ui/generic-associated-types/issue-88595.stderr b/tests/ui/generic-associated-types/issue-88595.stderr
index ab75a924006..87dd7118c06 100644
--- a/tests/ui/generic-associated-types/issue-88595.stderr
+++ b/tests/ui/generic-associated-types/issue-88595.stderr
@@ -10,5 +10,19 @@ note: for this opaque type
 LL |     type B<'b> = impl Clone;
    |                  ^^^^^^^^^^
 
-error: aborting due to 1 previous error
+error: non-defining opaque type use in defining scope
+  --> $DIR/issue-88595.rs:21:35
+   |
+LL |     fn a(&'a self) -> Self::B<'a> {}
+   |                                   ^^
+   |
+note: lifetime used multiple times
+  --> $DIR/issue-88595.rs:18:6
+   |
+LL | impl<'a> A<'a> for C {
+   |      ^^
+LL |     type B<'b> = impl Clone;
+   |            ^^
+
+error: aborting due to 2 previous errors
 
diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr
index 3fab766fa23..cc9939f2d57 100644
--- a/tests/ui/impl-trait/auto-trait-leak.stderr
+++ b/tests/ui/impl-trait/auto-trait-leak.stderr
@@ -6,16 +6,12 @@ LL |     send(cycle1().clone());
    |     |
    |     required by a bound introduced by this call
    |
+   = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
 note: opaque type is declared here
   --> $DIR/auto-trait-leak.rs:11:16
    |
 LL | fn cycle1() -> impl Clone {
    |                ^^^^^^^^^^
-note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
-  --> $DIR/auto-trait-leak.rs:17:4
-   |
-LL | fn cycle2() -> impl Clone {
-   |    ^^^^^^
 note: required by a bound in `send`
   --> $DIR/auto-trait-leak.rs:4:12
    |
diff --git a/tests/ui/impl-trait/issues/issue-78722-2.rs b/tests/ui/impl-trait/issues/issue-78722-2.rs
index 26181b612ed..e811620c03b 100644
--- a/tests/ui/impl-trait/issues/issue-78722-2.rs
+++ b/tests/ui/impl-trait/issues/issue-78722-2.rs
@@ -12,9 +12,9 @@ struct Bug {
             //~^ ERROR future that resolves to `u8`, but it resolves to `()`
             async {}
         }
+        // FIXME(type_alias_impl_trait): inform the user about why `F` is not available here.
         let f: F = async { 1 };
-        //~^ ERROR item constrains opaque type that is not in its signature
-        //~| ERROR `async` blocks are not allowed in constants
+        //~^ ERROR mismatched types
         1
     }],
 }
diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr
index c402ce864c7..91dad1b5e67 100644
--- a/tests/ui/impl-trait/issues/issue-78722-2.stderr
+++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr
@@ -4,30 +4,21 @@ error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:13:13: 13:21}` to be
 LL |         fn concrete_use() -> F {
    |                              ^ expected `()`, found `u8`
 
-error: item constrains opaque type that is not in its signature
-  --> $DIR/issue-78722-2.rs:15:20
+error[E0308]: mismatched types
+  --> $DIR/issue-78722-2.rs:16:20
    |
+LL | type F = impl core::future::Future<Output = u8>;
+   |          -------------------------------------- the expected future
+...
 LL |         let f: F = async { 1 };
-   |                    ^^^^^^^^^^^
+   |                -   ^^^^^^^^^^^ expected future, found `async` block
+   |                |
+   |                expected due to this
    |
-   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
-note: this item must mention the opaque type in its signature in order to be able to register hidden types
-  --> $DIR/issue-78722-2.rs:15:20
-   |
-LL |         let f: F = async { 1 };
-   |                    ^^^^^^^^^^^
-
-error[E0658]: `async` blocks are not allowed in constants
-  --> $DIR/issue-78722-2.rs:15:20
-   |
-LL |         let f: F = async { 1 };
-   |                    ^^^^^^^^^^^
-   |
-   = note: see issue #85368 <https://github.com/rust-lang/rust/issues/85368> for more information
-   = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: expected opaque type `F`
+            found `async` block `{async block@$DIR/issue-78722-2.rs:16:20: 16:31}`
 
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0271, E0658.
+Some errors have detailed explanations: E0271, E0308.
 For more information about an error, try `rustc --explain E0271`.
diff --git a/tests/ui/lint/issue-99387.rs b/tests/ui/lint/issue-99387.rs
index 571d4194fe7..6f082239456 100644
--- a/tests/ui/lint/issue-99387.rs
+++ b/tests/ui/lint/issue-99387.rs
@@ -19,8 +19,8 @@ impl<'a> Tr for &'a () {
 }
 
 pub fn ohno<'a>() -> <&'a () as Tr>::Item {
-    //~^ ERROR item constrains opaque type that is not in its signature
     None.into_iter()
+    //~^ ERROR mismatched types
 }
 
 fn main() {}
diff --git a/tests/ui/lint/issue-99387.stderr b/tests/ui/lint/issue-99387.stderr
index 0005e55324f..4eee4f36392 100644
--- a/tests/ui/lint/issue-99387.stderr
+++ b/tests/ui/lint/issue-99387.stderr
@@ -1,11 +1,17 @@
-error: item constrains opaque type that is not in its signature
-  --> $DIR/issue-99387.rs:21:22
+error[E0308]: mismatched types
+  --> $DIR/issue-99387.rs:22:5
    |
+LL | pub type Successors<'a> = impl Iterator<Item = &'a ()>;
+   |                           ---------------------------- the expected opaque type
+...
 LL | pub fn ohno<'a>() -> <&'a () as Tr>::Item {
-   |                      ^^^^^^^^^^^^^^^^^^^^
+   |                      -------------------- expected `Successors<'a>` because of return type
+LL |     None.into_iter()
+   |     ^^^^^^^^^^^^^^^^ expected opaque type, found `IntoIter<_>`
    |
-   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
-note: this item must mention the opaque type in its signature in order to be able to register hidden types
+   = note: expected opaque type `Successors<'a>`
+                   found struct `std::option::IntoIter<_>`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
   --> $DIR/issue-99387.rs:21:8
    |
 LL | pub fn ohno<'a>() -> <&'a () as Tr>::Item {
@@ -13,3 +19,4 @@ LL | pub fn ohno<'a>() -> <&'a () as Tr>::Item {
 
 error: aborting due to 1 previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
index f6f75455799..6bdc76aab45 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
@@ -6,16 +6,12 @@ LL |         is_send(foo());
    |         |
    |         required by a bound introduced by this call
    |
+   = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
 note: opaque type is declared here
   --> $DIR/auto-trait-leakage3.rs:7:20
    |
 LL |     pub type Foo = impl std::fmt::Debug;
    |                    ^^^^^^^^^^^^^^^^^^^^
-note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
-  --> $DIR/auto-trait-leakage3.rs:12:12
-   |
-LL |     pub fn bar() {
-   |            ^^^
 note: required by a bound in `is_send`
   --> $DIR/auto-trait-leakage3.rs:17:19
    |
diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
index 495308a6cac..73570de5326 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
@@ -35,18 +35,6 @@ LL | type TwoLifetimes<'a, 'b> = impl Debug;
    |                             ^^^^^^^^^^
 
 error: non-defining opaque type use in defining scope
-  --> $DIR/generic_duplicate_param_use.rs:29:5
-   |
-LL |     t
-   |     ^
-   |
-note: lifetime used multiple times
-  --> $DIR/generic_duplicate_param_use.rs:17:19
-   |
-LL | type TwoLifetimes<'a, 'b> = impl Debug;
-   |                   ^^  ^^
-
-error: non-defining opaque type use in defining scope
   --> $DIR/generic_duplicate_param_use.rs:33:50
    |
 LL | fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> {
@@ -59,6 +47,18 @@ LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug;
    |                                                  ^^^^^^^^^^
 
 error: non-defining opaque type use in defining scope
+  --> $DIR/generic_duplicate_param_use.rs:29:5
+   |
+LL |     t
+   |     ^
+   |
+note: lifetime used multiple times
+  --> $DIR/generic_duplicate_param_use.rs:17:19
+   |
+LL | type TwoLifetimes<'a, 'b> = impl Debug;
+   |                   ^^  ^^
+
+error: non-defining opaque type use in defining scope
   --> $DIR/generic_duplicate_param_use.rs:35:5
    |
 LL |     t
diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
index e3b7b1a76b0..bd68b4e3ea4 100644
--- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
@@ -31,15 +31,6 @@ note: for this opaque type
 LL | type OneLifetime<'a> = impl Debug;
    |                        ^^^^^^^^^^
 
-error[E0792]: expected generic lifetime parameter, found `'static`
-  --> $DIR/generic_nondefining_use.rs:23:5
-   |
-LL | type OneLifetime<'a> = impl Debug;
-   |                  -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
-...
-LL |     6u32
-   |     ^^^^
-
 error[E0792]: non-defining opaque type use in defining scope
   --> $DIR/generic_nondefining_use.rs:27:24
    |
@@ -52,6 +43,15 @@ note: for this opaque type
 LL | type OneConst<const X: usize> = impl Debug;
    |                                 ^^^^^^^^^^
 
+error[E0792]: expected generic lifetime parameter, found `'static`
+  --> $DIR/generic_nondefining_use.rs:23:5
+   |
+LL | type OneLifetime<'a> = impl Debug;
+   |                  -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
+...
+LL |     6u32
+   |     ^^^^
+
 error[E0792]: expected generic constant parameter, found `123`
   --> $DIR/generic_nondefining_use.rs:29:5
    |
diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
index 12ce6b14e31..5b5acb31812 100644
--- a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
+++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
@@ -9,7 +9,6 @@
 mod sus {
     use super::*;
     pub type Sep = impl Sized + std::fmt::Display;
-    //~^ ERROR: concrete type differs from previous defining opaque type use
     pub fn mk_sep() -> Sep {
         String::from("hello")
     }
@@ -42,6 +41,7 @@ mod sus {
         (): Proj<Assoc = i32>,
     {
         Bar { inner: 1i32, _marker: () }
+        //~^ ERROR type mismatch
     }
 }
 
diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
index 5a6998f4165..21d9ed93366 100644
--- a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
+++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
@@ -1,14 +1,27 @@
-error: concrete type differs from previous defining opaque type use
-  --> $DIR/hidden_type_mismatch.rs:11:20
+error[E0271]: type mismatch resolving `<() as Proj>::Assoc == i32`
+  --> $DIR/hidden_type_mismatch.rs:43:9
    |
 LL |     pub type Sep = impl Sized + std::fmt::Display;
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `String`
+   |                    ------------------------------ the expected opaque type
+...
+LL |         Bar { inner: 1i32, _marker: () }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Proj>::Assoc == i32`
    |
-note: previous use here
-  --> $DIR/hidden_type_mismatch.rs:37:21
+note: expected this to be `Sep`
+  --> $DIR/hidden_type_mismatch.rs:20:22
    |
-LL |     pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>;
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         type Assoc = sus::Sep;
+   |                      ^^^^^^^^
+   = note: expected opaque type `Sep`
+                     found type `i32`
+note: required for `Bar<()>` to implement `Copy`
+  --> $DIR/hidden_type_mismatch.rs:32:39
+   |
+LL |     impl<T: Proj<Assoc = i32> + Copy> Copy for Bar<T> {}
+   |                  -----------          ^^^^     ^^^^^^
+   |                  |
+   |                  unsatisfied trait bound introduced here
 
 error: aborting due to 1 previous error
 
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs
index 1022e5c4ece..19c6099135d 100644
--- a/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs
@@ -24,7 +24,7 @@ type Successors<'a> = impl std::fmt::Debug + 'a;
 impl Terminator {
     fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
         f = g;
-        //~^ ERROR item constrains opaque type that is not in its signature
+        //~^ ERROR mismatched types
     }
 }
 
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr
index e037dede2e0..790e7fe8580 100644
--- a/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr
@@ -1,11 +1,15 @@
-error: item constrains opaque type that is not in its signature
+error[E0308]: mismatched types
   --> $DIR/higher_kinded_params2.rs:26:13
    |
+LL | type Tait = impl std::fmt::Debug;
+   |             -------------------- the expected opaque type
+...
 LL |         f = g;
-   |             ^
+   |             ^ expected fn pointer, found fn item
    |
-   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
-note: this item must mention the opaque type in its signature in order to be able to register hidden types
+   = note: expected fn pointer `for<'x> fn(&'x ()) -> Tait`
+                 found fn item `for<'a> fn(&'a ()) -> String {g}`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
   --> $DIR/higher_kinded_params2.rs:25:8
    |
 LL |     fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
@@ -13,3 +17,4 @@ LL |     fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> S
 
 error: aborting due to 1 previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs
index e0bb1e2d02f..3845cde29fa 100644
--- a/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs
@@ -25,7 +25,6 @@ impl Terminator {
     fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
         f = g;
         //~^ ERROR mismatched types
-        //~| ERROR item constrains opaque type that is not in its signature
     }
 }
 
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr
index 14372d8f3e6..41a3f9ce268 100644
--- a/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr
@@ -1,28 +1,20 @@
-error: item constrains opaque type that is not in its signature
-  --> $DIR/higher_kinded_params3.rs:26:13
-   |
-LL |         f = g;
-   |             ^
-   |
-   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
-note: this item must mention the opaque type in its signature in order to be able to register hidden types
-  --> $DIR/higher_kinded_params3.rs:25:8
-   |
-LL |     fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
-   |        ^^^^^^^^^^
-
 error[E0308]: mismatched types
-  --> $DIR/higher_kinded_params3.rs:26:9
+  --> $DIR/higher_kinded_params3.rs:26:13
    |
 LL | type Tait<'a> = impl std::fmt::Debug + 'a;
    |                 ------------------------- the expected opaque type
 ...
 LL |         f = g;
-   |         ^^^^^ one type is more general than the other
+   |             ^ expected fn pointer, found fn item
    |
    = note: expected fn pointer `for<'x> fn(&'x ()) -> Tait<'x>`
-              found fn pointer `for<'a> fn(&'a ()) -> &'a ()`
+                 found fn item `for<'a> fn(&'a ()) -> &'a () {g}`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+  --> $DIR/higher_kinded_params3.rs:25:8
+   |
+LL |     fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
+   |        ^^^^^^^^^^
 
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
 For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/implied_bounds_from_types.rs b/tests/ui/type-alias-impl-trait/implied_bounds_from_types.rs
index 8023cd24f0b..239fcc6a5e6 100644
--- a/tests/ui/type-alias-impl-trait/implied_bounds_from_types.rs
+++ b/tests/ui/type-alias-impl-trait/implied_bounds_from_types.rs
@@ -12,6 +12,7 @@ impl<'a> Convert<'a> for () {
     type Witness = WithLifetime<&'a ()>;
 
     fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<&'a ()>, x: &'a T) -> &'b T {
+        //~^ ERROR non-defining opaque type use
         // compiler used to think it gets to assume 'a: 'b here because
         // of the `&'b WithLifetime<&'a ()>` argument
         x
diff --git a/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr b/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
index 5967a946830..23dbf0e8f60 100644
--- a/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
@@ -1,5 +1,17 @@
+error[E0792]: non-defining opaque type use in defining scope
+  --> $DIR/implied_bounds_from_types.rs:14:39
+   |
+LL |     fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<&'a ()>, x: &'a T) -> &'b T {
+   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^ argument `&'a ()` is not a generic parameter
+   |
+note: for this opaque type
+  --> $DIR/implied_bounds_from_types.rs:3:24
+   |
+LL | type WithLifetime<T> = impl Equals<SelfType = ()>;
+   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 error: lifetime may not live long enough
-  --> $DIR/implied_bounds_from_types.rs:17:9
+  --> $DIR/implied_bounds_from_types.rs:18:9
    |
 LL | impl<'a> Convert<'a> for () {
    |      -- lifetime `'a` defined here
@@ -12,5 +24,6 @@ LL |         x
    |
    = help: consider adding the following bound: `'a: 'b`
 
-error: aborting due to 1 previous error
+error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
index fd7488fa260..8b809ba014d 100644
--- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr
+++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
@@ -6,16 +6,12 @@ LL |         is_send(foo());
    |         |
    |         required by a bound introduced by this call
    |
+   = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
 note: opaque type is declared here
   --> $DIR/inference-cycle.rs:5:20
    |
 LL |     pub type Foo = impl std::fmt::Debug;
    |                    ^^^^^^^^^^^^^^^^^^^^
-note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
-  --> $DIR/inference-cycle.rs:11:12
-   |
-LL |     pub fn bar() {
-   |            ^^^
 note: required by a bound in `is_send`
   --> $DIR/inference-cycle.rs:21:19
    |
diff --git a/tests/ui/type-alias-impl-trait/issue-53092-2.rs b/tests/ui/type-alias-impl-trait/issue-53092-2.rs
index 057930f0c1c..61b23a3a933 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092-2.rs
+++ b/tests/ui/type-alias-impl-trait/issue-53092-2.rs
@@ -4,6 +4,7 @@
 type Bug<T, U> = impl Fn(T) -> U + Copy; //~ ERROR cycle detected
 
 const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
+//~^ ERROR: non-defining opaque type use
 
 fn make_bug<T, U: From<T>>() -> Bug<T, U> {
     |x| x.into() //~ ERROR the trait bound `U: From<T>` is not satisfied
diff --git a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
index e805a71ea6f..c2da5fc265c 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
@@ -1,3 +1,15 @@
+error[E0792]: non-defining opaque type use in defining scope
+  --> $DIR/issue-53092-2.rs:6:18
+   |
+LL | const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
+   |                  ^^^^^^^^^^^ argument `u8` is not a generic parameter
+   |
+note: for this opaque type
+  --> $DIR/issue-53092-2.rs:4:18
+   |
+LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
+   |                  ^^^^^^^^^^^^^^^^^^^^^^
+
 error[E0391]: cycle detected when computing type of `Bug::{opaque#0}`
   --> $DIR/issue-53092-2.rs:4:18
    |
@@ -25,13 +37,13 @@ LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
    = 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[E0277]: the trait bound `U: From<T>` is not satisfied
-  --> $DIR/issue-53092-2.rs:9:5
+  --> $DIR/issue-53092-2.rs:10:5
    |
 LL |     |x| x.into()
    |     ^^^^^^^^^^^^ the trait `From<T>` is not implemented for `U`
    |
 note: required by a bound in `make_bug`
-  --> $DIR/issue-53092-2.rs:8:19
+  --> $DIR/issue-53092-2.rs:9:19
    |
 LL | fn make_bug<T, U: From<T>>() -> Bug<T, U> {
    |                   ^^^^^^^ required by this bound in `make_bug`
@@ -40,7 +52,7 @@ help: consider restricting type parameter `U`
 LL | type Bug<T, U: std::convert::From<T>> = impl Fn(T) -> U + Copy;
    |              +++++++++++++++++++++++
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0277, E0391.
+Some errors have detailed explanations: E0277, E0391, E0792.
 For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/issue-53092.rs b/tests/ui/type-alias-impl-trait/issue-53092.rs
index 1be5b46d6df..34bab026088 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092.rs
+++ b/tests/ui/type-alias-impl-trait/issue-53092.rs
@@ -9,6 +9,7 @@ union Moo {
 }
 
 const CONST_BUG: Bug<u8, ()> = unsafe { Moo { y: () }.x };
+//~^ ERROR non-defining opaque type use
 
 fn make_bug<T, U: From<T>>() -> Bug<T, U> {
     |x| x.into() //~ ERROR the trait bound `U: From<T>` is not satisfied
diff --git a/tests/ui/type-alias-impl-trait/issue-53092.stderr b/tests/ui/type-alias-impl-trait/issue-53092.stderr
index 8605a098193..0c4cacd6655 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53092.stderr
@@ -1,11 +1,23 @@
+error[E0792]: non-defining opaque type use in defining scope
+  --> $DIR/issue-53092.rs:11:18
+   |
+LL | const CONST_BUG: Bug<u8, ()> = unsafe { Moo { y: () }.x };
+   |                  ^^^^^^^^^^^ argument `u8` is not a generic parameter
+   |
+note: for this opaque type
+  --> $DIR/issue-53092.rs:4:18
+   |
+LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
+   |                  ^^^^^^^^^^^^^^^^^^^^^^
+
 error[E0277]: the trait bound `U: From<T>` is not satisfied
-  --> $DIR/issue-53092.rs:14:5
+  --> $DIR/issue-53092.rs:15:5
    |
 LL |     |x| x.into()
    |     ^^^^^^^^^^^^ the trait `From<T>` is not implemented for `U`
    |
 note: required by a bound in `make_bug`
-  --> $DIR/issue-53092.rs:13:19
+  --> $DIR/issue-53092.rs:14:19
    |
 LL | fn make_bug<T, U: From<T>>() -> Bug<T, U> {
    |                   ^^^^^^^ required by this bound in `make_bug`
@@ -14,6 +26,7 @@ help: consider restricting type parameter `U`
 LL | type Bug<T, U: std::convert::From<T>> = impl Fn(T) -> U + Copy;
    |              +++++++++++++++++++++++
 
-error: aborting due to 1 previous error
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0277`.
+Some errors have detailed explanations: E0277, E0792.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/issue-70121.rs b/tests/ui/type-alias-impl-trait/issue-70121.rs
index bfd8d8872e3..b90bd312a0b 100644
--- a/tests/ui/type-alias-impl-trait/issue-70121.rs
+++ b/tests/ui/type-alias-impl-trait/issue-70121.rs
@@ -15,8 +15,8 @@ impl<'a> Tr for &'a () {
 }
 
 pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
-    //~^ ERROR item constrains opaque type that is not in its signature
     None.into_iter()
+    //~^ ERROR mismatched types
 }
 
 fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-70121.stderr b/tests/ui/type-alias-impl-trait/issue-70121.stderr
index d6ab26e30da..ed2eb17fbea 100644
--- a/tests/ui/type-alias-impl-trait/issue-70121.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-70121.stderr
@@ -1,11 +1,17 @@
-error: item constrains opaque type that is not in its signature
-  --> $DIR/issue-70121.rs:17:24
+error[E0308]: mismatched types
+  --> $DIR/issue-70121.rs:18:5
    |
+LL | pub type Successors<'a> = impl Iterator<Item = &'a ()>;
+   |                           ---------------------------- the expected opaque type
+...
 LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
-   |                        ^^^^^^^^^^^^^^^^^^^^
+   |                        -------------------- expected `Successors<'a>` because of return type
+LL |     None.into_iter()
+   |     ^^^^^^^^^^^^^^^^ expected opaque type, found `IntoIter<_>`
    |
-   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
-note: this item must mention the opaque type in its signature in order to be able to register hidden types
+   = note: expected opaque type `Successors<'a>`
+                   found struct `std::option::IntoIter<_>`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
   --> $DIR/issue-70121.rs:17:8
    |
 LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
@@ -13,3 +19,4 @@ LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
 
 error: aborting due to 1 previous error
 
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/issue-77179.rs b/tests/ui/type-alias-impl-trait/issue-77179.rs
index 2d9345a3e5e..1dc74c6b5fe 100644
--- a/tests/ui/type-alias-impl-trait/issue-77179.rs
+++ b/tests/ui/type-alias-impl-trait/issue-77179.rs
@@ -7,7 +7,7 @@ type Pointer<T> = impl std::ops::Deref<Target = T>;
 fn test() -> Pointer<_> {
     //~^ ERROR: the placeholder `_` is not allowed within types
     Box::new(1)
-    //~^ ERROR: expected generic type parameter, found `i32`
+    //~^ ERROR: mismatched types
 }
 
 fn main() {
diff --git a/tests/ui/type-alias-impl-trait/issue-77179.stderr b/tests/ui/type-alias-impl-trait/issue-77179.stderr
index ebd78e5b7a5..85a943c26e2 100644
--- a/tests/ui/type-alias-impl-trait/issue-77179.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-77179.stderr
@@ -1,11 +1,28 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-77179.rs:9:5
+   |
+LL | type Pointer<T> = impl std::ops::Deref<Target = T>;
+   |                   -------------------------------- the expected opaque type
+LL |
+LL | fn test() -> Pointer<_> {
+   |              ---------- expected `Pointer<_>` because of return type
+LL |
+LL |     Box::new(1)
+   |     ^^^^^^^^^^^ expected opaque type, found `Box<{integer}>`
+   |
+   = note: expected opaque type `Pointer<_>`
+                   found struct `Box<{integer}>`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+  --> $DIR/issue-77179.rs:7:4
+   |
+LL | fn test() -> Pointer<_> {
+   |    ^^^^
+
 error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
   --> $DIR/issue-77179.rs:7:22
    |
 LL | fn test() -> Pointer<_> {
-   |              --------^-
-   |              |       |
-   |              |       not allowed in type signatures
-   |              help: replace with the correct return type: `Pointer<i32>`
+   |                      ^ not allowed in type signatures
 
 error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
   --> $DIR/issue-77179.rs:18:25
@@ -16,16 +33,7 @@ LL |     fn bar() -> Pointer<_>;
    |                         not allowed in type signatures
    |                         help: use type parameters instead: `T`
 
-error[E0792]: expected generic type parameter, found `i32`
-  --> $DIR/issue-77179.rs:9:5
-   |
-LL | type Pointer<T> = impl std::ops::Deref<Target = T>;
-   |              - this generic parameter must be used with a generic type parameter
-...
-LL |     Box::new(1)
-   |     ^^^^^^^^^^^
-
 error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0121, E0792.
+Some errors have detailed explanations: E0121, E0308.
 For more information about an error, try `rustc --explain E0121`.
diff --git a/tests/ui/type-alias-impl-trait/multi-error.rs b/tests/ui/type-alias-impl-trait/multi-error.rs
index b5ff06572d0..cb4ad4dc633 100644
--- a/tests/ui/type-alias-impl-trait/multi-error.rs
+++ b/tests/ui/type-alias-impl-trait/multi-error.rs
@@ -17,6 +17,7 @@ impl Foo for () {
     fn foo() -> (Self::Bar<u32>, Self::Baz) {
         //~^ ERROR non-defining opaque type use
         ((), ())
+        //~^ ERROR expected generic type parameter
     }
 }
 
diff --git a/tests/ui/type-alias-impl-trait/multi-error.stderr b/tests/ui/type-alias-impl-trait/multi-error.stderr
index b0e6d13b0e1..761f01b32ac 100644
--- a/tests/ui/type-alias-impl-trait/multi-error.stderr
+++ b/tests/ui/type-alias-impl-trait/multi-error.stderr
@@ -10,6 +10,15 @@ note: for this opaque type
 LL |     type Bar<T> = impl Sized;
    |                   ^^^^^^^^^^
 
-error: aborting due to 1 previous error
+error[E0792]: expected generic type parameter, found `u32`
+  --> $DIR/multi-error.rs:19:9
+   |
+LL |     type Bar<T> = impl Sized;
+   |              - this generic parameter must be used with a generic type parameter
+...
+LL |         ((), ())
+   |         ^^^^^^^^
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/non-defining-method.rs b/tests/ui/type-alias-impl-trait/non-defining-method.rs
index 2f4a7052f72..8551806b3cb 100644
--- a/tests/ui/type-alias-impl-trait/non-defining-method.rs
+++ b/tests/ui/type-alias-impl-trait/non-defining-method.rs
@@ -15,6 +15,7 @@ impl Foo for () {
     type Bar<T> = impl Sized;
     fn foo() -> Self::Bar<u32> {}
     //~^ ERROR non-defining opaque type use
+    //~| ERROR expected generic type parameter, found `u32`
     fn bar<T>() -> Self::Bar<T> {}
 }
 
diff --git a/tests/ui/type-alias-impl-trait/non-defining-method.stderr b/tests/ui/type-alias-impl-trait/non-defining-method.stderr
index 2ba4c90a1c4..49a393ca745 100644
--- a/tests/ui/type-alias-impl-trait/non-defining-method.stderr
+++ b/tests/ui/type-alias-impl-trait/non-defining-method.stderr
@@ -10,6 +10,14 @@ note: for this opaque type
 LL |     type Bar<T> = impl Sized;
    |                   ^^^^^^^^^^
 
-error: aborting due to 1 previous error
+error[E0792]: expected generic type parameter, found `u32`
+  --> $DIR/non-defining-method.rs:16:32
+   |
+LL |     type Bar<T> = impl Sized;
+   |              - this generic parameter must be used with a generic type parameter
+LL |     fn foo() -> Self::Bar<u32> {}
+   |                                ^^
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr
index 796e2d011dc..e1b320cc38e 100644
--- a/tests/ui/type-alias-impl-trait/reveal_local.stderr
+++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr
@@ -4,16 +4,12 @@ error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque
 LL |     is_send::<Foo>();
    |               ^^^
    |
+   = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
 note: opaque type is declared here
   --> $DIR/reveal_local.rs:5:12
    |
 LL | type Foo = impl Debug;
    |            ^^^^^^^^^^
-note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
-  --> $DIR/reveal_local.rs:9:4
-   |
-LL | fn not_good() {
-   |    ^^^^^^^^
 note: required by a bound in `is_send`
   --> $DIR/reveal_local.rs:7:15
    |
@@ -26,16 +22,12 @@ error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque
 LL |     is_send::<Foo>();
    |               ^^^
    |
+   = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
 note: opaque type is declared here
   --> $DIR/reveal_local.rs:5:12
    |
 LL | type Foo = impl Debug;
    |            ^^^^^^^^^^
-note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
-  --> $DIR/reveal_local.rs:16:4
-   |
-LL | fn not_gooder() -> Foo {
-   |    ^^^^^^^^^^
 note: required by a bound in `is_send`
   --> $DIR/reveal_local.rs:7:15
    |