Skip to content

Commit 89947c0

Browse files
committed
---
yaml --- r: 93947 b: refs/heads/try c: d662820 h: refs/heads/master i: 93945: c2b4da6 93943: ff608ab v: v3
1 parent bcd33dd commit 89947c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+907
-361
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: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: a9bd049fc09445a20ab8a9283a24f1074403d061
5+
refs/heads/try: d662820b297f0ecda17126577571fcf886bdac81
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/rust.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,8 @@ names are effectively reserved. Some significant attributes include:
17541754
* The `deriving` attribute, for automatically generating
17551755
implementations of certain traits.
17561756
* The `static_assert` attribute, for asserting that a static bool is true at compiletime
1757+
* The `thread_local` attribute, for defining a `static mut` as a thread-local. Note that this is
1758+
only a low-level building block, and is not local to a *task*, nor does it provide safety.
17571759

17581760
Other attributes may be added or removed during development of the language.
17591761

branches/try/src/libextra/c_vec.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
*/
3838

3939
use std::ptr;
40-
use std::routine::Runnable;
4140
use std::util;
4241

4342
/**
@@ -50,7 +49,7 @@ pub struct CVec<T> {
5049
}
5150

5251
struct DtorRes {
53-
dtor: Option<~Runnable>,
52+
dtor: Option<proc()>,
5453
}
5554

5655
#[unsafe_destructor]
@@ -59,13 +58,13 @@ impl Drop for DtorRes {
5958
let dtor = util::replace(&mut self.dtor, None);
6059
match dtor {
6160
None => (),
62-
Some(f) => f.run()
61+
Some(f) => f()
6362
}
6463
}
6564
}
6665

6766
impl DtorRes {
68-
fn new(dtor: Option<~Runnable>) -> DtorRes {
67+
fn new(dtor: Option<proc()>) -> DtorRes {
6968
DtorRes {
7069
dtor: dtor,
7170
}
@@ -103,7 +102,7 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
103102
* * dtor - A function to run when the value is destructed, useful
104103
* for freeing the buffer, etc.
105104
*/
106-
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: ~Runnable)
105+
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: proc())
107106
-> CVec<T> {
108107
return CVec{
109108
base: base,
@@ -155,19 +154,6 @@ mod tests {
155154

156155
use std::libc::*;
157156
use std::libc;
158-
use std::routine::Runnable;
159-
160-
struct LibcFree {
161-
mem: *c_void,
162-
}
163-
164-
impl Runnable for LibcFree {
165-
fn run(~self) {
166-
unsafe {
167-
libc::free(self.mem)
168-
}
169-
}
170-
}
171157

172158
fn malloc(n: size_t) -> CVec<u8> {
173159
unsafe {
@@ -177,9 +163,7 @@ mod tests {
177163

178164
return c_vec_with_dtor(mem as *mut u8,
179165
n as uint,
180-
~LibcFree {
181-
mem: mem,
182-
} as ~Runnable);
166+
proc() unsafe { libc::free(mem); });
183167
}
184168
}
185169

branches/try/src/librustc/driver/session.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use syntax::abi;
2828
use syntax::parse::token;
2929
use syntax;
3030

31-
use std::int;
3231
use std::hashmap::{HashMap,HashSet};
3332

3433
#[deriving(Clone)]
@@ -209,7 +208,7 @@ pub struct Session_ {
209208
building_library: @mut bool,
210209
working_dir: Path,
211210
lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::Span, ~str)]>,
212-
node_id: @mut uint,
211+
node_id: @mut ast::NodeId,
213212
}
214213

215214
pub type Session = @Session_;
@@ -274,13 +273,15 @@ impl Session_ {
274273
pub fn next_node_id(&self) -> ast::NodeId {
275274
self.reserve_node_ids(1)
276275
}
277-
pub fn reserve_node_ids(&self, count: uint) -> ast::NodeId {
276+
pub fn reserve_node_ids(&self, count: ast::NodeId) -> ast::NodeId {
278277
let v = *self.node_id;
279-
*self.node_id += count;
280-
if v > (int::max_value as uint) {
281-
self.bug("Input too large, ran out of node ids!");
278+
279+
match v.checked_add(&count) {
280+
Some(next) => { *self.node_id = next; }
281+
None => self.bug("Input too large, ran out of node ids!")
282282
}
283-
v as int
283+
284+
v
284285
}
285286
pub fn diagnostic(&self) -> @mut diagnostic::span_handler {
286287
self.span_diagnostic

branches/try/src/librustc/front/config.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ pub fn strip_items(crate: ast::Crate,
4848
ctxt.fold_crate(crate)
4949
}
5050

51-
fn filter_item(cx: &Context, item: @ast::item) -> Option<@ast::item> {
52-
if item_in_cfg(cx, item) {
53-
Some(item)
54-
} else {
55-
None
56-
}
57-
}
58-
5951
fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item)
6052
-> Option<&'r ast::view_item> {
6153
if view_item_in_cfg(cx, view_item) {
@@ -66,9 +58,10 @@ fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item)
6658
}
6759

6860
fn fold_mod(cx: &Context, m: &ast::_mod) -> ast::_mod {
69-
let filtered_items = m.items.iter().filter_map(|a| {
70-
filter_item(cx, *a).and_then(|x| cx.fold_item(x))
71-
}).collect();
61+
let filtered_items = m.items.iter()
62+
.filter(|&a| item_in_cfg(cx, *a))
63+
.flat_map(|&x| cx.fold_item(x).move_iter())
64+
.collect();
7265
let filtered_view_items = m.view_items.iter().filter_map(|a| {
7366
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
7467
}).collect();
@@ -122,28 +115,25 @@ fn fold_item_underscore(cx: &Context, item: &ast::item_) -> ast::item_ {
122115
fold::noop_fold_item_underscore(&item, cx)
123116
}
124117

125-
fn filter_stmt(cx: &Context, stmt: @ast::Stmt) -> Option<@ast::Stmt> {
118+
fn retain_stmt(cx: &Context, stmt: @ast::Stmt) -> bool {
126119
match stmt.node {
127120
ast::StmtDecl(decl, _) => {
128121
match decl.node {
129122
ast::DeclItem(item) => {
130-
if item_in_cfg(cx, item) {
131-
Some(stmt)
132-
} else {
133-
None
134-
}
123+
item_in_cfg(cx, item)
135124
}
136-
_ => Some(stmt)
125+
_ => true
137126
}
138127
}
139-
_ => Some(stmt),
128+
_ => true
140129
}
141130
}
142131

143132
fn fold_block(cx: &Context, b: &ast::Block) -> ast::Block {
144-
let resulting_stmts = b.stmts.iter().filter_map(|a| {
145-
filter_stmt(cx, *a).and_then(|stmt| cx.fold_stmt(stmt))
146-
}).collect();
133+
let resulting_stmts = b.stmts.iter()
134+
.filter(|&a| retain_stmt(cx, *a))
135+
.flat_map(|&stmt| cx.fold_stmt(stmt).move_iter())
136+
.collect();
147137
let filtered_view_items = b.view_items.iter().filter_map(|a| {
148138
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
149139
}).collect();

branches/try/src/librustc/front/feature_gate.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
4040
("asm", Active),
4141
("managed_boxes", Active),
4242
("non_ascii_idents", Active),
43+
("thread_local", Active),
4344

4445
// These are used to test this portion of the compiler, they don't actually
4546
// mean anything
@@ -109,6 +110,17 @@ impl Visitor<()> for Context {
109110
}
110111

111112
fn visit_item(&mut self, i: @ast::item, _:()) {
113+
// NOTE: uncomment after snapshot
114+
/*
115+
for attr in i.attrs.iter() {
116+
if "thread_local" == attr.name() {
117+
self.gate_feature("thread_local", i.span,
118+
"`#[thread_local]` is an experimental feature, and does not \
119+
currently handle destructors. There is no corresponding \
120+
`#[task_local]` mapping to the task model");
121+
}
122+
}
123+
*/
112124
match i.node {
113125
ast::item_enum(ref def, _) => {
114126
for variant in def.variants.iter() {
@@ -154,8 +166,8 @@ impl Visitor<()> for Context {
154166
},
155167
ast::ty_box(_) => {
156168
self.gate_feature("managed_boxes", t.span,
157-
"The managed box syntax is being replaced by the `std::gc::Gc`
158-
and `std::rc::Rc` types. Equivalent functionality to managed
169+
"The managed box syntax is being replaced by the `std::gc::Gc` \
170+
and `std::rc::Rc` types. Equivalent functionality to managed \
159171
trait objects will be implemented but is currently missing.");
160172
}
161173
_ => {}

branches/try/src/librustc/front/std_inject.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use syntax::codemap;
1919
use syntax::fold::ast_fold;
2020
use syntax::fold;
2121
use syntax::opt_vec;
22+
use syntax::util::small_vector::SmallVector;
2223

2324
static STD_VERSION: &'static str = "0.9-pre";
2425

@@ -98,14 +99,14 @@ impl fold::ast_fold for StandardLibraryInjector {
9899
}
99100
}
100101

101-
fn fold_item(&self, item: @ast::item) -> Option<@ast::item> {
102+
fn fold_item(&self, item: @ast::item) -> SmallVector<@ast::item> {
102103
if !no_prelude(item.attrs) {
103104
// only recur if there wasn't `#[no_implicit_prelude];`
104105
// on this item, i.e. this means that the prelude is not
105106
// implicitly imported though the whole subtree
106107
fold::noop_fold_item(item, self)
107108
} else {
108-
Some(item)
109+
SmallVector::one(item)
109110
}
110111
}
111112

branches/try/src/librustc/front/test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use syntax::fold;
2626
use syntax::opt_vec;
2727
use syntax::print::pprust;
2828
use syntax::{ast, ast_util};
29+
use syntax::util::small_vector::SmallVector;
2930

3031
struct Test {
3132
span: Span,
@@ -76,7 +77,7 @@ impl fold::ast_fold for TestHarnessGenerator {
7677
}
7778
}
7879

79-
fn fold_item(&self, i: @ast::item) -> Option<@ast::item> {
80+
fn fold_item(&self, i: @ast::item) -> SmallVector<@ast::item> {
8081
self.cx.path.push(i.ident);
8182
debug!("current path: {}",
8283
ast_util::path_name_i(self.cx.path.clone()));
@@ -108,7 +109,7 @@ impl fold::ast_fold for TestHarnessGenerator {
108109

109110
let res = fold::noop_fold_item(i, self);
110111
self.cx.path.pop();
111-
return res;
112+
res
112113
}
113114

114115
fn fold_mod(&self, m: &ast::_mod) -> ast::_mod {

branches/try/src/librustc/lib/llvm.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,62 @@ pub enum RealPredicate {
128128

129129
// The LLVM TypeKind type - must stay in sync with the def of
130130
// LLVMTypeKind in llvm/include/llvm-c/Core.h
131+
#[cfg(not(stage0))]
132+
#[deriving(Eq)]
133+
#[repr(C)]
134+
pub enum TypeKind {
135+
Void = 0,
136+
Half = 1,
137+
Float = 2,
138+
Double = 3,
139+
X86_FP80 = 4,
140+
FP128 = 5,
141+
PPC_FP128 = 6,
142+
Label = 7,
143+
Integer = 8,
144+
Function = 9,
145+
Struct = 10,
146+
Array = 11,
147+
Pointer = 12,
148+
Vector = 13,
149+
Metadata = 14,
150+
X86_MMX = 15,
151+
}
152+
153+
// NOTE remove these after snapshot. (See also #10308.)
154+
#[cfg(stage0)]
131155
pub type TypeKind = u32;
156+
#[cfg(stage0)]
132157
pub static Void: TypeKind = 0;
158+
#[cfg(stage0)]
133159
pub static Half: TypeKind = 1;
160+
#[cfg(stage0)]
134161
pub static Float: TypeKind = 2;
162+
#[cfg(stage0)]
135163
pub static Double: TypeKind = 3;
164+
#[cfg(stage0)]
136165
pub static X86_FP80: TypeKind = 4;
166+
#[cfg(stage0)]
137167
pub static FP128: TypeKind = 5;
168+
#[cfg(stage0)]
138169
pub static PPC_FP128: TypeKind = 6;
170+
#[cfg(stage0)]
139171
pub static Label: TypeKind = 7;
172+
#[cfg(stage0)]
140173
pub static Integer: TypeKind = 8;
174+
#[cfg(stage0)]
141175
pub static Function: TypeKind = 9;
176+
#[cfg(stage0)]
142177
pub static Struct: TypeKind = 10;
178+
#[cfg(stage0)]
143179
pub static Array: TypeKind = 11;
180+
#[cfg(stage0)]
144181
pub static Pointer: TypeKind = 12;
182+
#[cfg(stage0)]
145183
pub static Vector: TypeKind = 13;
184+
#[cfg(stage0)]
146185
pub static Metadata: TypeKind = 14;
186+
#[cfg(stage0)]
147187
pub static X86_MMX: TypeKind = 15;
148188

149189
#[repr(C)]
@@ -1749,6 +1789,12 @@ pub fn SetUnnamedAddr(Global: ValueRef, Unnamed: bool) {
17491789
}
17501790
}
17511791

1792+
pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
1793+
unsafe {
1794+
llvm::LLVMSetThreadLocal(global, is_thread_local as Bool);
1795+
}
1796+
}
1797+
17521798
pub fn ConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
17531799
unsafe {
17541800
llvm::LLVMConstICmp(Pred as c_ushort, V1, V2)

branches/try/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl visit::Visitor<()> for ReadCrateVisitor {
6767

6868
#[deriving(Clone)]
6969
struct cache_entry {
70-
cnum: int,
70+
cnum: ast::CrateNum,
7171
span: Span,
7272
hash: @str,
7373
metas: @~[@ast::MetaItem]
@@ -242,7 +242,7 @@ fn metas_with_ident(ident: @str, metas: ~[@ast::MetaItem])
242242
}
243243

244244
fn existing_match(e: &Env, metas: &[@ast::MetaItem], hash: &str)
245-
-> Option<int> {
245+
-> Option<ast::CrateNum> {
246246
for c in e.crate_cache.iter() {
247247
if loader::metadata_matches(*c.metas, metas)
248248
&& (hash.is_empty() || c.hash.as_slice() == hash) {

0 commit comments

Comments
 (0)