diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-06-21 17:41:40 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-06-21 17:43:10 -0700 |
| commit | cc323d8637c36a8762bebaedad98cc916f4fcc1f (patch) | |
| tree | a12611ada6623aeebd84d9f78777ccd900c69ede /src | |
| parent | a06398214a6e2e9a431309e198e00e0f2dfe397d (diff) | |
Make liveness print out a proper error message for moves out of a self field
This was a call to span_bug() before. I'm not sure about the other cases, but the test case shows that the `vk_self` case can certainly arise with a bad program, so it should be a span_err() thing and not a span_bug() thing. Closes #2590
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustc/middle/liveness.rs | 9 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-2590.rs | 13 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index cc8b0383e36..9ad4009c513 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -1669,7 +1669,14 @@ impl check_methods for @liveness { #fmt["illegal move from field `%s`", *name]); ret; } - vk_local(*) | vk_self | vk_implicit_ret { + vk_self { + self.tcx.sess.span_err( + move_span, + "illegal move from self (cannot move out of a field of \ + self)"); + ret; + } + vk_local(*) | vk_implicit_ret { self.tcx.sess.span_bug( move_span, #fmt["illegal reader (%?) for `%?`", diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs new file mode 100644 index 00000000000..c27fee9f8a8 --- /dev/null +++ b/src/test/compile-fail/issue-2590.rs @@ -0,0 +1,13 @@ +import dvec::dvec; + +type parser = { + tokens: dvec<int>, +}; + +impl parser for parser { + fn parse() -> [mut int] { + dvec::unwrap(self.tokens) //! ERROR illegal move from self + } +} + +fn main() {} |
