diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-06-14 01:32:15 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-06-14 18:58:32 +0300 |
| commit | afc39bbf2447844569e872468f9440d430b81a46 (patch) | |
| tree | ba1bef6bb7dc8058e219457bdfac702738ab8f58 /src/librustc/traits | |
| parent | f3f9d6dfd92dfaeb14df891ad27b2531809dd734 (diff) | |
| download | rust-afc39bbf2447844569e872468f9440d430b81a46.tar.gz rust-afc39bbf2447844569e872468f9440d430b81a46.zip | |
Run `rustfmt --file-lines ...` for changes from previous commits.
Diffstat (limited to 'src/librustc/traits')
| -rw-r--r-- | src/librustc/traits/chalk_fulfill.rs | 2 | ||||
| -rw-r--r-- | src/librustc/traits/codegen/mod.rs | 14 | ||||
| -rw-r--r-- | src/librustc/traits/coherence.rs | 10 | ||||
| -rw-r--r-- | src/librustc/traits/error_reporting.rs | 7 | ||||
| -rw-r--r-- | src/librustc/traits/fulfill.rs | 51 | ||||
| -rw-r--r-- | src/librustc/traits/mod.rs | 7 | ||||
| -rw-r--r-- | src/librustc/traits/project.rs | 159 | ||||
| -rw-r--r-- | src/librustc/traits/query/type_op/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc/traits/specialize/mod.rs | 24 | ||||
| -rw-r--r-- | src/librustc/traits/specialize/specialization_graph.rs | 7 | ||||
| -rw-r--r-- | src/librustc/traits/util.rs | 23 |
11 files changed, 143 insertions, 165 deletions
diff --git a/src/librustc/traits/chalk_fulfill.rs b/src/librustc/traits/chalk_fulfill.rs index b1941b876d7..0c7c94b684a 100644 --- a/src/librustc/traits/chalk_fulfill.rs +++ b/src/librustc/traits/chalk_fulfill.rs @@ -30,7 +30,7 @@ impl FulfillmentContext<'tcx> { fn in_environment( infcx: &InferCtxt<'_, 'tcx>, - obligation: PredicateObligation<'tcx> + obligation: PredicateObligation<'tcx>, ) -> InEnvironment<'tcx, PredicateObligation<'tcx>> { assert!(!infcx.is_in_snapshot()); let obligation = infcx.resolve_vars_if_possible(&obligation); diff --git a/src/librustc/traits/codegen/mod.rs b/src/librustc/traits/codegen/mod.rs index a5d44f5f263..bb4095333f1 100644 --- a/src/librustc/traits/codegen/mod.rs +++ b/src/librustc/traits/codegen/mod.rs @@ -116,7 +116,7 @@ impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> { // # Global Cache pub struct ProjectionCache<'tcx> { - data: PhantomData<&'tcx ()> + data: PhantomData<&'tcx ()>, } impl<'tcx> DepTrackingMapConfig for ProjectionCache<'tcx> { @@ -137,11 +137,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// type inference variables that appear in `result` to be /// unified, and hence we need to process those obligations to get /// the complete picture of the type. - fn drain_fulfillment_cx_or_panic<T>(&self, - fulfill_cx: &mut FulfillmentContext<'tcx>, - result: &T) - -> T::Lifted - where T: TypeFoldable<'tcx> + ty::Lift<'tcx> + fn drain_fulfillment_cx_or_panic<T>( + &self, + fulfill_cx: &mut FulfillmentContext<'tcx>, + result: &T, + ) -> T::Lifted + where + T: TypeFoldable<'tcx> + ty::Lift<'tcx>, { debug!("drain_fulfillment_cx_or_panic()"); diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 949cc62f62c..d8087af60ac 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -87,11 +87,11 @@ where }) } -fn with_fresh_ty_vars<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - impl_def_id: DefId) - -> ty::ImplHeader<'tcx> -{ +fn with_fresh_ty_vars<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + impl_def_id: DefId, +) -> ty::ImplHeader<'tcx> { let tcx = selcx.tcx(); let impl_substs = selcx.infcx().fresh_substs_for_item(DUMMY_SP, impl_def_id); diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 99ced254dca..42bde356349 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1249,10 +1249,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { expected_ref: ty::PolyTraitRef<'tcx>, found: ty::PolyTraitRef<'tcx>, ) -> DiagnosticBuilder<'tcx> { - fn build_fn_sig_string<'tcx>( - tcx: TyCtxt<'tcx>, - trait_ref: &ty::TraitRef<'tcx>, - ) -> String { + fn build_fn_sig_string<'tcx>(tcx: TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> String { let inputs = trait_ref.substs.type_at(1); let sig = if let ty::Tuple(inputs) = inputs.sty { tcx.mk_fn_sig( @@ -1456,7 +1453,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ) -> bool { struct ParamToVarFolder<'a, 'tcx: 'a> { infcx: &'a InferCtxt<'a, 'tcx>, - var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>> + var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>, } impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> { diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index eaad696ba39..5e2c949c7d8 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -95,8 +95,10 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> { } /// Attempts to select obligations using `selcx`. - fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>) - -> Result<(), Vec<FulfillmentError<'tcx>>> { + fn select( + &mut self, + selcx: &mut SelectionContext<'a, 'tcx>, + ) -> Result<(), Vec<FulfillmentError<'tcx>>> { debug!("select(obligation-forest-size={})", self.predicates.len()); let mut errors = Vec::new(); @@ -143,13 +145,13 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { /// `SomeTrait` or a where-clause that lets us unify `$0` with /// something concrete. If this fails, we'll unify `$0` with /// `projection_ty` again. - fn normalize_projection_type(&mut self, - infcx: &InferCtxt<'_, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - projection_ty: ty::ProjectionTy<'tcx>, - cause: ObligationCause<'tcx>) - -> Ty<'tcx> - { + fn normalize_projection_type( + &mut self, + infcx: &InferCtxt<'_, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + projection_ty: ty::ProjectionTy<'tcx>, + cause: ObligationCause<'tcx>, + ) -> Ty<'tcx> { debug!("normalize_projection_type(projection_ty={:?})", projection_ty); @@ -172,10 +174,11 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { normalized_ty } - fn register_predicate_obligation(&mut self, - infcx: &InferCtxt<'_, 'tcx>, - obligation: PredicateObligation<'tcx>) - { + fn register_predicate_obligation( + &mut self, + infcx: &InferCtxt<'_, 'tcx>, + obligation: PredicateObligation<'tcx>, + ) { // this helps to reduce duplicate errors, as well as making // debug output much nicer to read and so on. let obligation = infcx.resolve_vars_if_possible(&obligation); @@ -192,9 +195,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { fn select_all_or_error( &mut self, - infcx: &InferCtxt<'_, 'tcx> - ) -> Result<(),Vec<FulfillmentError<'tcx>>> - { + infcx: &InferCtxt<'_, 'tcx>, + ) -> Result<(), Vec<FulfillmentError<'tcx>>> { self.select_where_possible(infcx)?; let errors: Vec<_> = @@ -209,10 +211,10 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { } } - fn select_where_possible(&mut self, - infcx: &InferCtxt<'_, 'tcx>) - -> Result<(),Vec<FulfillmentError<'tcx>>> - { + fn select_where_possible( + &mut self, + infcx: &InferCtxt<'_, 'tcx>, + ) -> Result<(), Vec<FulfillmentError<'tcx>>> { let mut selcx = SelectionContext::new(infcx); self.select(&mut selcx) } @@ -224,7 +226,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { struct FulfillProcessor<'a, 'b: 'a, 'tcx: 'b> { selcx: &'a mut SelectionContext<'b, 'tcx>, - register_region_obligations: bool + register_region_obligations: bool, } fn mk_pending(os: Vec<PredicateObligation<'tcx>>) -> Vec<PendingPredicateObligation<'tcx>> { @@ -514,9 +516,10 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { } /// Returns the set of type variables contained in a trait ref -fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>, - t: ty::PolyTraitRef<'tcx>) -> Vec<Ty<'tcx>> -{ +fn trait_ref_type_vars<'a, 'tcx>( + selcx: &mut SelectionContext<'a, 'tcx>, + t: ty::PolyTraitRef<'tcx>, +) -> Vec<Ty<'tcx>> { t.skip_binder() // ok b/c this check doesn't care about regions .input_types() .map(|t| selcx.infcx().resolve_vars_if_possible(&t)) diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 83162a1e12c..f5c91a77517 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -909,9 +909,10 @@ pub fn fully_normalize<'a, 'tcx, T>( mut fulfill_cx: FulfillmentContext<'tcx>, cause: ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, - value: &T) - -> Result<T, Vec<FulfillmentError<'tcx>>> - where T : TypeFoldable<'tcx> + value: &T, +) -> Result<T, Vec<FulfillmentError<'tcx>>> +where + T: TypeFoldable<'tcx>, { debug!("fully_normalize_with_fulfillcx(value={:?})", value); let selcx = &mut SelectionContext::new(infcx); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 75dd4d53b36..d189bb23116 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -185,10 +185,8 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> { /// the projection cache key used to track these additional obligations. pub fn poly_project_and_unify_type<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, - obligation: &PolyProjectionObligation<'tcx>) - -> Result<Option<Vec<PredicateObligation<'tcx>>>, - MismatchedProjectionTypes<'tcx>> -{ + obligation: &PolyProjectionObligation<'tcx>, +) -> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>> { debug!("poly_project_and_unify_type(obligation={:?})", obligation); @@ -212,10 +210,8 @@ pub fn poly_project_and_unify_type<'cx, 'tcx>( /// If successful, this may result in additional obligations. fn project_and_unify_type<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, - obligation: &ProjectionObligation<'tcx>) - -> Result<Option<Vec<PredicateObligation<'tcx>>>, - MismatchedProjectionTypes<'tcx>> -{ + obligation: &ProjectionObligation<'tcx>, +) -> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>> { debug!("project_and_unify_type(obligation={:?})", obligation); @@ -253,12 +249,14 @@ fn project_and_unify_type<'cx, 'tcx>( /// them with a fully resolved type where possible. The return value /// combines the normalized result and any additional obligations that /// were incurred as result. -pub fn normalize<'a, 'b, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - cause: ObligationCause<'tcx>, - value: &T) - -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> +pub fn normalize<'a, 'b, 'tcx, T>( + selcx: &'a mut SelectionContext<'b, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + cause: ObligationCause<'tcx>, + value: &T, +) -> Normalized<'tcx, T> +where + T: TypeFoldable<'tcx>, { normalize_with_depth(selcx, param_env, cause, 0, value) } @@ -269,10 +267,10 @@ pub fn normalize_with_depth<'a, 'b, 'tcx, T>( param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, depth: usize, - value: &T) - -> Normalized<'tcx, T> - - where T : TypeFoldable<'tcx> + value: &T, +) -> Normalized<'tcx, T> +where + T: TypeFoldable<'tcx>, { debug!("normalize_with_depth(depth={}, value={:?})", depth, value); let mut normalizer = AssocTypeNormalizer::new(selcx, param_env, cause, depth); @@ -296,12 +294,12 @@ struct AssocTypeNormalizer<'a, 'b: 'a, 'tcx: 'b> { } impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> { - fn new(selcx: &'a mut SelectionContext<'b, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - cause: ObligationCause<'tcx>, - depth: usize) - -> AssocTypeNormalizer<'a, 'b, 'tcx> - { + fn new( + selcx: &'a mut SelectionContext<'b, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + cause: ObligationCause<'tcx>, + depth: usize, + ) -> AssocTypeNormalizer<'a, 'b, 'tcx> { AssocTypeNormalizer { selcx, param_env, @@ -462,9 +460,8 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>( projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, depth: usize, - obligations: &mut Vec<PredicateObligation<'tcx>>) - -> Ty<'tcx> -{ + obligations: &mut Vec<PredicateObligation<'tcx>>, +) -> Ty<'tcx> { opt_normalize_projection_type(selcx, param_env, projection_ty.clone(), cause.clone(), depth, obligations) .unwrap_or_else(move || { @@ -507,9 +504,8 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>( projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, depth: usize, - obligations: &mut Vec<PredicateObligation<'tcx>>) - -> Option<Ty<'tcx>> -{ + obligations: &mut Vec<PredicateObligation<'tcx>>, +) -> Option<Ty<'tcx>> { let infcx = selcx.infcx(); let projection_ty = infcx.resolve_vars_if_possible(&projection_ty); @@ -705,9 +701,10 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>( /// If there are unresolved type variables, then we need to include /// any subobligations that bind them, at least until those type /// variables are fully resolved. -fn prune_cache_value_obligations<'a, 'tcx>(infcx: &'a InferCtxt<'a, 'tcx>, - result: &NormalizedTy<'tcx>) - -> NormalizedTy<'tcx> { +fn prune_cache_value_obligations<'a, 'tcx>( + infcx: &'a InferCtxt<'a, 'tcx>, + result: &NormalizedTy<'tcx>, +) -> NormalizedTy<'tcx> { if infcx.unresolved_type_vars(&result.value).is_none() { return NormalizedTy { value: result.value, obligations: vec![] }; } @@ -768,9 +765,8 @@ fn get_paranoid_cache_value_obligation<'a, 'tcx>( param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, - depth: usize) - -> PredicateObligation<'tcx> -{ + depth: usize, +) -> PredicateObligation<'tcx> { let trait_ref = projection_ty.trait_ref(infcx.tcx).to_poly_trait_ref(); Obligation { cause, @@ -799,13 +795,13 @@ fn get_paranoid_cache_value_obligation<'a, 'tcx>( /// an error for this obligation, but we legitimately should not, /// because it contains `[type error]`. Yuck! (See issue #29857 for /// one case where this arose.) -fn normalize_to_error<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - projection_ty: ty::ProjectionTy<'tcx>, - cause: ObligationCause<'tcx>, - depth: usize) - -> NormalizedTy<'tcx> -{ +fn normalize_to_error<'a, 'tcx>( + selcx: &mut SelectionContext<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + projection_ty: ty::ProjectionTy<'tcx>, + cause: ObligationCause<'tcx>, + depth: usize, +) -> NormalizedTy<'tcx> { let trait_ref = projection_ty.trait_ref(selcx.tcx()).to_poly_trait_ref(); let trait_obligation = Obligation { cause, recursion_depth: depth, @@ -863,9 +859,8 @@ impl<'tcx> Progress<'tcx> { /// - `obligation` must be fully normalized fn project_type<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, - obligation: &ProjectionTyObligation<'tcx>) - -> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>> -{ + obligation: &ProjectionTyObligation<'tcx>, +) -> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>> { debug!("project(obligation={:?})", obligation); @@ -929,8 +924,8 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, - candidate_set: &mut ProjectionTyCandidateSet<'tcx>) -{ + candidate_set: &mut ProjectionTyCandidateSet<'tcx>, +) { debug!("assemble_candidates_from_param_env(..)"); assemble_candidates_from_predicates(selcx, obligation, @@ -954,8 +949,8 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, - candidate_set: &mut ProjectionTyCandidateSet<'tcx>) -{ + candidate_set: &mut ProjectionTyCandidateSet<'tcx>, +) { debug!("assemble_candidates_from_trait_def(..)"); let tcx = selcx.tcx(); @@ -992,8 +987,9 @@ fn assemble_candidates_from_predicates<'cx, 'tcx, I>( obligation_trait_ref: &ty::TraitRef<'tcx>, candidate_set: &mut ProjectionTyCandidateSet<'tcx>, ctor: fn(ty::PolyProjectionPredicate<'tcx>) -> ProjectionTyCandidate<'tcx>, - env_predicates: I) - where I: IntoIterator<Item=ty::Predicate<'tcx>> + env_predicates: I, +) where + I: IntoIterator<Item = ty::Predicate<'tcx>>, { debug!("assemble_candidates_from_predicates(obligation={:?})", obligation); @@ -1033,8 +1029,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, - candidate_set: &mut ProjectionTyCandidateSet<'tcx>) -{ + candidate_set: &mut ProjectionTyCandidateSet<'tcx>, +) { // If we are resolving `<T as TraitRef<...>>::Item == Type`, // start out by selecting the predicate `T as TraitRef<...>`: let poly_trait_ref = obligation_trait_ref.to_poly_trait_ref(); @@ -1181,9 +1177,8 @@ fn confirm_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, - candidate: ProjectionTyCandidate<'tcx>) - -> Progress<'tcx> -{ + candidate: ProjectionTyCandidate<'tcx>, +) -> Progress<'tcx> { debug!("confirm_candidate(candidate={:?}, obligation={:?})", candidate, obligation); @@ -1204,9 +1199,8 @@ fn confirm_select_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, - vtable: Selection<'tcx>) - -> Progress<'tcx> -{ + vtable: Selection<'tcx>, +) -> Progress<'tcx> { match vtable { super::VtableImpl(data) => confirm_impl_candidate(selcx, obligation, data), @@ -1232,10 +1226,9 @@ fn confirm_select_candidate<'cx, 'tcx>( fn confirm_object_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, - obligation: &ProjectionTyObligation<'tcx>, - obligation_trait_ref: &ty::TraitRef<'tcx>) - -> Progress<'tcx> -{ + obligation: &ProjectionTyObligation<'tcx>, + obligation_trait_ref: &ty::TraitRef<'tcx>, +) -> Progress<'tcx> { let self_ty = obligation_trait_ref.self_ty(); let object_ty = selcx.infcx().shallow_resolve(self_ty); debug!("confirm_object_candidate(object_ty={:?})", @@ -1298,9 +1291,8 @@ fn confirm_object_candidate<'cx, 'tcx>( fn confirm_generator_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, - vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>) - -> Progress<'tcx> -{ + vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>, +) -> Progress<'tcx> { let gen_sig = vtable.substs.poly_sig(vtable.generator_def_id, selcx.tcx()); let Normalized { value: gen_sig, @@ -1351,9 +1343,8 @@ fn confirm_generator_candidate<'cx, 'tcx>( fn confirm_fn_pointer_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, - fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>) - -> Progress<'tcx> -{ + fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>, +) -> Progress<'tcx> { let fn_type = selcx.infcx().shallow_resolve(fn_pointer_vtable.fn_ty); let sig = fn_type.fn_sig(selcx.tcx()); let Normalized { @@ -1373,9 +1364,8 @@ fn confirm_fn_pointer_candidate<'cx, 'tcx>( fn confirm_closure_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, - vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>) - -> Progress<'tcx> -{ + vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>, +) -> Progress<'tcx> { let tcx = selcx.tcx(); let infcx = selcx.infcx(); let closure_sig_ty = vtable.substs.closure_sig_ty(vtable.closure_def_id, tcx); @@ -1406,9 +1396,8 @@ fn confirm_callable_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, fn_sig: ty::PolyFnSig<'tcx>, - flag: util::TupleArgumentsFlag) - -> Progress<'tcx> -{ + flag: util::TupleArgumentsFlag, +) -> Progress<'tcx> { let tcx = selcx.tcx(); debug!("confirm_callable_candidate({:?},{:?})", @@ -1481,9 +1470,8 @@ fn confirm_param_env_candidate<'cx, 'tcx>( fn confirm_impl_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, - impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>) - -> Progress<'tcx> -{ + impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>, +) -> Progress<'tcx> { let VtableImplData { impl_def_id, substs, nested } = impl_vtable; let tcx = selcx.tcx(); @@ -1524,9 +1512,8 @@ fn confirm_impl_candidate<'cx, 'tcx>( fn assoc_ty_def<'cx, 'tcx>( selcx: &SelectionContext<'cx, 'tcx>, impl_def_id: DefId, - assoc_ty_def_id: DefId) - -> specialization_graph::NodeItem<ty::AssocItem> -{ + assoc_ty_def_id: DefId, +) -> specialization_graph::NodeItem<ty::AssocItem> { let tcx = selcx.tcx(); let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).ident; let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id; @@ -1609,10 +1596,10 @@ pub struct ProjectionCacheKey<'tcx> { } impl<'cx, 'tcx> ProjectionCacheKey<'tcx> { - pub fn from_poly_projection_predicate(selcx: &mut SelectionContext<'cx, 'tcx>, - predicate: &ty::PolyProjectionPredicate<'tcx>) - -> Option<Self> - { + pub fn from_poly_projection_predicate( + selcx: &mut SelectionContext<'cx, 'tcx>, + predicate: &ty::PolyProjectionPredicate<'tcx>, + ) -> Option<Self> { let infcx = selcx.infcx(); // We don't do cross-snapshot caching of obligations with escaping regions, // so there's no cache key to use diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 8dfb11230f2..b298edfec59 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -44,9 +44,7 @@ pub trait TypeOp<'tcx>: Sized + fmt::Debug { /// which produces the resulting query region constraints. /// /// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html -pub trait QueryTypeOp<'tcx>: - fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'tcx> -{ +pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'tcx> { type QueryResponse: TypeFoldable<'tcx> + Lift<'tcx>; /// Give query the option for a simple fast path that never diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 3f1fcea35a0..3d47e94fb00 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -69,12 +69,13 @@ pub struct OverlapError { /// through associated type projection. We deal with such cases by using /// *fulfillment* to relate the two impls, requiring that all projections are /// resolved. -pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - source_impl: DefId, - source_substs: SubstsRef<'tcx>, - target_node: specialization_graph::Node) - -> SubstsRef<'tcx> { +pub fn translate_substs<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + source_impl: DefId, + source_substs: SubstsRef<'tcx>, + target_node: specialization_graph::Node, +) -> SubstsRef<'tcx> { debug!("translate_substs({:?}, {:?}, {:?}, {:?})", param_env, source_impl, source_substs, target_node); let source_trait_ref = infcx.tcx @@ -209,11 +210,12 @@ pub(super) fn specializes<'tcx>( /// generics of `target_impl`, including both those needed to unify with /// `source_trait_ref` and those whose identity is determined via a where /// clause in the impl. -fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - source_trait_ref: ty::TraitRef<'tcx>, - target_impl: DefId) - -> Result<SubstsRef<'tcx>, ()> { +fn fulfill_implication<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + source_trait_ref: ty::TraitRef<'tcx>, + target_impl: DefId, +) -> Result<SubstsRef<'tcx>, ()> { debug!("fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)", param_env, source_trait_ref, target_impl); diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index a6eae6da922..f736c5ef9b1 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -383,12 +383,7 @@ impl<'tcx> Graph { } /// Insert cached metadata mapping from a child impl back to its parent. - pub fn record_impl_from_cstore( - &mut self, - tcx: TyCtxt<'tcx>, - parent: DefId, - child: DefId, - ) { + pub fn record_impl_from_cstore(&mut self, tcx: TyCtxt<'tcx>, parent: DefId, child: DefId) { if self.parent.insert(child, parent).is_some() { bug!("When recording an impl from the crate store, information about its parent \ was already present."); diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index c7491343426..b6a1ab9fe70 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -12,10 +12,7 @@ use crate::util::nodemap::FxHashSet; use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized}; -fn anonymize_predicate<'tcx>( - tcx: TyCtxt<'tcx>, - pred: &ty::Predicate<'tcx>, -) -> ty::Predicate<'tcx> { +fn anonymize_predicate<'tcx>(tcx: TyCtxt<'tcx>, pred: &ty::Predicate<'tcx>) -> ty::Predicate<'tcx> { match *pred { ty::Predicate::Trait(ref data) => ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)), @@ -420,10 +417,7 @@ pub struct SupertraitDefIds<'tcx> { visited: FxHashSet<DefId>, } -pub fn supertrait_def_ids<'tcx>( - tcx: TyCtxt<'tcx>, - trait_def_id: DefId, -) -> SupertraitDefIds<'tcx> { +pub fn supertrait_def_ids<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) -> SupertraitDefIds<'tcx> { SupertraitDefIds { tcx, stack: vec![trait_def_id], @@ -489,13 +483,12 @@ impl<'tcx, I: Iterator<Item = ty::Predicate<'tcx>>> Iterator for FilterToTraits< /// Instantiate all bound parameters of the impl with the given substs, /// returning the resulting trait ref and all obligations that arise. /// The obligations are closed under normalization. -pub fn impl_trait_ref_and_oblig<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - impl_def_id: DefId, - impl_substs: SubstsRef<'tcx>,) - -> (ty::TraitRef<'tcx>, - Vec<PredicateObligation<'tcx>>) -{ +pub fn impl_trait_ref_and_oblig<'a, 'tcx>( + selcx: &mut SelectionContext<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + impl_def_id: DefId, + impl_substs: SubstsRef<'tcx>, +) -> (ty::TraitRef<'tcx>, Vec<PredicateObligation<'tcx>>) { let impl_trait_ref = selcx.tcx().impl_trait_ref(impl_def_id).unwrap(); let impl_trait_ref = |
