File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 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 ( ) { }
Original file line number Diff line number Diff line change 11error[E0308]: mismatched types
2- --> $DIR/issue-51154 .rs:2 :30
2+ --> $DIR/box-generic-closure .rs:6 :30
33 |
44LL | 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`
1414note: associated function defined here
1515 --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments