Skip to content

Commit 2ca6eae

Browse files
committed
Auto merge of #22963 - Manishearth:rollup, r=Manishearth
2 parents 1cc8b6e + c4b1500 commit 2ca6eae

34 files changed

+125
-268
lines changed

src/doc/intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,10 @@ numbers[1] is 3
510510
numbers[0] is 2
511511
```
512512
513-
Each time, we can get a slithtly different output because the threads
514-
are not quaranteed to run in any set order. If you get the same order
515-
every time it is because each of these threads are very small and
516-
complete too fast for their indeterminate behavior to surface.
513+
Each time, we can get a slightly different output because the threads are not
514+
guaranteed to run in any set order. If you get the same order every time it is
515+
because each of these threads are very small and complete too fast for their
516+
indeterminate behavior to surface.
517517
518518
The important part here is that the Rust compiler was able to use ownership to
519519
give us assurance _at compile time_ that we weren't doing something incorrect

src/doc/trpl/guessing-game.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,11 @@ In this case, we say `x` is a `u32` explicitly, so Rust is able to properly
422422
tell `random()` what to generate. In a similar fashion, both of these work:
423423
424424
```{rust,ignore}
425-
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426-
let input_num: Result<u32, _> = "5".parse(); // input_num: Result<u32, <u32 as FromStr>::Err>
425+
let input_num_option = "5".parse::<u32>().ok(); // input_num: Option<u32>
426+
let input_num_result: Result<u32, _> = "5".parse(); // input_num: Result<u32, <u32 as FromStr>::Err>
427427
```
428428
429-
Here we're converting the `Result` returned by `parse` to an `Option` by using
429+
Above, we're converting the `Result` returned by `parse` to an `Option` by using
430430
the `ok` method as well. Anyway, with us now converting our input to a number,
431431
our code looks like this:
432432
@@ -470,14 +470,14 @@ Let's try it out!
470470
```bash
471471
$ cargo build
472472
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
473-
src/main.rs:22:15: 22:24 error: mismatched types: expected `u32` but found `core::option::Option<u32>` (expected u32 but found enum core::option::Option)
474-
src/main.rs:22 match cmp(input_num, secret_number) {
473+
src/main.rs:21:15: 21:24 error: mismatched types: expected `u32`, found `core::result::Result<u32, core::num::ParseIntError>` (expected u32, found enum `core::result::Result`) [E0308]
474+
src/main.rs:21 match cmp(input_num, secret_number) {
475475
^~~~~~~~~
476476
error: aborting due to previous error
477477
```
478478
479-
Oh yeah! Our `input_num` has the type `Option<u32>`, rather than `u32`. We
480-
need to unwrap the Option. If you remember from before, `match` is a great way
479+
Oh yeah! Our `input_num` has the type `Result<u32, <some error>>`, rather than `u32`. We
480+
need to unwrap the Result. If you remember from before, `match` is a great way
481481
to do that. Try this code:
482482
483483
```{rust,no_run}
@@ -500,7 +500,7 @@ fn main() {
500500
let input_num: Result<u32, _> = input.parse();
501501

502502
let num = match input_num {
503-
Ok(num) => num,
503+
Ok(n) => n,
504504
Err(_) => {
505505
println!("Please input a number!");
506506
return;
@@ -524,7 +524,7 @@ fn cmp(a: u32, b: u32) -> Ordering {
524524
}
525525
```
526526
527-
We use a `match` to either give us the `u32` inside of the `Option`, or else
527+
We use a `match` to either give us the `u32` inside of the `Result`, or else
528528
print an error message and return. Let's give this a shot:
529529
530530
```bash

src/libcollections/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
//! * `o` - precedes the argument with a "0o"
365365
//! * '0' - This is used to indicate for integer formats that the padding should
366366
//! both be done with a `0` character as well as be sign-aware. A format
367-
//! like `{:08d}` would yield `00000001` for the integer `1`, while the
367+
//! like `{:08}` would yield `00000001` for the integer `1`, while the
368368
//! same format would yield `-0000001` for the integer `-1`. Notice that
369369
//! the negative version has one fewer zero than the positive version.
370370
//!

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,9 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
555555
'k' => {
556556
assert_eq!(next(st), '[');
557557
let did = parse_def_(st, ClosureSource, conv);
558-
let region = parse_region_(st, conv);
559558
let substs = parse_substs_(st, conv);
560559
assert_eq!(next(st), ']');
561-
return ty::mk_closure(st.tcx, did,
562-
st.tcx.mk_region(region), st.tcx.mk_substs(substs));
560+
return ty::mk_closure(st.tcx, did, st.tcx.mk_substs(substs));
563561
}
564562
'P' => {
565563
assert_eq!(next(st), '[');

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
139139
enc_substs(w, cx, substs);
140140
mywrite!(w, "]");
141141
}
142-
ty::ty_closure(def, region, substs) => {
142+
ty::ty_closure(def, substs) => {
143143
mywrite!(w, "k[{}|", (cx.ds)(def));
144-
enc_region(w, cx, *region);
145144
enc_substs(w, cx, substs);
146145
mywrite!(w, "]");
147146
}

src/librustc/middle/fast_reject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn simplify_type(tcx: &ty::ctxt,
7474
let def_id = tcx.lang_items.owned_box().unwrap();
7575
Some(StructSimplifiedType(def_id))
7676
}
77-
ty::ty_closure(def_id, _, _) => {
77+
ty::ty_closure(def_id, _) => {
7878
Some(ClosureSimplifiedType(def_id))
7979
}
8080
ty::ty_tup(ref tys) => {

src/librustc/middle/infer/combine.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,15 +503,14 @@ pub fn super_tys<'tcx, C>(this: &C,
503503
Ok(ty::mk_struct(tcx, a_id, tcx.mk_substs(substs)))
504504
}
505505

506-
(&ty::ty_closure(a_id, a_region, a_substs),
507-
&ty::ty_closure(b_id, b_region, b_substs))
506+
(&ty::ty_closure(a_id, a_substs),
507+
&ty::ty_closure(b_id, b_substs))
508508
if a_id == b_id => {
509509
// All ty_closure types with the same id represent
510510
// the (anonymous) type of the same closure expression. So
511511
// all of their regions should be equated.
512-
let region = try!(this.equate().regions(*a_region, *b_region));
513512
let substs = try!(this.substs_variances(None, a_substs, b_substs));
514-
Ok(ty::mk_closure(tcx, a_id, tcx.mk_region(region), tcx.mk_substs(substs)))
513+
Ok(ty::mk_closure(tcx, a_id, tcx.mk_substs(substs)))
515514
}
516515

517516
(&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => {

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
14961496
fn fn_ret(&self, id: NodeId) -> ty::PolyFnOutput<'tcx> {
14971497
let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
14981498
match fn_ty.sty {
1499-
ty::ty_closure(closure_def_id, _, substs) =>
1499+
ty::ty_closure(closure_def_id, substs) =>
15001500
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
15011501
_ =>
15021502
ty::ty_fn_ret(fn_ty),

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
607607
def::DefUpvar(var_id, fn_node_id) => {
608608
let ty = try!(self.node_ty(fn_node_id));
609609
match ty.sty {
610-
ty::ty_closure(closure_id, _, _) => {
610+
ty::ty_closure(closure_id, _) => {
611611
match self.typer.closure_kind(closure_id) {
612612
Some(kind) => {
613613
self.cat_upvar(id, span, var_id, fn_node_id, kind)

src/librustc/middle/region.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ impl InnermostEnclosingExpr {
320320

321321
#[derive(Debug, Copy)]
322322
pub struct Context {
323+
/// the scope that contains any new variables declared
323324
var_parent: InnermostDeclaringBlock,
324325

326+
/// region parent of expressions etc
325327
parent: InnermostEnclosingExpr,
326328
}
327329

0 commit comments

Comments
 (0)