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 | |
| parent | f3f9d6dfd92dfaeb14df891ad27b2531809dd734 (diff) | |
Run `rustfmt --file-lines ...` for changes from previous commits.
Diffstat (limited to 'src/librustc')
50 files changed, 364 insertions, 513 deletions
diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index f72248701d1..4f618457d6c 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -506,12 +506,12 @@ fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar, (pos.0 - source_file_start.0, width as u32) } - - impl<'tcx> HashStable<StableHashingContext<'tcx>> for feature_gate::Features { - fn hash_stable<W: StableHasherResult>(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher<W>) { + fn hash_stable<W: StableHasherResult>( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher<W>, + ) { // Unfortunately we cannot exhaustively list fields here, since the // struct is macro generated. self.declared_lang_features.hash_stable(hcx, hasher); diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 3a46a7e2afb..9b144b1ba3d 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -11,9 +11,10 @@ use crate::middle::region; use crate::ty; use crate::mir; -impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> -for &'tcx ty::List<T> - where T: HashStable<StableHashingContext<'a>> { +impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for &'tcx ty::List<T> +where + T: HashStable<StableHashingContext<'a>>, +{ fn hash_stable<W: StableHasherResult>(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher<W>) { @@ -41,7 +42,8 @@ for &'tcx ty::List<T> } impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx ty::List<T> - where T: HashStable<StableHashingContext<'a>> +where + T: HashStable<StableHashingContext<'a>>, { type KeyType = Fingerprint; @@ -119,18 +121,22 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid { impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::ConstVid<'tcx> { #[inline] - fn hash_stable<W: StableHasherResult>(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher<W>) { + fn hash_stable<W: StableHasherResult>( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher<W>, + ) { self.index.hash_stable(hcx, hasher); } } impl<'tcx> HashStable<StableHashingContext<'tcx>> for ty::BoundVar { #[inline] - fn hash_stable<W: StableHasherResult>(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher<W>) { + fn hash_stable<W: StableHasherResult>( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher<W>, + ) { self.index().hash_stable(hcx, hasher); } } diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 2d99e8a57e0..0bb939889a8 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -44,11 +44,11 @@ pub struct Trace<'a, 'tcx: 'a> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> { #[inline] - pub fn at(&'a self, - cause: &'a ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>) - -> At<'a, 'tcx> - { + pub fn at( + &'a self, + cause: &'a ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + ) -> At<'a, 'tcx> { At { infcx: self, cause, param_env } } } @@ -186,11 +186,9 @@ impl<'a, 'tcx> At<'a, 'tcx> { /// error-reporting, but doesn't actually perform any operation /// yet (this is useful when you want to set the trace using /// distinct values from those you wish to operate upon). - pub fn trace<T>(self, - expected: T, - actual: T) - -> Trace<'a, 'tcx> - where T: ToTrace<'tcx> + pub fn trace<T>(self, expected: T, actual: T) -> Trace<'a, 'tcx> + where + T: ToTrace<'tcx>, { self.trace_exp(true, expected, actual) } @@ -198,12 +196,9 @@ impl<'a, 'tcx> At<'a, 'tcx> { /// Like `trace`, but the expected value is determined by the /// boolean argument (if true, then the first argument `a` is the /// "expected" value). - pub fn trace_exp<T>(self, - a_is_expected: bool, - a: T, - b: T) - -> Trace<'a, 'tcx> - where T: ToTrace<'tcx> + pub fn trace_exp<T>(self, a_is_expected: bool, a: T, b: T) -> Trace<'a, 'tcx> + where + T: ToTrace<'tcx>, { let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b); Trace { at: self, trace: trace, a_is_expected } diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index 59b46b41c8d..8b11ebf9b92 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -49,8 +49,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { pub fn enter_canonical_trait_query<K, R>( &mut self, canonical_key: &Canonical<'tcx, K>, - operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) - -> Fallible<R>, + operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible<R>, ) -> Fallible<CanonicalizedQueryResponse<'tcx, R>> where K: TypeFoldable<'tcx>, @@ -126,7 +125,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { pub fn make_query_response_ignoring_pending_obligations<T>( &self, inference_vars: CanonicalVarValues<'tcx>, - answer: T + answer: T, ) -> Canonical<'tcx, QueryResponse<'tcx, <T as Lift<'tcx>>::Lifted>> where T: Debug + Lift<'tcx> + TypeFoldable<'tcx>, diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index f9fdc66cf3d..39d8241e6b4 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -17,9 +17,10 @@ pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> { } impl<'combine, 'infcx, 'tcx> Equate<'combine, 'infcx, 'tcx> { - pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool) - -> Equate<'combine, 'infcx, 'tcx> - { + pub fn new( + fields: &'combine mut CombineFields<'infcx, 'tcx>, + a_is_expected: bool, + ) -> Equate<'combine, 'infcx, 'tcx> { Equate { fields: fields, a_is_expected: a_is_expected } } } diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 830d6adc1b8..362a680f53c 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -74,7 +74,6 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { } } - impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn extract_type_name( &self, @@ -102,7 +101,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { &self, body_id: Option<hir::BodyId>, span: Span, - ty: Ty<'tcx> + ty: Ty<'tcx>, ) -> DiagnosticBuilder<'tcx> { let ty = self.resolve_vars_if_possible(&ty); let name = self.extract_type_name(&ty, None); @@ -229,7 +228,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn need_type_info_err_in_generator( &self, span: Span, - ty: Ty<'tcx> + ty: Ty<'tcx>, ) -> DiagnosticBuilder<'tcx> { let ty = self.resolve_vars_if_possible(&ty); let name = self.extract_type_name(&ty, None); diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 20331232dc7..645f2b02338 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -50,8 +50,7 @@ pub struct TypeFreshener<'a, 'tcx: 'a> { } impl<'a, 'tcx> TypeFreshener<'a, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) - -> TypeFreshener<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> TypeFreshener<'a, 'tcx> { TypeFreshener { infcx, ty_freshen_count: 0, diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 8e4796dc83d..7f184d3424f 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -14,9 +14,10 @@ pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> { } impl<'combine, 'infcx, 'tcx> Glb<'combine, 'infcx, 'tcx> { - pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool) - -> Glb<'combine, 'infcx, 'tcx> - { + pub fn new( + fields: &'combine mut CombineFields<'infcx, 'tcx>, + a_is_expected: bool, + ) -> Glb<'combine, 'infcx, 'tcx> { Glb { fields: fields, a_is_expected: a_is_expected } } } @@ -85,9 +86,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> { } } -impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> - for Glb<'combine, 'infcx, 'tcx> -{ +impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx, 'tcx> { fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> { self.fields.infcx } diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index 18a30e259eb..c7766636e04 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -41,11 +41,14 @@ pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> { fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; } -pub fn super_lattice_tys<'a, 'tcx, L>(this: &mut L, - a: Ty<'tcx>, - b: Ty<'tcx>) - -> RelateResult<'tcx, Ty<'tcx>> - where L: LatticeDir<'a, 'tcx>, 'tcx: 'a +pub fn super_lattice_tys<'a, 'tcx, L>( + this: &mut L, + a: Ty<'tcx>, + b: Ty<'tcx>, +) -> RelateResult<'tcx, Ty<'tcx>> +where + L: LatticeDir<'a, 'tcx>, + 'tcx: 'a, { debug!("{}.lattice_tys({:?}, {:?})", this.tag(), diff --git a/src/librustc/infer/lexical_region_resolve/graphviz.rs b/src/librustc/infer/lexical_region_resolve/graphviz.rs index 758a01bc52b..aa4bbcad6d5 100644 --- a/src/librustc/infer/lexical_region_resolve/graphviz.rs +++ b/src/librustc/infer/lexical_region_resolve/graphviz.rs @@ -46,8 +46,8 @@ graphs will be printed. \n\ pub fn maybe_print_constraints_for<'a, 'tcx>( region_data: &RegionConstraintData<'tcx>, - region_rels: &RegionRelations<'a, 'tcx>) -{ + region_rels: &RegionRelations<'a, 'tcx>, +) { let tcx = region_rels.tcx; let context = region_rels.context; @@ -127,10 +127,11 @@ enum Edge<'tcx> { } impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> { - fn new(name: String, - region_rels: &'a RegionRelations<'a, 'tcx>, - map: &'a ConstraintMap<'tcx>) - -> ConstraintGraph<'a, 'tcx> { + fn new( + name: String, + region_rels: &'a RegionRelations<'a, 'tcx>, + map: &'a ConstraintMap<'tcx>, + ) -> ConstraintGraph<'a, 'tcx> { let mut i = 0; let mut node_ids = FxHashMap::default(); { @@ -246,10 +247,11 @@ impl<'a, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'tcx> { pub type ConstraintMap<'tcx> = BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>; -fn dump_region_data_to<'a, 'tcx>(region_rels: &RegionRelations<'a, 'tcx>, - map: &ConstraintMap<'tcx>, - path: &str) - -> io::Result<()> { +fn dump_region_data_to<'a, 'tcx>( + region_rels: &RegionRelations<'a, 'tcx>, + map: &ConstraintMap<'tcx>, + path: &str, +) -> io::Result<()> { debug!("dump_region_data map (len: {}) path: {}", map.len(), path); diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 944969e2214..16f5a9d3b36 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -33,10 +33,7 @@ pub fn resolve<'tcx>( region_rels: &RegionRelations<'_, 'tcx>, var_infos: VarInfos, data: RegionConstraintData<'tcx>, -) -> ( - LexicalRegionResolutions<'tcx>, - Vec<RegionResolutionError<'tcx>>, -) { +) -> (LexicalRegionResolutions<'tcx>, Vec<RegionResolutionError<'tcx>>) { debug!("RegionConstraintData: resolve_regions()"); let mut errors = vec![]; let mut resolver = LexicalResolver { diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index 6e1ca9e7ed0..2a9f5856eb8 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -14,9 +14,10 @@ pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> { } impl<'combine, 'infcx, 'tcx> Lub<'combine, 'infcx, 'tcx> { - pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool) - -> Lub<'combine, 'infcx, 'tcx> - { + pub fn new( + fields: &'combine mut CombineFields<'infcx, 'tcx>, + a_is_expected: bool, + ) -> Lub<'combine, 'infcx, 'tcx> { Lub { fields: fields, a_is_expected: a_is_expected } } } @@ -85,9 +86,7 @@ impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> { } } -impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> - for Lub<'combine, 'infcx, 'tcx> -{ +impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx, 'tcx> { fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> { self.fields.infcx } diff --git a/src/librustc/infer/outlives/env.rs b/src/librustc/infer/outlives/env.rs index ff27bbf7db2..4b5df444148 100644 --- a/src/librustc/infer/outlives/env.rs +++ b/src/librustc/infer/outlives/env.rs @@ -190,11 +190,8 @@ impl<'a, 'tcx: 'a> OutlivesEnvironment<'tcx> { /// contain inference variables, it must be supplied, in which /// case we will register "givens" on the inference context. (See /// `RegionConstraintData`.) - fn add_outlives_bounds<I>( - &mut self, - infcx: Option<&InferCtxt<'a, 'tcx>>, - outlives_bounds: I, - ) where + fn add_outlives_bounds<I>(&mut self, infcx: Option<&InferCtxt<'a, 'tcx>>, outlives_bounds: I) + where I: IntoIterator<Item = OutlivesBound<'tcx>>, { // Record relationships such as `T:'x` that don't go into the diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index 5ca79bfa7bc..810c64185a7 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -105,7 +105,7 @@ pub struct UnresolvedTypeFinder<'a, 'tcx: 'a> { infcx: &'a InferCtxt<'a, 'tcx>, /// Used to find the type parameter name and location for error reporting. - pub first_unresolved: Option<(Ty<'tcx>,Option<Span>)>, + pub first_unresolved: Option<(Ty<'tcx>, Option<Span>)>, } impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> { @@ -157,9 +157,9 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> { /// Full type resolution replaces all type and region variables with /// their concrete results. If any variable cannot be replaced (never unified, etc) /// then an `Err` result is returned. -pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, - value: &T) -> FixupResult<'tcx, T> - where T : TypeFoldable<'tcx> +pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, value: &T) -> FixupResult<'tcx, T> +where + T: TypeFoldable<'tcx>, { let mut full_resolver = FullTypeResolver { infcx: infcx, err: None }; let result = value.fold_with(&mut full_resolver); diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index 0284e087b7e..ed84e3f63ae 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -17,9 +17,10 @@ pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> { } impl<'combine, 'infcx, 'tcx> Sub<'combine, 'infcx, 'tcx> { - pub fn new(f: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool) - -> Sub<'combine, 'infcx, 'tcx> - { + pub fn new( + f: &'combine mut CombineFields<'infcx, 'tcx>, + a_is_expected: bool, + ) -> Sub<'combine, 'infcx, 'tcx> { Sub { fields: f, a_is_expected: a_is_expected } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index c4a37d83866..468d909e549 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -1456,10 +1456,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc }) } -fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( - tcx: TyCtxt<'tcx>, - builtin_lints: T, -) { +fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, builtin_lints: T) { let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap(); if !tcx.sess.opts.debugging_opts.no_interleave_lints { diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 704be9600fa..d9e7caebb98 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -140,10 +140,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) { } } -fn configure_main( - tcx: TyCtxt<'_>, - visitor: &EntryContext<'_, '_>, -) -> Option<(DefId, EntryFnType)> { +fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(DefId, EntryFnType)> { if let Some((hir_id, _)) = visitor.start_fn { Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Start)) } else if let Some((hir_id, _)) = visitor.attr_main_fn { diff --git a/src/librustc/middle/exported_symbols.rs b/src/librustc/middle/exported_symbols.rs index 78a3e3ff268..20278809304 100644 --- a/src/librustc/middle/exported_symbols.rs +++ b/src/librustc/middle/exported_symbols.rs @@ -52,11 +52,7 @@ impl<'tcx> ExportedSymbol<'tcx> { } } - pub fn compare_stable( - &self, - tcx: TyCtxt<'tcx>, - other: &ExportedSymbol<'tcx>, - ) -> cmp::Ordering { + pub fn compare_stable(&self, tcx: TyCtxt<'tcx>, other: &ExportedSymbol<'tcx>) -> cmp::Ordering { match *self { ExportedSymbol::NonGeneric(self_def_id) => match *other { ExportedSymbol::NonGeneric(other_def_id) => { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 80c26c132f6..61770e6f487 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -288,14 +288,14 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { - pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a), - infcx: &'a InferCtxt<'a, 'tcx>, - body_owner: DefId, - param_env: ty::ParamEnv<'tcx>, - region_scope_tree: &'a region::ScopeTree, - tables: &'a ty::TypeckTables<'tcx>) - -> Self - { + pub fn with_infer( + delegate: &'a mut (dyn Delegate<'tcx> + 'a), + infcx: &'a InferCtxt<'a, 'tcx>, + body_owner: DefId, + param_env: ty::ParamEnv<'tcx>, + region_scope_tree: &'a region::ScopeTree, + tables: &'a ty::TypeckTables<'tcx>, + ) -> Self { ExprUseVisitor { mc: mc::MemCategorizationContext::with_infer( infcx, @@ -974,12 +974,12 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } } -fn copy_or_move<'a, 'tcx>(mc: &mc::MemCategorizationContext<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - cmt: &mc::cmt_<'tcx>, - move_reason: MoveReason) - -> ConsumeMode -{ +fn copy_or_move<'a, 'tcx>( + mc: &mc::MemCategorizationContext<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + cmt: &mc::cmt_<'tcx>, + move_reason: MoveReason, +) -> ConsumeMode { if !mc.type_is_copy_modulo_regions(param_env, cmt.ty, cmt.span) { Move(move_reason) } else { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bc87aa8f872..3b21b81df7b 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -432,11 +432,12 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { /// temporaries may be overly conservative; /// - similarly, as the results of upvar analysis are not yet /// known, the results around upvar accesses may be incorrect. - pub fn with_infer(infcx: &'a InferCtxt<'a, 'tcx>, - body_owner: DefId, - region_scope_tree: &'a region::ScopeTree, - tables: &'a ty::TypeckTables<'tcx>) - -> MemCategorizationContext<'a, 'tcx> { + pub fn with_infer( + infcx: &'a InferCtxt<'a, 'tcx>, + body_owner: DefId, + region_scope_tree: &'a region::ScopeTree, + tables: &'a ty::TypeckTables<'tcx>, + ) -> MemCategorizationContext<'a, 'tcx> { let tcx = infcx.tcx; // Subtle: we can't do rvalue promotion analysis until the @@ -586,10 +587,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> { // This recursion helper avoids going through *too many* // adjustments, since *only* non-overloaded deref recurses. - fn helper<'a, 'tcx>(mc: &MemCategorizationContext<'a, 'tcx>, - expr: &hir::Expr, - adjustments: &[adjustment::Adjustment<'tcx>]) - -> McResult<cmt_<'tcx>> { + fn helper<'a, 'tcx>( + mc: &MemCategorizationContext<'a, 'tcx>, + expr: &hir::Expr, + adjustments: &[adjustment::Adjustment<'tcx>], + ) -> McResult<cmt_<'tcx>> { match adjustments.split_last() { None => mc.cat_expr_unadjusted(expr), Some((adjustment, previous)) => { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 546d51e9124..8b1eeeb7f51 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -646,11 +646,7 @@ impl<'tcx> ScopeTree { /// Assuming that the provided region was defined within this `ScopeTree`, /// returns the outermost `Scope` that the region outlives. - pub fn early_free_scope( - &self, - tcx: TyCtxt<'tcx>, - br: &ty::EarlyBoundRegion, - ) -> Scope { + pub fn early_free_scope(&self, tcx: TyCtxt<'tcx>, br: &ty::EarlyBoundRegion) -> Scope { let param_owner = tcx.parent(br.def_id).unwrap(); let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap(); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index e187a3ced3f..8bc3158bd3c 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -1125,12 +1125,7 @@ fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &P<[hir::Gener } } -fn signal_shadowing_problem( - tcx: TyCtxt<'_>, - name: ast::Name, - orig: Original, - shadower: Shadower, -) { +fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: ast::Name, orig: Original, shadower: Shadower) { let mut err = if let (ShadowKind::Lifetime, ShadowKind::Lifetime) = (orig.kind, shadower.kind) { // lifetime/lifetime shadowing is an error struct_span_err!( diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 4a8f503b14f..afabcdfadd0 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -234,12 +234,7 @@ impl<'tcx> Operand<'tcx> { } impl<'tcx> BinOp { - pub fn ty( - &self, - tcx: TyCtxt<'tcx>, - lhs_ty: Ty<'tcx>, - rhs_ty: Ty<'tcx>, - ) -> Ty<'tcx> { + pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> { // FIXME: handle SIMD correctly match self { &BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem | 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 = diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index 2a228ed79a4..9ba99768215 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -104,11 +104,7 @@ pub struct OverloadedDeref<'tcx> { } impl<'tcx> OverloadedDeref<'tcx> { - pub fn method_call( - &self, - tcx: TyCtxt<'tcx>, - source: Ty<'tcx>, - ) -> (DefId, SubstsRef<'tcx>) { + pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> (DefId, SubstsRef<'tcx>) { let trait_def_id = match self.mutbl { hir::MutImmutable => tcx.lang_items().deref_trait(), hir::MutMutable => tcx.lang_items().deref_mut_trait() diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index a28da275ff1..e5d06532b3a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -139,7 +139,7 @@ impl<'tcx> CtxtInterners<'tcx> { fn intern_ty( local: &CtxtInterners<'tcx>, global: &CtxtInterners<'tcx>, - st: TyKind<'tcx> + st: TyKind<'tcx>, ) -> Ty<'tcx> { let flags = super::flags::FlagComputation::for_sty(&st); @@ -857,7 +857,6 @@ BraceStructLiftImpl! { } } - /// Canonicalized user type annotation. pub type CanonicalUserType<'tcx> = Canonical<'tcx, UserType<'tcx>>; @@ -1139,12 +1138,13 @@ impl<'tcx> TyCtxt<'tcx> { self.arena.alloc(Steal::new(mir)) } - pub fn alloc_adt_def(self, - did: DefId, - kind: AdtKind, - variants: IndexVec<VariantIdx, ty::VariantDef>, - repr: ReprOptions) - -> &'tcx ty::AdtDef { + pub fn alloc_adt_def( + self, + did: DefId, + kind: AdtKind, + variants: IndexVec<VariantIdx, ty::VariantDef>, + repr: ReprOptions, + ) -> &'tcx ty::AdtDef { let def = ty::AdtDef::new(self, did, kind, variants, repr); self.arena.alloc(def) } @@ -1923,9 +1923,9 @@ pub mod tls { /// Sets `context` as the new current ImplicitCtxt for the duration of the function `f` #[inline] - pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, - f: F) -> R - where F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R + pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, f: F) -> R + where + F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R, { set_tlv(context as *const _ as usize, || { f(&context) @@ -1999,7 +1999,8 @@ pub mod tls { /// Allows access to the current ImplicitCtxt in a closure if one is available #[inline] pub fn with_context_opt<F, R>(f: F) -> R - where F: for<'a, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'tcx>>) -> R + where + F: for<'a, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'tcx>>) -> R, { let context = get_tlv(); if context == 0 { @@ -2017,7 +2018,8 @@ pub mod tls { /// Panics if there is no ImplicitCtxt available #[inline] pub fn with_context<F, R>(f: F) -> R - where F: for<'a, 'tcx> FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R + where + F: for<'a, 'tcx> FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R, { with_context_opt(|opt_context| f(opt_context.expect("no ImplicitCtxt stored in tls"))) } @@ -2254,14 +2256,14 @@ impl<'tcx> Borrow<GoalKind<'tcx>> for Interned<'tcx, GoalKind<'tcx>> { } impl<'tcx> Borrow<[ExistentialPredicate<'tcx>]> - for Interned<'tcx, List<ExistentialPredicate<'tcx>>> { + for Interned<'tcx, List<ExistentialPredicate<'tcx>>> +{ fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'tcx>] { &self.0[..] } } -impl<'tcx> Borrow<[Predicate<'tcx>]> - for Interned<'tcx, List<Predicate<'tcx>>> { +impl<'tcx> Borrow<[Predicate<'tcx>]> for Interned<'tcx, List<Predicate<'tcx>>> { fn borrow<'a>(&'a self) -> &'a [Predicate<'tcx>] { &self.0[..] } @@ -2273,15 +2275,13 @@ impl<'tcx> Borrow<Const<'tcx>> for Interned<'tcx, Const<'tcx>> { } } -impl<'tcx> Borrow<[Clause<'tcx>]> -for Interned<'tcx, List<Clause<'tcx>>> { +impl<'tcx> Borrow<[Clause<'tcx>]> for Interned<'tcx, List<Clause<'tcx>>> { fn borrow<'a>(&'a self) -> &'a [Clause<'tcx>] { &self.0[..] } } -impl<'tcx> Borrow<[Goal<'tcx>]> -for Interned<'tcx, List<Goal<'tcx>>> { +impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List<Goal<'tcx>>> { fn borrow<'a>(&'a self) -> &'a [Goal<'tcx>] { &self.0[..] } @@ -2942,9 +2942,7 @@ impl<'tcx> TyCtxt<'tcx> { .unwrap_or(false) } - pub fn object_lifetime_defaults(self, id: HirId) - -> Option<&'tcx [ObjectLifetimeDefault]> - { + pub fn object_lifetime_defaults(self, id: HirId) -> Option<&'tcx [ObjectLifetimeDefault]> { self.object_lifetime_defaults_map(id.owner) .and_then(|map| map.get(&id.local_id).map(|v| &**v)) } diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index 9da35824bd0..8b98a2916a7 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -443,12 +443,7 @@ struct BoundVarReplacer<'a, 'tcx> { } impl<'a, 'tcx> BoundVarReplacer<'a, 'tcx> { - fn new<F, G, H>( - tcx: TyCtxt<'tcx>, - fld_r: &'a mut F, - fld_t: &'a mut G, - fld_c: &'a mut H, - ) -> Self + fn new<F, G, H>(tcx: TyCtxt<'tcx>, fld_r: &'a mut F, fld_t: &'a mut G, fld_c: &'a mut H) -> Self where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, G: FnMut(ty::BoundTy) -> Ty<'tcx>, diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 70db4f19a4c..6cee2709b63 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2443,23 +2443,26 @@ impl_stable_hash_for!(struct crate::ty::layout::AbiAndPrefAlign { }); impl<'tcx> HashStable<StableHashingContext<'tcx>> for Align { - fn hash_stable<W: StableHasherResult>(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher<W>) { + fn hash_stable<W: StableHasherResult>( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher<W>, + ) { self.bytes().hash_stable(hcx, hasher); } } impl<'tcx> HashStable<StableHashingContext<'tcx>> for Size { - fn hash_stable<W: StableHasherResult>(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher<W>) { + fn hash_stable<W: StableHasherResult>( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher<W>, + ) { self.bytes().hash_stable(hcx, hasher); } } -impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for LayoutError<'tcx> -{ +impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for LayoutError<'tcx> { fn hash_stable<W: StableHasherResult>(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher<W>) { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2e39f045747..c932586c078 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -975,11 +975,7 @@ impl<'tcx> Generics { } /// Returns the `GenericParamDef` associated with this `ParamTy`. - pub fn type_param( - &'tcx self, - param: &ParamTy, - tcx: TyCtxt<'tcx>, - ) -> &'tcx GenericParamDef { + pub fn type_param(&'tcx self, param: &ParamTy, tcx: TyCtxt<'tcx>) -> &'tcx GenericParamDef { if let Some(index) = param.index.checked_sub(self.parent_count as u32) { let param = &self.params[index as usize]; match param.kind { @@ -993,11 +989,7 @@ impl<'tcx> Generics { } /// Returns the `ConstParameterDef` associated with this `ParamConst`. - pub fn const_param( - &'tcx self, - param: &ParamConst, - tcx: TyCtxt<'tcx>, - ) -> &GenericParamDef { + pub fn const_param(&'tcx self, param: &ParamConst, tcx: TyCtxt<'tcx>) -> &GenericParamDef { if let Some(index) = param.index.checked_sub(self.parent_count as u32) { let param = &self.params[index as usize]; match param.kind { @@ -1772,7 +1764,8 @@ impl<'tcx, T> ParamEnvAnd<'tcx, T> { } impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for ParamEnvAnd<'tcx, T> - where T: HashStable<StableHashingContext<'a>> +where + T: HashStable<StableHashingContext<'a>>, { fn hash_stable<W: StableHasherResult>(&self, hcx: &mut StableHashingContext<'a>, @@ -2363,11 +2356,7 @@ impl<'tcx> AdtDef { } #[inline] - pub fn eval_explicit_discr( - &self, - tcx: TyCtxt<'tcx>, - expr_did: DefId, - ) -> Option<Discr<'tcx>> { + pub fn eval_explicit_discr(&self, tcx: TyCtxt<'tcx>, expr_did: DefId) -> Option<Discr<'tcx>> { let param_env = ParamEnv::empty(); let repr_type = self.repr.discr_type(); let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), expr_did); @@ -2714,7 +2703,7 @@ impl BorrowKind { #[derive(Debug, Clone)] pub enum Attributes<'tcx> { Owned(Lrc<[ast::Attribute]>), - Borrowed(&'tcx [ast::Attribute]) + Borrowed(&'tcx [ast::Attribute]), } impl<'tcx> ::std::ops::Deref for Attributes<'tcx> { @@ -3007,9 +2996,7 @@ impl<'tcx> TyCtxt<'tcx> { } /// Returns the possibly-auto-generated MIR of a `(DefId, Subst)` pair. - pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>) - -> &'tcx Body<'tcx> - { + pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> { match instance { ty::InstanceDef::Item(did) => { self.optimized_mir(did) @@ -3300,10 +3287,7 @@ fn crate_hash<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> Svh { tcx.hir().crate_hash } -fn instance_def_size_estimate<'tcx>( - tcx: TyCtxt<'tcx>, - instance_def: InstanceDef<'tcx>, -) -> usize { +fn instance_def_size_estimate<'tcx>(tcx: TyCtxt<'tcx>, instance_def: InstanceDef<'tcx>) -> usize { match instance_def { InstanceDef::Item(..) | InstanceDef::DropGlue(..) => { diff --git a/src/librustc/ty/print/mod.rs b/src/librustc/ty/print/mod.rs index 8e157bdd259..092e7c6f3ff 100644 --- a/src/librustc/ty/print/mod.rs +++ b/src/librustc/ty/print/mod.rs @@ -326,9 +326,7 @@ impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for Ty<'tcx> { } } -impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> - for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> -{ +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> { type Output = P::DynExistential; type Error = P::Error; fn print(&self, cx: P) -> Result<Self::Output, Self::Error> { diff --git a/src/librustc/ty/print/obsolete.rs b/src/librustc/ty/print/obsolete.rs index 2bfe35d4f1c..16fb3348039 100644 --- a/src/librustc/ty/print/obsolete.rs +++ b/src/librustc/ty/print/obsolete.rs @@ -23,11 +23,7 @@ pub struct DefPathBasedNames<'tcx> { } impl DefPathBasedNames<'tcx> { - pub fn new( - tcx: TyCtxt<'tcx>, - omit_disambiguators: bool, - omit_local_crate_name: bool, - ) -> Self { + pub fn new(tcx: TyCtxt<'tcx>, omit_disambiguators: bool, omit_local_crate_name: bool) -> Self { DefPathBasedNames { tcx, omit_disambiguators, omit_local_crate_name } } diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 95c5048b378..b79d7f06cd6 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -167,15 +167,15 @@ impl RegionHighlightMode { /// Trait for printers that pretty-print using `fmt::Write` to the printer. pub trait PrettyPrinter<'tcx>: - Printer<'tcx, + Printer< + 'tcx, Error = fmt::Error, Path = Self, Region = Self, Type = Self, DynExistential = Self, Const = Self, - > + - fmt::Write + > + fmt::Write { /// Like `print_def_path` but for value paths. fn print_value_path( @@ -186,21 +186,17 @@ pub trait PrettyPrinter<'tcx>: self.print_def_path(def_id, substs) } - fn in_binder<T>( - self, - value: &ty::Binder<T>, - ) -> Result<Self, Self::Error> - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> + fn in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, Self::Error> + where + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, { value.skip_binder().print(self) } /// Print comma-separated elements. - fn comma_sep<T>( - mut self, - mut elems: impl Iterator<Item = T>, - ) -> Result<Self, Self::Error> - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error> + where + T: Print<'tcx, Self, Output = Self, Error = Self::Error>, { if let Some(first) = elems.next() { self = first.print(self)?; @@ -1239,11 +1235,9 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> { Ok(self) } - fn in_binder<T>( - self, - value: &ty::Binder<T>, - ) -> Result<Self, Self::Error> - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> + fn in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, Self::Error> + where + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, { self.pretty_in_binder(value) } @@ -1417,11 +1411,9 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> { // HACK(eddyb) limited to `FmtPrinter` because of `binder_depth`, // `region_index` and `used_region_names`. impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> { - pub fn pretty_in_binder<T>( - mut self, - value: &ty::Binder<T>, - ) -> Result<Self, fmt::Error> - where T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx> + pub fn pretty_in_binder<T>(mut self, value: &ty::Binder<T>) -> Result<Self, fmt::Error> + where + T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>, { fn name_by_region_index(index: usize) -> InternedString { match index { @@ -1510,9 +1502,9 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> { } } -impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> - for ty::Binder<T> - where T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx> +impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder<T> +where + T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>, { type Output = P; type Error = P::Error; @@ -1521,10 +1513,10 @@ impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> } } -impl<'tcx, T, U, P: PrettyPrinter<'tcx>> Print<'tcx, P> - for ty::OutlivesPredicate<T, U> - where T: Print<'tcx, P, Output = P, Error = P::Error>, - U: Print<'tcx, P, Output = P, Error = P::Error>, +impl<'tcx, T, U, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::OutlivesPredicate<T, U> +where + T: Print<'tcx, P, Output = P, Error = P::Error>, + U: Print<'tcx, P, Output = P, Error = P::Error>, { type Output = P; type Error = P::Error; diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 3d00de8c8c1..dcc467a61b5 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -100,11 +100,7 @@ impl<'tcx> QueryJob<'tcx> { } #[cfg(not(parallel_compiler))] - pub(super) fn find_cycle_in_stack( - &self, - tcx: TyCtxt<'tcx>, - span: Span, - ) -> CycleError<'tcx> { + pub(super) fn find_cycle_in_stack(&self, tcx: TyCtxt<'tcx>, span: Span) -> CycleError<'tcx> { // Get the current executing query (waiter) and find the waitee amongst its parents let mut current_job = tls::with_related_context(tcx, |icx| icx.query.clone()); let mut cycle = Vec::new(); diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 72ebd3276c7..6f83991a2da 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -156,11 +156,7 @@ impl<'sess> OnDiskCache<'sess> { } } - pub fn serialize<'tcx, E>( - &self, - tcx: TyCtxt<'tcx>, - encoder: &mut E, - ) -> Result<(), E::Error> + pub fn serialize<'tcx, E>(&self, tcx: TyCtxt<'tcx>, encoder: &mut E) -> Result<(), E::Error> where E: ty_codec::TyEncoder, { diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 0051832c5df..48e68167f82 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -104,11 +104,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> { /// This function is inlined because that results in a noticeable speed-up /// for some compile-time benchmarks. #[inline(always)] - pub(super) fn try_get( - tcx: TyCtxt<'tcx>, - span: Span, - key: &Q::Key, - ) -> TryGetJob<'a, 'tcx, Q> { + pub(super) fn try_get(tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key) -> TryGetJob<'a, 'tcx, Q> { let cache = Q::query_cache(tcx); loop { let mut lock = cache.borrow_mut(); @@ -351,11 +347,7 @@ impl<'tcx> TyCtxt<'tcx> { } #[inline(never)] - pub(super) fn get_query<Q: QueryDescription<'tcx>>( - self, - span: Span, - key: Q::Key) - -> Q::Value { + pub(super) fn get_query<Q: QueryDescription<'tcx>>(self, span: Span, key: Q::Key) -> Q::Value { debug!("ty::query::get_query<{}>(key={:?}, span={:?})", Q::NAME.as_str(), key, @@ -444,9 +436,8 @@ impl<'tcx> TyCtxt<'tcx> { key: Q::Key, prev_dep_node_index: SerializedDepNodeIndex, dep_node_index: DepNodeIndex, - dep_node: &DepNode - ) -> Q::Value - { + dep_node: &DepNode, + ) -> Q::Value { // Note this function can be called concurrently from the same query // We must ensure that this is handled correctly @@ -537,8 +528,8 @@ impl<'tcx> TyCtxt<'tcx> { self, key: Q::Key, job: JobOwner<'_, 'tcx, Q>, - dep_node: DepNode) - -> (Q::Value, DepNodeIndex) { + dep_node: DepNode, + ) -> (Q::Value, DepNodeIndex) { // If the following assertion triggers, it can have two reasons: // 1. Something is wrong with DepNode creation, either here or // in DepGraph::try_mark_green() @@ -623,12 +614,7 @@ impl<'tcx> TyCtxt<'tcx> { } #[allow(dead_code)] - fn force_query<Q: QueryDescription<'tcx>>( - self, - key: Q::Key, - span: Span, - dep_node: DepNode - ) { + fn force_query<Q: QueryDescription<'tcx>>(self, key: Q::Key, span: Span, dep_node: DepNode) { profq_msg!( self, ProfileQueriesMsg::QueryBegin(span.data(), diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 9756e9c872b..a4efb566e13 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -804,7 +804,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::AdtDef { } } -impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) { +impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) { (self.0.fold_with(folder), self.1.fold_with(folder)) } @@ -862,7 +862,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> { } } -impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> { +impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self { self.map_bound_ref(|ty| ty.fold_with(folder)) } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index ed4a2cd7a29..810a26d3736 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -558,11 +558,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { /// This is the types of the fields of a generator which are not stored in a /// variant. #[inline] - pub fn prefix_tys( - self, - def_id: DefId, - tcx: TyCtxt<'tcx>, - ) -> impl Iterator<Item = Ty<'tcx>> { + pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> impl Iterator<Item = Ty<'tcx>> { self.upvar_tys(def_id, tcx) } } @@ -2265,11 +2261,7 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn from_bits( - tcx: TyCtxt<'tcx>, - bits: u128, - ty: ParamEnvAnd<'tcx, Ty<'tcx>>, - ) -> &'tcx Self { + pub fn from_bits(tcx: TyCtxt<'tcx>, bits: u128, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> &'tcx Self { let ty = tcx.lift_to_global(&ty).unwrap(); let size = tcx.layout_of(ty).unwrap_or_else(|e| { panic!("could not compute layout for {:?}: {:?}", ty, e) @@ -2308,11 +2300,7 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn assert_bits( - &self, - tcx: TyCtxt<'_>, - ty: ParamEnvAnd<'tcx, Ty<'tcx>>, - ) -> Option<u128> { + pub fn assert_bits(&self, tcx: TyCtxt<'_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option<u128> { assert_eq!(self.ty, ty.value); let ty = tcx.lift_to_global(&ty).unwrap(); let size = tcx.layout_of(ty).ok()?.size; diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 5a97d8bb725..79dcd327f52 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -241,12 +241,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { tcx.intern_substs(&substs) } - pub fn extend_to<F>( - &self, - tcx: TyCtxt<'tcx>, - def_id: DefId, - mut mk_kind: F, - ) -> SubstsRef<'tcx> + pub fn extend_to<F>(&self, tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>, { @@ -418,21 +413,11 @@ pub trait Subst<'tcx>: Sized { self.subst_spanned(tcx, substs, None) } - fn subst_spanned( - &self, - tcx: TyCtxt<'tcx>, - substs: &[Kind<'tcx>], - span: Option<Span>, - ) -> Self; + fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option<Span>) -> Self; } impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { - fn subst_spanned( - &self, - tcx: TyCtxt<'tcx>, - substs: &[Kind<'tcx>], - span: Option<Span>, - ) -> T { + fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option<Span>) -> T { let mut folder = SubstFolder { tcx, substs, span, diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 8b1d9d97276..a3b99f143d0 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -105,11 +105,7 @@ impl<'tcx> Discr<'tcx> { pub trait IntTypeExt { fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>; - fn disr_incr<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - val: Option<Discr<'tcx>>, - ) -> Option<Discr<'tcx>>; + fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx>, val: Option<Discr<'tcx>>) -> Option<Discr<'tcx>>; fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Discr<'tcx>; } @@ -138,11 +134,7 @@ impl IntTypeExt for attr::IntType { } } - fn disr_incr<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - val: Option<Discr<'tcx>>, - ) -> Option<Discr<'tcx>> { + fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx>, val: Option<Discr<'tcx>>) -> Option<Discr<'tcx>> { if let Some(val) = val { assert_eq!(self.to_ty(tcx), val.ty); let (new, oflo) = val.checked_add(tcx, 1); @@ -714,11 +706,7 @@ impl<'tcx> ty::TyS<'tcx> { /// over-approximation in generic contexts, where one can have /// strange rules like `<T as Foo<'static>>::Bar: Sized` that /// actually carry lifetime requirements. - pub fn is_sized( - &'tcx self, - tcx_at: TyCtxtAt<'tcx>, - param_env: ty::ParamEnv<'tcx>, - ) -> bool { + pub fn is_sized(&'tcx self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool { tcx_at.is_sized_raw(param_env.and(self)) } @@ -979,10 +967,7 @@ fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>> #[derive(Clone, HashStable)] pub struct NeedsDrop(pub bool); -fn needs_drop_raw<'tcx>( - tcx: TyCtxt<'tcx>, - query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, -) -> NeedsDrop { +fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> NeedsDrop { let (param_env, ty) = query.into_parts(); let needs_drop = |ty: Ty<'tcx>| -> bool { diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 65feb4c08d9..6b2f00e5f70 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -15,13 +15,13 @@ use crate::mir::interpret::ConstValue; /// inference variable, returns `None`, because we are not able to /// make any progress at all. This is to prevent "livelock" where we /// say "$0 is WF if $0 is WF". -pub fn obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - body_id: hir::HirId, - ty: Ty<'tcx>, - span: Span) - -> Option<Vec<traits::PredicateObligation<'tcx>>> -{ +pub fn obligations<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + body_id: hir::HirId, + ty: Ty<'tcx>, + span: Span, +) -> Option<Vec<traits::PredicateObligation<'tcx>>> { let mut wf = WfPredicates { infcx, param_env, body_id, @@ -41,25 +41,25 @@ pub fn obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, /// well-formed. For example, if there is a trait `Set` defined like /// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF /// if `Bar: Eq`. -pub fn trait_obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - body_id: hir::HirId, - trait_ref: &ty::TraitRef<'tcx>, - span: Span) - -> Vec<traits::PredicateObligation<'tcx>> -{ +pub fn trait_obligations<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + body_id: hir::HirId, + trait_ref: &ty::TraitRef<'tcx>, + span: Span, +) -> Vec<traits::PredicateObligation<'tcx>> { let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![] }; wf.compute_trait_ref(trait_ref, Elaborate::All); wf.normalize() } -pub fn predicate_obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - body_id: hir::HirId, - predicate: &ty::Predicate<'tcx>, - span: Span) - -> Vec<traits::PredicateObligation<'tcx>> -{ +pub fn predicate_obligations<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + body_id: hir::HirId, + predicate: &ty::Predicate<'tcx>, + span: Span, +) -> Vec<traits::PredicateObligation<'tcx>> { let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![] }; // (*) ok to skip binders, because wf code is prepared for it |
