Skip to content

Commit 75fd413

Browse files
authored
Rollup merge of rust-lang#66790 - christianpoveda:check-set-discriminant, r=oli-obk
Do `min_const_fn` checks for `SetDiscriminant`s target Fixes rust-lang#66556 r? @oli-obk @ecstatic-morse
2 parents 60f4212 + 2ced9d9 commit 75fd413

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/librustc_mir/transform/check_consts/validation.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,14 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
560560
trace!("visit_statement: statement={:?} location={:?}", statement, location);
561561

562562
match statement.kind {
563-
StatementKind::Assign(..) => {
563+
StatementKind::Assign(..) | StatementKind::SetDiscriminant { .. } => {
564564
self.super_statement(statement, location);
565565
}
566566
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
567567
self.check_op(ops::IfOrMatch);
568568
}
569569
// FIXME(eddyb) should these really do nothing?
570570
StatementKind::FakeRead(..) |
571-
StatementKind::SetDiscriminant { .. } |
572571
StatementKind::StorageLive(_) |
573572
StatementKind::StorageDead(_) |
574573
StatementKind::InlineAsm {..} |

src/librustc_mir/transform/qualify_min_const_fn.rs

+1-1
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)