]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/variance.rs
std: Rename Show/String to Debug/Display
[rust.git] / src / librustc_typeck / variance.rs
index 3ca0e40c51ed49c3f5bf4e6d2b6c022868b2c30a..1f10f8eb1b60d0dc2d49b0412ac07e310df9a371 100644 (file)
@@ -240,11 +240,11 @@ enum VarianceTerm<'a> {
     InferredTerm(InferredIndex),
 }
 
-impl<'a> fmt::Show for VarianceTerm<'a> {
+impl<'a> fmt::Debug for VarianceTerm<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            ConstantTerm(c1) => write!(f, "{}", c1),
-            TransformTerm(v1, v2) => write!(f, "({} \u{00D7} {})", v1, v2),
+            ConstantTerm(c1) => write!(f, "{:?}", c1),
+            TransformTerm(v1, v2) => write!(f, "({:?} \u{00D7} {:?})", v1, v2),
             InferredTerm(id) => write!(f, "[{}]", { let InferredIndex(i) = id; i })
         }
     }
@@ -288,7 +288,7 @@ fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
     let mut terms_cx = TermsContext {
         tcx: tcx,
         arena: arena,
-        inferred_map: NodeMap::new(),
+        inferred_map: NodeMap(),
         inferred_infos: Vec::new(),
 
         // cache and share the variance struct used for items with
@@ -323,10 +323,10 @@ fn add_inferred(&mut self,
         assert!(newly_added);
 
         debug!("add_inferred(item_id={}, \
-                kind={}, \
+                kind={:?}, \
                 index={}, \
                 param_id={},
-                inf_index={})",
+                inf_index={:?})",
                 item_id, kind, index, param_id, inf_index);
     }
 
@@ -402,8 +402,8 @@ fn visit_item(&mut self, item: &ast::Item) {
 struct ConstraintContext<'a, 'tcx: 'a> {
     terms_cx: TermsContext<'a, 'tcx>,
 
-    // These are the def-id of the std::kinds::marker::InvariantType,
-    // std::kinds::marker::InvariantLifetime, and so on. The arrays
+    // These are the def-id of the std::marker::InvariantType,
+    // std::marker::InvariantLifetime, and so on. The arrays
     // are indexed by the `ParamKind` (type, lifetime, self). Note
     // that there are no marker types for self, so the entries for
     // self are always None.
@@ -562,9 +562,9 @@ fn inferred_index(&self, param_id: ast::NodeId) -> InferredIndex {
         match self.terms_cx.inferred_map.get(&param_id) {
             Some(&index) => index,
             None => {
-                self.tcx().sess.bug(format!(
+                self.tcx().sess.bug(&format!(
                         "no inferred index entry for {}",
-                        self.tcx().map.node_to_string(param_id)).index(&FullRange));
+                        self.tcx().map.node_to_string(param_id))[]);
             }
         }
     }
@@ -673,8 +673,8 @@ fn declared_variance(&self,
     fn add_constraint(&mut self,
                       InferredIndex(index): InferredIndex,
                       variance: VarianceTermPtr<'a>) {
-        debug!("add_constraint(index={}, variance={})",
-                index, variance.to_string());
+        debug!("add_constraint(index={}, variance={:?})",
+                index, variance);
         self.constraints.push(Constraint { inferred: InferredIndex(index),
                                            variance: variance });
     }
@@ -837,9 +837,9 @@ fn add_constraints_from_ty(&mut self,
 
             ty::ty_infer(..) | ty::ty_err => {
                 self.tcx().sess.bug(
-                    format!("unexpected type encountered in \
+                    &format!("unexpected type encountered in \
                             variance inference: {}",
-                            ty.repr(self.tcx())).index(&FullRange));
+                            ty.repr(self.tcx()))[]);
             }
         }
     }
@@ -854,7 +854,7 @@ fn add_constraints_from_substs(&mut self,
                                    region_param_defs: &[ty::RegionParameterDef],
                                    substs: &subst::Substs<'tcx>,
                                    variance: VarianceTermPtr<'a>) {
-        debug!("add_constraints_from_substs(def_id={})", def_id);
+        debug!("add_constraints_from_substs(def_id={:?})", def_id);
 
         for p in type_param_defs.iter() {
             let variance_decl =
@@ -917,9 +917,9 @@ fn add_constraints_from_region(&mut self,
                 // regions when visiting member types or method types.
                 self.tcx()
                     .sess
-                    .bug(format!("unexpected region encountered in variance \
+                    .bug(&format!("unexpected region encountered in variance \
                                   inference: {}",
-                                 region.repr(self.tcx())).index(&FullRange));
+                                 region.repr(self.tcx()))[]);
             }
         }
     }
@@ -988,14 +988,14 @@ fn solve(&mut self) {
                 let new_value = glb(variance, old_value);
                 if old_value != new_value {
                     debug!("Updating inferred {} (node {}) \
-                            from {} to {} due to {}",
+                            from {:?} to {:?} due to {:?}",
                             inferred,
                             self.terms_cx
                                 .inferred_infos[inferred]
                                 .param_id,
                             old_value,
                             new_value,
-                            term.to_string());
+                            term);
 
                     self.solutions[inferred] = new_value;
                     changed = true;
@@ -1028,7 +1028,7 @@ fn write(&self) {
                   inferred_infos[index].item_id == item_id {
                 let info = &inferred_infos[index];
                 let variance = solutions[index];
-                debug!("Index {} Info {} / {} / {} Variance {}",
+                debug!("Index {} Info {} / {:?} / {:?} Variance {:?}",
                        index, info.index, info.kind, info.space, variance);
                 match info.kind {
                     TypeParam => {
@@ -1055,7 +1055,7 @@ fn write(&self) {
             // attribute and report an error with various results if found.
             if ty::has_attr(tcx, item_def_id, "rustc_variance") {
                 let found = item_variances.repr(tcx);
-                tcx.sess.span_err(tcx.map.span(item_id), found.index(&FullRange));
+                tcx.sess.span_err(tcx.map.span(item_id), &found[]);
             }
 
             let newly_added = tcx.item_variance_map.borrow_mut()