Skip to content

Commit dd1b214

Browse files
committed
---
yaml --- r: 52471 b: refs/heads/dist-snap c: 10e8ae8 h: refs/heads/master i: 52469: 7f59649 52467: d526974 52463: 7393dfa v: v3
1 parent d647adb commit dd1b214

Some content is hidden

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

77 files changed

+731
-388
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: ba2a3e823493b71933105c458fb7103b8d0d4d77
10+
refs/heads/dist-snap: 10e8ae852d5164ca172d96360994727234839399
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/AUTHORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Andrew Dunham <[email protected]>
1515
Andrew Paseltiner <[email protected]>
1616
Arkaitz Jimenez <[email protected]>
1717
Armin Ronacher <[email protected]>
18+
Ashok Gautham <[email protected]>
1819
Austin Seipp <[email protected]>
1920
2021
Ben Alpert <[email protected]>
@@ -25,6 +26,7 @@ Benjamin Jackman <[email protected]>
2526
Benjamin Kircher <[email protected]>
2627
Benjamin Peterson <[email protected]>
2728
Bilal Husain <[email protected]>
29+
Bill Fallon <[email protected]>
2830
Brendan Eich <[email protected]>
2931
Brian Anderson <[email protected]>
3032
Brian J. Burg <[email protected]>

branches/dist-snap/doc/rust.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,11 @@ Local variables are immutable unless declared with `let mut`. The
30183018
declaration (so `let mut x, y` declares two mutable variables, `x` and
30193019
`y`).
30203020

3021+
Function parameters are immutable unless declared with `mut`. The
3022+
`mut` keyword applies only to the following parameter (so `|mut x, y|`
3023+
and `fn f(mut x: ~int, y: ~int)` declare one mutable variable `x` and
3024+
one immutable variable `y`).
3025+
30213026
Local variables are not initialized when allocated; the entire frame worth of
30223027
local variables are allocated at once, on frame-entry, in an uninitialized
30233028
state. Subsequent statements within a function may or may not initialize the

branches/dist-snap/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
273273
procres: procres) {
274274

275275
// true if we found the error in question
276-
let found_flags = vec::to_mut(vec::from_elem(
276+
let found_flags = vec::cast_to_mut(vec::from_elem(
277277
vec::len(expected_errors), false));
278278

279279
if procres.status == 0 {

branches/dist-snap/src/libcore/dvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<A> DVec<A> {
145145
#[inline(always)]
146146
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
147147
do self.swap |v| {
148-
vec::from_mut(f(vec::to_mut(move v)))
148+
vec::cast_from_mut(f(vec::cast_to_mut(move v)))
149149
}
150150
}
151151

branches/dist-snap/src/libcore/f32.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ delegate!(fn exp2(n: c_float) -> c_float = cmath::c_float_utils::exp2)
5656
delegate!(fn abs(n: c_float) -> c_float = cmath::c_float_utils::abs)
5757
delegate!(fn abs_sub(a: c_float, b: c_float) -> c_float =
5858
cmath::c_float_utils::abs_sub)
59-
delegate!(fn floor(n: c_float) -> c_float = cmath::c_float_utils::floor)
6059
delegate!(fn mul_add(a: c_float, b: c_float, c: c_float) -> c_float =
6160
cmath::c_float_utils::mul_add)
6261
delegate!(fn fmax(a: c_float, b: c_float) -> c_float =
@@ -141,6 +140,10 @@ pub pure fn ge(x: f32, y: f32) -> bool { return x >= y; }
141140
#[inline(always)]
142141
pub pure fn gt(x: f32, y: f32) -> bool { return x > y; }
143142

143+
/// Returns `x` rounded down
144+
#[inline(always)]
145+
pub pure fn floor(x: f32) -> f32 { unsafe { floorf32(x) } }
146+
144147
// FIXME (#1999): replace the predicates below with llvm intrinsics or
145148
// calls to the libmath macros in the rust runtime for performance.
146149

@@ -298,6 +301,11 @@ impl f32: num::One {
298301
static pure fn one() -> f32 { 1.0 }
299302
}
300303

304+
#[abi="rust-intrinsic"]
305+
pub extern {
306+
fn floorf32(val: f32) -> f32;
307+
}
308+
301309
//
302310
// Local Variables:
303311
// mode: rust

branches/dist-snap/src/libcore/f64.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ delegate!(fn exp2(n: c_double) -> c_double = cmath::c_double_utils::exp2)
5757
delegate!(fn abs(n: c_double) -> c_double = cmath::c_double_utils::abs)
5858
delegate!(fn abs_sub(a: c_double, b: c_double) -> c_double =
5959
cmath::c_double_utils::abs_sub)
60-
delegate!(fn floor(n: c_double) -> c_double = cmath::c_double_utils::floor)
6160
delegate!(fn mul_add(a: c_double, b: c_double, c: c_double) -> c_double =
6261
cmath::c_double_utils::mul_add)
6362
delegate!(fn fmax(a: c_double, b: c_double) -> c_double =
@@ -210,12 +209,16 @@ pub pure fn is_infinite(x: f64) -> bool {
210209
return x == infinity || x == neg_infinity;
211210
}
212211

213-
/// Returns true if `x`is a finite number
212+
/// Returns true if `x` is a finite number
214213
#[inline(always)]
215214
pub pure fn is_finite(x: f64) -> bool {
216215
return !(is_NaN(x) || is_infinite(x));
217216
}
218217

218+
/// Returns `x` rounded down
219+
#[inline(always)]
220+
pub pure fn floor(x: f64) -> f64 { unsafe { floorf64(x) } }
221+
219222
// FIXME (#1999): add is_normal, is_subnormal, and fpclassify
220223

221224
/* Module: consts */
@@ -322,6 +325,11 @@ impl f64: num::One {
322325
static pure fn one() -> f64 { 1.0 }
323326
}
324327

328+
#[abi="rust-intrinsic"]
329+
pub extern {
330+
fn floorf64(val: f64) -> f64;
331+
}
332+
325333
//
326334
// Local Variables:
327335
// mode: rust

branches/dist-snap/src/libcore/gc.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use io;
4444
use libc::{size_t, uintptr_t};
4545
use option::{None, Option, Some};
4646
use ptr;
47-
use send_map::linear::LinearMap;
47+
use send_map::linear::LinearSet;
4848
use stackwalk;
4949
use sys;
5050

@@ -294,12 +294,6 @@ pub fn gc() {
294294
}
295295
}
296296

297-
type RootSet = LinearMap<*Word,()>;
298-
299-
fn RootSet() -> RootSet {
300-
LinearMap()
301-
}
302-
303297
#[cfg(gc)]
304298
fn expect_sentinel() -> bool { true }
305299

@@ -337,13 +331,13 @@ pub fn cleanup_stack_for_failure() {
337331
ptr::null()
338332
};
339333

340-
let mut roots = ~RootSet();
334+
let mut roots = LinearSet::new();
341335
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
342336
// Track roots to avoid double frees.
343-
if roots.find(&*root).is_some() {
337+
if roots.contains(&*root) {
344338
loop;
345339
}
346-
roots.insert(*root, ());
340+
roots.insert(*root);
347341

348342
if ptr::is_null(tydesc) {
349343
// FIXME #4420: Destroy this box

branches/dist-snap/src/libcore/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn as_c_charp<T>(s: &str, f: fn(*c_char) -> T) -> T {
8484

8585
pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
8686
-> Option<~str> {
87-
let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
87+
let buf = vec::cast_to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
8888
do vec::as_mut_buf(buf) |b, sz| {
8989
if f(b, sz as size_t) unsafe {
9090
Some(str::raw::from_buf(b as *u8))
@@ -111,7 +111,7 @@ pub mod win32 {
111111
let mut res = None;
112112
let mut done = false;
113113
while !done {
114-
let buf = vec::to_mut(vec::from_elem(n as uint, 0u16));
114+
let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16));
115115
do vec::as_mut_buf(buf) |b, _sz| {
116116
let k : DWORD = f(b, tmpbuf_sz as DWORD);
117117
if k == (0 as DWORD) {
@@ -1269,7 +1269,7 @@ mod tests {
12691269
};
12701270
assert (ostream as uint != 0u);
12711271
let s = ~"hello";
1272-
let mut buf = vec::to_mut(str::to_bytes(s) + ~[0 as u8]);
1272+
let mut buf = vec::cast_to_mut(str::to_bytes(s) + ~[0 as u8]);
12731273
do vec::as_mut_buf(buf) |b, _len| {
12741274
assert (libc::fwrite(b as *c_void, 1u as size_t,
12751275
(str::len(s) + 1u) as size_t, ostream)

branches/dist-snap/src/libcore/send_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ pub mod linear {
485485
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
486486
}
487487

488-
impl <T: Hash IterBytes Eq> LinearSet<T> {
488+
pub impl <T: Hash IterBytes Eq> LinearSet<T> {
489489
/// Create an empty LinearSet
490490
static fn new() -> LinearSet<T> { LinearSet{map: LinearMap()} }
491491
}

branches/dist-snap/src/libcore/task/spawn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,21 @@ macro_rules! move_it (
9696
{ $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
9797
)
9898

99-
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
99+
type TaskSet = send_map::linear::LinearSet<*rust_task>;
100100

101101
fn new_taskset() -> TaskSet {
102-
send_map::linear::LinearMap()
102+
send_map::linear::LinearSet::new()
103103
}
104104
fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) {
105-
let didnt_overwrite = tasks.insert(task, ());
105+
let didnt_overwrite = tasks.insert(task);
106106
assert didnt_overwrite;
107107
}
108108
fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
109109
let was_present = tasks.remove(&task);
110110
assert was_present;
111111
}
112112
pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) {
113-
tasks.each_key(|k| blk(*k))
113+
tasks.each(|k| blk(*k))
114114
}
115115

116116
// One of these per group of linked-failure tasks.

branches/dist-snap/src/libcore/vec.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
209209
}
210210

211211
/// Produces a mut vector from an immutable vector.
212-
pub pure fn to_mut<T>(v: ~[T]) -> ~[mut T] {
212+
pub pure fn cast_to_mut<T>(v: ~[T]) -> ~[mut T] {
213213
unsafe { ::cast::transmute(v) }
214214
}
215215

216216
/// Produces an immutable vector from a mut vector.
217-
pub pure fn from_mut<T>(v: ~[mut T]) -> ~[T] {
217+
pub pure fn cast_from_mut<T>(v: ~[mut T]) -> ~[T] {
218218
unsafe { ::cast::transmute(v) }
219219
}
220220

@@ -552,7 +552,7 @@ pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) unsafe {
552552
}
553553

554554
pub fn consume_mut<T>(v: ~[mut T], f: fn(uint, v: T)) {
555-
consume(vec::from_mut(v), f)
555+
consume(vec::cast_from_mut(v), f)
556556
}
557557

558558
/// Remove the last element from a vector and return it
@@ -718,7 +718,7 @@ pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
718718

719719
#[inline(always)]
720720
pub pure fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] {
721-
to_mut(append(from_mut(lhs), rhs))
721+
cast_to_mut(append(cast_from_mut(lhs), rhs))
722722
}
723723

724724
/**
@@ -3271,22 +3271,22 @@ mod tests {
32713271
}
32723272

32733273
#[test]
3274-
fn to_mut_no_copy() {
3274+
fn cast_to_mut_no_copy() {
32753275
unsafe {
32763276
let x = ~[1, 2, 3];
32773277
let addr = raw::to_ptr(x);
3278-
let x_mut = to_mut(x);
3278+
let x_mut = cast_to_mut(x);
32793279
let addr_mut = raw::to_ptr(x_mut);
32803280
assert addr == addr_mut;
32813281
}
32823282
}
32833283

32843284
#[test]
3285-
fn from_mut_no_copy() {
3285+
fn cast_from_mut_no_copy() {
32863286
unsafe {
32873287
let x = ~[mut 1, 2, 3];
32883288
let addr = raw::to_ptr(x);
3289-
let x_imm = from_mut(x);
3289+
let x_imm = cast_from_mut(x);
32903290
let addr_imm = raw::to_ptr(x_imm);
32913291
assert addr == addr_imm;
32923292
}

branches/dist-snap/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl ast::def: tr {
415415
ast::def_mod(did) => { ast::def_mod(did.tr(xcx)) }
416416
ast::def_foreign_mod(did) => { ast::def_foreign_mod(did.tr(xcx)) }
417417
ast::def_const(did) => { ast::def_const(did.tr(xcx)) }
418-
ast::def_arg(nid, m) => { ast::def_arg(xcx.tr_id(nid), m) }
418+
ast::def_arg(nid, m, b) => { ast::def_arg(xcx.tr_id(nid), m, b) }
419419
ast::def_local(nid, b) => { ast::def_local(xcx.tr_id(nid), b) }
420420
ast::def_variant(e_did, v_did) => {
421421
ast::def_variant(e_did.tr(xcx), v_did.tr(xcx))

branches/dist-snap/src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use util::common::indenter;
3030
use util::ppaux::{expr_repr, region_to_str};
3131

3232
use core::dvec;
33-
use core::send_map::linear::LinearMap;
33+
use core::send_map::linear::LinearSet;
3434
use core::vec;
3535
use std::map::HashMap;
3636
use syntax::ast::{m_const, m_imm, m_mutbl};
@@ -73,17 +73,18 @@ enum gather_loan_ctxt = @{bccx: borrowck_ctxt,
7373
req_maps: req_maps,
7474
mut item_ub: ast::node_id,
7575
mut root_ub: ast::node_id,
76-
mut ignore_adjustments: LinearMap<ast::node_id,()>};
76+
mut ignore_adjustments: LinearSet<ast::node_id>};
7777

7878
fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
7979
let glcx = gather_loan_ctxt(@{bccx: bccx,
8080
req_maps: {req_loan_map: HashMap(),
8181
pure_map: HashMap()},
8282
mut item_ub: 0,
8383
mut root_ub: 0,
84-
mut ignore_adjustments: LinearMap()});
84+
mut ignore_adjustments: LinearSet::new()});
8585
let v = visit::mk_vt(@visit::Visitor {visit_expr: req_loans_in_expr,
8686
visit_fn: req_loans_in_fn,
87+
visit_stmt: add_stmt_to_map,
8788
.. *visit::default_visitor()});
8889
visit::visit_crate(*crate, glcx, v);
8990
return glcx.req_maps;
@@ -125,7 +126,7 @@ fn req_loans_in_expr(ex: @ast::expr,
125126
ex.id, pprust::expr_to_str(ex, tcx.sess.intr()));
126127

127128
// If this expression is borrowed, have to ensure it remains valid:
128-
if !self.ignore_adjustments.contains_key(&ex.id) {
129+
if !self.ignore_adjustments.contains(&ex.id) {
129130
for tcx.adjustments.find(ex.id).each |adjustments| {
130131
self.guarantee_adjustments(ex, *adjustments);
131132
}
@@ -220,7 +221,7 @@ fn req_loans_in_expr(ex: @ast::expr,
220221

221222
// FIXME (#3387): Total hack: Ignore adjustments for the left-hand
222223
// side. Their regions will be inferred to be too large.
223-
self.ignore_adjustments.insert(rcvr.id, ());
224+
self.ignore_adjustments.insert(rcvr.id);
224225

225226
visit::visit_expr(ex, self, vt);
226227
}
@@ -573,3 +574,16 @@ impl gather_loan_ctxt {
573574
}
574575
}
575576

577+
// Setting up info that preserve needs.
578+
// This is just the most convenient place to do it.
579+
fn add_stmt_to_map(stmt: @ast::stmt,
580+
&&self: gather_loan_ctxt,
581+
vt: visit::vt<gather_loan_ctxt>) {
582+
match stmt.node {
583+
ast::stmt_expr(_, id) | ast::stmt_semi(_, id) => {
584+
self.bccx.stmt_map.insert(id, ());
585+
}
586+
_ => ()
587+
}
588+
visit::visit_stmt(stmt, self, vt);
589+
}

branches/dist-snap/src/librustc/middle/borrowck/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ use middle::liveness;
232232
use middle::mem_categorization::*;
233233
use middle::region;
234234
use middle::ty;
235-
use util::common::indenter;
235+
use util::common::{indenter, stmt_set};
236236
use util::ppaux::{expr_repr, note_and_explain_region};
237237
use util::ppaux::{ty_to_str, region_to_str, explain_region};
238238

@@ -272,6 +272,7 @@ fn check_crate(tcx: ty::ctxt,
272272
root_map: root_map(),
273273
mutbl_map: HashMap(),
274274
write_guard_map: HashMap(),
275+
stmt_map: HashMap(),
275276
mut loaned_paths_same: 0,
276277
mut loaned_paths_imm: 0,
277278
mut stable_paths: 0,
@@ -313,6 +314,7 @@ type borrowck_ctxt_ = {tcx: ty::ctxt,
313314
root_map: root_map,
314315
mutbl_map: mutbl_map,
315316
write_guard_map: write_guard_map,
317+
stmt_map: stmt_set,
316318

317319
// Statistics:
318320
mut loaned_paths_same: uint,

0 commit comments

Comments
 (0)