summaryrefslogtreecommitdiffstats
path: root/src/test/ui/impl-trait
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/impl-trait/auto-trait-leak.stderr18
-rw-r--r--src/test/ui/impl-trait/equality-rpass.stderr2
-rw-r--r--src/test/ui/impl-trait/equality.stderr9
-rw-r--r--src/test/ui/impl-trait/equality2.stderr2
-rw-r--r--src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr4
-rw-r--r--src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr9
-rw-r--r--src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs2
-rw-r--r--src/test/ui/impl-trait/hidden-lifetimes.stderr8
-rw-r--r--src/test/ui/impl-trait/impl-generic-mismatch.rs9
-rw-r--r--src/test/ui/impl-trait/impl-generic-mismatch.stderr18
-rw-r--r--src/test/ui/impl-trait/in-trait/auxiliary/rpitit.rs11
-rw-r--r--src/test/ui/impl-trait/in-trait/deep-match-works.rs16
-rw-r--r--src/test/ui/impl-trait/in-trait/deep-match.rs15
-rw-r--r--src/test/ui/impl-trait/in-trait/deep-match.stderr15
-rw-r--r--src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs13
-rw-r--r--src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr11
-rw-r--r--src/test/ui/impl-trait/in-trait/default-body-type-err.rs13
-rw-r--r--src/test/ui/impl-trait/in-trait/default-body-type-err.stderr12
-rw-r--r--src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs21
-rw-r--r--src/test/ui/impl-trait/in-trait/default-body.rs21
-rw-r--r--src/test/ui/impl-trait/in-trait/doesnt-satisfy.rs13
-rw-r--r--src/test/ui/impl-trait/in-trait/doesnt-satisfy.stderr17
-rw-r--r--src/test/ui/impl-trait/in-trait/early.rs23
-rw-r--r--src/test/ui/impl-trait/in-trait/encode.rs9
-rw-r--r--src/test/ui/impl-trait/in-trait/foreign.rs9
-rw-r--r--src/test/ui/impl-trait/in-trait/issue-102140.rs30
-rw-r--r--src/test/ui/impl-trait/in-trait/issue-102140.stderr29
-rw-r--r--src/test/ui/impl-trait/in-trait/issue-102301.rs18
-rw-r--r--src/test/ui/impl-trait/in-trait/issue-102571.rs24
-rw-r--r--src/test/ui/impl-trait/in-trait/issue-102571.stderr14
-rw-r--r--src/test/ui/impl-trait/in-trait/nested-rpitit.rs32
-rw-r--r--src/test/ui/impl-trait/in-trait/object-safety.rs22
-rw-r--r--src/test/ui/impl-trait/in-trait/object-safety.stderr50
-rw-r--r--src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs19
-rw-r--r--src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr17
-rw-r--r--src/test/ui/impl-trait/in-trait/opaque-in-impl.rs48
-rw-r--r--src/test/ui/impl-trait/in-trait/reveal.rs18
-rw-r--r--src/test/ui/impl-trait/in-trait/signature-mismatch.rs21
-rw-r--r--src/test/ui/impl-trait/in-trait/signature-mismatch.stderr16
-rw-r--r--src/test/ui/impl-trait/in-trait/success.rs40
-rw-r--r--src/test/ui/impl-trait/in-trait/wf-bounds.rs16
-rw-r--r--src/test/ui/impl-trait/in-trait/wf-bounds.stderr33
-rw-r--r--src/test/ui/impl-trait/issue-100075-2.rs8
-rw-r--r--src/test/ui/impl-trait/issue-100075-2.stderr24
-rw-r--r--src/test/ui/impl-trait/issue-100075.rs21
-rw-r--r--src/test/ui/impl-trait/issue-100075.stderr12
-rw-r--r--src/test/ui/impl-trait/issue-102605.rs15
-rw-r--r--src/test/ui/impl-trait/issue-102605.stderr41
-rw-r--r--src/test/ui/impl-trait/issue-103181-1.rs85
-rw-r--r--src/test/ui/impl-trait/issue-103181-1.stderr12
-rw-r--r--src/test/ui/impl-trait/issue-103181-2.rs29
-rw-r--r--src/test/ui/impl-trait/issue-103181-2.stderr9
-rw-r--r--src/test/ui/impl-trait/issue-103599.rs10
-rw-r--r--src/test/ui/impl-trait/issue-103599.stderr14
-rw-r--r--src/test/ui/impl-trait/issue-86465.rs6
-rw-r--r--src/test/ui/impl-trait/issue-86465.stderr2
-rw-r--r--src/test/ui/impl-trait/issue-87450.stderr2
-rw-r--r--src/test/ui/impl-trait/issue-99914.rs13
-rw-r--r--src/test/ui/impl-trait/issue-99914.stderr21
-rw-r--r--src/test/ui/impl-trait/issues/issue-78722.rs4
-rw-r--r--src/test/ui/impl-trait/issues/issue-78722.stderr6
-rw-r--r--src/test/ui/impl-trait/issues/issue-86800.stderr15
-rw-r--r--src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr2
-rw-r--r--src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr2
-rw-r--r--src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr14
-rw-r--r--src/test/ui/impl-trait/nested-return-type2-tait.rs1
-rw-r--r--src/test/ui/impl-trait/nested-return-type2-tait.stderr17
-rw-r--r--src/test/ui/impl-trait/nested-return-type2-tait2.stderr2
-rw-r--r--src/test/ui/impl-trait/nested-return-type2-tait3.stderr2
-rw-r--r--src/test/ui/impl-trait/nested-return-type2.rs1
-rw-r--r--src/test/ui/impl-trait/nested-return-type2.stderr17
-rw-r--r--src/test/ui/impl-trait/nested-return-type3-tait.rs1
-rw-r--r--src/test/ui/impl-trait/nested-return-type3-tait.stderr17
-rw-r--r--src/test/ui/impl-trait/nested-return-type3-tait2.rs1
-rw-r--r--src/test/ui/impl-trait/nested-return-type3-tait2.stderr17
-rw-r--r--src/test/ui/impl-trait/nested-return-type3-tait3.rs1
-rw-r--r--src/test/ui/impl-trait/nested-return-type3-tait3.stderr17
-rw-r--r--src/test/ui/impl-trait/nested-return-type3.rs1
-rw-r--r--src/test/ui/impl-trait/nested-return-type3.stderr17
-rw-r--r--src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs23
-rw-r--r--src/test/ui/impl-trait/nested_impl_trait.stderr4
-rw-r--r--src/test/ui/impl-trait/normalize-tait-in-const.rs39
-rw-r--r--src/test/ui/impl-trait/normalize-tait-in-const.stderr8
-rw-r--r--src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr4
-rw-r--r--src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr4
-rw-r--r--src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr96
-rw-r--r--src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr2
-rw-r--r--src/test/ui/impl-trait/region-escape-via-bound.stderr2
-rw-r--r--src/test/ui/impl-trait/static-return-lifetime-infered.stderr8
-rw-r--r--src/test/ui/impl-trait/suggest-calling-rpit-closure.stderr2
-rw-r--r--src/test/ui/impl-trait/unactionable_diagnostic.fixed25
-rw-r--r--src/test/ui/impl-trait/unactionable_diagnostic.rs25
-rw-r--r--src/test/ui/impl-trait/unactionable_diagnostic.stderr14
-rw-r--r--src/test/ui/impl-trait/where-allowed.stderr8
94 files changed, 1425 insertions, 65 deletions
diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr
index 634ff1486..feedfc40a 100644
--- a/src/test/ui/impl-trait/auto-trait-leak.stderr
+++ b/src/test/ui/impl-trait/auto-trait-leak.stderr
@@ -9,12 +9,12 @@ note: ...which requires borrow-checking `cycle1`...
|
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing `cycle1`...
+note: ...which requires processing MIR for `cycle1`...
--> $DIR/auto-trait-leak.rs:12:1
|
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing MIR for `cycle1`...
+note: ...which requires preparing `cycle1` for borrow checking...
--> $DIR/auto-trait-leak.rs:12:1
|
LL | fn cycle1() -> impl Clone {
@@ -29,6 +29,11 @@ note: ...which requires building MIR for `cycle1`...
|
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires building THIR for `cycle1`...
+ --> $DIR/auto-trait-leak.rs:12:1
+ |
+LL | fn cycle1() -> impl Clone {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `cycle1`...
--> $DIR/auto-trait-leak.rs:14:5
|
@@ -45,12 +50,12 @@ note: ...which requires borrow-checking `cycle2`...
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing `cycle2`...
+note: ...which requires processing MIR for `cycle2`...
--> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing MIR for `cycle2`...
+note: ...which requires preparing `cycle2` for borrow checking...
--> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
@@ -65,6 +70,11 @@ note: ...which requires building MIR for `cycle2`...
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires building THIR for `cycle2`...
+ --> $DIR/auto-trait-leak.rs:19:1
+ |
+LL | fn cycle2() -> impl Clone {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `cycle2`...
--> $DIR/auto-trait-leak.rs:20:5
|
diff --git a/src/test/ui/impl-trait/equality-rpass.stderr b/src/test/ui/impl-trait/equality-rpass.stderr
index 11eeceba0..bde8362fd 100644
--- a/src/test/ui/impl-trait/equality-rpass.stderr
+++ b/src/test/ui/impl-trait/equality-rpass.stderr
@@ -4,9 +4,9 @@ warning: the feature `specialization` is incomplete and may not be safe to use a
LL | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
- = note: `#[warn(incomplete_features)]` on by default
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted
diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr
index f14b447b0..1841b8e5d 100644
--- a/src/test/ui/impl-trait/equality.stderr
+++ b/src/test/ui/impl-trait/equality.stderr
@@ -4,18 +4,23 @@ warning: the feature `specialization` is incomplete and may not be safe to use a
LL | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
- = note: `#[warn(incomplete_features)]` on by default
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
error[E0308]: mismatched types
--> $DIR/equality.rs:15:5
|
LL | fn two(x: bool) -> impl Foo {
- | -------- expected `_` because of return type
+ | -------- expected `i32` because of return type
...
LL | 0_u32
| ^^^^^ expected `i32`, found `u32`
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 0_i32
+ | ~~~
error[E0277]: cannot add `impl Foo` to `u32`
--> $DIR/equality.rs:24:11
diff --git a/src/test/ui/impl-trait/equality2.stderr b/src/test/ui/impl-trait/equality2.stderr
index 46053c6e7..e399a6102 100644
--- a/src/test/ui/impl-trait/equality2.stderr
+++ b/src/test/ui/impl-trait/equality2.stderr
@@ -4,9 +4,9 @@ warning: the feature `specialization` is incomplete and may not be safe to use a
LL | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
- = note: `#[warn(incomplete_features)]` on by default
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
error[E0308]: mismatched types
--> $DIR/equality2.rs:25:18
diff --git a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr
index fd2e454e7..edf3911e2 100644
--- a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr
+++ b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr
@@ -1,8 +1,8 @@
-error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied
+error[E0277]: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not satisfied
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13
|
LL | fn ice() -> impl AsRef<Fn(&())> {
- | ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not implemented for `()`
+ | ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not implemented for `()`
error: aborting due to previous error
diff --git a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr
index c01c33a89..88e2520bf 100644
--- a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr
+++ b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr
@@ -6,15 +6,14 @@ LL | fn ice() -> impl AsRef<Fn(&())> {
|
help: add `dyn` keyword before this trait
|
-LL - fn ice() -> impl AsRef<Fn(&())> {
-LL + fn ice() -> impl AsRef<dyn Fn(&())> {
- |
+LL | fn ice() -> impl AsRef<dyn Fn(&())> {
+ | +++
-error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied
+error[E0277]: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not satisfied
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13
|
LL | fn ice() -> impl AsRef<Fn(&())> {
- | ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not implemented for `()`
+ | ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not implemented for `()`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs
index 856dc7a3f..5a922697f 100644
--- a/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs
+++ b/src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs
@@ -4,7 +4,7 @@
#![allow(warnings)]
fn ice() -> impl AsRef<Fn(&())> {
- //~^ ERROR: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied [E0277]
+ //~^ ERROR: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not satisfied [E0277]
//[edition2021]~| ERROR: trait objects must include the `dyn` keyword [E0782]
todo!()
}
diff --git a/src/test/ui/impl-trait/hidden-lifetimes.stderr b/src/test/ui/impl-trait/hidden-lifetimes.stderr
index efc228de5..3cc47e1e8 100644
--- a/src/test/ui/impl-trait/hidden-lifetimes.stderr
+++ b/src/test/ui/impl-trait/hidden-lifetimes.stderr
@@ -1,4 +1,4 @@
-error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds
+error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds
--> $DIR/hidden-lifetimes.rs:29:5
|
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
@@ -6,12 +6,12 @@ LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
LL | x
| ^
|
-help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound
+help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
|
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b {
| ++++
-error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds
+error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds
--> $DIR/hidden-lifetimes.rs:46:5
|
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
@@ -19,7 +19,7 @@ LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl S
LL | x
| ^
|
-help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound
+help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
|
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + 'b {
| ++++
diff --git a/src/test/ui/impl-trait/impl-generic-mismatch.rs b/src/test/ui/impl-trait/impl-generic-mismatch.rs
index ba678bb03..fb8bde0d0 100644
--- a/src/test/ui/impl-trait/impl-generic-mismatch.rs
+++ b/src/test/ui/impl-trait/impl-generic-mismatch.rs
@@ -18,6 +18,15 @@ impl Bar for () {
//~^ Error method `bar` has incompatible signature for trait
}
+trait Baz {
+ fn baz<U: Debug, T: Debug>(&self, _: &U, _: &T);
+}
+
+impl Baz for () {
+ fn baz<T: Debug>(&self, _: &impl Debug, _: &T) { }
+ //~^ Error method `baz` has incompatible signature for trait
+}
+
// With non-local trait (#49841):
use std::hash::{Hash, Hasher};
diff --git a/src/test/ui/impl-trait/impl-generic-mismatch.stderr b/src/test/ui/impl-trait/impl-generic-mismatch.stderr
index 489afd761..542f02d7e 100644
--- a/src/test/ui/impl-trait/impl-generic-mismatch.stderr
+++ b/src/test/ui/impl-trait/impl-generic-mismatch.stderr
@@ -27,8 +27,22 @@ help: try changing the `impl Trait` argument to a generic parameter
LL | fn bar<U: Debug>(&self, _: &U) { }
| ++++++++++ ~
+error[E0643]: method `baz` has incompatible signature for trait
+ --> $DIR/impl-generic-mismatch.rs:26:33
+ |
+LL | fn baz<U: Debug, T: Debug>(&self, _: &U, _: &T);
+ | - declaration in trait here
+...
+LL | fn baz<T: Debug>(&self, _: &impl Debug, _: &T) { }
+ | ^^^^^^^^^^ expected generic parameter, found `impl Trait`
+ |
+help: try changing the `impl Trait` argument to a generic parameter
+ |
+LL | fn baz<U: Debug, T: Debug>(&self, _: &T, _: &T) { }
+ | ~~~~~~~~~~~~~~~~~~~~ ~
+
error[E0643]: method `hash` has incompatible signature for trait
- --> $DIR/impl-generic-mismatch.rs:28:33
+ --> $DIR/impl-generic-mismatch.rs:37:33
|
LL | fn hash(&self, hasher: &mut impl Hasher) {}
| ^^^^^^^^^^^ expected generic parameter, found `impl Trait`
@@ -38,6 +52,6 @@ LL | fn hash(&self, hasher: &mut impl Hasher) {}
LL | fn hash<H: Hasher>(&self, state: &mut H);
| - declaration in trait here
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0643`.
diff --git a/src/test/ui/impl-trait/in-trait/auxiliary/rpitit.rs b/src/test/ui/impl-trait/in-trait/auxiliary/rpitit.rs
new file mode 100644
index 000000000..74df300f8
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/auxiliary/rpitit.rs
@@ -0,0 +1,11 @@
+#![feature(return_position_impl_trait_in_trait)]
+
+pub trait Foo {
+ fn bar() -> impl Sized;
+}
+
+pub struct Foreign;
+
+impl Foo for Foreign {
+ fn bar() {}
+}
diff --git a/src/test/ui/impl-trait/in-trait/deep-match-works.rs b/src/test/ui/impl-trait/in-trait/deep-match-works.rs
new file mode 100644
index 000000000..772da845e
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/deep-match-works.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+struct Wrapper<T>(T);
+
+trait Foo {
+ fn bar() -> Wrapper<impl Sized>;
+}
+
+impl Foo for () {
+ fn bar() -> Wrapper<i32> { Wrapper(0) }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/deep-match.rs b/src/test/ui/impl-trait/in-trait/deep-match.rs
new file mode 100644
index 000000000..a6385147c
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/deep-match.rs
@@ -0,0 +1,15 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+struct Wrapper<T>(T);
+
+trait Foo {
+ fn bar() -> Wrapper<impl Sized>;
+}
+
+impl Foo for () {
+ fn bar() -> i32 { 0 }
+ //~^ ERROR method `bar` has an incompatible return type for trait
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/deep-match.stderr b/src/test/ui/impl-trait/in-trait/deep-match.stderr
new file mode 100644
index 000000000..034ee5ea4
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/deep-match.stderr
@@ -0,0 +1,15 @@
+error[E0053]: method `bar` has an incompatible return type for trait
+ --> $DIR/deep-match.rs:11:17
+ |
+LL | fn bar() -> i32 { 0 }
+ | ^^^
+ | |
+ | expected struct `Wrapper`, found `i32`
+ | return type in trait
+ |
+ = note: expected struct `Wrapper<_>`
+ found type `i32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0053`.
diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs
new file mode 100644
index 000000000..45ae2b8ad
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.rs
@@ -0,0 +1,13 @@
+// edition:2021
+
+#![allow(incomplete_features)]
+#![feature(async_fn_in_trait)]
+
+pub trait Foo {
+ async fn woopsie_async(&self) -> String {
+ 42
+ //~^ ERROR mismatched types
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr
new file mode 100644
index 000000000..142b1bff1
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/default-body-type-err-2.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/default-body-type-err-2.rs:8:9
+ |
+LL | 42
+ | ^^- help: try using a conversion method: `.to_string()`
+ | |
+ | expected struct `String`, found integer
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err.rs b/src/test/ui/impl-trait/in-trait/default-body-type-err.rs
new file mode 100644
index 000000000..ac9baf91c
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/default-body-type-err.rs
@@ -0,0 +1,13 @@
+#![allow(incomplete_features)]
+#![feature(return_position_impl_trait_in_trait)]
+
+use std::ops::Deref;
+
+pub trait Foo {
+ fn lol(&self) -> impl Deref<Target = String> {
+ //~^ type mismatch resolving `<&i32 as Deref>::Target == String`
+ &1i32
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/default-body-type-err.stderr b/src/test/ui/impl-trait/in-trait/default-body-type-err.stderr
new file mode 100644
index 000000000..461247a3e
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/default-body-type-err.stderr
@@ -0,0 +1,12 @@
+error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String`
+ --> $DIR/default-body-type-err.rs:7:22
+ |
+LL | fn lol(&self) -> impl Deref<Target = String> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String`
+LL |
+LL | &1i32
+ | ----- return type was inferred to be `&i32` here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs b/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs
new file mode 100644
index 000000000..ad3cc7c25
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/default-body-with-rpit.rs
@@ -0,0 +1,21 @@
+// check-pass
+// edition:2021
+
+#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+trait Foo {
+ async fn baz(&self) -> impl Debug {
+ ""
+ }
+}
+
+struct Bar;
+
+impl Foo for Bar {}
+
+fn main() {
+ let _ = Bar.baz();
+}
diff --git a/src/test/ui/impl-trait/in-trait/default-body.rs b/src/test/ui/impl-trait/in-trait/default-body.rs
new file mode 100644
index 000000000..b0baf5bb1
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/default-body.rs
@@ -0,0 +1,21 @@
+// check-pass
+// edition:2021
+
+#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+trait Foo {
+ async fn baz(&self) -> &str {
+ ""
+ }
+}
+
+struct Bar;
+
+impl Foo for Bar {}
+
+fn main() {
+ let _ = Bar.baz();
+}
diff --git a/src/test/ui/impl-trait/in-trait/doesnt-satisfy.rs b/src/test/ui/impl-trait/in-trait/doesnt-satisfy.rs
new file mode 100644
index 000000000..bb4e0d44f
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/doesnt-satisfy.rs
@@ -0,0 +1,13 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Foo {
+ fn bar() -> impl std::fmt::Display;
+}
+
+impl Foo for () {
+ fn bar() -> () {}
+ //~^ ERROR `()` doesn't implement `std::fmt::Display`
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/src/test/ui/impl-trait/in-trait/doesnt-satisfy.stderr
new file mode 100644
index 000000000..aa5492d28
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/doesnt-satisfy.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `()` doesn't implement `std::fmt::Display`
+ --> $DIR/doesnt-satisfy.rs:9:17
+ |
+LL | fn bar() -> () {}
+ | ^^ `()` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `()`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `Foo::bar::{opaque#0}`
+ --> $DIR/doesnt-satisfy.rs:5:22
+ |
+LL | fn bar() -> impl std::fmt::Display;
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::bar::{opaque#0}`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/impl-trait/in-trait/early.rs b/src/test/ui/impl-trait/in-trait/early.rs
new file mode 100644
index 000000000..9c1c2b503
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/early.rs
@@ -0,0 +1,23 @@
+// check-pass
+// edition:2021
+
+#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+pub trait Foo {
+ async fn bar<'a: 'a>(&'a mut self);
+}
+
+impl Foo for () {
+ async fn bar<'a: 'a>(&'a mut self) {}
+}
+
+pub trait Foo2 {
+ fn bar<'a: 'a>(&'a mut self) -> impl Sized + 'a;
+}
+
+impl Foo2 for () {
+ fn bar<'a: 'a>(&'a mut self) -> impl Sized + 'a {}
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/encode.rs b/src/test/ui/impl-trait/in-trait/encode.rs
new file mode 100644
index 000000000..efb9f6498
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/encode.rs
@@ -0,0 +1,9 @@
+// build-pass
+// compile-flags: --crate-type=lib
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Foo {
+ fn bar() -> impl Sized;
+}
diff --git a/src/test/ui/impl-trait/in-trait/foreign.rs b/src/test/ui/impl-trait/in-trait/foreign.rs
new file mode 100644
index 000000000..6341f5b42
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/foreign.rs
@@ -0,0 +1,9 @@
+// check-pass
+// aux-build: rpitit.rs
+
+extern crate rpitit;
+
+fn main() {
+ // Witness an RPITIT from another crate
+ let () = <rpitit::Foreign as rpitit::Foo>::bar();
+}
diff --git a/src/test/ui/impl-trait/in-trait/issue-102140.rs b/src/test/ui/impl-trait/in-trait/issue-102140.rs
new file mode 100644
index 000000000..be1e012ac
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/issue-102140.rs
@@ -0,0 +1,30 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Marker {}
+impl Marker for u32 {}
+
+trait MyTrait {
+ fn foo(&self) -> impl Marker
+ where
+ Self: Sized;
+}
+
+struct Outer;
+
+impl MyTrait for Outer {
+ fn foo(&self) -> impl Marker {
+ 42
+ }
+}
+
+impl dyn MyTrait {
+ fn other(&self) -> impl Marker {
+ MyTrait::foo(&self)
+ //~^ ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
+ //~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
+ //~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/issue-102140.stderr b/src/test/ui/impl-trait/in-trait/issue-102140.stderr
new file mode 100644
index 000000000..08602185f
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/issue-102140.stderr
@@ -0,0 +1,29 @@
+error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
+ --> $DIR/issue-102140.rs:23:22
+ |
+LL | MyTrait::foo(&self)
+ | ------------ -^^^^
+ | | |
+ | | the trait `MyTrait` is not implemented for `&dyn MyTrait`
+ | | help: consider removing the leading `&`-reference
+ | required by a bound introduced by this call
+
+error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
+ --> $DIR/issue-102140.rs:23:9
+ |
+LL | MyTrait::foo(&self)
+ | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
+ |
+ = help: the trait `MyTrait` is implemented for `Outer`
+
+error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
+ --> $DIR/issue-102140.rs:23:9
+ |
+LL | MyTrait::foo(&self)
+ | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
+ |
+ = help: the trait `MyTrait` is implemented for `Outer`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/impl-trait/in-trait/issue-102301.rs b/src/test/ui/impl-trait/in-trait/issue-102301.rs
new file mode 100644
index 000000000..a93714a65
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/issue-102301.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Foo<T> {
+ fn foo<F2: Foo<T>>(self) -> impl Foo<T>;
+}
+
+struct Bar;
+
+impl Foo<u8> for Bar {
+ fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
+ self
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/issue-102571.rs b/src/test/ui/impl-trait/in-trait/issue-102571.rs
new file mode 100644
index 000000000..61c91e644
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/issue-102571.rs
@@ -0,0 +1,24 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Display;
+use std::ops::Deref;
+
+trait Foo {
+ fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
+}
+
+struct A;
+
+impl Foo for A {
+ fn bar(self) -> &'static str {
+ "Hello, world"
+ }
+}
+
+fn foo<T: Foo>(t: T) {
+ let () = t.bar();
+ //~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/issue-102571.stderr b/src/test/ui/impl-trait/in-trait/issue-102571.stderr
new file mode 100644
index 000000000..87219941d
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/issue-102571.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-102571.rs:20:9
+ |
+LL | let () = t.bar();
+ | ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
+ | |
+ | expected associated type, found `()`
+ |
+ = note: expected associated type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
+ found unit type `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/impl-trait/in-trait/nested-rpitit.rs b/src/test/ui/impl-trait/in-trait/nested-rpitit.rs
new file mode 100644
index 000000000..65285e3a3
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/nested-rpitit.rs
@@ -0,0 +1,32 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Display;
+use std::ops::Deref;
+
+trait Foo {
+ fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
+}
+
+struct A;
+
+impl Foo for A {
+ fn bar(self) -> &'static str {
+ "Hello, world"
+ }
+}
+
+struct B;
+
+impl Foo for B {
+ fn bar(self) -> Box<i32> {
+ Box::new(42)
+ }
+}
+
+fn main() {
+ println!("Message for you: {:?}", &*A.bar());
+ println!("Another for you: {:?}", &*B.bar());
+}
diff --git a/src/test/ui/impl-trait/in-trait/object-safety.rs b/src/test/ui/impl-trait/in-trait/object-safety.rs
new file mode 100644
index 000000000..dd35b9a2d
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/object-safety.rs
@@ -0,0 +1,22 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+trait Foo {
+ fn baz(&self) -> impl Debug;
+}
+
+impl Foo for u32 {
+ fn baz(&self) -> u32 {
+ 32
+ }
+}
+
+fn main() {
+ let i = Box::new(42_u32) as Box<dyn Foo>;
+ //~^ ERROR the trait `Foo` cannot be made into an object
+ //~| ERROR the trait `Foo` cannot be made into an object
+ let s = i.baz();
+ //~^ ERROR the trait `Foo` cannot be made into an object
+}
diff --git a/src/test/ui/impl-trait/in-trait/object-safety.stderr b/src/test/ui/impl-trait/in-trait/object-safety.stderr
new file mode 100644
index 000000000..9a1554b5e
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/object-safety.stderr
@@ -0,0 +1,50 @@
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/object-safety.rs:17:33
+ |
+LL | let i = Box::new(42_u32) as Box<dyn Foo>;
+ | ^^^^^^^^^^^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-safety.rs:7:8
+ |
+LL | trait Foo {
+ | --- this trait cannot be made into an object...
+LL | fn baz(&self) -> impl Debug;
+ | ^^^ ...because method `baz` references an `impl Trait` type in its return type
+ = help: consider moving `baz` to another trait
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/object-safety.rs:20:13
+ |
+LL | let s = i.baz();
+ | ^^^^^^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-safety.rs:7:8
+ |
+LL | trait Foo {
+ | --- this trait cannot be made into an object...
+LL | fn baz(&self) -> impl Debug;
+ | ^^^ ...because method `baz` references an `impl Trait` type in its return type
+ = help: consider moving `baz` to another trait
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/object-safety.rs:17:13
+ |
+LL | let i = Box::new(42_u32) as Box<dyn Foo>;
+ | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-safety.rs:7:8
+ |
+LL | trait Foo {
+ | --- this trait cannot be made into an object...
+LL | fn baz(&self) -> impl Debug;
+ | ^^^ ...because method `baz` references an `impl Trait` type in its return type
+ = help: consider moving `baz` to another trait
+ = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>`
+ = note: required by cast to type `Box<dyn Foo>`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0038`.
diff --git a/src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs b/src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs
new file mode 100644
index 000000000..3ac264e8e
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs
@@ -0,0 +1,19 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Display;
+
+trait Foo {
+ fn bar(&self) -> impl Display;
+}
+
+impl Foo for () {
+ fn bar(&self) -> impl Display {
+ "Hello, world"
+ }
+}
+
+fn main() {
+ let x: &str = ().bar();
+ //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr b/src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr
new file mode 100644
index 000000000..15edda483
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr
@@ -0,0 +1,17 @@
+error[E0308]: mismatched types
+ --> $DIR/opaque-in-impl-is-opaque.rs:17:19
+ |
+LL | fn bar(&self) -> impl Display {
+ | ------------ the found opaque type
+...
+LL | let x: &str = ().bar();
+ | ---- ^^^^^^^^ expected `&str`, found opaque type
+ | |
+ | expected due to this
+ |
+ = note: expected reference `&str`
+ found opaque type `impl std::fmt::Display`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/impl-trait/in-trait/opaque-in-impl.rs b/src/test/ui/impl-trait/in-trait/opaque-in-impl.rs
new file mode 100644
index 000000000..2e0662969
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/opaque-in-impl.rs
@@ -0,0 +1,48 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+trait Foo {
+ fn foo(&self) -> impl Debug;
+}
+
+impl Foo for () {
+ fn foo(&self) -> impl Debug {
+ "Hello, world"
+ }
+}
+
+impl<T: Default + Debug> Foo for std::marker::PhantomData<T> {
+ fn foo(&self) -> impl Debug {
+ T::default()
+ }
+}
+
+trait Bar {
+ fn bar<T>(&self) -> impl Debug;
+}
+
+impl Bar for () {
+ fn bar<T>(&self) -> impl Debug {
+ format!("Hello with generic {}", std::any::type_name::<T>())
+ }
+}
+
+trait Baz {
+ fn baz(&self) -> impl Debug + '_;
+}
+
+impl Baz for String {
+ fn baz(&self) -> impl Debug + '_ {
+ (self,)
+ }
+}
+
+fn main() {
+ println!("{:?}", ().foo());
+ println!("{:?}", ().bar::<u64>());
+ println!("{:?}", "hi".to_string().baz());
+}
diff --git a/src/test/ui/impl-trait/in-trait/reveal.rs b/src/test/ui/impl-trait/in-trait/reveal.rs
new file mode 100644
index 000000000..d6ede1cc4
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/reveal.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Foo {
+ fn f() -> Box<impl Sized>;
+}
+
+impl Foo for () {
+ fn f() -> Box<String> {
+ Box::new(String::new())
+ }
+}
+
+fn main() {
+ let x: Box<String> = <() as Foo>::f();
+}
diff --git a/src/test/ui/impl-trait/in-trait/signature-mismatch.rs b/src/test/ui/impl-trait/in-trait/signature-mismatch.rs
new file mode 100644
index 000000000..90682631a
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/signature-mismatch.rs
@@ -0,0 +1,21 @@
+// edition:2021
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::future::Future;
+
+pub trait AsyncTrait {
+ fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
+}
+
+pub struct Struct;
+
+impl AsyncTrait for Struct {
+ fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ //~^ ERROR `impl` item signature doesn't match `trait` item signature
+ async move { buff.to_vec() }
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr b/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr
new file mode 100644
index 000000000..6663d7faa
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/signature-mismatch.stderr
@@ -0,0 +1,16 @@
+error: `impl` item signature doesn't match `trait` item signature
+ --> $DIR/signature-mismatch.rs:15:5
+ |
+LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
+ | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + 'static`
+...
+LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
+ |
+ = note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + 'static`
+ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
+ = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
+ = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/impl-trait/in-trait/success.rs b/src/test/ui/impl-trait/in-trait/success.rs
new file mode 100644
index 000000000..4cbe682b4
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/success.rs
@@ -0,0 +1,40 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Display;
+
+trait Foo {
+ fn bar(&self) -> impl Display;
+}
+
+impl Foo for i32 {
+ fn bar(&self) -> i32 {
+ *self
+ }
+}
+
+impl Foo for &'static str {
+ fn bar(&self) -> &'static str {
+ *self
+ }
+}
+
+struct Yay;
+
+impl Foo for Yay {
+ fn bar(&self) -> String {
+ String::from(":^)")
+ }
+}
+
+fn foo_generically<T: Foo>(t: T) {
+ println!("{}", t.bar());
+}
+
+fn main() {
+ println!("{}", "Hello, world.".bar());
+ println!("The answer is {}!", 42.bar());
+ foo_generically(Yay);
+}
diff --git a/src/test/ui/impl-trait/in-trait/wf-bounds.rs b/src/test/ui/impl-trait/in-trait/wf-bounds.rs
new file mode 100644
index 000000000..2c71583b3
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/wf-bounds.rs
@@ -0,0 +1,16 @@
+// issue #101663
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Wf<T> {}
+
+trait Uwu {
+ fn nya() -> impl Wf<Vec<[u8]>>;
+ //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+
+ fn nya2() -> impl Wf<[u8]>;
+ //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/wf-bounds.stderr b/src/test/ui/impl-trait/in-trait/wf-bounds.stderr
new file mode 100644
index 000000000..92e36841b
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/wf-bounds.stderr
@@ -0,0 +1,33 @@
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+ --> $DIR/wf-bounds.rs:9:22
+ |
+LL | fn nya() -> impl Wf<Vec<[u8]>>;
+ | ^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `Vec`
+ --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+ |
+LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
+ | ^ required by this bound in `Vec`
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+ --> $DIR/wf-bounds.rs:12:23
+ |
+LL | fn nya2() -> impl Wf<[u8]>;
+ | ^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `Wf`
+ --> $DIR/wf-bounds.rs:6:10
+ |
+LL | trait Wf<T> {}
+ | ^ required by this bound in `Wf`
+help: consider relaxing the implicit `Sized` restriction
+ |
+LL | trait Wf<T: ?Sized> {}
+ | ++++++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/impl-trait/issue-100075-2.rs b/src/test/ui/impl-trait/issue-100075-2.rs
new file mode 100644
index 000000000..cf059af19
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-100075-2.rs
@@ -0,0 +1,8 @@
+fn opaque<T>(t: T) -> impl Sized {
+ //~^ ERROR cannot resolve opaque type
+ //~| WARNING function cannot return without recursing
+ opaque(Some(t))
+}
+
+#[allow(dead_code)]
+fn main() {}
diff --git a/src/test/ui/impl-trait/issue-100075-2.stderr b/src/test/ui/impl-trait/issue-100075-2.stderr
new file mode 100644
index 000000000..d2dbd8c62
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-100075-2.stderr
@@ -0,0 +1,24 @@
+warning: function cannot return without recursing
+ --> $DIR/issue-100075-2.rs:1:1
+ |
+LL | fn opaque<T>(t: T) -> impl Sized {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
+...
+LL | opaque(Some(t))
+ | --------------- recursive call site
+ |
+ = help: a `loop` may express intention better if this is on purpose
+ = note: `#[warn(unconditional_recursion)]` on by default
+
+error[E0720]: cannot resolve opaque type
+ --> $DIR/issue-100075-2.rs:1:23
+ |
+LL | fn opaque<T>(t: T) -> impl Sized {
+ | ^^^^^^^^^^ recursive opaque type
+...
+LL | opaque(Some(t))
+ | --------------- returning here with type `impl Sized`
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/src/test/ui/impl-trait/issue-100075.rs b/src/test/ui/impl-trait/issue-100075.rs
new file mode 100644
index 000000000..ea30abb48
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-100075.rs
@@ -0,0 +1,21 @@
+trait Marker {}
+impl<T> Marker for T {}
+
+fn maybe<T>(
+ _t: T,
+) -> Option<
+ //removing the line below makes it compile
+ &'static T,
+> {
+ None
+}
+
+fn _g<T>(t: &'static T) -> &'static impl Marker {
+ //~^ ERROR cannot resolve opaque type
+ if let Some(t) = maybe(t) {
+ return _g(t);
+ }
+ todo!()
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/issue-100075.stderr b/src/test/ui/impl-trait/issue-100075.stderr
new file mode 100644
index 000000000..267ecfdae
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-100075.stderr
@@ -0,0 +1,12 @@
+error[E0720]: cannot resolve opaque type
+ --> $DIR/issue-100075.rs:13:37
+ |
+LL | fn _g<T>(t: &'static T) -> &'static impl Marker {
+ | ^^^^^^^^^^^ recursive opaque type
+...
+LL | return _g(t);
+ | ----- returning here with type `&impl Marker`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/src/test/ui/impl-trait/issue-102605.rs b/src/test/ui/impl-trait/issue-102605.rs
new file mode 100644
index 000000000..3bbdf35af
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-102605.rs
@@ -0,0 +1,15 @@
+// edition:2021
+
+async fn foo() -> Result<(), String> {
+ Ok(())
+}
+
+fn convert_result<T, E>(r: Result<T, E>) -> Option<T> {
+ None
+}
+
+fn main() -> Option<()> {
+ //~^ ERROR `main` has invalid return type `Option<()>`
+ convert_result(foo())
+ //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/impl-trait/issue-102605.stderr b/src/test/ui/impl-trait/issue-102605.stderr
new file mode 100644
index 000000000..d4aba9149
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-102605.stderr
@@ -0,0 +1,41 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-102605.rs:13:20
+ |
+LL | convert_result(foo())
+ | -------------- ^^^^^ expected enum `Result`, found opaque type
+ | |
+ | arguments to this function are incorrect
+ |
+note: while checking the return type of the `async fn`
+ --> $DIR/issue-102605.rs:3:19
+ |
+LL | async fn foo() -> Result<(), String> {
+ | ^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, found opaque type
+ = note: expected enum `Result<(), _>`
+ found opaque type `impl Future<Output = Result<(), String>>`
+note: function defined here
+ --> $DIR/issue-102605.rs:7:4
+ |
+LL | fn convert_result<T, E>(r: Result<T, E>) -> Option<T> {
+ | ^^^^^^^^^^^^^^ ---------------
+help: consider `await`ing on the `Future`
+ |
+LL | convert_result(foo().await)
+ | ++++++
+help: try wrapping the expression in `Err`
+ |
+LL | convert_result(Err(foo()))
+ | ++++ +
+
+error[E0277]: `main` has invalid return type `Option<()>`
+ --> $DIR/issue-102605.rs:11:14
+ |
+LL | fn main() -> Option<()> {
+ | ^^^^^^^^^^ `main` can only return types that implement `Termination`
+ |
+ = help: consider using `()`, or a `Result`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/impl-trait/issue-103181-1.rs b/src/test/ui/impl-trait/issue-103181-1.rs
new file mode 100644
index 000000000..197aedf9d
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-103181-1.rs
@@ -0,0 +1,85 @@
+// edition:2021
+
+mod hyper {
+ use std::{fmt::Debug, future::Future, marker::PhantomData, pin::Pin, task::Poll};
+
+ pub trait HttpBody {
+ type Error;
+ }
+ impl HttpBody for () {
+ //~^ ERROR not all trait items implemented, missing: `Error`
+ // don't implement `Error` here for the ICE
+ }
+
+ pub struct Server<I, S>(I, S);
+
+ pub fn serve<I, S>(_: S) -> Server<I, S> {
+ todo!()
+ }
+
+ impl<S, B> Future for Server<(), S>
+ where
+ S: MakeServiceRef<(), (), ResBody = B>,
+ B: HttpBody,
+ B::Error: Debug,
+ {
+ type Output = ();
+
+ fn poll(self: Pin<&mut Self>, _: &mut std::task::Context<'_>) -> Poll<Self::Output> {
+ todo!()
+ }
+ }
+
+ pub trait MakeServiceRef<Target, ReqBody> {
+ type ResBody;
+ }
+
+ impl<T, S> MakeServiceRef<(), ()> for T
+ where
+ T: for<'a> Service<&'a (), Response = S>,
+ S: Service<()>,
+ {
+ type ResBody = ();
+ }
+
+ pub struct MakeServiceFn<F>(pub F);
+ pub struct ServiceFn<F, R>(pub PhantomData<(F, R)>);
+
+ pub trait Service<Request> {
+ type Response;
+ }
+
+ impl<'t, F, Ret, Target, Svc> Service<&'t Target> for MakeServiceFn<F>
+ where
+ F: Fn() -> Ret,
+ Ret: Future<Output = Result<Svc, ()>>,
+ {
+ type Response = Svc;
+ }
+
+ impl<F, ReqBody, Ret, ResBody, E> Service<ReqBody> for ServiceFn<F, ReqBody>
+ where
+ F: Fn() -> Ret,
+ Ret: Future<Output = Result<ResBody, E>>,
+ {
+ type Response = ResBody;
+ }
+}
+
+async fn smarvice() -> Result<(), ()> {
+ Ok(())
+}
+
+fn service_fn<F, R, S>(f: F) -> hyper::ServiceFn<F, R>
+where
+ F: Fn() -> S,
+{
+ hyper::ServiceFn(std::marker::PhantomData)
+}
+
+async fn iceice() {
+ let service = hyper::MakeServiceFn(|| async { Ok::<_, ()>(service_fn(|| smarvice())) });
+ hyper::serve::<(), _>(service).await;
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/issue-103181-1.stderr b/src/test/ui/impl-trait/issue-103181-1.stderr
new file mode 100644
index 000000000..cd026607d
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-103181-1.stderr
@@ -0,0 +1,12 @@
+error[E0046]: not all trait items implemented, missing: `Error`
+ --> $DIR/issue-103181-1.rs:9:5
+ |
+LL | type Error;
+ | ---------- `Error` from trait
+LL | }
+LL | impl HttpBody for () {
+ | ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/src/test/ui/impl-trait/issue-103181-2.rs b/src/test/ui/impl-trait/issue-103181-2.rs
new file mode 100644
index 000000000..b43ac4507
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-103181-2.rs
@@ -0,0 +1,29 @@
+// edition:2021
+
+trait SendFuture: Send {
+ type Output;
+}
+
+impl<Fut: Send> SendFuture for Fut {
+ type Output = ();
+}
+
+async fn broken_fut() {
+ ident_error;
+ //~^ ERROR cannot find value `ident_error` in this scope
+}
+
+// triggers normalization of `<Fut as SendFuture>::Output`,
+// which requires `Fut: Send`.
+fn normalize<Fut: SendFuture>(_: Fut, _: Fut::Output) {}
+
+async fn iceice<A, B>()
+// <- async fn is necessary
+where
+ A: Send,
+ B: Send, // <- a second bound
+{
+ normalize(broken_fut(), ());
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/issue-103181-2.stderr b/src/test/ui/impl-trait/issue-103181-2.stderr
new file mode 100644
index 000000000..5eb2dd918
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-103181-2.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `ident_error` in this scope
+ --> $DIR/issue-103181-2.rs:12:5
+ |
+LL | ident_error;
+ | ^^^^^^^^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/impl-trait/issue-103599.rs b/src/test/ui/impl-trait/issue-103599.rs
new file mode 100644
index 000000000..043ae67f2
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-103599.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+trait T {}
+
+fn wrap(x: impl T) -> impl T {
+ //~^ WARN function cannot return without recursing
+ wrap(wrap(x))
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/issue-103599.stderr b/src/test/ui/impl-trait/issue-103599.stderr
new file mode 100644
index 000000000..82038c1dc
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-103599.stderr
@@ -0,0 +1,14 @@
+warning: function cannot return without recursing
+ --> $DIR/issue-103599.rs:5:1
+ |
+LL | fn wrap(x: impl T) -> impl T {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
+LL |
+LL | wrap(wrap(x))
+ | ------- recursive call site
+ |
+ = help: a `loop` may express intention better if this is on purpose
+ = note: `#[warn(unconditional_recursion)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/issue-86465.rs b/src/test/ui/impl-trait/issue-86465.rs
index a79bb6474..8c7b41d73 100644
--- a/src/test/ui/impl-trait/issue-86465.rs
+++ b/src/test/ui/impl-trait/issue-86465.rs
@@ -1,6 +1,10 @@
#![feature(type_alias_impl_trait)]
-type X<'a, 'b> = impl std::fmt::Debug;
+pub trait Captures<'a> {}
+
+impl<'a, T: ?Sized> Captures<'a> for T {}
+
+type X<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
fn f<'t, 'u>(a: &'t u32, b: &'u u32) -> (X<'t, 'u>, X<'u, 't>) {
(a, a)
diff --git a/src/test/ui/impl-trait/issue-86465.stderr b/src/test/ui/impl-trait/issue-86465.stderr
index 90d6904ed..b949b2b42 100644
--- a/src/test/ui/impl-trait/issue-86465.stderr
+++ b/src/test/ui/impl-trait/issue-86465.stderr
@@ -1,5 +1,5 @@
error: concrete type differs from previous defining opaque type use
- --> $DIR/issue-86465.rs:6:5
+ --> $DIR/issue-86465.rs:10:5
|
LL | (a, a)
| ^^^^^^
diff --git a/src/test/ui/impl-trait/issue-87450.stderr b/src/test/ui/impl-trait/issue-87450.stderr
index 5019e544b..173fca63f 100644
--- a/src/test/ui/impl-trait/issue-87450.stderr
+++ b/src/test/ui/impl-trait/issue-87450.stderr
@@ -7,8 +7,8 @@ LL | fn foo() -> impl Fn() {
LL | wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo())))))))
| ----- recursive call site
|
- = note: `#[warn(unconditional_recursion)]` on by default
= help: a `loop` may express intention better if this is on purpose
+ = note: `#[warn(unconditional_recursion)]` on by default
error[E0720]: cannot resolve opaque type
--> $DIR/issue-87450.rs:5:13
diff --git a/src/test/ui/impl-trait/issue-99914.rs b/src/test/ui/impl-trait/issue-99914.rs
new file mode 100644
index 000000000..4324a0229
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-99914.rs
@@ -0,0 +1,13 @@
+// edition:2021
+
+fn main() {}
+
+struct Error;
+struct Okay;
+
+fn foo(t: Result<Okay, Error>) {
+ t.and_then(|t| -> _ { bar(t) });
+ //~^ ERROR mismatched types
+}
+
+async fn bar(t: Okay) {}
diff --git a/src/test/ui/impl-trait/issue-99914.stderr b/src/test/ui/impl-trait/issue-99914.stderr
new file mode 100644
index 000000000..074d5d58d
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-99914.stderr
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-99914.rs:9:27
+ |
+LL | t.and_then(|t| -> _ { bar(t) });
+ | ^^^^^^ expected enum `Result`, found opaque type
+ |
+note: while checking the return type of the `async fn`
+ --> $DIR/issue-99914.rs:13:23
+ |
+LL | async fn bar(t: Okay) {}
+ | ^ checked the `Output` of this `async fn`, found opaque type
+ = note: expected enum `Result<_, Error>`
+ found opaque type `impl Future<Output = ()>`
+help: try wrapping the expression in `Ok`
+ |
+LL | t.and_then(|t| -> _ { Ok(bar(t)) });
+ | +++ +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/impl-trait/issues/issue-78722.rs b/src/test/ui/impl-trait/issues/issue-78722.rs
index 002e4cde4..9ee1ba3d3 100644
--- a/src/test/ui/impl-trait/issues/issue-78722.rs
+++ b/src/test/ui/impl-trait/issues/issue-78722.rs
@@ -7,12 +7,12 @@ type F = impl core::future::Future<Output = u8>;
struct Bug {
V1: [(); {
fn concrete_use() -> F {
- //~^ ERROR type mismatch
+ //~^ ERROR expected `impl Future<Output = ()>` to be a future that resolves to `u8`, but it resolves to `()`
async {}
}
let f: F = async { 1 };
//~^ ERROR `async` blocks are not allowed in constants
- //~| ERROR destructors cannot be evaluated at compile-time
+ //~| ERROR destructor of
1
}],
}
diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr
index 690d6abc7..a96994f5a 100644
--- a/src/test/ui/impl-trait/issues/issue-78722.stderr
+++ b/src/test/ui/impl-trait/issues/issue-78722.stderr
@@ -7,16 +7,16 @@ 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
-error[E0493]: destructors cannot be evaluated at compile-time
+error[E0493]: destructor of `F` cannot be evaluated at compile-time
--> $DIR/issue-78722.rs:13:13
|
LL | let f: F = async { 1 };
- | ^ constants cannot evaluate destructors
+ | ^ the destructor for this type cannot be evaluated in constants
...
LL | }],
| - value is dropped here
-error[E0271]: type mismatch resolving `<impl Future<Output = ()> as Future>::Output == u8`
+error[E0271]: expected `impl Future<Output = ()>` to be a future that resolves to `u8`, but it resolves to `()`
--> $DIR/issue-78722.rs:9:30
|
LL | fn concrete_use() -> F {
diff --git a/src/test/ui/impl-trait/issues/issue-86800.stderr b/src/test/ui/impl-trait/issues/issue-86800.stderr
index 135d06d44..6c4aa3567 100644
--- a/src/test/ui/impl-trait/issues/issue-86800.stderr
+++ b/src/test/ui/impl-trait/issues/issue-86800.stderr
@@ -1,3 +1,11 @@
+error: unconstrained opaque type
+ --> $DIR/issue-86800.rs:33:34
+ |
+LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ =
+
stack backtrace:
@@ -12,8 +20,7 @@ error: internal compiler error: unexpected panic
query stack during panic:
-#0 [mir_borrowck] borrow-checking `execute_transaction_fut`
-#1 [type_of] computing type of `TransactionFuture::{opaque#0}`
-#2 [check_mod_item_types] checking item types in top-level module
-#3 [analysis] running analysis passes on this crate
+#0 [type_of] computing type of `TransactionFuture::{opaque#0}`
+#1 [check_mod_item_types] checking item types in top-level module
+#2 [analysis] running analysis passes on this crate
end of query stack
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
index cb1dc0b7d..ec49a6179 100644
--- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
+++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
@@ -7,7 +7,7 @@ LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> im
LL | if condition() { a } else { b }
| ^
|
-help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound
+help: to declare that `impl Trait<'d, 'e>` captures `'b`, you can add an explicit `'b` lifetime bound
|
LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> + 'b
| ++++
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
index 4388e6601..c36f9bc69 100644
--- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
+++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
@@ -7,7 +7,7 @@ LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a,
LL | if condition() { a } else { b }
| ^
|
-help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound
+help: to declare that `impl Trait<'a, 'b>` captures `'b`, you can add an explicit `'b` lifetime bound
|
LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> + 'b
| ++++
diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
index 16767abd7..9c81791fb 100644
--- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
+++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
@@ -6,7 +6,7 @@ LL | fn elided(x: &i32) -> impl Copy { x }
| |
| hidden type `&i32` captures the anonymous lifetime defined here
|
-help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound
+help: to declare that `impl Copy` captures `'_`, you can add an explicit `'_` lifetime bound
|
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
| ++++
@@ -19,7 +19,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
| |
| hidden type `&'a i32` captures the lifetime `'a` as defined here
|
-help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'a` lifetime bound
+help: to declare that `impl Copy` captures `'a`, you can add an explicit `'a` lifetime bound
|
LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
| ++++
@@ -32,7 +32,7 @@ LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
| |
| let's call the lifetime of this reference `'1`
|
-help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
+help: consider changing `impl Copy + 'static`'s explicit `'static` bound to the lifetime of argument `x`
|
LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
| ~~
@@ -47,7 +47,7 @@ error: lifetime may not live long enough
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
|
-help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
+help: consider changing `impl Copy + 'static`'s explicit `'static` bound to the lifetime of argument `x`
|
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
| ~~
@@ -76,7 +76,7 @@ help: to declare that the trait object captures data from argument `x`, you can
|
LL | fn elided5(x: &i32) -> (Box<dyn Debug + '_>, impl Debug) { (Box::new(x), x) }
| ++++
-help: to declare that the `impl Trait` captures data from argument `x`, you can add an explicit `'_` lifetime bound
+help: to declare that `impl Debug` captures data from argument `x`, you can add an explicit `'_` lifetime bound
|
LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug + '_) { (Box::new(x), x) }
| ++++
@@ -87,7 +87,7 @@ error: lifetime may not live long enough
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
|
-help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
+help: consider changing `impl LifetimeTrait<'a> + 'static`'s explicit `'static` bound to the lifetime of argument `x`
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
| ~~
@@ -104,7 +104,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32
LL | move |_| println!("{}", y)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound
+help: to declare that `impl Fn(&'a u32)` captures `'b`, you can add an explicit `'b` lifetime bound
|
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) + 'b {
| ++++
diff --git a/src/test/ui/impl-trait/nested-return-type2-tait.rs b/src/test/ui/impl-trait/nested-return-type2-tait.rs
index 42613d5cc..089018a1c 100644
--- a/src/test/ui/impl-trait/nested-return-type2-tait.rs
+++ b/src/test/ui/impl-trait/nested-return-type2-tait.rs
@@ -26,6 +26,7 @@ type Sendable = impl Send;
// var to make it uphold the `: Duh` bound on `Trait::Assoc`. The opaque
// type does not implement `Duh`, but if its hidden type does.
fn foo() -> impl Trait<Assoc = Sendable> {
+ //~^ WARN opaque type `impl Trait<Assoc = Sendable>` does not satisfy its associated type bounds
|| 42
}
diff --git a/src/test/ui/impl-trait/nested-return-type2-tait.stderr b/src/test/ui/impl-trait/nested-return-type2-tait.stderr
new file mode 100644
index 000000000..a8eb69cfc
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-return-type2-tait.stderr
@@ -0,0 +1,17 @@
+warning: opaque type `impl Trait<Assoc = Sendable>` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type2-tait.rs:28:24
+ |
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `Sendable`
+...
+LL | fn foo() -> impl Trait<Assoc = Sendable> {
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
+ |
+LL | type Sendable = impl Send + Duh;
+ | +++++
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/nested-return-type2-tait2.stderr b/src/test/ui/impl-trait/nested-return-type2-tait2.stderr
index fe1ae4fcb..348c737b0 100644
--- a/src/test/ui/impl-trait/nested-return-type2-tait2.stderr
+++ b/src/test/ui/impl-trait/nested-return-type2-tait2.stderr
@@ -5,7 +5,7 @@ LL | || 42
| ^^^^^ the trait `Duh` is not implemented for `Sendable`
|
= help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:7]`
+note: required for `[closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:7]` to implement `Trait`
--> $DIR/nested-return-type2-tait2.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
diff --git a/src/test/ui/impl-trait/nested-return-type2-tait3.stderr b/src/test/ui/impl-trait/nested-return-type2-tait3.stderr
index c0695d627..6ac671415 100644
--- a/src/test/ui/impl-trait/nested-return-type2-tait3.stderr
+++ b/src/test/ui/impl-trait/nested-return-type2-tait3.stderr
@@ -5,7 +5,7 @@ LL | || 42
| ^^^^^ the trait `Duh` is not implemented for `impl Send`
|
= help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:7]`
+note: required for `[closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:7]` to implement `Trait`
--> $DIR/nested-return-type2-tait3.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
diff --git a/src/test/ui/impl-trait/nested-return-type2.rs b/src/test/ui/impl-trait/nested-return-type2.rs
index 39928d543..cc1f1f4ec 100644
--- a/src/test/ui/impl-trait/nested-return-type2.rs
+++ b/src/test/ui/impl-trait/nested-return-type2.rs
@@ -23,6 +23,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F {
// Lazy TAIT would error out, but we inserted a hack to make it work again,
// keeping backwards compatibility.
fn foo() -> impl Trait<Assoc = impl Send> {
+ //~^ WARN opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds
|| 42
}
diff --git a/src/test/ui/impl-trait/nested-return-type2.stderr b/src/test/ui/impl-trait/nested-return-type2.stderr
new file mode 100644
index 000000000..3aed05ca1
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-return-type2.stderr
@@ -0,0 +1,17 @@
+warning: opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type2.rs:25:24
+ |
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `impl Send`
+...
+LL | fn foo() -> impl Trait<Assoc = impl Send> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
+ |
+LL | fn foo() -> impl Trait<Assoc = impl Send + Duh> {
+ | +++++
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/nested-return-type3-tait.rs b/src/test/ui/impl-trait/nested-return-type3-tait.rs
index 3936f4dbb..3a97e35b4 100644
--- a/src/test/ui/impl-trait/nested-return-type3-tait.rs
+++ b/src/test/ui/impl-trait/nested-return-type3-tait.rs
@@ -17,6 +17,7 @@ impl<F: Duh> Trait for F {
type Sendable = impl Send;
fn foo() -> impl Trait<Assoc = Sendable> {
+ //~^ WARN opaque type `impl Trait<Assoc = Sendable>` does not satisfy its associated type bounds
42
}
diff --git a/src/test/ui/impl-trait/nested-return-type3-tait.stderr b/src/test/ui/impl-trait/nested-return-type3-tait.stderr
new file mode 100644
index 000000000..5f58c8dca
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-return-type3-tait.stderr
@@ -0,0 +1,17 @@
+warning: opaque type `impl Trait<Assoc = Sendable>` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type3-tait.rs:19:24
+ |
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `Sendable`
+...
+LL | fn foo() -> impl Trait<Assoc = Sendable> {
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
+ |
+LL | type Sendable = impl Send + Duh;
+ | +++++
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/nested-return-type3-tait2.rs b/src/test/ui/impl-trait/nested-return-type3-tait2.rs
index 56778ed90..5b6f78a98 100644
--- a/src/test/ui/impl-trait/nested-return-type3-tait2.rs
+++ b/src/test/ui/impl-trait/nested-return-type3-tait2.rs
@@ -16,6 +16,7 @@ impl<F: Duh> Trait for F {
type Sendable = impl Send;
type Traitable = impl Trait<Assoc = Sendable>;
+//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds
fn foo() -> Traitable {
42
diff --git a/src/test/ui/impl-trait/nested-return-type3-tait2.stderr b/src/test/ui/impl-trait/nested-return-type3-tait2.stderr
new file mode 100644
index 000000000..c07f6ead7
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-return-type3-tait2.stderr
@@ -0,0 +1,17 @@
+warning: opaque type `Traitable` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type3-tait2.rs:18:29
+ |
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `Sendable`
+...
+LL | type Traitable = impl Trait<Assoc = Sendable>;
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
+ |
+LL | type Sendable = impl Send + Duh;
+ | +++++
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/nested-return-type3-tait3.rs b/src/test/ui/impl-trait/nested-return-type3-tait3.rs
index 04c6c92b1..394d8f581 100644
--- a/src/test/ui/impl-trait/nested-return-type3-tait3.rs
+++ b/src/test/ui/impl-trait/nested-return-type3-tait3.rs
@@ -15,6 +15,7 @@ impl<F: Duh> Trait for F {
}
type Traitable = impl Trait<Assoc = impl Send>;
+//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds
fn foo() -> Traitable {
42
diff --git a/src/test/ui/impl-trait/nested-return-type3-tait3.stderr b/src/test/ui/impl-trait/nested-return-type3-tait3.stderr
new file mode 100644
index 000000000..d98ad8922
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-return-type3-tait3.stderr
@@ -0,0 +1,17 @@
+warning: opaque type `Traitable` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type3-tait3.rs:17:29
+ |
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `impl Send`
+...
+LL | type Traitable = impl Trait<Assoc = impl Send>;
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
+ |
+LL | type Traitable = impl Trait<Assoc = impl Send + Duh>;
+ | +++++
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/nested-return-type3.rs b/src/test/ui/impl-trait/nested-return-type3.rs
index 74b4dae22..5a764fc4c 100644
--- a/src/test/ui/impl-trait/nested-return-type3.rs
+++ b/src/test/ui/impl-trait/nested-return-type3.rs
@@ -13,6 +13,7 @@ impl<F: Duh> Trait for F {
}
fn foo() -> impl Trait<Assoc = impl Send> {
+ //~^ WARN opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds
42
}
diff --git a/src/test/ui/impl-trait/nested-return-type3.stderr b/src/test/ui/impl-trait/nested-return-type3.stderr
new file mode 100644
index 000000000..632de71aa
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-return-type3.stderr
@@ -0,0 +1,17 @@
+warning: opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type3.rs:15:24
+ |
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `impl Send`
+...
+LL | fn foo() -> impl Trait<Assoc = impl Send> {
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
+ |
+LL | fn foo() -> impl Trait<Assoc = impl Send + Duh> {
+ | +++++
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs b/src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs
new file mode 100644
index 000000000..287a030cf
--- /dev/null
+++ b/src/test/ui/impl-trait/nested-rpit-with-anonymous-lifetimes.rs
@@ -0,0 +1,23 @@
+// check-pass
+
+pub struct VecNumber<'s> {
+ pub vec_number: Vec<Number<'s>>,
+ pub auxiliary_object: &'s Vec<usize>,
+}
+
+pub struct Number<'s> {
+ pub number: &'s usize,
+}
+
+impl<'s> VecNumber<'s> {
+ pub fn vec_number_iterable_per_item_in_auxiliary_object(
+ &self,
+ ) -> impl Iterator<Item = (&'s usize, impl Iterator<Item = &Number<'s>>)> {
+ self.auxiliary_object.iter().map(move |n| {
+ let iter_number = self.vec_number.iter();
+ (n, iter_number)
+ })
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr
index bb4ae5e82..3291cad68 100644
--- a/src/test/ui/impl-trait/nested_impl_trait.stderr
+++ b/src/test/ui/impl-trait/nested_impl_trait.stderr
@@ -53,7 +53,7 @@ LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`
|
= help: the trait `Into<U>` is implemented for `T`
- = note: required because of the requirements on the impl of `Into<impl Debug>` for `impl Into<u32>`
+ = note: required for `impl Into<u32>` to implement `Into<impl Debug>`
error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
--> $DIR/nested_impl_trait.rs:18:34
@@ -62,7 +62,7 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`
|
= help: the trait `Into<U>` is implemented for `T`
- = note: required because of the requirements on the impl of `Into<impl Debug>` for `impl Into<u32>`
+ = note: required for `impl Into<u32>` to implement `Into<impl Debug>`
error: aborting due to 8 previous errors
diff --git a/src/test/ui/impl-trait/normalize-tait-in-const.rs b/src/test/ui/impl-trait/normalize-tait-in-const.rs
new file mode 100644
index 000000000..020bcbb83
--- /dev/null
+++ b/src/test/ui/impl-trait/normalize-tait-in-const.rs
@@ -0,0 +1,39 @@
+// known-bug: #103507
+// failure-status: 101
+// normalize-stderr-test "note: .*\n\n" -> ""
+// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
+// rustc-env:RUST_BACKTRACE=0
+
+#![feature(type_alias_impl_trait)]
+#![feature(const_trait_impl)]
+#![feature(const_refs_to_cell)]
+#![feature(inline_const)]
+
+use std::marker::Destruct;
+
+trait T {
+ type Item;
+}
+
+type Alias<'a> = impl T<Item = &'a ()>;
+
+struct S;
+impl<'a> T for &'a S {
+ type Item = &'a ();
+}
+
+const fn filter_positive<'a>() -> &'a Alias<'a> {
+ &&S
+}
+
+const fn with_positive<F: ~const for<'a> Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
+ fun(filter_positive());
+}
+
+const fn foo(_: &Alias<'_>) {}
+
+const BAR: () = {
+ with_positive(foo);
+};
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/normalize-tait-in-const.stderr b/src/test/ui/impl-trait/normalize-tait-in-const.stderr
new file mode 100644
index 000000000..b9fc8726f
--- /dev/null
+++ b/src/test/ui/impl-trait/normalize-tait-in-const.stderr
@@ -0,0 +1,8 @@
+error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:198:90: Failed to normalize <for<'a, 'b> fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead
+
+query stack during panic:
+#0 [eval_to_allocation_raw] const-evaluating + checking `BAR`
+#1 [eval_to_const_value_raw] simplifying constant for the type system `BAR`
+end of query stack
+error: aborting due to previous error
+
diff --git a/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr b/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
index 365ecd9fc..687dbe65e 100644
--- a/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
+++ b/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
@@ -21,10 +21,10 @@ LL | fn foo() -> Self where Self: Sized;
| +++++++++++++++++
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
- --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:28:13
+ --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:28:17
|
LL | fn cat() -> Box<dyn NotObjectSafe> {
- | ^^^^^^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
+ | ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
diff --git a/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr b/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr
index 5ca01a593..d6f5a1ac2 100644
--- a/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr
+++ b/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:36:5
|
LL | fn can() -> impl NotObjectSafe {
- | ------------------ expected `_` because of return type
+ | ------------------ expected `A` because of return type
...
LL | B
| ^ expected struct `A`, found struct `B`
@@ -11,7 +11,7 @@ error[E0308]: mismatched types
--> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:43:5
|
LL | fn cat() -> impl ObjectSafe {
- | --------------- expected `_` because of return type
+ | --------------- expected `A` because of return type
...
LL | B
| ^ expected struct `A`, found struct `B`
diff --git a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr
index 10510c175..3c65fd998 100644
--- a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr
+++ b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr
@@ -2,28 +2,43 @@ error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
|
LL | fn foo() -> impl std::fmt::Display {
- | ---------------------- expected `_` because of return type
+ | ---------------------- expected `i32` because of return type
...
LL | 1u32
| ^^^^ expected `i32`, found `u32`
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 1i32
+ | ~~~
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
|
LL | fn bar() -> impl std::fmt::Display {
- | ---------------------- expected `_` because of return type
+ | ---------------------- expected `i32` because of return type
...
LL | return 1u32;
| ^^^^ expected `i32`, found `u32`
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | return 1i32;
+ | ~~~
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
|
LL | fn baz() -> impl std::fmt::Display {
- | ---------------------- expected `_` because of return type
+ | ---------------------- expected `i32` because of return type
...
LL | 1u32
| ^^^^ expected `i32`, found `u32`
+ |
+help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
+ |
+LL | }.try_into().unwrap()
+ | ++++++++++++++++++++
error[E0308]: `if` and `else` have incompatible types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
@@ -36,36 +51,66 @@ LL | | 1u32
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
+ |
+help: you could change the return type to be a boxed trait object
+ |
+LL | fn qux() -> Box<dyn std::fmt::Display> {
+ | ~~~~~~~ +
+help: if you change the return type to expect trait objects, box the returned expressions
+ |
+LL ~ Box::new(0i32)
+LL | } else {
+LL ~ Box::new(1u32)
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 1i32
+ | ~~~
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
|
LL | fn bat() -> impl std::fmt::Display {
- | ---------------------- expected `_` because of return type
+ | ---------------------- expected `i32` because of return type
...
LL | _ => 1u32,
| ^^^^ expected `i32`, found `u32`
+ |
+help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
+ |
+LL | }.try_into().unwrap()
+ | ++++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
|
LL | fn can() -> impl std::fmt::Display {
- | ---------------------- expected `_` because of return type
+ | ---------------------- expected `i32` because of return type
LL | / match 13 {
LL | | 0 => return 0i32,
LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____^ expected `i32`, found `u32`
+ |
+help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
+ |
+LL | }.try_into().unwrap()
+ | ++++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
|
LL | fn cat() -> impl std::fmt::Display {
- | ---------------------- expected `_` because of return type
+ | ---------------------- expected `i32` because of return type
...
LL | 1u32
| ^^^^ expected `i32`, found `u32`
+ |
+help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
+ |
+LL | }.try_into().unwrap()
+ | ++++++++++++++++++++
error[E0308]: `match` arms have incompatible types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
@@ -78,6 +123,20 @@ LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____- `match` arms have incompatible types
+ |
+help: you could change the return type to be a boxed trait object
+ |
+LL | fn dog() -> Box<dyn std::fmt::Display> {
+ | ~~~~~~~ +
+help: if you change the return type to expect trait objects, box the returned expressions
+ |
+LL ~ 0 => Box::new(0i32),
+LL ~ 1 => Box::new(1u32),
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 1 => 1i32,
+ | ~~~
error[E0308]: `if` and `else` have incompatible types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
@@ -90,6 +149,21 @@ LL | | 1u32
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
+ |
+help: you could change the return type to be a boxed trait object
+ |
+LL | fn apt() -> Box<dyn std::fmt::Display> {
+ | ~~~~~~~ +
+help: if you change the return type to expect trait objects, box the returned expressions
+ |
+LL ~ Box::new(0i32)
+LL | } else {
+LL ~ Box::new(1u32)
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 1i32
+ | ~~~
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
@@ -125,6 +199,11 @@ LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____- `match` arms have incompatible types
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 1 => 1i32,
+ | ~~~
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
@@ -164,6 +243,11 @@ LL | | 1u32
| | ^^^^ expected `i32`, found `u32`
LL | | }
| |_____- `if` and `else` have incompatible types
+ |
+help: change the type of the numeric literal from `u32` to `i32`
+ |
+LL | 1i32
+ | ~~~
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
index ade0dfa1b..cf2998bbf 100644
--- a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
+++ b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
@@ -9,7 +9,7 @@ note: expected this to be `u8`
|
LL | type Assoc = u8;
| ^^
-note: required because of the requirements on the impl of `Test` for `()`
+note: required for `()` to implement `Test`
--> $DIR/projection-mismatch-in-impl-where-clause.rs:11:9
|
LL | impl<T> Test for T where T: Super<Assoc = ()> {}
diff --git a/src/test/ui/impl-trait/region-escape-via-bound.stderr b/src/test/ui/impl-trait/region-escape-via-bound.stderr
index fdb2fe022..44a790cb1 100644
--- a/src/test/ui/impl-trait/region-escape-via-bound.stderr
+++ b/src/test/ui/impl-trait/region-escape-via-bound.stderr
@@ -7,7 +7,7 @@ LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
LL | x
| ^
|
-help: to declare that the `impl Trait` captures `'x`, you can add an explicit `'x` lifetime bound
+help: to declare that `impl Trait<'y>` captures `'x`, you can add an explicit `'x` lifetime bound
|
LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> + 'x
| ++++
diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr
index b86815231..b365bd884 100644
--- a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr
+++ b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr
@@ -6,7 +6,7 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound
+help: to declare that `impl Iterator<Item = u32>` captures `'_`, you can add an explicit `'_` lifetime bound
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ++++
@@ -19,7 +19,7 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound
+help: to declare that `impl Iterator<Item = u32>` captures `'_`, you can add an explicit `'_` lifetime bound
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ++++
@@ -32,7 +32,7 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'a` lifetime bound
+help: to declare that `impl Iterator<Item = u32>` captures `'a`, you can add an explicit `'a` lifetime bound
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
| ++++
@@ -45,7 +45,7 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'a` lifetime bound
+help: to declare that `impl Iterator<Item = u32>` captures `'a`, you can add an explicit `'a` lifetime bound
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
| ++++
diff --git a/src/test/ui/impl-trait/suggest-calling-rpit-closure.stderr b/src/test/ui/impl-trait/suggest-calling-rpit-closure.stderr
index 2a328a0e6..c10a856d8 100644
--- a/src/test/ui/impl-trait/suggest-calling-rpit-closure.stderr
+++ b/src/test/ui/impl-trait/suggest-calling-rpit-closure.stderr
@@ -11,7 +11,7 @@ LL | fn opaque() -> impl Fn() -> i32 {
|
= note: expected type `i32`
found opaque type `impl Fn() -> i32`
-help: use parentheses to call this closure
+help: use parentheses to call this opaque type
|
LL | opaque()()
| ++
diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.fixed b/src/test/ui/impl-trait/unactionable_diagnostic.fixed
new file mode 100644
index 000000000..6c2505177
--- /dev/null
+++ b/src/test/ui/impl-trait/unactionable_diagnostic.fixed
@@ -0,0 +1,25 @@
+// run-rustfix
+
+pub trait Trait {}
+
+pub struct Foo;
+
+impl Trait for Foo {}
+
+fn foo<'x, P>(
+ _post: P,
+ x: &'x Foo,
+) -> &'x impl Trait {
+ x
+}
+
+pub fn bar<'t, T: 't>(
+ //~^ HELP: consider adding an explicit lifetime bound...
+ post: T,
+ x: &'t Foo,
+) -> &'t impl Trait {
+ foo(post, x)
+ //~^ ERROR: the parameter type `T` may not live long enough
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.rs b/src/test/ui/impl-trait/unactionable_diagnostic.rs
new file mode 100644
index 000000000..bce35cbdd
--- /dev/null
+++ b/src/test/ui/impl-trait/unactionable_diagnostic.rs
@@ -0,0 +1,25 @@
+// run-rustfix
+
+pub trait Trait {}
+
+pub struct Foo;
+
+impl Trait for Foo {}
+
+fn foo<'x, P>(
+ _post: P,
+ x: &'x Foo,
+) -> &'x impl Trait {
+ x
+}
+
+pub fn bar<'t, T>(
+ //~^ HELP: consider adding an explicit lifetime bound...
+ post: T,
+ x: &'t Foo,
+) -> &'t impl Trait {
+ foo(post, x)
+ //~^ ERROR: the parameter type `T` may not live long enough
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.stderr b/src/test/ui/impl-trait/unactionable_diagnostic.stderr
new file mode 100644
index 000000000..a32004cda
--- /dev/null
+++ b/src/test/ui/impl-trait/unactionable_diagnostic.stderr
@@ -0,0 +1,14 @@
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/unactionable_diagnostic.rs:21:5
+ |
+LL | foo(post, x)
+ | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | pub fn bar<'t, T: 't>(
+ | ++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0309`.
diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr
index 58a2f79ef..2e7c7ca40 100644
--- a/src/test/ui/impl-trait/where-allowed.stderr
+++ b/src/test/ui/impl-trait/where-allowed.stderr
@@ -162,12 +162,18 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t
|
LL | fn in_return() -> impl Debug;
| ^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+ = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return
--> $DIR/where-allowed.rs:125:34
|
LL | fn in_trait_impl_return() -> impl Debug { () }
| ^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+ = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param
--> $DIR/where-allowed.rs:138:33
@@ -295,9 +301,9 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^^^^^
|
- = note: `#[deny(invalid_type_param_default)]` on by default
= 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 <https://github.com/rust-lang/rust/issues/36887>
+ = note: `#[deny(invalid_type_param_default)]` on by default
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/where-allowed.rs:241:36