Skip to content

Commit f3a1bae

Browse files
committed
add test for issue 114907
1 parent a725436 commit f3a1bae

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This is a non-regression test for issue #114907 where an ICE happened because of missing
2+
// `UniverseInfo`s accessed during diagnostics.
3+
//
4+
// A couple notes:
5+
// - the `FnOnce` bounds need an arg that is a reference
6+
// - a custom `Drop` is needed somewhere in the type that `accept` returns, to create universes
7+
// during liveness and dropck outlives computation
8+
9+
// check-fail
10+
11+
trait Role {
12+
type Inner;
13+
}
14+
15+
struct HandshakeCallback<C>(C);
16+
impl<C: FnOnce(&())> Role for HandshakeCallback<C> {
17+
type Inner = ();
18+
}
19+
20+
struct Handshake<R: Role> {
21+
_inner: Option<R::Inner>,
22+
}
23+
impl<R: Role> Drop for Handshake<R> {
24+
fn drop(&mut self) {}
25+
}
26+
27+
fn accept<C: FnOnce(&())>(_: C) -> Handshake<HandshakeCallback<C>> {
28+
todo!()
29+
}
30+
31+
fn main() {
32+
let callback = |_| {};
33+
accept(callback);
34+
//~^ ERROR mismatched types
35+
//~| ERROR mismatched types
36+
//~| ERROR implementation of `FnOnce` is not general enough
37+
//~| ERROR implementation of `FnOnce` is not general enough
38+
//~| ERROR higher-ranked subtype error
39+
//~| ERROR higher-ranked subtype error
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/missing-universe-cause-issue-114907.rs:33:5
3+
|
4+
LL | accept(callback);
5+
| ^^^^^^^^^^^^^^^^ one type is more general than the other
6+
|
7+
= note: expected trait `for<'a> FnOnce<(&'a (),)>`
8+
found trait `FnOnce<(&(),)>`
9+
note: this closure does not fulfill the lifetime requirements
10+
--> $DIR/missing-universe-cause-issue-114907.rs:32:20
11+
|
12+
LL | let callback = |_| {};
13+
| ^^^
14+
note: the lifetime requirement is introduced here
15+
--> $DIR/missing-universe-cause-issue-114907.rs:27:14
16+
|
17+
LL | fn accept<C: FnOnce(&())>(_: C) -> Handshake<HandshakeCallback<C>> {
18+
| ^^^^^^^^^^^
19+
help: consider specifying the type of the closure parameters
20+
|
21+
LL | let callback = |_: &_| {};
22+
| ~~~~~~~
23+
24+
error: implementation of `FnOnce` is not general enough
25+
--> $DIR/missing-universe-cause-issue-114907.rs:33:5
26+
|
27+
LL | accept(callback);
28+
| ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
29+
|
30+
= note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`...
31+
= note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2`
32+
33+
error: implementation of `FnOnce` is not general enough
34+
--> $DIR/missing-universe-cause-issue-114907.rs:33:5
35+
|
36+
LL | accept(callback);
37+
| ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
38+
|
39+
= note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`...
40+
= note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2`
41+
42+
error[E0308]: mismatched types
43+
--> $DIR/missing-universe-cause-issue-114907.rs:33:5
44+
|
45+
LL | accept(callback);
46+
| ^^^^^^^^^^^^^^^^ one type is more general than the other
47+
|
48+
= note: expected trait `for<'a> FnOnce<(&'a (),)>`
49+
found trait `FnOnce<(&(),)>`
50+
note: this closure does not fulfill the lifetime requirements
51+
--> $DIR/missing-universe-cause-issue-114907.rs:32:20
52+
|
53+
LL | let callback = |_| {};
54+
| ^^^
55+
note: the lifetime requirement is introduced here
56+
--> $DIR/missing-universe-cause-issue-114907.rs:20:21
57+
|
58+
LL | struct Handshake<R: Role> {
59+
| ^^^^
60+
help: consider specifying the type of the closure parameters
61+
|
62+
LL | let callback = |_: &_| {};
63+
| ~~~~~~~
64+
65+
error: higher-ranked subtype error
66+
--> $DIR/missing-universe-cause-issue-114907.rs:33:21
67+
|
68+
LL | accept(callback);
69+
| ^
70+
71+
error: higher-ranked subtype error
72+
--> $DIR/missing-universe-cause-issue-114907.rs:33:21
73+
|
74+
LL | accept(callback);
75+
| ^
76+
77+
error: aborting due to 6 previous errors
78+
79+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)