about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2017-12-18 23:08:33 +0100
committerGitHub <noreply@github.com>2017-12-18 23:08:33 +0100
commit6cc58b3fe8d7311b8802f1d9d4c772b5b84ebcd8 (patch)
treea9565281b5936a72872e6db138941452a72c5420 /src/test
parentc0a547a51eff9aeaa2d5ed7e01264b7ec67857cb (diff)
parent0555d256dd395ff65aa4435d26de36806edb2729 (diff)
downloadrust-6cc58b3fe8d7311b8802f1d9d4c772b5b84ebcd8.tar.gz
rust-6cc58b3fe8d7311b8802f1d9d4c772b5b84ebcd8.zip
Rollup merge of #46800 - estebank:expected-closure-def-span, r=arielb1
Rework expected closure error

* point at def span
* add label to primary span
* use `span_label`s instead of `span_note`s
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/closure_context/issue-26046-fn-mut.stderr19
-rw-r--r--src/test/ui/closure_context/issue-26046-fn-once.stderr19
-rw-r--r--src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr11
3 files changed, 16 insertions, 33 deletions
diff --git a/src/test/ui/closure_context/issue-26046-fn-mut.stderr b/src/test/ui/closure_context/issue-26046-fn-mut.stderr
index 82c83da4dae..77ce1176b5c 100644
--- a/src/test/ui/closure_context/issue-26046-fn-mut.stderr
+++ b/src/test/ui/closure_context/issue-26046-fn-mut.stderr
@@ -1,20 +1,13 @@
 error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut`
   --> $DIR/issue-26046-fn-mut.rs:14:19
    |
-14 |       let closure = || { //~ ERROR expected a closure that
-   |  ___________________^
-15 | |         num += 1;
-16 | |     };
-   | |_____^
-17 | 
-18 |       Box::new(closure)
-   |       ----------------- the requirement to implement `Fn` derives from here
-   |
-note: closure is `FnMut` because it mutates the variable `num` here
-  --> $DIR/issue-26046-fn-mut.rs:15:9
-   |
+14 |     let closure = || { //~ ERROR expected a closure that
+   |                   ^^ this closure implements `FnMut`, not `Fn`
 15 |         num += 1;
-   |         ^^^
+   |         --- closure is `FnMut` because it mutates the variable `num` here
+...
+18 |     Box::new(closure)
+   |     ----------------- the requirement to implement `Fn` derives from here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/closure_context/issue-26046-fn-once.stderr b/src/test/ui/closure_context/issue-26046-fn-once.stderr
index 0bc84872dde..4eed4461eba 100644
--- a/src/test/ui/closure_context/issue-26046-fn-once.stderr
+++ b/src/test/ui/closure_context/issue-26046-fn-once.stderr
@@ -1,20 +1,13 @@
 error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
   --> $DIR/issue-26046-fn-once.rs:14:19
    |
-14 |       let closure = move || { //~ ERROR expected a closure
-   |  ___________________^
-15 | |         vec
-16 | |     };
-   | |_____^
-17 | 
-18 |       Box::new(closure)
-   |       ----------------- the requirement to implement `Fn` derives from here
-   |
-note: closure is `FnOnce` because it moves the variable `vec` out of its environment
-  --> $DIR/issue-26046-fn-once.rs:15:9
-   |
+14 |     let closure = move || { //~ ERROR expected a closure
+   |                   ^^^^^^^ this closure implements `FnOnce`, not `Fn`
 15 |         vec
-   |         ^^^
+   |         --- closure is `FnOnce` because it moves the variable `vec` out of its environment
+...
+18 |     Box::new(closure)
+   |     ----------------- the requirement to implement `Fn` derives from here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr b/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr
index d3d9ce2b34a..2c16c5b619a 100644
--- a/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr
+++ b/src/test/ui/unboxed-closures-infer-fn-once-move-from-projection.stderr
@@ -2,15 +2,12 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closur
   --> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:24:13
    |
 24 |     let c = || drop(y.0); //~ ERROR expected a closure that implements the `Fn` trait
-   |             ^^^^^^^^^^^^
+   |             ^^^^^^^^-^^^
+   |             |       |
+   |             |       closure is `FnOnce` because it moves the variable `y` out of its environment
+   |             this closure implements `FnOnce`, not `Fn`
 25 |     foo(c);
    |     --- the requirement to implement `Fn` derives from here
-   |
-note: closure is `FnOnce` because it moves the variable `y` out of its environment
-  --> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:24:21
-   |
-24 |     let c = || drop(y.0); //~ ERROR expected a closure that implements the `Fn` trait
-   |                     ^
 
 error: aborting due to previous error