Skip to content

Commit 484f0f1

Browse files
committed
Correct nits from @pcwalton
1 parent c9e3cb6 commit 484f0f1

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/librustc/middle/mem_categorization.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* ## By-reference upvars
4949
*
5050
* One part of the translation which may be non-obvious is that we translate
51-
* closure upvars into the dereference of a borrow pointer; this more closely
51+
* closure upvars into the dereference of a borrowed pointer; this more closely
5252
* resembles the runtime translation. So, for example, if we had:
5353
*
5454
* let mut x = 3;
@@ -246,7 +246,7 @@ pub struct MemCategorizationContext<TYPER> {
246246
pub type McResult<T> = Result<T, ()>;
247247

248248
/**
249-
* The `Typer` trait provides the interface fro the mem-categorization
249+
* The `Typer` trait provides the interface for the mem-categorization
250250
* module to the results of the type check. It can be used to query
251251
* the type assigned to an expression node, to inquire after adjustments,
252252
* and so on.

src/librustc/middle/typeck/check/regionck.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ checks and effort.
3838
3939
Whenever we introduce a borrowed pointer, for example as the result of
4040
a borrow expression `let x = &data`, the lifetime of the pointer `x`
41-
is always specified as a region inferencr variable. `regionck` has the
41+
is always specified as a region inference variable. `regionck` has the
4242
job of adding constraints such that this inference variable is as
4343
narrow as possible while still accommodating all uses (that is, every
4444
dereference of the resulting pointer must be within the lifetime).
@@ -95,7 +95,7 @@ the following lattice:
9595
ty::ImmBorrow -> ty::UniqueImmBorrow -> ty::MutBorrow
9696
9797
So, for example, if we see an assignment `x = 5` to an upvar `x`, we
98-
will promote it's borrow kind to mutable borrow. If we see an `&mut x`
98+
will promote its borrow kind to mutable borrow. If we see an `&mut x`
9999
we'll do the same. Naturally, this applies not just to the upvar, but
100100
to everything owned by `x`, so the result is the same for something
101101
like `x.f = 5` and so on (presuming `x` is not a borrowed pointer to a
@@ -107,7 +107,7 @@ The fact that we are inferring borrow kinds as we go results in a
107107
semi-hacky interaction with mem-categorization. In particular,
108108
mem-categorization will query the current borrow kind as it
109109
categorizes, and we'll return the *current* value, but this may get
110-
adjusted later. Therefore, in this module, we genreally ignore the
110+
adjusted later. Therefore, in this module, we generally ignore the
111111
borrow kind (and derived mutabilities) that are returned from
112112
mem-categorization, since they may be inaccurate. (Another option
113113
would be to use a unification scheme, where instead of returning a
@@ -698,9 +698,9 @@ fn check_expr_fn_block(rcx: &mut Rcx,
698698
let inner_upvar_id = ty::UpvarId {
699699
var_id: var_id,
700700
closure_expr_id: expr.id };
701-
link_upvar_borrow_kind(rcx,
702-
inner_upvar_id,
703-
outer_upvar_id);
701+
link_upvar_borrow_kind_for_nested_closures(rcx,
702+
inner_upvar_id,
703+
outer_upvar_id);
704704
}
705705
_ => {}
706706
}
@@ -1114,7 +1114,7 @@ fn link_region_from_node_type(rcx: &mut Rcx,
11141114
/*!
11151115
* Like `link_region()`, except that the region is
11161116
* extracted from the type of `id`, which must be some
1117-
* region-typed thing.
1117+
* reference (`&T`, `&str`, etc).
11181118
*/
11191119

11201120
let rptr_ty = rcx.resolve_node_type(id);
@@ -1359,12 +1359,14 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &mut Rcx,
13591359
}
13601360
}
13611361

1362-
fn link_upvar_borrow_kind(rcx: &mut Rcx,
1363-
inner_upvar_id: ty::UpvarId,
1364-
outer_upvar_id: ty::UpvarId) {
1362+
fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx,
1363+
inner_upvar_id: ty::UpvarId,
1364+
outer_upvar_id: ty::UpvarId) {
13651365
/*!
13661366
* Indicates that the borrow_kind of `outer_upvar_id` must
1367-
* permit a reborrowing with the borrow_kind of `inner_upvar_id`
1367+
* permit a reborrowing with the borrow_kind of `inner_upvar_id`.
1368+
* This occurs in nested closures, see comment above at the call to
1369+
* this function.
13681370
*/
13691371

13701372
debug!("link_upvar_borrow_kind: inner_upvar_id={:?} outer_upvar_id={:?}",

0 commit comments

Comments
 (0)