about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-06-06 09:52:26 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-06-26 10:31:49 -0400
commit8147d17d8e3ac5c5dc9562862050f0876c556e88 (patch)
treeb43a33b4530b709117f27271e44b4692be76020d
parent214d7650c91e777c445a8ef0733c8553e34b2658 (diff)
downloadrust-8147d17d8e3ac5c5dc9562862050f0876c556e88.tar.gz
rust-8147d17d8e3ac5c5dc9562862050f0876c556e88.zip
make `normalize` take ownership of the thing to be normalized
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/input_output.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs18
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/type_op.rs1
3 files changed, 12 insertions, 11 deletions
diff --git a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs
index be0a2494b04..708ff4aa2ba 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs
@@ -51,7 +51,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
         // 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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
             "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
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
index 5e9b3ad5054..d9e3ecb8f85 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -289,7 +289,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
                     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 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
             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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
                     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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
                 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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
                     // 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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
                     // 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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
             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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, '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 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
                 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,
diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op.rs b/src/librustc_mir/borrow_check/nll/type_check/type_op.rs
index 0b35f3501fc..602abbdd4e7 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/type_op.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/type_op.rs
@@ -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>,