Skip to content

Commit eee7acd

Browse files
committed
---
yaml --- r: 106052 b: refs/heads/auto c: 695114e h: refs/heads/master v: v3
1 parent f5339a9 commit eee7acd

File tree

14 files changed

+98
-40
lines changed

14 files changed

+98
-40
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 0a181a89175f0531cf5b0e120721125d6a9b3e3e
16+
refs/heads/auto: 695114ea2c1ae147dcf1c3ac690a75ecf928b8b2
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,6 @@ impl<'a> CheckLoanCtxt<'a> {
522522
None => {
523523
return true;
524524
}
525-
Some(mc::AliasableStaticMut) => {
526-
return true;
527-
}
528525
Some(cause) => {
529526
this.bccx.report_aliasability_violation(
530527
expr.span,

branches/auto/src/librustc/middle/check_const.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
156156
}
157157
}
158158
}
159-
ExprVstore(_, ExprVstoreMutSlice) |
160159
ExprVstore(_, ExprVstoreSlice) |
161160
ExprVec(_, MutImmutable) |
162161
ExprAddrOf(MutImmutable, _) |

branches/auto/src/librustc/middle/check_static.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ impl<'a> Visitor<bool> for CheckStaticVisitor<'a> {
107107
ast::ExprVstore(_, ast::ExprVstoreSlice) => {
108108
visit::walk_expr(self, e, is_const);
109109
}
110-
ast::ExprVstore(_, ast::ExprVstoreMutSlice) => {
111-
self.tcx.sess.span_err(e.span,
112-
"static items are not allowed to have mutable slices");
113-
},
114110
ast::ExprUnary(ast::UnBox, _) => {
115111
self.tcx.sess.span_err(e.span,
116112
"static items are not allowed to have managed pointers");

branches/auto/src/librustc/middle/trans/consts.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111

1212
use back::abi;
13-
use lib::llvm::{llvm, ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, Bool, True,
14-
False};
13+
use lib::llvm::{llvm, ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, Bool, True};
1514
use lib::llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, IntSLE,
1615
RealOEQ, RealOGT, RealOGE, RealOLT, RealOLE, RealONE};
1716

@@ -575,8 +574,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
575574
is_local);
576575
(v, inlineable)
577576
}
578-
ast::ExprVstore(sub, store @ ast::ExprVstoreSlice) |
579-
ast::ExprVstore(sub, store @ ast::ExprVstoreMutSlice) => {
577+
ast::ExprVstore(sub, ast::ExprVstoreSlice) => {
580578
match sub.node {
581579
ast::ExprLit(ref lit) => {
582580
match lit.node {
@@ -594,8 +592,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
594592
llvm::LLVMAddGlobal(cx.llmod, llty.to_ref(), name)
595593
});
596594
llvm::LLVMSetInitializer(gv, cv);
597-
llvm::LLVMSetGlobalConstant(gv,
598-
if store == ast::ExprVstoreMutSlice { False } else { True });
595+
llvm::LLVMSetGlobalConstant(gv, True);
599596
SetLinkage(gv, PrivateLinkage);
600597
let p = const_ptrcast(cx, gv, llunitty);
601598
(C_struct(cx, [p, C_uint(cx, es.len())], false), false)

branches/auto/src/libstd/str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,9 @@ pub mod raw {
13761376

13771377
#[lang="strdup_uniq"]
13781378
#[cfg(not(test))]
1379+
#[allow(missing_doc)]
13791380
#[inline]
1380-
unsafe fn strdup_uniq(ptr: *u8, len: uint) -> ~str {
1381+
pub unsafe fn strdup_uniq(ptr: *u8, len: uint) -> ~str {
13811382
from_buf_len(ptr, len)
13821383
}
13831384

branches/auto/src/libstd/sync/atomics.rs

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ use std::kinds::marker;
2727
use option::{Option,Some,None};
2828
use ops::Drop;
2929

30+
/**
31+
* A simple atomic flag, that can be set and cleared. The most basic atomic type.
32+
*/
33+
pub struct AtomicFlag {
34+
priv v: int,
35+
priv nopod: marker::NoPod
36+
}
37+
3038
/**
3139
* An atomic boolean type.
3240
*/
@@ -84,11 +92,36 @@ pub enum Ordering {
8492
SeqCst
8593
}
8694

95+
pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v: 0, nopod: marker::NoPod };
8796
pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: 0, nopod: marker::NoPod };
8897
pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v: 0, nopod: marker::NoPod };
8998
pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: 0, nopod: marker::NoPod };
9099
pub static INIT_ATOMIC_U64 : AtomicU64 = AtomicU64 { v: 0, nopod: marker::NoPod };
91100

101+
impl AtomicFlag {
102+
103+
pub fn new() -> AtomicFlag {
104+
AtomicFlag { v: 0, nopod: marker::NoPod}
105+
}
106+
107+
/**
108+
* Clears the atomic flag
109+
*/
110+
#[inline]
111+
pub fn clear(&mut self, order: Ordering) {
112+
unsafe {atomic_store(&mut self.v, 0, order)}
113+
}
114+
115+
/**
116+
* Sets the flag if it was previously unset, returns the previous value of the
117+
* flag.
118+
*/
119+
#[inline]
120+
pub fn test_and_set(&mut self, order: Ordering) -> bool {
121+
unsafe { atomic_compare_and_swap(&mut self.v, 0, 1, order) > 0 }
122+
}
123+
}
124+
92125
impl AtomicBool {
93126
pub fn new(v: bool) -> AtomicBool {
94127
AtomicBool { v: if v { 1 } else { 0 }, nopod: marker::NoPod }
@@ -506,13 +539,13 @@ mod test {
506539
use super::*;
507540

508541
#[test]
509-
fn bool_() {
510-
let mut a = AtomicBool::new(false);
511-
assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
512-
assert_eq!(a.compare_and_swap(false, true, SeqCst), true);
542+
fn flag() {
543+
let mut flg = AtomicFlag::new();
544+
assert!(!flg.test_and_set(SeqCst));
545+
assert!(flg.test_and_set(SeqCst));
513546

514-
a.store(false, SeqCst);
515-
assert_eq!(a.compare_and_swap(false, true, SeqCst), false);
547+
flg.clear(SeqCst);
548+
assert!(!flg.test_and_set(SeqCst));
516549
}
517550

518551
#[test]
@@ -562,13 +595,15 @@ mod test {
562595
assert_eq!(a.load(SeqCst),false);
563596
}
564597

598+
static mut S_FLAG : AtomicFlag = INIT_ATOMIC_FLAG;
565599
static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
566600
static mut S_INT : AtomicInt = INIT_ATOMIC_INT;
567601
static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
568602

569603
#[test]
570604
fn static_init() {
571605
unsafe {
606+
assert!(!S_FLAG.test_and_set(SeqCst));
572607
assert!(!S_BOOL.load(SeqCst));
573608
assert!(S_INT.load(SeqCst) == 0);
574609
assert!(S_UINT.load(SeqCst) == 0);

branches/auto/src/libsyntax/ext/mtwt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn resolve_internal(id: Ident,
198198
resolvedthis
199199
}
200200
}
201-
IllegalCtxt() => fail!("expected resolvable context, got IllegalCtxt")
201+
IllegalCtxt => fail!("expected resolvable context, got IllegalCtxt")
202202
}
203203
};
204204
resolve_table.insert(key, resolved);

branches/auto/src/libsyntax/parse/parser.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,23 @@ impl<'a> Parser<'a> {
713713
result
714714
}
715715

716+
// parse a sequence parameter of enum variant. For consistency purposes,
717+
// these should not be empty.
718+
pub fn parse_enum_variant_seq<T>(
719+
&mut self,
720+
bra: &token::Token,
721+
ket: &token::Token,
722+
sep: SeqSep,
723+
f: |&mut Parser| -> T)
724+
-> Vec<T> {
725+
let result = self.parse_unspanned_seq(bra, ket, sep, f);
726+
if result.is_empty() {
727+
self.span_err(self.last_span,
728+
"nullary enum variants are written with no trailing `( )`");
729+
}
730+
result
731+
}
732+
716733
// NB: Do not use this function unless you actually plan to place the
717734
// spanned list in the AST.
718735
pub fn parse_seq<T>(
@@ -3013,7 +3030,7 @@ impl<'a> Parser<'a> {
30133030
self.expect(&token::RPAREN);
30143031
pat = PatEnum(enum_path, None);
30153032
} else {
3016-
args = self.parse_unspanned_seq(
3033+
args = self.parse_enum_variant_seq(
30173034
&token::LPAREN,
30183035
&token::RPAREN,
30193036
seq_sep_trailing_disallowed(token::COMMA),
@@ -4431,7 +4448,7 @@ impl<'a> Parser<'a> {
44314448
kind = StructVariantKind(self.parse_struct_def());
44324449
} else if self.token == token::LPAREN {
44334450
all_nullary = false;
4434-
let arg_tys = self.parse_unspanned_seq(
4451+
let arg_tys = self.parse_enum_variant_seq(
44354452
&token::LPAREN,
44364453
&token::RPAREN,
44374454
seq_sep_trailing_disallowed(token::COMMA),

branches/auto/src/test/compile-fail/enums-pats-not-idents.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -12,5 +12,5 @@
1212

1313
fn main() {
1414
// a bug in the parser is allowing this:
15-
let a() = 13;
15+
let a(1) = 13;
1616
}

branches/auto/src/test/run-pass/check-static-mut-slices.rs renamed to branches/auto/src/test/compile-fail/issue-12560-1.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Checks that mutable static items can have mutable slices
11+
// For style and consistency reasons, non-parametrized enum variants must
12+
// be used simply as `ident` instead of `ident ()`.
13+
// This test-case covers enum declaration.
1214

13-
static mut TEST: &'static mut [int] = &mut [1];
15+
enum Foo {
16+
Bar(), //~ ERROR nullary enum variants are written with no trailing `( )`
17+
Baz(), //~ ERROR nullary enum variants are written with no trailing `( )`
18+
Bazar
19+
}
1420

15-
pub fn main() {
16-
unsafe {
17-
TEST[0] += 1;
18-
assert_eq!(TEST[0], 2);
19-
}
21+
fn main() {
22+
println!("{}", match Bar { Bar => 1, Baz => 2, Bazar => 3 })
2023
}

branches/auto/src/test/compile-fail/check-static-immutable-mut-slices.rs renamed to branches/auto/src/test/compile-fail/issue-12560-2.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Checks that immutable static items can't have mutable slices
11+
// For style and consistency reasons, non-parametrized enum variants must
12+
// be used simply as `ident` instead of `ident ()`.
13+
// This test-case covers enum matching.
1214

13-
static TEST: &'static mut [int] = &mut [];
14-
//~^ ERROR static items are not allowed to have mutable slices
15+
enum Foo {
16+
Bar,
17+
Baz,
18+
Bazar
19+
}
1520

16-
pub fn main() { }
21+
fn main() {
22+
println!("{}", match Bar {
23+
Bar() => 1, //~ ERROR nullary enum variants are written with no trailing `( )`
24+
Baz() => 2, //~ ERROR nullary enum variants are written with no trailing `( )`
25+
Bazar => 3
26+
})
27+
}

branches/auto/src/test/compile-fail/issue-5927.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -14,7 +14,7 @@
1414

1515
fn main() {
1616
let z = match 3 {
17-
x() => x
17+
x(1) => x(1)
1818
};
1919
assert_eq!(z,3);
2020
}

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

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

1818
fn main() {
19+
let x = INIT_ATOMIC_FLAG; //~ ERROR cannot move out of static item
20+
let x = *&x; //~ ERROR: cannot move out of dereference
1921
let x = INIT_ATOMIC_BOOL; //~ ERROR cannot move out of static item
2022
let x = *&x; //~ ERROR: cannot move out of dereference
2123
let x = INIT_ATOMIC_INT; //~ ERROR cannot move out of static item

0 commit comments

Comments
 (0)