提交 8147d17d 编写于 作者: N Niko Matsakis

make `normalize` take ownership of the thing to be normalized

上级 214d7650
......@@ -51,7 +51,7 @@ pub(super) fn equate_inputs_and_outputs(
// Equate expected input tys with those in the MIR.
let argument_locals = (1..).map(Local::new);
for (&unnormalized_input_ty, local) in unnormalized_input_tys.iter().zip(argument_locals) {
let input_ty = self.normalize(&unnormalized_input_ty, Locations::All);
let input_ty = self.normalize(unnormalized_input_ty, Locations::All);
let mir_input_ty = mir.local_decls[local].ty;
self.equate_normalized_input_or_output(input_ty, mir_input_ty);
}
......@@ -71,7 +71,7 @@ pub(super) fn equate_inputs_and_outputs(
"equate_inputs_and_outputs: unnormalized_output_ty={:?}",
unnormalized_output_ty
);
let output_ty = self.normalize(&unnormalized_output_ty, Locations::All);
let output_ty = self.normalize(unnormalized_output_ty, Locations::All);
debug!(
"equate_inputs_and_outputs: normalized output_ty={:?}",
output_ty
......
......@@ -289,7 +289,7 @@ fn sanitize_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
let instantiated_predicates =
tcx.predicates_of(def_id).instantiate(tcx, substs);
let predicates =
type_checker.normalize(&instantiated_predicates.predicates, location);
type_checker.normalize(instantiated_predicates.predicates, location);
type_checker.prove_predicates(predicates, location);
}
......@@ -346,7 +346,7 @@ fn sanitize_place(
Place::Static(box Static { def_id, ty: sty }) => {
let sty = self.sanitize_type(place, sty);
let ty = self.tcx().type_of(def_id);
let ty = self.cx.normalize(&ty, location);
let ty = self.cx.normalize(ty, location);
if let Err(terr) = self.cx.eq_types(ty, sty, location.at_self()) {
span_mirbug!(
self,
......@@ -1023,7 +1023,7 @@ fn check_terminator(
LateBoundRegionConversionTime::FnCall,
&sig,
);
let sig = self.normalize(&sig, term_location);
let sig = self.normalize(sig, term_location);
self.check_call_dest(mir, term, &sig, destination, term_location);
self.prove_predicates(
......@@ -1311,7 +1311,7 @@ fn aggregate_field_ty(
let variant = &def.variants[variant_index];
let adj_field_index = active_field_index.unwrap_or(field_index);
if let Some(field) = variant.fields.get(adj_field_index) {
Ok(self.normalize(&field.ty(tcx, substs), location))
Ok(self.normalize(field.ty(tcx, substs), location))
} else {
Err(FieldAccessError::OutOfRange {
field_count: variant.fields.len(),
......@@ -1385,7 +1385,7 @@ fn check_rvalue(&mut self, mir: &Mir<'tcx>, rvalue: &Rvalue<'tcx>, location: Loc
// function definition. When we extract the
// signature, it comes from the `fn_sig` query,
// and hence may contain unnormalized results.
let fn_sig = self.normalize(&fn_sig, location);
let fn_sig = self.normalize(fn_sig, location);
let ty_fn_ptr_from = tcx.mk_fn_ptr(fn_sig);
......@@ -1430,7 +1430,7 @@ fn check_rvalue(&mut self, mir: &Mir<'tcx>, rvalue: &Rvalue<'tcx>, location: Loc
// function definition. When we extract the
// signature, it comes from the `fn_sig` query,
// and hence may contain unnormalized results.
let fn_sig = self.normalize(&fn_sig, location);
let fn_sig = self.normalize(fn_sig, location);
let ty_fn_ptr_from = tcx.safe_to_unsafe_fn_ty(fn_sig);
......@@ -1576,7 +1576,7 @@ fn prove_aggregate_predicates(
AggregateKind::Array(_) | AggregateKind::Tuple => ty::InstantiatedPredicates::empty(),
};
let predicates = self.normalize(&instantiated_predicates.predicates, location);
let predicates = self.normalize(instantiated_predicates.predicates, location);
debug!("prove_aggregate_predicates: predicates={:?}", predicates);
self.prove_predicates(predicates, location);
}
......@@ -1644,7 +1644,7 @@ fn typeck_mir(&mut self, mir: &Mir<'tcx>) {
}
}
fn normalize<T>(&mut self, value: &T, location: impl ToLocations) -> T
fn normalize<T>(&mut self, value: T, location: impl ToLocations) -> T
where
T: fmt::Debug + TypeFoldable<'tcx>,
{
......@@ -1661,7 +1661,7 @@ fn normalize<T>(&mut self, value: &T, location: impl ToLocations) -> T
let Normalized { value, obligations } = this
.infcx
.at(&ObligationCause::dummy(), this.param_env)
.normalize(value)
.normalize(&value)
.unwrap_or_else(|NoSolution| {
span_bug!(
this.last_span,
......
......@@ -19,6 +19,7 @@ pub(super) trait TypeOp<'gcx, 'tcx> {
/// Micro-optimization point: true if this is trivially true.
fn trivial_noop(&self) -> Option<Self::Output>;
/// Produce a description of the operation for the debug logs.
fn perform(
self,
type_checker: &mut TypeChecker<'_, 'gcx, 'tcx>,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册