]> git.lizzy.rs Git - rust.git/commitdiff
52985: formatting PR files
authorTristan Burgess <tburgessdev@gmail.com>
Wed, 22 Aug 2018 04:24:03 +0000 (00:24 -0400)
committerTristan Burgess <tburgessdev@gmail.com>
Wed, 22 Aug 2018 22:57:10 +0000 (18:57 -0400)
src/librustc/traits/query/normalize.rs
src/librustc_typeck/check/writeback.rs

index 45f026c9b68bb7caf657913353d02827e2ae6837..821d3229fdc66e3ed2e0510db02862a9f50e4420 100644 (file)
 //! which folds deeply, invoking the underlying
 //! `normalize_projection_ty` query when it encounters projections.
 
-use infer::{InferCtxt, InferOk};
 use infer::at::At;
-use mir::interpret::{GlobalId, ConstValue};
+use infer::{InferCtxt, InferOk};
+use mir::interpret::{ConstValue, GlobalId};
 use rustc_data_structures::small_vec::SmallVec;
-use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
 use traits::project::Normalized;
-use ty::{self, Ty, TyCtxt};
+use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
 use ty::fold::{TypeFoldable, TypeFolder};
 use ty::subst::{Subst, Substs};
+use ty::{self, Ty, TyCtxt};
 
 use super::NoSolution;
 
@@ -121,9 +121,14 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
                         let concrete_ty = generic_ty.subst(self.tcx(), substs);
                         self.anon_depth += 1;
                         if concrete_ty == ty {
-                            bug!("infinite recursion generic_ty: {:#?}, substs: {:#?}, \
-                                  concrete_ty: {:#?}, ty: {:#?}", generic_ty, substs, concrete_ty,
-                                  ty);
+                            bug!(
+                                "infinite recursion generic_ty: {:#?}, substs: {:#?}, \
+                                 concrete_ty: {:#?}, ty: {:#?}",
+                                generic_ty,
+                                substs,
+                                concrete_ty,
+                                ty
+                            );
                         }
                         let folded_ty = self.fold_ty(concrete_ty);
                         self.anon_depth -= 1;
@@ -149,8 +154,8 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
                 let gcx = self.infcx.tcx.global_tcx();
 
                 let mut orig_values = SmallVec::new();
-                let c_data =
-                    self.infcx.canonicalize_query(&self.param_env.and(*data), &mut orig_values);
+                let c_data = self.infcx
+                    .canonicalize_query(&self.param_env.and(*data), &mut orig_values);
                 debug!("QueryNormalizer: c_data = {:#?}", c_data);
                 debug!("QueryNormalizer: orig_values = {:#?}", orig_values);
                 match gcx.normalize_projection_ty(c_data) {
index 72103caadf623c7bb06f7c29f6244da4ca1cb9f6..319de51713b93abcb8bec52bbbbcc9059aecd185 100644 (file)
 use rustc::hir::def_id::{DefId, DefIndex};
 use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
 use rustc::infer::InferCtxt;
+use rustc::ty::adjustment::{Adjust, Adjustment};
+use rustc::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder};
 use rustc::ty::subst::UnpackedKind;
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::ty::adjustment::{Adjust, Adjustment};
-use rustc::ty::fold::{TypeFoldable, TypeFolder, BottomUpFolder};
 use rustc::util::nodemap::DefIdSet;
+use rustc_data_structures::sync::Lrc;
+use std::mem;
 use syntax::ast;
 use syntax_pos::Span;
-use std::mem;
-use rustc_data_structures::sync::Lrc;
 
 ///////////////////////////////////////////////////////////////////////////
 // Entry point
@@ -55,8 +55,7 @@ pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::Type
         );
         debug!(
             "used_trait_imports({:?}) = {:?}",
-            item_def_id,
-            used_trait_imports
+            item_def_id, used_trait_imports
         );
         wbcx.tables.used_trait_imports = used_trait_imports;
 
@@ -64,8 +63,7 @@ pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::Type
 
         debug!(
             "writeback: tables for {:?} are {:#?}",
-            item_def_id,
-            wbcx.tables
+            item_def_id, wbcx.tables
         );
 
         self.tcx.alloc_tables(wbcx.tables)
@@ -118,8 +116,8 @@ fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'gcx>) {
     // operating on scalars, we clear the overload.
     fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) {
         match e.node {
-            hir::ExprKind::Unary(hir::UnNeg, ref inner) |
-            hir::ExprKind::Unary(hir::UnNot, ref inner) => {
+            hir::ExprKind::Unary(hir::UnNeg, ref inner)
+            hir::ExprKind::Unary(hir::UnNot, ref inner) => {
                 let inner_ty = self.fcx.node_ty(inner.hir_id);
                 let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty);
 
@@ -178,8 +176,7 @@ fn fix_index_builtin_expr(&mut self, e: &hir::Expr) {
                     let index_ty = tables.expr_ty_adjusted(&index);
                     let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty);
 
-                    if base_ty.builtin_index().is_some()
-                        && index_ty == self.fcx.tcx.types.usize {
+                    if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize {
                         // Remove the method call record
                         tables.type_dependent_defs_mut().remove(e.hir_id);
                         tables.node_substs_mut().remove(e.hir_id);
@@ -191,24 +188,26 @@ fn fix_index_builtin_expr(&mut self, e: &hir::Expr) {
                                 // of size information - we need to get rid of it
                                 // Since this is "after" the other adjustment to be
                                 // discarded, we do an extra `pop()`
-                                Some(Adjustment { kind: Adjust::Unsize, .. }) => {
+                                Some(Adjustment {
+                                    kind: Adjust::Unsize,
+                                    ..
+                                }) => {
                                     // So the borrow discard actually happens here
                                     a.pop();
-                                },
+                                }
                                 _ => {}
                             }
                         });
                     }
-                },
+                }
                 // Might encounter non-valid indexes at this point, so there
                 // has to be a fall-through
-                _ => {},
+                _ => {}
             }
         }
     }
 }
 
-
 ///////////////////////////////////////////////////////////////////////////
 // Impl of Visitor for Resolver
 //
@@ -262,7 +261,9 @@ fn visit_pat(&mut self, p: &'gcx hir::Pat) {
                 if let Some(&bm) = self.fcx.tables.borrow().pat_binding_modes().get(p.hir_id) {
                     self.tables.pat_binding_modes_mut().insert(p.hir_id, bm);
                 } else {
-                    self.tcx().sess.delay_span_bug(p.span, "missing binding mode");
+                    self.tcx()
+                        .sess
+                        .delay_span_bug(p.span, "missing binding mode");
                 }
             }
             hir::PatKind::Struct(_, ref fields, _) => {
@@ -310,8 +311,7 @@ fn visit_upvar_borrow_map(&mut self) {
             };
             debug!(
                 "Upvar capture for {:?} resolved to {:?}",
-                upvar_id,
-                new_upvar_capture
+                upvar_id, new_upvar_capture
             );
             self.tables
                 .upvar_capture_map
@@ -425,8 +425,7 @@ fn visit_anon_types(&mut self, span: Span) {
                                     if subst == ty {
                                         // found it in the substitution list, replace with the
                                         // parameter from the existential type
-                                        return self
-                                            .tcx()
+                                        return self.tcx()
                                             .global_tcx()
                                             .mk_ty_param(param.index, param.name);
                                     }
@@ -464,14 +463,16 @@ fn visit_anon_types(&mut self, span: Span) {
                                                 name: p.name,
                                             };
                                             trace!("replace {:?} with {:?}", region, reg);
-                                            return self.tcx().global_tcx()
+                                            return self.tcx()
+                                                .global_tcx()
                                                 .mk_region(ty::ReEarlyBound(reg));
                                         }
                                     }
                                 }
                                 trace!("anon_defn: {:#?}", anon_defn);
                                 trace!("generics: {:#?}", generics);
-                                self.tcx().sess
+                                self.tcx()
+                                    .sess
                                     .struct_span_err(
                                         span,
                                         "non-defining existential type use in defining scope",
@@ -480,7 +481,7 @@ fn visit_anon_types(&mut self, span: Span) {
                                         span,
                                         format!(
                                             "lifetime `{}` is part of concrete type but not used \
-                                            in parameter list of existential type",
+                                             in parameter list of existential type",
                                             region,
                                         ),
                                     )
@@ -488,25 +489,27 @@ fn visit_anon_types(&mut self, span: Span) {
                                 self.tcx().global_tcx().mk_region(ty::ReStatic)
                             }
                         }
-                    }
+                    },
                 })
             };
 
             if let ty::Anon(defin_ty_def_id, _substs) = definition_ty.sty {
                 if def_id == defin_ty_def_id {
-                  // Concrete type resolved to the existential type itself
-                  // Force a cycle error
-                  self.tcx().at(span).type_of(defin_ty_def_id);
+                    // Concrete type resolved to the existential type itself
+                    // Force a cycle error
+                    self.tcx().at(span).type_of(defin_ty_def_id);
                 }
             }
 
-            let old = self.tables.concrete_existential_types.insert(def_id, definition_ty);
+            let old = self.tables
+                .concrete_existential_types
+                .insert(def_id, definition_ty);
             if let Some(old) = old {
                 if old != definition_ty {
                     span_bug!(
                         span,
                         "visit_anon_types tried to write \
-                        different types for the same existential type: {:?}, {:?}, {:?}",
+                         different types for the same existential type: {:?}, {:?}, {:?}",
                         def_id,
                         definition_ty,
                         old,
@@ -518,7 +521,12 @@ fn visit_anon_types(&mut self, span: Span) {
 
     fn visit_field_id(&mut self, node_id: ast::NodeId) {
         let hir_id = self.tcx().hir.node_to_hir_id(node_id);
-        if let Some(index) = self.fcx.tables.borrow_mut().field_indices_mut().remove(hir_id) {
+        if let Some(index) = self.fcx
+            .tables
+            .borrow_mut()
+            .field_indices_mut()
+            .remove(hir_id)
+        {
             self.tables.field_indices_mut().insert(hir_id, index);
         }
     }
@@ -567,8 +575,7 @@ fn visit_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
                 let resolved_adjustment = self.resolve(&adjustment, &span);
                 debug!(
                     "Adjustments for node {:?}: {:?}",
-                    hir_id,
-                    resolved_adjustment
+                    hir_id, resolved_adjustment
                 );
                 self.tables
                     .adjustments_mut()
@@ -592,8 +599,7 @@ fn visit_pat_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
                 let resolved_adjustment = self.resolve(&adjustment, &span);
                 debug!(
                     "pat_adjustments for node {:?}: {:?}",
-                    hir_id,
-                    resolved_adjustment
+                    hir_id, resolved_adjustment
                 );
                 self.tables
                     .pat_adjustments_mut()
@@ -709,7 +715,8 @@ fn new(
     fn report_error(&self, t: Ty<'tcx>) {
         if !self.tcx.sess.has_errors() {
             self.infcx
-                .need_type_info_err(Some(self.body.id()), self.span.to_span(&self.tcx), t).emit();
+                .need_type_info_err(Some(self.body.id()), self.span.to_span(&self.tcx), t)
+                .emit();
         }
     }
 }