summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/type-alias-impl-trait
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/type-alias-impl-trait')
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr48
-rw-r--r--tests/ui/type-alias-impl-trait/closure_parent_substs.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs13
-rw-r--r--tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs15
-rw-r--r--tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained.stderr23
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained2.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr48
-rw-r--r--tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/inference-cycle.rs7
-rw-r--r--tests/ui/type-alias-impl-trait/inference-cycle.stderr50
-rw-r--r--tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs8
-rw-r--r--tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs22
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs22
-rw-r--r--tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs39
-rw-r--r--tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs39
-rw-r--r--tests/ui/type-alias-impl-trait/issue-58662-simplified.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-63279.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/issue-63279.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/issue-94429.rs12
-rw-r--r--tests/ui/type-alias-impl-trait/issue-94429.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs27
-rw-r--r--tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs44
-rw-r--r--tests/ui/type-alias-impl-trait/not_well_formed.fixed19
-rw-r--r--tests/ui/type-alias-impl-trait/not_well_formed.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/not_well_formed.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-fn-tait.rs17
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/reveal_local.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/reveal_local.stderr73
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs14
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr17
-rw-r--r--tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/wf-nested.fail.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr7
43 files changed, 402 insertions, 276 deletions
diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs
index 660950d59..cad75cffe 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs
@@ -5,9 +5,6 @@
mod m {
pub type Foo = impl std::fmt::Debug;
- //~^ ERROR: cycle detected when computing type of opaque `m::Foo::{opaque#0}` [E0391]
- //~| ERROR: cycle detected when computing type of opaque `m::Foo::{opaque#0}` [E0391]
-
pub fn foo() -> Foo {
22_u32
}
diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
index d86988266..d47b1fe36 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
@@ -1,44 +1,5 @@
-error[E0391]: cycle detected when computing type of opaque `m::Foo::{opaque#0}`
- --> $DIR/auto-trait-leakage3.rs:7:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires type-checking `m::bar`...
- --> $DIR/auto-trait-leakage3.rs:16:9
- |
-LL | is_send(foo());
- | ^^^^^^^
- = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
- = note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `m::Foo::{opaque#0}`
- --> $DIR/auto-trait-leakage3.rs:7:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
-error[E0391]: cycle detected when computing type of opaque `m::Foo::{opaque#0}`
- --> $DIR/auto-trait-leakage3.rs:7:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires type-checking `m::bar`...
- --> $DIR/auto-trait-leakage3.rs:15:5
- |
-LL | pub fn bar() {
- | ^^^^^^^^^^^^
- = note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `m::Foo::{opaque#0}`
- --> $DIR/auto-trait-leakage3.rs:7:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits
- --> $DIR/auto-trait-leakage3.rs:16:17
+ --> $DIR/auto-trait-leakage3.rs:13:17
|
LL | is_send(foo());
| ------- ^^^^^
@@ -51,16 +12,15 @@ note: opaque type is declared here
LL | pub type Foo = impl std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
- --> $DIR/auto-trait-leakage3.rs:15:12
+ --> $DIR/auto-trait-leakage3.rs:12:12
|
LL | pub fn bar() {
| ^^^
note: required by a bound in `is_send`
- --> $DIR/auto-trait-leakage3.rs:20:19
+ --> $DIR/auto-trait-leakage3.rs:17:19
|
LL | fn is_send<T: Send>(_: T) {}
| ^^^^ required by this bound in `is_send`
-error: aborting due to 3 previous errors
+error: aborting due to previous error
-For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs
index 3ff20d99a..7d8193b26 100644
--- a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs
+++ b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs
@@ -1,5 +1,5 @@
// When WF checking the hidden type in the ParamEnv of the opaque type,
-// one complication arises when the hidden type is a closure/generator:
+// one complication arises when the hidden type is a closure/coroutine:
// the "parent_substs" of the type may reference lifetime parameters
// not present in the opaque type.
// These region parameters are not really useful in this check.
diff --git a/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr b/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr
index ae6462bb6..3484485e3 100644
--- a/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr
+++ b/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr
@@ -46,14 +46,17 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/closure_wf_outlives.rs:54:22
|
LL | type Opaque<T> = impl Sized;
- | ^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
+ | ^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/closure_wf_outlives.rs:59:12
|
LL | T: 'static,
| ^^^^^^^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | type Opaque<T: 'static> = impl Sized;
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs
new file mode 100644
index 000000000..4c56fe2d1
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs
@@ -0,0 +1,13 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Opaque<'lt> = impl Sized + 'lt;
+
+fn test<'a>(
+ arg: impl Iterator<Item = &'a u8>,
+) -> impl Iterator<Item = Opaque<'a>> {
+ arg
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs
new file mode 100644
index 000000000..97f8c799f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs
@@ -0,0 +1,15 @@
+// check-pass
+// edition: 2021
+
+#![feature(type_alias_impl_trait)]
+
+struct Foo<'a>(&'a ());
+
+impl<'a> Foo<'a> {
+ async fn new() -> () {
+ type T = impl Sized;
+ let _: T = ();
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
index 8c3a25dbf..c352a33fb 100644
--- a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
@@ -17,9 +17,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:13:9
|
LL | t
- | ^ ...so that the type `T` will meet its required lifetime bounds
+ | ^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the type `T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn wrong_generic<T: 'static>(t: T) -> WrongGeneric<T> {
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.rs b/tests/ui/type-alias-impl-trait/generic_underconstrained.rs
index d87a25aad..1acacc778 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained.rs
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.rs
@@ -8,5 +8,6 @@ type Underconstrained<T: Trait> = impl Send;
// no `Trait` bound
fn underconstrain<T>(_: T) -> Underconstrained<T> {
//~^ ERROR the trait bound `T: Trait`
+ //~| ERROR the trait bound `T: Trait`
unimplemented!()
}
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr
index bc9280127..88529b370 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr
@@ -14,6 +14,27 @@ help: consider restricting type parameter `T`
LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
| +++++++
-error: aborting due to previous error
+error[E0277]: the trait bound `T: Trait` is not satisfied
+ --> $DIR/generic_underconstrained.rs:9:51
+ |
+LL | fn underconstrain<T>(_: T) -> Underconstrained<T> {
+ | ___________________________________________________^
+LL | |
+LL | |
+LL | | unimplemented!()
+LL | | }
+ | |_^ the trait `Trait` is not implemented for `T`
+ |
+note: required by a bound on the type alias `Underconstrained`
+ --> $DIR/generic_underconstrained.rs:6:26
+ |
+LL | type Underconstrained<T: Trait> = impl Send;
+ | ^^^^^ required by this bound
+help: consider restricting type parameter `T`
+ |
+LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
+ | +++++++
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs b/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs
index 8adc0bf32..1e1bece9a 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs
@@ -7,6 +7,7 @@ type Underconstrained<T: std::fmt::Debug> = impl Send;
// not a defining use, because it doesn't define *all* possible generics
fn underconstrained<U>(_: U) -> Underconstrained<U> {
//~^ ERROR `U` doesn't implement `Debug`
+ //~| ERROR `U` doesn't implement `Debug`
5u32
}
@@ -15,5 +16,6 @@ type Underconstrained2<T: std::fmt::Debug> = impl Send;
// not a defining use, because it doesn't define *all* possible generics
fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
//~^ ERROR `V` doesn't implement `Debug`
+ //~| ERROR `V` doesn't implement `Debug`
5u32
}
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr
index fdc9ec090..b3b9cbca9 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr
@@ -15,13 +15,13 @@ LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
| +++++++++++++++++
error[E0277]: `V` doesn't implement `Debug`
- --> $DIR/generic_underconstrained2.rs:16:43
+ --> $DIR/generic_underconstrained2.rs:17:43
|
LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
| ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
note: required by a bound on the type alias `Underconstrained2`
- --> $DIR/generic_underconstrained2.rs:13:27
+ --> $DIR/generic_underconstrained2.rs:14:27
|
LL | type Underconstrained2<T: std::fmt::Debug> = impl Send;
| ^^^^^^^^^^^^^^^ required by this bound
@@ -30,6 +30,48 @@ help: consider restricting type parameter `V`
LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
| +++++++++++++++++
-error: aborting due to 2 previous errors
+error[E0277]: `U` doesn't implement `Debug`
+ --> $DIR/generic_underconstrained2.rs:8:53
+ |
+LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
+ | _____________________________________________________^
+LL | |
+LL | |
+LL | | 5u32
+LL | | }
+ | |_^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ |
+note: required by a bound on the type alias `Underconstrained`
+ --> $DIR/generic_underconstrained2.rs:5:26
+ |
+LL | type Underconstrained<T: std::fmt::Debug> = impl Send;
+ | ^^^^^^^^^^^^^^^ required by this bound
+help: consider restricting type parameter `U`
+ |
+LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
+ | +++++++++++++++++
+
+error[E0277]: `V` doesn't implement `Debug`
+ --> $DIR/generic_underconstrained2.rs:17:64
+ |
+LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
+ | ________________________________________________________________^
+LL | |
+LL | |
+LL | | 5u32
+LL | | }
+ | |_^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ |
+note: required by a bound on the type alias `Underconstrained2`
+ --> $DIR/generic_underconstrained2.rs:14:27
+ |
+LL | type Underconstrained2<T: std::fmt::Debug> = impl Send;
+ | ^^^^^^^^^^^^^^^ required by this bound
+help: consider restricting type parameter `V`
+ |
+LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
+ | +++++++++++++++++
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr b/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr
index aaf75cc3d..e35913be8 100644
--- a/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr
+++ b/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr
@@ -15,6 +15,8 @@ LL | impl Bop for Bar<()> {}
...
LL | impl Bop for Barr {}
| ^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>`
+ |
+ = note: upstream crates may add a new impl of trait `std::marker::FnPtr` for type `Barr` in future versions
error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>`
--> $DIR/impl_trait_for_same_tait.rs:30:1
diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
index 399775641..d6dd20739 100644
--- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
@@ -22,9 +22,12 @@ error[E0310]: the parameter type `A` may not live long enough
--> $DIR/implied_lifetime_wf_check3.rs:29:41
|
LL | fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
- | ^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ | ^^^^^^^^^^^^^^^^^^
+ | |
+ | the parameter type `A` must be valid for the static lifetime...
+ | ...so that the type `A` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() }
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
index 47bc31e78..81bc64bc3 100644
--- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `A` may not live long enough
--> $DIR/implied_lifetime_wf_check4_static.rs:4:18
|
LL | type Ty<A> = impl Sized + 'static;
- | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ | ^^^^^^^^^^^^^^^^^^^^
+ | |
+ | the parameter type `A` must be valid for the static lifetime...
+ | ...so that the type `A` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | type Ty<A: 'static> = impl Sized + 'static;
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.rs b/tests/ui/type-alias-impl-trait/inference-cycle.rs
index 20175a4fe..6e4507ed4 100644
--- a/tests/ui/type-alias-impl-trait/inference-cycle.rs
+++ b/tests/ui/type-alias-impl-trait/inference-cycle.rs
@@ -3,17 +3,14 @@
mod m {
pub type Foo = impl std::fmt::Debug;
- //~^ ERROR cycle detected
- //~| ERROR cycle detected
-
- // Cycle: error today, but it'd be nice if it eventually worked
pub fn foo() -> Foo {
is_send(bar())
}
pub fn bar() {
- is_send(foo()); // Today: error
+ // Cycle: error today, but it'd be nice if it eventually worked
+ is_send(foo());
//~^ ERROR: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits
}
diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
index 4ab059d05..ef7abe588 100644
--- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr
+++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
@@ -1,46 +1,7 @@
-error[E0391]: cycle detected when computing type of opaque `m::Foo::{opaque#0}`
- --> $DIR/inference-cycle.rs:5:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires type-checking `m::bar`...
- --> $DIR/inference-cycle.rs:16:9
- |
-LL | is_send(foo()); // Today: error
- | ^^^^^^^
- = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
- = note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `m::Foo::{opaque#0}`
- --> $DIR/inference-cycle.rs:5:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
-error[E0391]: cycle detected when computing type of opaque `m::Foo::{opaque#0}`
- --> $DIR/inference-cycle.rs:5:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires type-checking `m::bar`...
- --> $DIR/inference-cycle.rs:15:5
- |
-LL | pub fn bar() {
- | ^^^^^^^^^^^^
- = note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `m::Foo::{opaque#0}`
- --> $DIR/inference-cycle.rs:5:20
- |
-LL | pub type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits
- --> $DIR/inference-cycle.rs:16:17
+ --> $DIR/inference-cycle.rs:13:17
|
-LL | is_send(foo()); // Today: error
+LL | is_send(foo());
| ------- ^^^^^
| |
| required by a bound introduced by this call
@@ -51,16 +12,15 @@ note: opaque type is declared here
LL | pub type Foo = impl std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
- --> $DIR/inference-cycle.rs:15:12
+ --> $DIR/inference-cycle.rs:11:12
|
LL | pub fn bar() {
| ^^^
note: required by a bound in `is_send`
- --> $DIR/inference-cycle.rs:24:19
+ --> $DIR/inference-cycle.rs:21:19
|
LL | fn is_send<T: Send>(_: T) {}
| ^^^^ required by this bound in `is_send`
-error: aborting due to 3 previous errors
+error: aborting due to previous error
-For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs
new file mode 100644
index 000000000..6609d4eb5
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs
@@ -0,0 +1,8 @@
+#![feature(type_alias_impl_trait)]
+
+type T = impl Copy;
+//~^ ERROR cannot resolve opaque type
+
+static STATIC: T = None::<&'static T>;
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr
new file mode 100644
index 000000000..50ae6f386
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr
@@ -0,0 +1,9 @@
+error[E0720]: cannot resolve opaque type
+ --> $DIR/infinite-cycle-involving-weak.rs:3:10
+ |
+LL | type T = impl Copy;
+ | ^^^^^^^^^ cannot resolve opaque type
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs
new file mode 100644
index 000000000..ad1ede9c3
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs
@@ -0,0 +1,22 @@
+#![feature(coroutines, coroutine_trait, rustc_attrs)]
+#![feature(type_alias_impl_trait)]
+
+// check-pass
+
+mod gen {
+ use std::ops::Coroutine;
+
+ pub type CoroOnce<Y, R> = impl Coroutine<Yield = Y, Return = R>;
+
+ pub const fn const_coroutine<Y, R>(yielding: Y, returning: R) -> CoroOnce<Y, R> {
+ move || {
+ yield yielding;
+
+ return returning;
+ }
+ }
+}
+
+const FOO: gen::CoroOnce<usize, usize> = gen::const_coroutine(10, 100);
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs
deleted file mode 100644
index a213dbba4..000000000
--- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#![feature(generators, generator_trait, rustc_attrs)]
-#![feature(type_alias_impl_trait)]
-
-// check-pass
-
-mod gen {
- use std::ops::Generator;
-
- pub type GenOnce<Y, R> = impl Generator<Yield = Y, Return = R>;
-
- pub const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> {
- move || {
- yield yielding;
-
- return returning;
- }
- }
-}
-
-const FOO: gen::GenOnce<usize, usize> = gen::const_generator(10, 100);
-
-fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs
new file mode 100644
index 000000000..bc6a34392
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs
@@ -0,0 +1,39 @@
+// check-pass
+
+#![feature(coroutines, coroutine_trait)]
+#![feature(type_alias_impl_trait)]
+
+use std::ops::{Coroutine, CoroutineState};
+use std::pin::Pin;
+
+type RandCoroutine<'a> = impl Coroutine<Return = (), Yield = u64> + 'a;
+fn rand_coroutine<'a>(rng: &'a ()) -> RandCoroutine<'a> {
+ move || {
+ let _rng = rng;
+ loop {
+ yield 0;
+ }
+ }
+}
+
+pub type RandCoroutineWithIndirection<'c> = impl Coroutine<Return = (), Yield = u64> + 'c;
+pub fn rand_coroutine_with_indirection<'a>(rng: &'a ()) -> RandCoroutineWithIndirection<'a> {
+ fn helper<'b>(rng: &'b ()) -> impl 'b + Coroutine<Return = (), Yield = u64> {
+ move || {
+ let _rng = rng;
+ loop {
+ yield 0;
+ }
+ }
+ }
+
+ helper(rng)
+}
+
+fn main() {
+ let mut gen = rand_coroutine(&());
+ match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) {
+ CoroutineState::Yielded(_) => {}
+ CoroutineState::Complete(_) => {}
+ };
+}
diff --git a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
deleted file mode 100644
index 477b61390..000000000
--- a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// check-pass
-
-#![feature(generators, generator_trait)]
-#![feature(type_alias_impl_trait)]
-
-use std::ops::{Generator, GeneratorState};
-use std::pin::Pin;
-
-type RandGenerator<'a> = impl Generator<Return = (), Yield = u64> + 'a;
-fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> {
- move || {
- let _rng = rng;
- loop {
- yield 0;
- }
- }
-}
-
-pub type RandGeneratorWithIndirection<'c> = impl Generator<Return = (), Yield = u64> + 'c;
-pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> {
- fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> {
- move || {
- let _rng = rng;
- loop {
- yield 0;
- }
- }
- }
-
- helper(rng)
-}
-
-fn main() {
- let mut gen = rand_generator(&());
- match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) {
- GeneratorState::Yielded(_) => {}
- GeneratorState::Complete(_) => {}
- };
-}
diff --git a/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs b/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
index 27ca7d0fd..a1cf23dab 100644
--- a/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
+++ b/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
@@ -1,6 +1,6 @@
// check-pass
-#![feature(generators, generator_trait)]
+#![feature(coroutines, coroutine_trait)]
#![feature(type_alias_impl_trait)]
trait Trait {}
diff --git a/tests/ui/type-alias-impl-trait/issue-63279.rs b/tests/ui/type-alias-impl-trait/issue-63279.rs
index 0e46745c6..02f211146 100644
--- a/tests/ui/type-alias-impl-trait/issue-63279.rs
+++ b/tests/ui/type-alias-impl-trait/issue-63279.rs
@@ -3,11 +3,11 @@
type Closure = impl FnOnce();
fn c() -> Closure {
- //~^ ERROR: expected a `FnOnce<()>` closure, found `()`
+ //~^ ERROR: expected a `FnOnce()` closure, found `()`
|| -> Closure { || () }
//~^ ERROR: mismatched types
//~| ERROR: mismatched types
- //~| ERROR: expected a `FnOnce<()>` closure, found `()`
+ //~| ERROR: expected a `FnOnce()` closure, found `()`
}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-63279.stderr b/tests/ui/type-alias-impl-trait/issue-63279.stderr
index a86856247..58cafd21c 100644
--- a/tests/ui/type-alias-impl-trait/issue-63279.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-63279.stderr
@@ -1,17 +1,17 @@
-error[E0277]: expected a `FnOnce<()>` closure, found `()`
+error[E0277]: expected a `FnOnce()` closure, found `()`
--> $DIR/issue-63279.rs:5:11
|
LL | fn c() -> Closure {
- | ^^^^^^^ expected an `FnOnce<()>` closure, found `()`
+ | ^^^^^^^ expected an `FnOnce()` closure, found `()`
|
= help: the trait `FnOnce<()>` is not implemented for `()`
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
-error[E0277]: expected a `FnOnce<()>` closure, found `()`
+error[E0277]: expected a `FnOnce()` closure, found `()`
--> $DIR/issue-63279.rs:7:11
|
LL | || -> Closure { || () }
- | ^^^^^^^ expected an `FnOnce<()>` closure, found `()`
+ | ^^^^^^^ expected an `FnOnce()` closure, found `()`
|
= help: the trait `FnOnce<()>` is not implemented for `()`
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
diff --git a/tests/ui/type-alias-impl-trait/issue-94429.rs b/tests/ui/type-alias-impl-trait/issue-94429.rs
index d764545f9..306e73003 100644
--- a/tests/ui/type-alias-impl-trait/issue-94429.rs
+++ b/tests/ui/type-alias-impl-trait/issue-94429.rs
@@ -1,18 +1,18 @@
-#![feature(impl_trait_in_assoc_type, generator_trait, generators)]
-use std::ops::Generator;
+#![feature(impl_trait_in_assoc_type, coroutine_trait, coroutines)]
+use std::ops::Coroutine;
trait Runnable {
- type Gen: Generator<Yield = (), Return = ()>;
+ type Coro: Coroutine<Yield = (), Return = ()>;
- fn run(&mut self) -> Self::Gen;
+ fn run(&mut self) -> Self::Coro;
}
struct Implementor {}
impl Runnable for Implementor {
- type Gen = impl Generator<Yield = (), Return = ()>;
+ type Coro = impl Coroutine<Yield = (), Return = ()>;
- fn run(&mut self) -> Self::Gen {
+ fn run(&mut self) -> Self::Coro {
//~^ ERROR: type mismatch resolving
move || {
yield 1;
diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr
index 26605cdd2..360ecfa61 100644
--- a/tests/ui/type-alias-impl-trait/issue-94429.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr
@@ -1,8 +1,8 @@
-error[E0271]: type mismatch resolving `<{generator@$DIR/issue-94429.rs:17:9: 17:16} as Generator>::Yield == ()`
+error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:17:9: 17:16} as Coroutine>::Yield == ()`
--> $DIR/issue-94429.rs:15:26
|
-LL | fn run(&mut self) -> Self::Gen {
- | ^^^^^^^^^ expected integer, found `()`
+LL | fn run(&mut self) -> Self::Coro {
+ | ^^^^^^^^^^ expected integer, found `()`
error: aborting due to previous error
diff --git a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
index fdd8fa65b..5bd854be8 100644
--- a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
+++ b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
@@ -26,11 +26,9 @@ fn upvar() {
fn enum_upvar() {
type T = impl Copy;
let foo: T = Some((1u32, 2u32));
- let x = move || {
- match foo {
- None => (),
- Some((a, b)) => (),
- }
+ let x = move || match foo {
+ None => (),
+ Some((a, b)) => (),
};
}
@@ -63,6 +61,19 @@ mod only_pattern {
None => {}
}
}
+
+ type V = impl Copy;
+
+ fn baz(baz: Option<V>) {
+ match baz {
+ _ => {}
+ Some((mut x, mut y)) => {
+ x = 42;
+ y = "foo";
+ }
+ None => {}
+ }
+ }
}
mod only_pattern_rpit {
@@ -71,11 +82,7 @@ mod only_pattern_rpit {
let (mut x, mut y) = foo(false);
x = 42;
y = "foo";
- if b {
- panic!()
- } else {
- foo(true)
- }
+ if b { panic!() } else { foo(true) }
}
fn bar(b: bool) -> Option<impl Copy> {
diff --git a/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs b/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs
new file mode 100644
index 000000000..5f3dbaa17
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs
@@ -0,0 +1,44 @@
+//! This test checks that we do not walk types in async blocks for
+//! determining the opaque types that appear in a signature. async blocks,
+//! all other coroutines and closures are always private and not part of
+//! a signature. They become part of a signature via `dyn Trait` or `impl Trait`,
+//! which is something that we process abstractly without looking at its hidden
+//! types.
+// edition: 2021
+// check-pass
+
+#![feature(impl_trait_in_assoc_type)]
+
+use std::future::Future;
+
+pub struct MemtableLocalStateStore {
+ mem_table: MemTable,
+}
+
+impl LocalStateStore for MemtableLocalStateStore {
+ type IterStream<'a> = impl Sized + 'a where Self: 'a;
+
+ fn iter(&self) -> impl Future<Output = Self::IterStream<'_>> + '_ {
+ async move { merge_stream(self.mem_table.iter()) }
+ }
+}
+
+trait LocalStateStore {
+ type IterStream<'a>
+ where
+ Self: 'a;
+
+ fn iter(&self) -> impl Future<Output = Self::IterStream<'_>> + '_;
+}
+
+struct MemTable;
+
+impl MemTable {
+ fn iter<'a>(&'a self) -> impl Iterator<Item = &'a ()> {
+ std::iter::empty()
+ }
+}
+
+pub(crate) async fn merge_stream<'a>(mem_table_iter: impl Iterator<Item = &'a ()>) {}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.fixed b/tests/ui/type-alias-impl-trait/not_well_formed.fixed
new file mode 100644
index 000000000..d98e83ff6
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/not_well_formed.fixed
@@ -0,0 +1,19 @@
+// run-rustfix
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+fn main() {}
+
+trait TraitWithAssoc {
+ type Assoc;
+}
+
+type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; //~ associated type `Assoc` not found for `V`
+
+trait Trait<U> {}
+
+impl<W> Trait<W> for () {}
+
+fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T> {
+ ()
+}
diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.rs b/tests/ui/type-alias-impl-trait/not_well_formed.rs
index fbb7a4d58..18f173a69 100644
--- a/tests/ui/type-alias-impl-trait/not_well_formed.rs
+++ b/tests/ui/type-alias-impl-trait/not_well_formed.rs
@@ -1,4 +1,6 @@
+// run-rustfix
#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.stderr b/tests/ui/type-alias-impl-trait/not_well_formed.stderr
index c36b95f47..b267e6a75 100644
--- a/tests/ui/type-alias-impl-trait/not_well_formed.stderr
+++ b/tests/ui/type-alias-impl-trait/not_well_formed.stderr
@@ -1,8 +1,13 @@
error[E0220]: associated type `Assoc` not found for `V`
- --> $DIR/not_well_formed.rs:9:29
+ --> $DIR/not_well_formed.rs:11:29
|
LL | type Foo<V> = impl Trait<V::Assoc>;
- | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc`
+ | ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc`
+ |
+help: consider restricting type parameter `V`
+ |
+LL | type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
+ | ++++++++++++++++
error: aborting due to previous error
diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs b/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs
new file mode 100644
index 000000000..3d1759097
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs
@@ -0,0 +1,17 @@
+// test for #113326
+#![feature(type_alias_impl_trait)]
+
+pub type Diff = impl Fn(usize) -> usize;
+
+pub fn lift() -> Diff {
+ |_: usize |loop {}
+}
+
+pub fn add(
+ n: Diff,
+ m: Diff,
+) -> Diff {
+ move |x: usize| m(n(x)) //~ ERROR: concrete type differs
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr
new file mode 100644
index 000000000..b2898a211
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/recursive-fn-tait.rs:14:5
+ |
+LL | move |x: usize| m(n(x))
+ | ^^^^^^^^^^^^^^^^^^^^^^^ expected `{closure@$DIR/recursive-fn-tait.rs:7:5: 7:16}`, got `{closure@$DIR/recursive-fn-tait.rs:14:5: 14:20}`
+ |
+note: previous use here
+ --> $DIR/recursive-fn-tait.rs:7:5
+ |
+LL | |_: usize |loop {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/type-alias-impl-trait/reveal_local.rs b/tests/ui/type-alias-impl-trait/reveal_local.rs
index 7943bb240..07fd989b0 100644
--- a/tests/ui/type-alias-impl-trait/reveal_local.rs
+++ b/tests/ui/type-alias-impl-trait/reveal_local.rs
@@ -3,9 +3,6 @@
use std::fmt::Debug;
type Foo = impl Debug;
-//~^ ERROR cycle detected
-//~| ERROR cycle detected
-//~| ERROR cycle detected
fn is_send<T: Send>() {}
diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr
index c62fd88f4..796e2d011 100644
--- a/tests/ui/type-alias-impl-trait/reveal_local.stderr
+++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr
@@ -1,44 +1,5 @@
-error[E0391]: cycle detected when computing type of opaque `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- |
-note: ...which requires type-checking `not_good`...
- --> $DIR/reveal_local.rs:15:5
- |
-LL | is_send::<Foo>();
- | ^^^^^^^^^^^^^^
- = note: ...which requires evaluating trait selection obligation `Foo: core::marker::Send`...
- = note: ...which again requires computing type of opaque `Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
-error[E0391]: cycle detected when computing type of opaque `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- |
-note: ...which requires type-checking `not_good`...
- --> $DIR/reveal_local.rs:12:1
- |
-LL | fn not_good() {
- | ^^^^^^^^^^^^^
- = note: ...which again requires computing type of opaque `Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
- --> $DIR/reveal_local.rs:15:15
+ --> $DIR/reveal_local.rs:12:15
|
LL | is_send::<Foo>();
| ^^^
@@ -49,37 +10,18 @@ note: opaque type is declared here
LL | type Foo = impl Debug;
| ^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
- --> $DIR/reveal_local.rs:12:4
+ --> $DIR/reveal_local.rs:9:4
|
LL | fn not_good() {
| ^^^^^^^^
note: required by a bound in `is_send`
- --> $DIR/reveal_local.rs:10:15
+ --> $DIR/reveal_local.rs:7:15
|
LL | fn is_send<T: Send>() {}
| ^^^^ required by this bound in `is_send`
-error[E0391]: cycle detected when computing type of opaque `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- |
-note: ...which requires type-checking `not_gooder`...
- --> $DIR/reveal_local.rs:19:1
- |
-LL | fn not_gooder() -> Foo {
- | ^^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires computing type of opaque `Foo::{opaque#0}`, completing the cycle
-note: cycle used when computing type of `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
- --> $DIR/reveal_local.rs:25:15
+ --> $DIR/reveal_local.rs:22:15
|
LL | is_send::<Foo>();
| ^^^
@@ -90,16 +32,15 @@ note: opaque type is declared here
LL | type Foo = impl Debug;
| ^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
- --> $DIR/reveal_local.rs:19:4
+ --> $DIR/reveal_local.rs:16:4
|
LL | fn not_gooder() -> Foo {
| ^^^^^^^^^^
note: required by a bound in `is_send`
- --> $DIR/reveal_local.rs:10:15
+ --> $DIR/reveal_local.rs:7:15
|
LL | fn is_send<T: Send>() {}
| ^^^^ required by this bound in `is_send`
-error: aborting due to 5 previous errors
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs
index 857066c78..9796823a7 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs
@@ -4,7 +4,7 @@
// FIXME: this is ruled out for now but should work
type Foo = fn() -> impl Send;
-//~^ ERROR: `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR: `impl Trait` only allowed in function and inherent method argument and return types
fn make_foo() -> Foo {
|| 15
diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr
index ff375b2ff..e57c59d61 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr
@@ -1,4 +1,4 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types
--> $DIR/type-alias-impl-trait-fn-type.rs:6:20
|
LL | type Foo = fn() -> impl Send;
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs
new file mode 100644
index 000000000..ae3d317ab
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs
@@ -0,0 +1,14 @@
+#![feature(type_alias_impl_trait)]
+
+type Tait = impl Copy;
+// Make sure that this TAIT isn't considered unconstrained...
+
+fn empty_opaque() -> Tait {
+ if false {
+ match empty_opaque() {}
+ //~^ ERROR non-empty
+ }
+ 0u8
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr
new file mode 100644
index 000000000..6cc5b7a8a
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr
@@ -0,0 +1,17 @@
+error[E0004]: non-exhaustive patterns: type `Tait` is non-empty
+ --> $DIR/unconstrained-due-to-bad-pattern.rs:8:15
+ |
+LL | match empty_opaque() {}
+ | ^^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `Tait`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match empty_opaque() {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr b/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr
index 9e96323ab..7d72c9f81 100644
--- a/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr
@@ -1,10 +1,12 @@
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-in-associated-type.rs:36:23
|
+LL | impl<'a, T> Trait<'a, T> for () {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Opaque = impl Sized + 'a;
| ^^^^^^^^^^^^^^^ ...so that the type `&'a T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Trait<'a, T> for () {
| ++++
@@ -12,10 +14,12 @@ LL | impl<'a, T: 'a> Trait<'a, T> for () {
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-in-associated-type.rs:36:23
|
+LL | impl<'a, T> Trait<'a, T> for () {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Opaque = impl Sized + 'a;
| ^^^^^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Trait<'a, T> for () {
| ++++
diff --git a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr
index 753a46e88..2858afcd4 100644
--- a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr
@@ -2,14 +2,17 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-nested.rs:55:27
|
LL | type InnerOpaque<T> = impl Sized;
- | ^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
+ | ^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/wf-nested.rs:12:20
|
LL | struct IsStatic<T: 'static>(T);
| ^^^^^^^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | type InnerOpaque<T: 'static> = impl Sized;
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr
index 9ab6685a7..285e4f18c 100644
--- a/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-nested.rs:46:17
|
LL | let _ = outer.get();
- | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ | ^^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the type `T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn test<T: 'static>() {
| +++++++++