1
Fork 0

Rollup merge of #66790 - christianpoveda:check-set-discriminant, r=oli-obk

Do `min_const_fn` checks for `SetDiscriminant`s target

Fixes https://github.com/rust-lang/rust/issues/66556

r? @oli-obk @ecstatic-morse
This commit is contained in:
Mazdak Farrokhzad 2019-12-01 04:49:26 +01:00 committed by GitHub
commit 75fd413e7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View file

@ -560,7 +560,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
trace!("visit_statement: statement={:?} location={:?}", statement, location);
match statement.kind {
StatementKind::Assign(..) => {
StatementKind::Assign(..) | StatementKind::SetDiscriminant { .. } => {
self.super_statement(statement, location);
}
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
@ -568,7 +568,6 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
}
// FIXME(eddyb) should these really do nothing?
StatementKind::FakeRead(..) |
StatementKind::SetDiscriminant { .. } |
StatementKind::StorageLive(_) |
StatementKind::StorageDead(_) |
StatementKind::InlineAsm {..} |

View file

@ -225,7 +225,7 @@ fn check_statement(
StatementKind::FakeRead(_, place) => check_place(tcx, place, span, def_id, body),
// just an assignment
StatementKind::SetDiscriminant { .. } => Ok(()),
StatementKind::SetDiscriminant { place, .. } => check_place(tcx, place, span, def_id, body),
| StatementKind::InlineAsm { .. } => {
Err((span, "cannot use inline assembly in const fn".into()))