Skip to content

Commit 1b74981

Browse files
committed
---
yaml --- r: 158991 b: refs/heads/auto c: a79d4be h: refs/heads/master i: 158989: 9582c88 158987: 3c2aaec 158983: f8e4968 158975: ed5a989 v: v3
1 parent 8689b8d commit 1b74981

File tree

29 files changed

+432
-735
lines changed

29 files changed

+432
-735
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: fa2983a1b7fc77dad37d49dcebeda3c25aac1e3f
13+
refs/heads/auto: a79d4be39cf99ed4dba1c757400a3ea708956653
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/mk/docs.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
DOCS := index intro tutorial guide guide-ffi guide-macros guide-lifetimes \
2929
guide-tasks guide-container guide-pointers guide-testing \
3030
guide-plugin guide-crates complement-bugreport \
31-
complement-lang-faq complement-design-faq complement-project-faq \
31+
complement-lang-faq complement-design-faq complement-project-faq rust \
3232
rustdoc guide-unsafe guide-strings reference
3333

3434
PDF_DOCS := guide reference
3535

36-
RUSTDOC_DEPS_reference := doc/full-toc.inc
37-
RUSTDOC_FLAGS_reference := --html-in-header=doc/full-toc.inc
36+
RUSTDOC_DEPS_rust := doc/full-toc.inc
37+
RUSTDOC_FLAGS_rust := --html-in-header=doc/full-toc.inc
3838

3939
L10N_LANGS := ja
4040

branches/auto/src/libcollections/enum_set.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use core::fmt;
1818

1919
// FIXME(conventions): implement BitXor
2020
// FIXME(contentions): implement union family of methods? (general design may be wrong here)
21-
// FIXME(conventions): implement len
2221

2322
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
2423
/// A specialized `Set` implementation to use enum types.
@@ -92,6 +91,12 @@ impl<E:CLike> EnumSet<E> {
9291
EnumSet {bits: 0}
9392
}
9493

94+
/// Returns the number of elements in the given `EnumSet`.
95+
#[unstable = "matches collection reform specification, waiting for dust to settle"]
96+
pub fn len(&self) -> uint {
97+
self.bits.count_ones()
98+
}
99+
95100
/// Returns true if the `EnumSet` is empty.
96101
#[unstable = "matches collection reform specification, waiting for dust to settle"]
97102
pub fn is_empty(&self) -> bool {
@@ -269,6 +274,20 @@ mod test {
269274
assert_eq!("{A, C}", e.to_string().as_slice());
270275
}
271276

277+
#[test]
278+
fn test_len() {
279+
let mut e = EnumSet::new();
280+
assert_eq!(e.len(), 0);
281+
e.insert(A);
282+
e.insert(B);
283+
e.insert(C);
284+
assert_eq!(e.len(), 3);
285+
e.remove(&A);
286+
assert_eq!(e.len(), 2);
287+
e.clear();
288+
assert_eq!(e.len(), 0);
289+
}
290+
272291
///////////////////////////////////////////////////////////////////////////
273292
// intersect
274293

branches/auto/src/libcollections/vec.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,13 +801,14 @@ impl<T> Vec<T> {
801801
///
802802
/// # Example
803803
/// ```
804-
/// let mut v = vec!["foo", "bar", "baz", "qux"];
804+
/// let mut v = vec!["foo".to_string(), "bar".to_string(),
805+
/// "baz".to_string(), "qux".to_string()];
805806
///
806-
/// assert_eq!(v.swap_remove(1), Some("bar"));
807-
/// assert_eq!(v, vec!["foo", "qux", "baz"]);
807+
/// assert_eq!(v.swap_remove(1), Some("bar".to_string()));
808+
/// assert_eq!(v, vec!["foo".to_string(), "qux".to_string(), "baz".to_string()]);
808809
///
809-
/// assert_eq!(v.swap_remove(0), Some("foo"));
810-
/// assert_eq!(v, vec!["baz", "qux"]);
810+
/// assert_eq!(v.swap_remove(0), Some("foo".to_string()));
811+
/// assert_eq!(v, vec!["baz".to_string(), "qux".to_string()]);
811812
///
812813
/// assert_eq!(v.swap_remove(2), None);
813814
/// ```

branches/auto/src/libcore/atomic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,15 +717,15 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
717717
/// A fence 'A' which has `Release` ordering semantics, synchronizes with a
718718
/// fence 'B' with (at least) `Acquire` semantics, if and only if there exists
719719
/// atomic operations X and Y, both operating on some atomic object 'M' such
720-
/// that A is sequenced before X, Y is synchronized before B and Y observes
720+
/// that A is sequenced before X, Y is synchronized before B and Y observers
721721
/// the change to M. This provides a happens-before dependence between A and B.
722722
///
723723
/// Atomic operations with `Release` or `Acquire` semantics can also synchronize
724724
/// with a fence.
725725
///
726-
/// A fence which has `SeqCst` ordering, in addition to having both `Acquire`
727-
/// and `Release` semantics, participates in the global program order of the
728-
/// other `SeqCst` operations and/or fences.
726+
/// A fence with has `SeqCst` ordering, in addition to having both `Acquire` and
727+
/// `Release` semantics, participates in the global program order of the other
728+
/// `SeqCst` operations and/or fences.
729729
///
730730
/// Accepts `Acquire`, `Release`, `AcqRel` and `SeqCst` orderings.
731731
///

branches/auto/src/libcore/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ extern "rust-intrinsic" {
536536
/// `TypeId` represents a globally unique identifier for a type
537537
#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
538538
// middle/lang_items.rs
539-
#[deriving(Clone, PartialEq, Eq, Show)]
539+
#[deriving(PartialEq, Eq, Show)]
540540
pub struct TypeId {
541541
t: u64,
542542
}

branches/auto/src/librustc/driver/driver.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ pub fn phase_2_configure_and_expand(sess: &Session,
212212
*ty == config::CrateTypeExecutable
213213
});
214214

215+
krate = time(time_passes, "crate injection", krate, |krate|
216+
syntax::std_inject::maybe_inject_crates_ref(krate,
217+
sess.opts.alt_std_name.clone(),
218+
any_exe));
219+
215220
// strip before expansion to allow macros to depend on
216221
// configuration variables e.g/ in
217222
//
@@ -223,11 +228,6 @@ pub fn phase_2_configure_and_expand(sess: &Session,
223228
krate = time(time_passes, "configuration 1", krate, |krate|
224229
syntax::config::strip_unconfigured_items(sess.diagnostic(), krate));
225230

226-
krate = time(time_passes, "crate injection", krate, |krate|
227-
syntax::std_inject::maybe_inject_crates_ref(krate,
228-
sess.opts.alt_std_name.clone(),
229-
any_exe));
230-
231231
let mut addl_plugins = Some(addl_plugins);
232232
let Plugins { macros, registrars }
233233
= time(time_passes, "plugin loading", (), |_|

branches/auto/src/librustc/middle/traits/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub enum Vtable<N> {
176176
/// ID is the ID of the closure expression. This is a `VtableImpl`
177177
/// in spirit, but the impl is generated by the compiler and does
178178
/// not appear in the source.
179-
VtableUnboxedClosure(ast::DefId, subst::Substs),
179+
VtableUnboxedClosure(ast::DefId),
180180

181181
/// Successful resolution to an obligation provided by the caller
182182
/// for some type parameter.
@@ -338,7 +338,7 @@ impl<N> Vtable<N> {
338338
pub fn iter_nested(&self) -> Items<N> {
339339
match *self {
340340
VtableImpl(ref i) => i.iter_nested(),
341-
VtableUnboxedClosure(..) => (&[]).iter(),
341+
VtableUnboxedClosure(_) => (&[]).iter(),
342342
VtableParam(_) => (&[]).iter(),
343343
VtableBuiltin(ref i) => i.iter_nested(),
344344
}
@@ -347,7 +347,7 @@ impl<N> Vtable<N> {
347347
pub fn map_nested<M>(&self, op: |&N| -> M) -> Vtable<M> {
348348
match *self {
349349
VtableImpl(ref i) => VtableImpl(i.map_nested(op)),
350-
VtableUnboxedClosure(d, ref s) => VtableUnboxedClosure(d, s.clone()),
350+
VtableUnboxedClosure(d) => VtableUnboxedClosure(d),
351351
VtableParam(ref p) => VtableParam((*p).clone()),
352352
VtableBuiltin(ref i) => VtableBuiltin(i.map_nested(op)),
353353
}
@@ -356,7 +356,7 @@ impl<N> Vtable<N> {
356356
pub fn map_move_nested<M>(self, op: |N| -> M) -> Vtable<M> {
357357
match self {
358358
VtableImpl(i) => VtableImpl(i.map_move_nested(op)),
359-
VtableUnboxedClosure(d, s) => VtableUnboxedClosure(d, s),
359+
VtableUnboxedClosure(d) => VtableUnboxedClosure(d),
360360
VtableParam(p) => VtableParam(p),
361361
VtableBuiltin(i) => VtableBuiltin(i.map_move_nested(op)),
362362
}

branches/auto/src/librustc/middle/traits/select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,9 +1582,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15821582
Ok(VtableImpl(vtable_impl))
15831583
}
15841584

1585-
UnboxedClosureCandidate(closure_def_id, substs) => {
1586-
try!(self.confirm_unboxed_closure_candidate(obligation, closure_def_id, &substs));
1587-
Ok(VtableUnboxedClosure(closure_def_id, substs))
1585+
UnboxedClosureCandidate(closure_def_id, ref substs) => {
1586+
try!(self.confirm_unboxed_closure_candidate(obligation, closure_def_id, substs));
1587+
Ok(VtableUnboxedClosure(closure_def_id))
15881588
}
15891589
}
15901590
}

branches/auto/src/librustc/middle/traits/util.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,9 @@ impl<N:Repr> Repr for super::Vtable<N> {
311311
super::VtableImpl(ref v) =>
312312
v.repr(tcx),
313313

314-
super::VtableUnboxedClosure(ref d, ref s) =>
315-
format!("VtableUnboxedClosure({},{})",
316-
d.repr(tcx),
317-
s.repr(tcx)),
314+
super::VtableUnboxedClosure(ref d) =>
315+
format!("VtableUnboxedClosure({})",
316+
d.repr(tcx)),
318317

319318
super::VtableParam(ref v) =>
320319
format!("VtableParam({})", v.repr(tcx)),

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,7 @@ pub fn trans_fn_ref_with_substs(
490490
};
491491

492492
// If this is an unboxed closure, redirect to it.
493-
match closure::get_or_create_declaration_if_unboxed_closure(bcx,
494-
def_id,
495-
&substs) {
493+
match closure::get_or_create_declaration_if_unboxed_closure(bcx, def_id) {
496494
None => {}
497495
Some(llfn) => return llfn,
498496
}

branches/auto/src/librustc/middle/trans/closure.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use middle::trans::monomorphize::MonoId;
2727
use middle::trans::type_of::*;
2828
use middle::trans::type_::Type;
2929
use middle::ty;
30-
use middle::subst::{Subst, Substs};
3130
use util::ppaux::Repr;
3231
use util::ppaux::ty_to_string;
3332

@@ -421,21 +420,15 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
421420
/// Returns the LLVM function declaration for an unboxed closure, creating it
422421
/// if necessary. If the ID does not correspond to a closure ID, returns None.
423422
pub fn get_or_create_declaration_if_unboxed_closure<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
424-
closure_id: ast::DefId,
425-
substs: &Substs)
423+
closure_id: ast::DefId)
426424
-> Option<ValueRef> {
427425
let ccx = bcx.ccx();
428426
if !ccx.tcx().unboxed_closures.borrow().contains_key(&closure_id) {
429427
// Not an unboxed closure.
430428
return None
431429
}
432430

433-
let function_type = ty::node_id_to_type(bcx.tcx(), closure_id.node);
434-
let function_type = function_type.subst(bcx.tcx(), substs);
435-
436-
// Normalize type so differences in regions and typedefs don't cause
437-
// duplicate declarations
438-
let function_type = ty::normalize_ty(bcx.tcx(), function_type);
431+
let function_type = node_id_type(bcx, closure_id.node);
439432
let params = match ty::get(function_type).sty {
440433
ty::ty_unboxed_closure(_, _, ref substs) => substs.types.clone(),
441434
_ => unreachable!()
@@ -454,6 +447,7 @@ pub fn get_or_create_declaration_if_unboxed_closure<'blk, 'tcx>(bcx: Block<'blk,
454447
None => {}
455448
}
456449

450+
let function_type = node_id_type(bcx, closure_id.node);
457451
let symbol = ccx.tcx().map.with_path(closure_id.node, |path| {
458452
mangle_internal_name_by_path_and_seq(path, "unboxed_closure")
459453
});
@@ -486,12 +480,12 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
486480
let closure_id = ast_util::local_def(id);
487481
let llfn = get_or_create_declaration_if_unboxed_closure(
488482
bcx,
489-
closure_id,
490-
&bcx.fcx.param_substs.substs).unwrap();
483+
closure_id).unwrap();
491484

492-
let function_type = (*bcx.tcx().unboxed_closures.borrow())[closure_id]
493-
.closure_type
494-
.clone();
485+
let unboxed_closures = bcx.tcx().unboxed_closures.borrow();
486+
let function_type = (*unboxed_closures)[closure_id]
487+
.closure_type
488+
.clone();
495489
let function_type = ty::mk_closure(bcx.tcx(), function_type);
496490

497491
let freevars: Vec<ty::Freevar> =

branches/auto/src/librustc/middle/trans/meth.rs

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,16 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
355355

356356
Callee { bcx: bcx, data: Fn(llfn) }
357357
}
358-
traits::VtableUnboxedClosure(closure_def_id, substs) => {
359-
// The substitutions should have no type parameters remaining
360-
// after passing through fulfill_obligation
358+
traits::VtableUnboxedClosure(closure_def_id) => {
359+
let self_ty = node_id_type(bcx, closure_def_id.node);
360+
let callee_substs = get_callee_substitutions_for_unboxed_closure(
361+
bcx,
362+
self_ty);
363+
361364
let llfn = trans_fn_ref_with_substs(bcx,
362365
closure_def_id,
363366
MethodCall(method_call),
364-
substs);
367+
callee_substs);
365368

366369
Callee {
367370
bcx: bcx,
@@ -515,6 +518,24 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
515518
};
516519
}
517520

521+
/// Looks up the substitutions for an unboxed closure and adds the
522+
/// self type
523+
fn get_callee_substitutions_for_unboxed_closure(bcx: Block,
524+
self_ty: ty::t)
525+
-> subst::Substs {
526+
match ty::get(self_ty).sty {
527+
ty::ty_unboxed_closure(_, _, ref substs) => {
528+
substs.with_self_ty(ty::mk_rptr(bcx.tcx(),
529+
ty::ReStatic,
530+
ty::mt {
531+
ty: self_ty,
532+
mutbl: ast::MutMutable,
533+
}))
534+
},
535+
_ => unreachable!()
536+
}
537+
}
538+
518539
/// Creates a returns a dynamic vtable for the given type and vtable origin.
519540
/// This is used only for objects.
520541
///
@@ -559,19 +580,19 @@ pub fn get_vtable(bcx: Block,
559580
nested: _ }) => {
560581
emit_vtable_methods(bcx, id, substs).into_iter()
561582
}
562-
traits::VtableUnboxedClosure(closure_def_id, substs) => {
563-
// Look up closure type
564-
let self_ty = ty::node_id_to_type(bcx.tcx(), closure_def_id.node);
565-
// Apply substitutions from closure param environment.
566-
// The substitutions should have no type parameters
567-
// remaining after passing through fulfill_obligation
568-
let self_ty = self_ty.subst(bcx.tcx(), &substs);
583+
traits::VtableUnboxedClosure(closure_def_id) => {
584+
let self_ty = node_id_type(bcx, closure_def_id.node);
585+
586+
let callee_substs =
587+
get_callee_substitutions_for_unboxed_closure(
588+
bcx,
589+
self_ty.clone());
569590

570591
let mut llfn = trans_fn_ref_with_substs(
571592
bcx,
572593
closure_def_id,
573594
ExprId(0),
574-
substs.clone());
595+
callee_substs.clone());
575596

576597
{
577598
let unboxed_closures = bcx.tcx()
@@ -624,7 +645,7 @@ pub fn get_vtable(bcx: Block,
624645
llfn,
625646
&closure_type,
626647
closure_def_id,
627-
substs);
648+
callee_substs);
628649
}
629650
}
630651

branches/auto/src/librustc/middle/ty_fold.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,7 @@ impl<N:TypeFoldable> TypeFoldable for traits::Vtable<N> {
414414
fn fold_with<'tcx, F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<N> {
415415
match *self {
416416
traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
417-
traits::VtableUnboxedClosure(d, ref s) => {
418-
traits::VtableUnboxedClosure(d, s.fold_with(folder))
419-
}
417+
traits::VtableUnboxedClosure(d) => traits::VtableUnboxedClosure(d),
420418
traits::VtableParam(ref p) => traits::VtableParam(p.fold_with(folder)),
421419
traits::VtableBuiltin(ref d) => traits::VtableBuiltin(d.fold_with(folder)),
422420
}

0 commit comments

Comments
 (0)