Skip to content

Commit 9745a17

Browse files
committedApr 9, 2022
Remove rule that place loads may not happen with variant index set
1 parent a5d2c04 commit 9745a17

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed
 

‎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) {

‎compiler/rustc_middle/src/mir/mod.rs

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

0 commit comments

Comments
 (0)
Please sign in to comment.