Skip to content

Commit 6970c59

Browse files
committed
---
yaml --- r: 108389 b: refs/heads/dist-snap c: 25147b2 h: refs/heads/master i: 108387: 920f25c v: v3
1 parent b7f0a0a commit 6970c59

File tree

16 files changed

+224
-143
lines changed

16 files changed

+224
-143
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 37bf97a0f9cc764a19dfcff21d62384b2445dcbc
9+
refs/heads/dist-snap: 25147b2644ed569f16f22dc02d10a0a9b7b97c7e
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<E:CLike> Iterator<E> for Items<E> {
129129
}
130130

131131
fn size_hint(&self) -> (uint, Option<uint>) {
132-
let exact = self.bits.population_count();
132+
let exact = self.bits.count_ones();
133133
(exact, Some(exact))
134134
}
135135
}

branches/dist-snap/src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool
432432
4 => Type::array(&Type::i32(), align_units),
433433
8 if machine::llalign_of_min(cx, Type::i64()) == 8 =>
434434
Type::array(&Type::i64(), align_units),
435-
a if a.population_count() == 1 => Type::array(&Type::vector(&Type::i32(), a / 4),
435+
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(), a / 4),
436436
align_units),
437437
_ => fail!("unsupported enum alignment: {:?}", align)
438438
};

branches/dist-snap/src/librustc/middle/typeck/collect.rs

Lines changed: 110 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -552,110 +552,126 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
552552
}
553553
}
554554

555+
fn ensure_generics_abi(ccx: &CrateCtxt,
556+
span: Span,
557+
abis: AbiSet,
558+
generics: &ast::Generics) {
559+
if generics.ty_params.len() > 0 &&
560+
!(abis.is_rust() || abis.is_intrinsic()) {
561+
ccx.tcx.sess.span_err(span,
562+
"foreign functions may not use type parameters");
563+
}
564+
}
565+
555566
pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
556567
let tcx = ccx.tcx;
557568
debug!("convert: item {} with id {}", token::get_ident(it.ident), it.id);
558569
match it.node {
559-
// These don't define types.
560-
ast::ItemForeignMod(_) | ast::ItemMod(_) | ast::ItemMac(_) => {}
561-
ast::ItemEnum(ref enum_definition, ref generics) => {
562-
ensure_no_ty_param_bounds(ccx, it.span, generics, "enumeration");
563-
let tpt = ty_of_item(ccx, it);
564-
write_ty_to_tcx(tcx, it.id, tpt.ty);
565-
get_enum_variant_types(ccx,
566-
tpt.ty,
567-
enum_definition.variants,
568-
generics);
569-
}
570-
ast::ItemImpl(ref generics, ref opt_trait_ref, selfty, ref ms) => {
571-
let i_ty_generics = ty_generics(ccx, generics, 0);
572-
let selfty = ccx.to_ty(&ExplicitRscope, selfty);
573-
write_ty_to_tcx(tcx, it.id, selfty);
570+
// These don't define types.
571+
ast::ItemForeignMod(_) | ast::ItemMod(_) | ast::ItemMac(_) => {}
572+
ast::ItemEnum(ref enum_definition, ref generics) => {
573+
ensure_no_ty_param_bounds(ccx, it.span, generics, "enumeration");
574+
let tpt = ty_of_item(ccx, it);
575+
write_ty_to_tcx(tcx, it.id, tpt.ty);
576+
get_enum_variant_types(ccx,
577+
tpt.ty,
578+
enum_definition.variants,
579+
generics);
580+
},
581+
ast::ItemImpl(ref generics, ref opt_trait_ref, selfty, ref ms) => {
582+
let i_ty_generics = ty_generics(ccx, generics, 0);
583+
let selfty = ccx.to_ty(&ExplicitRscope, selfty);
584+
write_ty_to_tcx(tcx, it.id, selfty);
574585

575-
{
576-
let mut tcache = tcx.tcache.borrow_mut();
577-
tcache.get().insert(local_def(it.id),
578-
ty_param_bounds_and_ty {
579-
generics: i_ty_generics.clone(),
580-
ty: selfty});
581-
}
586+
{
587+
let mut tcache = tcx.tcache.borrow_mut();
588+
tcache.get().insert(local_def(it.id),
589+
ty_param_bounds_and_ty {
590+
generics: i_ty_generics.clone(),
591+
ty: selfty});
592+
}
582593

583-
// If there is a trait reference, treat the methods as always public.
584-
// This is to work around some incorrect behavior in privacy checking:
585-
// when the method belongs to a trait, it should acquire the privacy
586-
// from the trait, not the impl. Forcing the visibility to be public
587-
// makes things sorta work.
588-
let parent_visibility = if opt_trait_ref.is_some() {
589-
ast::Public
590-
} else {
591-
it.vis
592-
};
594+
// If there is a trait reference, treat the methods as always public.
595+
// This is to work around some incorrect behavior in privacy checking:
596+
// when the method belongs to a trait, it should acquire the privacy
597+
// from the trait, not the impl. Forcing the visibility to be public
598+
// makes things sorta work.
599+
let parent_visibility = if opt_trait_ref.is_some() {
600+
ast::Public
601+
} else {
602+
it.vis
603+
};
593604

594-
convert_methods(ccx,
595-
ImplContainer(local_def(it.id)),
596-
*ms,
597-
selfty,
598-
&i_ty_generics,
599-
generics,
600-
parent_visibility);
601-
602-
for trait_ref in opt_trait_ref.iter() {
603-
let trait_ref = instantiate_trait_ref(ccx, trait_ref, selfty);
604-
605-
// Prevent the builtin kind traits from being manually implemented.
606-
if tcx.lang_items.to_builtin_kind(trait_ref.def_id).is_some() {
607-
tcx.sess.span_err(it.span,
608-
"cannot provide an explicit implementation \
609-
for a builtin kind");
605+
convert_methods(ccx,
606+
ImplContainer(local_def(it.id)),
607+
*ms,
608+
selfty,
609+
&i_ty_generics,
610+
generics,
611+
parent_visibility);
612+
613+
for trait_ref in opt_trait_ref.iter() {
614+
let trait_ref = instantiate_trait_ref(ccx, trait_ref, selfty);
615+
616+
// Prevent the builtin kind traits from being manually implemented.
617+
if tcx.lang_items.to_builtin_kind(trait_ref.def_id).is_some() {
618+
tcx.sess.span_err(it.span,
619+
"cannot provide an explicit implementation \
620+
for a builtin kind");
621+
}
610622
}
611-
}
612-
}
613-
ast::ItemTrait(ref generics, _, ref trait_methods) => {
614-
let trait_def = trait_def_of_item(ccx, it);
615-
616-
// Run convert_methods on the provided methods.
617-
let (_, provided_methods) =
618-
split_trait_methods(*trait_methods);
619-
let untransformed_rcvr_ty = ty::mk_self(tcx, local_def(it.id));
620-
convert_methods(ccx,
621-
TraitContainer(local_def(it.id)),
622-
provided_methods,
623-
untransformed_rcvr_ty,
624-
&trait_def.generics,
625-
generics,
626-
it.vis);
627-
628-
// We need to do this *after* converting methods, since
629-
// convert_methods produces a tcache entry that is wrong for
630-
// static trait methods. This is somewhat unfortunate.
631-
ensure_trait_methods(ccx, it.id);
632-
}
633-
ast::ItemStruct(struct_def, ref generics) => {
634-
ensure_no_ty_param_bounds(ccx, it.span, generics, "structure");
635-
636-
// Write the class type
637-
let tpt = ty_of_item(ccx, it);
638-
write_ty_to_tcx(tcx, it.id, tpt.ty);
623+
},
624+
ast::ItemTrait(ref generics, _, ref trait_methods) => {
625+
let trait_def = trait_def_of_item(ccx, it);
626+
627+
// Run convert_methods on the provided methods.
628+
let (_, provided_methods) =
629+
split_trait_methods(*trait_methods);
630+
let untransformed_rcvr_ty = ty::mk_self(tcx, local_def(it.id));
631+
convert_methods(ccx,
632+
TraitContainer(local_def(it.id)),
633+
provided_methods,
634+
untransformed_rcvr_ty,
635+
&trait_def.generics,
636+
generics,
637+
it.vis);
638+
639+
// We need to do this *after* converting methods, since
640+
// convert_methods produces a tcache entry that is wrong for
641+
// static trait methods. This is somewhat unfortunate.
642+
ensure_trait_methods(ccx, it.id);
643+
},
644+
ast::ItemStruct(struct_def, ref generics) => {
645+
ensure_no_ty_param_bounds(ccx, it.span, generics, "structure");
646+
647+
// Write the class type
648+
let tpt = ty_of_item(ccx, it);
649+
write_ty_to_tcx(tcx, it.id, tpt.ty);
639650

640-
{
641-
let mut tcache = tcx.tcache.borrow_mut();
642-
tcache.get().insert(local_def(it.id), tpt.clone());
643-
}
651+
{
652+
let mut tcache = tcx.tcache.borrow_mut();
653+
tcache.get().insert(local_def(it.id), tpt.clone());
654+
}
644655

645-
convert_struct(ccx, struct_def, tpt, it.id);
646-
}
647-
ast::ItemTy(_, ref generics) => {
648-
ensure_no_ty_param_bounds(ccx, it.span, generics, "type");
649-
let tpt = ty_of_item(ccx, it);
650-
write_ty_to_tcx(tcx, it.id, tpt.ty);
651-
}
652-
_ => {
653-
// This call populates the type cache with the converted type
654-
// of the item in passing. All we have to do here is to write
655-
// it into the node type table.
656-
let tpt = ty_of_item(ccx, it);
657-
write_ty_to_tcx(tcx, it.id, tpt.ty);
658-
}
656+
convert_struct(ccx, struct_def, tpt, it.id);
657+
},
658+
ast::ItemTy(_, ref generics) => {
659+
ensure_no_ty_param_bounds(ccx, it.span, generics, "type");
660+
let tpt = ty_of_item(ccx, it);
661+
write_ty_to_tcx(tcx, it.id, tpt.ty);
662+
},
663+
ast::ItemFn(_, _, abi, ref generics, _) => {
664+
ensure_generics_abi(ccx, it.span, abi, generics);
665+
let tpt = ty_of_item(ccx, it);
666+
write_ty_to_tcx(tcx, it.id, tpt.ty);
667+
},
668+
_ => {
669+
// This call populates the type cache with the converted type
670+
// of the item in passing. All we have to do here is to write
671+
// it into the node type table.
672+
let tpt = ty_of_item(ccx, it);
673+
write_ty_to_tcx(tcx, it.id, tpt.ty);
674+
},
659675
}
660676
}
661677

branches/dist-snap/src/libstd/comm/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ impl<T: Send> Packet<T> {
305305
// See the discussion in the stream implementation for why we we
306306
// might decrement steals.
307307
Some(data) => {
308-
self.steals += 1;
309308
if self.steals > MAX_STEALS {
310309
match self.cnt.swap(0, atomics::SeqCst) {
311310
DISCONNECTED => {
@@ -314,11 +313,12 @@ impl<T: Send> Packet<T> {
314313
n => {
315314
let m = cmp::min(n, self.steals);
316315
self.steals -= m;
317-
self.cnt.fetch_add(n - m, atomics::SeqCst);
316+
self.bump(n - m);
318317
}
319318
}
320319
assert!(self.steals >= 0);
321320
}
321+
self.steals += 1;
322322
Ok(data)
323323
}
324324

branches/dist-snap/src/libstd/comm/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ impl<T: Send> Packet<T> {
213213
// down as much as possible (without going negative), and then
214214
// adding back in whatever we couldn't factor into steals.
215215
Some(data) => {
216-
self.steals += 1;
217216
if self.steals > MAX_STEALS {
218217
match self.cnt.swap(0, atomics::SeqCst) {
219218
DISCONNECTED => {
@@ -222,11 +221,12 @@ impl<T: Send> Packet<T> {
222221
n => {
223222
let m = cmp::min(n, self.steals);
224223
self.steals -= m;
225-
self.cnt.fetch_add(n - m, atomics::SeqCst);
224+
self.bump(n - m);
226225
}
227226
}
228227
assert!(self.steals >= 0);
229228
}
229+
self.steals += 1;
230230
match data {
231231
Data(t) => Ok(t),
232232
GoUp(up) => Err(Upgraded(up)),

branches/dist-snap/src/libstd/fmt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -158,7 +158,7 @@ library as well. If no format is specified (as in `{}` or `{:6}`), then the
158158
format trait used is the `Show` trait. This is one of the more commonly
159159
implemented traits when formatting a custom type.
160160
161-
When implementing a format trait for your own time, you will have to implement a
161+
When implementing a format trait for your own type, you will have to implement a
162162
method of the signature:
163163
164164
```rust
@@ -196,7 +196,7 @@ struct Vector2D {
196196
197197
impl fmt::Show for Vector2D {
198198
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
199-
// The `f.buf` value is of the type `&mut io::Writer`, which is what th
199+
// The `f.buf` value is of the type `&mut io::Writer`, which is what the
200200
// write! macro is expecting. Note that this formatting ignores the
201201
// various flags provided to format strings.
202202
write!(f.buf, "({}, {})", self.x, self.y)

branches/dist-snap/src/libstd/num/i16.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ use unstable::intrinsics;
2525
int_module!(i16, 16)
2626

2727
impl Bitwise for i16 {
28-
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
28+
/// Returns the number of ones in the binary representation of the number.
2929
#[inline]
30-
fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }
30+
fn count_ones(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }
3131

32-
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
32+
/// Returns the number of leading zeros in the in the binary representation
33+
/// of the number.
3334
#[inline]
3435
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } }
3536

36-
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
37+
/// Returns the number of trailing zeros in the in the binary representation
38+
/// of the number.
3739
#[inline]
3840
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } }
3941
}

branches/dist-snap/src/libstd/num/i32.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ use unstable::intrinsics;
2525
int_module!(i32, 32)
2626

2727
impl Bitwise for i32 {
28-
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
28+
/// Returns the number of ones in the binary representation of the number.
2929
#[inline]
30-
fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }
30+
fn count_ones(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }
3131

32-
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
32+
/// Returns the number of leading zeros in the in the binary representation
33+
/// of the number.
3334
#[inline]
3435
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } }
3536

36-
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
37+
/// Returns the number of trailing zeros in the in the binary representation
38+
/// of the number.
3739
#[inline]
3840
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } }
3941
}

branches/dist-snap/src/libstd/num/i64.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ use unstable::intrinsics;
2727
int_module!(i64, 64)
2828

2929
impl Bitwise for i64 {
30-
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
30+
/// Returns the number of ones in the binary representation of the number.
3131
#[inline]
32-
fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }
32+
fn count_ones(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }
3333

34-
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
34+
/// Returns the number of leading zeros in the in the binary representation
35+
/// of the number.
3536
#[inline]
3637
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } }
3738

38-
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
39+
/// Counts the number of trailing zeros.
3940
#[inline]
4041
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } }
4142
}

0 commit comments

Comments
 (0)