Skip to content

Commit ba373a7

Browse files
committed
---
yaml --- r: 227757 b: refs/heads/try c: 81e5c1f h: refs/heads/master i: 227755: 23f7e20 v: v3
1 parent c60d03a commit ba373a7

File tree

16 files changed

+249
-407
lines changed

16 files changed

+249
-407
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 699315e4f5295f31de3888792733e0459cf5fcdc
4+
refs/heads/try: 81e5c1ff061d2538ce2c3832ad33202a0135558d
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/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/try/src/librustc/metadata/tydecode.rs

Lines changed: 17 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,6 @@ 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-
207198
pub fn parse_existential_bounds_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum,
208199
pos: usize, tcx: &ty::ctxt<'tcx>, conv: F)
209200
-> ty::ExistentialBounds<'tcx> where
@@ -879,11 +870,23 @@ fn parse_existential_bounds_<'a,'tcx, F>(st: &mut PState<'a,'tcx>,
879870
-> ty::ExistentialBounds<'tcx> where
880871
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
881872
{
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();
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+
887890
return ty::ExistentialBounds { region_bound: region_bound,
888891
builtin_bounds: builtin_bounds,
889892
projection_bounds: projection_bounds };
@@ -923,60 +926,3 @@ fn parse_builtin_bounds_<F>(st: &mut PState, _conv: &mut F) -> ty::BuiltinBounds
923926
}
924927
}
925928
}
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/try/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,23 +380,9 @@ 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>) {
392383
enc_builtin_bounds(w, cx, &bs.builtin_bounds);
393384

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-
}
385+
enc_region(w, cx, bs.region_bound);
400386

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

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