Skip to content

Commit

Permalink
Unrolled build for rust-lang#120885
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
rust-timer authored Feb 12, 2024
2 parents 520b0b2 + 29db789 commit 9fe9c9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_const_eval/src/interpret/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ where
"`field` projection called on a slice -- call `index` projection instead"
);
let offset = base.layout().fields.offset(field);
// Computing the layout does normalization, so we get a normalized type out of this
// even if the field type is non-normalized (possible e.g. via associated types).
let field_layout = base.layout().field(self, field);

// Offset may need adjustment for unsized fields.
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_const_eval/src/interpret/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
// We visited all parts of this one.
return Ok(());
}

// Non-normalized types should never show up here.
ty::Param(..)
| ty::Alias(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..)
| ty::Error(..) => throw_inval!(TooGeneric),

// The rest is handled below.
_ => {}
};

Expand Down

0 comments on commit 9fe9c9c

Please sign in to comment.