Skip to content

Commit 9fe9c9c

Browse files
authored
Unrolled build for rust-lang#120885
Rollup merge of rust-lang#120885 - RalfJung:normal-visitor, r=compiler-errors interpret/visitor: ensure we only see normalized types [Prior discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Normalization.20after.20field.20projection) r? `@compiler-errors`
2 parents 520b0b2 + 29db789 commit 9fe9c9c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler/rustc_const_eval/src/interpret/projection.rs

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ where
149149
"`field` projection called on a slice -- call `index` projection instead"
150150
);
151151
let offset = base.layout().fields.offset(field);
152+
// Computing the layout does normalization, so we get a normalized type out of this
153+
// even if the field type is non-normalized (possible e.g. via associated types).
152154
let field_layout = base.layout().field(self, field);
153155

154156
// Offset may need adjustment for unsized fields.

compiler/rustc_const_eval/src/interpret/visitor.rs

+10
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
153153
// We visited all parts of this one.
154154
return Ok(());
155155
}
156+
157+
// Non-normalized types should never show up here.
158+
ty::Param(..)
159+
| ty::Alias(..)
160+
| ty::Bound(..)
161+
| ty::Placeholder(..)
162+
| ty::Infer(..)
163+
| ty::Error(..) => throw_inval!(TooGeneric),
164+
165+
// The rest is handled below.
156166
_ => {}
157167
};
158168

0 commit comments

Comments
 (0)