Skip to content

Commit 7bf60ba

Browse files
committed
---
yaml --- r: 144958 b: refs/heads/try2 c: 73bb4de h: refs/heads/master v: v3
1 parent fe5b962 commit 7bf60ba

File tree

115 files changed

+1135
-1889
lines changed

Some content is hidden

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

115 files changed

+1135
-1889
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: 49eb7bd2716f59e0cd47c427a4c60f49e8ce6e50
8+
refs/heads/try2: 73bb4de556b3dabc1ba5db397fc1bed28e0537a9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,12 +2459,25 @@ do k(3) |j| {
24592459
### For expressions
24602460

24612461
~~~~~~~~{.ebnf .gram}
2462-
for_expr : "for" pat "in" expr '{' block '}' ;
2462+
for_expr : "for" expr [ '|' ident_list '|' ] ? '{' block '}' ;
24632463
~~~~~~~~
24642464

2465-
A `for` expression is a syntactic construct for looping
2466-
over elements provided by an implementation of
2467-
`std::iterator::Iterator`.
2465+
A _for expression_ is similar to a [`do` expression](#do-expressions),
2466+
in that it provides a special block-form of lambda expression,
2467+
suited to passing the `block` function to a higher-order function implementing a loop.
2468+
2469+
In contrast to a `do` expression, a `for` expression is designed to work
2470+
with methods such as `each` and `times`, that require the body block to
2471+
return a boolean. The `for` expression accommodates this by implicitly
2472+
returning `true` at the end of each block, unless a `break` expression
2473+
is evaluated.
2474+
2475+
In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2476+
are rewritten inside `for` expressions in the same way that `return` expressions are,
2477+
with a combination of local flag variables,
2478+
and early boolean-valued returns from the `block` function,
2479+
such that the meaning of `break` and `loop` is preserved in a primitive loop
2480+
when rewritten as a `for` loop controlled by a higher order function.
24682481

24692482
An example of a for loop over the contents of a vector:
24702483

branches/try2/src/libextra/num/bigint.rs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use std::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
2323
use std::int;
2424
use std::num;
2525
use std::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable};
26-
use std::rand::{Rng, RngUtil};
2726
use std::str;
2827
use std::uint;
2928
use std::vec;
@@ -1089,53 +1088,6 @@ impl FromStrRadix for BigInt {
10891088
}
10901089
}
10911090
1092-
trait RandBigInt {
1093-
/// Generate a random BigUint of the given bit size.
1094-
fn gen_biguint(&mut self, bit_size: uint) -> BigUint;
1095-
1096-
/// Generate a random BigInt of the given bit size.
1097-
fn gen_bigint(&mut self, bit_size: uint) -> BigInt;
1098-
}
1099-
1100-
impl<R: Rng> RandBigInt for R {
1101-
/// Generate a random BigUint of the given bit size.
1102-
fn gen_biguint(&mut self, bit_size: uint) -> BigUint {
1103-
let (digits, rem) = bit_size.div_rem(&BigDigit::bits);
1104-
let mut data = vec::with_capacity(digits+1);
1105-
for _ in range(0, digits) {
1106-
data.push(self.gen());
1107-
}
1108-
if rem > 0 {
1109-
let final_digit: BigDigit = self.gen();
1110-
data.push(final_digit >> (BigDigit::bits - rem));
1111-
}
1112-
return BigUint::new(data);
1113-
}
1114-
1115-
/// Generate a random BigInt of the given bit size.
1116-
fn gen_bigint(&mut self, bit_size: uint) -> BigInt {
1117-
// Generate a random BigUint...
1118-
let biguint = self.gen_biguint(bit_size);
1119-
// ...and then randomly assign it a Sign...
1120-
let sign = if biguint.is_zero() {
1121-
// ...except that if the BigUint is zero, we need to try
1122-
// again with probability 0.5. This is because otherwise,
1123-
// the probability of generating a zero BigInt would be
1124-
// double that of any other number.
1125-
if self.gen() {
1126-
return self.gen_bigint(bit_size);
1127-
} else {
1128-
Zero
1129-
}
1130-
} else if self.gen() {
1131-
Plus
1132-
} else {
1133-
Minus
1134-
};
1135-
return BigInt::from_biguint(sign, biguint);
1136-
}
1137-
}
1138-
11391091
impl BigInt {
11401092
/// Creates and initializes an BigInt.
11411093
#[inline]
@@ -1197,7 +1149,6 @@ mod biguint_tests {
11971149
use std::cmp::{Less, Equal, Greater};
11981150
use std::int;
11991151
use std::num::{IntConvertible, Zero, One, FromStrRadix};
1200-
use std::rand::{task_rng};
12011152
use std::str;
12021153
use std::uint;
12031154
use std::vec;
@@ -1705,13 +1656,6 @@ mod biguint_tests {
17051656
check(20, "2432902008176640000");
17061657
check(30, "265252859812191058636308480000000");
17071658
}
1708-
1709-
#[test]
1710-
fn test_rand() {
1711-
let mut rng = task_rng();
1712-
let _n: BigUint = rng.gen_biguint(137);
1713-
assert!(rng.gen_biguint(0).is_zero());
1714-
}
17151659
}
17161660

17171661
#[cfg(test)]
@@ -1721,7 +1665,6 @@ mod bigint_tests {
17211665
use std::cmp::{Less, Equal, Greater};
17221666
use std::int;
17231667
use std::num::{IntConvertible, Zero, One, FromStrRadix};
1724-
use std::rand::{task_rng};
17251668
use std::uint;
17261669

17271670
#[test]
@@ -2142,13 +2085,6 @@ mod bigint_tests {
21422085
let zero: BigInt = Zero::zero();
21432086
assert_eq!(-zero, zero);
21442087
}
2145-
2146-
#[test]
2147-
fn test_rand() {
2148-
let mut rng = task_rng();
2149-
let _n: BigInt = rng.gen_bigint(137);
2150-
assert!(rng.gen_bigint(0).is_zero());
2151-
}
21522088
}
21532089

21542090
#[cfg(test)]

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,14 +2109,6 @@ pub mod llvm {
21092109
ArgNo: c_uint)
21102110
-> ValueRef;
21112111

2112-
#[fast_ffi]
2113-
pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
2114-
Scope: ValueRef,
2115-
Name: *c_char,
2116-
File: ValueRef,
2117-
LineNo: c_uint)
2118-
-> ValueRef;
2119-
21202112
#[fast_ffi]
21212113
pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
21222114

branches/try2/src/librustc/middle/cfg/construct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl CFGBuilder {
488488

489489
fn find_scope(&self,
490490
expr: @ast::Expr,
491-
label: Option<ast::Name>) -> LoopScope {
491+
label: Option<ast::Ident>) -> LoopScope {
492492
match label {
493493
None => {
494494
return *self.loop_scopes.last();

branches/try2/src/librustc/middle/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
867867

868868
fn find_scope<'a>(&self,
869869
expr: @ast::Expr,
870-
label: Option<ast::Name>,
870+
label: Option<ast::Ident>,
871871
loop_scopes: &'a mut ~[LoopScope]) -> &'a mut LoopScope {
872872
let index = match label {
873873
None => {

branches/try2/src/librustc/middle/effect.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,8 @@ impl Visitor<()> for EffectCheckVisitor {
102102
fn visit_block(&mut self, block:&Block, _:()) {
103103

104104
let old_unsafe_context = self.context.unsafe_context;
105-
let is_unsafe = match block.rules {
106-
ast::UnsafeBlock(*) => true, ast::DefaultBlock => false
107-
};
108-
if is_unsafe && self.context.unsafe_context == SafeContext {
105+
if block.rules == ast::UnsafeBlock &&
106+
self.context.unsafe_context == SafeContext {
109107
self.context.unsafe_context = UnsafeBlock(block.id)
110108
}
111109

branches/try2/src/librustc/middle/lint.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,11 +1131,8 @@ impl Visitor<@mut Context> for UnusedUnsafeLintVisitor {
11311131
fn visit_expr(&mut self, e:@ast::Expr, cx:@mut Context) {
11321132

11331133
match e.node {
1134-
// Don't warn about generated blocks, that'll just pollute the
1135-
// output.
1136-
ast::ExprBlock(ref blk) => {
1137-
if blk.rules == ast::UnsafeBlock(ast::UserProvided) &&
1138-
!cx.tcx.used_unsafe.contains(&blk.id) {
1134+
ast::ExprBlock(ref blk) if blk.rules == ast::UnsafeBlock => {
1135+
if !cx.tcx.used_unsafe.contains(&blk.id) {
11391136
cx.span_lint(unused_unsafe, blk.span,
11401137
"unnecessary `unsafe` block");
11411138
}

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ impl Liveness {
756756
}
757757

758758
pub fn find_loop_scope(&self,
759-
opt_label: Option<Name>,
759+
opt_label: Option<Ident>,
760760
id: NodeId,
761761
sp: Span)
762762
-> NodeId {

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5157,13 +5157,15 @@ impl Resolver {
51575157
ExprForLoop(*) => fail!("non-desugared expr_for_loop"),
51585158

51595159
ExprBreak(Some(label)) | ExprAgain(Some(label)) => {
5160-
match self.search_ribs(self.label_ribs, label, expr.span,
5160+
let name = label.name;
5161+
match self.search_ribs(self.label_ribs, name, expr.span,
51615162
DontAllowCapturingSelf) {
51625163
None =>
51635164
self.resolve_error(expr.span,
51645165
fmt!("use of undeclared label \
51655166
`%s`",
5166-
interner_get(label))),
5167+
self.session.str_of(
5168+
label))),
51675169
Some(DlDef(def @ DefLabel(_))) => {
51685170
self.record_def(expr.id, def)
51695171
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use std::vec;
7676
use std::local_data;
7777
use extra::time;
7878
use extra::sort;
79-
use syntax::ast::Name;
79+
use syntax::ast::Ident;
8080
use syntax::ast_map::{path, path_elt_to_str, path_name, path_pretty_name};
8181
use syntax::ast_util::{local_def};
8282
use syntax::attr;
@@ -1189,7 +1189,7 @@ pub fn scope_block(bcx: @mut Block,
11891189

11901190
pub fn loop_scope_block(bcx: @mut Block,
11911191
loop_break: @mut Block,
1192-
loop_label: Option<Name>,
1192+
loop_label: Option<Ident>,
11931193
n: &str,
11941194
opt_node_info: Option<NodeInfo>) -> @mut Block {
11951195
return new_block(bcx.fcx, Some(bcx), Some(@mut ScopeInfo {
@@ -3021,10 +3021,6 @@ pub fn trans_crate(sess: session::Session,
30213021
link_meta,
30223022
analysis.reachable);
30233023

3024-
if ccx.sess.opts.debuginfo {
3025-
debuginfo::initialize(ccx, crate);
3026-
}
3027-
30283024
{
30293025
let _icx = push_ctxt("text");
30303026
trans_mod(ccx, &crate.module);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use std::cast;
3838
use std::hashmap::{HashMap};
3939
use std::libc::{c_uint, c_longlong, c_ulonglong, c_char};
4040
use std::vec;
41-
use syntax::ast::{Name,Ident};
41+
use syntax::ast::Ident;
4242
use syntax::ast_map::{path, path_elt, path_pretty_name};
4343
use syntax::codemap::Span;
4444
use syntax::parse::token;
@@ -463,7 +463,7 @@ pub fn block_cleanups(bcx: @mut Block) -> ~[cleanup] {
463463
pub struct ScopeInfo {
464464
parent: Option<@mut ScopeInfo>,
465465
loop_break: Option<@mut Block>,
466-
loop_label: Option<Name>,
466+
loop_label: Option<Ident>,
467467
// A list of functions that must be run at when leaving this
468468
// block, cleaning up any variables that were introduced in the
469469
// block.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use util::ppaux;
2222
use middle::trans::type_::Type;
2323

2424
use syntax::ast;
25-
use syntax::ast::Name;
25+
use syntax::ast::Ident;
2626
use syntax::ast_util;
2727
use syntax::codemap::Span;
2828

@@ -188,7 +188,7 @@ pub fn trans_while(bcx: @mut Block, cond: @ast::Expr, body: &ast::Block) -> @mut
188188

189189
pub fn trans_loop(bcx:@mut Block,
190190
body: &ast::Block,
191-
opt_label: Option<Name>)
191+
opt_label: Option<Ident>)
192192
-> @mut Block {
193193
let _icx = push_ctxt("trans_loop");
194194
let next_bcx = sub_block(bcx, "next");
@@ -201,7 +201,7 @@ pub fn trans_loop(bcx:@mut Block,
201201
}
202202

203203
pub fn trans_break_cont(bcx: @mut Block,
204-
opt_label: Option<Name>,
204+
opt_label: Option<Ident>,
205205
to_end: bool)
206206
-> @mut Block {
207207
let _icx = push_ctxt("trans_break_cont");
@@ -254,11 +254,11 @@ pub fn trans_break_cont(bcx: @mut Block,
254254
return bcx;
255255
}
256256

257-
pub fn trans_break(bcx: @mut Block, label_opt: Option<Name>) -> @mut Block {
257+
pub fn trans_break(bcx: @mut Block, label_opt: Option<Ident>) -> @mut Block {
258258
return trans_break_cont(bcx, label_opt, true);
259259
}
260260

261-
pub fn trans_cont(bcx: @mut Block, label_opt: Option<Name>) -> @mut Block {
261+
pub fn trans_cont(bcx: @mut Block, label_opt: Option<Ident>) -> @mut Block {
262262
return trans_break_cont(bcx, label_opt, false);
263263
}
264264

0 commit comments

Comments
 (0)