Skip to content

Commit 17e40db

Browse files
committed
Relocate issues/issue-51154.rs to closures/box-generic-closure.rs
1 parent 6840234 commit 17e40db

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Regression test for issue <https://github.com/rust-lang/rust/issues/51154>
2+
//! Test that anonymous closure types cannot be coerced to a generic type
3+
//! parameter (F: FnMut()) when trying to box them.
4+
5+
fn foo<F: FnMut()>() {
6+
let _: Box<F> = Box::new(|| ());
7+
//~^ ERROR mismatched types
8+
}
9+
10+
fn main() {}

tests/ui/issues/issue-51154.stderr renamed to tests/ui/closures/box-generic-closure.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-51154.rs:2:30
2+
--> $DIR/box-generic-closure.rs:6:30
33
|
44
LL | fn foo<F: FnMut()>() {
55
| - expected this type parameter
@@ -9,7 +9,7 @@ LL | let _: Box<F> = Box::new(|| ());
99
| arguments to this function are incorrect
1010
|
1111
= note: expected type parameter `F`
12-
found closure `{closure@$DIR/issue-51154.rs:2:30: 2:32}`
12+
found closure `{closure@$DIR/box-generic-closure.rs:6:30: 6:32}`
1313
= help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F`
1414
note: associated function defined here
1515
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL

tests/ui/issues/issue-51154.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)