@@ -33,7 +33,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
33
33
/// ```text
34
34
/// [ 0. Pre-match ]
35
35
/// |
36
- /// [ 1. Evaluate Scrutinee]
36
+ /// [ 1. Evaluate Scrutinee (expression being matched on) ]
37
37
/// [ (fake read of scrutinee) ]
38
38
/// |
39
39
/// [ 2. Decision tree -- check discriminants ] <--------+
@@ -102,38 +102,38 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
102
102
destination : & Place < ' tcx > ,
103
103
span : Span ,
104
104
mut block : BasicBlock ,
105
- discriminant : ExprRef < ' tcx > ,
105
+ scrutinee : ExprRef < ' tcx > ,
106
106
arms : Vec < Arm < ' tcx > > ,
107
107
) -> BlockAnd < ( ) > {
108
108
let tcx = self . hir . tcx ( ) ;
109
109
110
110
// Step 1. Evaluate the scrutinee and add the fake read of it.
111
111
112
- let discriminant_span = discriminant . span ( ) ;
113
- let discriminant_place = unpack ! ( block = self . as_place( block, discriminant ) ) ;
112
+ let scrutinee_span = scrutinee . span ( ) ;
113
+ let scrutinee_place = unpack ! ( block = self . as_place( block, scrutinee ) ) ;
114
114
115
- // Matching on a `discriminant_place ` with an uninhabited type doesn't
115
+ // Matching on a `scrutinee_place ` with an uninhabited type doesn't
116
116
// generate any memory reads by itself, and so if the place "expression"
117
117
// contains unsafe operations like raw pointer dereferences or union
118
118
// field projections, we wouldn't know to require an `unsafe` block
119
119
// around a `match` equivalent to `std::intrinsics::unreachable()`.
120
120
// See issue #47412 for this hole being discovered in the wild.
121
121
//
122
122
// HACK(eddyb) Work around the above issue by adding a dummy inspection
123
- // of `discriminant_place `, specifically by applying `ReadForMatch`.
123
+ // of `scrutinee_place `, specifically by applying `ReadForMatch`.
124
124
//
125
- // NOTE: ReadForMatch also checks that the discriminant is initialized.
125
+ // NOTE: ReadForMatch also checks that the scrutinee is initialized.
126
126
// This is currently needed to not allow matching on an uninitialized,
127
127
// uninhabited value. If we get never patterns, those will check that
128
128
// the place is initialized, and so this read would only be used to
129
129
// check safety.
130
130
131
- let source_info = self . source_info ( discriminant_span ) ;
131
+ let source_info = self . source_info ( scrutinee_span ) ;
132
132
self . cfg . push ( block, Statement {
133
133
source_info,
134
134
kind : StatementKind :: FakeRead (
135
135
FakeReadCause :: ForMatchedPlace ,
136
- discriminant_place . clone ( ) ,
136
+ scrutinee_place . clone ( ) ,
137
137
) ,
138
138
} ) ;
139
139
@@ -175,7 +175,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
175
175
Candidate {
176
176
span : pattern. span ,
177
177
match_pairs : vec ! [
178
- MatchPair :: new( discriminant_place . clone( ) , pattern) ,
178
+ MatchPair :: new( scrutinee_place . clone( ) , pattern) ,
179
179
] ,
180
180
bindings : vec ! [ ] ,
181
181
ascriptions : vec ! [ ] ,
@@ -216,10 +216,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
216
216
. flat_map ( |( _, candidates) | candidates)
217
217
. collect :: < Vec < _ > > ( ) ;
218
218
219
- // this will generate code to test discriminant_place and
219
+ // this will generate code to test scrutinee_place and
220
220
// branch to the appropriate arm block
221
221
let otherwise = self . match_candidates (
222
- discriminant_span ,
222
+ scrutinee_span ,
223
223
candidates,
224
224
block,
225
225
& mut fake_borrows,
@@ -245,7 +245,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
245
245
// places. Create the required temporaries for them.
246
246
247
247
let fake_borrow_temps = if let Some ( ref borrows) = fake_borrows {
248
- self . calculate_fake_borrows ( borrows, discriminant_span )
248
+ self . calculate_fake_borrows ( borrows, scrutinee_span )
249
249
} else {
250
250
Vec :: new ( )
251
251
} ;
@@ -267,7 +267,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
267
267
LintLevel :: Inherited ,
268
268
& arm. patterns [ ..] ,
269
269
ArmHasGuard ( arm. guard . is_some ( ) ) ,
270
- Some ( ( Some ( & discriminant_place ) , discriminant_span ) ) ,
270
+ Some ( ( Some ( & scrutinee_place ) , scrutinee_span ) ) ,
271
271
) ;
272
272
273
273
for ( pat_index, candidate) in candidates. into_iter ( ) . enumerate ( ) {
@@ -276,7 +276,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
276
276
arm. guard . clone ( ) ,
277
277
arm_block,
278
278
& fake_borrow_temps,
279
- discriminant_span ,
279
+ scrutinee_span ,
280
280
pat_index,
281
281
) ;
282
282
}
@@ -1302,7 +1302,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1302
1302
guard : Option < Guard < ' tcx > > ,
1303
1303
arm_block : BasicBlock ,
1304
1304
fake_borrows : & Vec < ( & Place < ' tcx > , BorrowKind , Local ) > ,
1305
- discriminant_span : Span ,
1305
+ scrutinee_span : Span ,
1306
1306
pat_index : usize ,
1307
1307
) {
1308
1308
debug ! ( "bind_and_guard_matched_candidate(candidate={:?})" , candidate) ;
@@ -1427,7 +1427,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1427
1427
}
1428
1428
1429
1429
let re_erased = tcx. types . re_erased ;
1430
- let discriminant_source_info = self . source_info ( discriminant_span ) ;
1430
+ let scrutinee_source_info = self . source_info ( scrutinee_span ) ;
1431
1431
for & ( place, borrow_kind, temp) in fake_borrows {
1432
1432
let borrow = Rvalue :: Ref (
1433
1433
re_erased,
@@ -1436,7 +1436,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1436
1436
) ;
1437
1437
self . cfg . push_assign (
1438
1438
block,
1439
- discriminant_source_info ,
1439
+ scrutinee_source_info ,
1440
1440
& Place :: Local ( temp) ,
1441
1441
borrow,
1442
1442
) ;
0 commit comments