Skip to content

Commit

Permalink
Rollup merge of rust-lang#66790 - christianpoveda:check-set-discrimin…
Browse files Browse the repository at this point in the history
…ant, r=oli-obk

Do `min_const_fn` checks for `SetDiscriminant`s target

Fixes rust-lang#66556

r? @oli-obk @ecstatic-morse
  • Loading branch information
Centril authored Dec 1, 2019
2 parents 60f4212 + 2ced9d9 commit 75fd413
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,14 @@ 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, _) => {
self.check_op(ops::IfOrMatch);
}
// FIXME(eddyb) should these really do nothing?
StatementKind::FakeRead(..) |
StatementKind::SetDiscriminant { .. } |
StatementKind::StorageLive(_) |
StatementKind::StorageDead(_) |
StatementKind::InlineAsm {..} |
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 75fd413

Please sign in to comment.