]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/constrained_generic_params.rs
Auto merge of #68506 - tmandry:rollup-kz9d33v, r=tmandry
[rust.git] / src / librustc_typeck / constrained_generic_params.rs
index a3a703cf50e9807efb0bfee0c2e581d444d5dee3..a281c0ae67d24ef1635c883442495b6cb0eea62c 100644 (file)
@@ -1,21 +1,27 @@
-use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::fold::{TypeFoldable, TypeVisitor};
-use rustc::util::nodemap::FxHashSet;
-use syntax::source_map::Span;
+use rustc::ty::{self, Ty, TyCtxt};
+use rustc_data_structures::fx::FxHashSet;
+use rustc_span::source_map::Span;
 
 #[derive(Clone, PartialEq, Eq, Hash, Debug)]
 pub struct Parameter(pub u32);
 
 impl From<ty::ParamTy> for Parameter {
-    fn from(param: ty::ParamTy) -> Self { Parameter(param.index) }
+    fn from(param: ty::ParamTy) -> Self {
+        Parameter(param.index)
+    }
 }
 
 impl From<ty::EarlyBoundRegion> for Parameter {
-    fn from(param: ty::EarlyBoundRegion) -> Self { Parameter(param.index) }
+    fn from(param: ty::EarlyBoundRegion) -> Self {
+        Parameter(param.index)
+    }
 }
 
 impl From<ty::ParamConst> for Parameter {
-    fn from(param: ty::ParamConst) -> Self { Parameter(param.index) }
+    fn from(param: ty::ParamConst) -> Self {
+        Parameter(param.index)
+    }
 }
 
 /// Returns the set of parameters constrained by the impl header.
@@ -39,17 +45,14 @@ pub fn parameters_for<'tcx>(
     t: &impl TypeFoldable<'tcx>,
     include_nonconstraining: bool,
 ) -> Vec<Parameter> {
-    let mut collector = ParameterCollector {
-        parameters: vec![],
-        include_nonconstraining,
-    };
+    let mut collector = ParameterCollector { parameters: vec![], include_nonconstraining };
     t.visit_with(&mut collector);
     collector.parameters
 }
 
 struct ParameterCollector {
     parameters: Vec<Parameter>,
-    include_nonconstraining: bool
+    include_nonconstraining: bool,
 }
 
 impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
@@ -93,7 +96,6 @@ pub fn identify_constrained_generic_params<'tcx>(
     setup_constraining_predicates(tcx, &mut predicates, impl_trait_ref, input_parameters);
 }
 
-
 /// Order the predicates in `predicates` such that each parameter is
 /// constrained before it is used, if that is possible, and add the
 /// parameters so constrained to `input_parameters`. For example,
@@ -159,9 +161,11 @@ pub fn setup_constraining_predicates<'tcx>(
     //   * <U as Iterator>::Item = T
     //   * T: Debug
     //   * U: Iterator
-    debug!("setup_constraining_predicates: predicates={:?} \
+    debug!(
+        "setup_constraining_predicates: predicates={:?} \
             impl_trait_ref={:?} input_parameters={:?}",
-           predicates, impl_trait_ref, input_parameters);
+        predicates, impl_trait_ref, input_parameters
+    );
     let mut i = 0;
     let mut changed = true;
     while changed {
@@ -200,8 +204,10 @@ pub fn setup_constraining_predicates<'tcx>(
             i += 1;
             changed = true;
         }
-        debug!("setup_constraining_predicates: predicates={:?} \
+        debug!(
+            "setup_constraining_predicates: predicates={:?} \
                 i={} impl_trait_ref={:?} input_parameters={:?}",
-               predicates, i, impl_trait_ref, input_parameters);
+            predicates, i, impl_trait_ref, input_parameters
+        );
     }
 }