Skip to content

Commit 900acc9

Browse files
committed
---
yaml --- r: 193883 b: refs/heads/beta c: 277b4f0 h: refs/heads/master i: 193881: 7187723 193879: d6b9a02 v: v3
1 parent 6edf223 commit 900acc9

File tree

4 files changed

+62
-22
lines changed

4 files changed

+62
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 5f5ed62298e5e366b931363b804631305178df5c
34+
refs/heads/beta: 277b4f035aa7e42330aabbc243a8fcb5cf4cc8bd
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6

branches/beta/src/librustc/middle/expr_use_visitor.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -857,36 +857,30 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
857857
n: uint) {
858858
debug!("walk_autoref expr={}", expr.repr(self.tcx()));
859859

860-
// Match for unique trait coercions first, since we don't need the
861-
// call to cat_expr_autoderefd.
862-
match *autoref {
863-
ty::AutoUnsizeUniq(ty::UnsizeVtable(..)) |
864-
ty::AutoUnsize(ty::UnsizeVtable(..)) => {
865-
assert!(n == 1, format!("Expected exactly 1 deref with Uniq \
866-
AutoRefs, found: {}", n));
867-
let cmt_unadjusted =
868-
return_if_err!(self.mc.cat_expr_unadjusted(expr));
869-
self.delegate_consume(expr.id, expr.span, cmt_unadjusted);
870-
return;
871-
}
872-
_ => {}
873-
}
874-
875-
let cmt_derefd = return_if_err!(
876-
self.mc.cat_expr_autoderefd(expr, n));
877-
debug!("walk_adjustment: cmt_derefd={}",
878-
cmt_derefd.repr(self.tcx()));
879-
880860
match *autoref {
881861
ty::AutoPtr(r, m, _) => {
862+
let cmt_derefd = return_if_err!(
863+
self.mc.cat_expr_autoderefd(expr, n));
864+
debug!("walk_adjustment: cmt_derefd={}",
865+
cmt_derefd.repr(self.tcx()));
866+
882867
self.delegate.borrow(expr.id,
883868
expr.span,
884869
cmt_derefd,
885870
r,
886871
ty::BorrowKind::from_mutbl(m),
887872
AutoRef);
888873
}
889-
ty::AutoUnsizeUniq(_) | ty::AutoUnsize(_) | ty::AutoUnsafe(..) => {}
874+
ty::AutoUnsize(_) |
875+
ty::AutoUnsizeUniq(_) => {
876+
assert!(n == 1, format!("Expected exactly 1 deref with Uniq \
877+
AutoRefs, found: {}", n));
878+
let cmt_unadjusted =
879+
return_if_err!(self.mc.cat_expr_unadjusted(expr));
880+
self.delegate_consume(expr.id, expr.span, cmt_unadjusted);
881+
}
882+
ty::AutoUnsafe(..) => {
883+
}
890884
}
891885
}
892886

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that we report an error if an upcast box is moved twice.
12+
13+
fn consume(_: Box<[i32]>) {
14+
}
15+
16+
fn foo(b: Box<[i32;5]>) {
17+
consume(b);
18+
consume(b); //~ ERROR use of moved value
19+
}
20+
21+
fn main() {
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that we report an error if an upcast box is moved twice.
12+
13+
trait Foo { fn dummy(&self); }
14+
15+
fn consume(_: Box<Foo>) {
16+
}
17+
18+
fn foo(b: Box<Foo+Send>) {
19+
consume(b);
20+
consume(b); //~ ERROR use of moved value
21+
}
22+
23+
fn main() {
24+
}

0 commit comments

Comments
 (0)