Skip to content

Commit 6424a4b

Browse files
---
yaml --- r: 219519 b: refs/heads/snap-stage3 c: 3f9fc39 h: refs/heads/master i: 219517: ced5ace 219515: d6b7092 219511: 9933e17 219503: 58ff664 219487: e696f19 219455: aeb1096 219391: 298946b v: v3
1 parent 3f5888c commit 6424a4b

File tree

31 files changed

+788
-770
lines changed

31 files changed

+788
-770
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: c044791d80ea0dc5c4b57b6030a67b69f8510239
3-
refs/heads/snap-stage3: 3223c885b925d0cde92aaf900fa32dbcc5c8318c
3+
refs/heads/snap-stage3: 3f9fc39ab91a4d75b9499d3b3591db875649a0b7
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/src/doc/style/features/traits/generics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ yielding items of type `A` to produce a collection of `A`:
88
fn from_iter<T: Iterator<A>>(iterator: T) -> SomeCollection<A>
99
```
1010

11-
Here, the `Iterator` trait specifies an interface that a type `T` must
11+
Here, the `Iterator` trait is specifies an interface that a type `T` must
1212
explicitly implement to be used by this generic function.
1313

1414
**Pros**:

branches/snap-stage3/src/doc/trpl/error-handling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ There's another way of doing this that's a bit nicer than `unwrap()`:
225225

226226
```rust,ignore
227227
let mut buffer = String::new();
228-
let num_bytes_read = io::stdin().read_line(&mut buffer)
229-
.ok()
230-
.expect("Failed to read line");
228+
let input = io::stdin().read_line(&mut buffer)
229+
.ok()
230+
.expect("Failed to read line");
231231
```
232232

233233
`ok()` converts the `Result` into an `Option`, and `expect()` does the same

branches/snap-stage3/src/librustc/metadata/tydecode.rs

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ pub fn parse_substs_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: us
195195
parse_substs(&mut st, conv)
196196
}
197197

198+
pub fn parse_bounds_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum,
199+
pos: usize, tcx: &ty::ctxt<'tcx>, conv: F)
200+
-> ty::ParamBounds<'tcx> where
201+
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
202+
{
203+
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
204+
parse_bounds(&mut st, conv)
205+
}
206+
198207
pub fn parse_existential_bounds_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum,
199208
pos: usize, tcx: &ty::ctxt<'tcx>, conv: F)
200209
-> ty::ExistentialBounds<'tcx> where
@@ -870,23 +879,11 @@ fn parse_existential_bounds_<'a,'tcx, F>(st: &mut PState<'a,'tcx>,
870879
-> ty::ExistentialBounds<'tcx> where
871880
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
872881
{
873-
let builtin_bounds = parse_builtin_bounds_(st, conv);
874-
let region_bound = parse_region_(st, conv);
875-
let mut projection_bounds = Vec::new();
876-
877-
loop {
878-
match next(st) {
879-
'P' => {
880-
projection_bounds.push(
881-
ty::Binder(parse_projection_predicate_(st, conv)));
882-
}
883-
'.' => { break; }
884-
c => {
885-
panic!("parse_bounds: bad bounds ('{}')", c)
886-
}
887-
}
888-
}
889-
882+
let ty::ParamBounds { trait_bounds, mut region_bounds, builtin_bounds, projection_bounds } =
883+
parse_bounds_(st, conv);
884+
assert_eq!(region_bounds.len(), 1);
885+
assert_eq!(trait_bounds.len(), 0);
886+
let region_bound = region_bounds.pop().unwrap();
890887
return ty::ExistentialBounds { region_bound: region_bound,
891888
builtin_bounds: builtin_bounds,
892889
projection_bounds: projection_bounds };
@@ -926,3 +923,60 @@ fn parse_builtin_bounds_<F>(st: &mut PState, _conv: &mut F) -> ty::BuiltinBounds
926923
}
927924
}
928925
}
926+
927+
fn parse_bounds<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, mut conv: F)
928+
-> ty::ParamBounds<'tcx> where
929+
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
930+
{
931+
parse_bounds_(st, &mut conv)
932+
}
933+
934+
fn parse_bounds_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
935+
-> ty::ParamBounds<'tcx> where
936+
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
937+
{
938+
let builtin_bounds = parse_builtin_bounds_(st, conv);
939+
940+
let region_bounds = parse_region_bounds_(st, conv);
941+
942+
let mut param_bounds = ty::ParamBounds {
943+
region_bounds: region_bounds,
944+
builtin_bounds: builtin_bounds,
945+
trait_bounds: Vec::new(),
946+
projection_bounds: Vec::new(),
947+
};
948+
949+
950+
loop {
951+
match next(st) {
952+
'I' => {
953+
param_bounds.trait_bounds.push(
954+
ty::Binder(parse_trait_ref_(st, conv)));
955+
}
956+
'P' => {
957+
param_bounds.projection_bounds.push(
958+
ty::Binder(parse_projection_predicate_(st, conv)));
959+
}
960+
'.' => {
961+
return param_bounds;
962+
}
963+
c => {
964+
panic!("parse_bounds: bad bounds ('{}')", c)
965+
}
966+
}
967+
}
968+
}
969+
970+
fn parse_region_bounds_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
971+
-> Vec<ty::Region> where
972+
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
973+
{
974+
let mut region_bounds = Vec::new();
975+
loop {
976+
match next(st) {
977+
'R' => { region_bounds.push(parse_region_(st, conv)); }
978+
'.' => { return region_bounds; }
979+
c => { panic!("parse_bounds: bad bounds ('{}')", c); }
980+
}
981+
}
982+
}

branches/snap-stage3/src/librustc/metadata/tyencode.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,23 @@ pub fn enc_builtin_bounds(w: &mut Encoder, _cx: &ctxt, bs: &ty::BuiltinBounds) {
380380
pub fn enc_existential_bounds<'a,'tcx>(w: &mut Encoder,
381381
cx: &ctxt<'a,'tcx>,
382382
bs: &ty::ExistentialBounds<'tcx>) {
383+
let param_bounds = ty::ParamBounds { trait_bounds: vec!(),
384+
region_bounds: vec!(bs.region_bound),
385+
builtin_bounds: bs.builtin_bounds,
386+
projection_bounds: bs.projection_bounds.clone() };
387+
enc_bounds(w, cx, &param_bounds);
388+
}
389+
390+
pub fn enc_bounds<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
391+
bs: &ty::ParamBounds<'tcx>) {
383392
enc_builtin_bounds(w, cx, &bs.builtin_bounds);
384393

385-
enc_region(w, cx, bs.region_bound);
394+
enc_region_bounds(w, cx, &bs.region_bounds);
395+
396+
for tp in &bs.trait_bounds {
397+
mywrite!(w, "I");
398+
enc_trait_ref(w, cx, tp.0);
399+
}
386400

387401
for tp in &bs.projection_bounds {
388402
mywrite!(w, "P");

branches/snap-stage3/src/librustc/middle/check_match.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub use self::Constructor::*;
1212
use self::Usefulness::*;
1313
use self::WitnessPreference::*;
1414

15-
use middle::const_eval::{compare_const_vals, ConstVal};
15+
use middle::const_eval::{compare_const_vals, const_bool, const_float, const_val};
1616
use middle::const_eval::{eval_const_expr, eval_const_expr_partial};
1717
use middle::const_eval::{const_expr_to_pat, lookup_const_by_id};
1818
use middle::def::*;
@@ -111,9 +111,9 @@ pub enum Constructor {
111111
/// Enum variants.
112112
Variant(ast::DefId),
113113
/// Literal values.
114-
ConstantValue(ConstVal),
114+
ConstantValue(const_val),
115115
/// Ranges of literal values (2..5).
116-
ConstantRange(ConstVal, ConstVal),
116+
ConstantRange(const_val, const_val),
117117
/// Array patterns of length n.
118118
Slice(usize),
119119
/// Array patterns with a subslice.
@@ -262,7 +262,7 @@ fn check_for_static_nan(cx: &MatchCheckCtxt, pat: &Pat) {
262262
ast_util::walk_pat(pat, |p| {
263263
if let ast::PatLit(ref expr) = p.node {
264264
match eval_const_expr_partial(cx.tcx, &**expr, None) {
265-
Ok(ConstVal::Float(f)) if f.is_nan() => {
265+
Ok(const_float(f)) if f.is_nan() => {
266266
span_warn!(cx.tcx.sess, p.span, E0003,
267267
"unmatchable NaN in pattern, \
268268
use the is_nan method in a guard instead");
@@ -391,9 +391,9 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: ast:
391391
}
392392
}
393393

394-
fn const_val_to_expr(value: &ConstVal) -> P<ast::Expr> {
394+
fn const_val_to_expr(value: &const_val) -> P<ast::Expr> {
395395
let node = match value {
396-
&ConstVal::Bool(b) => ast::LitBool(b),
396+
&const_bool(b) => ast::LitBool(b),
397397
_ => unreachable!()
398398
};
399399
P(ast::Expr {
@@ -596,7 +596,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
596596
max_slice_length: usize) -> Vec<Constructor> {
597597
match left_ty.sty {
598598
ty::TyBool =>
599-
[true, false].iter().map(|b| ConstantValue(ConstVal::Bool(*b))).collect(),
599+
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
600600

601601
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
602602
ty::TySlice(_) =>
@@ -826,7 +826,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
826826
}
827827

828828
fn range_covered_by_constructor(ctor: &Constructor,
829-
from: &ConstVal, to: &ConstVal) -> Option<bool> {
829+
from: &const_val, to: &const_val) -> Option<bool> {
830830
let (c_from, c_to) = match *ctor {
831831
ConstantValue(ref value) => (value, value),
832832
ConstantRange(ref from, ref to) => (from, to),

0 commit comments

Comments
 (0)