Skip to content

Commit c66ad14

Browse files
committed
Check SetDiscriminant place
1 parent 91642e3 commit c66ad14

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/librustc_mir/transform/check_consts/validation.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,12 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
566566
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
567567
self.check_op(ops::IfOrMatch);
568568
}
569+
StatementKind::SetDiscriminant { ref place, .. } => {
570+
let ctx = PlaceContext::MutatingUse(MutatingUseContext::Projection);
571+
self.visit_place(&place, ctx, location)
572+
}
569573
// FIXME(eddyb) should these really do nothing?
570574
StatementKind::FakeRead(..) |
571-
StatementKind::SetDiscriminant { .. } |
572575
StatementKind::StorageLive(_) |
573576
StatementKind::StorageDead(_) |
574577
StatementKind::InlineAsm {..} |

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn check_statement(
225225
StatementKind::FakeRead(_, place) => check_place(tcx, place, span, def_id, body),
226226

227227
// just an assignment
228-
StatementKind::SetDiscriminant { .. } => Ok(()),
228+
StatementKind::SetDiscriminant { place, .. } => check_place(tcx, place, span, def_id, body),
229229

230230
| StatementKind::InlineAsm { .. } => {
231231
Err((span, "cannot use inline assembly in const fn".into()))

0 commit comments

Comments
 (0)