From 4dcd6cc208e143309d481f0ecf4051bd9d139a18 Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Sun, 3 Feb 2019 22:08:34 +0900 Subject: [PATCH] Fix failing tests. --- .../library-features/boxed-closure-impls.md | 2 +- src/test/ui/unsized-locals/fnbox-compat.rs | 3 +- .../ui/unsized-locals/fnbox-compat.stderr | 30 +++++-------------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/doc/unstable-book/src/library-features/boxed-closure-impls.md b/src/doc/unstable-book/src/library-features/boxed-closure-impls.md index 0c738d0f78e..5ceb54ff3b9 100644 --- a/src/doc/unstable-book/src/library-features/boxed-closure-impls.md +++ b/src/doc/unstable-book/src/library-features/boxed-closure-impls.md @@ -37,7 +37,7 @@ fn main() { }); // Call it - f(); + f(&42); } ``` diff --git a/src/test/ui/unsized-locals/fnbox-compat.rs b/src/test/ui/unsized-locals/fnbox-compat.rs index 3cb9ac560a2..c2c385e9fea 100644 --- a/src/test/ui/unsized-locals/fnbox-compat.rs +++ b/src/test/ui/unsized-locals/fnbox-compat.rs @@ -4,9 +4,10 @@ use std::boxed::FnBox; fn call_it(f: Box T>) -> T { f(&42) + //~^ERROR implementation of `std::ops::FnOnce` is not general enough } fn main() { let s = "hello".to_owned(); - assert_eq!(&call_it(Box::new(|| s)) as &str, "hello"); + assert_eq!(&call_it(Box::new(|_| s)) as &str, "hello"); } diff --git a/src/test/ui/unsized-locals/fnbox-compat.stderr b/src/test/ui/unsized-locals/fnbox-compat.stderr index 5172092fb1c..c37bfaa47f7 100644 --- a/src/test/ui/unsized-locals/fnbox-compat.stderr +++ b/src/test/ui/unsized-locals/fnbox-compat.stderr @@ -1,27 +1,11 @@ -error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments - --> $DIR/fnbox-compat.rs:11:34 +error: implementation of `std::ops::FnOnce` is not general enough + --> $DIR/fnbox-compat.rs:6:5 | -LL | assert_eq!(&call_it(Box::new(|| s)) as &str, "hello"); - | ^^ - | | - | expected closure that takes 1 argument - | takes 0 arguments -help: consider changing the closure to take and ignore the expected argument +LL | f(&42) + | ^^^^^^ | -LL | assert_eq!(&call_it(Box::new(|_| s)) as &str, "hello"); - | ^^^ + = 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` + = 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` -error[E0277]: the size for values of type `dyn for<'r> std::boxed::FnBox<(&'r i32,), Output=_>` cannot be known at compilation time - --> $DIR/fnbox-compat.rs:11:25 - | -LL | assert_eq!(&call_it(Box::new(|| s)) as &str, "hello"); - | ^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::boxed::FnBox<(&'r i32,), Output=_>` - = note: to learn more, visit - = note: required by `>::new` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors occurred: E0277, E0593. -For more information about an error, try `rustc --explain E0277`.