Skip to content

Commit 5241474

Browse files
committed
---
yaml --- r: 139314 b: refs/heads/try2 c: 3d588c5 h: refs/heads/master v: v3
1 parent 9c2e150 commit 5241474

Some content is hidden

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

43 files changed

+618
-267
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: de468c8cd2f55124f98ae67941bc4c11dee92c14
8+
refs/heads/try2: 3d588c528685fa0590ff91f189f0ef44a3815ec2
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,9 @@ td {
101101
#TOC ul {
102102
list-style: none;
103103
padding-left: 0px;
104+
}
105+
106+
/* Adjust list alignment so rustdoc indexes don't align with blockquotes */
107+
div.index ul {
108+
padding-left: 1em;
104109
}

branches/try2/doc/rust.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,10 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
16711671
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
16721672
more comma-separated expressions of uniform type in square brackets.
16731673

1674+
In the `[expr ',' ".." expr]` form, the expression after the `".."`
1675+
must be a constant expression that can be evaluated at compile time, such
1676+
as a [literal](#literals) or a [static item](#static-items).
1677+
16741678
~~~~
16751679
[1, 2, 3, 4];
16761680
["a", "b", "c", "d"];
@@ -2156,6 +2160,19 @@ do f |j| {
21562160
}
21572161
~~~~
21582162

2163+
In this example, both calls to the (binary) function `k` are equivalent:
2164+
2165+
~~~~
2166+
# fn k(x:int, f: &fn(int)) { }
2167+
# fn l(i: int) { }
2168+
2169+
k(3, |j| l(j));
2170+
2171+
do k(3) |j| {
2172+
l(j);
2173+
}
2174+
~~~~
2175+
21592176

21602177
### For expressions
21612178

@@ -2184,7 +2201,7 @@ and early boolean-valued returns from the `block` function,
21842201
such that the meaning of `break` and `loop` is preserved in a primitive loop
21852202
when rewritten as a `for` loop controlled by a higher order function.
21862203

2187-
An example a for loop:
2204+
An example of a for loop over the contents of a vector:
21882205

21892206
~~~~
21902207
# type foo = int;
@@ -2198,6 +2215,14 @@ for v.each |e| {
21982215
}
21992216
~~~~
22002217

2218+
An example of a for loop over a series of integers:
2219+
2220+
~~~~
2221+
# fn bar(b:uint) { }
2222+
for uint::range(0, 256) |i| {
2223+
bar(i);
2224+
}
2225+
~~~~
22012226

22022227
### If expressions
22032228

@@ -2474,6 +2499,7 @@ fail_unless!(b != "world");
24742499

24752500
The vector type constructor represents a homogeneous array of values of a given type.
24762501
A vector has a fixed size.
2502+
(Operations like `vec::push` operate solely on owned vectors.)
24772503
A vector type can be annotated with a _definite_ size,
24782504
written with a trailing asterisk and integer literal, such as `[int * 10]`.
24792505
Such a definite-sized vector type is a first-class type, since its size is known statically.
@@ -2484,6 +2510,10 @@ such as `&[T]`, `@[T]` or `~[T]`.
24842510
The kind of a vector type depends on the kind of its element type,
24852511
as with other simple structural types.
24862512

2513+
Expressions producing vectors of definite size cannot be evaluated in a
2514+
context expecting a vector of indefinite size; one must copy the
2515+
definite-sized vector contents into a distinct vector of indefinite size.
2516+
24872517
An example of a vector type and its use:
24882518

24892519
~~~~

branches/try2/src/libcore/cast.rs

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

11+
//! Unsafe casting functions
12+
1113
pub mod rusti {
1214
#[abi = "rust-intrinsic"]
1315
#[link_name = "rusti"]

branches/try2/src/libcore/cell.rs

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

11+
//! A mutable, nullable memory location
12+
1113
use cast::transmute;
1214
use option;
1315
use prelude::*;
1416

15-
/// A dynamic, mutable location.
16-
///
17-
/// Similar to a mutable option type, but friendlier.
17+
/*
18+
A dynamic, mutable location.
19+
20+
Similar to a mutable option type, but friendlier.
21+
*/
1822

1923
pub struct Cell<T> {
2024
mut value: Option<T>

branches/try2/src/libcore/clone.rs

Lines changed: 13 additions & 2 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-
/**
12-
Clonable types are copied with the clone method
11+
/*! The Clone trait for types that cannot be "implicitly copied"
12+
13+
In Rust, some simple types are "implicitly copyable" and when you
14+
assign them or pass them as arguments, the receiver will get a copy,
15+
leaving the original value in place. These types do not require
16+
allocation to copy and do not have finalizers (i.e. they do not
17+
contain owned pointers or implement `Drop`), so the compiler considers
18+
them cheap and safe to copy and automatically implements the `Copy`
19+
trait for them. For other types copies must be made explicitly,
20+
by convention implementing the `Clone` trait and calling the
21+
`clone` method.
22+
1323
*/
24+
1425
pub trait Clone {
1526
fn clone(&self) -> Self;
1627
}

branches/try2/src/libcore/comm.rs

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

11+
/*!
12+
Message passing
13+
*/
14+
1115
use cast;
1216
use either::{Either, Left, Right};
1317
use kinds::Owned;

branches/try2/src/libcore/condition.rs

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

11+
/*! Condition handling */
12+
1113
use prelude::*;
1214
use task;
1315
use task::local_data::{local_data_pop, local_data_set};

branches/try2/src/libcore/core.rc

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,39 @@
1010

1111
/*!
1212

13-
The Rust core library
13+
# The Rust core library
1414

1515
The Rust core library provides runtime features required by the language,
1616
including the task scheduler and memory allocators, as well as library
1717
support for Rust built-in types, platform abstractions, and other commonly
1818
used features.
1919

2020
`core` includes modules corresponding to each of the integer types, each of
21-
the floating point types, the `bool` type, tuples, characters, strings,
22-
vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`), and unsafe
23-
and borrowed pointers (`ptr`). Additionally, `core` provides task management
24-
and creation (`task`), communication primitives (`comm` and `pipes`), platform
25-
abstractions (`os` and `path`), basic I/O abstractions (`io`), common traits
26-
(`cmp`, `num`, `to_str`), and complete bindings to the C standard library
27-
(`libc`).
21+
the floating point types, the `bool` type, tuples, characters, strings
22+
(`str`), vectors (`vec`), managed boxes (`managed`), owned boxes (`owned`),
23+
and unsafe and borrowed pointers (`ptr`). Additionally, `core` provides
24+
pervasive types (`option` and `result`), task creation and communication
25+
primitives (`task`, `comm`), platform abstractions (`os` and `path`), basic
26+
I/O abstractions (`io`), common traits (`kinds`, `ops`, `cmp`, `num`,
27+
`to_str`), and complete bindings to the C standard library (`libc`).
2828

29-
`core` is linked to all crates by default and its contents imported.
30-
Implicitly, all crates behave as if they included the following prologue:
29+
# Core injection and the Rust prelude
30+
31+
`core` is imported at the topmost level of every crate by default, as
32+
if the first line of each crate was
3133

3234
extern mod core;
33-
use core::*;
35+
36+
This means that the contents of core can be accessed from from any context
37+
with the `core::` path prefix, as in `use core::vec`, `use core::task::spawn`,
38+
etc.
39+
40+
Additionally, `core` contains a `prelude` module that reexports many of the
41+
most common core modules, types and traits. The contents of the prelude are
42+
imported inte every *module* by default. Implicitly, all modules behave as if
43+
they contained the following prologue:
44+
45+
use core::prelude::*;
3446

3547
*/
3648

branches/try2/src/libcore/iter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ pub fn build_sized_opt<A,B: Buildable<A>>(size: Option<uint>,
284284

285285
// Functions that combine iteration and building
286286

287-
/// Applies a function to each element of an iterable and returns the results.
287+
/// Applies a function to each element of an iterable and returns the results
288+
/// in a sequence built via `BU`. See also `map_to_vec`.
288289
#[inline(always)]
289290
pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U)
290291
-> BU {

branches/try2/src/libcore/prelude.rs

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

11-
// This file is imported into every module by default.
11+
//! The Rust prelude. Imported into every module by default.
1212
1313
/* Reexported core operators */
1414

branches/try2/src/libcore/rt/mod.rs

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

11+
#[doc(hidden)];
12+
1113
use libc::c_char;
1214

1315
// Some basic logging

branches/try2/src/libcore/unstable/lang.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ pub unsafe fn borrow_as_imm(a: *u8) {
9999
#[lang="return_to_mut"]
100100
#[inline(always)]
101101
pub unsafe fn return_to_mut(a: *u8) {
102-
let a: *mut BoxRepr = transmute(a);
103-
(*a).header.ref_count &= !FROZEN_BIT;
102+
// Sometimes the box is null, if it is conditionally frozen.
103+
// See e.g. #4904.
104+
if !a.is_null() {
105+
let a: *mut BoxRepr = transmute(a);
106+
(*a).header.ref_count &= !FROZEN_BIT;
107+
}
104108
}
105109

106110
#[lang="check_not_borrowed"]

branches/try2/src/libcore/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ pub fn with_capacity<T>(capacity: uint) -> ~[T] {
172172
/**
173173
* Builds a vector by calling a provided function with an argument
174174
* function that pushes an element to the back of a vector.
175-
* This version takes an initial size for the vector.
175+
* This version takes an initial capacity for the vector.
176176
*
177177
* # Arguments
178178
*
179179
* * size - An initial size of the vector to reserve
180-
* * builder - A function that will construct the vector. It recieves
180+
* * builder - A function that will construct the vector. It receives
181181
* as an argument a function that will push an element
182182
* onto the vector being constructed.
183183
*/
@@ -194,7 +194,7 @@ pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> ~[A] {
194194
*
195195
* # Arguments
196196
*
197-
* * builder - A function that will construct the vector. It recieves
197+
* * builder - A function that will construct the vector. It receives
198198
* as an argument a function that will push an element
199199
* onto the vector being constructed.
200200
*/

branches/try2/src/librustc/README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ lib/ - bindings to LLVM
3232
The files concerned purely with syntax -- that is, the AST, parser,
3333
pretty-printer, lexer, macro expander, and utilities for traversing
3434
ASTs -- are in a separate crate called "syntax", whose files are in
35-
./../libsyntax if the parent directory of front/, middle/, back/, and
36-
so on is . .
35+
./../libsyntax, where . is the current directory (that is, the parent
36+
directory of front/, middle/, back/, and so on).
3737

3838
The entry-point for the compiler is main() in driver/rustc.rs, and
3939
this file sequences the various parts together.

branches/try2/src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn req_loans_in_expr(ex: @ast::expr,
145145

146146
// make sure that the thing we are pointing out stays valid
147147
// for the lifetime `scope_r` of the resulting ptr:
148-
let scope_r = ty_region(tcx.ty(ex));
148+
let scope_r = ty_region(tcx, ex.span, tcx.ty(ex));
149149
self.guarantee_valid(base_cmt, mutbl, scope_r);
150150
visit::visit_expr(ex, self, vt);
151151
}
@@ -599,7 +599,8 @@ pub impl GatherLoanCtxt {
599599
// find the region of the resulting pointer (note that
600600
// the type of such a pattern will *always* be a
601601
// region pointer)
602-
let scope_r = ty_region(self.tcx().ty(pat));
602+
let scope_r = ty_region(self.tcx(), pat.span,
603+
self.tcx().ty(pat));
603604

604605
// if the scope of the region ptr turns out to be
605606
// specific to this arm, wrap the categorization with

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,17 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
15791579
id: ast::node_id,
15801580
impl_id: Option<ast::def_id>,
15811581
param_substs: Option<@param_substs>,
1582-
sp: Option<span>) -> fn_ctxt {
1582+
sp: Option<span>) -> fn_ctxt
1583+
{
1584+
for param_substs.each |p| { p.validate(); }
1585+
1586+
debug!("new_fn_ctxt_w_id(path=%s, id=%?, impl_id=%?, \
1587+
param_substs=%s",
1588+
path_str(ccx.sess, path),
1589+
id,
1590+
impl_id,
1591+
opt_param_substs_to_str(ccx.tcx, &param_substs));
1592+
15831593
let llbbs = mk_standard_basic_blocks(llfndecl);
15841594
return @mut fn_ctxt_ {
15851595
llfn: llfndecl,

branches/try2/src/librustc/middle/trans/callee.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn trans_fn_ref_with_vtables(
217217
// - `type_params`: values for each of the fn/method's type parameters
218218
// - `vtables`: values for each bound on each of the type parameters
219219

220-
let _icx = bcx.insn_ctxt("trans_fn_with_vtables");
220+
let _icx = bcx.insn_ctxt("trans_fn_ref_with_vtables");
221221
let ccx = bcx.ccx();
222222
let tcx = ccx.tcx;
223223

@@ -228,6 +228,8 @@ pub fn trans_fn_ref_with_vtables(
228228
vtables);
229229
let _indenter = indenter();
230230

231+
fail_unless!(type_params.all(|t| !ty::type_needs_infer(*t)));
232+
231233
// Polytype of the function item (may have type params)
232234
let fn_tpt = ty::lookup_item_type(tcx, def_id);
233235

0 commit comments

Comments
 (0)