Skip to content

Commit bcd33dd

Browse files
committed
---
yaml --- r: 93946 b: refs/heads/try c: a9bd049 h: refs/heads/master v: v3
1 parent c2b4da6 commit bcd33dd

Some content is hidden

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

45 files changed

+383
-900
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: e147a090a5c7125428c16b142922002f7a645ea1
5+
refs/heads/try: a9bd049fc09445a20ab8a9283a24f1074403d061
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/rust.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,8 +1754,6 @@ 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.
17591757

17601758
Other attributes may be added or removed during development of the language.
17611759

branches/try/src/libextra/c_vec.rs

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

3939
use std::ptr;
40+
use std::routine::Runnable;
4041
use std::util;
4142

4243
/**
@@ -49,7 +50,7 @@ pub struct CVec<T> {
4950
}
5051

5152
struct DtorRes {
52-
dtor: Option<proc()>,
53+
dtor: Option<~Runnable>,
5354
}
5455

5556
#[unsafe_destructor]
@@ -58,13 +59,13 @@ impl Drop for DtorRes {
5859
let dtor = util::replace(&mut self.dtor, None);
5960
match dtor {
6061
None => (),
61-
Some(f) => f()
62+
Some(f) => f.run()
6263
}
6364
}
6465
}
6566

6667
impl DtorRes {
67-
fn new(dtor: Option<proc()>) -> DtorRes {
68+
fn new(dtor: Option<~Runnable>) -> DtorRes {
6869
DtorRes {
6970
dtor: dtor,
7071
}
@@ -102,7 +103,7 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
102103
* * dtor - A function to run when the value is destructed, useful
103104
* for freeing the buffer, etc.
104105
*/
105-
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: proc())
106+
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: ~Runnable)
106107
-> CVec<T> {
107108
return CVec{
108109
base: base,
@@ -154,6 +155,19 @@ mod tests {
154155

155156
use std::libc::*;
156157
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+
}
157171

158172
fn malloc(n: size_t) -> CVec<u8> {
159173
unsafe {
@@ -163,7 +177,9 @@ mod tests {
163177

164178
return c_vec_with_dtor(mem as *mut u8,
165179
n as uint,
166-
proc() unsafe { libc::free(mem); });
180+
~LibcFree {
181+
mem: mem,
182+
} as ~Runnable);
167183
}
168184
}
169185

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

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

31+
use std::int;
3132
use std::hashmap::{HashMap,HashSet};
3233

3334
#[deriving(Clone)]
@@ -208,7 +209,7 @@ pub struct Session_ {
208209
building_library: @mut bool,
209210
working_dir: Path,
210211
lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::Span, ~str)]>,
211-
node_id: @mut ast::NodeId,
212+
node_id: @mut uint,
212213
}
213214

214215
pub type Session = @Session_;
@@ -273,15 +274,13 @@ impl Session_ {
273274
pub fn next_node_id(&self) -> ast::NodeId {
274275
self.reserve_node_ids(1)
275276
}
276-
pub fn reserve_node_ids(&self, count: ast::NodeId) -> ast::NodeId {
277+
pub fn reserve_node_ids(&self, count: uint) -> ast::NodeId {
277278
let v = *self.node_id;
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!")
279+
*self.node_id += count;
280+
if v > (int::max_value as uint) {
281+
self.bug("Input too large, ran out of node ids!");
282282
}
283-
284-
v
283+
v as int
285284
}
286285
pub fn diagnostic(&self) -> @mut diagnostic::span_handler {
287286
self.span_diagnostic

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ 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+
5159
fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item)
5260
-> Option<&'r ast::view_item> {
5361
if view_item_in_cfg(cx, view_item) {
@@ -58,10 +66,9 @@ fn filter_view_item<'r>(cx: &Context, view_item: &'r ast::view_item)
5866
}
5967

6068
fn fold_mod(cx: &Context, m: &ast::_mod) -> ast::_mod {
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();
69+
let filtered_items = m.items.iter().filter_map(|a| {
70+
filter_item(cx, *a).and_then(|x| cx.fold_item(x))
71+
}).collect();
6572
let filtered_view_items = m.view_items.iter().filter_map(|a| {
6673
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
6774
}).collect();
@@ -115,25 +122,28 @@ fn fold_item_underscore(cx: &Context, item: &ast::item_) -> ast::item_ {
115122
fold::noop_fold_item_underscore(&item, cx)
116123
}
117124

118-
fn retain_stmt(cx: &Context, stmt: @ast::Stmt) -> bool {
125+
fn filter_stmt(cx: &Context, stmt: @ast::Stmt) -> Option<@ast::Stmt> {
119126
match stmt.node {
120127
ast::StmtDecl(decl, _) => {
121128
match decl.node {
122129
ast::DeclItem(item) => {
123-
item_in_cfg(cx, item)
130+
if item_in_cfg(cx, item) {
131+
Some(stmt)
132+
} else {
133+
None
134+
}
124135
}
125-
_ => true
136+
_ => Some(stmt)
126137
}
127138
}
128-
_ => true
139+
_ => Some(stmt),
129140
}
130141
}
131142

132143
fn fold_block(cx: &Context, b: &ast::Block) -> ast::Block {
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();
144+
let resulting_stmts = b.stmts.iter().filter_map(|a| {
145+
filter_stmt(cx, *a).and_then(|stmt| cx.fold_stmt(stmt))
146+
}).collect();
137147
let filtered_view_items = b.view_items.iter().filter_map(|a| {
138148
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
139149
}).collect();

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//! Features are enabled in programs via the crate-level attributes of
1919
//! #[feature(...)] with a comma-separated list of features.
2020
21+
use middle::lint;
22+
2123
use syntax::ast;
2224
use syntax::attr::AttrMetaMethods;
2325
use syntax::codemap::Span;
@@ -38,7 +40,6 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
3840
("asm", Active),
3941
("managed_boxes", Active),
4042
("non_ascii_idents", Active),
41-
("thread_local", Active),
4243

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

110111
fn visit_item(&mut self, i: @ast::item, _:()) {
111-
// NOTE: uncomment after snapshot
112-
/*
113-
for attr in i.attrs.iter() {
114-
if "thread_local" == attr.name() {
115-
self.gate_feature("thread_local", i.span,
116-
"`#[thread_local]` is an experimental feature, and does not \
117-
currently handle destructors. There is no corresponding \
118-
`#[task_local]` mapping to the task model");
119-
}
120-
}
121-
*/
122112
match i.node {
123113
ast::item_enum(ref def, _) => {
124114
for variant in def.variants.iter() {
@@ -164,8 +154,8 @@ impl Visitor<()> for Context {
164154
},
165155
ast::ty_box(_) => {
166156
self.gate_feature("managed_boxes", t.span,
167-
"The managed box syntax is being replaced by the `std::gc::Gc` \
168-
and `std::rc::Rc` types. Equivalent functionality to managed \
157+
"The managed box syntax is being replaced by the `std::gc::Gc`
158+
and `std::rc::Rc` types. Equivalent functionality to managed
169159
trait objects will be implemented but is currently missing.");
170160
}
171161
_ => {}
@@ -209,7 +199,10 @@ pub fn check_crate(sess: Session, crate: &ast::Crate) {
209199
directive not necessary");
210200
}
211201
None => {
212-
sess.span_err(mi.span, "unknown feature");
202+
sess.add_lint(lint::unknown_features,
203+
ast::CRATE_NODE_ID,
204+
mi.span,
205+
~"unknown feature");
213206
}
214207
}
215208
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ 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;
2322

2423
static STD_VERSION: &'static str = "0.9-pre";
2524

@@ -99,14 +98,14 @@ impl fold::ast_fold for StandardLibraryInjector {
9998
}
10099
}
101100

102-
fn fold_item(&self, item: @ast::item) -> SmallVector<@ast::item> {
101+
fn fold_item(&self, item: @ast::item) -> Option<@ast::item> {
103102
if !no_prelude(item.attrs) {
104103
// only recur if there wasn't `#[no_implicit_prelude];`
105104
// on this item, i.e. this means that the prelude is not
106105
// implicitly imported though the whole subtree
107106
fold::noop_fold_item(item, self)
108107
} else {
109-
SmallVector::one(item)
108+
Some(item)
110109
}
111110
}
112111

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ 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;
3029

3130
struct Test {
3231
span: Span,
@@ -77,7 +76,7 @@ impl fold::ast_fold for TestHarnessGenerator {
7776
}
7877
}
7978

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

110109
let res = fold::noop_fold_item(i, self);
111110
self.cx.path.pop();
112-
res
111+
return res;
113112
}
114113

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

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

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -128,62 +128,22 @@ 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)]
155131
pub type TypeKind = u32;
156-
#[cfg(stage0)]
157132
pub static Void: TypeKind = 0;
158-
#[cfg(stage0)]
159133
pub static Half: TypeKind = 1;
160-
#[cfg(stage0)]
161134
pub static Float: TypeKind = 2;
162-
#[cfg(stage0)]
163135
pub static Double: TypeKind = 3;
164-
#[cfg(stage0)]
165136
pub static X86_FP80: TypeKind = 4;
166-
#[cfg(stage0)]
167137
pub static FP128: TypeKind = 5;
168-
#[cfg(stage0)]
169138
pub static PPC_FP128: TypeKind = 6;
170-
#[cfg(stage0)]
171139
pub static Label: TypeKind = 7;
172-
#[cfg(stage0)]
173140
pub static Integer: TypeKind = 8;
174-
#[cfg(stage0)]
175141
pub static Function: TypeKind = 9;
176-
#[cfg(stage0)]
177142
pub static Struct: TypeKind = 10;
178-
#[cfg(stage0)]
179143
pub static Array: TypeKind = 11;
180-
#[cfg(stage0)]
181144
pub static Pointer: TypeKind = 12;
182-
#[cfg(stage0)]
183145
pub static Vector: TypeKind = 13;
184-
#[cfg(stage0)]
185146
pub static Metadata: TypeKind = 14;
186-
#[cfg(stage0)]
187147
pub static X86_MMX: TypeKind = 15;
188148

189149
#[repr(C)]
@@ -1789,12 +1749,6 @@ pub fn SetUnnamedAddr(Global: ValueRef, Unnamed: bool) {
17891749
}
17901750
}
17911751

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-
17981752
pub fn ConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
17991753
unsafe {
18001754
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: ast::CrateNum,
70+
cnum: int,
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<ast::CrateNum> {
245+
-> Option<int> {
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)