Skip to content

Commit cc323d8

Browse files
committed
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
1 parent a063982 commit cc323d8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/rustc/middle/liveness.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,14 @@ impl check_methods for @liveness {
16691669
#fmt["illegal move from field `%s`", *name]);
16701670
ret;
16711671
}
1672-
vk_local(*) | vk_self | vk_implicit_ret {
1672+
vk_self {
1673+
self.tcx.sess.span_err(
1674+
move_span,
1675+
"illegal move from self (cannot move out of a field of \
1676+
self)");
1677+
ret;
1678+
}
1679+
vk_local(*) | vk_implicit_ret {
16731680
self.tcx.sess.span_bug(
16741681
move_span,
16751682
#fmt["illegal reader (%?) for `%?`",

src/test/compile-fail/issue-2590.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import dvec::dvec;
2+
3+
type parser = {
4+
tokens: dvec<int>,
5+
};
6+
7+
impl parser for parser {
8+
fn parse() -> [mut int] {
9+
dvec::unwrap(self.tokens) //! ERROR illegal move from self
10+
}
11+
}
12+
13+
fn main() {}

0 commit comments

Comments
 (0)