You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structQqq;fnconsume(_:Qqq){}fnmain(){let a = Qqq;consume(a);consume(a);}
<anon>:6:13: 6:14 error: use of moved value: `a` [E0382]
<anon>:6 consume(a);
^
<anon>:5:13: 5:14 note: `a` moved here because it has type `Qqq`, which is non-copyable
<anon>:5 consume(a);
It look more or less clear. But if we move and try to use on the same line:
structQqq;fnconsume(_:Qqq){}fnmain(){let a = Qqq;loop{consume(a);}}
the diagnostic looks less clear:
<anon>:6:17: 6:18 error: use of moved value: `a` [E0382]
<anon>:6 consume(a);
^
<anon>:6:17: 6:18 help: see the detailed explanation for E0382
note: `a` was previously moved here(where?) because it has type `Qqq`, which is non-copyable
Note the absence of filename and line number.
Maybe it should point to the same line <anon>:6 or there should dedicated message mentioning the loop...
The text was updated successfully, but these errors were encountered:
huonw
changed the title
Diagnostic when using moved value in loop{} may be metter
Diagnostic when using moved value in loop{} could be clearer
Feb 25, 2016
<anon>:6:17: 6:18 note: `a` was possibly moved here earlier because this expression may be evaluated multiple times
<anon>:6:17: 6:18 note: `a` was moved because it has type `Qqq`, which is non-copyable
Special-casing loops seems hard to do, but this might be enough to clarify what's going on.
Consider this error message:
It look more or less clear. But if we move and try to use on the same line:
the diagnostic looks less clear:
Note the absence of filename and line number.
Maybe it should point to the same line
<anon>:6
or there should dedicated message mentioning the loop...The text was updated successfully, but these errors were encountered: