Skip to content

Commit 4dcd6cc

Browse files
qnighycrlf0710
authored andcommitted
Fix failing tests.
1 parent e55d82c commit 4dcd6cc

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

src/doc/unstable-book/src/library-features/boxed-closure-impls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
});
3838

3939
// Call it
40-
f();
40+
f(&42);
4141
}
4242
```
4343

src/test/ui/unsized-locals/fnbox-compat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use std::boxed::FnBox;
44

55
fn call_it<T>(f: Box<dyn FnBox(&i32) -> T>) -> T {
66
f(&42)
7+
//~^ERROR implementation of `std::ops::FnOnce` is not general enough
78
}
89

910
fn main() {
1011
let s = "hello".to_owned();
11-
assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
12+
assert_eq!(&call_it(Box::new(|_| s)) as &str, "hello");
1213
}
Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
2-
--> $DIR/fnbox-compat.rs:11:34
1+
error: implementation of `std::ops::FnOnce` is not general enough
2+
--> $DIR/fnbox-compat.rs:6:5
33
|
4-
LL | assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
5-
| ^^
6-
| |
7-
| expected closure that takes 1 argument
8-
| takes 0 arguments
9-
help: consider changing the closure to take and ignore the expected argument
4+
LL | f(&42)
5+
| ^^^^^^
106
|
11-
LL | assert_eq!(&call_it(Box::new(|_| s)) as &str, "hello");
12-
| ^^^
7+
= note: `std::ops::FnOnce<(&'0 i32,)>` would have to be implemented for the type `std::boxed::Box<(dyn for<'r> std::boxed::FnBox<(&'r i32,), Output=T> + 'static)>`, for some specific lifetime `'0`
8+
= note: but `std::ops::FnOnce<(&'1 i32,)>` is actually implemented for the type `std::boxed::Box<(dyn std::boxed::FnBox<(&'1 i32,), Output=T> + '_)>`, for some specific lifetime `'1`
139

14-
error[E0277]: the size for values of type `dyn for<'r> std::boxed::FnBox<(&'r i32,), Output=_>` cannot be known at compilation time
15-
--> $DIR/fnbox-compat.rs:11:25
16-
|
17-
LL | assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
18-
| ^^^^^^^^ doesn't have a size known at compile-time
19-
|
20-
= help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::boxed::FnBox<(&'r i32,), Output=_>`
21-
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
22-
= note: required by `<std::boxed::Box<T>>::new`
23-
24-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
2511

26-
Some errors occurred: E0277, E0593.
27-
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)