Skip to content

Commit 8732bf5

Browse files
committed
Remove rule that place loads may not happen with variant index set
1 parent 4bce639 commit 8732bf5

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Diff for: compiler/rustc_const_eval/src/transform/validate.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
246246
self.super_projection_elem(local, proj_base, elem, context, location);
247247
}
248248

249-
fn visit_place(&mut self, place: &Place<'tcx>, _: PlaceContext, location: Location) {
249+
fn visit_place(&mut self, place: &Place<'tcx>, _: PlaceContext, _: Location) {
250250
// Set off any `bug!`s in the type computation code
251-
let ty = place.ty(&self.body.local_decls, self.tcx);
252-
if ty.variant_index.is_some() {
253-
self.fail(location, "Top level places may not have their variant index set!");
254-
}
251+
let _ = place.ty(&self.body.local_decls, self.tcx);
255252
}
256253

257254
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {

Diff for: compiler/rustc_middle/src/mir/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@ pub struct CopyNonOverlapping<'tcx> {
19311931
/// pointee type is unsized, the pointer additionally stored the value of the metadata.
19321932
///
19331933
/// Computing a place may cause UB. One possibility is that the pointer used for a `Deref` may not
1934-
/// be suitably aligned. Another possibility is that the place is not in bouns, meaning it does not
1934+
/// be suitably aligned. Another possibility is that the place is not in bounds, meaning it does not
19351935
/// point to an actual allocation.
19361936
///
19371937
/// However, if this is actually UB and when the UB kicks in is undecided. This is being discussed
@@ -2325,10 +2325,9 @@ pub struct SourceScopeLocalData {
23252325
/// This is what is implemented in miri today. Are these the semantics we want for MIR? Is this
23262326
/// something we can even decide without knowing more about Rust's memory model?
23272327
///
2328-
/// Loading a place that has its variant index set is not well-formed. However, note that this rule
2329-
/// only applies to places appearing in MIR bodies. Many functions, such as [`Place::ty`], still
2330-
/// accept such a place. If you write a function for which it might be ambiguous whether such a
2331-
/// thing is accepted, make sure to document your choice clearly.
2328+
/// **Needs clarifiation:** Is loading a place that has its variant index set well-formed? Miri
2329+
/// currently implements it, but it seems like this may be something to check against in the
2330+
/// validator.
23322331
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
23332332
pub enum Operand<'tcx> {
23342333
/// Creates a value by loading the given place. The type of the place must be `Copy`

0 commit comments

Comments
 (0)