Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do min_const_fn checks for SetDiscriminants target #66790

Merged
merged 3 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
pvdrz marked this conversation as resolved.
Show resolved Hide resolved
}
// 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