Skip to content

Commit 5d3ca4b

Browse files
committed
Merge remote-tracking branch 'mozilla/master' into incoming
Conflicts: src/librustc/middle/astencode.rs src/librustc/middle/check_const.rs
2 parents c06ee9f + efd1438 commit 5d3ca4b

File tree

137 files changed

+2265
-1572
lines changed

Some content is hidden

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

137 files changed

+2265
-1572
lines changed

Makefile.in

+8-8
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,29 @@ $(foreach target,$(CFG_TARGET_TRIPLES),\
239239
# Standard library variables
240240
######################################################################
241241

242-
STDLIB_CRATE := $(S)src/libstd/core.rc
242+
STDLIB_CRATE := $(S)src/libstd/std.rs
243243
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
244-
core.rc *.rs */*.rs */*/*rs */*/*/*rs))
244+
*.rs */*.rs */*/*rs */*/*/*rs))
245245

246246
######################################################################
247247
# Extra library variables
248248
######################################################################
249249

250-
EXTRALIB_CRATE := $(S)src/libextra/std.rc
250+
EXTRALIB_CRATE := $(S)src/libextra/extra.rs
251251
EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
252-
std.rc *.rs */*.rs))
252+
*.rs */*.rs))
253253

254254
######################################################################
255255
# rustc crate variables
256256
######################################################################
257257

258-
COMPILER_CRATE := $(S)src/librustc/rustc.rc
258+
COMPILER_CRATE := $(S)src/librustc/rustc.rs
259259
COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
260-
rustc.rc *.rs */*.rs */*/*.rs */*/*/*.rs))
260+
*.rs */*.rs */*/*.rs */*/*/*.rs))
261261

262-
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rc
262+
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
263263
LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
264-
syntax.rc *.rs */*.rs */*/*.rs))
264+
*.rs */*.rs */*/*.rs))
265265

266266
DRIVER_CRATE := $(S)src/driver/driver.rs
267267

doc/tutorial.md

+44-13
Original file line numberDiff line numberDiff line change
@@ -1552,13 +1552,6 @@ fn each(v: &[int], op: &fn(v: &int)) {
15521552
}
15531553
~~~~
15541554

1555-
As an aside, the reason we pass in a *pointer* to an integer rather
1556-
than the integer itself is that this is how the actual `each()`
1557-
function for vectors works. `vec::each` though is a
1558-
[generic](#generics) function, so must be efficient to use for all
1559-
types. Passing the elements by pointer avoids copying potentially
1560-
large objects.
1561-
15621555
As a caller, if we use a closure to provide the final operator
15631556
argument, we can write it in a way that has a pleasant, block-like
15641557
structure.
@@ -1616,6 +1609,9 @@ To enable `debug!` logging, set the RUST_LOG environment variable to the name of
16161609

16171610
## For loops
16181611

1612+
> ***Note:*** The closure-based protocol used `for` loop is on the way out. The `for` loop will
1613+
> use iterator objects in the future instead.
1614+
16191615
The most common way to express iteration in Rust is with a `for`
16201616
loop. Like `do`, `for` is a nice syntax for describing control flow
16211617
with closures. Additionally, within a `for` loop, `break`, `loop`,
@@ -1640,7 +1636,16 @@ fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool {
16401636
And using this function to iterate over a vector:
16411637

16421638
~~~~
1643-
# use each = std::vec::each;
1639+
# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool {
1640+
# let mut n = 0;
1641+
# while n < v.len() {
1642+
# if !op(&v[n]) {
1643+
# return false;
1644+
# }
1645+
# n += 1;
1646+
# }
1647+
# return true;
1648+
# }
16441649
each([2, 4, 8, 5, 16], |n| {
16451650
if *n % 2 != 0 {
16461651
println("found odd number!");
@@ -1656,7 +1661,16 @@ out of the loop, you just write `break`. To skip ahead
16561661
to the next iteration, write `loop`.
16571662

16581663
~~~~
1659-
# use each = std::vec::each;
1664+
# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool {
1665+
# let mut n = 0;
1666+
# while n < v.len() {
1667+
# if !op(&v[n]) {
1668+
# return false;
1669+
# }
1670+
# n += 1;
1671+
# }
1672+
# return true;
1673+
# }
16601674
for each([2, 4, 8, 5, 16]) |n| {
16611675
if *n % 2 != 0 {
16621676
println("found odd number!");
@@ -1671,7 +1685,16 @@ normally allowed in closures, in a block that appears as the body of a
16711685
the enclosing function, not just the loop body.
16721686

16731687
~~~~
1674-
# use each = std::vec::each;
1688+
# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool {
1689+
# let mut n = 0;
1690+
# while n < v.len() {
1691+
# if !op(&v[n]) {
1692+
# return false;
1693+
# }
1694+
# n += 1;
1695+
# }
1696+
# return true;
1697+
# }
16751698
fn contains(v: &[int], elt: int) -> bool {
16761699
for each(v) |x| {
16771700
if (*x == elt) { return true; }
@@ -1686,7 +1709,16 @@ In these situations it can be convenient to lean on Rust's
16861709
argument patterns to bind `x` to the actual value, not the pointer.
16871710

16881711
~~~~
1689-
# use each = std::vec::each;
1712+
# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool {
1713+
# let mut n = 0;
1714+
# while n < v.len() {
1715+
# if !op(&v[n]) {
1716+
# return false;
1717+
# }
1718+
# n += 1;
1719+
# }
1720+
# return true;
1721+
# }
16901722
# fn contains(v: &[int], elt: int) -> bool {
16911723
for each(v) |&x| {
16921724
if (x == elt) { return true; }
@@ -1841,10 +1873,9 @@ vector consisting of the result of applying `function` to each element
18411873
of `vector`:
18421874

18431875
~~~~
1844-
# use std::vec;
18451876
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
18461877
let mut accumulator = ~[];
1847-
for vec::each(vector) |element| {
1878+
for vector.iter().advance |element| {
18481879
accumulator.push(function(element));
18491880
}
18501881
return accumulator;

mk/tools.mk

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
# and host architectures
1313

1414
# The test runner that runs the cfail/rfail/rpass and bxench tests
15-
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rc
16-
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*rs)
15+
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rs
16+
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*.rs)
1717

1818
# Rustpkg, the package manager and build system
19-
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rc
20-
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*rs)
19+
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rs
20+
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*.rs)
2121

2222
# Rustdoc, the documentation tool
23-
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rc
23+
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rs
2424
RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)
2525

2626
# Rusti, the JIT REPL
27-
RUSTI_LIB := $(S)src/librusti/rusti.rc
27+
RUSTI_LIB := $(S)src/librusti/rusti.rs
2828
RUSTI_INPUTS := $(wildcard $(S)src/librusti/*.rs)
2929

3030
# Rust, the convenience tool
31-
RUST_LIB := $(S)src/librust/rust.rc
31+
RUST_LIB := $(S)src/librust/rust.rs
3232
RUST_INPUTS := $(wildcard $(S)src/librust/*.rs)
3333

3434
# FIXME: These are only built for the host arch. Eventually we'll
File renamed without changes.

src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn compose_and_run_compiler(
529529
let extra_link_args = ~[~"-L",
530530
aux_output_dir_name(config, testfile).to_str()];
531531

532-
for vec::each(props.aux_builds) |rel_ab| {
532+
for props.aux_builds.iter().advance |rel_ab| {
533533
let abs_ab = config.aux_base.push_rel(&Path(*rel_ab));
534534
let aux_args =
535535
make_compile_args(config, props, ~[~"--lib"] + extra_link_args,

src/libextra/arc.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ mod tests {
521521
use core::cell::Cell;
522522
use core::comm;
523523
use core::task;
524+
use core::uint;
524525

525526
#[test]
526527
fn manually_share_arc() {
@@ -790,18 +791,20 @@ mod tests {
790791
}
791792
assert_eq!(*state, 42);
792793
*state = 31337;
794+
// FIXME: #7372: hits type inference bug with iterators
793795
// send to other readers
794-
for vec::each(reader_convos) |x| {
795-
match *x {
796+
for uint::range(0, reader_convos.len()) |i| {
797+
match reader_convos[i] {
796798
(ref rc, _) => rc.send(()),
797799
}
798800
}
799801
}
800802
let read_mode = arc.downgrade(write_mode);
801803
do (&read_mode).read |state| {
804+
// FIXME: #7372: hits type inference bug with iterators
802805
// complete handshake with other readers
803-
for vec::each(reader_convos) |x| {
804-
match *x {
806+
for uint::range(0, reader_convos.len()) |i| {
807+
match reader_convos[i] {
805808
(_, ref rp) => rp.recv(),
806809
}
807810
}

src/libextra/arena.rs

+28-25
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,21 @@ use list::{MutList, MutCons, MutNil};
4141
use core::at_vec;
4242
use core::cast::{transmute, transmute_mut, transmute_mut_region};
4343
use core::cast;
44-
use core::libc::size_t;
4544
use core::ptr;
46-
use core::sys::TypeDesc;
4745
use core::sys;
4846
use core::uint;
4947
use core::vec;
5048
use core::unstable::intrinsics;
49+
use core::unstable::intrinsics::{TyDesc};
5150

52-
pub mod rustrt {
53-
use core::libc::size_t;
54-
use core::sys::TypeDesc;
51+
#[cfg(not(stage0))]
52+
use core::unstable::intrinsics::{get_tydesc};
5553

56-
pub extern {
57-
#[rust_stack]
58-
unsafe fn rust_call_tydesc_glue(root: *u8,
59-
tydesc: *TypeDesc,
60-
field: size_t);
61-
}
54+
#[cfg(stage0)]
55+
unsafe fn get_tydesc<T>() -> *TyDesc {
56+
intrinsics::get_tydesc::<T>() as *TyDesc
6257
}
6358

64-
// This probably belongs somewhere else. Needs to be kept in sync with
65-
// changes to glue...
66-
static tydesc_drop_glue_index: size_t = 3 as size_t;
67-
6859
// The way arena uses arrays is really deeply awful. The arrays are
6960
// allocated, and have capacities reserved, but the fill for the array
7061
// will always stay at 0.
@@ -125,6 +116,19 @@ fn round_up_to(base: uint, align: uint) -> uint {
125116
(base + (align - 1)) & !(align - 1)
126117
}
127118

119+
#[inline]
120+
#[cfg(not(stage0))]
121+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
122+
// This function should be inlined when stage0 is gone
123+
((*tydesc).drop_glue)(data);
124+
}
125+
126+
#[inline]
127+
#[cfg(stage0)]
128+
unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
129+
((*tydesc).drop_glue)(0 as **TyDesc, data);
130+
}
131+
128132
// Walk down a chunk, running the destructors for any objects stored
129133
// in it.
130134
unsafe fn destroy_chunk(chunk: &Chunk) {
@@ -137,19 +141,18 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
137141
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
138142
let (size, align) = ((*tydesc).size, (*tydesc).align);
139143

140-
let after_tydesc = idx + sys::size_of::<*TypeDesc>();
144+
let after_tydesc = idx + sys::size_of::<*TyDesc>();
141145

142146
let start = round_up_to(after_tydesc, align);
143147

144148
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
145149
// start, size, align, is_done);
146150
if is_done {
147-
rustrt::rust_call_tydesc_glue(
148-
ptr::offset(buf, start), tydesc, tydesc_drop_glue_index);
151+
call_drop_glue(tydesc, ptr::offset(buf, start) as *i8);
149152
}
150153

151154
// Find where the next tydesc lives
152-
idx = round_up_to(start + size, sys::pref_align_of::<*TypeDesc>());
155+
idx = round_up_to(start + size, sys::pref_align_of::<*TyDesc>());
153156
}
154157
}
155158

@@ -158,12 +161,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
158161
// is necessary in order to properly do cleanup if a failure occurs
159162
// during an initializer.
160163
#[inline]
161-
unsafe fn bitpack_tydesc_ptr(p: *TypeDesc, is_done: bool) -> uint {
164+
unsafe fn bitpack_tydesc_ptr(p: *TyDesc, is_done: bool) -> uint {
162165
let p_bits: uint = transmute(p);
163166
p_bits | (is_done as uint)
164167
}
165168
#[inline]
166-
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
169+
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
167170
(transmute(p & !1), p & 1 == 1)
168171
}
169172

@@ -203,7 +206,7 @@ impl Arena {
203206
#[inline]
204207
fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
205208
unsafe {
206-
let tydesc = sys::get_type_desc::<T>();
209+
let tydesc = get_tydesc::<T>();
207210
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
208211
let ptr: *mut T = transmute(ptr);
209212
intrinsics::move_val_init(&mut (*ptr), op());
@@ -231,13 +234,13 @@ impl Arena {
231234
let head = transmute_mut_region(&mut self.head);
232235

233236
let tydesc_start = head.fill;
234-
let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
237+
let after_tydesc = head.fill + sys::size_of::<*TyDesc>();
235238
let start = round_up_to(after_tydesc, align);
236239
let end = start + n_bytes;
237240
if end > at_vec::capacity(head.data) {
238241
return self.alloc_nonpod_grow(n_bytes, align);
239242
}
240-
head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
243+
head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
241244

242245
//debug!("idx = %u, size = %u, align = %u, fill = %u",
243246
// start, n_bytes, align, head.fill);
@@ -250,7 +253,7 @@ impl Arena {
250253
#[inline]
251254
fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
252255
unsafe {
253-
let tydesc = sys::get_type_desc::<T>();
256+
let tydesc = get_tydesc::<T>();
254257
let (ty_ptr, ptr) =
255258
self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align);
256259
let ty_ptr: *mut uint = transmute(ty_ptr);

0 commit comments

Comments
 (0)