Skip to content

Commit 19d4186

Browse files
committed
---
yaml --- r: 111387 b: refs/heads/master c: 3b9ade0 h: refs/heads/master i: 111385: 280db65 111383: 5a7e710 v: v3
1 parent 3de545c commit 19d4186

File tree

18 files changed

+166
-451
lines changed

18 files changed

+166
-451
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: 3f8e68686f826ed333321a6650481162c95911f6
2+
refs/heads/master: 3b9ade0f81d519733940ec28b796c11fdb0fd17b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b5dd3f05fe95168b5569d0f519636149479eb6ac
55
refs/heads/try: 38201d7c6bf0c32b0e5bdc8ecd63976ebc1b3a4c

trunk/src/libcollections/bitv.rs

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ impl SmallBitv {
9797
pub fn set_all(&mut self) { self.bits = !0; }
9898

9999
#[inline]
100-
pub fn all(&self, nbits: uint) -> bool {
100+
pub fn is_true(&self, nbits: uint) -> bool {
101101
small_mask(nbits) & !self.bits == 0
102102
}
103103

104104
#[inline]
105-
pub fn none(&self, nbits: uint) -> bool {
105+
pub fn is_false(&self, nbits: uint) -> bool {
106106
small_mask(nbits) & self.bits == 0
107107
}
108108

@@ -412,10 +412,13 @@ impl Bitv {
412412

413413
/// Returns `true` if all bits are 1
414414
#[inline]
415-
pub fn all(&self) -> bool {
415+
pub fn is_true(&self) -> bool {
416416
match self.rep {
417-
Small(ref b) => b.all(self.nbits),
418-
_ => self.iter().all(|x| x)
417+
Small(ref b) => b.is_true(self.nbits),
418+
_ => {
419+
for i in self.iter() { if !i { return false; } }
420+
true
421+
}
419422
}
420423
}
421424

@@ -430,19 +433,16 @@ impl Bitv {
430433
}
431434

432435
/// Returns `true` if all bits are 0
433-
pub fn none(&self) -> bool {
436+
pub fn is_false(&self) -> bool {
434437
match self.rep {
435-
Small(ref b) => b.none(self.nbits),
436-
_ => self.iter().all(|x| !x)
438+
Small(ref b) => b.is_false(self.nbits),
439+
Big(_) => {
440+
for i in self.iter() { if i { return false; } }
441+
true
442+
}
437443
}
438444
}
439445

440-
#[inline]
441-
/// Returns `true` if any bit is 1
442-
pub fn any(&self) -> bool {
443-
!self.none()
444-
}
445-
446446
pub fn init_to_vec(&self, i: uint) -> uint {
447447
return if self.get(i) { 1 } else { 0 };
448448
}
@@ -1551,51 +1551,6 @@ mod tests {
15511551
assert!(b.contains(&1000));
15521552
}
15531553

1554-
#[test]
1555-
fn test_small_bitv_tests() {
1556-
let v = from_bytes([0]);
1557-
assert!(!v.all());
1558-
assert!(!v.any());
1559-
assert!(v.none());
1560-
1561-
let v = from_bytes([0b00010100]);
1562-
assert!(!v.all());
1563-
assert!(v.any());
1564-
assert!(!v.none());
1565-
1566-
let v = from_bytes([0xFF]);
1567-
assert!(v.all());
1568-
assert!(v.any());
1569-
assert!(!v.none());
1570-
}
1571-
1572-
#[test]
1573-
fn test_big_bitv_tests() {
1574-
let v = from_bytes([ // 88 bits
1575-
0, 0, 0, 0,
1576-
0, 0, 0, 0,
1577-
0, 0, 0]);
1578-
assert!(!v.all());
1579-
assert!(!v.any());
1580-
assert!(v.none());
1581-
1582-
let v = from_bytes([ // 88 bits
1583-
0, 0, 0b00010100, 0,
1584-
0, 0, 0, 0b00110100,
1585-
0, 0, 0]);
1586-
assert!(!v.all());
1587-
assert!(v.any());
1588-
assert!(!v.none());
1589-
1590-
let v = from_bytes([ // 88 bits
1591-
0xFF, 0xFF, 0xFF, 0xFF,
1592-
0xFF, 0xFF, 0xFF, 0xFF,
1593-
0xFF, 0xFF, 0xFF]);
1594-
assert!(v.all());
1595-
assert!(v.any());
1596-
assert!(!v.none());
1597-
}
1598-
15991554
fn rng() -> rand::IsaacRng {
16001555
let seed = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
16011556
rand::SeedableRng::from_seed(seed)

trunk/src/librustc/metadata/creader.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ fn resolve_crate<'a>(e: &mut Env,
300300
dylib, rlib, metadata
301301
} = load_ctxt.load_library_crate(root);
302302

303+
// Claim this crate number and cache it
304+
let cnum = e.next_crate_num;
305+
e.next_crate_num += 1;
306+
303307
// Stash paths for top-most crate locally if necessary.
304308
let crate_paths = if root.is_none() {
305309
Some(CratePaths {
@@ -320,17 +324,6 @@ fn resolve_crate<'a>(e: &mut Env,
320324
@RefCell::new(HashMap::new())
321325
};
322326

323-
// Claim this crate number and cache it if we're linking to the
324-
// crate, otherwise it's a syntax-only crate and we don't need to
325-
// reserve a number
326-
let cnum = if should_link {
327-
let n = e.next_crate_num;
328-
e.next_crate_num += 1;
329-
n
330-
} else {
331-
-1
332-
};
333-
334327
let cmeta = @cstore::crate_metadata {
335328
name: load_ctxt.crate_id.name.to_owned(),
336329
data: metadata,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ pub fn monomorphic_fn(ccx: &CrateContext,
272272
}
273273

274274
// Ugh -- but this ensures any new variants won't be forgotten
275-
ast_map::NodeLifetime(..) |
276275
ast_map::NodeExpr(..) |
277276
ast_map::NodeStmt(..) |
278277
ast_map::NodeArg(..) |

trunk/src/librustc/middle/typeck/variance.rs

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ use arena::Arena;
198198
use middle::ty;
199199
use std::fmt;
200200
use syntax::ast;
201-
use syntax::ast_map;
202201
use syntax::ast_util;
203202
use syntax::owned_slice::OwnedSlice;
204203
use syntax::visit;
@@ -518,13 +517,6 @@ impl<'a> Visitor<()> for ConstraintContext<'a> {
518517
}
519518
}
520519

521-
/// Is `param_id` a lifetime according to `map`?
522-
fn is_lifetime(map: &ast_map::Map, param_id: ast::NodeId) -> bool {
523-
match map.find(param_id) {
524-
Some(ast_map::NodeLifetime(..)) => true, _ => false
525-
}
526-
}
527-
528520
impl<'a> ConstraintContext<'a> {
529521
fn tcx(&self) -> &'a ty::ctxt {
530522
self.terms_cx.tcx
@@ -541,70 +533,6 @@ impl<'a> ConstraintContext<'a> {
541533
}
542534
}
543535

544-
fn find_binding_for_lifetime(&self, param_id: ast::NodeId) -> ast::NodeId {
545-
let tcx = self.terms_cx.tcx;
546-
assert!(is_lifetime(&tcx.map, param_id));
547-
match tcx.named_region_map.find(&param_id) {
548-
Some(&ast::DefEarlyBoundRegion(_, lifetime_decl_id))
549-
=> lifetime_decl_id,
550-
Some(_) => fail!("should not encounter non early-bound cases"),
551-
552-
// The lookup should only fail when `param_id` is
553-
// itself a lifetime binding: use it as the decl_id.
554-
None => param_id,
555-
}
556-
557-
}
558-
559-
/// Is `param_id` a type parameter for which we infer variance?
560-
fn is_to_be_inferred(&self, param_id: ast::NodeId) -> bool {
561-
let result = self.terms_cx.inferred_map.contains_key(&param_id);
562-
563-
// To safe-guard against invalid inferred_map constructions,
564-
// double-check if variance is inferred at some use of a type
565-
// parameter (by inspecting parent of its binding declaration
566-
// to see if it is introduced by a type or by a fn/impl).
567-
568-
let check_result = |this:&ConstraintContext| -> bool {
569-
let tcx = this.terms_cx.tcx;
570-
let decl_id = this.find_binding_for_lifetime(param_id);
571-
// Currently only called on lifetimes; double-checking that.
572-
assert!(is_lifetime(&tcx.map, param_id));
573-
let parent_id = tcx.map.get_parent(decl_id);
574-
let parent = tcx.map.find(parent_id).unwrap_or_else(
575-
|| fail!("tcx.map missing entry for id: {}", parent_id));
576-
577-
let is_inferred;
578-
macro_rules! cannot_happen { () => { {
579-
fail!("invalid parent: {:s} for {:s}",
580-
tcx.map.node_to_str(parent_id),
581-
tcx.map.node_to_str(param_id));
582-
} } }
583-
584-
match parent {
585-
ast_map::NodeItem(p) => {
586-
match p.node {
587-
ast::ItemTy(..) |
588-
ast::ItemEnum(..) |
589-
ast::ItemStruct(..) |
590-
ast::ItemTrait(..) => is_inferred = true,
591-
ast::ItemFn(..) => is_inferred = false,
592-
_ => cannot_happen!(),
593-
}
594-
}
595-
ast_map::NodeTraitMethod(..) => is_inferred = false,
596-
ast_map::NodeMethod(_) => is_inferred = false,
597-
_ => cannot_happen!(),
598-
}
599-
600-
return is_inferred;
601-
};
602-
603-
assert_eq!(result, check_result(self));
604-
605-
return result;
606-
}
607-
608536
fn declared_variance(&self,
609537
param_def_id: ast::DefId,
610538
item_def_id: ast::DefId,
@@ -860,10 +788,8 @@ impl<'a> ConstraintContext<'a> {
860788
variance: VarianceTermPtr<'a>) {
861789
match region {
862790
ty::ReEarlyBound(param_id, _, _) => {
863-
if self.is_to_be_inferred(param_id) {
864-
let index = self.inferred_index(param_id);
865-
self.add_constraint(index, variance);
866-
}
791+
let index = self.inferred_index(param_id);
792+
self.add_constraint(index, variance);
867793
}
868794

869795
ty::ReStatic => { }

trunk/src/libstd/intrinsics.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ extern "rust-intrinsic" {
394394

395395
pub fn roundf32(x: f32) -> f32;
396396
pub fn roundf64(x: f64) -> f64;
397-
397+
}
398+
#[cfg(not(stage0))]
399+
extern "rust-intrinsic" {
398400
pub fn ctpop8(x: u8) -> u8;
399401
pub fn ctpop16(x: u16) -> u16;
400402
pub fn ctpop32(x: u32) -> u32;
@@ -413,7 +415,29 @@ extern "rust-intrinsic" {
413415
pub fn bswap16(x: u16) -> u16;
414416
pub fn bswap32(x: u32) -> u32;
415417
pub fn bswap64(x: u64) -> u64;
418+
}
416419

420+
// NOTE: remove this after a snap, and merge the extern block above
421+
macro_rules! stage0_hack {
422+
($( $u_ty:ty, $i_ty:ty => $($name:ident),*);*) => {
423+
$(
424+
$(
425+
#[cfg(stage0)]
426+
pub unsafe fn $name(x: $u_ty) -> $u_ty {
427+
extern "rust-intrinsic" { fn $name(x: $i_ty) -> $i_ty; }
428+
$name(x as $i_ty) as $u_ty
429+
}
430+
)*)*
431+
}
432+
}
433+
stage0_hack! {
434+
u8, i8 => ctpop8, ctlz8, cttz8;
435+
u16, i16 => ctpop16, ctlz16, cttz16, bswap16;
436+
u32, i32 => ctpop32, ctlz32, cttz32, bswap32;
437+
u64, i64 => ctpop64, ctlz64, cttz64, bswap64
438+
}
439+
440+
extern "rust-intrinsic" {
417441
pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool);
418442
pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool);
419443
pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool);

trunk/src/libsyntax/ast_map.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ pub enum Node {
107107

108108
/// NodeStructCtor represents a tuple struct.
109109
NodeStructCtor(@StructDef),
110-
111-
NodeLifetime(@Lifetime),
112110
}
113111

114112
// The odd layout is to bring down the total size.
@@ -129,7 +127,6 @@ enum MapEntry {
129127
EntryLocal(NodeId, @Pat),
130128
EntryBlock(NodeId, P<Block>),
131129
EntryStructCtor(NodeId, @StructDef),
132-
EntryLifetime(NodeId, @Lifetime),
133130

134131
// Roots for node trees.
135132
RootCrate,
@@ -156,7 +153,6 @@ impl MapEntry {
156153
EntryLocal(id, _) => id,
157154
EntryBlock(id, _) => id,
158155
EntryStructCtor(id, _) => id,
159-
EntryLifetime(id, _) => id,
160156
_ => return None
161157
})
162158
}
@@ -174,7 +170,6 @@ impl MapEntry {
174170
EntryLocal(_, p) => NodeLocal(p),
175171
EntryBlock(_, p) => NodeBlock(p),
176172
EntryStructCtor(_, p) => NodeStructCtor(p),
177-
EntryLifetime(_, p) => NodeLifetime(p),
178173
_ => return None
179174
})
180175
}
@@ -218,8 +213,6 @@ impl Map {
218213
self.find_entry(id).and_then(|x| x.to_node())
219214
}
220215

221-
/// Retrieve the parent NodeId for `id`, or `id` itself if no
222-
/// parent is registered in this map.
223216
pub fn get_parent(&self, id: NodeId) -> NodeId {
224217
self.find_entry(id).and_then(|x| x.parent()).unwrap_or(id)
225218
}
@@ -507,15 +500,6 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
507500
SmallVector::one(stmt)
508501
}
509502

510-
fn fold_type_method(&mut self, m: &TypeMethod) -> TypeMethod {
511-
let parent = self.parent;
512-
self.parent = DUMMY_NODE_ID;
513-
let m = fold::noop_fold_type_method(m, self);
514-
assert_eq!(self.parent, m.id);
515-
self.parent = parent;
516-
m
517-
}
518-
519503
fn fold_method(&mut self, m: @Method) -> @Method {
520504
let parent = self.parent;
521505
self.parent = DUMMY_NODE_ID;
@@ -538,12 +522,6 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
538522
self.insert(block.id, EntryBlock(self.parent, block));
539523
block
540524
}
541-
542-
fn fold_lifetime(&mut self, lifetime: &Lifetime) -> Lifetime {
543-
let lifetime = fold::noop_fold_lifetime(lifetime, self);
544-
self.insert(lifetime.id, EntryLifetime(self.parent, @lifetime));
545-
lifetime
546-
}
547525
}
548526

549527
pub fn map_crate<F: FoldOps>(krate: Crate, fold_ops: F) -> (Crate, Map) {
@@ -680,9 +658,6 @@ fn node_id_to_str(map: &Map, id: NodeId) -> ~str {
680658
Some(NodeStructCtor(_)) => {
681659
format!("struct_ctor {} (id={})", map.path_to_str(id), id)
682660
}
683-
Some(NodeLifetime(ref l)) => {
684-
format!("lifetime {} (id={})", pprust::lifetime_to_str(*l), id)
685-
}
686661
None => {
687662
format!("unknown node (id={})", id)
688663
}

0 commit comments

Comments
 (0)