Skip to content

Commit 21c52ae

Browse files
committed
add RPITIT tests: method compat auto trait leakage
1 parent 958e149 commit 21c52ae

5 files changed

+224
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::{anon_assoc#0}`
2+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
3+
|
4+
LL | fn foo() -> impl Sized {
5+
| ^^^^^^^^^^
6+
|
7+
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
8+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
9+
|
10+
LL | fn foo() -> impl Sized {
11+
| ^^^^^^^^^^
12+
= note: ...which requires evaluating trait selection obligation `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo::{opaque#0}: core::marker::Send`...
13+
note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo::{opaque#0}`...
14+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
15+
|
16+
LL | fn foo() -> impl Sized {
17+
| ^^^^^^^^^^
18+
note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
19+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
20+
|
21+
LL | fn foo() -> impl Sized {
22+
| ^^^^^^^^^^^^^^^^^^^^^^
23+
note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
24+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
25+
|
26+
LL | fn foo() -> impl Sized {
27+
| ^^^^^^^^^^^^^^^^^^^^^^
28+
note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo` contains FFI-unwind calls...
29+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
30+
|
31+
LL | fn foo() -> impl Sized {
32+
| ^^^^^^^^^^^^^^^^^^^^^^
33+
note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
34+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
35+
|
36+
LL | fn foo() -> impl Sized {
37+
| ^^^^^^^^^^^^^^^^^^^^^^
38+
note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
39+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
40+
|
41+
LL | fn foo() -> impl Sized {
42+
| ^^^^^^^^^^^^^^^^^^^^^^
43+
note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
44+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
45+
|
46+
LL | fn foo() -> impl Sized {
47+
| ^^^^^^^^^^^^^^^^^^^^^^
48+
= note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::{anon_assoc#0}`, completing the cycle
49+
note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>` is well-formed
50+
--> $DIR/method-compatability-via-leakage-cycle.rs:13:1
51+
|
52+
LL | impl Trait for u32 {
53+
| ^^^^^^^^^^^^^^^^^^
54+
= 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
55+
56+
error: aborting due to 1 previous error
57+
58+
For more information about this error, try `rustc --explain E0391`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::{anon_assoc#0}`
2+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
3+
|
4+
LL | fn foo() -> impl Sized {
5+
| ^^^^^^^^^^
6+
|
7+
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
8+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
9+
|
10+
LL | fn foo() -> impl Sized {
11+
| ^^^^^^^^^^^^^^^^^^^^^^
12+
note: ...which requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo::{opaque#0}`...
13+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
14+
|
15+
LL | fn foo() -> impl Sized {
16+
| ^^^^^^^^^^
17+
note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo::{opaque#0}`...
18+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
19+
|
20+
LL | fn foo() -> impl Sized {
21+
| ^^^^^^^^^^
22+
note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
23+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
24+
|
25+
LL | fn foo() -> impl Sized {
26+
| ^^^^^^^^^^^^^^^^^^^^^^
27+
note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
28+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
29+
|
30+
LL | fn foo() -> impl Sized {
31+
| ^^^^^^^^^^^^^^^^^^^^^^
32+
note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo` contains FFI-unwind calls...
33+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
34+
|
35+
LL | fn foo() -> impl Sized {
36+
| ^^^^^^^^^^^^^^^^^^^^^^
37+
note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
38+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
39+
|
40+
LL | fn foo() -> impl Sized {
41+
| ^^^^^^^^^^^^^^^^^^^^^^
42+
note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
43+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
44+
|
45+
LL | fn foo() -> impl Sized {
46+
| ^^^^^^^^^^^^^^^^^^^^^^
47+
note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
48+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
49+
|
50+
LL | fn foo() -> impl Sized {
51+
| ^^^^^^^^^^^^^^^^^^^^^^
52+
= note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::{anon_assoc#0}`, completing the cycle
53+
note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>` is well-formed
54+
--> $DIR/method-compatability-via-leakage-cycle.rs:13:1
55+
|
56+
LL | impl Trait for u32 {
57+
| ^^^^^^^^^^^^^^^^^^
58+
= 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
59+
60+
error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::{anon_assoc#0}`
61+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
62+
|
63+
LL | fn foo() -> impl Sized {
64+
| ^^^^^^^^^^
65+
|
66+
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
67+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
68+
|
69+
LL | fn foo() -> impl Sized {
70+
| ^^^^^^^^^^^^^^^^^^^^^^
71+
note: ...which requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo::{opaque#0}`...
72+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
73+
|
74+
LL | fn foo() -> impl Sized {
75+
| ^^^^^^^^^^
76+
note: ...which requires computing type of opaque `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo::{opaque#0}`...
77+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:17
78+
|
79+
LL | fn foo() -> impl Sized {
80+
| ^^^^^^^^^^
81+
note: ...which requires borrow-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
82+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
83+
|
84+
LL | fn foo() -> impl Sized {
85+
| ^^^^^^^^^^^^^^^^^^^^^^
86+
note: ...which requires promoting constants in MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
87+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
88+
|
89+
LL | fn foo() -> impl Sized {
90+
| ^^^^^^^^^^^^^^^^^^^^^^
91+
note: ...which requires checking if `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo` contains FFI-unwind calls...
92+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
93+
|
94+
LL | fn foo() -> impl Sized {
95+
| ^^^^^^^^^^^^^^^^^^^^^^
96+
note: ...which requires building MIR for `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
97+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
98+
|
99+
LL | fn foo() -> impl Sized {
100+
| ^^^^^^^^^^^^^^^^^^^^^^
101+
note: ...which requires match-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
102+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
103+
|
104+
LL | fn foo() -> impl Sized {
105+
| ^^^^^^^^^^^^^^^^^^^^^^
106+
note: ...which requires type-checking `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::foo`...
107+
--> $DIR/method-compatability-via-leakage-cycle.rs:14:5
108+
|
109+
LL | fn foo() -> impl Sized {
110+
| ^^^^^^^^^^^^^^^^^^^^^^
111+
= note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>::{anon_assoc#0}`, completing the cycle
112+
note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:13:1: 13:19>` is well-formed
113+
--> $DIR/method-compatability-via-leakage-cycle.rs:13:1
114+
|
115+
LL | impl Trait for u32 {
116+
| ^^^^^^^^^^^^^^^^^^
117+
= 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
118+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
119+
120+
error: aborting due to 2 previous errors
121+
122+
For more information about this error, try `rustc --explain E0391`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ revisions: current next
2+
//@[next] compile-flags: -Znext-solver
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
4+
5+
// Recursively using the trait method inside of an impl in case checking
6+
// method compatability relies on opaque type leakage currently causes a
7+
// cycle error.
8+
9+
trait Trait {
10+
fn foo() -> impl Sized + Send;
11+
}
12+
13+
impl Trait for u32 {
14+
fn foo() -> impl Sized {
15+
//~^ ERROR cycle detected
16+
//[next]~| ERROR cycle detected
17+
u32::foo()
18+
}
19+
}
20+
21+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ check-pass
2+
//@ revisions: current next
3+
//@[next] compile-flags: -Znext-solver
4+
//@ ignore-compare-mode-next-solver (explicit revisions)
5+
6+
trait Trait {
7+
fn foo() -> impl Sized + Send;
8+
}
9+
10+
impl Trait for u32 {
11+
fn foo() -> impl Sized {}
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0601]: `main` function not found in crate `method_compatability_via_leakage`
2+
--> $DIR/method-compatability-via-leakage.rs:7:2
3+
|
4+
LL | }
5+
| ^ consider adding a `main` function to `$DIR/method-compatability-via-leakage.rs`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0601`.

0 commit comments

Comments
 (0)