You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #117241 - compiler-errors:auto-trait-leak-cycle, r=oli-obk
Stash and cancel cycle errors for auto trait leakage in opaques
We don't need to emit a traditional cycle error when we have a selection error that explains what's going on but in more detail.
We may want to augment this error to actually point out the cycle, now that the cycle error is not being emitted. We could do that by storing the set of opaques that was in the `CyclePlaceholder` that gets returned from `type_of_opaque`.
r? `@oli-obk` cc `@estebank` #117235
note: ...which requires computing type of opaque `cycle2::{opaque#0}`...
45
-
--> $DIR/auto-trait-leak.rs:19:16
46
-
|
47
-
LL | fn cycle2() -> impl Clone {
48
-
| ^^^^^^^^^^
49
-
note: ...which requires type-checking `cycle2`...
50
-
--> $DIR/auto-trait-leak.rs:19:1
51
-
|
52
-
LL | fn cycle2() -> impl Clone {
53
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
54
-
= note: ...which again requires computing type of opaque `cycle1::{opaque#0}`, completing the cycle
55
-
note: cycle used when computing type of `cycle1::{opaque#0}`
56
-
--> $DIR/auto-trait-leak.rs:11:16
57
-
|
58
-
LL | fn cycle1() -> impl Clone {
59
-
| ^^^^^^^^^^
60
-
= 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
61
-
62
1
error: cannot check whether the hidden type of opaque type satisfies auto traits
63
-
--> $DIR/auto-trait-leak.rs:20:10
2
+
--> $DIR/auto-trait-leak.rs:18:10
64
3
|
65
4
LL | send(cycle1().clone());
66
5
| ---- ^^^^^^^^^^^^^^^^
@@ -73,7 +12,7 @@ note: opaque type is declared here
73
12
LL | fn cycle1() -> impl Clone {
74
13
| ^^^^^^^^^^
75
14
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
76
-
--> $DIR/auto-trait-leak.rs:19:4
15
+
--> $DIR/auto-trait-leak.rs:17:4
77
16
|
78
17
LL | fn cycle2() -> impl Clone {
79
18
| ^^^^^^
@@ -83,6 +22,5 @@ note: required by a bound in `send`
83
22
LL | fn send<T: Send>(_: T) {}
84
23
| ^^^^ required by this bound in `send`
85
24
86
-
error: aborting due to 3 previous errors
25
+
error: aborting due to previous error
87
26
88
-
For more information about this error, try `rustc --explain E0391`.
= note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
14
-
note: cycle used when computing type of `m::Foo::{opaque#0}`
15
-
--> $DIR/auto-trait-leakage3.rs:7:20
16
-
|
17
-
LL | pub type Foo = impl std::fmt::Debug;
18
-
| ^^^^^^^^^^^^^^^^^^^^
19
-
= 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
20
-
21
-
error[E0391]: cycle detected when computing type of opaque `m::Foo::{opaque#0}`
22
-
--> $DIR/auto-trait-leakage3.rs:7:20
23
-
|
24
-
LL | pub type Foo = impl std::fmt::Debug;
25
-
| ^^^^^^^^^^^^^^^^^^^^
26
-
|
27
-
note: ...which requires type-checking `m::bar`...
28
-
--> $DIR/auto-trait-leakage3.rs:15:5
29
-
|
30
-
LL | pub fn bar() {
31
-
| ^^^^^^^^^^^^
32
-
= note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
33
-
note: cycle used when computing type of `m::Foo::{opaque#0}`
34
-
--> $DIR/auto-trait-leakage3.rs:7:20
35
-
|
36
-
LL | pub type Foo = impl std::fmt::Debug;
37
-
| ^^^^^^^^^^^^^^^^^^^^
38
-
= 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
39
-
40
1
error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits
41
-
--> $DIR/auto-trait-leakage3.rs:16:17
2
+
--> $DIR/auto-trait-leakage3.rs:13:17
42
3
|
43
4
LL | is_send(foo());
44
5
| ------- ^^^^^
@@ -51,16 +12,15 @@ note: opaque type is declared here
51
12
LL | pub type Foo = impl std::fmt::Debug;
52
13
| ^^^^^^^^^^^^^^^^^^^^
53
14
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
54
-
--> $DIR/auto-trait-leakage3.rs:15:12
15
+
--> $DIR/auto-trait-leakage3.rs:12:12
55
16
|
56
17
LL | pub fn bar() {
57
18
| ^^^
58
19
note: required by a bound in `is_send`
59
-
--> $DIR/auto-trait-leakage3.rs:20:19
20
+
--> $DIR/auto-trait-leakage3.rs:17:19
60
21
|
61
22
LL | fn is_send<T: Send>(_: T) {}
62
23
| ^^^^ required by this bound in `is_send`
63
24
64
-
error: aborting due to 3 previous errors
25
+
error: aborting due to previous error
65
26
66
-
For more information about this error, try `rustc --explain E0391`.
= note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
14
-
note: cycle used when computing type of `m::Foo::{opaque#0}`
15
-
--> $DIR/inference-cycle.rs:5:20
16
-
|
17
-
LL | pub type Foo = impl std::fmt::Debug;
18
-
| ^^^^^^^^^^^^^^^^^^^^
19
-
= 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
20
-
21
-
error[E0391]: cycle detected when computing type of opaque `m::Foo::{opaque#0}`
22
-
--> $DIR/inference-cycle.rs:5:20
23
-
|
24
-
LL | pub type Foo = impl std::fmt::Debug;
25
-
| ^^^^^^^^^^^^^^^^^^^^
26
-
|
27
-
note: ...which requires type-checking `m::bar`...
28
-
--> $DIR/inference-cycle.rs:15:5
29
-
|
30
-
LL | pub fn bar() {
31
-
| ^^^^^^^^^^^^
32
-
= note: ...which again requires computing type of opaque `m::Foo::{opaque#0}`, completing the cycle
33
-
note: cycle used when computing type of `m::Foo::{opaque#0}`
34
-
--> $DIR/inference-cycle.rs:5:20
35
-
|
36
-
LL | pub type Foo = impl std::fmt::Debug;
37
-
| ^^^^^^^^^^^^^^^^^^^^
38
-
= 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
39
-
40
1
error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits
41
-
--> $DIR/inference-cycle.rs:16:17
2
+
--> $DIR/inference-cycle.rs:13:17
42
3
|
43
-
LL | is_send(foo()); // Today: error
4
+
LL | is_send(foo());
44
5
| ------- ^^^^^
45
6
| |
46
7
| required by a bound introduced by this call
@@ -51,16 +12,15 @@ note: opaque type is declared here
51
12
LL | pub type Foo = impl std::fmt::Debug;
52
13
| ^^^^^^^^^^^^^^^^^^^^
53
14
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
54
-
--> $DIR/inference-cycle.rs:15:12
15
+
--> $DIR/inference-cycle.rs:11:12
55
16
|
56
17
LL | pub fn bar() {
57
18
| ^^^
58
19
note: required by a bound in `is_send`
59
-
--> $DIR/inference-cycle.rs:24:19
20
+
--> $DIR/inference-cycle.rs:21:19
60
21
|
61
22
LL | fn is_send<T: Send>(_: T) {}
62
23
| ^^^^ required by this bound in `is_send`
63
24
64
-
error: aborting due to 3 previous errors
25
+
error: aborting due to previous error
65
26
66
-
For more information about this error, try `rustc --explain E0391`.
0 commit comments