Expand "recursive opaque type" diagnostic
Fix #70968, partially address #66523.
This commit is contained in:
parent
ff4a2533a0
commit
96f5584b80
13 changed files with 374 additions and 115 deletions
9
src/test/ui/impl-trait/binding-without-value.rs
Normal file
9
src/test/ui/impl-trait/binding-without-value.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![allow(incomplete_features)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
|
||||
fn foo() {
|
||||
let _ : impl Copy;
|
||||
//~^ ERROR cannot resolve opaque type
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
16
src/test/ui/impl-trait/binding-without-value.stderr
Normal file
16
src/test/ui/impl-trait/binding-without-value.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/binding-without-value.rs:5:13
|
||||
|
|
||||
LL | let _ : impl Copy;
|
||||
| - ^^^^^^^^^ cannot resolve to a concrete type
|
||||
| |
|
||||
| this binding might not have a concrete type
|
||||
|
|
||||
help: set the binding to a value for a concrete type to be resolved
|
||||
|
|
||||
LL | let _ : impl Copy = /* value */;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0720`.
|
||||
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
trait Quux {}
|
||||
|
||||
fn foo() -> impl Quux { //~ opaque type expands to a recursive type
|
||||
fn foo() -> impl Quux { //~ ERROR cannot resolve opaque type
|
||||
struct Foo<T>(T);
|
||||
impl<T> Quux for Foo<T> {}
|
||||
Foo(bar())
|
||||
}
|
||||
|
||||
fn bar() -> impl Quux { //~ opaque type expands to a recursive type
|
||||
fn bar() -> impl Quux { //~ ERROR cannot resolve opaque type
|
||||
struct Bar<T>(T);
|
||||
impl<T> Quux for Bar<T> {}
|
||||
Bar(foo())
|
||||
|
|
|
|||
|
|
@ -1,18 +1,26 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/infinite-impl-trait-issue-38064.rs:8:13
|
||||
|
|
||||
LL | fn foo() -> impl Quux {
|
||||
| ^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `foo::Foo<bar::Bar<impl Quux>>`
|
||||
| ^^^^^^^^^ recursive opaque type
|
||||
...
|
||||
LL | Foo(bar())
|
||||
| ---------- returning here with type `foo::Foo<impl Quux>`
|
||||
...
|
||||
LL | fn bar() -> impl Quux {
|
||||
| --------- returning this opaque type `foo::Foo<impl Quux>`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/infinite-impl-trait-issue-38064.rs:14:13
|
||||
|
|
||||
LL | fn foo() -> impl Quux {
|
||||
| --------- returning this opaque type `bar::Bar<impl Quux>`
|
||||
...
|
||||
LL | fn bar() -> impl Quux {
|
||||
| ^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `bar::Bar<foo::Foo<impl Quux>>`
|
||||
| ^^^^^^^^^ recursive opaque type
|
||||
...
|
||||
LL | Bar(foo())
|
||||
| ---------- returning here with type `bar::Bar<impl Quux>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-direct.rs:5:14
|
||||
|
|
||||
LL | fn test() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | test()
|
||||
| ------ returning here with type `impl Sized`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,114 +1,147 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:7:22
|
||||
|
|
||||
LL | fn option(i: i32) -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `std::option::Option<(impl Sized, i32)>`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | if i < 0 { None } else { Some((option(i - 1), i)) }
|
||||
| ---- ------------------------ returning here with type `std::option::Option<(impl Sized, i32)>`
|
||||
| |
|
||||
| returning here with type `std::option::Option<(impl Sized, i32)>`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:12:15
|
||||
|
|
||||
LL | fn tuple() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `(impl Sized,)`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | (tuple(),)
|
||||
| ---------- returning here with type `(impl Sized,)`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:17:15
|
||||
|
|
||||
LL | fn array() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[impl Sized; 1]`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | [array()]
|
||||
| --------- returning here with type `[impl Sized; 1]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:22:13
|
||||
|
|
||||
LL | fn ptr() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `*const impl Sized`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | &ptr() as *const _
|
||||
| ------------------ returning here with type `*const impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:27:16
|
||||
|
|
||||
LL | fn fn_ptr() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `fn() -> impl Sized`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | fn_ptr as fn() -> _
|
||||
| ------------------- returning here with type `fn() -> impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:32:25
|
||||
|
|
||||
LL | fn closure_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 37:6 x:impl Sized]`
|
||||
LL | fn closure_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
...
|
||||
LL | / move || {
|
||||
LL | | x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 37:6 x:impl Sized]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:40:29
|
||||
|
|
||||
LL | fn closure_ref_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 45:6 x:impl Sized]`
|
||||
LL | fn closure_ref_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
...
|
||||
LL | / move || {
|
||||
LL | | &x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 45:6 x:impl Sized]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:48:21
|
||||
|
|
||||
LL | fn closure_sig() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:21]`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | || closure_sig()
|
||||
| ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:21]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:53:23
|
||||
|
|
||||
LL | fn generator_sig() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:23]`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | || generator_sig()
|
||||
| ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:23]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:58:27
|
||||
|
|
||||
LL | fn generator_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6 x:impl Sized {()}]`
|
||||
LL | fn generator_capture() -> impl Sized {
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
...
|
||||
LL | / move || {
|
||||
LL | | yield;
|
||||
LL | | x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6 x:impl Sized {()}]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:67:35
|
||||
|
|
||||
LL | fn substs_change<T: 'static>() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `(impl Sized,)`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | (substs_change::<&T>(),)
|
||||
| ------------------------ returning here with type `(impl Sized,)`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:72:24
|
||||
|
|
||||
LL | fn generator_hold() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6 {impl Sized, ()}]`
|
||||
LL | fn generator_hold() -> impl Sized {
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | / move || {
|
||||
LL | | let x = generator_hold();
|
||||
LL | | yield;
|
||||
LL | | x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6 {impl Sized, ()}]`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:86:26
|
||||
|
|
||||
LL | fn mutual_recursion() -> impl Sync {
|
||||
| ^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
| ^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | mutual_recursion_b()
|
||||
| -------------------- returning here with type `impl Sized`
|
||||
...
|
||||
LL | fn mutual_recursion_b() -> impl Sized {
|
||||
| ---------- returning this opaque type `impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:91:28
|
||||
|
|
||||
LL | fn mutual_recursion() -> impl Sync {
|
||||
| --------- returning this opaque type `impl std::marker::Sync`
|
||||
...
|
||||
LL | fn mutual_recursion_b() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL |
|
||||
LL | mutual_recursion()
|
||||
| ------------------ returning here with type `impl std::marker::Sync`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@
|
|||
|
||||
fn id<T>(t: T) -> impl Sized { t }
|
||||
|
||||
fn recursive_id() -> impl Sized { //~ ERROR opaque type expands to a recursive type
|
||||
fn recursive_id() -> impl Sized { //~ ERROR cannot resolve opaque type
|
||||
id(recursive_id2())
|
||||
}
|
||||
|
||||
fn recursive_id2() -> impl Sized { //~ ERROR opaque type expands to a recursive type
|
||||
fn recursive_id2() -> impl Sized { //~ ERROR cannot resolve opaque type
|
||||
id(recursive_id())
|
||||
}
|
||||
|
||||
fn wrap<T>(t: T) -> impl Sized { (t,) }
|
||||
|
||||
fn recursive_wrap() -> impl Sized { //~ ERROR opaque type expands to a recursive type
|
||||
fn recursive_wrap() -> impl Sized { //~ ERROR cannot resolve opaque type
|
||||
wrap(recursive_wrap2())
|
||||
}
|
||||
|
||||
fn recursive_wrap2() -> impl Sized { //~ ERROR opaque type expands to a recursive type
|
||||
fn recursive_wrap2() -> impl Sized { //~ ERROR cannot resolve opaque type
|
||||
wrap(recursive_wrap())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +1,46 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:7:22
|
||||
|
|
||||
LL | fn id<T>(t: T) -> impl Sized { t }
|
||||
| ---------- returning this opaque type `impl Sized`
|
||||
LL |
|
||||
LL | fn recursive_id() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL | id(recursive_id2())
|
||||
| ------------------- returning here with type `impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:11:23
|
||||
|
|
||||
LL | fn id<T>(t: T) -> impl Sized { t }
|
||||
| ---------- returning this opaque type `impl Sized`
|
||||
...
|
||||
LL | fn recursive_id2() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL | id(recursive_id())
|
||||
| ------------------ returning here with type `impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:17:24
|
||||
|
|
||||
LL | fn wrap<T>(t: T) -> impl Sized { (t,) }
|
||||
| ---------- returning this opaque type `impl Sized`
|
||||
LL |
|
||||
LL | fn recursive_wrap() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `((impl Sized,),)`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL | wrap(recursive_wrap2())
|
||||
| ----------------------- returning here with type `impl Sized`
|
||||
|
||||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:21:25
|
||||
|
|
||||
LL | fn wrap<T>(t: T) -> impl Sized { (t,) }
|
||||
| ---------- returning this opaque type `impl Sized`
|
||||
...
|
||||
LL | fn recursive_wrap2() -> impl Sized {
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
|
|
||||
= note: expanded type is `((impl Sized,),)`
|
||||
| ^^^^^^^^^^ recursive opaque type
|
||||
LL | wrap(recursive_wrap())
|
||||
| ---------------------- returning here with type `impl Sized`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
use std::fmt::Debug;
|
||||
|
||||
// Disallowed
|
||||
fn in_adt_in_return() -> Vec<impl Debug> { panic!() }
|
||||
//~^ ERROR opaque type expands to a recursive type
|
||||
fn in_adt_in_return() -> Vec<impl Debug> { panic!() } //~ ERROR cannot resolve opaque type
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
error[E0720]: opaque type expands to a recursive type
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
--> $DIR/where-allowed-2.rs:6:30
|
||||
|
|
||||
LL | fn in_adt_in_return() -> Vec<impl Debug> { panic!() }
|
||||
| ^^^^^^^^^^ expands to a recursive type
|
||||
| ^^^^^^^^^^ -------- this returned value is of `!` type
|
||||
| |
|
||||
| cannot resolve to a concrete type
|
||||
|
|
||||
= note: type resolves to itself
|
||||
= help: this error will resolve once the item's body returns a concrete type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue