Skip to content

Commit ef26d69

Browse files
committed
---
yaml --- r: 129019 b: refs/heads/master c: 2e5aea6 h: refs/heads/master i: 129017: ec8fd4b 129015: 81a8c22 v: v3
1 parent a19859e commit ef26d69

File tree

22 files changed

+299
-72
lines changed

22 files changed

+299
-72
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: be8bd24e3190237469f74a426c9daa12c70d3de1
2+
refs/heads/master: 2e5aea65cd2594f19b9043d8df0e6461504cda9b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
55
refs/heads/try: 961753763fb87ddcbbccaec4ea87648608d19a58

trunk/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ then
635635
LLVM_VERSION=$($LLVM_CONFIG --version)
636636

637637
case $LLVM_VERSION in
638-
(3.[2-5]*)
638+
(3.[2-6]*)
639639
msg "found ok version of LLVM: $LLVM_VERSION"
640640
;;
641641
(*)

trunk/src/doc/guide.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,9 +2896,11 @@ pub fn print_hello() {
28962896
}
28972897
```
28982898

2899-
When we include a module like this, we don't need to make the `mod` declaration,
2900-
it's just understood. This helps prevent 'rightward drift': when you end up
2901-
indenting so many times that your code is hard to read.
2899+
When we include a module like this, we don't need to make the `mod` declaration
2900+
in `hello.rs`, because it's already been declared in `lib.rs`. `hello.rs` just
2901+
contains the body of the module which is defined (by the `pub mod hello`) in
2902+
`lib.rs`. This helps prevent 'rightward drift': when you end up indenting so
2903+
many times that your code is hard to read.
29022904

29032905
Finally, make a new directory, `src/goodbye`, and make a new file in it,
29042906
`src/goodbye/mod.rs`:

trunk/src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ mod tests {
563563

564564
struct Noncopy {
565565
string: String,
566-
array: Vec<int> ,
566+
array: Vec<int>,
567567
}
568568

569569
#[test]

trunk/src/libcollections/bitv.rs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,9 @@ mod tests {
25662566
let mut r = rng();
25672567
let mut bitv = 0 as uint;
25682568
b.iter(|| {
2569-
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
2569+
for _ in range(0u, 100) {
2570+
bitv |= 1 << ((r.next_u32() as uint) % uint::BITS);
2571+
}
25702572
&bitv
25712573
})
25722574
}
@@ -2576,7 +2578,9 @@ mod tests {
25762578
let mut r = rng();
25772579
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25782580
b.iter(|| {
2579-
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
2581+
for _ in range(0u, 100) {
2582+
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
2583+
}
25802584
&bitv
25812585
})
25822586
}
@@ -2586,7 +2590,9 @@ mod tests {
25862590
let mut r = rng();
25872591
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25882592
b.iter(|| {
2589-
bitv.set((r.next_u32() as uint) % uint::BITS, true);
2593+
for _ in range(0u, 100) {
2594+
bitv.set((r.next_u32() as uint) % uint::BITS, true);
2595+
}
25902596
&bitv
25912597
})
25922598
}
@@ -2596,7 +2602,9 @@ mod tests {
25962602
let mut r = rng();
25972603
let mut bitv = BitvSet::new();
25982604
b.iter(|| {
2599-
bitv.insert((r.next_u32() as uint) % uint::BITS);
2605+
for _ in range(0u, 100) {
2606+
bitv.insert((r.next_u32() as uint) % uint::BITS);
2607+
}
26002608
&bitv
26012609
})
26022610
}
@@ -2606,7 +2614,9 @@ mod tests {
26062614
let mut r = rng();
26072615
let mut bitv = BitvSet::new();
26082616
b.iter(|| {
2609-
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
2617+
for _ in range(0u, 100) {
2618+
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
2619+
}
26102620
&bitv
26112621
})
26122622
}
@@ -2616,29 +2626,33 @@ mod tests {
26162626
let mut b1 = Bitv::with_capacity(BENCH_BITS, false);
26172627
let b2 = Bitv::with_capacity(BENCH_BITS, false);
26182628
b.iter(|| {
2619-
b1.union(&b2);
2629+
b1.union(&b2)
26202630
})
26212631
}
26222632

26232633
#[bench]
2624-
fn bench_btv_small_iter(b: &mut Bencher) {
2634+
fn bench_bitv_small_iter(b: &mut Bencher) {
26252635
let bitv = Bitv::with_capacity(uint::BITS, false);
26262636
b.iter(|| {
2627-
let mut _sum = 0;
2628-
for pres in bitv.iter() {
2629-
_sum += pres as uint;
2637+
let mut sum = 0;
2638+
for _ in range(0u, 10) {
2639+
for pres in bitv.iter() {
2640+
sum += pres as uint;
2641+
}
26302642
}
2643+
sum
26312644
})
26322645
}
26332646

26342647
#[bench]
26352648
fn bench_bitv_big_iter(b: &mut Bencher) {
26362649
let bitv = Bitv::with_capacity(BENCH_BITS, false);
26372650
b.iter(|| {
2638-
let mut _sum = 0;
2651+
let mut sum = 0;
26392652
for pres in bitv.iter() {
2640-
_sum += pres as uint;
2653+
sum += pres as uint;
26412654
}
2655+
sum
26422656
})
26432657
}
26442658

@@ -2647,10 +2661,11 @@ mod tests {
26472661
let bitv = BitvSet::from_bitv(from_fn(BENCH_BITS,
26482662
|idx| {idx % 3 == 0}));
26492663
b.iter(|| {
2650-
let mut _sum = 0;
2664+
let mut sum = 0;
26512665
for idx in bitv.iter() {
2652-
_sum += idx;
2666+
sum += idx;
26532667
}
2668+
sum
26542669
})
26552670
}
26562671
}

trunk/src/libcollections/priority_queue.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,9 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
529529
}
530530

531531
impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
532-
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
533-
let mut q = PriorityQueue::new();
534-
q.extend(iter);
535-
q
532+
fn from_iter<Iter: Iterator<T>>(mut iter: Iter) -> PriorityQueue<T> {
533+
let vec: Vec<T> = iter.collect();
534+
PriorityQueue::from_vec(vec)
536535
}
537536
}
538537

trunk/src/libcore/mem.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ use ptr;
1919

2020
pub use intrinsics::transmute;
2121

22+
/// Moves a thing into the void.
23+
///
24+
/// The forget function will take ownership of the provided value but neglect
25+
/// to run any required cleanup or memory management operations on it.
26+
///
27+
/// This function is the unsafe version of the `drop` function because it does
28+
/// not run any destructors.
29+
#[stable]
30+
pub use intrinsics::forget;
31+
2232
/// Returns the size of a type in bytes.
2333
#[inline]
2434
#[stable]
@@ -337,17 +347,6 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
337347
#[stable]
338348
pub fn drop<T>(_x: T) { }
339349

340-
/// Moves a thing into the void.
341-
///
342-
/// The forget function will take ownership of the provided value but neglect
343-
/// to run any required cleanup or memory management operations on it.
344-
///
345-
/// This function is the unsafe version of the `drop` function because it does
346-
/// not run any destructors.
347-
#[inline]
348-
#[stable]
349-
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing) }
350-
351350
/// Interprets `src` as `&U`, and then reads `src` without moving the contained
352351
/// value.
353352
///

trunk/src/librustc/middle/resolve_lifetime.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ impl<'a> LifetimeContext<'a> {
206206

207207
self.check_lifetime_names(&generics.lifetimes);
208208

209-
let referenced_idents = free_lifetimes(&generics.ty_params);
209+
let referenced_idents = free_lifetimes(&generics.ty_params,
210+
&generics.where_clause);
210211
debug!("pushing fn scope id={} due to fn item/method\
211212
referenced_idents={:?}",
212213
n,
@@ -403,7 +404,8 @@ fn search_lifetimes(lifetimes: &Vec<ast::LifetimeDef>,
403404
///////////////////////////////////////////////////////////////////////////
404405

405406
pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::LifetimeDef> {
406-
let referenced_idents = free_lifetimes(&generics.ty_params);
407+
let referenced_idents = free_lifetimes(&generics.ty_params,
408+
&generics.where_clause);
407409
if referenced_idents.is_empty() {
408410
return Vec::new();
409411
}
@@ -414,7 +416,9 @@ pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::Lifeti
414416
.collect()
415417
}
416418

417-
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
419+
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>,
420+
where_clause: &ast::WhereClause)
421+
-> Vec<ast::Name> {
418422
/*!
419423
* Gathers up and returns the names of any lifetimes that appear
420424
* free in `ty_params`. Of course, right now, all lifetimes appear
@@ -426,6 +430,9 @@ pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
426430
for ty_param in ty_params.iter() {
427431
visit::walk_ty_param_bounds(&mut collector, &ty_param.bounds, ());
428432
}
433+
for predicate in where_clause.predicates.iter() {
434+
visit::walk_ty_param_bounds(&mut collector, &predicate.bounds, ());
435+
}
429436
return collector.names;
430437

431438
struct FreeLifetimeCollector {

trunk/src/librustc/middle/trans/base.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,26 +2240,44 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
22402240
ty::ty_bare_fn(ref f) => (f.sig.clone(), f.abi, false),
22412241
ty::ty_unboxed_closure(closure_did, _) => {
22422242
let unboxed_closures = ccx.tcx.unboxed_closures.borrow();
2243-
let function_type = unboxed_closures.get(&closure_did)
2244-
.closure_type
2245-
.clone();
2243+
let ref function_type = unboxed_closures.get(&closure_did)
2244+
.closure_type;
2245+
22462246
(function_type.sig.clone(), RustCall, true)
22472247
}
2248-
_ => fail!("expected closure or function.")
2248+
_ => ccx.sess().bug("expected closure or function.")
22492249
};
22502250

2251+
22512252
// Since index 0 is the return value of the llvm func, we start
22522253
// at either 1 or 2 depending on whether there's an env slot or not
22532254
let mut first_arg_offset = if has_env { 2 } else { 1 };
22542255
let mut attrs = llvm::AttrBuilder::new();
22552256
let ret_ty = fn_sig.output;
22562257

2257-
// These have an odd calling convention, so we skip them for now.
2258-
//
2259-
// FIXME(pcwalton): We don't have to skip them; just untuple the result.
2260-
if abi == RustCall {
2261-
return attrs;
2262-
}
2258+
// These have an odd calling convention, so we need to manually
2259+
// unpack the input ty's
2260+
let input_tys = match ty::get(fn_ty).sty {
2261+
ty::ty_unboxed_closure(_, _) => {
2262+
assert!(abi == RustCall);
2263+
2264+
match ty::get(fn_sig.inputs[0]).sty {
2265+
ty::ty_nil => Vec::new(),
2266+
ty::ty_tup(ref inputs) => inputs.clone(),
2267+
_ => ccx.sess().bug("expected tuple'd inputs")
2268+
}
2269+
},
2270+
ty::ty_bare_fn(_) if abi == RustCall => {
2271+
let inputs = vec![fn_sig.inputs[0]];
2272+
2273+
match ty::get(fn_sig.inputs[1]).sty {
2274+
ty::ty_nil => inputs,
2275+
ty::ty_tup(ref t_in) => inputs.append(t_in.as_slice()),
2276+
_ => ccx.sess().bug("expected tuple'd inputs")
2277+
}
2278+
}
2279+
_ => fn_sig.inputs.clone()
2280+
};
22632281

22642282
// A function pointer is called without the declaration
22652283
// available, so we have to apply any attributes with ABI
@@ -2315,7 +2333,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
23152333
}
23162334
}
23172335

2318-
for (idx, &t) in fn_sig.inputs.iter().enumerate().map(|(i, v)| (i + first_arg_offset, v)) {
2336+
for (idx, &t) in input_tys.iter().enumerate().map(|(i, v)| (i + first_arg_offset, v)) {
23192337
match ty::get(t).sty {
23202338
// this needs to be first to prevent fat pointers from falling through
23212339
_ if !type_is_immediate(ccx, t) => {

trunk/src/librustc/middle/trans/callee.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ fn resolve_default_method_vtables(bcx: &Block,
288288
/// `Trait` so that a by-value self method can be called.
289289
pub fn trans_unboxing_shim(bcx: &Block,
290290
llshimmedfn: ValueRef,
291-
method: &ty::Method,
291+
fty: &ty::BareFnTy,
292292
method_id: ast::DefId,
293293
substs: subst::Substs)
294294
-> ValueRef {
@@ -297,29 +297,29 @@ pub fn trans_unboxing_shim(bcx: &Block,
297297
let tcx = bcx.tcx();
298298

299299
// Transform the self type to `Box<self_type>`.
300-
let self_type = *method.fty.sig.inputs.get(0);
300+
let self_type = *fty.sig.inputs.get(0);
301301
let boxed_self_type = ty::mk_uniq(tcx, self_type);
302302
let boxed_function_type = ty::FnSig {
303-
binder_id: method.fty.sig.binder_id,
304-
inputs: method.fty.sig.inputs.iter().enumerate().map(|(i, typ)| {
303+
binder_id: fty.sig.binder_id,
304+
inputs: fty.sig.inputs.iter().enumerate().map(|(i, typ)| {
305305
if i == 0 {
306306
boxed_self_type
307307
} else {
308308
*typ
309309
}
310310
}).collect(),
311-
output: method.fty.sig.output,
311+
output: fty.sig.output,
312312
variadic: false,
313313
};
314314
let boxed_function_type = ty::BareFnTy {
315-
fn_style: method.fty.fn_style,
316-
abi: method.fty.abi,
315+
fn_style: fty.fn_style,
316+
abi: fty.abi,
317317
sig: boxed_function_type,
318318
};
319319
let boxed_function_type =
320320
ty::mk_bare_fn(tcx, boxed_function_type).subst(tcx, &substs);
321321
let function_type =
322-
ty::mk_bare_fn(tcx, method.fty.clone()).subst(tcx, &substs);
322+
ty::mk_bare_fn(tcx, (*fty).clone()).subst(tcx, &substs);
323323

324324
let function_name = ty::with_path(tcx, method_id, |path| {
325325
link::mangle_internal_name_by_path_and_seq(path, "unboxing_shim")

trunk/src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ impl param_substs {
201201
}
202202

203203
fn param_substs_to_string(this: &param_substs, tcx: &ty::ctxt) -> String {
204-
format!("param_substs({})", this.substs.repr(tcx))
204+
format!("param_substs(substs={},vtables={})",
205+
this.substs.repr(tcx),
206+
this.vtables.repr(tcx))
205207
}
206208

207209
impl Repr for param_substs {
@@ -859,8 +861,7 @@ pub fn find_vtable(tcx: &ty::ctxt,
859861
debug!("find_vtable(n_param={:?}, n_bound={}, ps={})",
860862
n_param, n_bound, ps.repr(tcx));
861863

862-
let param_bounds = ps.vtables.get(n_param.space,
863-
n_param.index);
864+
let param_bounds = ps.vtables.get(n_param.space, n_param.index);
864865
param_bounds.get(n_bound).clone()
865866
}
866867

0 commit comments

Comments
 (0)