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