1
Fork 0

Check SetDiscriminant place

This commit is contained in:
Christian Poveda 2019-11-26 08:27:31 -05:00
parent 91642e3ac0
commit c66ad14057
2 changed files with 5 additions and 2 deletions

View file

@ -566,9 +566,12 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => {
self.check_op(ops::IfOrMatch);
}
StatementKind::SetDiscriminant { ref place, .. } => {
let ctx = PlaceContext::MutatingUse(MutatingUseContext::Projection);
self.visit_place(&place, ctx, location)
}
// 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()))