Skip to content

Commit 58c08cd

Browse files
committed
Remove type flag based opaque type workaround
1 parent 84fc551 commit 58c08cd

File tree

9 files changed

+30
-181
lines changed

9 files changed

+30
-181
lines changed

compiler/rustc_type_ir/src/lib.rs

-8
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,6 @@ bitflags! {
204204
| TypeFlags::HAS_CT_INFER.bits
205205
| TypeFlags::HAS_TY_PLACEHOLDER.bits
206206
| TypeFlags::HAS_CT_PLACEHOLDER.bits
207-
// The `evaluate_obligation` query does not return further
208-
// obligations. If it evaluates an obligation with an opaque
209-
// type, that opaque type may get compared to another type,
210-
// constraining it. We would lose this information.
211-
// FIXME: differentiate between crate-local opaque types
212-
// and opaque types from other crates, as only opaque types
213-
// from the local crate can possibly be a local name
214-
| TypeFlags::HAS_TY_OPAQUE.bits
215207
// We consider 'freshened' types and constants
216208
// to depend on a particular fn.
217209
// The freshening process throws away information,

src/test/ui/impl-trait/auto-trait-leak.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ fn main() {
1111
// return type, which can't depend on the obligation.
1212
fn cycle1() -> impl Clone {
1313
//~^ ERROR cycle detected
14-
//~| ERROR cycle detected
1514
send(cycle2().clone());
1615

1716
Rc::new(Cell::new(5))

src/test/ui/impl-trait/auto-trait-leak.stderr

+15-97
Original file line numberDiff line numberDiff line change
@@ -30,129 +30,47 @@ note: ...which requires building MIR for `cycle1`...
3030
LL | fn cycle1() -> impl Clone {
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3232
note: ...which requires type-checking `cycle1`...
33-
--> $DIR/auto-trait-leak.rs:12:1
34-
|
35-
LL | fn cycle1() -> impl Clone {
36-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
37-
note: ...which requires computing type of `cycle2::{opaque#0}`...
38-
--> $DIR/auto-trait-leak.rs:20:16
39-
|
40-
LL | fn cycle2() -> impl Clone {
41-
| ^^^^^^^^^^
42-
note: ...which requires borrow-checking `cycle2`...
43-
--> $DIR/auto-trait-leak.rs:20:1
44-
|
45-
LL | fn cycle2() -> impl Clone {
46-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
47-
note: ...which requires processing `cycle2`...
48-
--> $DIR/auto-trait-leak.rs:20:1
49-
|
50-
LL | fn cycle2() -> impl Clone {
51-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
52-
note: ...which requires processing MIR for `cycle2`...
53-
--> $DIR/auto-trait-leak.rs:20:1
54-
|
55-
LL | fn cycle2() -> impl Clone {
56-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
57-
note: ...which requires unsafety-checking `cycle2`...
58-
--> $DIR/auto-trait-leak.rs:20:1
59-
|
60-
LL | fn cycle2() -> impl Clone {
61-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
62-
note: ...which requires building MIR for `cycle2`...
63-
--> $DIR/auto-trait-leak.rs:20:1
64-
|
65-
LL | fn cycle2() -> impl Clone {
66-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
67-
note: ...which requires type-checking `cycle2`...
68-
--> $DIR/auto-trait-leak.rs:20:1
69-
|
70-
LL | fn cycle2() -> impl Clone {
71-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
72-
= note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
73-
note: cycle used when checking item types in top-level module
74-
--> $DIR/auto-trait-leak.rs:1:1
75-
|
76-
LL | / use std::cell::Cell;
77-
LL | | use std::rc::Rc;
78-
LL | |
79-
LL | | fn send<T: Send>(_: T) {}
80-
... |
81-
LL | | Rc::new(String::from("foo"))
82-
LL | | }
83-
| |_^
84-
85-
error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}`
86-
--> $DIR/auto-trait-leak.rs:12:16
33+
--> $DIR/auto-trait-leak.rs:14:5
8734
|
88-
LL | fn cycle1() -> impl Clone {
89-
| ^^^^^^^^^^
90-
|
91-
note: ...which requires borrow-checking `cycle1`...
92-
--> $DIR/auto-trait-leak.rs:12:1
93-
|
94-
LL | fn cycle1() -> impl Clone {
95-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
96-
note: ...which requires processing `cycle1`...
97-
--> $DIR/auto-trait-leak.rs:12:1
98-
|
99-
LL | fn cycle1() -> impl Clone {
100-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
101-
note: ...which requires processing MIR for `cycle1`...
102-
--> $DIR/auto-trait-leak.rs:12:1
103-
|
104-
LL | fn cycle1() -> impl Clone {
105-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
106-
note: ...which requires unsafety-checking `cycle1`...
107-
--> $DIR/auto-trait-leak.rs:12:1
108-
|
109-
LL | fn cycle1() -> impl Clone {
110-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
111-
note: ...which requires building MIR for `cycle1`...
112-
--> $DIR/auto-trait-leak.rs:12:1
113-
|
114-
LL | fn cycle1() -> impl Clone {
115-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
116-
note: ...which requires type-checking `cycle1`...
117-
--> $DIR/auto-trait-leak.rs:12:1
118-
|
119-
LL | fn cycle1() -> impl Clone {
120-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
35+
LL | send(cycle2().clone());
36+
| ^^^^
37+
= note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`...
12138
note: ...which requires computing type of `cycle2::{opaque#0}`...
122-
--> $DIR/auto-trait-leak.rs:20:16
39+
--> $DIR/auto-trait-leak.rs:19:16
12340
|
12441
LL | fn cycle2() -> impl Clone {
12542
| ^^^^^^^^^^
12643
note: ...which requires borrow-checking `cycle2`...
127-
--> $DIR/auto-trait-leak.rs:20:1
44+
--> $DIR/auto-trait-leak.rs:19:1
12845
|
12946
LL | fn cycle2() -> impl Clone {
13047
| ^^^^^^^^^^^^^^^^^^^^^^^^^
13148
note: ...which requires processing `cycle2`...
132-
--> $DIR/auto-trait-leak.rs:20:1
49+
--> $DIR/auto-trait-leak.rs:19:1
13350
|
13451
LL | fn cycle2() -> impl Clone {
13552
| ^^^^^^^^^^^^^^^^^^^^^^^^^
13653
note: ...which requires processing MIR for `cycle2`...
137-
--> $DIR/auto-trait-leak.rs:20:1
54+
--> $DIR/auto-trait-leak.rs:19:1
13855
|
13956
LL | fn cycle2() -> impl Clone {
14057
| ^^^^^^^^^^^^^^^^^^^^^^^^^
14158
note: ...which requires unsafety-checking `cycle2`...
142-
--> $DIR/auto-trait-leak.rs:20:1
59+
--> $DIR/auto-trait-leak.rs:19:1
14360
|
14461
LL | fn cycle2() -> impl Clone {
14562
| ^^^^^^^^^^^^^^^^^^^^^^^^^
14663
note: ...which requires building MIR for `cycle2`...
147-
--> $DIR/auto-trait-leak.rs:20:1
64+
--> $DIR/auto-trait-leak.rs:19:1
14865
|
14966
LL | fn cycle2() -> impl Clone {
15067
| ^^^^^^^^^^^^^^^^^^^^^^^^^
15168
note: ...which requires type-checking `cycle2`...
152-
--> $DIR/auto-trait-leak.rs:20:1
69+
--> $DIR/auto-trait-leak.rs:20:5
15370
|
154-
LL | fn cycle2() -> impl Clone {
155-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
71+
LL | send(cycle1().clone());
72+
| ^^^^
73+
= note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`...
15674
= note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
15775
note: cycle used when checking item types in top-level module
15876
--> $DIR/auto-trait-leak.rs:1:1
@@ -166,6 +84,6 @@ LL | | Rc::new(String::from("foo"))
16684
LL | | }
16785
| |_^
16886

169-
error: aborting due to 2 previous errors
87+
error: aborting due to previous error
17088

17189
For more information about this error, try `rustc --explain E0391`.

src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
mod m {
77
type Foo = impl std::fmt::Debug;
88
//~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
9-
//~| ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
109

1110
pub fn foo() -> Foo {
1211
22_u32

src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr

+5-22
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,18 @@ LL | type Foo = impl std::fmt::Debug;
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
77
note: ...which requires type-checking `m::bar`...
8-
--> $DIR/auto-trait-leakage3.rs:15:5
8+
--> $DIR/auto-trait-leakage3.rs:15:9
99
|
10-
LL | pub fn bar() {
11-
| ^^^^^^^^^^^^
10+
LL | is_send(foo());
11+
| ^^^^^^^
12+
= note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
1213
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
1314
note: cycle used when checking item types in module `m`
1415
--> $DIR/auto-trait-leakage3.rs:6:1
1516
|
1617
LL | mod m {
1718
| ^^^^^
1819

19-
error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
20-
--> $DIR/auto-trait-leakage3.rs:7:16
21-
|
22-
LL | type Foo = impl std::fmt::Debug;
23-
| ^^^^^^^^^^^^^^^^^^^^
24-
|
25-
note: ...which requires type-checking `m::bar`...
26-
--> $DIR/auto-trait-leakage3.rs:15:5
27-
|
28-
LL | pub fn bar() {
29-
| ^^^^^^^^^^^^
30-
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
31-
note: cycle used when checking item types in module `m`
32-
--> $DIR/auto-trait-leakage3.rs:6:1
33-
|
34-
LL | mod m {
35-
| ^^^^^
36-
37-
error: aborting due to 2 previous errors
20+
error: aborting due to previous error
3821

3922
For more information about this error, try `rustc --explain E0391`.

src/test/ui/type-alias-impl-trait/inference-cycle.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
mod m {
55
type Foo = impl std::fmt::Debug;
66
//~^ ERROR cycle detected
7-
//~| ERROR cycle detected
87

98
// Cycle: error today, but it'd be nice if it eventually worked
109

src/test/ui/type-alias-impl-trait/inference-cycle.stderr

+5-22
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,18 @@ LL | type Foo = impl std::fmt::Debug;
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
77
note: ...which requires type-checking `m::bar`...
8-
--> $DIR/inference-cycle.rs:15:5
8+
--> $DIR/inference-cycle.rs:15:9
99
|
10-
LL | pub fn bar() {
11-
| ^^^^^^^^^^^^
10+
LL | is_send(foo()); // Today: error
11+
| ^^^^^^^
12+
= note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
1213
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
1314
note: cycle used when checking item types in module `m`
1415
--> $DIR/inference-cycle.rs:4:1
1516
|
1617
LL | mod m {
1718
| ^^^^^
1819

19-
error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
20-
--> $DIR/inference-cycle.rs:5:16
21-
|
22-
LL | type Foo = impl std::fmt::Debug;
23-
| ^^^^^^^^^^^^^^^^^^^^
24-
|
25-
note: ...which requires type-checking `m::bar`...
26-
--> $DIR/inference-cycle.rs:15:5
27-
|
28-
LL | pub fn bar() {
29-
| ^^^^^^^^^^^^
30-
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
31-
note: cycle used when checking item types in module `m`
32-
--> $DIR/inference-cycle.rs:4:1
33-
|
34-
LL | mod m {
35-
| ^^^^^
36-
37-
error: aborting due to 2 previous errors
20+
error: aborting due to previous error
3821

3922
For more information about this error, try `rustc --explain E0391`.

src/test/ui/type-alias-impl-trait/reveal_local.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::fmt::Debug;
44

55
type Foo = impl Debug;
66
//~^ ERROR cycle detected
7-
//~| ERROR cycle detected
87

98
fn is_send<T: Send>() { }
109

src/test/ui/type-alias-impl-trait/reveal_local.stderr

+5-28
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ LL | type Foo = impl Debug;
55
| ^^^^^^^^^^
66
|
77
note: ...which requires type-checking `not_good`...
8-
--> $DIR/reveal_local.rs:11:1
8+
--> $DIR/reveal_local.rs:13:5
99
|
10-
LL | fn not_good() {
11-
| ^^^^^^^^^^^^^
10+
LL | is_send::<Foo>();
11+
| ^^^^^^^^^^^^^^
12+
= note: ...which requires evaluating trait selection obligation `Foo: core::marker::Send`...
1213
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
1314
note: cycle used when checking item types in top-level module
1415
--> $DIR/reveal_local.rs:1:1
@@ -22,30 +23,6 @@ LL | |
2223
LL | | fn main() {}
2324
| |____________^
2425

25-
error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
26-
--> $DIR/reveal_local.rs:5:12
27-
|
28-
LL | type Foo = impl Debug;
29-
| ^^^^^^^^^^
30-
|
31-
note: ...which requires type-checking `not_gooder`...
32-
--> $DIR/reveal_local.rs:17:1
33-
|
34-
LL | fn not_gooder() {
35-
| ^^^^^^^^^^^^^^^
36-
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
37-
note: cycle used when checking item types in top-level module
38-
--> $DIR/reveal_local.rs:1:1
39-
|
40-
LL | / #![feature(type_alias_impl_trait)]
41-
LL | |
42-
LL | | use std::fmt::Debug;
43-
LL | |
44-
... |
45-
LL | |
46-
LL | | fn main() {}
47-
| |____________^
48-
49-
error: aborting due to 2 previous errors
26+
error: aborting due to previous error
5027

5128
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)