Skip to content

Commit a239c8d

Browse files
committed
Add test for issue-41366
1 parent 50ffa79 commit a239c8d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/test/ui/closures/issue-41366.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait T<'x> {
2+
type V;
3+
}
4+
5+
impl<'g> T<'g> for u32 {
6+
type V = u16;
7+
}
8+
9+
fn main() {
10+
(&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
11+
//~^ ERROR: type mismatch in closure arguments
12+
//~| ERROR: type mismatch resolving
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0631]: type mismatch in closure arguments
2+
--> $DIR/issue-41366.rs:10:5
3+
|
4+
LL | (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
5+
| ^^-----^
6+
| | |
7+
| | found signature of `fn(_) -> _`
8+
| expected signature of `for<'x> fn(<u32 as T<'x>>::V) -> _`
9+
|
10+
= note: required for the cast to the object type `dyn for<'x> std::ops::Fn(<u32 as T<'x>>::V)`
11+
12+
error[E0271]: type mismatch resolving `for<'x> <[closure@$DIR/issue-41366.rs:10:7: 10:12] as std::ops::FnOnce<(<u32 as T<'x>>::V,)>>::Output == ()`
13+
--> $DIR/issue-41366.rs:10:5
14+
|
15+
LL | (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
16+
| ^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
17+
|
18+
= note: required for the cast to the object type `dyn for<'x> std::ops::Fn(<u32 as T<'x>>::V)`
19+
20+
error: aborting due to 2 previous errors
21+
22+
For more information about this error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)