Skip to content

Commit 4544b4d

Browse files
Rollup merge of #62777 - gilescope:self-referencial-to-recursion, r=eddyb
Self-referencial type now called a recursive type As per Boat's suggestion - #62539, this makes the error message clearer.
2 parents ed83734 + c56c5a8 commit 4544b4d

File tree

5 files changed

+36
-18
lines changed

5 files changed

+36
-18
lines changed

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ fn check_opaque<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>,
13211321
tcx.sess, span, E0720,
13221322
"opaque type expands to a recursive type",
13231323
);
1324-
err.span_label(span, "expands to self-referential type");
1324+
err.span_label(span, "expands to a recursive type");
13251325
if let ty::Opaque(..) = partially_expanded_type.sty {
13261326
err.note("type resolves to itself");
13271327
} else {

src/test/ui/async-await/recursive-async-impl-trait-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0720]: opaque type expands to a recursive type
22
--> $DIR/recursive-async-impl-trait-type.rs:7:40
33
|
44
LL | async fn recursive_async_function() -> () {
5-
| ^^ expands to self-referential type
5+
| ^^ expands to a recursive type
66
|
77
= note: expanded type is `std::future::GenFuture<[static generator@$DIR/recursive-async-impl-trait-type.rs:7:43: 9:2 {impl std::future::Future, ()}]>`
88

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Output = String caused an ICE whereas Output = &'static str compiled successfully.
2+
// Broken MIR: generator contains type std::string::String in MIR,
3+
// but typeck only knows about {<S as T>::Future, ()}
4+
// check-pass
5+
// edition:2018
6+
7+
#![feature(async_await)]
8+
use std::future::Future;
9+
10+
pub trait T {
11+
type Future: Future<Output = String>;
12+
fn bar() -> Self::Future;
13+
}
14+
pub async fn foo<S>() where S: T {
15+
S::bar().await;
16+
S::bar().await;
17+
}
18+
pub fn main() {}

src/test/ui/impl-trait/issues/infinite-impl-trait-issue-38064.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ error[E0720]: opaque type expands to a recursive type
22
--> $DIR/infinite-impl-trait-issue-38064.rs:8:13
33
|
44
LL | fn foo() -> impl Quux {
5-
| ^^^^^^^^^ expands to self-referential type
5+
| ^^^^^^^^^ expands to a recursive type
66
|
77
= note: expanded type is `foo::Foo<bar::Bar<impl Quux>>`
88

99
error[E0720]: opaque type expands to a recursive type
1010
--> $DIR/infinite-impl-trait-issue-38064.rs:14:13
1111
|
1212
LL | fn bar() -> impl Quux {
13-
| ^^^^^^^^^ expands to self-referential type
13+
| ^^^^^^^^^ expands to a recursive type
1414
|
1515
= note: expanded type is `bar::Bar<foo::Foo<impl Quux>>`
1616

src/test/ui/impl-trait/recursive-impl-trait-type.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,111 @@ error[E0720]: opaque type expands to a recursive type
22
--> $DIR/recursive-impl-trait-type.rs:6:22
33
|
44
LL | fn option(i: i32) -> impl Sized {
5-
| ^^^^^^^^^^ expands to self-referential type
5+
| ^^^^^^^^^^ expands to a recursive type
66
|
77
= note: expanded type is `std::option::Option<(impl Sized, i32)>`
88

99
error[E0720]: opaque type expands to a recursive type
1010
--> $DIR/recursive-impl-trait-type.rs:14:15
1111
|
1212
LL | fn tuple() -> impl Sized {
13-
| ^^^^^^^^^^ expands to self-referential type
13+
| ^^^^^^^^^^ expands to a recursive type
1414
|
1515
= note: expanded type is `(impl Sized,)`
1616

1717
error[E0720]: opaque type expands to a recursive type
1818
--> $DIR/recursive-impl-trait-type.rs:18:15
1919
|
2020
LL | fn array() -> impl Sized {
21-
| ^^^^^^^^^^ expands to self-referential type
21+
| ^^^^^^^^^^ expands to a recursive type
2222
|
2323
= note: expanded type is `[impl Sized; 1]`
2424

2525
error[E0720]: opaque type expands to a recursive type
2626
--> $DIR/recursive-impl-trait-type.rs:22:13
2727
|
2828
LL | fn ptr() -> impl Sized {
29-
| ^^^^^^^^^^ expands to self-referential type
29+
| ^^^^^^^^^^ expands to a recursive type
3030
|
3131
= note: expanded type is `*const impl Sized`
3232

3333
error[E0720]: opaque type expands to a recursive type
3434
--> $DIR/recursive-impl-trait-type.rs:26:16
3535
|
3636
LL | fn fn_ptr() -> impl Sized {
37-
| ^^^^^^^^^^ expands to self-referential type
37+
| ^^^^^^^^^^ expands to a recursive type
3838
|
3939
= note: expanded type is `fn() -> impl Sized`
4040

4141
error[E0720]: opaque type expands to a recursive type
4242
--> $DIR/recursive-impl-trait-type.rs:30:25
4343
|
4444
LL | fn closure_capture() -> impl Sized {
45-
| ^^^^^^^^^^ expands to self-referential type
45+
| ^^^^^^^^^^ expands to a recursive type
4646
|
4747
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:32:5: 32:19 x:impl Sized]`
4848

4949
error[E0720]: opaque type expands to a recursive type
5050
--> $DIR/recursive-impl-trait-type.rs:35:29
5151
|
5252
LL | fn closure_ref_capture() -> impl Sized {
53-
| ^^^^^^^^^^ expands to self-referential type
53+
| ^^^^^^^^^^ expands to a recursive type
5454
|
5555
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:37:5: 37:20 x:impl Sized]`
5656

5757
error[E0720]: opaque type expands to a recursive type
5858
--> $DIR/recursive-impl-trait-type.rs:40:21
5959
|
6060
LL | fn closure_sig() -> impl Sized {
61-
| ^^^^^^^^^^ expands to self-referential type
61+
| ^^^^^^^^^^ expands to a recursive type
6262
|
6363
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:41:5: 41:21]`
6464

6565
error[E0720]: opaque type expands to a recursive type
6666
--> $DIR/recursive-impl-trait-type.rs:44:23
6767
|
6868
LL | fn generator_sig() -> impl Sized {
69-
| ^^^^^^^^^^ expands to self-referential type
69+
| ^^^^^^^^^^ expands to a recursive type
7070
|
7171
= note: expanded type is `[closure@$DIR/recursive-impl-trait-type.rs:45:5: 45:23]`
7272

7373
error[E0720]: opaque type expands to a recursive type
7474
--> $DIR/recursive-impl-trait-type.rs:48:27
7575
|
7676
LL | fn generator_capture() -> impl Sized {
77-
| ^^^^^^^^^^ expands to self-referential type
77+
| ^^^^^^^^^^ expands to a recursive type
7878
|
7979
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type.rs:50:5: 50:26 x:impl Sized {()}]`
8080

8181
error[E0720]: opaque type expands to a recursive type
8282
--> $DIR/recursive-impl-trait-type.rs:53:26
8383
|
8484
LL | fn substs_change<T>() -> impl Sized {
85-
| ^^^^^^^^^^ expands to self-referential type
85+
| ^^^^^^^^^^ expands to a recursive type
8686
|
8787
= note: expanded type is `(impl Sized,)`
8888

8989
error[E0720]: opaque type expands to a recursive type
9090
--> $DIR/recursive-impl-trait-type.rs:57:24
9191
|
9292
LL | fn generator_hold() -> impl Sized {
93-
| ^^^^^^^^^^ expands to self-referential type
93+
| ^^^^^^^^^^ expands to a recursive type
9494
|
9595
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type.rs:58:5: 62:6 {impl Sized, ()}]`
9696

9797
error[E0720]: opaque type expands to a recursive type
9898
--> $DIR/recursive-impl-trait-type.rs:69:26
9999
|
100100
LL | fn mutual_recursion() -> impl Sync {
101-
| ^^^^^^^^^ expands to self-referential type
101+
| ^^^^^^^^^ expands to a recursive type
102102
|
103103
= note: type resolves to itself
104104

105105
error[E0720]: opaque type expands to a recursive type
106106
--> $DIR/recursive-impl-trait-type.rs:73:28
107107
|
108108
LL | fn mutual_recursion_b() -> impl Sized {
109-
| ^^^^^^^^^^ expands to self-referential type
109+
| ^^^^^^^^^^ expands to a recursive type
110110
|
111111
= note: type resolves to itself
112112

0 commit comments

Comments
 (0)