@@ -38,7 +38,7 @@ checks and effort.
38
38
39
39
Whenever we introduce a borrowed pointer, for example as the result of
40
40
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
42
42
job of adding constraints such that this inference variable is as
43
43
narrow as possible while still accommodating all uses (that is, every
44
44
dereference of the resulting pointer must be within the lifetime).
@@ -95,7 +95,7 @@ the following lattice:
95
95
ty::ImmBorrow -> ty::UniqueImmBorrow -> ty::MutBorrow
96
96
97
97
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`
99
99
we'll do the same. Naturally, this applies not just to the upvar, but
100
100
to everything owned by `x`, so the result is the same for something
101
101
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
107
107
semi-hacky interaction with mem-categorization. In particular,
108
108
mem-categorization will query the current borrow kind as it
109
109
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
111
111
borrow kind (and derived mutabilities) that are returned from
112
112
mem-categorization, since they may be inaccurate. (Another option
113
113
would be to use a unification scheme, where instead of returning a
@@ -698,9 +698,9 @@ fn check_expr_fn_block(rcx: &mut Rcx,
698
698
let inner_upvar_id = ty:: UpvarId {
699
699
var_id : var_id,
700
700
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) ;
704
704
}
705
705
_ => { }
706
706
}
@@ -1114,7 +1114,7 @@ fn link_region_from_node_type(rcx: &mut Rcx,
1114
1114
/*!
1115
1115
* Like `link_region()`, except that the region is
1116
1116
* extracted from the type of `id`, which must be some
1117
- * region-typed thing .
1117
+ * reference (`&T`, `&str`, etc) .
1118
1118
*/
1119
1119
1120
1120
let rptr_ty = rcx. resolve_node_type ( id) ;
@@ -1359,12 +1359,14 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &mut Rcx,
1359
1359
}
1360
1360
}
1361
1361
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 ) {
1365
1365
/*!
1366
1366
* 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.
1368
1370
*/
1369
1371
1370
1372
debug ! ( "link_upvar_borrow_kind: inner_upvar_id={:?} outer_upvar_id={:?}" ,
0 commit comments