@@ -134,7 +134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
134
134
// }
135
135
// ```
136
136
//
137
- // cc #46688
137
+ // See issue #46688.
138
138
def_bm = ty:: BindByValue ( hir:: MutImmutable ) ;
139
139
}
140
140
@@ -152,7 +152,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
152
152
let ty = self . node_ty ( lt. hir_id ) ;
153
153
154
154
// Byte string patterns behave the same way as array patterns
155
- // They can denote both statically and dynamically sized byte arrays
155
+ // They can denote both statically and dynamically- sized byte arrays.
156
156
let mut pat_ty = ty;
157
157
if let hir:: ExprKind :: Lit ( ref lt) = lt. node {
158
158
if let ast:: LitKind :: ByteStr ( _) = lt. node {
@@ -166,7 +166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166
166
}
167
167
}
168
168
169
- // somewhat surprising: in this case, the subtyping
169
+ // Somewhat surprising: in this case, the subtyping
170
170
// relation goes the opposite way as the other
171
171
// cases. Actually what we really want is not a subtyping
172
172
// relation at all but rather that there exists a LUB (so
@@ -177,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
177
177
//
178
178
// &'static str <: expected
179
179
//
180
- // that's equivalent to there existing a LUB.
180
+ // then that's equivalent to there existing a LUB.
181
181
if let Some ( mut err) = self . demand_suptype_diag ( pat. span , expected, pat_ty) {
182
182
err. emit_unless ( discrim_span
183
183
. filter ( |& s| s. is_compiler_desugaring ( CompilerDesugaringKind :: IfTemporary ) )
@@ -230,7 +230,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
230
230
// it to type the entire expression.
231
231
let common_type = self . resolve_vars_if_possible ( & lhs_ty) ;
232
232
233
- // subtyping doesn't matter here, as the value is some kind of scalar
233
+ // Subtyping doesn't matter here, as the value is some kind of scalar.
234
234
self . demand_eqtype_pat ( pat. span , expected, lhs_ty, discrim_span) ;
235
235
self . demand_eqtype_pat ( pat. span , expected, rhs_ty, discrim_span) ;
236
236
common_type
@@ -250,8 +250,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
250
250
let local_ty = self . local_ty ( pat. span , pat. hir_id ) . decl_ty ;
251
251
match bm {
252
252
ty:: BindByReference ( mutbl) => {
253
- // if the binding is like
254
- // ref x | ref const x | ref mut x
253
+ // If the binding is like
254
+ // ref x | ref const x | ref mut x
255
255
// then `x` is assigned a value of type `&M T` where M is the mutability
256
256
// and T is the expected type.
257
257
let region_var = self . next_region_var ( infer:: PatternRegion ( pat. span ) ) ;
@@ -263,16 +263,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263
263
// an explanation.
264
264
self . demand_eqtype_pat ( pat. span , region_ty, local_ty, discrim_span) ;
265
265
}
266
- // otherwise the type of x is the expected type T
266
+ // Otherwise, the type of x is the expected type `T`.
267
267
ty:: BindByValue ( _) => {
268
- // As above, `T <: typeof(x)` is required but we
268
+ // As above, `T <: typeof(x)` is required, but we
269
269
// use equality, see (*) below.
270
270
self . demand_eqtype_pat ( pat. span , expected, local_ty, discrim_span) ;
271
271
}
272
272
}
273
273
274
- // if there are multiple arms, make sure they all agree on
275
- // what the type of the binding `x` ought to be
274
+ // If there are multiple arms, make sure they all agree on
275
+ // what the type of the binding `x` ought to be.
276
276
if var_id != pat. hir_id {
277
277
let vt = self . local_ty ( pat. span , var_id) . decl_ty ;
278
278
self . demand_eqtype_pat ( pat. span , vt, local_ty, discrim_span) ;
@@ -880,7 +880,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
880
880
// possibly incorrect trailing `;` in the else arm
881
881
remove_semicolon = self . could_remove_semicolon ( block, then_ty) ;
882
882
stmt. span
883
- } else { // empty block, point at its entirety
883
+ } else { // empty block; point at its entirety
884
884
// Avoid overlapping spans that aren't as readable:
885
885
// ```
886
886
// 2 | let x = if true {
@@ -917,19 +917,19 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
917
917
else_expr. span
918
918
} ;
919
919
920
- // Compute `Span` of `then` part of `if`-expression:
920
+ // Compute `Span` of `then` part of `if`-expression.
921
921
let then_sp = if let ExprKind :: Block ( block, _) = & then_expr. node {
922
922
if let Some ( expr) = & block. expr {
923
923
expr. span
924
924
} else if let Some ( stmt) = block. stmts . last ( ) {
925
925
// possibly incorrect trailing `;` in the else arm
926
926
remove_semicolon = remove_semicolon. or ( self . could_remove_semicolon ( block, else_ty) ) ;
927
927
stmt. span
928
- } else { // empty block, point at its entirety
929
- outer_sp = None ; // same as in `error_sp`, cleanup output
928
+ } else { // empty block; point at its entirety
929
+ outer_sp = None ; // same as in `error_sp`; cleanup output
930
930
then_expr. span
931
931
}
932
- } else { // shouldn't happen unless the parser has done something weird
932
+ } else { // shouldn't happen unless the parser has done something weird
933
933
then_expr. span
934
934
} ;
935
935
0 commit comments