about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMark Simulacrum <mark.simulacrum@gmail.com>2017-05-31 10:52:45 -0600
committerGitHub <noreply@github.com>2017-05-31 10:52:45 -0600
commitb851d1cdb47b5961a4b37b0645232a18e122663f (patch)
tree82d2b94279f3e0b9e33925389f06f53a33b7693c /src/test
parentd5a7fd585fd3f0e98c99db74cf5071efdbd1a59a (diff)
parentc2f7e945526bff3b7d812137d81b235263060ee8 (diff)
downloadrust-b851d1cdb47b5961a4b37b0645232a18e122663f.tar.gz
rust-b851d1cdb47b5961a4b37b0645232a18e122663f.zip
Rollup merge of #42196 - tommyip:explain_closure_err, r=nikomatsakis
Explain why a closure is `FnOnce` in closure errors.

Issue: #42065
@nikomatsakis Am I going the right direction with this?

~~I am stuck in a few bits:~~
~~1. How to trace the code to get the upvar instead of the original variable's span?~~
~~2. How to find the node id of the upvar where the move occured?~~
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/fn_once-moved.rs3
-rw-r--r--src/test/ui/fn_once-moved.stderr6
2 files changed, 7 insertions, 2 deletions
diff --git a/src/test/ui/fn_once-moved.rs b/src/test/ui/fn_once-moved.rs
index 781d3885eae..409964082f2 100644
--- a/src/test/ui/fn_once-moved.rs
+++ b/src/test/ui/fn_once-moved.rs
@@ -20,5 +20,6 @@ fn main() {
     debug_dump_dict();
     debug_dump_dict();
     //~^ ERROR use of moved value: `debug_dump_dict`
-    //~| NOTE closure was moved because it only implements `FnOnce`
+    //~| NOTE closure cannot be invoked more than once because it moves the
+    //~| variable `dict` out of its environment
 }
diff --git a/src/test/ui/fn_once-moved.stderr b/src/test/ui/fn_once-moved.stderr
index 91c89e55c54..27b7d91d1d4 100644
--- a/src/test/ui/fn_once-moved.stderr
+++ b/src/test/ui/fn_once-moved.stderr
@@ -6,7 +6,11 @@ error[E0382]: use of moved value: `debug_dump_dict`
 21 |     debug_dump_dict();
    |     ^^^^^^^^^^^^^^^ value used here after move
    |
-   = help: closure was moved because it only implements `FnOnce`
+note: closure cannot be invoked more than once because it moves the variable `dict` out of its environment
+  --> $DIR/fn_once-moved.rs:16:29
+   |
+16 |         for (key, value) in dict {
+   |                             ^^^^
 
 error: aborting due to previous error(s)