Skip to content

Commit f0efdad

Browse files
author
Richard Diamond
committed
---
yaml --- r: 150896 b: refs/heads/try2 c: 506008f h: refs/heads/master v: v3
1 parent 203ffb0 commit f0efdad

33 files changed

+163
-598
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: 29a39700a1a46de2046bd6913da9c38d064a5a8f
8+
refs/heads/try2: 506008f9a0334fe5381397cac2f2f3ca85f1a6d6
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)

branches/try2/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,

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,9 +3507,8 @@ impl<'a> Resolver<'a> {
35073507
// its scope.
35083508

35093509
self.resolve_error(span,
3510-
"can't use type parameters from \
3511-
outer function; try using a local \
3512-
type parameter instead");
3510+
"attempt to use a type \
3511+
argument out of scope");
35133512
}
35143513

35153514
return None;
@@ -3531,9 +3530,8 @@ impl<'a> Resolver<'a> {
35313530
// its scope.
35323531

35333532
self.resolve_error(span,
3534-
"can't use type parameters from \
3535-
outer function; try using a local \
3536-
type parameter instead");
3533+
"attempt to use a type \
3534+
argument out of scope");
35373535
}
35383536

35393537
return None;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ impl<'a> TypeFolder for SubstFolder<'a> {
9595
root.repr(self.tcx)),
9696
None => ~""
9797
};
98-
let m = format!("can't use type parameters from outer \
99-
function{}; try using a local type \
100-
parameter instead", root_msg);
98+
let m = format!("missing type param `{}`{}",
99+
t.repr(self.tcx), root_msg);
101100
match self.span {
102101
Some(span) => self.tcx.sess.span_err(span, m),
103102
None => self.tcx.sess.err(m)

branches/try2/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(..) |

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,13 +2416,13 @@ pub enum Representability {
24162416

24172417
/// Check whether a type is representable. This means it cannot contain unboxed
24182418
/// structural recursion. This check is needed for structs and enums.
2419-
pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
2419+
pub fn is_type_representable(cx: &ctxt, ty: t) -> Representability {
24202420

24212421
// Iterate until something non-representable is found
2422-
fn find_nonrepresentable<It: Iterator<t>>(cx: &ctxt, sp: Span, seen: &mut Vec<DefId>,
2422+
fn find_nonrepresentable<It: Iterator<t>>(cx: &ctxt, seen: &mut Vec<DefId>,
24232423
mut iter: It) -> Representability {
24242424
for ty in iter {
2425-
let r = type_structurally_recursive(cx, sp, seen, ty);
2425+
let r = type_structurally_recursive(cx, seen, ty);
24262426
if r != Representable {
24272427
return r
24282428
}
@@ -2432,7 +2432,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
24322432

24332433
// Does the type `ty` directly (without indirection through a pointer)
24342434
// contain any types on stack `seen`?
2435-
fn type_structurally_recursive(cx: &ctxt, sp: Span, seen: &mut Vec<DefId>,
2435+
fn type_structurally_recursive(cx: &ctxt, seen: &mut Vec<DefId>,
24362436
ty: t) -> Representability {
24372437
debug!("type_structurally_recursive: {}",
24382438
::util::ppaux::ty_to_str(cx, ty));
@@ -2455,19 +2455,19 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
24552455
match get(ty).sty {
24562456
// Tuples
24572457
ty_tup(ref ts) => {
2458-
find_nonrepresentable(cx, sp, seen, ts.iter().map(|t| *t))
2458+
find_nonrepresentable(cx, seen, ts.iter().map(|t| *t))
24592459
}
24602460
// Fixed-length vectors.
24612461
// FIXME(#11924) Behavior undecided for zero-length vectors.
24622462
ty_vec(ty, VstoreFixed(_)) => {
2463-
type_structurally_recursive(cx, sp, seen, ty)
2463+
type_structurally_recursive(cx, seen, ty)
24642464
}
24652465

24662466
// Push struct and enum def-ids onto `seen` before recursing.
24672467
ty_struct(did, ref substs) => {
24682468
seen.push(did);
24692469
let fields = struct_fields(cx, did, substs);
2470-
let r = find_nonrepresentable(cx, sp, seen,
2470+
let r = find_nonrepresentable(cx, seen,
24712471
fields.iter().map(|f| f.mt.ty));
24722472
seen.pop();
24732473
r
@@ -2478,10 +2478,8 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
24782478

24792479
let mut r = Representable;
24802480
for variant in vs.iter() {
2481-
let iter = variant.args.iter().map(|aty| {
2482-
aty.subst_spanned(cx, substs, Some(sp))
2483-
});
2484-
r = find_nonrepresentable(cx, sp, seen, iter);
2481+
let iter = variant.args.iter().map(|aty| subst(cx, substs, *aty));
2482+
r = find_nonrepresentable(cx, seen, iter);
24852483

24862484
if r != Representable { break }
24872485
}
@@ -2501,7 +2499,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
25012499
// contains a different, structurally recursive type, maintain a stack
25022500
// of seen types and check recursion for each of them (issues #3008, #3779).
25032501
let mut seen: Vec<DefId> = Vec::new();
2504-
type_structurally_recursive(cx, sp, &mut seen, ty)
2502+
type_structurally_recursive(cx, &mut seen, ty)
25052503
}
25062504

25072505
pub fn type_is_trait(ty: t) -> bool {

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3356,7 +3356,7 @@ pub fn check_representable(tcx: &ty::ctxt,
33563356
// recursive type. It is only necessary to throw an error on those that
33573357
// contain themselves. For case 2, there must be an inner type that will be
33583358
// caught by case 1.
3359-
match ty::is_type_representable(tcx, sp, rty) {
3359+
match ty::is_type_representable(tcx, rty) {
33603360
ty::SelfRecursive => {
33613361
tcx.sess.span_err(
33623362
sp, format!("illegal recursive {} type; \

branches/try2/src/librustc/middle/typeck/collect.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -945,24 +945,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
945945
let param_ty = ty::param_ty {idx: base_index + offset,
946946
def_id: local_def(param.id)};
947947
let bounds = @compute_bounds(ccx, param_ty, &param.bounds);
948-
let default = param.default.map(|path| {
949-
let ty = ast_ty_to_ty(ccx, &ExplicitRscope, path);
950-
let cur_idx = param_ty.idx;
951-
952-
ty::walk_ty(ty, |t| {
953-
match ty::get(t).sty {
954-
ty::ty_param(p) => if p.idx > cur_idx {
955-
ccx.tcx.sess.span_err(path.span,
956-
"type parameters with a default cannot use \
957-
forward declared identifiers")
958-
},
959-
_ => {}
960-
}
961-
});
962-
963-
ty
964-
});
965-
948+
let default = param.default.map(|x| ast_ty_to_ty(ccx, &ExplicitRscope, x));
966949
let def = ty::TypeParameterDef {
967950
ident: param.ident,
968951
def_id: local_def(param.id),

0 commit comments

Comments
 (0)