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 | |
| parent | f3f9d6dfd92dfaeb14df891ad27b2531809dd734 (diff) | |
| download | rust-afc39bbf2447844569e872468f9440d430b81a46.tar.gz rust-afc39bbf2447844569e872468f9440d430b81a46.zip | |
Run `rustfmt --file-lines ...` for changes from previous commits.
Diffstat (limited to 'src')
107 files changed, 813 insertions, 1159 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 diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index e03de7799d3..a0dd767a3a8 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -125,11 +125,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend { ) { unsafe { allocator::codegen(tcx, mods, kind) } } - fn compile_codegen_unit<'a, 'tcx: 'a>( - &self, - tcx: TyCtxt<'tcx>, - cgu_name: InternedString, - ) { + fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString) { base::compile_codegen_unit(tcx, cgu_name); } fn target_machine_factory( diff --git a/src/librustc_codegen_ssa/debuginfo/type_names.rs b/src/librustc_codegen_ssa/debuginfo/type_names.rs index 9dd6bf77a04..8f0bb6ee198 100644 --- a/src/librustc_codegen_ssa/debuginfo/type_names.rs +++ b/src/librustc_codegen_ssa/debuginfo/type_names.rs @@ -210,12 +210,7 @@ pub fn push_debuginfo_type_name<'tcx>( } } - fn push_item_name( - tcx: TyCtxt<'tcx>, - def_id: DefId, - qualified: bool, - output: &mut String, - ) { + fn push_item_name(tcx: TyCtxt<'tcx>, def_id: DefId, qualified: bool, output: &mut String) { if qualified { output.push_str(&tcx.crate_name(def_id.krate).as_str()); for path_element in tcx.def_path(def_id).data { diff --git a/src/librustc_codegen_utils/symbol_names/legacy.rs b/src/librustc_codegen_utils/symbol_names/legacy.rs index 72eb4969aa8..22b7e0a2fb0 100644 --- a/src/librustc_codegen_utils/symbol_names/legacy.rs +++ b/src/librustc_codegen_utils/symbol_names/legacy.rs @@ -367,11 +367,9 @@ impl PrettyPrinter<'tcx> for SymbolPrinter<'tcx> { ) -> bool { false } - 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)?; diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 6d667aa008f..a43347a2197 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -184,11 +184,7 @@ impl Visitor<'tcx> for IfThisChanged<'tcx> { } } -fn check_paths<'tcx>( - tcx: TyCtxt<'tcx>, - if_this_changed: &Sources, - then_this_would_need: &Targets, -) { +fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_would_need: &Targets) { // Return early here so as not to construct the query, which is not cheap. if if_this_changed.is_empty() { for &(target_span, _, _, _) in then_this_would_need { diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index cb995907a51..69cb696f4c5 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -811,7 +811,7 @@ pub fn create_global_ctxt( resolutions: Resolutions, outputs: OutputFilenames, tx: mpsc::Sender<Box<dyn Any + Send>>, - crate_name: &str + crate_name: &str, ) -> BoxedGlobalCtxt { let sess = compiler.session().clone(); let cstore = compiler.cstore.clone(); diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index a3cd3320907..4bafe16b8e6 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -620,7 +620,7 @@ impl<'a, 'tcx> CrateMetadata { tcx: TyCtxt<'tcx>, ) -> ty::GenericPredicates<'tcx> { self.entry(item_id).predicates.unwrap().decode((self, tcx)) - } +} pub fn get_predicates_defined_on( &self, @@ -701,19 +701,12 @@ impl<'a, 'tcx> CrateMetadata { self.get_impl_data(id).coerce_unsized_info } - pub fn get_impl_trait( - &self, - id: DefIndex, - tcx: TyCtxt<'tcx>, - ) -> Option<ty::TraitRef<'tcx>> { + pub fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> { self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx))) } /// Iterates over all the stability attributes in the given crate. - pub fn get_lib_features( - &self, - tcx: TyCtxt<'tcx>, - ) -> &'tcx [(ast::Name, Option<ast::Name>)] { + pub fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option<ast::Name>)] { // FIXME: For a proc macro crate, not sure whether we should return the "host" // features or an empty Vec. Both don't cause ICEs. tcx.arena.alloc_from_iter(self.root @@ -883,11 +876,7 @@ impl<'a, 'tcx> CrateMetadata { self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some() } - pub fn maybe_get_optimized_mir( - &self, - tcx: TyCtxt<'tcx>, - id: DefIndex, - ) -> Option<Body<'tcx>> { + pub fn maybe_get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Option<Body<'tcx>> { match self.is_proc_macro(id) { true => None, false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))), diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 82fee9ea48f..161a08c5773 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1511,12 +1511,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn check_activations( - &mut self, - location: Location, - span: Span, - flow_state: &Flows<'cx, 'tcx>, - ) { + fn check_activations(&mut self, location: Location, span: Span, flow_state: &Flows<'cx, 'tcx>) { // Two-phase borrow support: For each activation that is newly // generated at this statement, check if it interferes with // another borrow. @@ -2034,11 +2029,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }; } - fn is_local_ever_initialized(&self, - local: Local, - flow_state: &Flows<'cx, 'tcx>) - -> Option<InitIndex> - { + fn is_local_ever_initialized( + &self, + local: Local, + flow_state: &Flows<'cx, 'tcx>, + ) -> Option<InitIndex> { let mpi = self.move_data.rev_lookup.find_local(local); let ii = &self.move_data.init_path_map[mpi]; for &index in ii { @@ -2050,11 +2045,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } /// Adds the place into the used mutable variables set - fn add_used_mut<'d>( - &mut self, - root_place: RootPlace<'d, 'tcx>, - flow_state: &Flows<'cx, 'tcx>, - ) { + fn add_used_mut<'d>(&mut self, root_place: RootPlace<'d, 'tcx>, flow_state: &Flows<'cx, 'tcx>) { match root_place { RootPlace { place: Place::Base(PlaceBase::Local(local)), diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs index 5afc0514a56..6ce925cc7d1 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs @@ -33,11 +33,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Search the upvars (if any) to find one that references fr. Return its index. - crate fn get_upvar_index_for_region( - &self, - tcx: TyCtxt<'tcx>, - fr: RegionVid, - ) -> Option<usize> { + crate fn get_upvar_index_for_region(&self, tcx: TyCtxt<'tcx>, fr: RegionVid) -> Option<usize> { let upvar_index = self .universal_regions .defining_ty @@ -134,5 +130,4 @@ impl<'tcx> RegionInferenceContext<'tcx> { (argument_name, argument_span) } - } diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index 704e9315e7f..c1d1185cf17 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -16,10 +16,7 @@ pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, 'tcx>, body: &mut Body<'tcx>) { /// Replaces all regions appearing in `value` with fresh inference /// variables. -pub fn renumber_regions<'tcx, T>( - infcx: &InferCtxt<'_, 'tcx>, - value: &T, -) -> T +pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'_, 'tcx>, value: &T) -> T where T: TypeFoldable<'tcx>, { diff --git a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs index 563514b922c..d86702773e3 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs @@ -150,9 +150,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { } } -impl<'a, 'b, 'tcx> TypeOutlivesDelegate<'tcx> - for &'a mut ConstraintConversion<'b, 'tcx> -{ +impl<'a, 'b, 'tcx> TypeOutlivesDelegate<'tcx> for &'a mut ConstraintConversion<'b, 'tcx> { fn push_sub_region_constraint( &mut self, _origin: SubregionOrigin<'tcx>, diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index 79045eea53c..b35bcc09a23 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -36,7 +36,6 @@ impl<'tcx> IsPrefixOf<'tcx> for Place<'tcx> { } } - pub(super) struct Prefixes<'cx, 'tcx: 'cx> { body: &'cx Body<'tcx>, tcx: TyCtxt<'tcx>, @@ -60,11 +59,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Returns an iterator over the prefixes of `place` /// (inclusive) from longest to smallest, potentially /// terminating the iteration early based on `kind`. - pub(super) fn prefixes( - &self, - place: &'cx Place<'tcx>, - kind: PrefixSet, - ) -> Prefixes<'cx, 'tcx> { + pub(super) fn prefixes(&self, place: &'cx Place<'tcx>, kind: PrefixSet) -> Prefixes<'cx, 'tcx> { Prefixes { next: Some(place), kind, diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 3e14949ffc9..50d9bbf4cc3 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -70,11 +70,7 @@ pub struct MaybeInitializedPlaces<'a, 'tcx: 'a> { } impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> { - pub fn new( - tcx: TyCtxt<'tcx>, - body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'tcx>, - ) -> Self { + pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self { MaybeInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } @@ -125,11 +121,7 @@ pub struct MaybeUninitializedPlaces<'a, 'tcx: 'a> { } impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> { - pub fn new( - tcx: TyCtxt<'tcx>, - body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'tcx>, - ) -> Self { + pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self { MaybeUninitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } @@ -179,11 +171,7 @@ pub struct DefinitelyInitializedPlaces<'a, 'tcx: 'a> { } impl<'a, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'tcx> { - pub fn new( - tcx: TyCtxt<'tcx>, - body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'tcx>, - ) -> Self { + pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self { DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } @@ -228,11 +216,7 @@ pub struct EverInitializedPlaces<'a, 'tcx: 'a> { } impl<'a, 'tcx: 'a> EverInitializedPlaces<'a, 'tcx> { - pub fn new( - tcx: TyCtxt<'tcx>, - body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'tcx>, - ) -> Self { + pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self { EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } @@ -241,7 +225,6 @@ impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'tcx> { fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data } } - impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> { fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 236d36c7661..7740042c783 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -52,8 +52,7 @@ pub struct Cx<'a, 'tcx: 'a> { } impl<'a, 'tcx> Cx<'a, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'tcx>, - src_id: hir::HirId) -> Cx<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>, src_id: hir::HirId) -> Cx<'a, 'tcx> { let tcx = infcx.tcx; let src_def_id = tcx.hir().local_def_id_from_hir_id(src_id); let tables = tcx.typeck_tables_of(src_def_id); diff --git a/src/librustc_mir/interpret/intrinsics/type_name.rs b/src/librustc_mir/interpret/intrinsics/type_name.rs index c92d501140f..5ca3531c98b 100644 --- a/src/librustc_mir/interpret/intrinsics/type_name.rs +++ b/src/librustc_mir/interpret/intrinsics/type_name.rs @@ -174,11 +174,9 @@ impl PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> { ) -> bool { false } - 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)?; diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index aa86a1c1104..e530c56ed6f 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -315,10 +315,7 @@ pub fn collect_crate_mono_items<'tcx>( // Find all non-generic items by walking the HIR. These items serve as roots to // start monomorphizing from. -fn collect_roots<'tcx>( - tcx: TyCtxt<'tcx>, - mode: MonoItemCollectionMode, -) -> Vec<MonoItem<'tcx>> { +fn collect_roots<'tcx>(tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode) -> Vec<MonoItem<'tcx>> { debug!("Collecting roots"); let mut roots = Vec::new(); @@ -1188,11 +1185,7 @@ fn create_mono_items_for_default_impls<'tcx>( } /// Scan the miri alloc in order to find function calls, closures, and drop-glue -fn collect_miri<'tcx>( - tcx: TyCtxt<'tcx>, - alloc_id: AllocId, - output: &mut Vec<MonoItem<'tcx>>, -) { +fn collect_miri<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut Vec<MonoItem<'tcx>>) { let alloc_kind = tcx.alloc_map.lock().get(alloc_id); match alloc_kind { Some(GlobalAlloc::Static(def_id)) => { diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index 4abc0674382..a821cb2cfda 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -203,10 +203,7 @@ struct PostInliningPartitioning<'tcx> { internalization_candidates: FxHashSet<MonoItem<'tcx>>, } -fn place_root_mono_items<'tcx, I>( - tcx: TyCtxt<'tcx>, - mono_items: I, -) -> PreInliningPartitioning<'tcx> +fn place_root_mono_items<'tcx, I>(tcx: TyCtxt<'tcx>, mono_items: I) -> PreInliningPartitioning<'tcx> where I: Iterator<Item = MonoItem<'tcx>>, { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 4b3b1f9d4da..f5a22ea0931 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -163,11 +163,7 @@ fn local_decls_for_sig<'tcx>(sig: &ty::FnSig<'tcx>, span: Span) .collect() } -fn build_drop_shim<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: DefId, - ty: Option<Ty<'tcx>>, -) -> Body<'tcx> { +fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>) -> Body<'tcx> { debug!("build_drop_shim(def_id={:?}, ty={:?})", def_id, ty); // Check if this is a generator, if so, return the drop glue for it diff --git a/src/librustc_mir/transform/add_call_guards.rs b/src/librustc_mir/transform/add_call_guards.rs index 892b99f94e8..c08c33bc6ff 100644 --- a/src/librustc_mir/transform/add_call_guards.rs +++ b/src/librustc_mir/transform/add_call_guards.rs @@ -31,12 +31,7 @@ pub use self::AddCallGuards::*; */ impl MirPass for AddCallGuards { - fn run_pass<'tcx>( - &self, - _tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { self.add_call_guards(body); } } diff --git a/src/librustc_mir/transform/add_moves_for_packed_drops.rs b/src/librustc_mir/transform/add_moves_for_packed_drops.rs index 12e7ab21896..a111669f149 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -46,11 +46,7 @@ impl MirPass for AddMovesForPackedDrops { } } -pub fn add_moves_for_packed_drops<'tcx>( - tcx: TyCtxt<'tcx>, - body: &mut Body<'tcx>, - def_id: DefId, -) { +pub fn add_moves_for_packed_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, def_id: DefId) { let patch = add_moves_for_packed_drops_patch(tcx, body, def_id); patch.apply(body); } diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index c478eaf5731..ee040bf6590 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -74,12 +74,7 @@ fn may_have_reference<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool { } impl MirPass for AddRetag { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { if !tcx.sess.opts.debugging_opts.mir_emit_retag { return; } diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index 83040a71cba..6ee14160bbd 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -27,12 +27,7 @@ pub struct CleanupNonCodegenStatements; pub struct DeleteNonCodegenStatements; impl MirPass for CleanupNonCodegenStatements { - fn run_pass<'tcx>( - &self, - _tcx: TyCtxt<'tcx>, - _source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) { let mut delete = DeleteNonCodegenStatements; delete.visit_body(body); } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index fc4efdf8f39..2ec5c192726 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -31,12 +31,7 @@ use crate::transform::{MirPass, MirSource}; pub struct ConstProp; impl MirPass for ConstProp { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) { // will be evaluated by miri and produce its errors there if source.promoted.is_some() { return; diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index e84308fd947..c850b48e074 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -30,12 +30,7 @@ use crate::util::def_use::DefUseAnalysis; pub struct CopyPropagation; impl MirPass for CopyPropagation { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) { // We only run when the MIR optimization level is > 1. // This avoids a slow pass, and messing up debug info. if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 { diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index 41943d86332..1b42a0dffb8 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -6,12 +6,7 @@ use crate::util::expand_aggregate; pub struct Deaggregator; impl MirPass for Deaggregator { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) { let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); let local_decls = &*local_decls; for bb in basic_blocks { diff --git a/src/librustc_mir/transform/dump_mir.rs b/src/librustc_mir/transform/dump_mir.rs index 375a9177638..243820ba7d0 100644 --- a/src/librustc_mir/transform/dump_mir.rs +++ b/src/librustc_mir/transform/dump_mir.rs @@ -18,12 +18,7 @@ impl MirPass for Marker { Cow::Borrowed(self.0) } - fn run_pass<'tcx>( - &self, - _tcx: TyCtxt<'tcx>, - _source: MirSource<'tcx>, - _body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>) { } } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 761bbb53800..9c7aedc12a2 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -1092,12 +1092,7 @@ where } impl MirPass for StateTransform { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) { let yield_ty = if let Some(yield_ty) = body.yield_ty { yield_ty } else { diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 687993a2c52..1cbdc2a2de2 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -38,12 +38,7 @@ struct CallSite<'tcx> { } impl MirPass for Inline { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) { if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 { Inliner { tcx, source }.run_pass(body); } diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index 5c8e712cc25..f0aa189804f 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -10,12 +10,7 @@ use crate::transform::{MirPass, MirSource}; pub struct Lower128Bit; impl MirPass for Lower128Bit { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { let debugging_override = tcx.sess.opts.debugging_opts.lower_128bit_ops; let target_default = tcx.sess.host.options.i128_lowering; if !debugging_override.unwrap_or(target_default) { diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 3caee069a7f..04dce326e69 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -141,12 +141,7 @@ pub trait MirPass { default_name::<Self>() } - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - source: MirSource<'tcx>, - body: &mut Body<'tcx>, - ); + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>); } pub fn run_passes( diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index 69f1ef096fb..7b3cdc835eb 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -19,12 +19,7 @@ pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) } impl MirPass for RemoveNoopLandingPads { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { remove_noop_landing_pads(tcx, body); } } diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index e5774692e93..ac15f52d9ec 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -57,12 +57,7 @@ impl MirPass for SimplifyCfg { Cow::Borrowed(&self.label) } - fn run_pass<'tcx>( - &self, - _tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body); simplify_cfg(body); } diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 228a060f611..0c63a8d9c96 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -19,12 +19,7 @@ impl MirPass for SimplifyBranches { Cow::Borrowed(&self.label) } - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { for block in body.basic_blocks_mut() { let terminator = block.terminator_mut(); terminator.kind = match terminator.kind { diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 08b10a5d337..90b52b76155 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -37,12 +37,7 @@ use crate::util::patch::MirPatch; pub struct UniformArrayMoveOut; impl MirPass for UniformArrayMoveOut { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { let mut patch = MirPatch::new(body); { let mut visitor = UniformArrayMoveOutVisitor{body, patch: &mut patch, tcx}; @@ -164,12 +159,7 @@ impl<'a, 'tcx> UniformArrayMoveOutVisitor<'a, 'tcx> { pub struct RestoreSubsliceArrayMoveOut; impl MirPass for RestoreSubsliceArrayMoveOut { - fn run_pass<'tcx>( - &self, - tcx: TyCtxt<'tcx>, - _src: MirSource<'tcx>, - body: &mut Body<'tcx>, - ) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) { let mut patch = MirPatch::new(body); { let mut visitor = RestoreDataCollector { diff --git a/src/librustc_mir/util/mod.rs b/src/librustc_mir/util/mod.rs index 36c5a1a2f59..719029dbaac 100644 --- a/src/librustc_mir/util/mod.rs +++ b/src/librustc_mir/util/mod.rs @@ -21,10 +21,7 @@ pub use self::graphviz::{graphviz_safe_def_name, write_mir_graphviz}; pub use self::graphviz::write_node_label as write_graphviz_node_label; /// If possible, suggest replacing `ref` with `ref mut`. -pub fn suggest_ref_mut<'tcx>( - tcx: TyCtxt<'tcx>, - binding_span: Span, -) -> Option<(String)> { +pub fn suggest_ref_mut<'tcx>(tcx: TyCtxt<'tcx>, binding_span: Span) -> Option<(String)> { let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).unwrap(); if hi_src.starts_with("ref") && hi_src["ref".len()..].starts_with(Pattern_White_Space) diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 2c2643e9b42..fc46adb702c 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -93,11 +93,7 @@ pub fn dump_mir<'tcx, F>( ); } -pub fn dump_enabled<'tcx>( - tcx: TyCtxt<'tcx>, - pass_name: &str, - source: MirSource<'tcx>, -) -> bool { +pub fn dump_enabled<'tcx>(tcx: TyCtxt<'tcx>, pass_name: &str, source: MirSource<'tcx>) -> bool { let filters = match tcx.sess.opts.debugging_opts.dump_mir { None => return false, Some(ref filters) => filters, @@ -370,11 +366,7 @@ where /// After we print the main statement, we sometimes dump extra /// information. There's often a lot of little things "nuzzled up" in /// a statement. -fn write_extra<'tcx, F>( - tcx: TyCtxt<'tcx>, - write: &mut dyn Write, - mut visit_op: F, -) -> io::Result<()> +fn write_extra<'tcx, F>(tcx: TyCtxt<'tcx>, write: &mut dyn Write, mut visit_op: F) -> io::Result<()> where F: FnMut(&mut ExtraComments<'tcx>), { diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 5610982c01e..c2cb2f4d174 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -337,11 +337,7 @@ fn item_tables<'a, 'tcx>( if tcx.has_typeck_tables(def_id) { tcx.typeck_tables_of(def_id) } else { empty_tables } } -fn min<'tcx>( - vis1: ty::Visibility, - vis2: ty::Visibility, - tcx: TyCtxt<'tcx>, -) -> ty::Visibility { +fn min<'tcx>(vis1: ty::Visibility, vis2: ty::Visibility, tcx: TyCtxt<'tcx>) -> ty::Visibility { if vis1.is_at_least(vis2, tcx) { vis2 } else { vis1 } } diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index d5a49041958..2b678919ce4 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -179,10 +179,7 @@ impl context::AggregateOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> { impl context::ContextOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> { /// Returns `true` if this is a coinductive goal: basically proving that an auto trait /// is implemented or proving that a trait reference is well-formed. - fn is_coinductive( - &self, - goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>> - ) -> bool { + fn is_coinductive(&self, goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>) -> bool { use rustc::traits::{WellFormed, WhereClause}; let mut goal = goal.value.goal; @@ -441,12 +438,9 @@ impl context::UnificationOps<ChalkArenas<'tcx>, ChalkArenas<'tcx>> fn u_canonicalize_goal( &mut self, value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, - ) -> ( - Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, - UniverseMap, - ) { + ) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) { (value.clone(), UniverseMap) - } +} fn invert_goal( &mut self, @@ -652,7 +646,8 @@ impl<'tcx> Upcast<'tcx> for ExClause<ChalkArenas<'tcx>> { } impl<'tcx, T> Upcast<'tcx> for Canonical<'tcx, T> - where T: Upcast<'tcx> +where + T: Upcast<'tcx>, { type Upcasted = Canonical<'tcx, T::Upcasted>; diff --git a/src/librustc_traits/chalk_context/program_clauses/primitive.rs b/src/librustc_traits/chalk_context/program_clauses/primitive.rs index cdcf73d3c3a..8e4b9da6de2 100644 --- a/src/librustc_traits/chalk_context/program_clauses/primitive.rs +++ b/src/librustc_traits/chalk_context/program_clauses/primitive.rs @@ -15,10 +15,7 @@ use crate::lowering::Lower; use crate::generic_types; use std::iter; -crate fn wf_clause_for_raw_ptr<'tcx>( - tcx: TyCtxt<'tcx>, - mutbl: hir::Mutability, -) -> Clauses<'tcx> { +crate fn wf_clause_for_raw_ptr<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Clauses<'tcx> { let ptr_ty = generic_types::raw_ptr(tcx, mutbl); let wf_clause = ProgramClause { diff --git a/src/librustc_traits/chalk_context/unify.rs b/src/librustc_traits/chalk_context/unify.rs index 7ae0e8548fa..d66faa92336 100644 --- a/src/librustc_traits/chalk_context/unify.rs +++ b/src/librustc_traits/chalk_context/unify.rs @@ -15,7 +15,7 @@ crate fn unify<'me, 'tcx, T: Relate<'tcx>>( environment: Environment<'tcx>, variance: ty::Variance, a: &T, - b: &T + b: &T, ) -> RelateResult<'tcx, UnificationResult<'tcx>> { debug!("unify( a = {:?}, @@ -50,10 +50,7 @@ struct ChalkTypeRelatingDelegate<'me, 'tcx: 'me> { } impl ChalkTypeRelatingDelegate<'me, 'tcx> { - fn new( - infcx: &'me InferCtxt<'me, 'tcx>, - environment: Environment<'tcx>, - ) -> Self { + fn new(infcx: &'me InferCtxt<'me, 'tcx>, environment: Environment<'tcx>) -> Self { Self { infcx, environment, diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs index 8e789e0408f..7f9ebdc79c2 100644 --- a/src/librustc_traits/implied_outlives_bounds.rs +++ b/src/librustc_traits/implied_outlives_bounds.rs @@ -39,7 +39,7 @@ fn implied_outlives_bounds<'tcx>( fn compute_implied_outlives_bounds<'tcx>( infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, - ty: Ty<'tcx> + ty: Ty<'tcx>, ) -> Fallible<Vec<OutlivesBound<'tcx>>> { let tcx = infcx.tcx; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 3aa050fb56d..9ffbbd384c6 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -1027,8 +1027,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); expected: Ty<'tcx>, def_bm: ty::BindingMode, discrim_span: Option<Span>, - ) -> Ty<'tcx> - { + ) -> Ty<'tcx> { // Resolve the path and check the definition for errors. let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.hir_id) { diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index 80c6c13b57e..dc4969d7ad2 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -31,7 +31,7 @@ pub struct Autoderef<'a, 'tcx: 'a> { include_raw_pointers: bool, span: Span, silence_errors: bool, - reached_recursion_limit: bool + reached_recursion_limit: bool, } impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> { @@ -86,13 +86,13 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> { } impl<'a, 'tcx> Autoderef<'a, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - body_id: hir::HirId, - span: Span, - base_ty: Ty<'tcx>) - -> Autoderef<'a, 'tcx> - { + pub fn new( + infcx: &'a InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + body_id: hir::HirId, + span: Span, + base_ty: Ty<'tcx>, + ) -> Autoderef<'a, 'tcx> { Autoderef { infcx, body_id, @@ -172,13 +172,15 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> { } /// Returns the adjustment steps. - pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) - -> Vec<Adjustment<'tcx>> { + pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) -> Vec<Adjustment<'tcx>> { fcx.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(fcx, needs)) } - pub fn adjust_steps_as_infer_ok(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) - -> InferOk<'tcx, Vec<Adjustment<'tcx>>> { + pub fn adjust_steps_as_infer_ok( + &self, + fcx: &FnCtxt<'a, 'tcx>, + needs: Needs, + ) -> InferOk<'tcx, Vec<Adjustment<'tcx>>> { let mut obligations = vec![]; let targets = self.steps.iter().skip(1).map(|&(ty, _)| ty) .chain(iter::once(self.cur_ty)); @@ -239,11 +241,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> { } } -pub fn report_autoderef_recursion_limit_error<'tcx>( - tcx: TyCtxt<'tcx>, - span: Span, - ty: Ty<'tcx>, -) { +pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) { // We've reached the recursion limit, error gracefully. let suggested_limit = *tcx.sess.recursion_limit.get() * 2; let msg = format!("reached the recursion limit while auto-dereferencing `{:?}`", diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index e70090dd85a..53101499af1 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -158,12 +158,13 @@ impl From<ErrorReported> for CastError { } } -fn make_invalid_casting_error<'a, 'tcx>(sess: &'a Session, - span: Span, - expr_ty: Ty<'tcx>, - cast_ty: Ty<'tcx>, - fcx: &FnCtxt<'a, 'tcx>) - -> DiagnosticBuilder<'a> { +fn make_invalid_casting_error<'a, 'tcx>( + sess: &'a Session, + span: Span, + expr_ty: Ty<'tcx>, + cast_ty: Ty<'tcx>, + fcx: &FnCtxt<'a, 'tcx>, +) -> DiagnosticBuilder<'a> { type_error_struct!(sess, span, expr_ty, E0606, "casting `{}` as `{}` is invalid", fcx.ty_to_string(expr_ty), @@ -171,13 +172,14 @@ fn make_invalid_casting_error<'a, 'tcx>(sess: &'a Session, } impl<'a, 'tcx> CastCheck<'tcx> { - pub fn new(fcx: &FnCtxt<'a, 'tcx>, - expr: &'tcx hir::Expr, - expr_ty: Ty<'tcx>, - cast_ty: Ty<'tcx>, - cast_span: Span, - span: Span) - -> Result<CastCheck<'tcx>, ErrorReported> { + pub fn new( + fcx: &FnCtxt<'a, 'tcx>, + expr: &'tcx hir::Expr, + expr_ty: Ty<'tcx>, + cast_ty: Ty<'tcx>, + cast_span: Span, + span: Span, + ) -> Result<CastCheck<'tcx>, ErrorReported> { let check = CastCheck { expr, expr_ty, @@ -531,11 +533,12 @@ impl<'a, 'tcx> CastCheck<'tcx> { } } - fn check_ptr_ptr_cast(&self, - fcx: &FnCtxt<'a, 'tcx>, - m_expr: ty::TypeAndMut<'tcx>, - m_cast: ty::TypeAndMut<'tcx>) - -> Result<CastKind, CastError> { + fn check_ptr_ptr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_expr: ty::TypeAndMut<'tcx>, + m_cast: ty::TypeAndMut<'tcx>, + ) -> Result<CastKind, CastError> { debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast); // ptr-ptr cast. vtables must match. @@ -572,10 +575,11 @@ impl<'a, 'tcx> CastCheck<'tcx> { } } - fn check_fptr_ptr_cast(&self, - fcx: &FnCtxt<'a, 'tcx>, - m_cast: ty::TypeAndMut<'tcx>) - -> Result<CastKind, CastError> { + fn check_fptr_ptr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_cast: ty::TypeAndMut<'tcx>, + ) -> Result<CastKind, CastError> { // fptr-ptr cast. must be to thin ptr match fcx.pointer_kind(m_cast.ty, self.span)? { @@ -585,10 +589,11 @@ impl<'a, 'tcx> CastCheck<'tcx> { } } - fn check_ptr_addr_cast(&self, - fcx: &FnCtxt<'a, 'tcx>, - m_expr: ty::TypeAndMut<'tcx>) - -> Result<CastKind, CastError> { + fn check_ptr_addr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_expr: ty::TypeAndMut<'tcx>, + ) -> Result<CastKind, CastError> { // ptr-addr cast. must be from thin ptr match fcx.pointer_kind(m_expr.ty, self.span)? { @@ -598,11 +603,12 @@ impl<'a, 'tcx> CastCheck<'tcx> { } } - fn check_ref_cast(&self, - fcx: &FnCtxt<'a, 'tcx>, - m_expr: ty::TypeAndMut<'tcx>, - m_cast: ty::TypeAndMut<'tcx>) - -> Result<CastKind, CastError> { + fn check_ref_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_expr: ty::TypeAndMut<'tcx>, + m_cast: ty::TypeAndMut<'tcx>, + ) -> Result<CastKind, CastError> { // array-ptr-cast. if m_expr.mutbl == hir::MutImmutable && m_cast.mutbl == hir::MutImmutable { @@ -623,10 +629,11 @@ impl<'a, 'tcx> CastCheck<'tcx> { Err(CastError::IllegalCast) } - fn check_addr_ptr_cast(&self, - fcx: &FnCtxt<'a, 'tcx>, - m_cast: TypeAndMut<'tcx>) - -> Result<CastKind, CastError> { + fn check_addr_ptr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_cast: TypeAndMut<'tcx>, + ) -> Result<CastKind, CastError> { // ptr-addr cast. pointer must be thin. match fcx.pointer_kind(m_cast.ty, self.span)? { None => Err(CastError::UnknownCastPtrKind), diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index e1623fe49e7..a56196ccf82 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -121,9 +121,11 @@ fn success<'tcx>(adj: Vec<Adjustment<'tcx>>, } impl<'f, 'tcx> Coerce<'f, 'tcx> { - fn new(fcx: &'f FnCtxt<'f, 'tcx>, - cause: ObligationCause<'tcx>, - allow_two_phase: AllowTwoPhase) -> Self { + fn new( + fcx: &'f FnCtxt<'f, 'tcx>, + cause: ObligationCause<'tcx>, + allow_two_phase: AllowTwoPhase, + ) -> Self { Coerce { fcx, cause, @@ -1073,12 +1075,13 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { /// could coerce from. This will record `expression`, and later /// calls to `coerce` may come back and add adjustments and things /// if necessary. - pub fn coerce<'a>(&mut self, - fcx: &FnCtxt<'a, 'tcx>, - cause: &ObligationCause<'tcx>, - expression: &'tcx hir::Expr, - expression_ty: Ty<'tcx>) - { + pub fn coerce<'a>( + &mut self, + fcx: &FnCtxt<'a, 'tcx>, + cause: &ObligationCause<'tcx>, + expression: &'tcx hir::Expr, + expression_ty: Ty<'tcx>, + ) { self.coerce_inner(fcx, cause, Some(expression), @@ -1098,12 +1101,13 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { /// The `augment_error` gives you a chance to extend the error /// message, in case any results (e.g., we use this to suggest /// removing a `;`). - pub fn coerce_forced_unit<'a>(&mut self, - fcx: &FnCtxt<'a, 'tcx>, - cause: &ObligationCause<'tcx>, - augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>), - label_unit_as_expected: bool) - { + pub fn coerce_forced_unit<'a>( + &mut self, + fcx: &FnCtxt<'a, 'tcx>, + cause: &ObligationCause<'tcx>, + augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>), + label_unit_as_expected: bool, + ) { self.coerce_inner(fcx, cause, None, @@ -1115,14 +1119,15 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { /// The inner coercion "engine". If `expression` is `None`, this /// is a forced-unit case, and hence `expression_ty` must be /// `Nil`. - fn coerce_inner<'a>(&mut self, - fcx: &FnCtxt<'a, 'tcx>, - cause: &ObligationCause<'tcx>, - expression: Option<&'tcx hir::Expr>, - mut expression_ty: Ty<'tcx>, - augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>, - label_expression_as_expected: bool) - { + fn coerce_inner<'a>( + &mut self, + fcx: &FnCtxt<'a, 'tcx>, + cause: &ObligationCause<'tcx>, + expression: Option<&'tcx hir::Expr>, + mut expression_ty: Ty<'tcx>, + augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>, + label_expression_as_expected: bool, + ) { // Incorporate whatever type inference information we have // until now; in principle we might also want to process // pending obligations, but doing so should only improve diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index beaa32b0bd3..088ac0e8ba6 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -410,15 +410,16 @@ fn check_region_bounds_on_impl_method<'tcx>( Ok(()) } -fn extract_spans_for_error_reporting<'a, 'tcx>(infcx: &infer::InferCtxt<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - terr: &TypeError<'_>, - cause: &ObligationCause<'tcx>, - impl_m: &ty::AssocItem, - impl_sig: ty::FnSig<'tcx>, - trait_m: &ty::AssocItem, - trait_sig: ty::FnSig<'tcx>) - -> (Span, Option<Span>) { +fn extract_spans_for_error_reporting<'a, 'tcx>( + infcx: &infer::InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + terr: &TypeError<'_>, + cause: &ObligationCause<'tcx>, + impl_m: &ty::AssocItem, + impl_sig: ty::FnSig<'tcx>, + trait_m: &ty::AssocItem, + trait_sig: ty::FnSig<'tcx>, +) -> (Span, Option<Span>) { let tcx = infcx.tcx; let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap(); let (impl_m_output, impl_m_iter) = match tcx.hir() diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 8f80c9a9f5b..2003782e7ad 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -29,10 +29,7 @@ use syntax_pos::Span; /// struct/enum definition for the nominal type itself (i.e. /// cannot do `struct S<T>; impl<T:Clone> Drop for S<T> { ... }`). /// -pub fn check_drop_impl<'tcx>( - tcx: TyCtxt<'tcx>, - drop_impl_did: DefId, -) -> Result<(), ErrorReported> { +pub fn check_drop_impl<'tcx>(tcx: TyCtxt<'tcx>, drop_impl_did: DefId) -> Result<(), ErrorReported> { let dtor_self_type = tcx.type_of(drop_impl_did); let dtor_predicates = tcx.predicates_of(drop_impl_did); match dtor_self_type.sty { diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index bd2db8facd4..5f9aa5fbabe 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -75,10 +75,12 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { } } -pub fn resolve_interior<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>, - def_id: DefId, - body_id: hir::BodyId, - interior: Ty<'tcx>) { +pub fn resolve_interior<'a, 'tcx>( + fcx: &'a FnCtxt<'a, 'tcx>, + def_id: DefId, + body_id: hir::BodyId, + interior: Ty<'tcx>, +) { let body = fcx.tcx.hir().body(body_id); let mut visitor = InteriorVisitor { fcx, diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 25ca4668a10..5df0010b63e 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -58,11 +58,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { - fn new(fcx: &'a FnCtxt<'a, 'tcx>, - span: Span, - self_expr: &'tcx hir::Expr, - call_expr: &'tcx hir::Expr) - -> ConfirmContext<'a, 'tcx> { + fn new( + fcx: &'a FnCtxt<'a, 'tcx>, + span: Span, + self_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr, + ) -> ConfirmContext<'a, 'tcx> { ConfirmContext { fcx, span, @@ -263,10 +264,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { } fn extract_existential_trait_ref<R, F>(&mut self, self_ty: Ty<'tcx>, mut closure: F) -> R - where F: FnMut(&mut ConfirmContext<'a, 'tcx>, - Ty<'tcx>, - ty::PolyExistentialTraitRef<'tcx>) - -> R + where + F: FnMut(&mut ConfirmContext<'a, 'tcx>, Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>) -> R, { // If we specified that this is an object method, then the // self-type ought to be something that can be dereferenced to diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 6990277482a..b492197870b 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -174,13 +174,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// * `self_ty`: the (unadjusted) type of the self expression (`foo`) /// * `supplied_method_types`: the explicit method type parameters, if any (`T1..Tn`) /// * `self_expr`: the self expression (`foo`) - pub fn lookup_method(&self, - self_ty: Ty<'tcx>, - segment: &hir::PathSegment, - span: Span, - call_expr: &'tcx hir::Expr, - self_expr: &'tcx hir::Expr) - -> Result<MethodCallee<'tcx>, MethodError<'tcx>> { + pub fn lookup_method( + &self, + self_ty: Ty<'tcx>, + segment: &hir::PathSegment, + span: Span, + call_expr: &'tcx hir::Expr, + self_expr: &'tcx hir::Expr, + ) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> { debug!("lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})", segment.ident, self_ty, @@ -245,13 +246,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(result.callee) } - fn lookup_probe(&self, - span: Span, - method_name: ast::Ident, - self_ty: Ty<'tcx>, - call_expr: &'tcx hir::Expr, - scope: ProbeScope) - -> probe::PickResult<'tcx> { + fn lookup_probe( + &self, + span: Span, + method_name: ast::Ident, + self_ty: Ty<'tcx>, + call_expr: &'tcx hir::Expr, + scope: ProbeScope, + ) -> probe::PickResult<'tcx> { let mode = probe::Mode::MethodCall; let self_ty = self.resolve_vars_if_possible(&self_ty); self.probe_for_name(span, mode, method_name, IsSuggestion(false), diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 3c60ba219fa..661883f2ac1 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -259,18 +259,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |probe_cx| probe_cx.pick()) } - fn probe_op<OP,R>(&'a self, - span: Span, - mode: Mode, - method_name: Option<ast::Ident>, - return_type: Option<Ty<'tcx>>, - is_suggestion: IsSuggestion, - self_ty: Ty<'tcx>, - scope_expr_id: hir::HirId, - scope: ProbeScope, - op: OP) - -> Result<R, MethodError<'tcx>> - where OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result<R, MethodError<'tcx>> + fn probe_op<OP, R>( + &'a self, + span: Span, + mode: Mode, + method_name: Option<ast::Ident>, + return_type: Option<Ty<'tcx>>, + is_suggestion: IsSuggestion, + self_ty: Ty<'tcx>, + scope_expr_id: hir::HirId, + scope: ProbeScope, + op: OP, + ) -> Result<R, MethodError<'tcx>> + where + OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result<R, MethodError<'tcx>>, { let mut orig_values = OriginalQueryValues::default(); let param_env_and_self_ty = @@ -463,17 +465,17 @@ fn method_autoderef_steps<'tcx>( }) } - impl<'a, 'tcx> ProbeContext<'a, 'tcx> { - fn new(fcx: &'a FnCtxt<'a, 'tcx>, - span: Span, - mode: Mode, - method_name: Option<ast::Ident>, - return_type: Option<Ty<'tcx>>, - orig_steps_var_values: OriginalQueryValues<'tcx>, - steps: Lrc<Vec<CandidateStep<'tcx>>>, - is_suggestion: IsSuggestion) - -> ProbeContext<'a, 'tcx> { + fn new( + fcx: &'a FnCtxt<'a, 'tcx>, + span: Span, + mode: Mode, + method_name: Option<ast::Ident>, + return_type: Option<Ty<'tcx>>, + orig_steps_var_values: OriginalQueryValues<'tcx>, + steps: Lrc<Vec<CandidateStep<'tcx>>>, + is_suggestion: IsSuggestion, + ) -> ProbeContext<'a, 'tcx> { ProbeContext { fcx, span, @@ -808,12 +810,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // Do a search through a list of bounds, using a callback to actually // create the candidates. - fn elaborate_bounds<F>(&mut self, - bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>, - mut mk_cand: F) - where F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>, - ty::PolyTraitRef<'tcx>, - ty::AssocItem) + fn elaborate_bounds<F>( + &mut self, + bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>, + mut mk_cand: F, + ) where + F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>, ty::PolyTraitRef<'tcx>, ty::AssocItem), { let tcx = self.tcx; for bound_trait_ref in traits::transitive_bounds(tcx, bounds) { @@ -1045,9 +1047,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { .next() } - fn pick_by_value_method(&mut self, step: &CandidateStep<'tcx>, self_ty: Ty<'tcx>) - -> Option<PickResult<'tcx>> - { + fn pick_by_value_method( + &mut self, + step: &CandidateStep<'tcx>, + self_ty: Ty<'tcx>, + ) -> Option<PickResult<'tcx>> { //! For each type `T` in the step list, this attempts to find a //! method where the (transformed) self type is exactly `T`. We //! do however do one transformation on the adjustment: if we @@ -1075,11 +1079,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { }) } - fn pick_autorefd_method(&mut self, - step: &CandidateStep<'tcx>, - self_ty: Ty<'tcx>, - mutbl: hir::Mutability) - -> Option<PickResult<'tcx>> { + fn pick_autorefd_method( + &mut self, + step: &CandidateStep<'tcx>, + self_ty: Ty<'tcx>, + mutbl: hir::Mutability, + ) -> Option<PickResult<'tcx>> { let tcx = self.tcx; // In general, during probing we erase regions. See diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4a25c7323c3..3a30e31f89e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1010,8 +1010,14 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { } // Don't descend into the bodies of nested closures - fn visit_fn(&mut self, _: intravisit::FnKind<'tcx>, _: &'tcx hir::FnDecl, - _: hir::BodyId, _: Span, _: hir::HirId) { } + fn visit_fn( + &mut self, + _: intravisit::FnKind<'tcx>, + _: &'tcx hir::FnDecl, + _: hir::BodyId, + _: Span, + _: hir::HirId, + ) { } } /// When `check_fn` is invoked on a generator (i.e., a body that @@ -1034,15 +1040,15 @@ struct GeneratorTypes<'tcx> { /// /// * ... /// * inherited: other fields inherited from the enclosing fn (if any) -fn check_fn<'a, 'tcx>(inherited: &'a Inherited<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - fn_sig: ty::FnSig<'tcx>, - decl: &'tcx hir::FnDecl, - fn_id: hir::HirId, - body: &'tcx hir::Body, - can_be_generator: Option<hir::GeneratorMovability>) - -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) -{ +fn check_fn<'a, 'tcx>( + inherited: &'a Inherited<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + fn_sig: ty::FnSig<'tcx>, + decl: &'tcx hir::FnDecl, + fn_id: hir::HirId, + body: &'tcx hir::Body, + can_be_generator: Option<hir::GeneratorMovability>, +) -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) { let mut fn_sig = fn_sig.clone(); debug!("check_fn(sig={:?}, fn_id={}, param_env={:?})", fn_sig, fn_id, param_env); @@ -1755,11 +1761,7 @@ fn check_packed<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, def_id: DefId) { } } -fn check_packed_inner<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: DefId, - stack: &mut Vec<DefId>, -) -> bool { +fn check_packed_inner<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, stack: &mut Vec<DefId>) -> bool { let t = tcx.type_of(def_id); if stack.contains(&def_id) { debug!("check_packed_inner: {:?} is recursive", t); @@ -1867,12 +1869,7 @@ fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, def_id: DefId) { } #[allow(trivial_numeric_casts)] -pub fn check_enum<'tcx>( - tcx: TyCtxt<'tcx>, - sp: Span, - vs: &'tcx [hir::Variant], - id: hir::HirId, -) { +pub fn check_enum<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, vs: &'tcx [hir::Variant], id: hir::HirId) { let def_id = tcx.hir().local_def_id_from_hir_id(id); let def = tcx.adt_def(def_id); def.destructor(tcx); // force the destructor to be evaluated @@ -1933,12 +1930,7 @@ pub fn check_enum<'tcx>( check_transparent(tcx, sp, def_id); } -fn report_unexpected_variant_res<'tcx>( - tcx: TyCtxt<'tcx>, - res: Res, - span: Span, - qpath: &QPath, -) { +fn report_unexpected_variant_res<'tcx>(tcx: TyCtxt<'tcx>, res: Res, span: Span, qpath: &QPath) { span_err!(tcx.sess, span, E0533, "expected unit struct/variant or constant, found {} `{}`", res.descr(), @@ -2075,10 +2067,11 @@ enum TupleArgumentsFlag { } impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - pub fn new(inh: &'a Inherited<'a, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - body_id: hir::HirId) - -> FnCtxt<'a, 'tcx> { + pub fn new( + inh: &'a Inherited<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + body_id: hir::HirId, + ) -> FnCtxt<'a, 'tcx> { FnCtxt { body_id, param_env, @@ -2165,17 +2158,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty } - fn record_deferred_call_resolution(&self, - closure_def_id: DefId, - r: DeferredCallResolution<'tcx>) { + fn record_deferred_call_resolution( + &self, + closure_def_id: DefId, + r: DeferredCallResolution<'tcx>, + ) { let mut deferred_call_resolutions = self.deferred_call_resolutions.borrow_mut(); deferred_call_resolutions.entry(closure_def_id).or_default().push(r); } - fn remove_deferred_call_resolutions(&self, - closure_def_id: DefId) - -> Vec<DeferredCallResolution<'tcx>> - { + fn remove_deferred_call_resolutions( + &self, + closure_def_id: DefId, + ) -> Vec<DeferredCallResolution<'tcx>> { let mut deferred_call_resolutions = self.deferred_call_resolutions.borrow_mut(); deferred_call_resolutions.remove(&closure_def_id).unwrap_or(vec![]) } @@ -2664,14 +2659,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ret_ty.builtin_deref(true).unwrap() } - fn lookup_indexing(&self, - expr: &hir::Expr, - base_expr: &'tcx hir::Expr, - base_ty: Ty<'tcx>, - idx_ty: Ty<'tcx>, - needs: Needs) - -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> - { + fn lookup_indexing( + &self, + expr: &hir::Expr, + base_expr: &'tcx hir::Expr, + base_ty: Ty<'tcx>, + idx_ty: Ty<'tcx>, + needs: Needs, + ) -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> { // FIXME(#18741) -- this is almost but not quite the same as the // autoderef that normal method probing does. They could likely be // consolidated. @@ -2690,14 +2685,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// supports builtin indexing or overloaded indexing. /// This loop implements one step in that search; the autoderef loop /// is implemented by `lookup_indexing`. - fn try_index_step(&self, - expr: &hir::Expr, - base_expr: &hir::Expr, - autoderef: &Autoderef<'a, 'tcx>, - needs: Needs, - index_ty: Ty<'tcx>) - -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> - { + fn try_index_step( + &self, + expr: &hir::Expr, + base_expr: &hir::Expr, + autoderef: &Autoderef<'a, 'tcx>, + needs: Needs, + index_ty: Ty<'tcx>, + ) -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> { let adjusted_ty = autoderef.unambiguous_final_ty(self); debug!("try_index_step(expr={:?}, base_expr={:?}, adjusted_ty={:?}, \ index_ty={:?})", @@ -2815,14 +2810,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { method } - fn check_method_argument_types(&self, - sp: Span, - expr_sp: Span, - method: Result<MethodCallee<'tcx>, ()>, - args_no_rcvr: &'tcx [hir::Expr], - tuple_arguments: TupleArgumentsFlag, - expected: Expectation<'tcx>) - -> Ty<'tcx> { + fn check_method_argument_types( + &self, + sp: Span, + expr_sp: Span, + method: Result<MethodCallee<'tcx>, ()>, + args_no_rcvr: &'tcx [hir::Expr], + tuple_arguments: TupleArgumentsFlag, + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let has_error = match method { Ok(method) => { method.substs.references_error() || method.sig.references_error() @@ -2878,10 +2874,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn obligations_for_self_ty<'b>(&'b self, self_ty: ty::TyVid) - -> impl Iterator<Item=(ty::PolyTraitRef<'tcx>, traits::PredicateObligation<'tcx>)> - + Captures<'tcx> + 'b - { + fn obligations_for_self_ty<'b>( + &'b self, + self_ty: ty::TyVid, + ) -> impl Iterator<Item = (ty::PolyTraitRef<'tcx>, traits::PredicateObligation<'tcx>)> + + Captures<'tcx> + + 'b { // FIXME: consider using `sub_root_var` here so we // can see through subtyping. let ty_var_root = self.root_var(self_ty); @@ -2924,15 +2922,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Generic function that factors out common logic from function calls, /// method calls and overloaded operators. - fn check_argument_types(&self, - sp: Span, - expr_sp: Span, - fn_inputs: &[Ty<'tcx>], - expected_arg_tys: &[Ty<'tcx>], - args: &'tcx [hir::Expr], - c_variadic: bool, - tuple_arguments: TupleArgumentsFlag, - def_span: Option<Span>) { + fn check_argument_types( + &self, + sp: Span, + expr_sp: Span, + fn_inputs: &[Ty<'tcx>], + expected_arg_tys: &[Ty<'tcx>], + args: &'tcx [hir::Expr], + c_variadic: bool, + tuple_arguments: TupleArgumentsFlag, + def_span: Option<Span>, + ) { let tcx = self.tcx; // Grab the argument types, supplying fresh type variables @@ -3196,22 +3196,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_expr_eq_type(&self, - expr: &'tcx hir::Expr, - expected: Ty<'tcx>) { + fn check_expr_eq_type(&self, expr: &'tcx hir::Expr, expected: Ty<'tcx>) { let ty = self.check_expr_with_hint(expr, expected); self.demand_eqtype(expr.span, expected, ty); } - pub fn check_expr_has_type_or_error(&self, - expr: &'tcx hir::Expr, - expected: Ty<'tcx>) -> Ty<'tcx> { + pub fn check_expr_has_type_or_error( + &self, + expr: &'tcx hir::Expr, + expected: Ty<'tcx>, + ) -> Ty<'tcx> { self.check_expr_meets_expectation_or_error(expr, ExpectHasType(expected)) } - fn check_expr_meets_expectation_or_error(&self, - expr: &'tcx hir::Expr, - expected: Expectation<'tcx>) -> Ty<'tcx> { + fn check_expr_meets_expectation_or_error( + &self, + expr: &'tcx hir::Expr, + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let expected_ty = expected.to_option(&self).unwrap_or(self.tcx.types.bool); let mut ty = self.check_expr_with_expectation(expr, expected); @@ -3244,23 +3246,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty } - fn check_expr_coercable_to_type(&self, - expr: &'tcx hir::Expr, - expected: Ty<'tcx>) -> Ty<'tcx> { + fn check_expr_coercable_to_type(&self, expr: &'tcx hir::Expr, expected: Ty<'tcx>) -> Ty<'tcx> { let ty = self.check_expr_with_hint(expr, expected); // checks don't need two phase self.demand_coerce(expr, ty, expected, AllowTwoPhase::No) } - fn check_expr_with_hint(&self, - expr: &'tcx hir::Expr, - expected: Ty<'tcx>) -> Ty<'tcx> { + fn check_expr_with_hint(&self, expr: &'tcx hir::Expr, expected: Ty<'tcx>) -> Ty<'tcx> { self.check_expr_with_expectation(expr, ExpectHasType(expected)) } - fn check_expr_with_expectation(&self, - expr: &'tcx hir::Expr, - expected: Expectation<'tcx>) -> Ty<'tcx> { + fn check_expr_with_expectation( + &self, + expr: &'tcx hir::Expr, + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { self.check_expr_with_expectation_and_needs(expr, expected, Needs::None) } @@ -3342,13 +3342,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // Checks a method call. - fn check_method_call(&self, - expr: &'tcx hir::Expr, - segment: &hir::PathSegment, - span: Span, - args: &'tcx [hir::Expr], - expected: Expectation<'tcx>, - needs: Needs) -> Ty<'tcx> { + fn check_method_call( + &self, + expr: &'tcx hir::Expr, + segment: &hir::PathSegment, + span: Span, + args: &'tcx [hir::Expr], + expected: Expectation<'tcx>, + needs: Needs, + ) -> Ty<'tcx> { let rcvr = &args[0]; let rcvr_t = self.check_expr_with_needs(&rcvr, needs); // no need to check for bot/err -- callee does that @@ -3403,11 +3405,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // Check field access expressions - fn check_field(&self, - expr: &'tcx hir::Expr, - needs: Needs, - base: &'tcx hir::Expr, - field: ast::Ident) -> Ty<'tcx> { + fn check_field( + &self, + expr: &'tcx hir::Expr, + needs: Needs, + base: &'tcx hir::Expr, + field: ast::Ident, + ) -> Ty<'tcx> { let expr_t = self.check_expr_with_needs(base, needs); let expr_t = self.structurally_resolved_type(base.span, expr_t); @@ -3675,14 +3679,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit(); } - fn check_expr_struct_fields(&self, - adt_ty: Ty<'tcx>, - expected: Expectation<'tcx>, - expr_id: hir::HirId, - span: Span, - variant: &'tcx ty::VariantDef, - ast_fields: &'tcx [hir::Field], - check_completeness: bool) -> bool { + fn check_expr_struct_fields( + &self, + adt_ty: Ty<'tcx>, + expected: Expectation<'tcx>, + expr_id: hir::HirId, + span: Span, + variant: &'tcx ty::VariantDef, + ast_fields: &'tcx [hir::Field], + check_completeness: bool, + ) -> bool { let tcx = self.tcx; let adt_ty_hint = @@ -3786,9 +3792,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { error_happened } - fn check_struct_fields_on_error(&self, - fields: &'tcx [hir::Field], - base_expr: &'tcx Option<P<hir::Expr>>) { + fn check_struct_fields_on_error( + &self, + fields: &'tcx [hir::Field], + base_expr: &'tcx Option<P<hir::Expr>>, + ) { for field in fields { self.check_expr(&field.expr); } @@ -3855,13 +3863,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_expr_struct(&self, - expr: &hir::Expr, - expected: Expectation<'tcx>, - qpath: &QPath, - fields: &'tcx [hir::Field], - base_expr: &'tcx Option<P<hir::Expr>>) -> Ty<'tcx> - { + fn check_expr_struct( + &self, + expr: &hir::Expr, + expected: Expectation<'tcx>, + qpath: &QPath, + fields: &'tcx [hir::Field], + base_expr: &'tcx Option<P<hir::Expr>>, + ) -> Ty<'tcx> { // Find the relevant variant let (variant, adt_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, expr.hir_id) { @@ -3925,10 +3934,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Note that inspecting a type's structure *directly* may expose the fact /// that there are actually multiple representations for `Error`, so avoid /// that when err needs to be handled differently. - fn check_expr_with_expectation_and_needs(&self, - expr: &'tcx hir::Expr, - expected: Expectation<'tcx>, - needs: Needs) -> Ty<'tcx> { + fn check_expr_with_expectation_and_needs( + &self, + expr: &'tcx hir::Expr, + expected: Expectation<'tcx>, + needs: Needs, + ) -> Ty<'tcx> { debug!(">> type-checking: expr={:?} expected={:?}", expr, expected); @@ -3976,7 +3987,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &'tcx hir::Expr, expected: Expectation<'tcx>, - needs: Needs + needs: Needs, ) -> Ty<'tcx> { debug!( "check_expr_kind(expr={:?}, expected={:?}, needs={:?})", @@ -4784,10 +4795,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) } - pub fn check_decl_initializer(&self, - local: &'tcx hir::Local, - init: &'tcx hir::Expr) -> Ty<'tcx> - { + pub fn check_decl_initializer( + &self, + local: &'tcx hir::Local, + init: &'tcx hir::Expr, + ) -> Ty<'tcx> { // FIXME(tschottdorf): `contains_explicit_ref_binding()` must be removed // for #42640 (default match binding modes). // @@ -4870,7 +4882,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.has_errors.set(self.has_errors.get() | old_has_errors); } - pub fn check_block_no_value(&self, blk: &'tcx hir::Block) { + pub fn check_block_no_value(&self, blk: &'tcx hir::Block) { let unit = self.tcx.mk_unit(); let ty = self.check_block_with_expected(blk, ExpectHasType(unit)); @@ -4881,9 +4893,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_block_with_expected(&self, - blk: &'tcx hir::Block, - expected: Expectation<'tcx>) -> Ty<'tcx> { + fn check_block_with_expected( + &self, + blk: &'tcx hir::Block, + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let prev = { let mut fcx_ps = self.ps.borrow_mut(); let unsafety_state = fcx_ps.recurse(blk); @@ -5155,11 +5169,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// This routine checks if the return expression in a block would make sense on its own as a /// statement and the return type has been left as default or has been specified as `()`. If so, /// it suggests adding a semicolon. - fn suggest_missing_semicolon(&self, - err: &mut DiagnosticBuilder<'tcx>, - expression: &'tcx hir::Expr, - expected: Ty<'tcx>, - cause_span: Span) { + fn suggest_missing_semicolon( + &self, + err: &mut DiagnosticBuilder<'tcx>, + expression: &'tcx hir::Expr, + expected: Ty<'tcx>, + cause_span: Span, + ) { if expected.is_unit() { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. @@ -5268,11 +5284,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn could_remove_semicolon( - &self, - blk: &'tcx hir::Block, - expected_ty: Ty<'tcx>, - ) -> Option<Span> { + fn could_remove_semicolon(&self, blk: &'tcx hir::Block, expected_ty: Ty<'tcx>) -> Option<Span> { // Be helpful when the user wrote `{... expr;}` and // taking the `;` off is enough to fix the error. let last_stmt = blk.stmts.last()?; @@ -5632,9 +5644,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: hir::HirId, - ctxt: BreakableCtxt<'tcx>, f: F) - -> (BreakableCtxt<'tcx>, R) { + fn with_breakable_ctxt<F: FnOnce() -> R, R>( + &self, + id: hir::HirId, + ctxt: BreakableCtxt<'tcx>, + f: F, + ) -> (BreakableCtxt<'tcx>, R) { let index; { let mut enclosing_breakables = self.enclosing_breakables.borrow_mut(); diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 1c129882d9c..93855a3b68a 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -13,12 +13,13 @@ use rustc::hir; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Checks a `a <op>= b` - pub fn check_binop_assign(&self, - expr: &'tcx hir::Expr, - op: hir::BinOp, - lhs_expr: &'tcx hir::Expr, - rhs_expr: &'tcx hir::Expr) -> Ty<'tcx> - { + pub fn check_binop_assign( + &self, + expr: &'tcx hir::Expr, + op: hir::BinOp, + lhs_expr: &'tcx hir::Expr, + rhs_expr: &'tcx hir::Expr, + ) -> Ty<'tcx> { let (lhs_ty, rhs_ty, return_ty) = self.check_overloaded_binop(expr, lhs_expr, rhs_expr, op, IsAssign::Yes); @@ -43,12 +44,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Checks a potentially overloaded binary operator. - pub fn check_binop(&self, - expr: &'tcx hir::Expr, - op: hir::BinOp, - lhs_expr: &'tcx hir::Expr, - rhs_expr: &'tcx hir::Expr) -> Ty<'tcx> - { + pub fn check_binop( + &self, + expr: &'tcx hir::Expr, + op: hir::BinOp, + lhs_expr: &'tcx hir::Expr, + rhs_expr: &'tcx hir::Expr, + ) -> Ty<'tcx> { let tcx = self.tcx; debug!("check_binop(expr.hir_id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})", @@ -104,14 +106,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn enforce_builtin_binop_types(&self, - lhs_expr: &'tcx hir::Expr, - lhs_ty: Ty<'tcx>, - rhs_expr: &'tcx hir::Expr, - rhs_ty: Ty<'tcx>, - op: hir::BinOp) - -> Ty<'tcx> - { + fn enforce_builtin_binop_types( + &self, + lhs_expr: &'tcx hir::Expr, + lhs_ty: Ty<'tcx>, + rhs_expr: &'tcx hir::Expr, + rhs_ty: Ty<'tcx>, + op: hir::BinOp, + ) -> Ty<'tcx> { debug_assert!(is_builtin_binop(lhs_ty, rhs_ty, op)); let tcx = self.tcx; @@ -142,14 +144,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_overloaded_binop(&self, - expr: &'tcx hir::Expr, - lhs_expr: &'tcx hir::Expr, - rhs_expr: &'tcx hir::Expr, - op: hir::BinOp, - is_assign: IsAssign) - -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) - { + fn check_overloaded_binop( + &self, + expr: &'tcx hir::Expr, + lhs_expr: &'tcx hir::Expr, + rhs_expr: &'tcx hir::Expr, + op: hir::BinOp, + is_assign: IsAssign, + ) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) { debug!("check_overloaded_binop(expr.hir_id={}, op={:?}, is_assign={:?})", expr.hir_id, op, @@ -611,12 +613,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - pub fn check_user_unop(&self, - ex: &'tcx hir::Expr, - operand_ty: Ty<'tcx>, - op: hir::UnOp) - -> Ty<'tcx> - { + pub fn check_user_unop( + &self, + ex: &'tcx hir::Expr, + operand_ty: Ty<'tcx>, + op: hir::UnOp, + ) -> Ty<'tcx> { assert!(op.is_by_value()); match self.lookup_op_method(operand_ty, &[], Op::Unary(op, ex.span)) { Ok(method) => { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 8baf6d03e1d..77ac2b96160 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -227,18 +227,11 @@ fn check_associated_item<'tcx>( }) } -fn for_item<'tcx>( - tcx: TyCtxt<'tcx>, - item: &hir::Item, -) -> CheckWfFcxBuilder<'tcx> { +fn for_item<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item) -> CheckWfFcxBuilder<'tcx> { for_id(tcx, item.hir_id, item.span) } -fn for_id<'tcx>( - tcx: TyCtxt<'tcx>, - id: hir::HirId, - span: Span, -) -> CheckWfFcxBuilder<'tcx> { +fn for_id<'tcx>(tcx: TyCtxt<'tcx>, id: hir::HirId, span: Span) -> CheckWfFcxBuilder<'tcx> { let def_id = tcx.hir().local_def_id_from_hir_id(id); CheckWfFcxBuilder { inherited: Inherited::build(tcx, def_id), @@ -768,11 +761,12 @@ fn check_existential_types<'fcx, 'tcx>( substituted_predicates } -fn check_method_receiver<'fcx, 'tcx>(fcx: &FnCtxt<'fcx, 'tcx>, - method_sig: &hir::MethodSig, - method: &ty::AssocItem, - self_ty: Ty<'tcx>) -{ +fn check_method_receiver<'fcx, 'tcx>( + fcx: &FnCtxt<'fcx, 'tcx>, + method_sig: &hir::MethodSig, + method: &ty::AssocItem, + self_ty: Ty<'tcx>, +) { // Check that the method has a valid receiver type, given the type `Self`. debug!("check_method_receiver({:?}, self_ty={:?})", method, self_ty); @@ -1028,11 +1022,7 @@ fn reject_shadowing_parameters(tcx: TyCtxt<'_>, def_id: DefId) { /// Feature gates RFC 2056 -- trivial bounds, checking for global bounds that /// aren't true. -fn check_false_global_bounds<'a, 'tcx>( - fcx: &FnCtxt<'a, 'tcx>, - span: Span, - id: hir::HirId) -{ +fn check_false_global_bounds<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, span: Span, id: hir::HirId) { let empty_env = ty::ParamEnv::empty(); let def_id = fcx.tcx.hir().local_def_id_from_hir_id(id); diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 7816d8e2ba5..4336e861ce2 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -40,11 +40,7 @@ fn check_impl<'tcx>(tcx: TyCtxt<'tcx>, hir_id: HirId) { } } -fn enforce_trait_manually_implementable( - tcx: TyCtxt<'_>, - impl_def_id: DefId, - trait_def_id: DefId, -) { +fn enforce_trait_manually_implementable(tcx: TyCtxt<'_>, impl_def_id: DefId, trait_def_id: DefId) { let did = Some(trait_def_id); let li = tcx.lang_items(); let span = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap()); @@ -96,11 +92,7 @@ fn enforce_trait_manually_implementable( /// We allow impls of marker traits to overlap, so they can't override impls /// as that could make it ambiguous which associated item to use. -fn enforce_empty_impls_for_marker_traits( - tcx: TyCtxt<'_>, - impl_def_id: DefId, - trait_def_id: DefId, -) { +fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt<'_>, impl_def_id: DefId, trait_def_id: DefId) { if !tcx.trait_def(trait_def_id).is_marker { return; } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 542ced15953..d4b2c200297 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -514,11 +514,7 @@ fn convert_variant_ctor<'tcx>(tcx: TyCtxt<'tcx>, ctor_id: hir::HirId) { tcx.predicates_of(def_id); } -fn convert_enum_variant_types<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: DefId, - variants: &[hir::Variant], -) { +fn convert_enum_variant_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, variants: &[hir::Variant]) { let def = tcx.adt_def(def_id); let repr_type = def.repr.discr_type(); let initial = repr_type.initial_discriminant(tcx); @@ -1143,11 +1139,7 @@ fn type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { /// /// If you want to fail anyway, you can set the `fail` parameter to true, but in this case, /// you'd better just call [`type_of`] directly. -pub fn checked_type_of<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: DefId, - fail: bool, -) -> Option<Ty<'tcx>> { +pub fn checked_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fail: bool) -> Option<Ty<'tcx>> { use rustc::hir::*; let hir_id = match tcx.hir().as_local_hir_id(def_id) { @@ -1842,10 +1834,7 @@ fn predicates_defined_on<'tcx>( /// Returns a list of all type predicates (explicit and implicit) for the definition with /// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus /// `Self: Trait` predicates for traits. -fn predicates_of<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: DefId, -) -> &'tcx ty::GenericPredicates<'tcx> { +fn predicates_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::GenericPredicates<'tcx> { let mut result = tcx.predicates_defined_on(def_id); if tcx.is_trait(def_id) { diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 52fa0d8ebdc..b833d8555ee 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -183,10 +183,7 @@ fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: &str) } /// Enforce that we do not have two items in an impl with the same name. -fn enforce_impl_items_are_distinct<'tcx>( - tcx: TyCtxt<'tcx>, - impl_item_refs: &[hir::ImplItemRef], -) { +fn enforce_impl_items_are_distinct<'tcx>(tcx: TyCtxt<'tcx>, impl_item_refs: &[hir::ImplItemRef]) { let mut seen_type_items = FxHashMap::default(); let mut seen_value_items = FxHashMap::default(); for impl_item_ref in impl_item_refs { diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 40168e917e9..ea458842acc 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -34,10 +34,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn crate_variances<'tcx>( - tcx: TyCtxt<'tcx>, - crate_num: CrateNum, -) -> &'tcx CrateVariancesMap<'tcx> { +fn crate_variances<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx CrateVariancesMap<'tcx> { assert_eq!(crate_num, LOCAL_CRATE); let mut arena = arena::TypedArena::default(); let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &mut arena); |
