mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 22:18:23 +03:00
fix normalizing associated types. this brings us up to 52 passing tests!
This commit is contained in:
committed by
Oliver Schneider
parent
bb6e5224da
commit
8e495999df
@@ -7,9 +7,10 @@
|
||||
use rustc::mir::visit::{Visitor, LvalueContext};
|
||||
use rustc::mir;
|
||||
use rustc::traits::Reveal;
|
||||
use rustc::ty;
|
||||
use rustc::ty::{self, TypeFoldable};
|
||||
use rustc::ty::layout::Layout;
|
||||
use rustc::ty::subst::{Subst, Substs};
|
||||
use rustc::infer::TransNormalize;
|
||||
|
||||
use error::{EvalResult, EvalError};
|
||||
use eval_context::{EvalContext, StackPopCleanup};
|
||||
@@ -135,8 +136,16 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx> {
|
||||
Validate(op, ref lvalues) => {
|
||||
for operand in lvalues {
|
||||
// We need to monomorphize ty *without* erasing lifetimes
|
||||
let ty = operand.ty.subst(self.tcx, self.substs());
|
||||
// TODO: do we have to self.tcx.normalize_associated_type(&{ty}) ? That however seems to erase lifetimes.
|
||||
let mut ty = operand.ty.subst(self.tcx, self.substs());
|
||||
// This is essentially a copy of normalize_associated_type, but without erasure
|
||||
if ty.has_projection_types() {
|
||||
let param_env = ty::ParamEnv::empty(Reveal::All);
|
||||
ty = self.tcx.infer_ctxt().enter(move |infcx| {
|
||||
ty.trans_normalize(&infcx, param_env)
|
||||
})
|
||||
}
|
||||
|
||||
// Now we can do validation at this type
|
||||
let lvalue = self.eval_lvalue(&operand.lval)?;
|
||||
self.validate(lvalue, ty, ValidationCtx::new(op))?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user