Skip to content

Commit 285789f

Browse files
committed
---
yaml --- r: 106463 b: refs/heads/try c: 8784d2f h: refs/heads/master i: 106461: 340ebb4 106459: 79b8710 106455: 7a165d2 106447: 754b97c 106431: e86980e v: v3
1 parent 6ac808e commit 285789f

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
5-
refs/heads/try: c75dd78ccb07f395285acebeb8617a7fe6911f71
5+
refs/heads/try: 8784d2fa957ff7f6c9b317c53d1bc6a2b39b840a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/borrowck/gather_loans/gather_moves.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn check_is_legal_to_move_from(bccx: &BorrowckCtxt,
104104
mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
105105
mc::cat_deref(_, _, mc::GcPtr) |
106106
mc::cat_deref(_, _, mc::UnsafePtr(..)) |
107-
mc::cat_upvar(..) |
107+
mc::cat_upvar(..) | mc::cat_static_item |
108108
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {
109109
bccx.span_err(
110110
cmt0.span,
@@ -120,19 +120,6 @@ fn check_is_legal_to_move_from(bccx: &BorrowckCtxt,
120120
true
121121
}
122122

123-
// It seems strange to allow a move out of a static item,
124-
// but what happens in practice is that you have a
125-
// reference to a constant with a type that should be
126-
// moved, like `None::<~int>`. The type of this constant
127-
// is technically `Option<~int>`, which moves, but we know
128-
// that the content of static items will never actually
129-
// contain allocated pointers, so we can just memcpy it.
130-
// Since static items can never have allocated memory,
131-
// this is ok. For now anyhow.
132-
mc::cat_static_item => {
133-
true
134-
}
135-
136123
mc::cat_rvalue(..) |
137124
mc::cat_local(..) |
138125
mc::cat_arg(..) => {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 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+
// Ensure that moves out of static items is forbidden
12+
13+
use std::kinds::marker;
14+
15+
struct Foo {
16+
foo: int,
17+
nopod: marker::NoPod
18+
}
19+
20+
static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod};
21+
22+
23+
fn test(f: Foo) {
24+
let _f = Foo{foo: 4, ..f};
25+
}
26+
27+
fn main() {
28+
test(BAR); //~ ERROR cannot move out of static item
29+
}

branches/try/src/test/compile-fail/static-items-cant-move.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ fn test(f: Foo) {
2525
}
2626

2727
fn main() {
28-
test(BAR);
28+
test(BAR); //~ ERROR cannot move out of static item
2929
}

branches/try/src/test/compile-fail/std-uncopyable-atomics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use std::sync::atomics::*;
1616
use std::ptr;
1717

1818
fn main() {
19-
let x = INIT_ATOMIC_FLAG;
19+
let x = INIT_ATOMIC_FLAG; //~ ERROR cannot move out of static item
2020
let x = *&x; //~ ERROR: cannot move out of dereference
21-
let x = INIT_ATOMIC_BOOL;
21+
let x = INIT_ATOMIC_BOOL; //~ ERROR cannot move out of static item
2222
let x = *&x; //~ ERROR: cannot move out of dereference
23-
let x = INIT_ATOMIC_INT;
23+
let x = INIT_ATOMIC_INT; //~ ERROR cannot move out of static item
2424
let x = *&x; //~ ERROR: cannot move out of dereference
25-
let x = INIT_ATOMIC_UINT;
25+
let x = INIT_ATOMIC_UINT; //~ ERROR cannot move out of static item
2626
let x = *&x; //~ ERROR: cannot move out of dereference
2727
let x: AtomicPtr<uint> = AtomicPtr::new(ptr::mut_null());
2828
let x = *&x; //~ ERROR: cannot move out of dereference

branches/try/src/test/run-pass/issue-6919.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
extern crate issue6919_3;
1616

1717
pub fn main() {
18-
issue6919_3::D.k;
18+
let _ = issue6919_3::D.k;
1919
}
2020

0 commit comments

Comments
 (0)