summaryrefslogtreecommitdiffstats
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/impl-trait
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/auto-trait-leak.rs6
-rw-r--r--tests/ui/impl-trait/auto-trait-leak.stderr151
-rw-r--r--tests/ui/impl-trait/autoderef.rs2
-rw-r--r--tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr13
-rw-r--r--tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr13
-rw-r--r--tests/ui/impl-trait/coherence-treats-tait-ambig.rs19
-rw-r--r--tests/ui/impl-trait/deduce-signature-from-supertrait.rs4
-rw-r--r--tests/ui/impl-trait/defined-by-trait-resolution.rs12
-rw-r--r--tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs9
-rw-r--r--tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr16
-rw-r--r--tests/ui/impl-trait/equality.stderr4
-rw-r--r--tests/ui/impl-trait/in-assoc-type-unconstrained.stderr4
-rw-r--r--tests/ui/impl-trait/in-assoc-type.rs3
-rw-r--r--tests/ui/impl-trait/in-assoc-type.stderr6
-rw-r--r--tests/ui/impl-trait/in-trait/foreign.rs4
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102140.next.stderr6
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr21
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr20
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr20
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.rs21
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.stderr74
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs19
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr65
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr65
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.rs55
-rw-r--r--tests/ui/impl-trait/in-trait/suggest-missing-item.fixed25
-rw-r--r--tests/ui/impl-trait/in-trait/suggest-missing-item.rs21
-rw-r--r--tests/ui/impl-trait/in-trait/suggest-missing-item.stderr21
-rw-r--r--tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr9
-rw-r--r--tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr9
-rw-r--r--tests/ui/impl-trait/in-trait/unconstrained-lt.rs16
-rw-r--r--tests/ui/impl-trait/in-trait/variances-of-gat.rs19
-rw-r--r--tests/ui/impl-trait/in-trait/wf-bounds.current.stderr27
-rw-r--r--tests/ui/impl-trait/in-trait/wf-bounds.next.stderr27
-rw-r--r--tests/ui/impl-trait/in-trait/wf-bounds.rs7
-rw-r--r--tests/ui/impl-trait/issue-103181-2.rs2
-rw-r--r--tests/ui/impl-trait/issue-103181-2.stderr57
-rw-r--r--tests/ui/impl-trait/issue-55872-3.rs1
-rw-r--r--tests/ui/impl-trait/issue-55872-3.stderr6
-rw-r--r--tests/ui/impl-trait/issues/issue-65581.rs1
-rw-r--r--tests/ui/impl-trait/issues/issue-70877.rs4
-rw-r--r--tests/ui/impl-trait/issues/issue-70877.stderr6
-rw-r--r--tests/ui/impl-trait/issues/issue-74282.rs9
-rw-r--r--tests/ui/impl-trait/issues/issue-74282.stderr18
-rw-r--r--tests/ui/impl-trait/issues/issue-78722-2.rs22
-rw-r--r--tests/ui/impl-trait/issues/issue-78722-2.stderr32
-rw-r--r--tests/ui/impl-trait/issues/issue-78722.rs3
-rw-r--r--tests/ui/impl-trait/issues/issue-78722.stderr6
-rw-r--r--tests/ui/impl-trait/multiple-defining-usages-in-body.rs2
-rw-r--r--tests/ui/impl-trait/multiple-defining-usages-in-body.stderr10
-rw-r--r--tests/ui/impl-trait/nested-return-type2-tait.stderr4
-rw-r--r--tests/ui/impl-trait/nested-return-type3-tait.stderr4
-rw-r--r--tests/ui/impl-trait/nested-return-type3-tait2.stderr4
-rw-r--r--tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs27
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs3
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr15
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr4
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs3
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr15
-rw-r--r--tests/ui/impl-trait/reveal-during-codegen.rs11
-rw-r--r--tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs12
-rw-r--r--tests/ui/impl-trait/universal_wrong_hrtb.rs2
-rw-r--r--tests/ui/impl-trait/universal_wrong_hrtb.stderr10
67 files changed, 896 insertions, 266 deletions
diff --git a/tests/ui/impl-trait/auto-trait-leak.rs b/tests/ui/impl-trait/auto-trait-leak.rs
index c2fbbf94f..d71c09879 100644
--- a/tests/ui/impl-trait/auto-trait-leak.rs
+++ b/tests/ui/impl-trait/auto-trait-leak.rs
@@ -3,21 +3,23 @@ use std::rc::Rc;
fn send<T: Send>(_: T) {}
-fn main() {
-}
+fn main() {}
// Cycles should work as the deferred obligations are
// independently resolved and only require the concrete
// return type, which can't depend on the obligation.
fn cycle1() -> impl Clone {
//~^ ERROR cycle detected
+ //~| ERROR cycle detected
send(cycle2().clone());
+ //~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
Rc::new(Cell::new(5))
}
fn cycle2() -> impl Clone {
send(cycle1().clone());
+ //~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
Rc::new(String::from("foo"))
}
diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr
index aa4ee75bb..92a9763bc 100644
--- a/tests/ui/impl-trait/auto-trait-leak.stderr
+++ b/tests/ui/impl-trait/auto-trait-leak.stderr
@@ -1,44 +1,9 @@
error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}`
- --> $DIR/auto-trait-leak.rs:12:16
+ --> $DIR/auto-trait-leak.rs:11:16
|
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^
|
-note: ...which requires borrow-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires promoting constants in MIR for `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires preparing `cycle1` for borrow checking...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires match-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-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
|
@@ -46,51 +11,51 @@ LL | send(cycle2().clone());
| ^^^^
= note: ...which requires evaluating trait selection obligation `cycle2::{opaque#0}: core::marker::Send`...
note: ...which requires computing type of `cycle2::{opaque#0}`...
- --> $DIR/auto-trait-leak.rs:19:16
+ --> $DIR/auto-trait-leak.rs:20:16
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^
-note: ...which requires borrow-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+note: ...which requires type-checking `cycle2`...
+ --> $DIR/auto-trait-leak.rs:21:5
|
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires promoting constants in MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+LL | send(cycle1().clone());
+ | ^^^^
+ = note: ...which requires evaluating trait selection obligation `cycle1::{opaque#0}: core::marker::Send`...
+ = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
+note: cycle used when checking item types in top-level module
+ --> $DIR/auto-trait-leak.rs:1:1
|
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires preparing `cycle2` for borrow checking...
- --> $DIR/auto-trait-leak.rs:19:1
+LL | / use std::cell::Cell;
+LL | | use std::rc::Rc;
+LL | |
+LL | | fn send<T: Send>(_: T) {}
+... |
+LL | | Rc::new(String::from("foo"))
+LL | | }
+ | |_^
+
+error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}`
+ --> $DIR/auto-trait-leak.rs:11:16
|
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+LL | fn cycle1() -> impl Clone {
+ | ^^^^^^^^^^
|
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+note: ...which requires type-checking `cycle1`...
+ --> $DIR/auto-trait-leak.rs:14:5
|
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires match-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+LL | send(cycle2().clone());
+ | ^^^^
+ = note: ...which requires evaluating trait selection obligation `cycle2::{opaque#0}: core::marker::Send`...
+note: ...which requires computing type of `cycle2::{opaque#0}`...
+ --> $DIR/auto-trait-leak.rs:20:16
|
LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building THIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+ | ^^^^^^^^^^
+note: ...which requires type-checking `cycle2`...
+ --> $DIR/auto-trait-leak.rs:20:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires type-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:5
- |
-LL | send(cycle1().clone());
- | ^^^^
- = note: ...which requires evaluating trait selection obligation `cycle1::{opaque#0}: core::marker::Send`...
= note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/auto-trait-leak.rs:1:1
@@ -104,6 +69,54 @@ LL | | Rc::new(String::from("foo"))
LL | | }
| |_^
-error: aborting due to previous error
+error: cannot check whether the hidden type of opaque type satisfies auto traits
+ --> $DIR/auto-trait-leak.rs:21:10
+ |
+LL | send(cycle1().clone());
+ | ---- ^^^^^^^^^^^^^^^^
+ | |
+ | required by a bound introduced by this call
+ |
+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:20:4
+ |
+LL | fn cycle2() -> impl Clone {
+ | ^^^^^^
+note: required by a bound in `send`
+ --> $DIR/auto-trait-leak.rs:4:12
+ |
+LL | fn send<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `send`
+
+error: cannot check whether the hidden type of opaque type satisfies auto traits
+ --> $DIR/auto-trait-leak.rs:14:10
+ |
+LL | send(cycle2().clone());
+ | ---- ^^^^^^^^^^^^^^^^
+ | |
+ | required by a bound introduced by this call
+ |
+note: opaque type is declared here
+ --> $DIR/auto-trait-leak.rs:20:16
+ |
+LL | fn cycle2() -> 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:11:4
+ |
+LL | fn cycle1() -> impl Clone {
+ | ^^^^^^
+note: required by a bound in `send`
+ --> $DIR/auto-trait-leak.rs:4:12
+ |
+LL | fn send<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `send`
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/impl-trait/autoderef.rs b/tests/ui/impl-trait/autoderef.rs
index 5e4f49954..0d07a5496 100644
--- a/tests/ui/impl-trait/autoderef.rs
+++ b/tests/ui/impl-trait/autoderef.rs
@@ -1,3 +1,5 @@
+// revisions: current next
+//[next] compile-flag: -Ztrait-solver=next
// check-pass
use std::path::Path;
diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr b/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr
new file mode 100644
index 000000000..61fed1629
--- /dev/null
+++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `Into<T>` for type `Foo`
+ --> $DIR/coherence-treats-tait-ambig.rs:10:1
+ |
+LL | impl Into<T> for Foo {
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: conflicting implementation in crate `core`:
+ - impl<T, U> Into<U> for T
+ where U: From<T>;
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr b/tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr
new file mode 100644
index 000000000..61fed1629
--- /dev/null
+++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `Into<T>` for type `Foo`
+ --> $DIR/coherence-treats-tait-ambig.rs:10:1
+ |
+LL | impl Into<T> for Foo {
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: conflicting implementation in crate `core`:
+ - impl<T, U> Into<U> for T
+ where U: From<T>;
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.rs b/tests/ui/impl-trait/coherence-treats-tait-ambig.rs
new file mode 100644
index 000000000..156a7eb0e
--- /dev/null
+++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.rs
@@ -0,0 +1,19 @@
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
+
+#![feature(type_alias_impl_trait)]
+
+type T = impl Sized;
+
+struct Foo;
+
+impl Into<T> for Foo {
+//~^ ERROR conflicting implementations of trait `Into<T>` for type `Foo`
+ fn into(self) -> T {
+ Foo
+ }
+}
+
+fn main() {
+ let _: T = Foo.into();
+}
diff --git a/tests/ui/impl-trait/deduce-signature-from-supertrait.rs b/tests/ui/impl-trait/deduce-signature-from-supertrait.rs
index d2c347920..7a51aac44 100644
--- a/tests/ui/impl-trait/deduce-signature-from-supertrait.rs
+++ b/tests/ui/impl-trait/deduce-signature-from-supertrait.rs
@@ -8,8 +8,10 @@ impl<T: Fn(i32)> SuperExpectation for T {}
type Foo = impl SuperExpectation;
-fn main() {
+fn bop(_: Foo) {
let _: Foo = |x| {
let _ = x.to_string();
};
}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/defined-by-trait-resolution.rs b/tests/ui/impl-trait/defined-by-trait-resolution.rs
new file mode 100644
index 000000000..1744046dd
--- /dev/null
+++ b/tests/ui/impl-trait/defined-by-trait-resolution.rs
@@ -0,0 +1,12 @@
+//! The trait query `foo: Fn() -> u8` is a valid defining use of RPIT.
+
+// build-pass
+
+fn returns_u8(_: impl Fn() -> u8) {}
+
+pub fn foo() -> impl Sized {
+ returns_u8(foo);
+ 0u8
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs
new file mode 100644
index 000000000..befd768b1
--- /dev/null
+++ b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs
@@ -0,0 +1,9 @@
+fn test() -> impl std::fmt::Debug {
+ if true {
+ "boo2"
+ } else {
+ //~^ ERROR `if` and `else` have incompatible types
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr
new file mode 100644
index 000000000..9b63911da
--- /dev/null
+++ b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr
@@ -0,0 +1,16 @@
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/dont-suggest-box-on-empty-else-arm.rs:4:12
+ |
+LL | if true {
+ | ------- `if` and `else` have incompatible types
+LL | "boo2"
+ | ------ expected because of this
+LL | } else {
+ | ____________^
+LL | |
+LL | | }
+ | |_____^ expected `&str`, found `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/equality.stderr b/tests/ui/impl-trait/equality.stderr
index 69f4cbbbf..9b8bff215 100644
--- a/tests/ui/impl-trait/equality.stderr
+++ b/tests/ui/impl-trait/equality.stderr
@@ -30,10 +30,10 @@ LL | n + sum_to(n - 1)
|
= help: the trait `Add<impl Foo>` is not implemented for `u32`
= help: the following other types implement trait `Add<Rhs>`:
+ <u32 as Add>
+ <u32 as Add<&u32>>
<&'a u32 as Add<u32>>
<&u32 as Add<&u32>>
- <u32 as Add<&u32>>
- <u32 as Add>
error: aborting due to 2 previous errors; 1 warning emitted
diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr
index 1097cd0f4..8e61a65ab 100644
--- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr
+++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr
@@ -40,10 +40,10 @@ LL | fn method() -> Self::Ty;
= note: expected signature `fn() -> <() as compare_method::Trait>::Ty`
found signature `fn()`
note: this item must have the opaque type in its signature in order to be able to register hidden types
- --> $DIR/in-assoc-type-unconstrained.rs:22:9
+ --> $DIR/in-assoc-type-unconstrained.rs:22:12
|
LL | fn method() -> () {}
- | ^^^^^^^^^^^^^^^^^
+ | ^^^^^^
error: unconstrained opaque type
--> $DIR/in-assoc-type-unconstrained.rs:20:19
diff --git a/tests/ui/impl-trait/in-assoc-type.rs b/tests/ui/impl-trait/in-assoc-type.rs
index 36c54bdd6..38ad2fa6f 100644
--- a/tests/ui/impl-trait/in-assoc-type.rs
+++ b/tests/ui/impl-trait/in-assoc-type.rs
@@ -1,3 +1,6 @@
+//! This test checks that we don't allow registering hidden types for
+//! opaque types from other impls.
+
#![feature(impl_trait_in_assoc_type)]
trait Foo<T> {
diff --git a/tests/ui/impl-trait/in-assoc-type.stderr b/tests/ui/impl-trait/in-assoc-type.stderr
index f0a272dc2..af60da07c 100644
--- a/tests/ui/impl-trait/in-assoc-type.stderr
+++ b/tests/ui/impl-trait/in-assoc-type.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/in-assoc-type.rs:17:22
+ --> $DIR/in-assoc-type.rs:20:22
|
LL | type Bar = impl std::fmt::Debug;
| -------------------- the expected opaque type
@@ -12,10 +12,10 @@ LL | fn foo(&self) -> <Self as Foo<()>>::Bar {}
= note: expected opaque type `<() as Foo<()>>::Bar`
found unit type `()`
note: this item must have the opaque type in its signature in order to be able to register hidden types
- --> $DIR/in-assoc-type.rs:17:5
+ --> $DIR/in-assoc-type.rs:20:8
|
LL | fn foo(&self) -> <Self as Foo<()>>::Bar {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^
error: aborting due to previous error
diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs
index 98417b343..b0fbe3a3d 100644
--- a/tests/ui/impl-trait/in-trait/foreign.rs
+++ b/tests/ui/impl-trait/in-trait/foreign.rs
@@ -14,6 +14,10 @@ impl Foo for Local {
fn bar(self) -> Arc<String> { Arc::new(String::new()) }
}
+fn generic(f: impl Foo) {
+ let x = &*f.bar();
+}
+
fn main() {
// Witness an RPITIT from another crate.
let &() = Foreign.bar();
diff --git a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr
index 7aa7880e2..94893c9e7 100644
--- a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr
+++ b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr
@@ -6,11 +6,7 @@ LL | MyTrait::foo(&self)
| |
| required by a bound introduced by this call
|
-help: consider removing the leading `&`-reference
- |
-LL - MyTrait::foo(&self)
-LL + MyTrait::foo(self)
- |
+ = help: the trait `MyTrait` is implemented for `Outer`
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
--> $DIR/issue-102140.rs:26:9
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr
new file mode 100644
index 000000000..239c4b35c
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr
@@ -0,0 +1,21 @@
+error[E0053]: method `early` has an incompatible type for trait
+ --> $DIR/method-signature-matches.rs:58:27
+ |
+LL | fn early<'late, T>(_: &'late ()) {}
+ | - ^^^^^^^^^
+ | | |
+ | | expected type parameter `T`, found `()`
+ | | help: change the parameter type to match the trait: `&T`
+ | this type parameter
+ |
+note: type in trait
+ --> $DIR/method-signature-matches.rs:53:28
+ |
+LL | fn early<'early, T>(x: &'early T) -> impl Sized;
+ | ^^^^^^^^^
+ = note: expected signature `fn(&T)`
+ found signature `fn(&'late ())`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr
new file mode 100644
index 000000000..d3183b92e
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr
@@ -0,0 +1,20 @@
+error[E0053]: method `owo` has an incompatible type for trait
+ --> $DIR/method-signature-matches.rs:14:15
+ |
+LL | fn owo(_: u8) {}
+ | ^^
+ | |
+ | expected `()`, found `u8`
+ | help: change the parameter type to match the trait: `()`
+ |
+note: type in trait
+ --> $DIR/method-signature-matches.rs:9:15
+ |
+LL | fn owo(x: ()) -> impl Sized;
+ | ^^
+ = note: expected signature `fn(())`
+ found signature `fn(u8)`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr
new file mode 100644
index 000000000..80fda1c9f
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr
@@ -0,0 +1,20 @@
+error[E0053]: method `owo` has an incompatible type for trait
+ --> $DIR/method-signature-matches.rs:25:21
+ |
+LL | async fn owo(_: u8) {}
+ | ^^
+ | |
+ | expected `()`, found `u8`
+ | help: change the parameter type to match the trait: `()`
+ |
+note: type in trait
+ --> $DIR/method-signature-matches.rs:20:21
+ |
+LL | async fn owo(x: ()) {}
+ | ^^
+ = note: expected signature `fn(()) -> _`
+ found signature `fn(u8) -> _`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.rs b/tests/ui/impl-trait/in-trait/method-signature-matches.rs
index c848ee3f6..294f93b30 100644
--- a/tests/ui/impl-trait/in-trait/method-signature-matches.rs
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.rs
@@ -1,51 +1,62 @@
// edition: 2021
+// revisions: mismatch mismatch_async too_many too_few lt
#![feature(return_position_impl_trait_in_trait, async_fn_in_trait)]
#![allow(incomplete_features)]
+#[cfg(mismatch)]
trait Uwu {
fn owo(x: ()) -> impl Sized;
}
+#[cfg(mismatch)]
impl Uwu for () {
fn owo(_: u8) {}
- //~^ ERROR method `owo` has an incompatible type for trait
+ //[mismatch]~^ ERROR method `owo` has an incompatible type for trait
}
+#[cfg(mismatch_async)]
trait AsyncUwu {
async fn owo(x: ()) {}
}
+#[cfg(mismatch_async)]
impl AsyncUwu for () {
async fn owo(_: u8) {}
- //~^ ERROR method `owo` has an incompatible type for trait
+ //[mismatch_async]~^ ERROR method `owo` has an incompatible type for trait
}
+#[cfg(too_many)]
trait TooMuch {
fn calm_down_please() -> impl Sized;
}
+#[cfg(too_many)]
impl TooMuch for () {
fn calm_down_please(_: (), _: (), _: ()) {}
- //~^ ERROR method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0
+ //[too_many]~^ ERROR method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0
}
+#[cfg(too_few)]
trait TooLittle {
fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized;
}
+#[cfg(too_few)]
impl TooLittle for () {
fn come_on_a_little_more_effort() {}
- //~^ ERROR method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3
+ //[too_few]~^ ERROR method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3
}
+#[cfg(lt)]
trait Lifetimes {
fn early<'early, T>(x: &'early T) -> impl Sized;
}
+#[cfg(lt)]
impl Lifetimes for () {
fn early<'late, T>(_: &'late ()) {}
- //~^ ERROR method `early` has an incompatible type for trait
+ //[lt]~^ ERROR method `early` has an incompatible type for trait
}
fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.stderr
deleted file mode 100644
index 3ec62020e..000000000
--- a/tests/ui/impl-trait/in-trait/method-signature-matches.stderr
+++ /dev/null
@@ -1,74 +0,0 @@
-error[E0053]: method `owo` has an incompatible type for trait
- --> $DIR/method-signature-matches.rs:11:15
- |
-LL | fn owo(_: u8) {}
- | ^^
- | |
- | expected `()`, found `u8`
- | help: change the parameter type to match the trait: `()`
- |
-note: type in trait
- --> $DIR/method-signature-matches.rs:7:15
- |
-LL | fn owo(x: ()) -> impl Sized;
- | ^^
- = note: expected signature `fn(())`
- found signature `fn(u8)`
-
-error[E0053]: method `owo` has an incompatible type for trait
- --> $DIR/method-signature-matches.rs:20:21
- |
-LL | async fn owo(_: u8) {}
- | ^^
- | |
- | expected `()`, found `u8`
- | help: change the parameter type to match the trait: `()`
- |
-note: type in trait
- --> $DIR/method-signature-matches.rs:16:21
- |
-LL | async fn owo(x: ()) {}
- | ^^
- = note: expected signature `fn(()) -> _`
- found signature `fn(u8) -> _`
-
-error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0
- --> $DIR/method-signature-matches.rs:29:28
- |
-LL | fn calm_down_please() -> impl Sized;
- | ------------------------------------ trait requires 0 parameters
-...
-LL | fn calm_down_please(_: (), _: (), _: ()) {}
- | ^^^^^^^^^^^^^^^^ expected 0 parameters, found 3
-
-error[E0050]: method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3
- --> $DIR/method-signature-matches.rs:38:5
- |
-LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized;
- | ---------------- trait requires 3 parameters
-...
-LL | fn come_on_a_little_more_effort() {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 parameters, found 0
-
-error[E0053]: method `early` has an incompatible type for trait
- --> $DIR/method-signature-matches.rs:47:27
- |
-LL | fn early<'late, T>(_: &'late ()) {}
- | - ^^^^^^^^^
- | | |
- | | expected type parameter `T`, found `()`
- | | help: change the parameter type to match the trait: `&'early T`
- | this type parameter
- |
-note: type in trait
- --> $DIR/method-signature-matches.rs:43:28
- |
-LL | fn early<'early, T>(x: &'early T) -> impl Sized;
- | ^^^^^^^^^
- = note: expected signature `fn(&'early T)`
- found signature `fn(&())`
-
-error: aborting due to 5 previous errors
-
-Some errors have detailed explanations: E0050, E0053.
-For more information about an error, try `rustc --explain E0050`.
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr
new file mode 100644
index 000000000..24bcfeb74
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr
@@ -0,0 +1,12 @@
+error[E0050]: method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3
+ --> $DIR/method-signature-matches.rs:47:5
+ |
+LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized;
+ | ---------------- trait requires 3 parameters
+...
+LL | fn come_on_a_little_more_effort() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 parameters, found 0
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0050`.
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr
new file mode 100644
index 000000000..616cbd290
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr
@@ -0,0 +1,12 @@
+error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0
+ --> $DIR/method-signature-matches.rs:36:28
+ |
+LL | fn calm_down_please() -> impl Sized;
+ | ------------------------------------ trait requires 0 parameters
+...
+LL | fn calm_down_please(_: (), _: (), _: ()) {}
+ | ^^^^^^^^^^^^^^^^ expected 0 parameters, found 3
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0050`.
diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr
new file mode 100644
index 000000000..ff30103b7
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr
@@ -0,0 +1,16 @@
+error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied
+ --> $DIR/return-dont-satisfy-bounds.rs:13:34
+ |
+LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
+ | ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
+ |
+ = help: the trait `Foo<char>` is implemented for `Bar`
+note: required by a bound in `Foo::foo::{opaque#0}`
+ --> $DIR/return-dont-satisfy-bounds.rs:7:30
+ |
+LL | fn foo<F2>(self) -> impl Foo<T>;
+ | ^^^^^^ required by this bound in `Foo::foo::{opaque#0}`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr
new file mode 100644
index 000000000..7c7f7feaa
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr
@@ -0,0 +1,16 @@
+error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied
+ --> $DIR/return-dont-satisfy-bounds.rs:13:34
+ |
+LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
+ | ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
+ |
+ = help: the trait `Foo<char>` is implemented for `Bar`
+note: required by a bound in `Foo::{opaque#0}`
+ --> $DIR/return-dont-satisfy-bounds.rs:7:30
+ |
+LL | fn foo<F2>(self) -> impl Foo<T>;
+ | ^^^^^^ required by this bound in `Foo::{opaque#0}`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs
new file mode 100644
index 000000000..65528f212
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs
@@ -0,0 +1,19 @@
+// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
+// revisions: current next
+
+#![feature(return_position_impl_trait_in_trait)]
+
+trait Foo<T> {
+ fn foo<F2>(self) -> impl Foo<T>;
+}
+
+struct Bar;
+
+impl Foo<char> for Bar {
+ fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
+ //~^ ERROR: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied [E0277]
+ self
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr
index eba270af7..8c9dd4031 100644
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr
@@ -1,16 +1,61 @@
-error: `impl` item signature doesn't match `trait` item signature
- --> $DIR/signature-mismatch.rs:17:5
+error: return type captures more lifetimes than trait definition
+ --> $DIR/signature-mismatch.rs:36:47
+ |
+LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: hidden type must only reference lifetimes captured by this impl trait
+ --> $DIR/signature-mismatch.rs:17:40
|
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
- | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
+
+error: return type captures more lifetimes than trait definition
+ --> $DIR/signature-mismatch.rs:41:57
+ |
+LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: hidden type must only reference lifetimes captured by this impl trait
+ --> $DIR/signature-mismatch.rs:18:57
+ |
+LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
+
+error: return type captures more lifetimes than trait definition
+ --> $DIR/signature-mismatch.rs:49:10
+ |
+LL | fn async_fn_multiple<'a, 'b>(
+ | -- this lifetime was captured
...
-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`
+LL | ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: hidden type must only reference lifetimes captured by this impl trait
+ --> $DIR/signature-mismatch.rs:20:12
+ |
+LL | -> impl Future<Output = Vec<u8>> + Captures<'a>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: hidden type inferred to be `impl Future<Output = Vec<u8>> + Captures2<'a, 'b>`
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/signature-mismatch.rs:58:10
+ |
+LL | ) -> impl Future<Output = Vec<u8>> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future<Output = Vec<u8>>` will meet its required lifetime bounds...
+ |
+note: ...that is required by this bound
+ --> $DIR/signature-mismatch.rs:25:42
+ |
+LL | ) -> impl Future<Output = Vec<u8>> + 'a;
+ | ^^
+help: consider adding an explicit lifetime bound...
|
- = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
- found signature `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
+LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>(
+ | ++++
-error: aborting due to previous error
+error: aborting due to 4 previous errors
+For more information about this error, try `rustc --explain E0309`.
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
index eba270af7..8c9dd4031 100644
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
@@ -1,16 +1,61 @@
-error: `impl` item signature doesn't match `trait` item signature
- --> $DIR/signature-mismatch.rs:17:5
+error: return type captures more lifetimes than trait definition
+ --> $DIR/signature-mismatch.rs:36:47
+ |
+LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: hidden type must only reference lifetimes captured by this impl trait
+ --> $DIR/signature-mismatch.rs:17:40
|
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
- | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
+
+error: return type captures more lifetimes than trait definition
+ --> $DIR/signature-mismatch.rs:41:57
+ |
+LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ | -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: hidden type must only reference lifetimes captured by this impl trait
+ --> $DIR/signature-mismatch.rs:18:57
+ |
+LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
+
+error: return type captures more lifetimes than trait definition
+ --> $DIR/signature-mismatch.rs:49:10
+ |
+LL | fn async_fn_multiple<'a, 'b>(
+ | -- this lifetime was captured
...
-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`
+LL | ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: hidden type must only reference lifetimes captured by this impl trait
+ --> $DIR/signature-mismatch.rs:20:12
+ |
+LL | -> impl Future<Output = Vec<u8>> + Captures<'a>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: hidden type inferred to be `impl Future<Output = Vec<u8>> + Captures2<'a, 'b>`
+
+error[E0309]: the parameter type `T` may not live long enough
+ --> $DIR/signature-mismatch.rs:58:10
+ |
+LL | ) -> impl Future<Output = Vec<u8>> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future<Output = Vec<u8>>` will meet its required lifetime bounds...
+ |
+note: ...that is required by this bound
+ --> $DIR/signature-mismatch.rs:25:42
+ |
+LL | ) -> impl Future<Output = Vec<u8>> + 'a;
+ | ^^
+help: consider adding an explicit lifetime bound...
|
- = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
- found signature `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
+LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>(
+ | ++++
-error: aborting due to previous error
+error: aborting due to 4 previous errors
+For more information about this error, try `rustc --explain E0309`.
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.rs b/tests/ui/impl-trait/in-trait/signature-mismatch.rs
index 38c902a97..23dd71ace 100644
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs
@@ -7,17 +7,70 @@
use std::future::Future;
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+trait Captures2<'a, 'b> {}
+impl<T> Captures2<'_, '_> for T {}
+
pub trait AsyncTrait {
fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
+ fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
+ fn async_fn_multiple<'a>(&'a self, buff: &[u8])
+ -> impl Future<Output = Vec<u8>> + Captures<'a>;
+ fn async_fn_reduce_outlive<'a, T>(
+ &'a self,
+ buff: &[u8],
+ t: T,
+ ) -> impl Future<Output = Vec<u8>> + 'a;
+ fn async_fn_reduce<'a, T>(
+ &'a self,
+ buff: &[u8],
+ t: T,
+ ) -> impl Future<Output = Vec<u8>> + Captures<'a>;
}
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
+ //~^ ERROR return type captures more lifetimes than trait definition
+ async move { buff.to_vec() }
+ }
+
+ fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ //~^ ERROR return type captures more lifetimes than trait definition
+ async move { buff.to_vec() }
+ }
+
+ fn async_fn_multiple<'a, 'b>(
+ &'a self,
+ buff: &'b [u8],
+ ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
+ //~^ ERROR return type captures more lifetimes than trait definition
async move { buff.to_vec() }
}
+
+ fn async_fn_reduce_outlive<'a, 'b, T>(
+ &'a self,
+ buff: &'b [u8],
+ t: T,
+ ) -> impl Future<Output = Vec<u8>> {
+ //~^ ERROR the parameter type `T` may not live long enough
+ async move {
+ let _t = t;
+ vec![]
+ }
+ }
+
+ // OK: We remove the `Captures<'a>`, providing a guarantee that we don't capture `'a`,
+ // but we still fulfill the `Captures<'a>` trait bound.
+ fn async_fn_reduce<'a, 'b, T>(&'a self, buff: &'b [u8], t: T) -> impl Future<Output = Vec<u8>> {
+ async move {
+ let _t = t;
+ vec![]
+ }
+ }
}
fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed
new file mode 100644
index 000000000..d9f775a6c
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed
@@ -0,0 +1,25 @@
+// edition:2021
+// run-rustfix
+
+#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
+
+trait Trait {
+ async fn foo();
+
+ async fn bar() -> i32;
+
+ fn test(&self) -> impl Sized + '_;
+
+ async fn baz(&self) -> &i32;
+}
+
+struct S;
+
+impl Trait for S {async fn baz(&self) -> &i32 { todo!() }
+fn test(&self) -> impl Sized + '_ { todo!() }
+async fn bar() -> i32 { todo!() }
+async fn foo() { todo!() }
+}
+//~^ ERROR not all trait items implemented
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs
new file mode 100644
index 000000000..26979b514
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs
@@ -0,0 +1,21 @@
+// edition:2021
+// run-rustfix
+
+#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
+
+trait Trait {
+ async fn foo();
+
+ async fn bar() -> i32;
+
+ fn test(&self) -> impl Sized + '_;
+
+ async fn baz(&self) -> &i32;
+}
+
+struct S;
+
+impl Trait for S {}
+//~^ ERROR not all trait items implemented
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr
new file mode 100644
index 000000000..44f98896e
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr
@@ -0,0 +1,21 @@
+error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz`
+ --> $DIR/suggest-missing-item.rs:18:1
+ |
+LL | async fn foo();
+ | --------------- `foo` from trait
+LL |
+LL | async fn bar() -> i32;
+ | ---------------------- `bar` from trait
+LL |
+LL | fn test(&self) -> impl Sized + '_;
+ | ---------------------------------- `test` from trait
+LL |
+LL | async fn baz(&self) -> &i32;
+ | ---------------------------- `baz` from trait
+...
+LL | impl Trait for S {}
+ | ^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `test`, `baz` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr
new file mode 100644
index 000000000..bf088ae8b
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/unconstrained-lt.rs:10:6
+ |
+LL | impl<'a, T> Foo for T {
+ | ^^ unconstrained lifetime parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr
new file mode 100644
index 000000000..bf088ae8b
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/unconstrained-lt.rs:10:6
+ |
+LL | impl<'a, T> Foo for T {
+ | ^^ unconstrained lifetime parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs
new file mode 100644
index 000000000..f966be43a
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs
@@ -0,0 +1,16 @@
+// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
+// revisions: current next
+
+#![feature(return_position_impl_trait_in_trait)]
+
+trait Foo {
+ fn test() -> impl Sized;
+}
+
+impl<'a, T> Foo for T {
+ //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+
+ fn test() -> &'a () { &() }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/variances-of-gat.rs b/tests/ui/impl-trait/in-trait/variances-of-gat.rs
new file mode 100644
index 000000000..4008ece94
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/variances-of-gat.rs
@@ -0,0 +1,19 @@
+// check-pass
+// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
+// revisions: current next
+
+#![feature(return_position_impl_trait_in_trait)]
+
+trait Foo {}
+
+impl Foo for () {}
+
+trait ThreeCellFragment {
+ fn ext_cells<'a>(&'a self) -> impl Foo + 'a {
+ self.ext_adjacent_cells()
+ }
+
+ fn ext_adjacent_cells<'a>(&'a self) -> impl Foo + 'a;
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr
index 1a7071612..74c84c012 100644
--- a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr
+++ b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr
@@ -1,5 +1,5 @@
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:13:22
+ --> $DIR/wf-bounds.rs:17:22
|
LL | fn nya() -> impl Wf<Vec<[u8]>>;
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -9,14 +9,14 @@ note: required by a bound in `Vec`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:16:23
+ --> $DIR/wf-bounds.rs:20: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:8:10
+ --> $DIR/wf-bounds.rs:10:10
|
LL | trait Wf<T> {
| ^ required by this bound in `Wf`
@@ -26,7 +26,7 @@ LL | trait Wf<T: ?Sized> {
| ++++++++
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:19:44
+ --> $DIR/wf-bounds.rs:23:44
|
LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -35,6 +35,23 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
note: required by a bound in `Vec`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
-error: aborting due to 3 previous errors
+error[E0277]: `T` doesn't implement `std::fmt::Display`
+ --> $DIR/wf-bounds.rs:26:26
+ |
+LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
+ | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
+ |
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `NeedsDisplay`
+ --> $DIR/wf-bounds.rs:14:24
+ |
+LL | struct NeedsDisplay<T: Display>(T);
+ | ^^^^^^^ required by this bound in `NeedsDisplay`
+help: consider restricting type parameter `T`
+ |
+LL | fn nya4<T: std::fmt::Display>() -> impl Wf<NeedsDisplay<T>>;
+ | +++++++++++++++++++
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr
index 1a7071612..74c84c012 100644
--- a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr
+++ b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr
@@ -1,5 +1,5 @@
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:13:22
+ --> $DIR/wf-bounds.rs:17:22
|
LL | fn nya() -> impl Wf<Vec<[u8]>>;
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -9,14 +9,14 @@ note: required by a bound in `Vec`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:16:23
+ --> $DIR/wf-bounds.rs:20: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:8:10
+ --> $DIR/wf-bounds.rs:10:10
|
LL | trait Wf<T> {
| ^ required by this bound in `Wf`
@@ -26,7 +26,7 @@ LL | trait Wf<T: ?Sized> {
| ++++++++
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:19:44
+ --> $DIR/wf-bounds.rs:23:44
|
LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -35,6 +35,23 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
note: required by a bound in `Vec`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
-error: aborting due to 3 previous errors
+error[E0277]: `T` doesn't implement `std::fmt::Display`
+ --> $DIR/wf-bounds.rs:26:26
+ |
+LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
+ | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
+ |
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `NeedsDisplay`
+ --> $DIR/wf-bounds.rs:14:24
+ |
+LL | struct NeedsDisplay<T: Display>(T);
+ | ^^^^^^^ required by this bound in `NeedsDisplay`
+help: consider restricting type parameter `T`
+ |
+LL | fn nya4<T: std::fmt::Display>() -> impl Wf<NeedsDisplay<T>>;
+ | +++++++++++++++++++
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs
index 1c9590bd8..f8c1e561d 100644
--- a/tests/ui/impl-trait/in-trait/wf-bounds.rs
+++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs
@@ -5,10 +5,14 @@
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
+use std::fmt::Display;
+
trait Wf<T> {
type Output;
}
+struct NeedsDisplay<T: Display>(T);
+
trait Uwu {
fn nya() -> impl Wf<Vec<[u8]>>;
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
@@ -18,6 +22,9 @@ trait Uwu {
fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+
+ fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
+ //~^ ERROR `T` doesn't implement `std::fmt::Display`
}
fn main() {}
diff --git a/tests/ui/impl-trait/issue-103181-2.rs b/tests/ui/impl-trait/issue-103181-2.rs
index b43ac4507..34deb98be 100644
--- a/tests/ui/impl-trait/issue-103181-2.rs
+++ b/tests/ui/impl-trait/issue-103181-2.rs
@@ -24,6 +24,8 @@ where
B: Send, // <- a second bound
{
normalize(broken_fut(), ());
+ //~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
+ //~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
}
fn main() {}
diff --git a/tests/ui/impl-trait/issue-103181-2.stderr b/tests/ui/impl-trait/issue-103181-2.stderr
index 5eb2dd918..cb5253ea6 100644
--- a/tests/ui/impl-trait/issue-103181-2.stderr
+++ b/tests/ui/impl-trait/issue-103181-2.stderr
@@ -4,6 +4,61 @@ error[E0425]: cannot find value `ident_error` in this scope
LL | ident_error;
| ^^^^^^^^^^^ not found in this scope
-error: aborting due to previous error
+error: cannot check whether the hidden type of opaque type satisfies auto traits
+ --> $DIR/issue-103181-2.rs:26:15
+ |
+LL | normalize(broken_fut(), ());
+ | --------- ^^^^^^^^^^^^
+ | |
+ | required by a bound introduced by this call
+ |
+note: opaque type is declared here
+ --> $DIR/issue-103181-2.rs:11:23
+ |
+LL | async fn broken_fut() {
+ | ^
+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/issue-103181-2.rs:20:10
+ |
+LL | async fn iceice<A, B>()
+ | ^^^^^^
+note: required for `impl Future<Output = ()>` to implement `SendFuture`
+ --> $DIR/issue-103181-2.rs:7:17
+ |
+LL | impl<Fut: Send> SendFuture for Fut {
+ | ---- ^^^^^^^^^^ ^^^
+ | |
+ | unsatisfied trait bound introduced here
+note: required by a bound in `normalize`
+ --> $DIR/issue-103181-2.rs:18:19
+ |
+LL | fn normalize<Fut: SendFuture>(_: Fut, _: Fut::Output) {}
+ | ^^^^^^^^^^ required by this bound in `normalize`
+
+error: cannot check whether the hidden type of opaque type satisfies auto traits
+ --> $DIR/issue-103181-2.rs:26:5
+ |
+LL | normalize(broken_fut(), ());
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: opaque type is declared here
+ --> $DIR/issue-103181-2.rs:11:23
+ |
+LL | async fn broken_fut() {
+ | ^
+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/issue-103181-2.rs:20:10
+ |
+LL | async fn iceice<A, B>()
+ | ^^^^^^
+note: required for `impl Future<Output = ()>` to implement `SendFuture`
+ --> $DIR/issue-103181-2.rs:7:17
+ |
+LL | impl<Fut: Send> SendFuture for Fut {
+ | ---- ^^^^^^^^^^ ^^^
+ | |
+ | unsatisfied trait bound introduced here
+
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/impl-trait/issue-55872-3.rs b/tests/ui/impl-trait/issue-55872-3.rs
index d031271ac..7490a1308 100644
--- a/tests/ui/impl-trait/issue-55872-3.rs
+++ b/tests/ui/impl-trait/issue-55872-3.rs
@@ -1,5 +1,4 @@
// edition:2018
-// ignore-compare-mode-chalk
#![feature(impl_trait_in_assoc_type)]
diff --git a/tests/ui/impl-trait/issue-55872-3.stderr b/tests/ui/impl-trait/issue-55872-3.stderr
index c6e10f0f3..827988974 100644
--- a/tests/ui/impl-trait/issue-55872-3.stderr
+++ b/tests/ui/impl-trait/issue-55872-3.stderr
@@ -1,8 +1,8 @@
-error[E0277]: the trait bound `[async block@$DIR/issue-55872-3.rs:16:9: 16:17]: Copy` is not satisfied
- --> $DIR/issue-55872-3.rs:14:20
+error[E0277]: the trait bound `[async block@$DIR/issue-55872-3.rs:15:9: 15:17]: Copy` is not satisfied
+ --> $DIR/issue-55872-3.rs:13:20
|
LL | fn foo<T>() -> Self::E {
- | ^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/issue-55872-3.rs:16:9: 16:17]`
+ | ^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/issue-55872-3.rs:15:9: 15:17]`
error: aborting due to previous error
diff --git a/tests/ui/impl-trait/issues/issue-65581.rs b/tests/ui/impl-trait/issues/issue-65581.rs
index b947fc1d2..af65b79d3 100644
--- a/tests/ui/impl-trait/issues/issue-65581.rs
+++ b/tests/ui/impl-trait/issues/issue-65581.rs
@@ -1,5 +1,4 @@
// check-pass
-// ignore-compare-mode-chalk
#![allow(dead_code)]
diff --git a/tests/ui/impl-trait/issues/issue-70877.rs b/tests/ui/impl-trait/issues/issue-70877.rs
index 8169cfafa..df7722986 100644
--- a/tests/ui/impl-trait/issues/issue-70877.rs
+++ b/tests/ui/impl-trait/issues/issue-70877.rs
@@ -25,12 +25,12 @@ fn ham() -> Foo {
Bar(1)
}
-fn oof() -> impl std::fmt::Debug {
+fn oof(_: Foo) -> impl std::fmt::Debug {
let mut bar = ham();
let func = bar.next().unwrap();
return func(&"oof"); //~ ERROR opaque type's hidden type cannot be another opaque type
}
fn main() {
- let _ = oof();
+ let _ = oof(ham());
}
diff --git a/tests/ui/impl-trait/issues/issue-70877.stderr b/tests/ui/impl-trait/issues/issue-70877.stderr
index 8813bff3c..ee140e6f6 100644
--- a/tests/ui/impl-trait/issues/issue-70877.stderr
+++ b/tests/ui/impl-trait/issues/issue-70877.stderr
@@ -5,10 +5,10 @@ LL | return func(&"oof");
| ^^^^^^^^^^^^ one of the two opaque types used here has to be outside its defining scope
|
note: opaque type whose hidden type is being assigned
- --> $DIR/issue-70877.rs:28:13
+ --> $DIR/issue-70877.rs:28:19
|
-LL | fn oof() -> impl std::fmt::Debug {
- | ^^^^^^^^^^^^^^^^^^^^
+LL | fn oof(_: Foo) -> impl std::fmt::Debug {
+ | ^^^^^^^^^^^^^^^^^^^^
note: opaque type being used as hidden type
--> $DIR/issue-70877.rs:4:15
|
diff --git a/tests/ui/impl-trait/issues/issue-74282.rs b/tests/ui/impl-trait/issues/issue-74282.rs
index 654de0cd0..51bd5f67e 100644
--- a/tests/ui/impl-trait/issues/issue-74282.rs
+++ b/tests/ui/impl-trait/issues/issue-74282.rs
@@ -3,9 +3,12 @@
type Closure = impl Fn() -> u64;
struct Anonymous(Closure);
-fn main() {
+fn bop(_: Closure) {
let y = || -> Closure { || 3 };
- Anonymous(|| { //~ ERROR mismatched types
- 3 //~^ ERROR mismatched types
+ Anonymous(|| {
+ //~^ ERROR mismatched types
+ 3 //~^^ ERROR mismatched types
})
}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/issues/issue-74282.stderr b/tests/ui/impl-trait/issues/issue-74282.stderr
index 724f3c5d6..d43e9fee0 100644
--- a/tests/ui/impl-trait/issues/issue-74282.stderr
+++ b/tests/ui/impl-trait/issues/issue-74282.stderr
@@ -8,6 +8,7 @@ LL | Anonymous(|| {
| _____---------_^
| | |
| | arguments to this struct are incorrect
+LL | |
LL | | 3
LL | | })
| |_____^ expected opaque type, found closure
@@ -25,15 +26,20 @@ LL | struct Anonymous(Closure);
error[E0308]: mismatched types
--> $DIR/issue-74282.rs:8:5
|
-LL | fn main() {
- | - expected `()` because of default return type
-LL | let y = || -> Closure { || 3 };
LL | / Anonymous(|| {
+LL | |
LL | | 3
LL | | })
- | | ^- help: consider using a semicolon here: `;`
- | |______|
- | expected `()`, found `Anonymous`
+ | |______^ expected `()`, found `Anonymous`
+ |
+help: consider using a semicolon here
+ |
+LL | });
+ | +
+help: try adding a return type
+ |
+LL | fn bop(_: Closure) -> Anonymous {
+ | ++++++++++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/impl-trait/issues/issue-78722-2.rs b/tests/ui/impl-trait/issues/issue-78722-2.rs
new file mode 100644
index 000000000..cf5361e1e
--- /dev/null
+++ b/tests/ui/impl-trait/issues/issue-78722-2.rs
@@ -0,0 +1,22 @@
+//! test that we cannot register hidden types for opaque types
+//! declared outside an anonymous constant.
+// edition:2018
+
+#![feature(type_alias_impl_trait)]
+
+type F = impl core::future::Future<Output = u8>;
+
+struct Bug {
+ V1: [(); {
+ fn concrete_use() -> F {
+ //~^ ERROR future that resolves to `u8`, but it resolves to `()`
+ async {}
+ }
+ let f: F = async { 1 };
+ //~^ ERROR item constrains opaque type that is not in its signature
+ //~| ERROR `async` blocks are not allowed in constants
+ 1
+ }],
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr
new file mode 100644
index 000000000..6db603e77
--- /dev/null
+++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr
@@ -0,0 +1,32 @@
+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
+
+error[E0271]: expected `[async block@$DIR/issue-78722-2.rs:13:13: 13:21]` to be a future that resolves to `u8`, but it resolves to `()`
+ --> $DIR/issue-78722-2.rs:11:30
+ |
+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
+ |
+LL | let f: F = async { 1 };
+ | ^^^^^^^^^^^
+ |
+ = 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: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0271, E0658.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/tests/ui/impl-trait/issues/issue-78722.rs b/tests/ui/impl-trait/issues/issue-78722.rs
index 7b5ab5f22..75ccc8d8e 100644
--- a/tests/ui/impl-trait/issues/issue-78722.rs
+++ b/tests/ui/impl-trait/issues/issue-78722.rs
@@ -2,10 +2,9 @@
#![feature(type_alias_impl_trait)]
-type F = impl core::future::Future<Output = u8>;
-
struct Bug {
V1: [(); {
+ type F = impl core::future::Future<Output = u8>;
fn concrete_use() -> F {
//~^ ERROR to be a future that resolves to `u8`, but it resolves to `()`
async {}
diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr
index 05a2c135c..36340a0ba 100644
--- a/tests/ui/impl-trait/issues/issue-78722.stderr
+++ b/tests/ui/impl-trait/issues/issue-78722.stderr
@@ -1,5 +1,5 @@
error[E0658]: `async` blocks are not allowed in constants
- --> $DIR/issue-78722.rs:13:20
+ --> $DIR/issue-78722.rs:12:20
|
LL | let f: F = async { 1 };
| ^^^^^^^^^^^
@@ -7,8 +7,8 @@ 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[E0271]: expected `[async block@$DIR/issue-78722.rs:11:13: 11:21]` to be a future that resolves to `u8`, but it resolves to `()`
- --> $DIR/issue-78722.rs:9:30
+error[E0271]: expected `[async block@$DIR/issue-78722.rs:10:13: 10:21]` to be a future that resolves to `u8`, but it resolves to `()`
+ --> $DIR/issue-78722.rs:8:30
|
LL | fn concrete_use() -> F {
| ^ expected `()`, found `u8`
diff --git a/tests/ui/impl-trait/multiple-defining-usages-in-body.rs b/tests/ui/impl-trait/multiple-defining-usages-in-body.rs
index c3a6f09f8..86661153a 100644
--- a/tests/ui/impl-trait/multiple-defining-usages-in-body.rs
+++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.rs
@@ -4,9 +4,9 @@ impl Trait for () {}
fn foo<T: Trait, U: Trait>() -> impl Trait {
//~^ WARN function cannot return without recursing [unconditional_recursion]
let a: T = foo::<T, U>();
- //~^ ERROR concrete type differs from previous defining opaque type use
loop {}
let _: T = foo::<U, T>();
+ //~^ ERROR concrete type differs from previous defining opaque type use
}
fn main() {}
diff --git a/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr
index 06991749b..f3c090408 100644
--- a/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr
+++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr
@@ -11,15 +11,15 @@ LL | let a: T = foo::<T, U>();
= note: `#[warn(unconditional_recursion)]` on by default
error: concrete type differs from previous defining opaque type use
- --> $DIR/multiple-defining-usages-in-body.rs:6:16
+ --> $DIR/multiple-defining-usages-in-body.rs:8:16
|
-LL | let a: T = foo::<T, U>();
- | ^^^^^^^^^^^^^ expected `U`, got `T`
+LL | let _: T = foo::<U, T>();
+ | ^^^^^^^^^^^^^ expected `T`, got `U`
|
note: previous use here
- --> $DIR/multiple-defining-usages-in-body.rs:9:16
+ --> $DIR/multiple-defining-usages-in-body.rs:6:16
|
-LL | let _: T = foo::<U, T>();
+LL | let a: T = foo::<T, U>();
| ^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
diff --git a/tests/ui/impl-trait/nested-return-type2-tait.stderr b/tests/ui/impl-trait/nested-return-type2-tait.stderr
index a8eb69cfc..4383e8ab3 100644
--- a/tests/ui/impl-trait/nested-return-type2-tait.stderr
+++ b/tests/ui/impl-trait/nested-return-type2-tait.stderr
@@ -8,10 +8,6 @@ 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/tests/ui/impl-trait/nested-return-type3-tait.stderr b/tests/ui/impl-trait/nested-return-type3-tait.stderr
index 5f58c8dca..d32944a0d 100644
--- a/tests/ui/impl-trait/nested-return-type3-tait.stderr
+++ b/tests/ui/impl-trait/nested-return-type3-tait.stderr
@@ -8,10 +8,6 @@ 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/tests/ui/impl-trait/nested-return-type3-tait2.stderr b/tests/ui/impl-trait/nested-return-type3-tait2.stderr
index c07f6ead7..a2eddd116 100644
--- a/tests/ui/impl-trait/nested-return-type3-tait2.stderr
+++ b/tests/ui/impl-trait/nested-return-type3-tait2.stderr
@@ -8,10 +8,6 @@ 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/tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs b/tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs
new file mode 100644
index 000000000..1025c2c7e
--- /dev/null
+++ b/tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs
@@ -0,0 +1,27 @@
+// build-pass
+// edition:2021
+// compile-flags: -Cdebuginfo=2
+
+// We were not normalizing opaques with escaping bound vars during codegen,
+// leading to later linker errors because of differences in mangled symbol name.
+
+fn func<T>() -> impl Sized {}
+
+trait Trait<'a> {
+ type Assoc;
+
+ fn call() {
+ let _ = async {
+ let _value = func::<Self::Assoc>();
+ std::future::ready(()).await
+ };
+ }
+}
+
+impl Trait<'static> for () {
+ type Assoc = ();
+}
+
+fn main() {
+ <()>::call();
+}
diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs
index af9dfe25b..01c933473 100644
--- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs
+++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs
@@ -1,5 +1,7 @@
#![feature(type_alias_impl_trait)]
+// check-pass
+
type Foo = impl PartialEq<(Foo, i32)>;
struct Bar;
@@ -11,7 +13,6 @@ impl PartialEq<(Foo, i32)> for Bar {
}
fn foo() -> Foo {
- //~^ ERROR can't compare `Bar` with `(Bar, i32)`
Bar
}
diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr
deleted file mode 100644
index 7b63a3d0b..000000000
--- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0277]: can't compare `Bar` with `(Bar, i32)`
- --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:13:13
- |
-LL | fn foo() -> Foo {
- | ^^^ no implementation for `Bar == (Bar, i32)`
-LL |
-LL | Bar
- | --- return type was inferred to be `Bar` here
- |
- = help: the trait `PartialEq<(Bar, i32)>` is not implemented for `Bar`
- = help: the trait `PartialEq<(Foo, i32)>` is implemented for `Bar`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
index fe62a8f32..fe765271b 100644
--- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
+++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
@@ -44,10 +44,10 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
= note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _`
found signature `fn(&b::Bar, &(b::Bar, i32)) -> _`
note: this item must have the opaque type in its signature in order to be able to register hidden types
- --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:9
+ --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:12
|
LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^
error: aborting due to 4 previous errors
diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs
index ad0a003e8..aab10be2d 100644
--- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs
+++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs
@@ -1,5 +1,3 @@
-// check-pass
-
#![feature(type_alias_impl_trait)]
type Foo = impl PartialEq<(Foo, i32)>;
@@ -13,6 +11,7 @@ impl PartialEq<(Bar, i32)> for Bar {
}
fn foo() -> Foo {
+ //~^ ERROR can't compare `Bar` with `(Foo, i32)`
Bar
}
diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr
new file mode 100644
index 000000000..b98b859a9
--- /dev/null
+++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr
@@ -0,0 +1,15 @@
+error[E0277]: can't compare `Bar` with `(Foo, i32)`
+ --> $DIR/recursive-type-alias-impl-trait-declaration.rs:13:13
+ |
+LL | fn foo() -> Foo {
+ | ^^^ no implementation for `Bar == (Foo, i32)`
+LL |
+LL | Bar
+ | --- return type was inferred to be `Bar` here
+ |
+ = help: the trait `PartialEq<(Foo, i32)>` is not implemented for `Bar`
+ = help: the trait `PartialEq<(Bar, i32)>` is implemented for `Bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/reveal-during-codegen.rs b/tests/ui/impl-trait/reveal-during-codegen.rs
new file mode 100644
index 000000000..11463772e
--- /dev/null
+++ b/tests/ui/impl-trait/reveal-during-codegen.rs
@@ -0,0 +1,11 @@
+// build-pass
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
+
+fn test() -> Option<impl Sized> {
+ Some("")
+}
+
+fn main() {
+ test();
+}
diff --git a/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs
new file mode 100644
index 000000000..98dbaf036
--- /dev/null
+++ b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs
@@ -0,0 +1,12 @@
+// check-pass
+
+#![allow(incomplete_features)]
+#![feature(adt_const_params, return_position_impl_trait_in_trait)]
+
+pub struct Element;
+
+pub trait Node {
+ fn elements<const T: &'static str>(&self) -> impl Iterator<Item = Element>;
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/universal_wrong_hrtb.rs b/tests/ui/impl-trait/universal_wrong_hrtb.rs
index b9551c2ce..485617101 100644
--- a/tests/ui/impl-trait/universal_wrong_hrtb.rs
+++ b/tests/ui/impl-trait/universal_wrong_hrtb.rs
@@ -3,6 +3,6 @@ trait Trait<'a> {
}
fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
-//~^ ERROR `impl Trait` can only mention lifetimes bound at the fn or impl level
+//~^ ERROR `impl Trait` can only mention lifetimes from an fn or impl
fn main() {}
diff --git a/tests/ui/impl-trait/universal_wrong_hrtb.stderr b/tests/ui/impl-trait/universal_wrong_hrtb.stderr
index 37eb8dfa1..b5a091b61 100644
--- a/tests/ui/impl-trait/universal_wrong_hrtb.stderr
+++ b/tests/ui/impl-trait/universal_wrong_hrtb.stderr
@@ -1,14 +1,8 @@
-error: `impl Trait` can only mention lifetimes bound at the fn or impl level
+error: `impl Trait` can only mention lifetimes from an fn or impl
--> $DIR/universal_wrong_hrtb.rs:5:73
|
LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
- | ^^
- |
-note: lifetime declared here
- --> $DIR/universal_wrong_hrtb.rs:5:39
- |
-LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
- | ^^
+ | -- lifetime declared here ^^
error: aborting due to previous error