From f3f9d6dfd92dfaeb14df891ad27b2531809dd734 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 14 Jun 2019 00:48:52 +0300 Subject: [PATCH 1/2] Unify all uses of 'gcx and 'tcx. --- src/librustc/cfg/construct.rs | 4 +- src/librustc/cfg/graphviz.rs | 2 +- src/librustc/cfg/mod.rs | 2 +- src/librustc/dep_graph/dep_node.rs | 58 +-- src/librustc/dep_graph/graph.rs | 10 +- src/librustc/dep_graph/safe.rs | 2 +- src/librustc/hir/check_attr.rs | 4 +- src/librustc/hir/def_id.rs | 2 +- src/librustc/hir/lowering.rs | 34 +- src/librustc/hir/upvars.rs | 2 +- src/librustc/ich/hcx.rs | 10 +- src/librustc/ich/impls_syntax.rs | 4 +- src/librustc/ich/impls_ty.rs | 16 +- src/librustc/infer/at.rs | 20 +- src/librustc/infer/canonical/canonicalizer.rs | 48 +-- src/librustc/infer/canonical/mod.rs | 22 +- .../infer/canonical/query_response.rs | 32 +- src/librustc/infer/canonical/substitute.rs | 6 +- src/librustc/infer/combine.rs | 30 +- src/librustc/infer/equate.rs | 14 +- src/librustc/infer/error_reporting/mod.rs | 14 +- .../infer/error_reporting/need_type_info.rs | 26 +- .../nice_region_error/different_lifetimes.rs | 2 +- .../nice_region_error/find_anon_type.rs | 28 +- .../error_reporting/nice_region_error/mod.rs | 14 +- .../nice_region_error/named_anon_conflict.rs | 2 +- .../nice_region_error/outlives_closure.rs | 2 +- .../nice_region_error/placeholder_error.rs | 15 +- .../nice_region_error/static_impl_trait.rs | 2 +- .../error_reporting/nice_region_error/util.rs | 2 +- src/librustc/infer/error_reporting/note.rs | 2 +- src/librustc/infer/freshen.rs | 14 +- src/librustc/infer/fudge.rs | 10 +- src/librustc/infer/glb.rs | 20 +- src/librustc/infer/higher_ranked/mod.rs | 4 +- src/librustc/infer/lattice.rs | 8 +- .../infer/lexical_region_resolve/graphviz.rs | 20 +- .../infer/lexical_region_resolve/mod.rs | 16 +- src/librustc/infer/lub.rs | 20 +- src/librustc/infer/mod.rs | 48 +-- src/librustc/infer/nll_relate/mod.rs | 32 +- src/librustc/infer/opaque_types/mod.rs | 41 +- src/librustc/infer/outlives/env.rs | 6 +- .../infer/outlives/free_region_map.rs | 6 +- src/librustc/infer/outlives/obligations.rs | 14 +- src/librustc/infer/outlives/verify.rs | 14 +- .../infer/region_constraints/leak_check.rs | 4 +- src/librustc/infer/region_constraints/mod.rs | 12 +- src/librustc/infer/resolve.rs | 44 +-- src/librustc/infer/sub.rs | 14 +- src/librustc/infer/unify_key.rs | 6 +- src/librustc/lint/context.rs | 18 +- src/librustc/lint/mod.rs | 6 +- src/librustc/macros.rs | 14 +- src/librustc/middle/cstore.rs | 4 +- src/librustc/middle/dead.rs | 16 +- src/librustc/middle/dependency_format.rs | 10 +- src/librustc/middle/entry.rs | 6 +- src/librustc/middle/exported_symbols.rs | 8 +- src/librustc/middle/expr_use_visitor.rs | 20 +- src/librustc/middle/free_region.rs | 8 +- src/librustc/middle/intrinsicck.rs | 8 +- src/librustc/middle/lang_items.rs | 8 +- src/librustc/middle/lib_features.rs | 6 +- src/librustc/middle/liveness.rs | 8 +- src/librustc/middle/mem_categorization.rs | 24 +- src/librustc/middle/reachable.rs | 10 +- src/librustc/middle/region.rs | 14 +- src/librustc/middle/resolve_lifetime.rs | 18 +- src/librustc/middle/stability.rs | 18 +- src/librustc/middle/weak_lang_items.rs | 10 +- src/librustc/mir/interpret/error.rs | 12 +- src/librustc/mir/interpret/mod.rs | 2 +- src/librustc/mir/mod.rs | 34 +- src/librustc/mir/mono.rs | 34 +- src/librustc/mir/tcx.rs | 18 +- src/librustc/traits/auto_trait.rs | 54 ++- src/librustc/traits/chalk_fulfill.rs | 10 +- src/librustc/traits/codegen/mod.rs | 18 +- src/librustc/traits/coherence.rs | 30 +- src/librustc/traits/engine.rs | 16 +- src/librustc/traits/error_reporting.rs | 18 +- src/librustc/traits/fulfill.rs | 28 +- src/librustc/traits/mod.rs | 38 +- src/librustc/traits/object_safety.rs | 4 +- src/librustc/traits/on_unimplemented.rs | 18 +- src/librustc/traits/project.rs | 110 +++--- src/librustc/traits/query/dropck_outlives.rs | 8 +- .../traits/query/evaluate_obligation.rs | 2 +- src/librustc/traits/query/normalize.rs | 10 +- .../traits/query/normalize_erasing_regions.rs | 8 +- src/librustc/traits/query/outlives_bounds.rs | 2 +- .../traits/query/type_op/ascribe_user_type.rs | 12 +- src/librustc/traits/query/type_op/custom.rs | 14 +- src/librustc/traits/query/type_op/eq.rs | 12 +- .../query/type_op/implied_outlives_bounds.rs | 12 +- src/librustc/traits/query/type_op/mod.rs | 34 +- .../traits/query/type_op/normalize.rs | 78 ++-- src/librustc/traits/query/type_op/outlives.rs | 15 +- .../traits/query/type_op/prove_predicate.rs | 12 +- src/librustc/traits/query/type_op/subtype.rs | 12 +- src/librustc/traits/select.rs | 32 +- src/librustc/traits/specialize/mod.rs | 12 +- .../traits/specialize/specialization_graph.rs | 26 +- src/librustc/traits/structural_impls.rs | 30 +- src/librustc/traits/util.rs | 84 ++-- src/librustc/ty/_match.rs | 12 +- src/librustc/ty/adjustment.rs | 4 +- src/librustc/ty/codec.rs | 2 +- src/librustc/ty/constness.rs | 8 +- src/librustc/ty/context.rs | 180 ++++----- src/librustc/ty/erase_regions.rs | 12 +- src/librustc/ty/error.rs | 6 +- src/librustc/ty/fast_reject.rs | 4 +- src/librustc/ty/fold.rs | 66 ++-- .../ty/inhabitedness/def_id_forest.rs | 10 +- src/librustc/ty/inhabitedness/mod.rs | 18 +- src/librustc/ty/instance.rs | 28 +- src/librustc/ty/layout.rs | 54 +-- src/librustc/ty/mod.rs | 130 +++---- src/librustc/ty/outlives.rs | 2 +- src/librustc/ty/print/mod.rs | 16 +- src/librustc/ty/print/obsolete.rs | 4 +- src/librustc/ty/print/pretty.rs | 56 +-- src/librustc/ty/query/config.rs | 22 +- src/librustc/ty/query/job.rs | 14 +- src/librustc/ty/query/keys.rs | 42 +- src/librustc/ty/query/on_disk_cache.rs | 20 +- src/librustc/ty/query/plumbing.rs | 72 ++-- src/librustc/ty/query/values.rs | 12 +- src/librustc/ty/relate.rs | 359 +++++------------- src/librustc/ty/structural_impls.rs | 110 +++--- src/librustc/ty/sty.rs | 130 +++---- src/librustc/ty/subst.rs | 42 +- src/librustc/ty/trait_def.rs | 10 +- src/librustc/ty/util.rs | 56 +-- src/librustc/ty/wf.rs | 16 +- src/librustc_borrowck/borrowck/check_loans.rs | 2 +- .../borrowck/gather_loans/gather_moves.rs | 2 +- .../borrowck/gather_loans/mod.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 10 +- src/librustc_borrowck/borrowck/move_data.rs | 10 +- src/librustc_borrowck/dataflow.rs | 4 +- src/librustc_codegen_llvm/allocator.rs | 2 +- src/librustc_codegen_llvm/attributes.rs | 2 +- src/librustc_codegen_llvm/back/write.rs | 2 +- src/librustc_codegen_llvm/base.rs | 8 +- src/librustc_codegen_llvm/builder.rs | 2 +- src/librustc_codegen_llvm/context.rs | 8 +- .../debuginfo/metadata.rs | 2 +- src/librustc_codegen_llvm/lib.rs | 18 +- src/librustc_codegen_ssa/back/linker.rs | 4 +- .../back/symbol_export.rs | 18 +- src/librustc_codegen_ssa/back/write.rs | 16 +- src/librustc_codegen_ssa/base.rs | 10 +- src/librustc_codegen_ssa/common.rs | 2 +- .../debuginfo/type_names.rs | 8 +- src/librustc_codegen_ssa/traits/backend.rs | 12 +- src/librustc_codegen_utils/codegen_backend.rs | 2 +- src/librustc_codegen_utils/lib.rs | 2 +- src/librustc_codegen_utils/symbol_names.rs | 2 +- .../symbol_names/legacy.rs | 14 +- src/librustc_codegen_utils/symbol_names/v0.rs | 8 +- .../symbol_names_test.rs | 4 +- src/librustc_driver/pretty.rs | 16 +- src/librustc_incremental/assert_dep_graph.rs | 8 +- .../assert_module_sources.rs | 4 +- .../persist/dirty_clean.rs | 10 +- src/librustc_incremental/persist/load.rs | 2 +- src/librustc_incremental/persist/save.rs | 6 +- src/librustc_interface/passes.rs | 14 +- src/librustc_interface/proc_macro_decls.rs | 4 +- src/librustc_lint/lib.rs | 2 +- src/librustc_lint/types.rs | 6 +- src/librustc_macros/src/query.rs | 8 +- src/librustc_metadata/cstore_impl.rs | 13 +- src/librustc_metadata/decoder.rs | 46 +-- src/librustc_metadata/encoder.rs | 8 +- src/librustc_metadata/foreign_modules.rs | 4 +- src/librustc_metadata/link_args.rs | 2 +- src/librustc_metadata/native_libs.rs | 4 +- src/librustc_mir/borrow_check/borrow_set.rs | 10 +- .../borrow_check/conflict_errors.rs | 4 +- .../borrow_check/error_reporting.rs | 6 +- src/librustc_mir/borrow_check/flows.rs | 20 +- src/librustc_mir/borrow_check/mod.rs | 54 +-- src/librustc_mir/borrow_check/move_errors.rs | 4 +- .../borrow_check/mutability_errors.rs | 12 +- .../borrow_check/nll/constraint_generation.rs | 12 +- .../nll/explain_borrow/find_use.rs | 14 +- .../borrow_check/nll/explain_borrow/mod.rs | 6 +- src/librustc_mir/borrow_check/nll/facts.rs | 4 +- .../borrow_check/nll/invalidation.rs | 12 +- src/librustc_mir/borrow_check/nll/mod.rs | 22 +- .../nll/region_infer/error_reporting/mod.rs | 14 +- .../error_reporting/region_name.rs | 20 +- .../region_infer/error_reporting/var_name.rs | 8 +- .../borrow_check/nll/region_infer/mod.rs | 72 ++-- src/librustc_mir/borrow_check/nll/renumber.rs | 12 +- .../nll/type_check/constraint_conversion.rs | 14 +- .../nll/type_check/free_region_relations.rs | 8 +- .../nll/type_check/input_output.rs | 2 +- .../nll/type_check/liveness/mod.rs | 8 +- .../nll/type_check/liveness/trace.rs | 26 +- .../borrow_check/nll/type_check/mod.rs | 54 +-- .../borrow_check/nll/type_check/relate_tys.rs | 12 +- .../borrow_check/nll/universal_regions.rs | 20 +- src/librustc_mir/borrow_check/path_utils.rs | 4 +- src/librustc_mir/borrow_check/place_ext.rs | 4 +- .../borrow_check/places_conflict.rs | 20 +- src/librustc_mir/borrow_check/prefixes.rs | 10 +- src/librustc_mir/borrow_check/used_muts.rs | 10 +- src/librustc_mir/build/mod.rs | 8 +- src/librustc_mir/const_eval.rs | 16 +- .../dataflow/drop_flag_effects.rs | 42 +- src/librustc_mir/dataflow/impls/borrows.rs | 14 +- src/librustc_mir/dataflow/impls/mod.rs | 86 ++--- src/librustc_mir/dataflow/mod.rs | 12 +- .../dataflow/move_paths/builder.rs | 24 +- src/librustc_mir/dataflow/move_paths/mod.rs | 6 +- src/librustc_mir/hair/constant.rs | 2 +- src/librustc_mir/hair/cx/mod.rs | 10 +- src/librustc_mir/hair/pattern/_match.rs | 28 +- src/librustc_mir/hair/pattern/check_match.rs | 4 +- src/librustc_mir/hair/pattern/mod.rs | 10 +- src/librustc_mir/hair/util.rs | 2 +- src/librustc_mir/interpret/eval_context.rs | 6 +- .../interpret/intrinsics/type_name.rs | 14 +- src/librustc_mir/interpret/machine.rs | 2 +- src/librustc_mir/interpret/memory.rs | 6 +- src/librustc_mir/interpret/snapshot.rs | 2 +- src/librustc_mir/lints.rs | 4 +- src/librustc_mir/monomorphize/collector.rs | 42 +- src/librustc_mir/monomorphize/item.rs | 14 +- src/librustc_mir/monomorphize/mod.rs | 2 +- src/librustc_mir/monomorphize/partitioning.rs | 30 +- src/librustc_mir/shim.rs | 18 +- src/librustc_mir/transform/add_call_guards.rs | 2 +- .../transform/add_moves_for_packed_drops.rs | 8 +- src/librustc_mir/transform/add_retag.rs | 4 +- src/librustc_mir/transform/check_unsafety.rs | 18 +- .../transform/cleanup_post_borrowck.rs | 2 +- src/librustc_mir/transform/const_prop.rs | 10 +- src/librustc_mir/transform/copy_prop.rs | 2 +- src/librustc_mir/transform/deaggregator.rs | 2 +- src/librustc_mir/transform/dump_mir.rs | 6 +- src/librustc_mir/transform/elaborate_drops.rs | 20 +- src/librustc_mir/transform/erase_regions.rs | 6 +- src/librustc_mir/transform/generator.rs | 20 +- src/librustc_mir/transform/inline.rs | 6 +- src/librustc_mir/transform/instcombine.rs | 6 +- src/librustc_mir/transform/lower_128bit.rs | 10 +- src/librustc_mir/transform/mod.rs | 18 +- src/librustc_mir/transform/no_landing_pads.rs | 4 +- src/librustc_mir/transform/promote_consts.rs | 4 +- src/librustc_mir/transform/qualify_consts.rs | 10 +- .../transform/qualify_min_const_fn.rs | 12 +- .../transform/remove_noop_landing_pads.rs | 4 +- src/librustc_mir/transform/rustc_peek.rs | 8 +- src/librustc_mir/transform/simplify.rs | 4 +- .../transform/simplify_branches.rs | 2 +- .../transform/uniform_array_move_out.rs | 6 +- src/librustc_mir/util/alignment.rs | 4 +- src/librustc_mir/util/borrowck_errors.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 4 +- src/librustc_mir/util/graphviz.rs | 8 +- src/librustc_mir/util/liveness.rs | 6 +- src/librustc_mir/util/mod.rs | 4 +- src/librustc_mir/util/pretty.rs | 54 +-- src/librustc_passes/layout_test.rs | 8 +- src/librustc_passes/loops.rs | 2 +- src/librustc_passes/rvalue_promotion.rs | 12 +- src/librustc_plugin/build.rs | 4 +- src/librustc_privacy/lib.rs | 42 +- src/librustc_save_analysis/dump_visitor.rs | 2 +- src/librustc_save_analysis/lib.rs | 4 +- src/librustc_traits/chalk_context/mod.rs | 114 +++--- .../chalk_context/program_clauses/builtin.rs | 8 +- .../chalk_context/program_clauses/mod.rs | 6 +- .../program_clauses/primitive.rs | 14 +- .../chalk_context/resolvent_ops.rs | 20 +- src/librustc_traits/chalk_context/unify.rs | 14 +- src/librustc_traits/dropck_outlives.rs | 8 +- src/librustc_traits/evaluate_obligation.rs | 2 +- src/librustc_traits/generic_types.rs | 16 +- .../implied_outlives_bounds.rs | 4 +- src/librustc_traits/lowering/environment.rs | 8 +- src/librustc_traits/lowering/mod.rs | 16 +- .../normalize_erasing_regions.rs | 2 +- .../normalize_projection_ty.rs | 2 +- src/librustc_traits/type_op.rs | 28 +- src/librustc_typeck/astconv.rs | 20 +- src/librustc_typeck/check/_match.rs | 32 +- src/librustc_typeck/check/autoderef.rs | 28 +- src/librustc_typeck/check/callee.rs | 36 +- src/librustc_typeck/check/cast.rs | 34 +- src/librustc_typeck/check/closure.rs | 12 +- src/librustc_typeck/check/coercion.rs | 50 ++- src/librustc_typeck/check/compare_method.rs | 18 +- src/librustc_typeck/check/demand.rs | 2 +- src/librustc_typeck/check/dropck.rs | 10 +- .../check/generator_interior.rs | 12 +- src/librustc_typeck/check/intrinsic.rs | 6 +- src/librustc_typeck/check/method/confirm.rs | 30 +- src/librustc_typeck/check/method/mod.rs | 8 +- src/librustc_typeck/check/method/probe.rs | 36 +- src/librustc_typeck/check/method/suggest.rs | 20 +- src/librustc_typeck/check/mod.rs | 251 ++++++------ src/librustc_typeck/check/op.rs | 30 +- src/librustc_typeck/check/regionck.rs | 44 +-- src/librustc_typeck/check/upvar.rs | 26 +- src/librustc_typeck/check/wfcheck.rs | 90 ++--- src/librustc_typeck/check/writeback.rs | 70 ++-- src/librustc_typeck/check_unused.rs | 8 +- src/librustc_typeck/coherence/builtin.rs | 22 +- .../coherence/inherent_impls.rs | 6 +- .../coherence/inherent_impls_overlap.rs | 4 +- src/librustc_typeck/coherence/mod.rs | 12 +- src/librustc_typeck/coherence/orphan.rs | 4 +- src/librustc_typeck/coherence/unsafety.rs | 4 +- src/librustc_typeck/collect.rs | 80 ++-- .../constrained_generic_params.rs | 4 +- src/librustc_typeck/impl_wf_check.rs | 12 +- src/librustc_typeck/lib.rs | 18 +- src/librustc_typeck/outlives/explicit.rs | 2 +- .../outlives/implicit_infer.rs | 8 +- src/librustc_typeck/outlives/mod.rs | 4 +- src/librustc_typeck/outlives/test.rs | 4 +- src/librustc_typeck/outlives/utils.rs | 4 +- src/librustc_typeck/variance/constraints.rs | 2 +- src/librustc_typeck/variance/mod.rs | 4 +- src/librustc_typeck/variance/terms.rs | 6 +- src/librustc_typeck/variance/test.rs | 4 +- src/librustdoc/clean/auto_trait.rs | 24 +- src/librustdoc/clean/mod.rs | 4 +- src/librustdoc/core.rs | 2 +- .../hotplug_codegen_backend/the_backend.rs | 2 +- .../internal-lints/pass_ty_by_ref.rs | 30 +- .../internal-lints/pass_ty_by_ref.stderr | 42 +- .../internal-lints/qualified_ty_ty_ctxt.rs | 8 +- .../qualified_ty_ty_ctxt.stderr | 6 +- 341 files changed, 3109 insertions(+), 3327 deletions(-) diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index a2e7ebfdb0e4b..139c144fbcf4e 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -8,7 +8,7 @@ use crate::hir::{self, PatKind}; use crate::hir::def_id::DefId; struct CFGBuilder<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, owner_def_id: DefId, tables: &'a ty::TypeckTables<'tcx>, graph: CFGGraph, @@ -30,7 +30,7 @@ struct LoopScope { break_index: CFGIndex, // where to go on a `break` } -pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &hir::Body) -> CFG { +pub fn construct<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body) -> CFG { let mut graph = graph::Graph::new(); let entry = graph.add_node(CFGNodeData::Entry); diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index 481b5c72e9304..dbc462ee49b37 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -12,7 +12,7 @@ pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode); pub type Edge<'a> = &'a cfg::CFGEdge; pub struct LabelledCFG<'a, 'tcx: 'a> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub cfg: &'a cfg::CFG, pub name: String, /// `labelled_edges` controls whether we emit labels on the edges diff --git a/src/librustc/cfg/mod.rs b/src/librustc/cfg/mod.rs index d25d58bfd1fa6..db168d99a0801 100644 --- a/src/librustc/cfg/mod.rs +++ b/src/librustc/cfg/mod.rs @@ -49,7 +49,7 @@ pub type CFGNode = graph::Node; pub type CFGEdge = graph::Edge; impl CFG { - pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &hir::Body) -> CFG { + pub fn new<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body) -> CFG { construct::construct(tcx, body) } diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 82bba96dd4cc7..f7647167a7578 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -204,10 +204,10 @@ macro_rules! define_dep_nodes { impl DepNode { #[allow(unreachable_code, non_snake_case)] #[inline(always)] - pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, - dep: DepConstructor<'gcx>) + pub fn new<'a, 'tcx>(tcx: TyCtxt<'tcx>, + dep: DepConstructor<'tcx>) -> DepNode - where 'gcx: 'a + 'tcx, + where 'tcx: 'a, 'tcx: 'a { match dep { @@ -307,7 +307,7 @@ macro_rules! define_dep_nodes { /// refers to something from the previous compilation session that /// has been removed. #[inline] - pub fn extract_def_id(&self, tcx: TyCtxt<'_, '_>) -> Option { + pub fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option { if self.kind.can_reconstruct_query_key() { let def_path_hash = DefPathHash(self.hash); tcx.def_path_hash_to_def_id.as_ref()? @@ -400,7 +400,7 @@ impl DefPathHash { impl DefId { #[inline(always)] - pub fn to_dep_node(self, tcx: TyCtxt<'_, '_>, kind: DepKind) -> DepNode { + pub fn to_dep_node(self, tcx: TyCtxt<'_>, kind: DepKind) -> DepNode { DepNode::from_def_path_hash(kind, tcx.def_path_hash(self)) } } @@ -442,50 +442,50 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> ]); pub trait RecoverKey<'tcx>: Sized { - fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option; + fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option; } impl RecoverKey<'tcx> for CrateNum { - fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option { + fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option { dep_node.extract_def_id(tcx).map(|id| id.krate) } } impl RecoverKey<'tcx> for DefId { - fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option { + fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option { dep_node.extract_def_id(tcx) } } impl RecoverKey<'tcx> for DefIndex { - fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option { + fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option { dep_node.extract_def_id(tcx).map(|id| id.index) } } -trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug { +trait DepNodeParams<'tcx>: fmt::Debug { const CAN_RECONSTRUCT_QUERY_KEY: bool; /// This method turns the parameters of a DepNodeConstructor into an opaque /// Fingerprint to be used in DepNode. /// Not all DepNodeParams support being turned into a Fingerprint (they /// don't need to if the corresponding DepNode is anonymous). - fn to_fingerprint(&self, _: TyCtxt<'gcx, 'tcx>) -> Fingerprint { + fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint { panic!("Not implemented. Accidentally called on anonymous node?") } - fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String { + fn to_debug_str(&self, _: TyCtxt<'tcx>) -> String { format!("{:?}", self) } } -impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T +impl<'tcx, T> DepNodeParams<'tcx> for T where T: HashStable> + fmt::Debug, { default const CAN_RECONSTRUCT_QUERY_KEY: bool = false; - default fn to_fingerprint(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Fingerprint { + default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint { let mut hcx = tcx.create_stable_hashing_context(); let mut hasher = StableHasher::new(); @@ -494,39 +494,39 @@ where hasher.finish() } - default fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String { + default fn to_debug_str(&self, _: TyCtxt<'tcx>) -> String { format!("{:?}", *self) } } -impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefId { +impl<'tcx> DepNodeParams<'tcx> for DefId { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; - fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint { tcx.def_path_hash(*self).0 } - fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { + fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String { tcx.def_path_str(*self) } } -impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefIndex { +impl<'tcx> DepNodeParams<'tcx> for DefIndex { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; - fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint { tcx.hir().definitions().def_path_hash(*self).0 } - fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { + fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String { tcx.def_path_str(DefId::local(*self)) } } -impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for CrateNum { +impl<'tcx> DepNodeParams<'tcx> for CrateNum { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; - fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint { let def_id = DefId { krate: *self, index: CRATE_DEF_INDEX, @@ -534,18 +534,18 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for CrateNum { tcx.def_path_hash(def_id).0 } - fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { + fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String { tcx.crate_name(*self).as_str().to_string() } } -impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) { +impl<'tcx> DepNodeParams<'tcx> for (DefId, DefId) { const CAN_RECONSTRUCT_QUERY_KEY: bool = false; // We actually would not need to specialize the implementation of this // method but it's faster to combine the hashes than to instantiate a full // hashing context and stable-hashing state. - fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint { let (def_id_0, def_id_1) = *self; let def_path_hash_0 = tcx.def_path_hash(def_id_0); @@ -554,7 +554,7 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) { def_path_hash_0.0.combine(def_path_hash_1.0) } - fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { + fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String { let (def_id_0, def_id_1) = *self; format!("({}, {})", @@ -563,13 +563,13 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) { } } -impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for HirId { +impl<'tcx> DepNodeParams<'tcx> for HirId { const CAN_RECONSTRUCT_QUERY_KEY: bool = false; // We actually would not need to specialize the implementation of this // method but it's faster to combine the hashes than to instantiate a full // hashing context and stable-hashing state. - fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint { let HirId { owner, local_id, diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 40ccd6e7b280a..c2e3c12cea8ed 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -557,7 +557,7 @@ impl DepGraph { /// a node index can be found for that node. pub fn try_mark_green_and_read( &self, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, dep_node: &DepNode, ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> { self.try_mark_green(tcx, dep_node).map(|(prev_index, dep_node_index)| { @@ -569,7 +569,7 @@ impl DepGraph { pub fn try_mark_green( &self, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, dep_node: &DepNode, ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> { debug_assert!(!dep_node.kind.is_eval_always()); @@ -603,7 +603,7 @@ impl DepGraph { /// Try to mark a dep-node which existed in the previous compilation session as green. fn try_mark_previous_green<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, data: &DepGraphData, prev_dep_node_index: SerializedDepNodeIndex, dep_node: &DepNode, @@ -790,7 +790,7 @@ impl DepGraph { #[inline(never)] fn emit_diagnostics<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, data: &DepGraphData, dep_node_index: DepNodeIndex, did_allocation: bool, @@ -841,7 +841,7 @@ impl DepGraph { // // This method will only load queries that will end up in the disk cache. // Other queries will not be executed. - pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) { + pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx>) { let green_nodes: Vec = { let data = self.data.as_ref().unwrap(); data.colors.values.indices().filter_map(|prev_index| { diff --git a/src/librustc/dep_graph/safe.rs b/src/librustc/dep_graph/safe.rs index 62667c957cdc0..e5eda14cdbe61 100644 --- a/src/librustc/dep_graph/safe.rs +++ b/src/librustc/dep_graph/safe.rs @@ -33,7 +33,7 @@ impl DepGraphSafe for DefId { /// The type context itself can be used to access all kinds of tracked /// state, but those accesses should always generate read events. -impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {} +impl<'tcx> DepGraphSafe for TyCtxt<'tcx> {} /// Tuples make it easy to build up state. impl DepGraphSafe for (A, B) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 4d13d91c8f27d..4b84d56858cca 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -88,7 +88,7 @@ impl Target { } struct CheckAttrVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl CheckAttrVisitor<'tcx> { @@ -347,7 +347,7 @@ fn is_c_like_enum(item: &hir::Item) -> bool { } } -fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module( module_def_id, &mut CheckAttrVisitor { tcx }.as_deep_visitor() diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index b3abe50a5952f..debed38361a14 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -177,7 +177,7 @@ impl DefId { LocalDefId::from_def_id(self) } - pub fn describe_as_module(&self, tcx: TyCtxt<'_, '_>) -> String { + pub fn describe_as_module(&self, tcx: TyCtxt<'_>) -> String { if self.is_local() && self.index == CRATE_DEF_INDEX { format!("top-level module") } else { diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index b5e9f6bd3a610..5fa67fe4489ad 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -413,8 +413,8 @@ impl<'a> LoweringContext<'a> { /// needed from arbitrary locations in the crate, /// e.g., the number of lifetime generic parameters /// declared for every type and trait definition. - struct MiscCollector<'lcx, 'interner: 'lcx> { - lctx: &'lcx mut LoweringContext<'interner>, + struct MiscCollector<'tcx, 'interner: 'tcx> { + lctx: &'tcx mut LoweringContext<'interner>, hir_id_owner: Option, } @@ -458,8 +458,8 @@ impl<'a> LoweringContext<'a> { } } - impl<'lcx, 'interner> Visitor<'lcx> for MiscCollector<'lcx, 'interner> { - fn visit_pat(&mut self, p: &'lcx Pat) { + impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> { + fn visit_pat(&mut self, p: &'tcx Pat) { match p.node { // Doesn't generate a HIR node PatKind::Paren(..) => {}, @@ -473,7 +473,7 @@ impl<'a> LoweringContext<'a> { visit::walk_pat(self, p) } - fn visit_item(&mut self, item: &'lcx Item) { + fn visit_item(&mut self, item: &'tcx Item) { let hir_id = self.lctx.allocate_hir_id_counter(item.id); match item.node { @@ -505,7 +505,7 @@ impl<'a> LoweringContext<'a> { }); } - fn visit_trait_item(&mut self, item: &'lcx TraitItem) { + fn visit_trait_item(&mut self, item: &'tcx TraitItem) { self.lctx.allocate_hir_id_counter(item.id); match item.node { @@ -521,21 +521,21 @@ impl<'a> LoweringContext<'a> { } } - fn visit_impl_item(&mut self, item: &'lcx ImplItem) { + fn visit_impl_item(&mut self, item: &'tcx ImplItem) { self.lctx.allocate_hir_id_counter(item.id); self.with_hir_id_owner(Some(item.id), |this| { visit::walk_impl_item(this, item); }); } - fn visit_foreign_item(&mut self, i: &'lcx ForeignItem) { + fn visit_foreign_item(&mut self, i: &'tcx ForeignItem) { // Ignore patterns in foreign items self.with_hir_id_owner(None, |this| { visit::walk_foreign_item(this, i) }); } - fn visit_ty(&mut self, t: &'lcx Ty) { + fn visit_ty(&mut self, t: &'tcx Ty) { match t.node { // Mirrors the case in visit::walk_ty TyKind::BareFn(ref f) => { @@ -559,11 +559,11 @@ impl<'a> LoweringContext<'a> { } } - struct ItemLowerer<'lcx, 'interner: 'lcx> { - lctx: &'lcx mut LoweringContext<'interner>, + struct ItemLowerer<'tcx, 'interner: 'tcx> { + lctx: &'tcx mut LoweringContext<'interner>, } - impl<'lcx, 'interner> ItemLowerer<'lcx, 'interner> { + impl<'tcx, 'interner> ItemLowerer<'tcx, 'interner> { fn with_trait_impl_ref(&mut self, trait_impl_ref: &Option, f: F) where F: FnOnce(&mut Self), @@ -579,8 +579,8 @@ impl<'a> LoweringContext<'a> { } } - impl<'lcx, 'interner> Visitor<'lcx> for ItemLowerer<'lcx, 'interner> { - fn visit_mod(&mut self, m: &'lcx Mod, _s: Span, _attrs: &[Attribute], n: NodeId) { + impl<'tcx, 'interner> Visitor<'tcx> for ItemLowerer<'tcx, 'interner> { + fn visit_mod(&mut self, m: &'tcx Mod, _s: Span, _attrs: &[Attribute], n: NodeId) { self.lctx.modules.insert(n, hir::ModuleItems { items: BTreeSet::new(), trait_items: BTreeSet::new(), @@ -593,7 +593,7 @@ impl<'a> LoweringContext<'a> { self.lctx.current_module = old; } - fn visit_item(&mut self, item: &'lcx Item) { + fn visit_item(&mut self, item: &'tcx Item) { let mut item_hir_id = None; self.lctx.with_hir_id_owner(item.id, |lctx| { if let Some(hir_item) = lctx.lower_item(item) { @@ -624,7 +624,7 @@ impl<'a> LoweringContext<'a> { } } - fn visit_trait_item(&mut self, item: &'lcx TraitItem) { + fn visit_trait_item(&mut self, item: &'tcx TraitItem) { self.lctx.with_hir_id_owner(item.id, |lctx| { let hir_item = lctx.lower_trait_item(item); let id = hir::TraitItemId { hir_id: hir_item.hir_id }; @@ -635,7 +635,7 @@ impl<'a> LoweringContext<'a> { visit::walk_trait_item(self, item); } - fn visit_impl_item(&mut self, item: &'lcx ImplItem) { + fn visit_impl_item(&mut self, item: &'tcx ImplItem) { self.lctx.with_hir_id_owner(item.id, |lctx| { let hir_item = lctx.lower_impl_item(item); let id = hir::ImplItemId { hir_id: hir_item.hir_id }; diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs index 332d15c319379..1a4fe35c530bb 100644 --- a/src/librustc/hir/upvars.rs +++ b/src/librustc/hir/upvars.rs @@ -55,7 +55,7 @@ impl Visitor<'tcx> for LocalCollector { } struct CaptureCollector<'a, 'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, locals: &'a FxHashSet, upvars: FxIndexMap, } diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 4b5b458b2afb7..4ef4d70ee1dcd 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -61,12 +61,12 @@ pub enum NodeIdHashingMode { /// We could also just store a plain reference to the hir::Crate but we want /// to avoid that the crate is used to get untracked access to all of the HIR. #[derive(Clone, Copy)] -struct BodyResolver<'gcx>(&'gcx hir::Crate); +struct BodyResolver<'tcx>(&'tcx hir::Crate); -impl<'gcx> BodyResolver<'gcx> { +impl<'tcx> BodyResolver<'tcx> { // Return a reference to the hir::Body with the given BodyId. // DOES NOT DO ANY TRACKING, use carefully. - fn body(self, id: hir::BodyId) -> &'gcx hir::Body { + fn body(self, id: hir::BodyId) -> &'tcx hir::Body { self.0.body(id) } } @@ -205,8 +205,8 @@ for &'b mut T { } } -impl StableHashingContextProvider<'lcx> for TyCtxt<'gcx, 'lcx> { - fn get_stable_hashing_context(&self) -> StableHashingContext<'lcx> { +impl StableHashingContextProvider<'tcx> for TyCtxt<'tcx> { + fn get_stable_hashing_context(&self) -> StableHashingContext<'tcx> { (*self).create_stable_hashing_context() } } diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index e0c01277801d4..f72248701d14b 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -508,9 +508,9 @@ fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar, -impl<'gcx> HashStable> for feature_gate::Features { +impl<'tcx> HashStable> for feature_gate::Features { fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, + hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { // Unfortunately we cannot exhaustively list fields here, since the // struct is macro generated. diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 89e79c56ca39d..3a46a7e2afb5b 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -11,8 +11,8 @@ use crate::middle::region; use crate::ty; use crate::mir; -impl<'a, 'gcx, T> HashStable> -for &'gcx ty::List +impl<'a, 'tcx, T> HashStable> +for &'tcx ty::List where T: HashStable> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, @@ -40,7 +40,7 @@ for &'gcx ty::List } } -impl<'a, 'gcx, T> ToStableHashKey> for &'gcx ty::List +impl<'a, 'tcx, T> ToStableHashKey> for &'tcx ty::List where T: HashStable> { type KeyType = Fingerprint; @@ -54,7 +54,7 @@ impl<'a, 'gcx, T> ToStableHashKey> for &'gcx ty::List HashStable> for ty::subst::Kind<'gcx> { +impl<'a, 'tcx> HashStable> for ty::subst::Kind<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { @@ -117,19 +117,19 @@ impl<'a> HashStable> for ty::RegionVid { } } -impl<'gcx, 'tcx> HashStable> for ty::ConstVid<'tcx> { +impl<'a, 'tcx> HashStable> for ty::ConstVid<'tcx> { #[inline] fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, + hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { self.index.hash_stable(hcx, hasher); } } -impl<'gcx> HashStable> for ty::BoundVar { +impl<'tcx> HashStable> for ty::BoundVar { #[inline] fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, + hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { self.index().hash_stable(hcx, hasher); } diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 5772110889290..2d99e8a57e01f 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -30,24 +30,24 @@ use super::*; use crate::ty::Const; use crate::ty::relate::{Relate, TypeRelation}; -pub struct At<'a, 'gcx: 'tcx, 'tcx: 'a> { - pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct At<'a, 'tcx: 'a> { + pub infcx: &'a InferCtxt<'a, 'tcx>, pub cause: &'a ObligationCause<'tcx>, pub param_env: ty::ParamEnv<'tcx>, } -pub struct Trace<'a, 'gcx: 'tcx, 'tcx: 'a> { - at: At<'a, 'gcx, 'tcx>, +pub struct Trace<'a, 'tcx: 'a> { + at: At<'a, 'tcx>, a_is_expected: bool, trace: TypeTrace<'tcx>, } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { #[inline] pub fn at(&'a self, cause: &'a ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>) - -> At<'a, 'gcx, 'tcx> + -> At<'a, 'tcx> { At { infcx: self, cause, param_env } } @@ -61,7 +61,7 @@ pub trait ToTrace<'tcx>: Relate<'tcx> + Copy { -> TypeTrace<'tcx>; } -impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> At<'a, 'tcx> { /// Hacky routine for equating two impl headers in coherence. pub fn eq_impl_headers(self, expected: &ty::ImplHeader<'tcx>, @@ -189,7 +189,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { pub fn trace(self, expected: T, actual: T) - -> Trace<'a, 'gcx, 'tcx> + -> Trace<'a, 'tcx> where T: ToTrace<'tcx> { self.trace_exp(true, expected, actual) @@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { a_is_expected: bool, a: T, b: T) - -> Trace<'a, 'gcx, 'tcx> + -> Trace<'a, 'tcx> where T: ToTrace<'tcx> { let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b); @@ -210,7 +210,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> Trace<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Trace<'a, 'tcx> { /// Makes `a <: b` where `a` may or may not be expected (if /// `a_is_expected` is true, then `a` is expected). /// Makes `expected <: actual`. diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index dadac4b1e6b8f..b4779eec65f4c 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -21,7 +21,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; use smallvec::SmallVec; -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Canonicalizes a query value `V`. When we canonicalize a query, /// we not only canonicalize unbound inference variables, but we /// *also* replace all free regions whatsoever. So for example a @@ -41,9 +41,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { &self, value: &V, query_state: &mut OriginalQueryValues<'tcx>, - ) -> Canonicalized<'gcx, V> + ) -> Canonicalized<'tcx, V> where - V: TypeFoldable<'tcx> + Lift<'gcx>, + V: TypeFoldable<'tcx> + Lift<'tcx>, { self.tcx .sess @@ -85,9 +85,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { /// out the [chapter in the rustc guide][c]. /// /// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query-result - pub fn canonicalize_response(&self, value: &V) -> Canonicalized<'gcx, V> + pub fn canonicalize_response(&self, value: &V) -> Canonicalized<'tcx, V> where - V: TypeFoldable<'tcx> + Lift<'gcx>, + V: TypeFoldable<'tcx> + Lift<'tcx>, { let mut query_state = OriginalQueryValues::default(); Canonicalizer::canonicalize( @@ -99,9 +99,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { ) } - pub fn canonicalize_user_type_annotation(&self, value: &V) -> Canonicalized<'gcx, V> + pub fn canonicalize_user_type_annotation(&self, value: &V) -> Canonicalized<'tcx, V> where - V: TypeFoldable<'tcx> + Lift<'gcx>, + V: TypeFoldable<'tcx> + Lift<'tcx>, { let mut query_state = OriginalQueryValues::default(); Canonicalizer::canonicalize( @@ -130,9 +130,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { &self, value: &V, query_state: &mut OriginalQueryValues<'tcx>, - ) -> Canonicalized<'gcx, V> + ) -> Canonicalized<'tcx, V> where - V: TypeFoldable<'tcx> + Lift<'gcx>, + V: TypeFoldable<'tcx> + Lift<'tcx>, { self.tcx .sess @@ -160,7 +160,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { trait CanonicalizeRegionMode { fn canonicalize_free_region( &self, - canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + canonicalizer: &mut Canonicalizer<'_, 'tcx>, r: ty::Region<'tcx>, ) -> ty::Region<'tcx>; @@ -172,7 +172,7 @@ struct CanonicalizeQueryResponse; impl CanonicalizeRegionMode for CanonicalizeQueryResponse { fn canonicalize_free_region( &self, - canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + canonicalizer: &mut Canonicalizer<'_, 'tcx>, r: ty::Region<'tcx>, ) -> ty::Region<'tcx> { match r { @@ -221,7 +221,7 @@ struct CanonicalizeUserTypeAnnotation; impl CanonicalizeRegionMode for CanonicalizeUserTypeAnnotation { fn canonicalize_free_region( &self, - canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + canonicalizer: &mut Canonicalizer<'_, 'tcx>, r: ty::Region<'tcx>, ) -> ty::Region<'tcx> { match r { @@ -244,7 +244,7 @@ struct CanonicalizeAllFreeRegions; impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions { fn canonicalize_free_region( &self, - canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + canonicalizer: &mut Canonicalizer<'_, 'tcx>, r: ty::Region<'tcx>, ) -> ty::Region<'tcx> { canonicalizer.canonical_var_for_region_in_root_universe(r) @@ -260,7 +260,7 @@ struct CanonicalizeFreeRegionsOtherThanStatic; impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic { fn canonicalize_free_region( &self, - canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + canonicalizer: &mut Canonicalizer<'_, 'tcx>, r: ty::Region<'tcx>, ) -> ty::Region<'tcx> { if let ty::ReStatic = r { @@ -275,9 +275,9 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic { } } -struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>, - tcx: TyCtxt<'gcx, 'tcx>, +struct Canonicalizer<'cx, 'tcx: 'cx> { + infcx: Option<&'cx InferCtxt<'cx, 'tcx>>, + tcx: TyCtxt<'tcx>, variables: SmallVec<[CanonicalVarInfo; 8]>, query_state: &'cx mut OriginalQueryValues<'tcx>, // Note that indices is only used once `var_values` is big enough to be @@ -289,8 +289,8 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { binder_index: ty::DebruijnIndex, } -impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -495,18 +495,18 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> } } -impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> { /// The main `canonicalize` method, shared impl of /// `canonicalize_query` and `canonicalize_response`. fn canonicalize( value: &V, - infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>, - tcx: TyCtxt<'gcx, 'tcx>, + infcx: Option<&InferCtxt<'_, 'tcx>>, + tcx: TyCtxt<'tcx>, canonicalize_region_mode: &dyn CanonicalizeRegionMode, query_state: &mut OriginalQueryValues<'tcx>, - ) -> Canonicalized<'gcx, V> + ) -> Canonicalized<'tcx, V> where - V: TypeFoldable<'tcx> + Lift<'gcx>, + V: TypeFoldable<'tcx> + Lift<'tcx>, { let needs_canonical_flags = if canonicalize_region_mode.any() { TypeFlags::KEEP_IN_LOCAL_TCX | diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index 85e784d0ca5fb..8b1c34a487f5c 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -44,15 +44,15 @@ mod substitute; /// variables have been rewritten to "canonical vars". These are /// numbered starting from 0 in order of first appearance. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable, HashStable)] -pub struct Canonical<'gcx, V> { +pub struct Canonical<'tcx, V> { pub max_universe: ty::UniverseIndex, - pub variables: CanonicalVarInfos<'gcx>, + pub variables: CanonicalVarInfos<'tcx>, pub value: V, } -pub type CanonicalVarInfos<'gcx> = &'gcx List; +pub type CanonicalVarInfos<'tcx> = &'tcx List; -impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {} +impl<'tcx> UseSpecializedDecodable for CanonicalVarInfos<'tcx> {} /// A set of values corresponding to the canonical variables from some /// `Canonical`. You can give these values to @@ -194,10 +194,10 @@ pub struct QueryResponse<'tcx, R> { pub value: R, } -pub type Canonicalized<'gcx, V> = Canonical<'gcx, >::Lifted>; +pub type Canonicalized<'tcx, V> = Canonical<'tcx, >::Lifted>; -pub type CanonicalizedQueryResponse<'gcx, T> = - &'gcx Canonical<'gcx, QueryResponse<'gcx, >::Lifted>>; +pub type CanonicalizedQueryResponse<'tcx, T> = + &'tcx Canonical<'tcx, QueryResponse<'tcx, >::Lifted>>; /// Indicates whether or not we were able to prove the query to be /// true. @@ -254,7 +254,7 @@ impl<'tcx, R> Canonical<'tcx, QueryResponse<'tcx, R>> { } } -impl<'gcx, V> Canonical<'gcx, V> { +impl<'tcx, V> Canonical<'tcx, V> { /// Allows you to map the `value` of a canonical while keeping the /// same set of bound variables. /// @@ -278,7 +278,7 @@ impl<'gcx, V> Canonical<'gcx, V> { /// let ty: Ty<'tcx> = ...; /// let b: Canonical<'tcx, (T, Ty<'tcx>)> = a.unchecked_map(|v| (v, ty)); /// ``` - pub fn unchecked_map(self, map_op: impl FnOnce(V) -> W) -> Canonical<'gcx, W> { + pub fn unchecked_map(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, W> { let Canonical { max_universe, variables, @@ -294,7 +294,7 @@ impl<'gcx, V> Canonical<'gcx, V> { pub type QueryRegionConstraint<'tcx> = ty::Binder, Region<'tcx>>>; -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Creates a substitution S for the canonical value with fresh /// inference variables and applies it to the canonical value. /// Returns both the instantiated result *and* the substitution S. @@ -478,7 +478,7 @@ impl<'tcx> CanonicalVarValues<'tcx> { /// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]` /// we'll return a substitution `subst` with: /// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`. - pub fn make_identity(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Self { + pub fn make_identity(&self, tcx: TyCtxt<'tcx>) -> Self { use crate::ty::subst::UnpackedKind; CanonicalVarValues { diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index 345889ca44174..59b46b41c8dbd 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -29,7 +29,7 @@ use crate::ty::subst::{Kind, UnpackedKind}; use crate::ty::{self, BoundVar, InferConst, Lift, Ty, TyCtxt}; use crate::util::captures::Captures; -impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { +impl<'tcx> InferCtxtBuilder<'tcx> { /// The "main method" for a canonicalized trait query. Given the /// canonical key `canonical_key`, this method will create a new /// inference context, instantiate the key, and run your operation @@ -42,20 +42,20 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { /// /// (It might be mildly nicer to implement this on `TyCtxt`, and /// not `InferCtxtBuilder`, but that is a bit tricky right now. - /// In part because we would need a `for<'gcx: 'tcx>` sort of + /// In part because we would need a `for<'tcx>` sort of /// bound for the closure and in part because it is convenient to /// have `'tcx` be free on this function so that we can talk about /// `K: TypeFoldable<'tcx>`.) pub fn enter_canonical_trait_query( - &'tcx mut self, + &mut self, canonical_key: &Canonical<'tcx, K>, - operation: impl FnOnce(&InferCtxt<'_, 'gcx, 'tcx>, &mut dyn TraitEngine<'tcx>, K) + operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible, - ) -> Fallible> + ) -> Fallible> where K: TypeFoldable<'tcx>, - R: Debug + Lift<'gcx> + TypeFoldable<'tcx>, - Canonical<'gcx, as Lift<'gcx>>::Lifted>: ArenaAllocatable, + R: Debug + Lift<'tcx> + TypeFoldable<'tcx>, + Canonical<'tcx, as Lift<'tcx>>::Lifted>: ArenaAllocatable, { self.enter_with_canonical( DUMMY_SP, @@ -73,7 +73,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { } } -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// This method is meant to be invoked as the final step of a canonical query /// implementation. It is given: /// @@ -98,10 +98,10 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { inference_vars: CanonicalVarValues<'tcx>, answer: T, fulfill_cx: &mut dyn TraitEngine<'tcx>, - ) -> Fallible> + ) -> Fallible> where - T: Debug + Lift<'gcx> + TypeFoldable<'tcx>, - Canonical<'gcx, as Lift<'gcx>>::Lifted>: ArenaAllocatable, + T: Debug + Lift<'tcx> + TypeFoldable<'tcx>, + Canonical<'tcx, as Lift<'tcx>>::Lifted>: ArenaAllocatable, { let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?; let canonical_result = self.canonicalize_response(&query_response); @@ -127,9 +127,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { &self, inference_vars: CanonicalVarValues<'tcx>, answer: T - ) -> Canonical<'gcx, QueryResponse<'gcx, >::Lifted>> + ) -> Canonical<'tcx, QueryResponse<'tcx, >::Lifted>> where - T: Debug + Lift<'gcx> + TypeFoldable<'tcx>, + T: Debug + Lift<'tcx> + TypeFoldable<'tcx>, { self.canonicalize_response(&QueryResponse { var_values: inference_vars, @@ -148,7 +148,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { fulfill_cx: &mut dyn TraitEngine<'tcx>, ) -> Result, NoSolution> where - T: Debug + TypeFoldable<'tcx> + Lift<'gcx>, + T: Debug + TypeFoldable<'tcx> + Lift<'tcx>, { let tcx = self.tcx; @@ -567,7 +567,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { param_env: ty::ParamEnv<'tcx>, unsubstituted_region_constraints: &'a [QueryRegionConstraint<'tcx>], result_subst: &'a CanonicalVarValues<'tcx>, - ) -> impl Iterator> + 'a + Captures<'gcx> { + ) -> impl Iterator> + 'a + Captures<'tcx> { unsubstituted_region_constraints .iter() .map(move |constraint| { @@ -647,7 +647,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { /// Given the region obligations and constraints scraped from the infcx, /// creates query region constraints. pub fn make_query_outlives<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, outlives_obligations: impl Iterator, ty::Region<'tcx>)>, region_constraints: &RegionConstraintData<'tcx>, ) -> Vec> { diff --git a/src/librustc/infer/canonical/substitute.rs b/src/librustc/infer/canonical/substitute.rs index d1310771fb353..1234b96ab110c 100644 --- a/src/librustc/infer/canonical/substitute.rs +++ b/src/librustc/infer/canonical/substitute.rs @@ -14,7 +14,7 @@ use crate::ty::{self, TyCtxt}; impl<'tcx, V> Canonical<'tcx, V> { /// Instantiate the wrapped value, replacing each canonical value /// with the value given in `var_values`. - pub fn substitute(&self, tcx: TyCtxt<'_, 'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V + pub fn substitute(&self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V where V: TypeFoldable<'tcx>, { @@ -29,7 +29,7 @@ impl<'tcx, V> Canonical<'tcx, V> { /// V, replacing each of the canonical variables. pub fn substitute_projected( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>, projection_fn: impl FnOnce(&V) -> &T, ) -> T @@ -46,7 +46,7 @@ impl<'tcx, V> Canonical<'tcx, V> { /// must be values for the set of canonical variables that appear in /// `value`. pub(super) fn substitute_value<'a, 'tcx, T>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>, value: &'a T, ) -> T diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index d886efd33915f..23550569f7ccf 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -44,8 +44,8 @@ use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; #[derive(Clone)] -pub struct CombineFields<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { - pub infcx: &'infcx InferCtxt<'infcx, 'gcx, 'tcx>, +pub struct CombineFields<'infcx, 'tcx: 'infcx> { + pub infcx: &'infcx InferCtxt<'infcx, 'tcx>, pub trace: TypeTrace<'tcx>, pub cause: Option, pub param_env: ty::ParamEnv<'tcx>, @@ -57,7 +57,7 @@ pub enum RelationDir { SubtypeOf, SupertypeOf, EqTo } -impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { +impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> { pub fn super_combine_tys( &self, relation: &mut R, @@ -65,7 +65,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { b: Ty<'tcx>, ) -> RelateResult<'tcx, Ty<'tcx>> where - R: TypeRelation<'gcx, 'tcx>, + R: TypeRelation<'tcx>, { let a_is_expected = relation.a_is_expected(); @@ -125,7 +125,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { b: &'tcx ty::Const<'tcx>, ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> where - R: TypeRelation<'gcx, 'tcx>, + R: TypeRelation<'tcx>, { let a_is_expected = relation.a_is_expected(); @@ -208,24 +208,24 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { } } -impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { - pub fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { +impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { + pub fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } - pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'gcx, 'tcx> { + pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'tcx> { Equate::new(self, a_is_expected) } - pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'gcx, 'tcx> { + pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'tcx> { Sub::new(self, a_is_expected) } - pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'gcx, 'tcx> { + pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'tcx> { Lub::new(self, a_is_expected) } - pub fn glb<'a>(&'a mut self, a_is_expected: bool) -> Glb<'a, 'infcx, 'gcx, 'tcx> { + pub fn glb<'a>(&'a mut self, a_is_expected: bool) -> Glb<'a, 'infcx, 'tcx> { Glb::new(self, a_is_expected) } @@ -355,8 +355,8 @@ impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { } } -struct Generalizer<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +struct Generalizer<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, /// The span, used when creating new type variables and things. span: Span, @@ -415,8 +415,8 @@ struct Generalization<'tcx> { needs_wf: bool, } -impl TypeRelation<'gcx, 'tcx> for Generalizer<'_, 'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { +impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index a9e0e3376a54d..f9fdc66cf3dae 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -11,23 +11,23 @@ use crate::mir::interpret::ConstValue; use crate::infer::unify_key::replace_if_possible; /// Ensures `a` is made equal to `b`. Returns `a` on success. -pub struct Equate<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { - fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, +pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> { + fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } -impl<'combine, 'infcx, 'gcx, 'tcx> Equate<'combine, 'infcx, 'gcx, 'tcx> { - pub fn new(fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) - -> Equate<'combine, 'infcx, 'gcx, 'tcx> +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> { Equate { fields: fields, a_is_expected: a_is_expected } } } -impl TypeRelation<'gcx, 'tcx> for Equate<'combine, 'infcx, 'gcx, 'tcx> { +impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> { fn tag(&self) -> &'static str { "Equate" } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.a_is_expected } diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index d50cb8e61a60b..04d29a8db1c35 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -67,7 +67,7 @@ mod need_type_info; pub mod nice_region_error; -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn note_and_explain_region( self, region_scope_tree: ®ion::ScopeTree, @@ -282,7 +282,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn report_region_errors( &self, region_scope_tree: ®ion::ScopeTree, @@ -445,13 +445,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { use ty::print::Printer; use ty::subst::Kind; - struct AbsolutePathPrinter<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, + struct AbsolutePathPrinter<'tcx> { + tcx: TyCtxt<'tcx>, } struct NonTrivialPath; - impl<'gcx, 'tcx> Printer<'gcx, 'tcx> for AbsolutePathPrinter<'gcx, 'tcx> { + impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { type Error = NonTrivialPath; type Path = Vec; @@ -460,7 +460,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { type DynExistential = !; type Const = !; - fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx> { + fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { self.tcx } @@ -1546,7 +1546,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { fn report_inference_failure( &self, var_origin: RegionVariableOrigin, diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 16b6792fde48f..830d6adc1b872 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -9,16 +9,16 @@ use syntax::source_map::CompilerDesugaringKind; use syntax_pos::Span; use errors::DiagnosticBuilder; -struct FindLocalByTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +struct FindLocalByTypeVisitor<'a, 'tcx> { + infcx: &'a InferCtxt<'a, 'tcx>, target_ty: Ty<'tcx>, - hir_map: &'a hir::map::Map<'gcx>, - found_local_pattern: Option<&'gcx Pat>, - found_arg_pattern: Option<&'gcx Pat>, + hir_map: &'a hir::map::Map<'tcx>, + found_local_pattern: Option<&'tcx Pat>, + found_arg_pattern: Option<&'tcx Pat>, found_ty: Option>, } -impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> { fn node_matches_type(&mut self, hir_id: HirId) -> Option> { let ty_opt = self.infcx.in_progress_tables.and_then(|tables| { tables.borrow().node_type_opt(hir_id) @@ -47,12 +47,12 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { +impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::OnlyBodies(&self.hir_map) } - fn visit_local(&mut self, local: &'gcx Local) { + fn visit_local(&mut self, local: &'tcx Local) { if let (None, Some(ty)) = (self.found_local_pattern, self.node_matches_type(local.hir_id)) { self.found_local_pattern = Some(&*local.pat); self.found_ty = Some(ty); @@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { intravisit::walk_local(self, local); } - fn visit_body(&mut self, body: &'gcx Body) { + fn visit_body(&mut self, body: &'tcx Body) { for argument in &body.arguments { if let (None, Some(ty)) = ( self.found_arg_pattern, @@ -75,7 +75,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn extract_type_name( &self, ty: Ty<'tcx>, @@ -103,7 +103,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { body_id: Option, span: Span, ty: Ty<'tcx> - ) -> DiagnosticBuilder<'gcx> { + ) -> DiagnosticBuilder<'tcx> { let ty = self.resolve_vars_if_possible(&ty); let name = self.extract_type_name(&ty, None); @@ -230,7 +230,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { &self, span: Span, ty: Ty<'tcx> - ) -> DiagnosticBuilder<'gcx> { + ) -> DiagnosticBuilder<'tcx> { let ty = self.resolve_vars_if_possible(&ty); let name = self.extract_type_name(&ty, None); diff --git a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs index ecdcb4bbf114a..6bd2c04d51281 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -5,7 +5,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::error_reporting::nice_region_error::util::AnonymousArgInfo; use crate::util::common::ErrorReported; -impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when both the concerned regions are anonymous. /// /// Consider a case where we have diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index 8dd415ec9af4c..fa95ea1013253 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -5,7 +5,7 @@ use crate::middle::resolve_lifetime as rl; use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; use crate::infer::error_reporting::nice_region_error::NiceRegionError; -impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// This function calls the `visit_ty` method for the parameters /// corresponding to the anonymous regions. The `nested_visitor.found_type` /// contains the anonymous type. @@ -60,9 +60,9 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { // to the anonymous region. fn find_component_for_bound_region( &self, - arg: &'gcx hir::Ty, + arg: &'tcx hir::Ty, br: &ty::BoundRegion, - ) -> Option<(&'gcx hir::Ty)> { + ) -> Option<(&'tcx hir::Ty)> { let mut nested_visitor = FindNestedTypeVisitor { tcx: self.tcx(), bound_region: *br, @@ -81,23 +81,23 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { // walk the types like &mut Vec<&u8> and &u8 looking for the HIR // where that lifetime appears. This allows us to highlight the // specific part of the type in the error message. -struct FindNestedTypeVisitor<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct FindNestedTypeVisitor<'tcx> { + tcx: TyCtxt<'tcx>, // The bound_region corresponding to the Refree(freeregion) // associated with the anonymous region we are looking for. bound_region: ty::BoundRegion, // The type where the anonymous lifetime appears // for e.g., Vec<`&u8`> and <`&u8`> - found_type: Option<&'gcx hir::Ty>, + found_type: Option<&'tcx hir::Ty>, current_index: ty::DebruijnIndex, } -impl Visitor<'gcx> for FindNestedTypeVisitor<'gcx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { +impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } - fn visit_ty(&mut self, arg: &'gcx hir::Ty) { + fn visit_ty(&mut self, arg: &'tcx hir::Ty) { match arg.node { hir::TyKind::BareFn(_) => { self.current_index.shift_in(1); @@ -208,15 +208,15 @@ impl Visitor<'gcx> for FindNestedTypeVisitor<'gcx, 'tcx> { // and would walk the types like Vec in the above example and Ref looking for the HIR // where that lifetime appears. This allows us to highlight the // specific part of the type in the error message. -struct TyPathVisitor<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct TyPathVisitor<'tcx> { + tcx: TyCtxt<'tcx>, found_it: bool, bound_region: ty::BoundRegion, current_index: ty::DebruijnIndex, } -impl Visitor<'gcx> for TyPathVisitor<'gcx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { +impl Visitor<'tcx> for TyPathVisitor<'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } @@ -267,7 +267,7 @@ impl Visitor<'gcx> for TyPathVisitor<'gcx, 'tcx> { } } - fn visit_ty(&mut self, arg: &'gcx hir::Ty) { + fn visit_ty(&mut self, arg: &'tcx hir::Ty) { // ignore nested types // // If you have a type like `Foo<'a, &Ty>` we diff --git a/src/librustc/infer/error_reporting/nice_region_error/mod.rs b/src/librustc/infer/error_reporting/nice_region_error/mod.rs index dc9ec15cb2492..541d9a96dbe60 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/mod.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/mod.rs @@ -14,7 +14,7 @@ mod outlives_closure; mod static_impl_trait; mod util; -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { pub fn try_report_nice_region_error(&self, error: &RegionResolutionError<'tcx>) -> bool { match *error { ConcreteFailure(..) | SubSupConflict(..) => {} @@ -30,16 +30,16 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { } } -pub struct NiceRegionError<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +pub struct NiceRegionError<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, error: Option>, regions: Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)>, tables: Option<&'cx ty::TypeckTables<'tcx>>, } -impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> { pub fn new( - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + infcx: &'cx InferCtxt<'cx, 'tcx>, error: RegionResolutionError<'tcx>, tables: Option<&'cx ty::TypeckTables<'tcx>>, ) -> Self { @@ -47,7 +47,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> { } pub fn new_from_span( - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + infcx: &'cx InferCtxt<'cx, 'tcx>, span: Span, sub: ty::Region<'tcx>, sup: ty::Region<'tcx>, @@ -56,7 +56,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> { Self { infcx, error: None, regions: Some((span, sub, sup)), tables } } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 0efc124e31fee..51bee49b70fc0 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -5,7 +5,7 @@ use crate::hir::{FunctionRetTy, TyKind}; use crate::ty; use errors::{Applicability, DiagnosticBuilder}; -impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and /// an anonymous region, emit an descriptive diagnostic error. pub(super) fn try_report_named_anon_conflict(&self) -> Option> { diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs index af201886a00d5..0d98a024977d9 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -9,7 +9,7 @@ use crate::hir::Node; use crate::util::common::ErrorReported; use crate::infer::lexical_region_resolve::RegionResolutionError::SubSupConflict; -impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when binding escapes a closure. /// /// Consider a case where we have diff --git a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs index 8631236c0e36e..b4fb018920647 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -13,7 +13,7 @@ use crate::ty::print::{Print, RegionHighlightMode, FmtPrinter}; use std::fmt::{self, Write}; -impl NiceRegionError<'me, 'gcx, 'tcx> { +impl NiceRegionError<'me, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and /// an anonymous region, emit a descriptive diagnostic error. pub(super) fn try_report_placeholder_conflict(&self) -> Option> { @@ -321,14 +321,14 @@ impl NiceRegionError<'me, 'gcx, 'tcx> { ) { // HACK(eddyb) maybe move this in a more central location. #[derive(Copy, Clone)] - struct Highlighted<'gcx, 'tcx, T> { - tcx: TyCtxt<'gcx, 'tcx>, + struct Highlighted<'tcx, T> { + tcx: TyCtxt<'tcx>, highlight: RegionHighlightMode, value: T, } - impl<'gcx, 'tcx, T> Highlighted<'gcx, 'tcx, T> { - fn map(self, f: impl FnOnce(T) -> U) -> Highlighted<'gcx, 'tcx, U> { + impl<'tcx, T> Highlighted<'tcx, T> { + fn map(self, f: impl FnOnce(T) -> U) -> Highlighted<'tcx, U> { Highlighted { tcx: self.tcx, highlight: self.highlight, @@ -337,12 +337,11 @@ impl NiceRegionError<'me, 'gcx, 'tcx> { } } - impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T> + impl<'tcx, T> fmt::Display for Highlighted<'tcx, T> where T: for<'a, 'b, 'c> Print< - 'gcx, 'tcx, - FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>, + FmtPrinter<'a, 'tcx, &'b mut fmt::Formatter<'c>>, Error = fmt::Error, >, { diff --git a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs index 23acaeb31f8d4..9d405d4ea40c9 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -6,7 +6,7 @@ use crate::ty::{BoundRegion, FreeRegion, RegionKind}; use crate::util::common::ErrorReported; use errors::Applicability; -impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when the return type is a static impl Trait. pub(super) fn try_report_static_impl_trait(&self) -> Option { if let Some(ref error) = self.error { diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index feade7a8f56f2..017f36b020988 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -24,7 +24,7 @@ pub(super) struct AnonymousArgInfo<'tcx> { pub is_first: bool, } -impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { // This method walks the Type of the function body arguments using // `fold_regions()` function and returns the // &hir::Arg of the function argument corresponding to the anonymous diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index 9eb46aa3779d9..cc7c13cea7d92 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -4,7 +4,7 @@ use crate::ty::{self, Region}; use crate::ty::error::TypeError; use errors::DiagnosticBuilder; -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub(super) fn note_region_origin(&self, err: &mut DiagnosticBuilder<'_>, origin: &SubregionOrigin<'tcx>) { diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 641e5b127e8d0..20331232dc741 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -41,17 +41,17 @@ use std::collections::hash_map::Entry; use super::InferCtxt; use super::unify_key::ToType; -pub struct TypeFreshener<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct TypeFreshener<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, ty_freshen_count: u32, const_freshen_count: u32, ty_freshen_map: FxHashMap>, const_freshen_map: FxHashMap, &'tcx ty::Const<'tcx>>, } -impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) - -> TypeFreshener<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> TypeFreshener<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) + -> TypeFreshener<'a, 'tcx> { TypeFreshener { infcx, ty_freshen_count: 0, @@ -113,8 +113,8 @@ impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index ef6ea20c6dfba..59364862c649b 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -22,7 +22,7 @@ fn const_vars_since_snapshot<'tcx>( }).collect()) } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// This rather funky routine is used while processing expected /// types. What happens here is that we want to propagate a /// coercion through the return type of a fn to its @@ -133,8 +133,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } -pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct InferenceFudger<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, type_vars: (Range, Vec), int_vars: Range, float_vars: Range, @@ -142,8 +142,8 @@ pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { const_vars: (Range>, Vec), } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 0b3c0904d1777..8e4796dc83d5a 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -8,23 +8,23 @@ use crate::ty::{self, Ty, TyCtxt}; use crate::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Greatest lower bound" (common subtype) -pub struct Glb<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { - fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, +pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> { + fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } -impl<'combine, 'infcx, 'gcx, 'tcx> Glb<'combine, 'infcx, 'gcx, 'tcx> { - pub fn new(fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) - -> Glb<'combine, 'infcx, 'gcx, 'tcx> +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> { Glb { fields: fields, a_is_expected: a_is_expected } } } -impl TypeRelation<'gcx, 'tcx> for Glb<'combine, 'infcx, 'gcx, 'tcx> { +impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> { fn tag(&self) -> &'static str { "Glb" } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.a_is_expected } @@ -85,10 +85,10 @@ impl TypeRelation<'gcx, 'tcx> for Glb<'combine, 'infcx, 'gcx, 'tcx> { } } -impl<'combine, 'infcx, 'gcx, 'tcx> LatticeDir<'infcx, 'gcx, 'tcx> - for Glb<'combine, 'infcx, 'gcx, 'tcx> +impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> + for Glb<'combine, 'infcx, 'tcx> { - fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'gcx, 'tcx> { + fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> { self.fields.infcx } diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index fcec820cbb92a..542ac4931ecfa 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -9,7 +9,7 @@ use crate::ty::relate::{Relate, RelateResult, TypeRelation}; use crate::ty::{self, Binder, TypeFoldable}; use crate::mir::interpret::ConstValue; -impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> CombineFields<'a, 'tcx> { pub fn higher_ranked_sub( &mut self, a: &Binder, @@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// Replaces all regions (resp. types) bound by `binder` with placeholder /// regions (resp. types) and return a map indicating which bound-region /// placeholder region. This is the first step of checking subtyping diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index 236ebc19340bb..18a30e259ebfc 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -27,8 +27,8 @@ use crate::ty::TyVar; use crate::ty::{self, Ty}; use crate::ty::relate::{RelateResult, TypeRelation}; -pub trait LatticeDir<'f, 'gcx: 'f + 'tcx, 'tcx: 'f>: TypeRelation<'gcx, 'tcx> { - fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>; +pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> { + fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; fn cause(&self) -> &ObligationCause<'tcx>; @@ -41,11 +41,11 @@ pub trait LatticeDir<'f, 'gcx: 'f + 'tcx, 'tcx: 'f>: TypeRelation<'gcx, 'tcx> { fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; } -pub fn super_lattice_tys<'a, 'gcx, 'tcx, L>(this: &mut L, +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, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a + 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 1878afd581dd4..758a01bc52be5 100644 --- a/src/librustc/infer/lexical_region_resolve/graphviz.rs +++ b/src/librustc/infer/lexical_region_resolve/graphviz.rs @@ -44,9 +44,9 @@ graphs will be printed. \n\ "); } -pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>( +pub fn maybe_print_constraints_for<'a, 'tcx>( region_data: &RegionConstraintData<'tcx>, - region_rels: &RegionRelations<'a, 'gcx, 'tcx>) + region_rels: &RegionRelations<'a, 'tcx>) { let tcx = region_rels.tcx; let context = region_rels.context; @@ -107,9 +107,9 @@ pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>( } } -struct ConstraintGraph<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { +struct ConstraintGraph<'a, 'tcx: 'a> { graph_name: String, - region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>, + region_rels: &'a RegionRelations<'a, 'tcx>, map: &'a BTreeMap, SubregionOrigin<'tcx>>, node_ids: FxHashMap, } @@ -126,11 +126,11 @@ enum Edge<'tcx> { EnclScope(region::Scope, region::Scope), } -impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> { fn new(name: String, - region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>, + region_rels: &'a RegionRelations<'a, 'tcx>, map: &'a ConstraintMap<'tcx>) - -> ConstraintGraph<'a, 'gcx, 'tcx> { + -> ConstraintGraph<'a, 'tcx> { let mut i = 0; let mut node_ids = FxHashMap::default(); { @@ -161,7 +161,7 @@ impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'tcx> { type Node = Node; type Edge = Edge<'tcx>; fn graph_id(&self) -> dot::Id<'_> { @@ -215,7 +215,7 @@ fn edge_to_nodes(e: &Edge<'_>) -> (Node, Node) { } } -impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'tcx> { type Node = Node; type Edge = Edge<'tcx>; fn nodes(&self) -> dot::Nodes<'_, Node> { @@ -246,7 +246,7 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { pub type ConstraintMap<'tcx> = BTreeMap, SubregionOrigin<'tcx>>; -fn dump_region_data_to<'a, 'gcx, 'tcx>(region_rels: &RegionRelations<'a, 'gcx, 'tcx>, +fn dump_region_data_to<'a, 'tcx>(region_rels: &RegionRelations<'a, 'tcx>, map: &ConstraintMap<'tcx>, path: &str) -> io::Result<()> { diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 1612a2a54d10c..944969e2214d2 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -30,7 +30,7 @@ mod graphviz; /// assuming such values can be found. It returns the final values of /// all the variables as well as a set of errors that must be reported. pub fn resolve<'tcx>( - region_rels: &RegionRelations<'_, '_, 'tcx>, + region_rels: &RegionRelations<'_, 'tcx>, var_infos: VarInfos, data: RegionConstraintData<'tcx>, ) -> ( @@ -96,14 +96,14 @@ struct RegionAndOrigin<'tcx> { type RegionGraph<'tcx> = Graph<(), Constraint<'tcx>>; -struct LexicalResolver<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - region_rels: &'cx RegionRelations<'cx, 'gcx, 'tcx>, +struct LexicalResolver<'cx, 'tcx: 'cx> { + region_rels: &'cx RegionRelations<'cx, 'tcx>, var_infos: VarInfos, data: RegionConstraintData<'tcx>, } -impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { +impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.region_rels.tcx } @@ -136,14 +136,14 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { /// Initially, the value for all variables is set to `'empty`, the /// empty region. The `expansion` phase will grow this larger. - fn construct_var_data(&self, tcx: TyCtxt<'_, 'tcx>) -> LexicalRegionResolutions<'tcx> { + fn construct_var_data(&self, tcx: TyCtxt<'tcx>) -> LexicalRegionResolutions<'tcx> { LexicalRegionResolutions { error_region: tcx.lifetimes.re_static, values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars()) } } - fn dump_constraints(&self, free_regions: &RegionRelations<'_, '_, 'tcx>) { + fn dump_constraints(&self, free_regions: &RegionRelations<'_, 'tcx>) { debug!( "----() Start constraint listing (context={:?}) ()----", free_regions.context @@ -785,7 +785,7 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> { } impl<'tcx> LexicalRegionResolutions<'tcx> { - fn normalize(&self, tcx: TyCtxt<'_, 'tcx>, value: T) -> T + fn normalize(&self, tcx: TyCtxt<'tcx>, value: T) -> T where T: TypeFoldable<'tcx>, { diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index ab49968ce24db..6e1ca9e7ed041 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -8,23 +8,23 @@ use crate::ty::{self, Ty, TyCtxt}; use crate::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Least upper bound" (common supertype) -pub struct Lub<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { - fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, +pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> { + fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } -impl<'combine, 'infcx, 'gcx, 'tcx> Lub<'combine, 'infcx, 'gcx, 'tcx> { - pub fn new(fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) - -> Lub<'combine, 'infcx, 'gcx, 'tcx> +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> { Lub { fields: fields, a_is_expected: a_is_expected } } } -impl TypeRelation<'gcx, 'tcx> for Lub<'combine, 'infcx, 'gcx, 'tcx> { +impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> { fn tag(&self) -> &'static str { "Lub" } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() } + fn tcx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } fn a_is_expected(&self) -> bool { self.a_is_expected } @@ -85,10 +85,10 @@ impl TypeRelation<'gcx, 'tcx> for Lub<'combine, 'infcx, 'gcx, 'tcx> { } } -impl<'combine, 'infcx, 'gcx, 'tcx> LatticeDir<'infcx, 'gcx, 'tcx> - for Lub<'combine, 'infcx, 'gcx, 'tcx> +impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> + for Lub<'combine, 'infcx, 'tcx> { - fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'gcx, 'tcx> { + fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> { self.fields.infcx } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 538b76be7b045..47a276b2bcc57 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -91,7 +91,7 @@ impl SuppressRegionErrors { /// Indicates that the MIR borrowck will repeat these region /// checks, so we should ignore errors if NLL is (unconditionally) /// enabled. - pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_>) -> Self { + pub fn when_nll_is_enabled(tcx: TyCtxt<'_>) -> Self { match tcx.borrowck_mode() { // If we're on Migrate mode, report AST region errors BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, @@ -102,8 +102,8 @@ impl SuppressRegionErrors { } } -pub struct InferCtxt<'a, 'gcx, 'tcx> { - pub tcx: TyCtxt<'gcx, 'tcx>, +pub struct InferCtxt<'a, 'tcx> { + pub tcx: TyCtxt<'tcx>, /// During type-checking/inference of a body, `in_progress_tables` /// contains a reference to the tables being built up, which are @@ -464,14 +464,14 @@ impl<'tcx> fmt::Display for FixupError<'tcx> { /// Helper type of a temporary returned by `tcx.infer_ctxt()`. /// Necessary because we can't write the following bound: -/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`. -pub struct InferCtxtBuilder<'gcx: 'tcx, 'tcx> { - global_tcx: TyCtxt<'gcx, 'gcx>, +/// `F: for<'b, 'tcx> where 'tcx FnOnce(InferCtxt<'b, 'tcx>)`. +pub struct InferCtxtBuilder<'tcx> { + global_tcx: TyCtxt<'tcx>, fresh_tables: Option>>, } -impl TyCtxt<'gcx, 'gcx> { - pub fn infer_ctxt<'tcx>(self) -> InferCtxtBuilder<'gcx, 'tcx> { +impl TyCtxt<'tcx> { + pub fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> { InferCtxtBuilder { global_tcx: self, fresh_tables: None, @@ -479,7 +479,7 @@ impl TyCtxt<'gcx, 'gcx> { } } -impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { +impl<'tcx> InferCtxtBuilder<'tcx> { /// Used only by `rustc_typeck` during body type-checking/inference, /// will initialize `in_progress_tables` with fresh `TypeckTables`. pub fn with_fresh_in_progress_tables(mut self, table_owner: DefId) -> Self { @@ -495,10 +495,10 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { /// the bound values in `C` to their instantiated values in `V` /// (in other words, `S(C) = V`). pub fn enter_with_canonical( - &'tcx mut self, + &mut self, span: Span, canonical: &Canonical<'tcx, T>, - f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>, T, CanonicalVarValues<'tcx>) -> R, + f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>, T, CanonicalVarValues<'tcx>) -> R, ) -> R where T: TypeFoldable<'tcx>, @@ -510,7 +510,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { }) } - pub fn enter(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R { + pub fn enter(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R { let InferCtxtBuilder { global_tcx, ref fresh_tables, @@ -567,7 +567,7 @@ impl<'tcx, T> InferOk<'tcx, T> { /// Extracts `value`, registering any obligations into `fulfill_cx`. pub fn into_value_registering_obligations( self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx>, ) -> T { let InferOk { value, obligations } = self; @@ -598,7 +598,7 @@ pub struct CombinedSnapshot<'a, 'tcx: 'a> { _in_progress_tables: Option>>, } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn is_in_snapshot(&self) -> bool { self.in_snapshot.get() } @@ -614,7 +614,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } - pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'gcx, 'tcx> { + pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx> { freshen::TypeFreshener::new(self) } @@ -677,7 +677,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { &'a self, trace: TypeTrace<'tcx>, param_env: ty::ParamEnv<'tcx>, - ) -> CombineFields<'a, 'gcx, 'tcx> { + ) -> CombineFields<'a, 'tcx> { CombineFields { infcx: self, trace, @@ -1548,13 +1548,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } -pub struct ShallowResolver<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct ShallowResolver<'a, 'tcx> { + infcx: &'a InferCtxt<'a, 'tcx>, } -impl<'a, 'gcx, 'tcx> ShallowResolver<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> ShallowResolver<'a, 'tcx> { #[inline(always)] - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self { ShallowResolver { infcx } } @@ -1599,8 +1599,8 @@ impl<'a, 'gcx, 'tcx> ShallowResolver<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -1624,7 +1624,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx> } } -impl<'gcx, 'tcx> TypeTrace<'tcx> { +impl<'tcx> TypeTrace<'tcx> { pub fn span(&self) -> Span { self.cause.span } @@ -1641,7 +1641,7 @@ impl<'gcx, 'tcx> TypeTrace<'tcx> { } } - pub fn dummy(tcx: TyCtxt<'gcx, 'tcx>) -> TypeTrace<'tcx> { + pub fn dummy(tcx: TyCtxt<'tcx>) -> TypeTrace<'tcx> { TypeTrace { cause: ObligationCause::dummy(), values: Types(ExpectedFound { diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index f6ba13d2aa8f8..2c821d0ae15c1 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -38,11 +38,11 @@ pub enum NormalizationStrategy { Eager, } -pub struct TypeRelating<'me, 'gcx: 'tcx, 'tcx: 'me, D> +pub struct TypeRelating<'me, 'tcx: 'me, D> where D: TypeRelatingDelegate<'tcx>, { - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + infcx: &'me InferCtxt<'me, 'tcx>, /// Callback to use when we deduce an outlives relationship delegate: D, @@ -135,12 +135,12 @@ struct BoundRegionScope<'tcx> { #[derive(Copy, Clone)] struct UniversallyQuantified(bool); -impl<'me, 'gcx, 'tcx, D> TypeRelating<'me, 'gcx, 'tcx, D> +impl<'me, 'tcx, D> TypeRelating<'me, 'tcx, D> where D: TypeRelatingDelegate<'tcx>, { pub fn new( - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + infcx: &'me InferCtxt<'me, 'tcx>, delegate: D, ambient_variance: ty::Variance, ) -> Self { @@ -416,7 +416,7 @@ trait VidValuePair<'tcx>: Debug { /// for more details on why we want them. fn vid_scopes>( &self, - relate: &'r mut TypeRelating<'_, '_, 'tcx, D>, + relate: &'r mut TypeRelating<'_, 'tcx, D>, ) -> &'r mut Vec>; /// Given a generalized type G that should replace the vid, relate @@ -424,7 +424,7 @@ trait VidValuePair<'tcx>: Debug { /// appeared. fn relate_generalized_ty( &self, - relate: &mut TypeRelating<'_, '_, 'tcx, D>, + relate: &mut TypeRelating<'_, 'tcx, D>, generalized_ty: Ty<'tcx>, ) -> RelateResult<'tcx, Ty<'tcx>> where @@ -442,7 +442,7 @@ impl VidValuePair<'tcx> for (ty::TyVid, Ty<'tcx>) { fn vid_scopes( &self, - relate: &'r mut TypeRelating<'_, '_, 'tcx, D>, + relate: &'r mut TypeRelating<'_, 'tcx, D>, ) -> &'r mut Vec> where D: TypeRelatingDelegate<'tcx>, @@ -452,7 +452,7 @@ impl VidValuePair<'tcx> for (ty::TyVid, Ty<'tcx>) { fn relate_generalized_ty( &self, - relate: &mut TypeRelating<'_, '_, 'tcx, D>, + relate: &mut TypeRelating<'_, 'tcx, D>, generalized_ty: Ty<'tcx>, ) -> RelateResult<'tcx, Ty<'tcx>> where @@ -474,7 +474,7 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) { fn vid_scopes( &self, - relate: &'r mut TypeRelating<'_, '_, 'tcx, D>, + relate: &'r mut TypeRelating<'_, 'tcx, D>, ) -> &'r mut Vec> where D: TypeRelatingDelegate<'tcx>, @@ -484,7 +484,7 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) { fn relate_generalized_ty( &self, - relate: &mut TypeRelating<'_, '_, 'tcx, D>, + relate: &mut TypeRelating<'_, 'tcx, D>, generalized_ty: Ty<'tcx>, ) -> RelateResult<'tcx, Ty<'tcx>> where @@ -494,11 +494,11 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) { } } -impl TypeRelation<'gcx, 'tcx> for TypeRelating<'me, 'gcx, 'tcx, D> +impl TypeRelation<'tcx> for TypeRelating<'me, 'tcx, D> where D: TypeRelatingDelegate<'tcx>, { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -798,11 +798,11 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> { /// scopes. /// /// [blog post]: https://is.gd/0hKvIr -struct TypeGeneralizer<'me, 'gcx: 'tcx, 'tcx: 'me, D> +struct TypeGeneralizer<'me, 'tcx: 'me, D> where D: TypeRelatingDelegate<'tcx> + 'me, { - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + infcx: &'me InferCtxt<'me, 'tcx>, delegate: &'me mut D, @@ -823,11 +823,11 @@ where universe: ty::UniverseIndex, } -impl TypeRelation<'gcx, 'tcx> for TypeGeneralizer<'me, 'gcx, 'tcx, D> +impl TypeRelation<'tcx> for TypeGeneralizer<'me, 'tcx, D> where D: TypeRelatingDelegate<'tcx>, { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 355d527e8efb8..8e9af8b39385f 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -73,7 +73,7 @@ pub struct OpaqueTypeDecl<'tcx> { pub origin: hir::ExistTyOrigin, } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// Replaces all opaque types in `value` with fresh inference variables /// and creates appropriate obligations. For example, given the input: /// @@ -430,8 +430,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { &self, def_id: DefId, opaque_defn: &OpaqueTypeDecl<'tcx>, - instantiated_ty: Ty<'gcx>, - ) -> Ty<'gcx> { + instantiated_ty: Ty<'tcx>, + ) -> Ty<'tcx> { debug!( "infer_opaque_definition_from_instantiation(def_id={:?}, instantiated_ty={:?})", def_id, instantiated_ty @@ -446,7 +446,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // `impl Trait` return type, resulting in the parameters // shifting. let id_substs = InternalSubsts::identity_for_item(gcx, def_id); - let map: FxHashMap, Kind<'gcx>> = opaque_defn + let map: FxHashMap, Kind<'tcx>> = opaque_defn .substs .iter() .enumerate() @@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ); // We can unwrap here because our reverse mapper always - // produces things with 'gcx lifetime, though the type folder + // produces things with 'tcx lifetime, though the type folder // obscures that. let definition_ty = gcx.lift(&definition_ty).unwrap(); @@ -491,14 +491,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // // We ignore any type parameters because impl trait values are assumed to // capture all the in-scope type parameters. -struct OpaqueTypeOutlivesVisitor<'a, 'gcx, 'tcx> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +struct OpaqueTypeOutlivesVisitor<'a, 'tcx> { + infcx: &'a InferCtxt<'a, 'tcx>, least_region: ty::Region<'tcx>, span: Span, } -impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx> -{ +impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, 'tcx> { fn visit_binder>(&mut self, t: &ty::Binder) -> bool { t.skip_binder().visit_with(self); false // keep visiting @@ -552,27 +551,27 @@ impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx> } } -struct ReverseMapper<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct ReverseMapper<'tcx> { + tcx: TyCtxt<'tcx>, /// If errors have already been reported in this fn, we suppress /// our own errors because they are sometimes derivative. tainted_by_errors: bool, opaque_type_def_id: DefId, - map: FxHashMap, Kind<'gcx>>, + map: FxHashMap, Kind<'tcx>>, map_missing_regions_to_empty: bool, /// initially `Some`, set to `None` once error has been reported hidden_ty: Option>, } -impl ReverseMapper<'gcx, 'tcx> { +impl ReverseMapper<'tcx> { fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, tainted_by_errors: bool, opaque_type_def_id: DefId, - map: FxHashMap, Kind<'gcx>>, + map: FxHashMap, Kind<'tcx>>, hidden_ty: Ty<'tcx>, ) -> Self { Self { @@ -599,8 +598,8 @@ impl ReverseMapper<'gcx, 'tcx> { } } -impl TypeFolder<'gcx, 'tcx> for ReverseMapper<'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { +impl TypeFolder<'tcx> for ReverseMapper<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -724,8 +723,8 @@ impl TypeFolder<'gcx, 'tcx> for ReverseMapper<'gcx, 'tcx> { } } -struct Instantiator<'a, 'gcx: 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +struct Instantiator<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, parent_def_id: DefId, body_id: hir::HirId, param_env: ty::ParamEnv<'tcx>, @@ -733,7 +732,7 @@ struct Instantiator<'a, 'gcx: 'tcx, 'tcx: 'a> { obligations: Vec>, } -impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Instantiator<'a, 'tcx> { fn instantiate_opaque_types_in_map>(&mut self, value: &T) -> T { debug!("instantiate_opaque_types_in_map(value={:?})", value); let tcx = self.infcx.tcx; @@ -944,7 +943,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { /// and `opaque_hir_id` is the `HirId` of the definition of the existential type `Baz`. /// For the above example, this function returns `true` for `f1` and `false` for `f2`. pub fn may_define_existential_type( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, def_id: DefId, opaque_hir_id: hir::HirId, ) -> bool { diff --git a/src/librustc/infer/outlives/env.rs b/src/librustc/infer/outlives/env.rs index 3e626999200fe..ff27bbf7db24c 100644 --- a/src/librustc/infer/outlives/env.rs +++ b/src/librustc/infer/outlives/env.rs @@ -67,7 +67,7 @@ pub struct OutlivesEnvironment<'tcx> { /// because of implied bounds. pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>; -impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> { +impl<'a, 'tcx: 'a> OutlivesEnvironment<'tcx> { pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self { let mut env = OutlivesEnvironment { param_env, @@ -160,7 +160,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> { /// Tests: `src/test/compile-fail/regions-free-region-ordering-*.rs` pub fn add_implied_bounds( &mut self, - infcx: &InferCtxt<'a, 'gcx, 'tcx>, + infcx: &InferCtxt<'a, 'tcx>, fn_sig_tys: &[Ty<'tcx>], body_id: hir::HirId, span: Span, @@ -192,7 +192,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> { /// `RegionConstraintData`.) fn add_outlives_bounds( &mut self, - infcx: Option<&InferCtxt<'a, 'gcx, 'tcx>>, + infcx: Option<&InferCtxt<'a, 'tcx>>, outlives_bounds: I, ) where I: IntoIterator>, diff --git a/src/librustc/infer/outlives/free_region_map.rs b/src/librustc/infer/outlives/free_region_map.rs index c2ae561fcd39f..1250995a59c10 100644 --- a/src/librustc/infer/outlives/free_region_map.rs +++ b/src/librustc/infer/outlives/free_region_map.rs @@ -28,9 +28,9 @@ impl<'tcx> FreeRegionMap<'tcx> { /// cases, this is more conservative than necessary, in order to /// avoid making arbitrary choices. See /// `TransitiveRelation::postdom_upper_bound` for more details. - pub fn lub_free_regions<'gcx>( + pub fn lub_free_regions( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, r_a: Region<'tcx>, r_b: Region<'tcx>, ) -> Region<'tcx> { @@ -91,7 +91,7 @@ impl_stable_hash_for!(struct FreeRegionMap<'tcx> { impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> { type Lifted = FreeRegionMap<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option> { self.relation.maybe_map(|&fr| tcx.lift(&fr)) .map(|relation| FreeRegionMap { relation }) } diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index ddc1cd0ff3ffa..671718b1008e2 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -69,7 +69,7 @@ use crate::ty::outlives::Component; use crate::ty::{self, Region, Ty, TyCtxt, TypeFoldable}; use crate::ty::subst::UnpackedKind; -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Registers that the given region obligation must be resolved /// from within the scope of `body_id`. These regions are enqueued /// and later processed by regionck, when full type information is @@ -226,15 +226,15 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { /// via a "delegate" of type `D` -- this is usually the `infcx`, which /// accrues them into the `region_obligations` code, but for NLL we /// use something else. -pub struct TypeOutlives<'cx, 'gcx: 'tcx, 'tcx: 'cx, D> +pub struct TypeOutlives<'cx, 'tcx: 'cx, D> where D: TypeOutlivesDelegate<'tcx>, { // See the comments on `process_registered_region_obligations` for the meaning // of these fields. delegate: D, - tcx: TyCtxt<'gcx, 'tcx>, - verify_bound: VerifyBoundCx<'cx, 'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, + verify_bound: VerifyBoundCx<'cx, 'tcx>, } pub trait TypeOutlivesDelegate<'tcx> { @@ -254,13 +254,13 @@ pub trait TypeOutlivesDelegate<'tcx> { ); } -impl<'cx, 'gcx, 'tcx, D> TypeOutlives<'cx, 'gcx, 'tcx, D> +impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D> where D: TypeOutlivesDelegate<'tcx>, { pub fn new( delegate: D, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, @@ -487,7 +487,7 @@ where } } -impl<'cx, 'gcx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'tcx> { fn push_sub_region_constraint( &mut self, origin: SubregionOrigin<'tcx>, diff --git a/src/librustc/infer/outlives/verify.rs b/src/librustc/infer/outlives/verify.rs index 72079a6adc9fb..96335e1052ee3 100644 --- a/src/librustc/infer/outlives/verify.rs +++ b/src/librustc/infer/outlives/verify.rs @@ -12,16 +12,16 @@ use crate::util::captures::Captures; /// via a "delegate" of type `D` -- this is usually the `infcx`, which /// accrues them into the `region_obligations` code, but for NLL we /// use something else. -pub struct VerifyBoundCx<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct VerifyBoundCx<'cx, 'tcx: 'cx> { + tcx: TyCtxt<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, } -impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, @@ -102,7 +102,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { pub fn projection_declared_bounds_from_trait( &self, projection_ty: ty::ProjectionTy<'tcx>, - ) -> impl Iterator> + 'cx + Captures<'gcx> { + ) -> impl Iterator> + 'cx + Captures<'tcx> { self.declared_projection_bounds_from_trait(projection_ty) } @@ -244,7 +244,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { fn declared_projection_bounds_from_trait( &self, projection_ty: ty::ProjectionTy<'tcx>, - ) -> impl Iterator> + 'cx + Captures<'gcx> { + ) -> impl Iterator> + 'cx + Captures<'tcx> { debug!("projection_bounds(projection_ty={:?})", projection_ty); let tcx = self.tcx; self.region_bounds_declared_on_associated_item(projection_ty.item_def_id) @@ -284,7 +284,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { fn region_bounds_declared_on_associated_item( &self, assoc_item_def_id: DefId, - ) -> impl Iterator> + 'cx + Captures<'gcx> { + ) -> impl Iterator> + 'cx + Captures<'tcx> { let tcx = self.tcx; let assoc_item = tcx.associated_item(assoc_item_def_id); let trait_def_id = assoc_item.container.assert_trait(); diff --git a/src/librustc/infer/region_constraints/leak_check.rs b/src/librustc/infer/region_constraints/leak_check.rs index 5fc6523feba55..30f6137289abf 100644 --- a/src/librustc/infer/region_constraints/leak_check.rs +++ b/src/librustc/infer/region_constraints/leak_check.rs @@ -22,7 +22,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { /// refactor the constraint set. pub fn leak_check( &mut self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, overly_polymorphic: bool, placeholder_map: &PlaceholderMap<'tcx>, _snapshot: &CombinedSnapshot<'_, 'tcx>, @@ -109,7 +109,7 @@ impl<'tcx> TaintSet<'tcx> { fn fixed_point( &mut self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, undo_log: &[UndoLog<'tcx>], verifys: &[Verify<'tcx>], ) { diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index cab102907f603..f2235fe8d6d12 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -700,7 +700,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { pub fn lub_regions( &mut self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, origin: SubregionOrigin<'tcx>, a: Region<'tcx>, b: Region<'tcx>, @@ -722,7 +722,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { pub fn glb_regions( &mut self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, origin: SubregionOrigin<'tcx>, a: Region<'tcx>, b: Region<'tcx>, @@ -744,7 +744,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { pub fn opportunistic_resolve_var( &mut self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, rid: RegionVid, ) -> ty::Region<'tcx> { let vid = self.unification_table.probe_value(rid).min_vid; @@ -760,7 +760,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { fn combine_vars( &mut self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, t: CombineMapType, a: Region<'tcx>, b: Region<'tcx>, @@ -849,8 +849,8 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> { } } -impl<'gcx, 'tcx> GenericKind<'tcx> { - pub fn to_ty(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { +impl<'tcx> GenericKind<'tcx> { + pub fn to_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match *self { GenericKind::Param(ref p) => p.to_ty(tcx), GenericKind::Projection(ref p) => tcx.mk_projection(p.item_def_id, p.substs), diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index 774ebdcdd2502..5ca79bfa7bc1e 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -12,19 +12,19 @@ use crate::ty::fold::{TypeFolder, TypeVisitor}; /// been unified with (similar to `shallow_resolve`, but deep). This is /// useful for printing messages etc but also required at various /// points for correctness. -pub struct OpportunisticVarResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct OpportunisticVarResolver<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, } -impl<'a, 'gcx, 'tcx> OpportunisticVarResolver<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> { #[inline] - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self { OpportunisticVarResolver { infcx } } } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -50,18 +50,18 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gc /// The opportunistic type and region resolver is similar to the /// opportunistic type resolver, but also opportunistically resolves /// regions. It is useful for canonicalization. -pub struct OpportunisticTypeAndRegionResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, } -impl<'a, 'gcx, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { +impl<'a, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self { OpportunisticTypeAndRegionResolver { infcx } } } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -101,20 +101,20 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeAndRegionResolv /// type variables that don't yet have a value. The first unresolved type is stored. /// It does not construct the fully resolved type (which might /// involve some hashing and so forth). -pub struct UnresolvedTypeFinder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +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)>, } -impl<'a, 'gcx, 'tcx> UnresolvedTypeFinder<'a, 'gcx, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { +impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self { UnresolvedTypeFinder { infcx, first_unresolved: None } } } -impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { let t = self.infcx.shallow_resolve(t); if t.has_infer_types() { @@ -157,7 +157,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, '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, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, +pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, value: &T) -> FixupResult<'tcx, T> where T : TypeFoldable<'tcx> { @@ -171,13 +171,13 @@ pub fn fully_resolve<'a, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, // N.B. This type is not public because the protocol around checking the // `err` field is not enforcable otherwise. -struct FullTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +struct FullTypeResolver<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, err: Option>, } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index e17da50d7be8c..0284e087b7e83 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -11,14 +11,14 @@ use crate::mir::interpret::ConstValue; use std::mem; /// Ensures `a` is made a subtype of `b`. Returns `a` on success. -pub struct Sub<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { - fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, +pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> { + fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } -impl<'combine, 'infcx, 'gcx, 'tcx> Sub<'combine, 'infcx, 'gcx, 'tcx> { - pub fn new(f: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) - -> Sub<'combine, 'infcx, 'gcx, 'tcx> +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> { Sub { fields: f, a_is_expected: a_is_expected } } @@ -31,9 +31,9 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Sub<'combine, 'infcx, 'gcx, 'tcx> { } } -impl TypeRelation<'gcx, 'tcx> for Sub<'combine, 'infcx, 'gcx, 'tcx> { +impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> { fn tag(&self) -> &'static str { "Sub" } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.infcx.tcx } + fn tcx(&self) -> TyCtxt<'tcx> { self.fields.infcx.tcx } fn a_is_expected(&self) -> bool { self.a_is_expected } fn with_cause(&mut self, cause: Cause, f: F) -> R diff --git a/src/librustc/infer/unify_key.rs b/src/librustc/infer/unify_key.rs index 7f9880031f3f0..846611db05427 100644 --- a/src/librustc/infer/unify_key.rs +++ b/src/librustc/infer/unify_key.rs @@ -10,7 +10,7 @@ use std::marker::PhantomData; use std::cell::RefMut; pub trait ToType { - fn to_type<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>; + fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>; } impl UnifyKey for ty::IntVid { @@ -52,7 +52,7 @@ impl UnifyKey for ty::RegionVid { } impl ToType for IntVarValue { - fn to_type<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match *self { ty::IntType(i) => tcx.mk_mach_int(i), ty::UintType(i) => tcx.mk_mach_uint(i), @@ -72,7 +72,7 @@ impl UnifyKey for ty::FloatVid { impl EqUnifyValue for FloatVarValue {} impl ToType for FloatVarValue { - fn to_type<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { tcx.mk_mach_float(self.0) } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index c6a77a314be6a..c4a37d83866cf 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -509,7 +509,7 @@ impl LintStore { /// Context for lint checking after type checking. pub struct LateContext<'a, 'tcx: 'a> { /// Type context we're checking in. - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, /// Side-tables for the body we are in. // FIXME: Make this lazy to avoid running the TypeckTables query? @@ -781,10 +781,10 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { /// ``` pub fn get_def_path(&self, def_id: DefId) -> Vec { pub struct AbsolutePathPrinter<'tcx> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, } - impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { + impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { type Error = !; type Path = Vec; @@ -793,7 +793,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { type DynExistential = (); type Const = (); - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -1372,7 +1372,7 @@ macro_rules! late_lint_pass_impl { late_lint_methods!(late_lint_pass_impl, [], ['tcx]); fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, module_def_id: DefId, pass: T, ) { @@ -1404,7 +1404,7 @@ fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( } pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, module_def_id: DefId, builtin_lints: T, ) { @@ -1423,7 +1423,7 @@ pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( } } -fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx, 'tcx>, pass: T) { +fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, pass: T) { let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let krate = tcx.hir().krate(); @@ -1457,7 +1457,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, 'tcx>, + tcx: TyCtxt<'tcx>, builtin_lints: T, ) { let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap(); @@ -1491,7 +1491,7 @@ fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( /// Performs lint checking on a crate. pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, builtin_lints: impl FnOnce() -> T + Send, ) { join(|| { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 5a17eee173d5a..70c0e83517af0 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -761,12 +761,12 @@ pub fn struct_lint_level<'a>(sess: &'a Session, return err } -pub fn maybe_lint_level_root(tcx: TyCtxt<'_, '_>, id: hir::HirId) -> bool { +pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool { let attrs = tcx.hir().attrs_by_hir_id(id); attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) } -fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap { +fn lint_levels<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap { assert_eq!(cnum, LOCAL_CRATE); let mut builder = LintLevelMapBuilder { levels: LintLevelSets::builder(tcx.sess), @@ -787,7 +787,7 @@ fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevel struct LintLevelMapBuilder<'tcx> { levels: levels::LintLevelsBuilder<'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl LintLevelMapBuilder<'tcx> { diff --git a/src/librustc/macros.rs b/src/librustc/macros.rs index aeacd3722b438..09fa924efc7ab 100644 --- a/src/librustc/macros.rs +++ b/src/librustc/macros.rs @@ -195,7 +195,7 @@ macro_rules! CloneLiftImpls { $( impl<$tcx> $crate::ty::Lift<$tcx> for $ty { type Lifted = Self; - fn lift_to_tcx<'gcx>(&self, _: $crate::ty::TyCtxt<'gcx, $tcx>) -> Option { + fn lift_to_tcx(&self, _: $crate::ty::TyCtxt<$tcx>) -> Option { Some(Clone::clone(self)) } } @@ -218,7 +218,7 @@ macro_rules! CloneTypeFoldableImpls { (for <$tcx:lifetime> { $($ty:ty,)+ }) => { $( impl<$tcx> $crate::ty::fold::TypeFoldable<$tcx> for $ty { - fn super_fold_with<'gcx: $tcx, F: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( + fn super_fold_with>( &self, _: &mut F ) -> $ty { @@ -264,7 +264,7 @@ macro_rules! BraceStructLiftImpl { { type Lifted = $lifted; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<$lifted> { + fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> { $(let $field = tcx.lift(&self.$field)?;)* Some(Self::Lifted { $($field),* }) } @@ -283,7 +283,7 @@ macro_rules! EnumLiftImpl { { type Lifted = $lifted; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<$lifted> { + fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> { EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output()) } } @@ -332,7 +332,7 @@ macro_rules! BraceStructTypeFoldableImpl { impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s $(where $($wc)*)* { - fn super_fold_with<'gcx: $tcx, V: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( + fn super_fold_with>( &self, folder: &mut V, ) -> Self { @@ -359,7 +359,7 @@ macro_rules! TupleStructTypeFoldableImpl { impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s $(where $($wc)*)* { - fn super_fold_with<'gcx: $tcx, V: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( + fn super_fold_with>( &self, folder: &mut V, ) -> Self { @@ -386,7 +386,7 @@ macro_rules! EnumTypeFoldableImpl { impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s $(where $($wc)*)* { - fn super_fold_with<'gcx: $tcx, V: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( + fn super_fold_with>( &self, folder: &mut V, ) -> Self { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index f258f06b87dcc..2e9e1ac582f81 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -211,7 +211,7 @@ pub trait CrateStore { fn crates_untracked(&self) -> Vec; // utility functions - fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata; + fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx>) -> EncodedMetadata; fn metadata_encoding_version(&self) -> &[u8]; } @@ -226,7 +226,7 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync; // In order to get this left-to-right dependency ordering, we perform a // topological sort of all crates putting the leaves at the right-most // positions. -pub fn used_crates(tcx: TyCtxt<'_, '_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> { +pub fn used_crates(tcx: TyCtxt<'_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> { let mut libs = tcx.crates() .iter() .cloned() diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 18e19e802e889..0356e7e10724d 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -26,7 +26,7 @@ use syntax_pos; // explored. For example, if it's a live Node::Item that is a // function, then we should explore its block to check for codes that // may need to be marked as live. -fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool { +fn should_explore<'tcx>(tcx: TyCtxt<'tcx>, hir_id: hir::HirId) -> bool { match tcx.hir().find_by_hir_id(hir_id) { Some(Node::Item(..)) | Some(Node::ImplItem(..)) | @@ -40,7 +40,7 @@ fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool { struct MarkSymbolVisitor<'a, 'tcx: 'a> { worklist: Vec, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, live_symbols: FxHashSet, repr_has_repr_c: bool, @@ -302,7 +302,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { } fn has_allow_dead_code_or_lang_attr( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, id: hir::HirId, attrs: &[ast::Attribute], ) -> bool { @@ -354,7 +354,7 @@ fn has_allow_dead_code_or_lang_attr( struct LifeSeeder<'k, 'tcx: 'k> { worklist: Vec, krate: &'k hir::Crate, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, // see `MarkSymbolVisitor::struct_constructors` struct_constructors: FxHashMap, } @@ -425,7 +425,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } fn create_and_seed_worklist<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &privacy::AccessLevels, krate: &hir::Crate, ) -> (Vec, FxHashMap) { @@ -453,7 +453,7 @@ fn create_and_seed_worklist<'tcx>( } fn find_live<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &privacy::AccessLevels, krate: &hir::Crate, ) -> FxHashSet { @@ -474,7 +474,7 @@ fn find_live<'tcx>( } struct DeadVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, live_symbols: FxHashSet, } @@ -662,7 +662,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> { } } -pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) { let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let krate = tcx.hir().krate(); let live_symbols = find_live(tcx, access_levels, krate); diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 2f6a3f2f02721..879da6413e28a 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -81,7 +81,7 @@ pub enum Linkage { Dynamic, } -pub fn calculate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn calculate<'tcx>(tcx: TyCtxt<'tcx>) { let sess = &tcx.sess; let fmts = sess.crate_types.borrow().iter().map(|&ty| { let linkage = calculate_type(tcx, ty); @@ -92,7 +92,7 @@ pub fn calculate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { sess.dependency_formats.set(fmts); } -fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: config::CrateType) -> DependencyList { +fn calculate_type<'tcx>(tcx: TyCtxt<'tcx>, ty: config::CrateType) -> DependencyList { let sess = &tcx.sess; if !sess.opts.output_types.should_codegen() { @@ -241,7 +241,7 @@ fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: config::CrateType) -> Depen } fn add_library( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, cnum: CrateNum, link: LinkagePreference, m: &mut FxHashMap, @@ -267,7 +267,7 @@ fn add_library( } } -fn attempt_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Option { +fn attempt_static<'tcx>(tcx: TyCtxt<'tcx>) -> Option { let sess = &tcx.sess; let crates = cstore::used_crates(tcx, RequireStatic); if !crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) { @@ -324,7 +324,7 @@ fn activate_injected_dep(injected: Option, // After the linkage for a crate has been determined we need to verify that // there's only going to be one allocator in the output. -fn verify_ok<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, list: &[Linkage]) { +fn verify_ok<'tcx>(tcx: TyCtxt<'tcx>, list: &[Linkage]) { let sess = &tcx.sess; if list.len() == 0 { return diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 024196e35647c..704be9600fa4d 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -47,7 +47,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> { } } -fn entry_fn(tcx: TyCtxt<'_, '_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> { +fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> { assert_eq!(cnum, LOCAL_CRATE); let any_exe = tcx.sess.crate_types.borrow().iter().any(|ty| { @@ -141,7 +141,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) { } fn configure_main( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>, ) -> Option<(DefId, EntryFnType)> { if let Some((hir_id, _)) = visitor.start_fn { @@ -179,7 +179,7 @@ fn configure_main( } } -pub fn find_entry_point(tcx: TyCtxt<'_, '_>) -> Option<(DefId, EntryFnType)> { +pub fn find_entry_point(tcx: TyCtxt<'_>) -> Option<(DefId, EntryFnType)> { tcx.entry_fn(LOCAL_CRATE) } diff --git a/src/librustc/middle/exported_symbols.rs b/src/librustc/middle/exported_symbols.rs index 9e7af280408bd..78a3e3ff2681c 100644 --- a/src/librustc/middle/exported_symbols.rs +++ b/src/librustc/middle/exported_symbols.rs @@ -38,7 +38,7 @@ pub enum ExportedSymbol<'tcx> { } impl<'tcx> ExportedSymbol<'tcx> { - pub fn symbol_name(&self, tcx: TyCtxt<'tcx, '_>) -> ty::SymbolName { + pub fn symbol_name(&self, tcx: TyCtxt<'tcx>) -> ty::SymbolName { match *self { ExportedSymbol::NonGeneric(def_id) => { tcx.symbol_name(ty::Instance::mono(tcx, def_id)) @@ -54,7 +54,7 @@ impl<'tcx> ExportedSymbol<'tcx> { pub fn compare_stable( &self, - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, other: &ExportedSymbol<'tcx>, ) -> cmp::Ordering { match *self { @@ -91,13 +91,13 @@ impl<'tcx> ExportedSymbol<'tcx> { } } -pub fn metadata_symbol_name(tcx: TyCtxt<'_, '_>) -> String { +pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String { format!("rust_metadata_{}_{}", tcx.original_crate_name(LOCAL_CRATE), tcx.crate_disambiguator(LOCAL_CRATE).to_fingerprint().to_hex()) } -impl<'a, 'gcx> HashStable> for ExportedSymbol<'gcx> { +impl<'a, 'tcx> HashStable> for ExportedSymbol<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 3ed926d758264..80c26c132f614 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -202,7 +202,7 @@ enum OverloadedCallType { } impl OverloadedCallType { - fn from_trait_id(tcx: TyCtxt<'_, '_>, trait_id: DefId) -> OverloadedCallType { + fn from_trait_id(tcx: TyCtxt<'_>, trait_id: DefId) -> OverloadedCallType { for &(maybe_function_trait, overloaded_call_type) in &[ (tcx.lang_items().fn_once_trait(), FnOnceOverloadedCall), (tcx.lang_items().fn_mut_trait(), FnMutOverloadedCall), @@ -219,7 +219,7 @@ impl OverloadedCallType { bug!("overloaded call didn't map to known function trait") } - fn from_method_id(tcx: TyCtxt<'_, '_>, method_id: DefId) -> OverloadedCallType { + fn from_method_id(tcx: TyCtxt<'_>, method_id: DefId) -> OverloadedCallType { let method = tcx.associated_item(method_id); OverloadedCallType::from_trait_id(tcx, method.container.id()) } @@ -229,8 +229,8 @@ impl OverloadedCallType { // The ExprUseVisitor type // // This is the code that actually walks the tree. -pub struct ExprUseVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - mc: mc::MemCategorizationContext<'a, 'gcx, 'tcx>, +pub struct ExprUseVisitor<'a, 'tcx: 'a> { + mc: mc::MemCategorizationContext<'a, 'tcx>, delegate: &'a mut dyn Delegate<'tcx>, param_env: ty::ParamEnv<'tcx>, } @@ -254,7 +254,7 @@ macro_rules! return_if_err { ) } -impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> { +impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { /// Creates the ExprUseVisitor, configuring it with the various options provided: /// /// - `delegate` -- who receives the callbacks @@ -268,7 +268,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> { /// See also `with_infer`, which is used *during* typeck. pub fn new( delegate: &'a mut (dyn Delegate<'tcx> + 'a), - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body_owner: DefId, param_env: ty::ParamEnv<'tcx>, region_scope_tree: &'a region::ScopeTree, @@ -287,9 +287,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a), - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, + infcx: &'a InferCtxt<'a, 'tcx>, body_owner: DefId, param_env: ty::ParamEnv<'tcx>, region_scope_tree: &'a region::ScopeTree, @@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.consume_expr(&body.value); } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.mc.tcx } @@ -974,7 +974,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } } -fn copy_or_move<'a, 'gcx, 'tcx>(mc: &mc::MemCategorizationContext<'a, 'gcx, 'tcx>, +fn copy_or_move<'a, 'tcx>(mc: &mc::MemCategorizationContext<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, cmt: &mc::cmt_<'tcx>, move_reason: MoveReason) diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index 74c50cabab0c4..a8a7df08469aa 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -15,8 +15,8 @@ use crate::ty::{self, TyCtxt, Region}; /// /// This stuff is a bit convoluted and should be refactored, but as we /// transition to NLL, it'll all go away anyhow. -pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> { - pub tcx: TyCtxt<'gcx, 'tcx>, +pub struct RegionRelations<'a, 'tcx: 'a> { + pub tcx: TyCtxt<'tcx>, /// The context used to fetch the region maps. pub context: DefId, @@ -28,9 +28,9 @@ pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> { pub free_regions: &'a FreeRegionMap<'tcx>, } -impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> RegionRelations<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, context: DefId, region_scope_tree: &'a region::ScopeTree, free_regions: &'a FreeRegionMap<'tcx>, diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index d3ed818c4be45..e8d68e0b7a7aa 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -10,7 +10,7 @@ use syntax_pos::{Span, sym}; use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; use crate::hir; -fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module( module_def_id, &mut ItemVisitor { tcx }.as_deep_visitor() @@ -25,18 +25,18 @@ pub fn provide(providers: &mut Providers<'_>) { } struct ItemVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } struct ExprVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: &'tcx ty::TypeckTables<'tcx>, param_env: ty::ParamEnv<'tcx>, } /// If the type is `Option`, it will return `T`, otherwise /// the type itself. Works on most `Option`-like types. -fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { +fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { let (def, substs) = match ty.sty { ty::Adt(def, substs) => (def, substs), _ => return ty diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 02163409b3271..d7abdb8ecbe10 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -106,7 +106,7 @@ impl LanguageItems { struct LanguageItemCollector<'tcx> { items: LanguageItems, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, /// A mapping from the name of the lang item to its order and the form it must be of. item_refs: FxHashMap<&'static str, (usize, Target)>, } @@ -160,7 +160,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> { } impl LanguageItemCollector<'tcx> { - fn new(tcx: TyCtxt<'tcx, 'tcx>) -> LanguageItemCollector<'tcx> { + fn new(tcx: TyCtxt<'tcx>) -> LanguageItemCollector<'tcx> { let mut item_refs = FxHashMap::default(); $( item_refs.insert($name, ($variant as usize, $target)); )* @@ -217,7 +217,7 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> { } /// Traverse and collect all the lang items in all crates. -pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> LanguageItems { +pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LanguageItems { // Initialize the collector. let mut collector = LanguageItemCollector::new(tcx); @@ -402,7 +402,7 @@ language_item_table! { Rc, "rc", rc, Target::Struct; } -impl<'tcx, 'gcx> TyCtxt<'tcx, 'gcx> { +impl<'tcx> TyCtxt<'tcx> { /// Returns the `DefId` for a given `LangItem`. /// If not found, fatally abort compilation. pub fn require_lang_item(&self, lang_item: LangItem) -> DefId { diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index b05ede53d1cfd..9c131ce63428b 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -38,12 +38,12 @@ impl LibFeatures { } pub struct LibFeatureCollector<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, lib_features: LibFeatures, } impl LibFeatureCollector<'tcx> { - fn new(tcx: TyCtxt<'tcx, 'tcx>) -> LibFeatureCollector<'tcx> { + fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> { LibFeatureCollector { tcx, lib_features: LibFeatures::new(), @@ -142,7 +142,7 @@ impl Visitor<'tcx> for LibFeatureCollector<'tcx> { } } -pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> LibFeatures { +pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LibFeatures { let mut collector = LibFeatureCollector::new(tcx); intravisit::walk_crate(&mut collector, tcx.hir().krate()); collector.lib_features diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 92cb407f67d7c..260935a38d6d4 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -150,7 +150,7 @@ enum LiveNodeKind { ExitNode } -fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_>) -> String { +fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String { let cm = tcx.sess.source_map(); match lnk { UpvarNode(s) => { @@ -181,7 +181,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { fn visit_arm(&mut self, a: &'tcx hir::Arm) { visit_arm(self, a); } } -fn check_mod_liveness<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_liveness<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module( module_def_id, &mut IrMaps::new(tcx, module_def_id).as_deep_visitor(), @@ -257,7 +257,7 @@ enum VarKind { } struct IrMaps<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body_owner: DefId, num_live_nodes: usize, num_vars: usize, @@ -269,7 +269,7 @@ struct IrMaps<'tcx> { } impl IrMaps<'tcx> { - fn new(tcx: TyCtxt<'tcx, 'tcx>, body_owner: DefId) -> IrMaps<'tcx> { + fn new(tcx: TyCtxt<'tcx>, body_owner: DefId) -> IrMaps<'tcx> { IrMaps { tcx, body_owner, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 4b5b901f4703e..bc87aa8f872b4 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -287,14 +287,14 @@ impl HirNode for hir::Pat { } #[derive(Clone)] -pub struct MemCategorizationContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - pub tcx: TyCtxt<'gcx, 'tcx>, +pub struct MemCategorizationContext<'a, 'tcx> { + pub tcx: TyCtxt<'tcx>, pub body_owner: DefId, pub upvars: Option<&'tcx FxIndexMap>, pub region_scope_tree: &'a region::ScopeTree, pub tables: &'a ty::TypeckTables<'tcx>, rvalue_promotable_map: Option<&'tcx ItemLocalSet>, - infcx: Option<&'a InferCtxt<'a, 'gcx, 'tcx>>, + infcx: Option<&'a InferCtxt<'a, 'tcx>>, } pub type McResult = Result; @@ -340,7 +340,7 @@ impl MutabilityCategory { } fn from_local( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, tables: &ty::TypeckTables<'_>, id: ast::NodeId, ) -> MutabilityCategory { @@ -402,14 +402,14 @@ impl MutabilityCategory { } } -impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> { +impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body_owner: DefId, region_scope_tree: &'a region::ScopeTree, tables: &'a ty::TypeckTables<'tcx>, rvalue_promotable_map: Option<&'tcx ItemLocalSet>, - ) -> MemCategorizationContext<'a, 'tcx, 'tcx> { + ) -> MemCategorizationContext<'a, 'tcx> { MemCategorizationContext { tcx, body_owner, @@ -422,7 +422,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { /// Creates a `MemCategorizationContext` during type inference. /// This is used during upvar analysis and a few other places. /// Because the typeck tables are not yet complete, the results @@ -432,11 +432,11 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, '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, 'gcx, '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, 'gcx, 'tcx> { + -> MemCategorizationContext<'a, 'tcx> { let tcx = infcx.tcx; // Subtle: we can't do rvalue promotion analysis until the @@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { pub fn cat_expr(&self, expr: &hir::Expr) -> McResult> { // This recursion helper avoids going through *too many* // adjustments, since *only* non-overloaded deref recurses. - fn helper<'a, 'gcx, 'tcx>(mc: &MemCategorizationContext<'a, 'gcx, 'tcx>, + fn helper<'a, 'tcx>(mc: &MemCategorizationContext<'a, 'tcx>, expr: &hir::Expr, adjustments: &[adjustment::Adjustment<'tcx>]) -> McResult> { @@ -1518,7 +1518,7 @@ impl<'tcx> cmt_<'tcx> { } } - pub fn descriptive_string(&self, tcx: TyCtxt<'_, '_>) -> Cow<'static, str> { + pub fn descriptive_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> { match self.cat { Categorization::StaticItem => { "static item".into() diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index b0068a191da4c..363ccd74c08d9 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -27,7 +27,7 @@ use crate::hir::intravisit; // Returns true if the given item must be inlined because it may be // monomorphized or it was marked with `#[inline]`. This will only return // true for functions. -fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item, attrs: CodegenFnAttrs) -> bool { +fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAttrs) -> bool { if attrs.requests_inline() { return true } @@ -43,7 +43,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item, attrs: Codeg } fn method_might_be_inlined<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem, impl_src: DefId, ) -> bool { @@ -67,7 +67,7 @@ fn method_might_be_inlined<'tcx>( // Information needed while computing reachability. struct ReachableContext<'a, 'tcx: 'a> { // The type context. - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, // The set of items which must be exported in the linkage sense. reachable_symbols: HirIdSet, @@ -335,7 +335,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // trait items are used from inlinable code through method call syntax or UFCS, or their // trait is a lang item. struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &'a privacy::AccessLevels, worklist: &'a mut Vec, } @@ -391,7 +391,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, #[derive(Clone, HashStable)] pub struct ReachableSet(pub Lrc); -fn reachable_set<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> ReachableSet { +fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> ReachableSet { debug_assert!(crate_num == LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 5968933721de6..546d51e9124ad 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -169,7 +169,7 @@ impl Scope { self.id } - pub fn node_id(&self, tcx: TyCtxt<'_, '_>, scope_tree: &ScopeTree) -> ast::NodeId { + pub fn node_id(&self, tcx: TyCtxt<'_>, scope_tree: &ScopeTree) -> ast::NodeId { match scope_tree.root_body { Some(hir_id) => { tcx.hir().hir_to_node_id(hir::HirId { @@ -184,7 +184,7 @@ impl Scope { /// Returns the span of this `Scope`. Note that in general the /// returned span may not correspond to the span of any `NodeId` in /// the AST. - pub fn span(&self, tcx: TyCtxt<'_, '_>, scope_tree: &ScopeTree) -> Span { + pub fn span(&self, tcx: TyCtxt<'_>, scope_tree: &ScopeTree) -> Span { let node_id = self.node_id(tcx, scope_tree); if node_id == ast::DUMMY_NODE_ID { return DUMMY_SP; @@ -359,7 +359,7 @@ pub struct Context { } struct RegionResolutionVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, // The number of expressions and patterns visited in the current body expr_and_pat_count: usize, @@ -646,9 +646,9 @@ 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<'gcx>( + pub fn early_free_scope( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, br: &ty::EarlyBoundRegion, ) -> Scope { let param_owner = tcx.parent(br.def_id).unwrap(); @@ -679,7 +679,7 @@ impl<'tcx> ScopeTree { /// Assuming that the provided region was defined within this `ScopeTree`, /// returns the outermost `Scope` that the region outlives. - pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion) -> Scope { + pub fn free_scope(&self, tcx: TyCtxt<'tcx>, fr: &ty::FreeRegion) -> Scope { let param_owner = match fr.bound_region { ty::BoundRegion::BrNamed(def_id, _) => { tcx.parent(def_id).unwrap() @@ -1334,7 +1334,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> { } } -fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ScopeTree { +fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree { let closure_base_def_id = tcx.closure_base_def_id(def_id); if closure_base_def_id != def_id { return tcx.region_scope_tree(closure_base_def_id); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index edd5cb4541a96..e187a3ced3f4b 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -218,7 +218,7 @@ impl_stable_hash_for!(struct crate::middle::resolve_lifetime::ResolveLifetimes { }); struct LifetimeContext<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, map: &'a mut NamedRegionMap, scope: ScopeRef<'a>, @@ -368,7 +368,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { /// entire crate. You should not read the result of this query /// directly, but rather use `named_region_map`, `is_late_bound_map`, /// etc. -fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes { +fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes { assert_eq!(for_krate, LOCAL_CRATE); let named_region_map = krate(tcx); @@ -395,7 +395,7 @@ fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tc tcx.arena.alloc(rl) } -fn krate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> NamedRegionMap { +fn krate<'tcx>(tcx: TyCtxt<'tcx>) -> NamedRegionMap { let krate = tcx.hir().krate(); let mut map = NamedRegionMap { defs: Default::default(), @@ -1098,7 +1098,7 @@ impl ShadowKind { } } -fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_>, params: &P<[hir::GenericParam]>) { +fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &P<[hir::GenericParam]>) { let lifetime_params: Vec<_> = params .iter() .filter_map(|param| match param.kind { @@ -1126,7 +1126,7 @@ fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_>, params: &P<[hir::G } fn signal_shadowing_problem( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, name: ast::Name, orig: Original, shadower: Shadower, @@ -1166,7 +1166,7 @@ fn signal_shadowing_problem( // if one of the label shadows a lifetime or another label. fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { struct GatherLabels<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, scope: ScopeRef<'a>, labels_in_fn: &'a mut Vec, } @@ -1215,7 +1215,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { } fn check_if_label_shadows_lifetime( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, mut scope: ScopeRef<'_>, label: ast::Ident, ) { @@ -1253,7 +1253,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { } } -fn compute_object_lifetime_defaults(tcx: TyCtxt<'_, '_>) -> HirIdMap> { +fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap> { let mut map = HirIdMap::default(); for item in tcx.hir().krate().items.values() { match item.node { @@ -1310,7 +1310,7 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_, '_>) -> HirIdMap, + tcx: TyCtxt<'_>, generics: &hir::Generics, ) -> Vec { fn add_bounds(set: &mut Set1, bounds: &[hir::GenericBound]) { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index dbd008256b024..19d127a565fc3 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -106,7 +106,7 @@ impl_stable_hash_for!(struct self::Index<'tcx> { // A private tree-walker for producing an Index. struct Annotator<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, index: &'a mut Index<'tcx>, parent_stab: Option<&'tcx Stability>, parent_depr: Option, @@ -317,7 +317,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { } struct MissingStabilityAnnotations<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &'a AccessLevels, } @@ -390,7 +390,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { } impl<'tcx> Index<'tcx> { - pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Index<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>) -> Index<'tcx> { let is_staged_api = tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api; @@ -466,7 +466,7 @@ impl<'tcx> Index<'tcx> { /// Cross-references the feature names of unstable APIs with enabled /// features and possibly prints errors. -fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor()); } @@ -502,7 +502,7 @@ pub fn deprecation_in_effect(since: &str) -> bool { } struct Checker<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } /// Result of `TyCtxt::eval_stability`. @@ -521,7 +521,7 @@ pub enum EvalResult { Unmarked, } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { // See issue #38412. fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool { // Check if `def_id` is a trait method. @@ -827,7 +827,7 @@ impl Visitor<'tcx> for Checker<'tcx> { } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn lookup_deprecation(self, id: DefId) -> Option { self.lookup_deprecation_entry(id).map(|depr| depr.attr) } @@ -836,7 +836,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { /// Given the list of enabled features that were not language features (i.e., that /// were expected to be library features), and the list of features used from /// libraries, identify activated features that don't exist and error about them. -pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx>) { let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); if tcx.stability().staged_api[&LOCAL_CRATE] { @@ -921,7 +921,7 @@ pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } fn unnecessary_stable_feature_lint<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, span: Span, feature: Symbol, since: Symbol, diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 45d405df950e9..422ff3f2fd366 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -18,13 +18,13 @@ macro_rules! weak_lang_items { ($($name:ident, $item:ident, $sym:ident;)*) => ( struct Context<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, items: &'a mut lang_items::LanguageItems, } /// Checks the crate for usage of weak lang items, returning a vector of all the /// language items required by this crate, but not defined yet. -pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, +pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItems) { // These are never called by user code, they're generated by the compiler. // They will never implicitly be added to the `missing` array unless we do @@ -60,7 +60,7 @@ pub fn link_name(attrs: &[ast::Attribute]) -> Option { /// Not all lang items are always required for each compilation, particularly in /// the case of panic=abort. In these situations some lang items are injected by /// crates and don't actually need to be defined in libstd. -pub fn whitelisted(tcx: TyCtxt<'_, '_>, lang_item: lang_items::LangItem) -> bool { +pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: lang_items::LangItem) -> bool { // If we're not compiling with unwinding, we won't actually need these // symbols. Other panic runtimes ensure that the relevant symbols are // available to link things together, but they're never exercised. @@ -72,7 +72,7 @@ pub fn whitelisted(tcx: TyCtxt<'_, '_>, lang_item: lang_items::LangItem) -> bool false } -fn verify<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, +fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) { // We only need to check for the presence of weak lang items if we're // emitting something that's not an rlib. @@ -142,7 +142,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { } } -impl<'tcx, 'gcx> TyCtxt<'tcx, 'gcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool { let lang_items = self.lang_items(); let did = Some(item_def_id); diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 009cab3bd0315..e8113b4516cda 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -74,16 +74,16 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> { } } -impl<'gcx, 'tcx> ConstEvalErr<'tcx> { +impl<'tcx> ConstEvalErr<'tcx> { pub fn struct_error( &self, - tcx: TyCtxtAt<'gcx, 'tcx>, + tcx: TyCtxtAt<'tcx>, message: &str, ) -> Result, ErrorHandled> { self.struct_generic(tcx, message, None) } - pub fn report_as_error(&self, tcx: TyCtxtAt<'gcx, 'tcx>, message: &str) -> ErrorHandled { + pub fn report_as_error(&self, tcx: TyCtxtAt<'tcx>, message: &str) -> ErrorHandled { let err = self.struct_error(tcx, message); match err { Ok(mut err) => { @@ -96,7 +96,7 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> { pub fn report_as_lint( &self, - tcx: TyCtxtAt<'gcx, 'tcx>, + tcx: TyCtxtAt<'tcx>, message: &str, lint_root: hir::HirId, span: Option, @@ -129,7 +129,7 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> { fn struct_generic( &self, - tcx: TyCtxtAt<'gcx, 'tcx>, + tcx: TyCtxtAt<'tcx>, message: &str, lint_root: Option, ) -> Result, ErrorHandled> { @@ -170,7 +170,7 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> { } } -pub fn struct_error<'gcx, 'tcx>(tcx: TyCtxtAt<'gcx, 'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> { +pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> { struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg) } diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index f68385ec26759..a36c788022955 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -66,7 +66,7 @@ enum AllocDiscriminant { pub fn specialized_encode_alloc_id<'tcx, E: Encoder>( encoder: &mut E, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, alloc_id: AllocId, ) -> Result<(), E::Error> { let alloc: GlobalAlloc<'tcx> = diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index e73023d9a8cc9..008a57bddfe8e 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1240,8 +1240,8 @@ impl<'tcx> Terminator<'tcx> { } impl<'tcx> TerminatorKind<'tcx> { - pub fn if_<'gcx>( - tcx: TyCtxt<'gcx, 'tcx>, + pub fn if_( + tcx: TyCtxt<'tcx>, cond: Operand<'tcx>, t: BasicBlock, f: BasicBlock, @@ -2324,7 +2324,7 @@ impl<'tcx> Operand<'tcx> { /// with given `DefId` and substs. Since this is used to synthesize /// MIR, assumes `user_ty` is None. pub fn function_handle( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, span: Span, @@ -2795,7 +2795,7 @@ impl UserTypeProjection { CloneTypeFoldableAndLiftImpls! { ProjectionKind, } impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { use crate::mir::ProjectionElem::*; let base = self.base.fold_with(folder); @@ -3012,8 +3012,8 @@ pub struct GeneratorLayout<'tcx> { } #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] -pub struct BorrowCheckResult<'gcx> { - pub closure_requirements: Option>, +pub struct BorrowCheckResult<'tcx> { + pub closure_requirements: Option>, pub used_mut_upvars: SmallVec<[Field; 8]>, } @@ -3068,7 +3068,7 @@ pub struct BorrowCheckResult<'gcx> { /// TyCtxt, and hence we cannot use `ReVar` (which is what we use /// internally within the rest of the NLL code). #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] -pub struct ClosureRegionRequirements<'gcx> { +pub struct ClosureRegionRequirements<'tcx> { /// The number of external regions defined on the closure. In our /// example above, it would be 3 -- one for `'static`, then `'1` /// and `'2`. This is just used for a sanity check later on, to @@ -3078,7 +3078,7 @@ pub struct ClosureRegionRequirements<'gcx> { /// Requirements between the various free regions defined in /// indices. - pub outlives_requirements: Vec>, + pub outlives_requirements: Vec>, } /// Indicates an outlives constraint between a type or between two @@ -3262,7 +3262,7 @@ EnumTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { use crate::mir::TerminatorKind::*; let kind = match self.kind { @@ -3430,7 +3430,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { match self { &Place::Projection(ref p) => Place::Projection(p.fold_with(folder)), _ => self.clone(), @@ -3447,7 +3447,7 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { use crate::mir::Rvalue::*; match *self { Use(ref op) => Use(op.fold_with(folder)), @@ -3519,7 +3519,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { match *self { Operand::Copy(ref place) => Operand::Copy(place.fold_with(folder)), Operand::Move(ref place) => Operand::Move(place.fold_with(folder)), @@ -3536,7 +3536,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for Projection<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { use crate::mir::ProjectionElem::*; let base = self.base.fold_with(folder); @@ -3562,7 +3562,7 @@ impl<'tcx> TypeFoldable<'tcx> for Projection<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for Field { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _: &mut F) -> Self { + fn super_fold_with>(&self, _: &mut F) -> Self { *self } fn super_visit_with>(&self, _: &mut V) -> bool { @@ -3571,7 +3571,7 @@ impl<'tcx> TypeFoldable<'tcx> for Field { } impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _: &mut F) -> Self { + fn super_fold_with>(&self, _: &mut F) -> Self { *self } fn super_visit_with>(&self, _: &mut V) -> bool { @@ -3580,7 +3580,7 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal { } impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _: &mut F) -> Self { + fn super_fold_with>(&self, _: &mut F) -> Self { self.clone() } fn super_visit_with>(&self, _: &mut V) -> bool { @@ -3589,7 +3589,7 @@ impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix { } impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { Constant { span: self.span.clone(), ty: self.ty.fold_with(folder), diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index cf1126efc0f86..39ae48b303abf 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -48,7 +48,7 @@ pub enum MonoItem<'tcx> { } impl<'tcx> MonoItem<'tcx> { - pub fn size_estimate(&self, tcx: TyCtxt<'tcx, 'tcx>) -> usize { + pub fn size_estimate(&self, tcx: TyCtxt<'tcx>) -> usize { match *self { MonoItem::Fn(instance) => { // Estimate the size of a function based on how many statements @@ -72,7 +72,7 @@ impl<'tcx> MonoItem<'tcx> { } } - pub fn symbol_name(&self, tcx: TyCtxt<'tcx, 'tcx>) -> SymbolName { + pub fn symbol_name(&self, tcx: TyCtxt<'tcx>) -> SymbolName { match *self { MonoItem::Fn(instance) => tcx.symbol_name(instance), MonoItem::Static(def_id) => { @@ -87,7 +87,7 @@ impl<'tcx> MonoItem<'tcx> { } } - pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx, 'tcx>) -> InstantiationMode { + pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode { let inline_in_all_cgus = tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| { tcx.sess.opts.optimize != OptLevel::No @@ -131,7 +131,7 @@ impl<'tcx> MonoItem<'tcx> { } } - pub fn explicit_linkage(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Option { + pub fn explicit_linkage(&self, tcx: TyCtxt<'tcx>) -> Option { let def_id = match *self { MonoItem::Fn(ref instance) => instance.def_id(), MonoItem::Static(def_id) => def_id, @@ -167,7 +167,7 @@ impl<'tcx> MonoItem<'tcx> { /// Similarly, if a vtable method has such a signature, and therefore can't /// be used, we can just not emit it and have a placeholder (a null pointer, /// which will never be accessed) in its place. - pub fn is_instantiable(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool { + pub fn is_instantiable(&self, tcx: TyCtxt<'tcx>) -> bool { debug!("is_instantiable({:?})", self); let (def_id, substs) = match *self { MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs), @@ -179,7 +179,7 @@ impl<'tcx> MonoItem<'tcx> { tcx.substitute_normalize_and_test_predicates((def_id, &substs)) } - pub fn to_string(&self, tcx: TyCtxt<'tcx, 'tcx>, debug: bool) -> String { + pub fn to_string(&self, tcx: TyCtxt<'tcx>, debug: bool) -> String { return match *self { MonoItem::Fn(instance) => { to_string_internal(tcx, "fn ", instance, debug) @@ -194,7 +194,7 @@ impl<'tcx> MonoItem<'tcx> { }; fn to_string_internal<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, prefix: &str, instance: Instance<'tcx>, debug: bool, @@ -207,7 +207,7 @@ impl<'tcx> MonoItem<'tcx> { } } - pub fn local_span(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Option { + pub fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { MonoItem::Fn(Instance { def, .. }) => { tcx.hir().as_local_hir_id(def.def_id()) @@ -333,7 +333,7 @@ impl<'tcx> CodegenUnit<'tcx> { base_n::encode(hash, base_n::CASE_INSENSITIVE) } - pub fn estimate_size(&mut self, tcx: TyCtxt<'tcx, 'tcx>) { + pub fn estimate_size(&mut self, tcx: TyCtxt<'tcx>) { // Estimate the size of a codegen unit as (approximately) the number of MIR // statements it corresponds to. self.size_estimate = Some(self.items.keys().map(|mi| mi.size_estimate(tcx)).sum()); @@ -359,7 +359,7 @@ impl<'tcx> CodegenUnit<'tcx> { WorkProductId::from_cgu_name(&self.name().as_str()) } - pub fn work_product(&self, tcx: TyCtxt<'_, '_>) -> WorkProduct { + pub fn work_product(&self, tcx: TyCtxt<'_>) -> WorkProduct { let work_product_id = self.work_product_id(); tcx.dep_graph .previous_work_product(&work_product_id) @@ -370,14 +370,14 @@ impl<'tcx> CodegenUnit<'tcx> { pub fn items_in_deterministic_order( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Vec<(MonoItem<'tcx>, (Linkage, Visibility))> { // The codegen tests rely on items being process in the same order as // they appear in the file, so for local items, we sort by node_id first #[derive(PartialEq, Eq, PartialOrd, Ord)] pub struct ItemSortKey(Option, SymbolName); - fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: MonoItem<'tcx>) -> ItemSortKey { + fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey { ItemSortKey(match item { MonoItem::Fn(ref instance) => { match instance.def { @@ -413,7 +413,7 @@ impl<'tcx> CodegenUnit<'tcx> { items } - pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx, 'tcx>) -> DepNode { + pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode { DepNode::new(tcx, DepConstructor::CompileCodegenUnit(self.name().clone())) } } @@ -443,13 +443,13 @@ impl<'a, 'tcx> HashStable> for CodegenUnit<'tcx> { } } -pub struct CodegenUnitNameBuilder<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct CodegenUnitNameBuilder<'tcx> { + tcx: TyCtxt<'tcx>, cache: FxHashMap, } -impl CodegenUnitNameBuilder<'gcx, 'tcx> { - pub fn new(tcx: TyCtxt<'gcx, 'tcx>) -> Self { +impl CodegenUnitNameBuilder<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>) -> Self { CodegenUnitNameBuilder { tcx, cache: Default::default(), diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 76d7d98b90256..4a8f503b14f8a 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -21,7 +21,7 @@ pub struct PlaceTy<'tcx> { #[cfg(target_arch = "x86_64")] static_assert_size!(PlaceTy<'_>, 16); -impl<'gcx, 'tcx> PlaceTy<'tcx> { +impl<'tcx> PlaceTy<'tcx> { pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> { PlaceTy { ty, variant_index: None } } @@ -33,7 +33,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> { /// not carry a `Ty` for `T`.) /// /// Note that the resulting type has not been normalized. - pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx> { + pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> { let answer = match self.ty.sty { ty::Adt(adt_def, substs) => { let variant_def = match self.variant_index { @@ -56,7 +56,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> { /// Convenience wrapper around `projection_ty_core` for /// `PlaceElem`, where we can just use the `Ty` that is already /// stored inline on field projection elems. - pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> { + pub fn projection_ty(self, tcx: TyCtxt<'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> { self.projection_ty_core(tcx, elem, |_, _, ty| ty) } @@ -67,7 +67,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> { /// (which should be trivial when `T` = `Ty`). pub fn projection_ty_core( self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, elem: &ProjectionElem, mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>, ) -> PlaceTy<'tcx> @@ -118,7 +118,7 @@ BraceStructTypeFoldableImpl! { } impl<'tcx> Place<'tcx> { - pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> PlaceTy<'tcx> + pub fn ty(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx> where D: HasLocalDecls<'tcx>, { @@ -139,7 +139,7 @@ pub enum RvalueInitializationState { } impl<'tcx> Rvalue<'tcx> { - pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> + pub fn ty(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx> where D: HasLocalDecls<'tcx>, { @@ -221,7 +221,7 @@ impl<'tcx> Rvalue<'tcx> { } impl<'tcx> Operand<'tcx> { - pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> + pub fn ty(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx> where D: HasLocalDecls<'tcx>, { @@ -234,9 +234,9 @@ impl<'tcx> Operand<'tcx> { } impl<'tcx> BinOp { - pub fn ty<'gcx>( + pub fn ty( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>, ) -> Ty<'tcx> { diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index 00a162a31fa56..d89cf8eb3e843 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -48,11 +48,11 @@ pub struct AutoTraitInfo<'cx> { } pub struct AutoTraitFinder<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl<'tcx> AutoTraitFinder<'tcx> { - pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Self { + pub fn new(tcx: TyCtxt<'tcx>) -> Self { AutoTraitFinder { tcx } } @@ -79,7 +79,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { ty: Ty<'tcx>, orig_env: ty::ParamEnv<'tcx>, trait_did: DefId, - auto_trait_callback: impl for<'i> Fn(&InferCtxt<'_, 'tcx, 'i>, AutoTraitInfo<'i>) -> A, + auto_trait_callback: impl Fn(&InferCtxt<'_, 'tcx>, AutoTraitInfo<'tcx>) -> A, ) -> AutoTraitResult { let tcx = self.tcx; @@ -270,16 +270,16 @@ impl AutoTraitFinder<'tcx> { // the final synthesized generics: we don't want our generated docs page to contain something // like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate // 'user_env', which only holds the predicates that will actually be displayed to the user. - fn evaluate_predicates<'b, 'c>( + fn evaluate_predicates( &self, - infcx: &InferCtxt<'b, 'tcx, 'c>, + infcx: &InferCtxt<'_, 'tcx>, trait_did: DefId, - ty: Ty<'c>, - param_env: ty::ParamEnv<'c>, - user_env: ty::ParamEnv<'c>, - fresh_preds: &mut FxHashSet>, + ty: Ty<'tcx>, + param_env: ty::ParamEnv<'tcx>, + user_env: ty::ParamEnv<'tcx>, + fresh_preds: &mut FxHashSet>, only_projections: bool, - ) -> Option<(ty::ParamEnv<'c>, ty::ParamEnv<'c>)> { + ) -> Option<(ty::ParamEnv<'tcx>, ty::ParamEnv<'tcx>)> { let tcx = infcx.tcx; let mut select = SelectionContext::with_negative(&infcx, true); @@ -617,20 +617,14 @@ impl AutoTraitFinder<'tcx> { } } - fn evaluate_nested_obligations< - 'b, - 'c, - 'd, - 'cx, - T: Iterator>>, - >( + fn evaluate_nested_obligations( &self, ty: Ty<'_>, - nested: T, - computed_preds: &'b mut FxHashSet>, - fresh_preds: &'b mut FxHashSet>, - predicates: &'b mut VecDeque>, - select: &mut SelectionContext<'c, 'd, 'cx>, + nested: impl Iterator>>, + computed_preds: &mut FxHashSet>, + fresh_preds: &mut FxHashSet>, + predicates: &mut VecDeque>, + select: &mut SelectionContext<'_, 'tcx>, only_projections: bool, ) -> bool { let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID); @@ -822,23 +816,23 @@ impl AutoTraitFinder<'tcx> { return true; } - pub fn clean_pred<'c, 'd, 'cx>( + pub fn clean_pred( &self, - infcx: &InferCtxt<'c, 'd, 'cx>, - p: ty::Predicate<'cx>, - ) -> ty::Predicate<'cx> { + infcx: &InferCtxt<'_, 'tcx>, + p: ty::Predicate<'tcx>, + ) -> ty::Predicate<'tcx> { infcx.freshen(p) } } // Replaces all ReVars in a type with ty::Region's, using the provided map -pub struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { +pub struct RegionReplacer<'a, 'tcx> { vid_to_region: &'a FxHashMap>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionReplacer<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustc/traits/chalk_fulfill.rs b/src/librustc/traits/chalk_fulfill.rs index a7b5e6cf41b77..b1941b876d7c1 100644 --- a/src/librustc/traits/chalk_fulfill.rs +++ b/src/librustc/traits/chalk_fulfill.rs @@ -29,7 +29,7 @@ impl FulfillmentContext<'tcx> { } fn in_environment( - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, obligation: PredicateObligation<'tcx> ) -> InEnvironment<'tcx, PredicateObligation<'tcx>> { assert!(!infcx.is_in_snapshot()); @@ -52,7 +52,7 @@ fn in_environment( impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { fn normalize_projection_type( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, _param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, _cause: ObligationCause<'tcx>, @@ -62,7 +62,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { fn register_predicate_obligation( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, obligation: PredicateObligation<'tcx>, ) { self.obligations.insert(in_environment(infcx, obligation)); @@ -70,7 +70,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { fn select_all_or_error( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Result<(), Vec>> { self.select_where_possible(infcx)?; @@ -89,7 +89,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { fn select_where_possible( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Result<(), Vec>> { let mut errors = Vec::new(); let mut next_round = FxHashSet::default(); diff --git a/src/librustc/traits/codegen/mod.rs b/src/librustc/traits/codegen/mod.rs index f2c173230765b..a5d44f5f2637a 100644 --- a/src/librustc/traits/codegen/mod.rs +++ b/src/librustc/traits/codegen/mod.rs @@ -19,7 +19,7 @@ use crate::ty::fold::TypeFoldable; /// obligations *could be* resolved if we wanted to. /// Assumes that this is run after the entire crate has been successfully type-checked. pub fn codegen_fulfill_obligation<'tcx>( - ty: TyCtxt<'tcx, 'tcx>, + ty: TyCtxt<'tcx>, (param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>), ) -> Vtable<'tcx, ()> { // Remove any references to regions; this helps improve caching. @@ -73,7 +73,7 @@ pub fn codegen_fulfill_obligation<'tcx>( }) } -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Monomorphizes a type from the AST by first applying the /// in-scope substitutions and then normalizing any associated /// types. @@ -115,19 +115,19 @@ impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> { // # Global Cache -pub struct ProjectionCache<'gcx> { - data: PhantomData<&'gcx ()> +pub struct ProjectionCache<'tcx> { + data: PhantomData<&'tcx ()> } -impl<'gcx> DepTrackingMapConfig for ProjectionCache<'gcx> { - type Key = Ty<'gcx>; - type Value = Ty<'gcx>; +impl<'tcx> DepTrackingMapConfig for ProjectionCache<'tcx> { + type Key = Ty<'tcx>; + type Value = Ty<'tcx>; fn to_dep_kind() -> DepKind { DepKind::TraitSelect } } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// Finishes processes any obligations that remain in the /// fulfillment context, and then returns the result with all type /// variables removed and regions erased. Because this is intended @@ -141,7 +141,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fulfill_cx: &mut FulfillmentContext<'tcx>, result: &T) -> T::Lifted - where T: TypeFoldable<'tcx> + ty::Lift<'gcx> + 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 83f9796364163..949cc62f62c4f 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -48,8 +48,8 @@ pub fn add_placeholder_note(err: &mut errors::DiagnosticBuilder<'_>) { /// If there are types that satisfy both impls, invokes `on_overlap` /// with a suitably-freshened `ImplHeader` with those types /// substituted. Otherwise, invokes `no_overlap`. -pub fn overlapping_impls<'gcx, F1, F2, R>( - tcx: TyCtxt<'gcx, 'gcx>, +pub fn overlapping_impls<'tcx, F1, F2, R>( + tcx: TyCtxt<'tcx>, impl1_def_id: DefId, impl2_def_id: DefId, intercrate_mode: IntercrateMode, @@ -87,7 +87,7 @@ where }) } -fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, '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> @@ -111,8 +111,8 @@ fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, ' /// Can both impl `a` and impl `b` be satisfied by a common type (including /// where-clauses)? If so, returns an `ImplHeader` that unifies the two impls. -fn overlap<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn overlap<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, a_def_id: DefId, b_def_id: DefId, ) -> Option> { @@ -122,7 +122,7 @@ fn overlap<'cx, 'gcx, 'tcx>( } fn overlap_within_probe( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, + selcx: &mut SelectionContext<'cx, 'tcx>, a_def_id: DefId, b_def_id: DefId, snapshot: &CombinedSnapshot<'_, 'tcx>, @@ -183,8 +183,8 @@ fn overlap_within_probe( Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder }) } -pub fn trait_ref_is_knowable<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn trait_ref_is_knowable<'tcx>( + tcx: TyCtxt<'tcx>, trait_ref: ty::TraitRef<'tcx>, ) -> Option { debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref); @@ -229,8 +229,8 @@ pub fn trait_ref_is_knowable<'gcx, 'tcx>( } } -pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn trait_ref_is_local_or_fundamental<'tcx>( + tcx: TyCtxt<'tcx>, trait_ref: ty::TraitRef<'tcx>, ) -> bool { trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental) @@ -247,8 +247,8 @@ pub enum OrphanCheckErr<'tcx> { /// /// 1. All type parameters in `Self` must be "covered" by some local type constructor. /// 2. Some local type must appear in `Self`. -pub fn orphan_check<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn orphan_check<'tcx>( + tcx: TyCtxt<'tcx>, impl_def_id: DefId, ) -> Result<(), OrphanCheckErr<'tcx>> { debug!("orphan_check({:?})", impl_def_id); @@ -355,7 +355,7 @@ pub fn orphan_check<'gcx, 'tcx>( /// Note that this function is never called for types that have both type /// parameters and inference variables. fn orphan_check_trait_ref<'tcx>( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, trait_ref: ty::TraitRef<'tcx>, in_crate: InCrate, ) -> Result<(), OrphanCheckErr<'tcx>> { @@ -431,7 +431,7 @@ fn orphan_check_trait_ref<'tcx>( } } -fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { +fn uncovered_tys<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { if ty_is_local_constructor(ty, in_crate) { vec![] } else if fundamental_ty(ty) { @@ -450,7 +450,7 @@ fn is_possibly_remote_type(ty: Ty<'_>, _in_crate: InCrate) -> bool { } } -fn ty_is_local(tcx: TyCtxt<'_, '_>, ty: Ty<'_>, in_crate: InCrate) -> bool { +fn ty_is_local(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bool { ty_is_local_constructor(ty, in_crate) || fundamental_ty(ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, in_crate)) } diff --git a/src/librustc/traits/engine.rs b/src/librustc/traits/engine.rs index e43ca8e7e0acf..b96126c7b6735 100644 --- a/src/librustc/traits/engine.rs +++ b/src/librustc/traits/engine.rs @@ -9,7 +9,7 @@ use super::{ObligationCause, PredicateObligation}; pub trait TraitEngine<'tcx>: 'tcx { fn normalize_projection_type( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, @@ -20,7 +20,7 @@ pub trait TraitEngine<'tcx>: 'tcx { /// parameters (except for `Self`). fn register_bound( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>, def_id: DefId, @@ -40,18 +40,18 @@ pub trait TraitEngine<'tcx>: 'tcx { fn register_predicate_obligation( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, obligation: PredicateObligation<'tcx>, ); fn select_all_or_error( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Result<(), Vec>>; fn select_where_possible( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Result<(), Vec>>; fn pending_obligations(&self) -> Vec>; @@ -60,7 +60,7 @@ pub trait TraitEngine<'tcx>: 'tcx { pub trait TraitEngineExt<'tcx> { fn register_predicate_obligations( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, obligations: impl IntoIterator>, ); } @@ -68,7 +68,7 @@ pub trait TraitEngineExt<'tcx> { impl> TraitEngineExt<'tcx> for T { fn register_predicate_obligations( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, obligations: impl IntoIterator>, ) { for obligation in obligations { @@ -78,7 +78,7 @@ impl> TraitEngineExt<'tcx> for T { } impl dyn TraitEngine<'tcx> { - pub fn new(tcx: TyCtxt<'_, 'tcx>) -> Box { + pub fn new(tcx: TyCtxt<'tcx>) -> Box { if tcx.sess.opts.debugging_opts.chalk { Box::new(ChalkFulfillmentContext::new()) } else { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 1fb325ae05669..99ced254dcad9 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -38,7 +38,7 @@ use syntax::ast; use syntax::symbol::sym; use syntax_pos::{DUMMY_SP, Span, ExpnInfo, ExpnFormat}; -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>], body_id: Option, @@ -1249,8 +1249,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { expected_ref: ty::PolyTraitRef<'tcx>, found: ty::PolyTraitRef<'tcx>, ) -> DiagnosticBuilder<'tcx> { - fn build_fn_sig_string<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, + fn build_fn_sig_string<'tcx>( + tcx: TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>, ) -> String { let inputs = trait_ref.substs.type_at(1); @@ -1296,7 +1296,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn recursive_type_with_infinite_size_error(self, type_def_id: DefId) -> DiagnosticBuilder<'tcx> @@ -1342,7 +1342,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferCtxt<'a, 'tcx> { fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>, body_id: Option) { // Unable to successfully determine, probably means @@ -1454,13 +1454,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { param_env: ty::ParamEnv<'tcx>, pred: ty::PolyTraitRef<'tcx>, ) -> bool { - struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, + struct ParamToVarFolder<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, var_map: FxHashMap, Ty<'tcx>> } - impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ParamToVarFolder<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.infcx.tcx } + impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { if let ty::Param(ty::ParamTy {name, .. }) = ty.sty { diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index c7943d16885bd..eaad696ba391c 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -68,7 +68,7 @@ pub struct PendingPredicateObligation<'tcx> { pub stalled_on: Vec>, } -impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> { +impl<'a, 'tcx> FulfillmentContext<'tcx> { /// Creates a new fulfillment context. pub fn new() -> FulfillmentContext<'tcx> { FulfillmentContext { @@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> { } /// Attempts to select obligations using `selcx`. - fn select(&mut self, selcx: &mut SelectionContext<'a, 'gcx, 'tcx>) + fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>) -> Result<(), Vec>> { debug!("select(obligation-forest-size={})", self.predicates.len()); @@ -143,8 +143,8 @@ 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<'a, 'gcx>(&mut self, - infcx: &InferCtxt<'a, 'gcx, 'tcx>, + fn normalize_projection_type(&mut self, + infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>) @@ -172,8 +172,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { normalized_ty } - fn register_predicate_obligation<'a, 'gcx>(&mut self, - infcx: &InferCtxt<'a, 'gcx, 'tcx>, + fn register_predicate_obligation(&mut self, + infcx: &InferCtxt<'_, 'tcx>, obligation: PredicateObligation<'tcx>) { // this helps to reduce duplicate errors, as well as making @@ -190,9 +190,9 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { }); } - fn select_all_or_error<'a, 'gcx>( + fn select_all_or_error( &mut self, - infcx: &InferCtxt<'a, 'gcx, 'tcx> + infcx: &InferCtxt<'_, 'tcx> ) -> Result<(),Vec>> { self.select_where_possible(infcx)?; @@ -209,8 +209,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { } } - fn select_where_possible<'a, 'gcx>(&mut self, - infcx: &InferCtxt<'a, 'gcx, 'tcx>) + fn select_where_possible(&mut self, + infcx: &InferCtxt<'_, 'tcx>) -> Result<(),Vec>> { let mut selcx = SelectionContext::new(infcx); @@ -222,8 +222,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { } } -struct FulfillProcessor<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> { - selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +struct FulfillProcessor<'a, 'b: 'a, 'tcx: 'b> { + selcx: &'a mut SelectionContext<'b, 'tcx>, register_region_obligations: bool } @@ -234,7 +234,7 @@ fn mk_pending(os: Vec>) -> Vec ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx, 'tcx> { +impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { type Obligation = PendingPredicateObligation<'tcx>; type Error = FulfillmentErrorCode<'tcx>; @@ -514,7 +514,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx, } /// Returns the set of type variables contained in a trait ref -fn trait_ref_type_vars<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tcx>, +fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>, t: ty::PolyTraitRef<'tcx>) -> Vec> { t.skip_binder() // ok b/c this check doesn't care about regions diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 01be8de172c26..83162a1e12c25 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -140,7 +140,7 @@ pub struct ObligationCause<'tcx> { } impl<'tcx> ObligationCause<'tcx> { - pub fn span<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Span { + pub fn span(&self, tcx: TyCtxt<'tcx>) -> Span { match self.code { ObligationCauseCode::CompareImplMethodObligation { .. } | ObligationCauseCode::MainFunctionType | @@ -363,9 +363,9 @@ impl<'tcx> DomainGoal<'tcx> { } impl<'tcx> GoalKind<'tcx> { - pub fn from_poly_domain_goal<'gcx>( + pub fn from_poly_domain_goal( domain_goal: PolyDomainGoal<'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> GoalKind<'tcx> { match domain_goal.no_bound_vars() { Some(p) => p.into_goal(), @@ -643,8 +643,8 @@ pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, /// `bound` or is not known to meet bound (note that this is /// conservative towards *no impl*, which is the opposite of the /// `evaluate` methods). -pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>( - infcx: &InferCtxt<'a, 'gcx, 'tcx>, +pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>, def_id: DefId, @@ -711,7 +711,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>( } fn do_normalize_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, region_context: DefId, cause: ObligationCause<'tcx>, elaborated_env: ty::ParamEnv<'tcx>, @@ -796,7 +796,7 @@ fn do_normalize_predicates<'tcx>( // FIXME: this is gonna need to be removed ... /// Normalizes the parameter environment, reporting errors if they occur. pub fn normalize_param_env_or_error<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, region_context: DefId, unnormalized_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, @@ -904,8 +904,8 @@ pub fn normalize_param_env_or_error<'tcx>( ) } -pub fn fully_normalize<'a, 'gcx, 'tcx, T>( - infcx: &InferCtxt<'a, 'gcx, 'tcx>, +pub fn fully_normalize<'a, 'tcx, T>( + infcx: &InferCtxt<'a, 'tcx>, mut fulfill_cx: FulfillmentContext<'tcx>, cause: ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -937,7 +937,7 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>( /// encountered an error or one of the predicates did not hold. Used /// when creating vtables to check for unsatisfiable methods. fn normalize_and_test_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, predicates: Vec>, ) -> bool { debug!("normalize_and_test_predicates(predicates={:?})", @@ -966,7 +966,7 @@ fn normalize_and_test_predicates<'tcx>( } fn substitute_normalize_and_test_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, key: (DefId, SubstsRef<'tcx>), ) -> bool { debug!("substitute_normalize_and_test_predicates(key={:?})", @@ -984,7 +984,7 @@ fn substitute_normalize_and_test_predicates<'tcx>( /// that come from `trait_ref`, including its supertraits. #[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`. fn vtable_methods<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, ) -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] { debug!("vtable_methods({:?})", trait_ref); @@ -1185,7 +1185,7 @@ pub trait ExClauseFold<'tcx> where Self: chalk_engine::context::Context + Clone, { - fn fold_ex_clause_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>( + fn fold_ex_clause_with>( ex_clause: &chalk_engine::ExClause, folder: &mut F, ) -> chalk_engine::ExClause; @@ -1204,18 +1204,18 @@ where type LiftedDelayedLiteral: Debug + 'tcx; type LiftedLiteral: Debug + 'tcx; - fn lift_ex_clause_to_tcx<'gcx>( + fn lift_ex_clause_to_tcx( ex_clause: &chalk_engine::ExClause, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option; - fn lift_delayed_literal_to_tcx<'gcx>( + fn lift_delayed_literal_to_tcx( ex_clause: &chalk_engine::DelayedLiteral, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option; - fn lift_literal_to_tcx<'gcx>( + fn lift_literal_to_tcx( ex_clause: &chalk_engine::Literal, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option; } diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 01b81b182af96..cfd5cfa897daf 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -83,7 +83,7 @@ pub enum MethodViolationCode { UndispatchableReceiver, } -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Returns the object safety violations that affect /// astconv -- currently, `Self` in supertraits. This is needed /// because `object_safety_violations` can't be used during @@ -702,6 +702,6 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> { } } -pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_def_id: DefId) -> bool { +pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) -> bool { tcx.object_safety_violations(trait_def_id).is_empty() } diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index fe190db5fdbee..0a42b6b46f2c9 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -36,7 +36,7 @@ impl OnUnimplementedNote { } fn parse_error( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, span: Span, message: &str, label: &str, @@ -52,9 +52,9 @@ fn parse_error( ErrorReported } -impl<'gcx, 'tcx> OnUnimplementedDirective { +impl<'tcx> OnUnimplementedDirective { fn parse( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, items: &[NestedMetaItem], span: Span, @@ -134,7 +134,7 @@ impl<'gcx, 'tcx> OnUnimplementedDirective { } pub fn of_item( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, impl_def_id: DefId, ) -> Result, ErrorReported> { @@ -166,7 +166,7 @@ impl<'gcx, 'tcx> OnUnimplementedDirective { pub fn evaluate( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_ref: ty::TraitRef<'tcx>, options: &[(Symbol, Option)], ) -> OnUnimplementedNote { @@ -214,9 +214,9 @@ impl<'gcx, 'tcx> OnUnimplementedDirective { } } -impl<'gcx, 'tcx> OnUnimplementedFormatString { +impl<'tcx> OnUnimplementedFormatString { fn try_parse( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, from: LocalInternedString, err_sp: Span, @@ -228,7 +228,7 @@ impl<'gcx, 'tcx> OnUnimplementedFormatString { fn verify( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, span: Span, ) -> Result<(), ErrorReported> { @@ -274,7 +274,7 @@ impl<'gcx, 'tcx> OnUnimplementedFormatString { pub fn format( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_ref: ty::TraitRef<'tcx>, options: &FxHashMap, ) -> String { diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index e997e4d9c3183..75dd4d53b3644 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -183,8 +183,8 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> { /// /// If successful, this may result in additional obligations. Also returns /// the projection cache key used to track these additional obligations. -pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +pub fn poly_project_and_unify_type<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &PolyProjectionObligation<'tcx>) -> Result>>, MismatchedProjectionTypes<'tcx>> @@ -210,8 +210,8 @@ pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>( /// ::U == V /// /// If successful, this may result in additional obligations. -fn project_and_unify_type<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn project_and_unify_type<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionObligation<'tcx>) -> Result>>, MismatchedProjectionTypes<'tcx>> @@ -253,7 +253,7 @@ fn project_and_unify_type<'cx, 'gcx, '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, 'gcx, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +pub fn normalize<'a, 'b, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, value: &T) @@ -264,8 +264,8 @@ pub fn normalize<'a, 'b, 'gcx, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'gcx } /// As `normalize`, but with a custom depth. -pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>( - selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +pub fn normalize_with_depth<'a, 'b, 'tcx, T>( + selcx: &'a mut SelectionContext<'b, 'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, depth: usize, @@ -287,20 +287,20 @@ pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>( } } -struct AssocTypeNormalizer<'a, 'b: 'a, 'gcx: 'b+'tcx, 'tcx: 'b> { - selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +struct AssocTypeNormalizer<'a, 'b: 'a, 'tcx: 'b> { + selcx: &'a mut SelectionContext<'b, 'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, obligations: Vec>, depth: usize, } -impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { - fn new(selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +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, 'gcx, 'tcx> + -> AssocTypeNormalizer<'a, 'b, 'tcx> { AssocTypeNormalizer { selcx, @@ -322,8 +322,8 @@ impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { } } -impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { - fn tcx<'c>(&'c self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { + fn tcx<'c>(&'c self) -> TyCtxt<'tcx> { self.selcx.tcx() } @@ -456,8 +456,8 @@ impl<'tcx,T> Normalized<'tcx,T> { /// there are unresolved type variables in the projection, we will /// substitute a fresh type variable `$X` and generate a new /// obligation `::Item == $X` for later. -pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>( - selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +pub fn normalize_projection_type<'a, 'b, 'tcx>( + selcx: &'a mut SelectionContext<'b, 'tcx>, param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, @@ -501,8 +501,8 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>( /// often immediately appended to another obligations vector. So now this /// function takes an obligations vector and appends to it directly, which is /// slightly uglier but avoids the need for an extra short-lived allocation. -fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( - selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, +fn opt_normalize_projection_type<'a, 'b, 'tcx>( + selcx: &'a mut SelectionContext<'b, 'tcx>, param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, @@ -705,7 +705,7 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, '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, 'gcx, 'tcx>(infcx: &'a InferCtxt<'a, 'gcx, '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() { @@ -763,8 +763,8 @@ fn prune_cache_value_obligations<'a, 'gcx, 'tcx>(infcx: &'a InferCtxt<'a, 'gcx, /// that may yet turn out to be wrong. This *may* lead to some sort /// of trouble, though we don't have a concrete example of how that /// can occur yet. But it seems risky at best. -fn get_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>( - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +fn get_paranoid_cache_value_obligation<'a, 'tcx>( + infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, projection_ty: ty::ProjectionTy<'tcx>, cause: ObligationCause<'tcx>, @@ -799,7 +799,7 @@ fn get_paranoid_cache_value_obligation<'a, 'gcx, '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, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, '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>, @@ -836,7 +836,7 @@ struct Progress<'tcx> { } impl<'tcx> Progress<'tcx> { - fn error<'gcx>(tcx: TyCtxt<'gcx, 'tcx>) -> Self { + fn error(tcx: TyCtxt<'tcx>) -> Self { Progress { ty: tcx.types.err, obligations: vec![], @@ -861,8 +861,8 @@ impl<'tcx> Progress<'tcx> { /// /// IMPORTANT: /// - `obligation` must be fully normalized -fn project_type<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn project_type<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>) -> Result, ProjectionTyError<'tcx>> { @@ -925,8 +925,8 @@ fn project_type<'cx, 'gcx, 'tcx>( /// The first thing we have to do is scan through the parameter /// environment to see whether there are any projection predicates /// there that can answer this question. -fn assemble_candidates_from_param_env<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +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>) @@ -950,8 +950,8 @@ fn assemble_candidates_from_param_env<'cx, 'gcx, 'tcx>( /// ``` /// /// Here, for example, we could conclude that the result is `i32`. -fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +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>) @@ -986,8 +986,8 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>( bounds) } -fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn assemble_candidates_from_predicates<'cx, 'tcx, I>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, candidate_set: &mut ProjectionTyCandidateSet<'tcx>, @@ -1029,8 +1029,8 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>( } } -fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +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>) @@ -1177,8 +1177,8 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>( }); } -fn confirm_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, candidate: ProjectionTyCandidate<'tcx>) @@ -1200,8 +1200,8 @@ fn confirm_candidate<'cx, 'gcx, 'tcx>( } } -fn confirm_select_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_select_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>, vtable: Selection<'tcx>) @@ -1230,8 +1230,8 @@ fn confirm_select_candidate<'cx, 'gcx, 'tcx>( } } -fn confirm_object_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_object_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>) -> Progress<'tcx> @@ -1295,8 +1295,8 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>( confirm_param_env_candidate(selcx, obligation, env_predicate) } -fn confirm_generator_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_generator_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>) -> Progress<'tcx> @@ -1348,8 +1348,8 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>( .with_addl_obligations(obligations) } -fn confirm_fn_pointer_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, '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> @@ -1370,8 +1370,8 @@ fn confirm_fn_pointer_candidate<'cx, 'gcx, 'tcx>( .with_addl_obligations(obligations) } -fn confirm_closure_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_closure_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>) -> Progress<'tcx> @@ -1402,8 +1402,8 @@ fn confirm_closure_candidate<'cx, 'gcx, 'tcx>( .with_addl_obligations(obligations) } -fn confirm_callable_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_callable_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, fn_sig: ty::PolyFnSig<'tcx>, flag: util::TupleArgumentsFlag) @@ -1437,8 +1437,8 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>( confirm_param_env_candidate(selcx, obligation, predicate) } -fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_param_env_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, poly_cache_entry: ty::PolyProjectionPredicate<'tcx>, ) -> Progress<'tcx> { @@ -1478,8 +1478,8 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>( } } -fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( - selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +fn confirm_impl_candidate<'cx, 'tcx>( + selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTyObligation<'tcx>, impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>) -> Progress<'tcx> @@ -1521,8 +1521,8 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( /// /// Based on the "projection mode", this lookup may in fact only examine the /// topmost impl. See the comments for `Reveal` for more details. -fn assoc_ty_def<'cx, 'gcx, 'tcx>( - selcx: &SelectionContext<'cx, 'gcx, 'tcx>, +fn assoc_ty_def<'cx, 'tcx>( + selcx: &SelectionContext<'cx, 'tcx>, impl_def_id: DefId, assoc_ty_def_id: DefId) -> specialization_graph::NodeItem @@ -1608,8 +1608,8 @@ pub struct ProjectionCacheKey<'tcx> { ty: ty::ProjectionTy<'tcx> } -impl<'cx, 'gcx, 'tcx> ProjectionCacheKey<'tcx> { - pub fn from_poly_projection_predicate(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, +impl<'cx, 'tcx> ProjectionCacheKey<'tcx> { + pub fn from_poly_projection_predicate(selcx: &mut SelectionContext<'cx, 'tcx>, predicate: &ty::PolyProjectionPredicate<'tcx>) -> Option { diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 90df5ed10d78f..46403a38c99bd 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -6,7 +6,7 @@ use syntax::source_map::Span; use crate::ty::subst::Kind; use crate::ty::{self, Ty, TyCtxt}; -impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> At<'cx, 'tcx> { /// Given a type `ty` of some value being dropped, computes a set /// of "kinds" (types, regions) that must be outlive the execution /// of the destructor. These basically correspond to data that the @@ -85,7 +85,7 @@ pub struct DropckOutlivesResult<'tcx> { } impl<'tcx> DropckOutlivesResult<'tcx> { - pub fn report_overflows(&self, tcx: TyCtxt<'_, 'tcx>, span: Span, ty: Ty<'tcx>) { + pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) { if let Some(overflow_ty) = self.overflows.iter().next() { let mut err = struct_span_err!( tcx.sess, @@ -101,7 +101,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> { pub fn into_kinds_reporting_overflows( self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>, ) -> Vec> { @@ -185,7 +185,7 @@ impl_stable_hash_for!(struct DtorckConstraint<'tcx> { /// /// Note also that `needs_drop` requires a "global" type (i.e., one /// with erased regions), but this function does not. -pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> bool { +pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { match ty.sty { // None of these types have a destructor and hence they do not // require anything in particular to outlive the dtor's diff --git a/src/librustc/traits/query/evaluate_obligation.rs b/src/librustc/traits/query/evaluate_obligation.rs index d5230f15c2565..031e342484786 100644 --- a/src/librustc/traits/query/evaluate_obligation.rs +++ b/src/librustc/traits/query/evaluate_obligation.rs @@ -3,7 +3,7 @@ use crate::infer::canonical::OriginalQueryValues; use crate::traits::{EvaluationResult, PredicateObligation, SelectionContext, TraitQueryMode, OverflowError}; -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Evaluates whether the predicate can be satisfied (by any means) /// in the given `ParamEnv`. pub fn predicate_may_hold( diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 86067a7c1d801..50476721e8247 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -14,7 +14,7 @@ use crate::ty::{self, Ty, TyCtxt}; use super::NoSolution; -impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> At<'cx, 'tcx> { /// Normalize `value` in the context of the inference context, /// yielding a resulting type, or an error if `value` cannot be /// normalized. If you don't care about regions, you should prefer @@ -73,8 +73,8 @@ pub struct NormalizationResult<'tcx> { pub normalized_ty: Ty<'tcx>, } -struct QueryNormalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +struct QueryNormalizer<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, cause: &'cx ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, obligations: Vec>, @@ -82,8 +82,8 @@ struct QueryNormalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { anon_depth: usize, } -impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx> { - fn tcx<'c>(&'c self) -> TyCtxt<'gcx, 'tcx> { +impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { + fn tcx<'c>(&'c self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc/traits/query/normalize_erasing_regions.rs b/src/librustc/traits/query/normalize_erasing_regions.rs index 8b820e22cac0b..3218ff062ce5e 100644 --- a/src/librustc/traits/query/normalize_erasing_regions.rs +++ b/src/librustc/traits/query/normalize_erasing_regions.rs @@ -10,7 +10,7 @@ use crate::ty::{self, Ty, TyCtxt}; use crate::ty::fold::{TypeFoldable, TypeFolder}; -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Erase the regions in `value` and then fully normalize all the /// types found within. The result will also have regions erased. /// @@ -63,12 +63,12 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> { } struct NormalizeAfterErasingRegionsFolder<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, } -impl TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { +impl TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustc/traits/query/outlives_bounds.rs b/src/librustc/traits/query/outlives_bounds.rs index 954de15905fb7..40bd18738b528 100644 --- a/src/librustc/traits/query/outlives_bounds.rs +++ b/src/librustc/traits/query/outlives_bounds.rs @@ -64,7 +64,7 @@ impl<'a, 'tcx> HashStable> for OutlivesBound<'tcx> { } } -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// Implied bounds are region relationships that we deduce /// automatically. The idea is that (e.g.) a caller must check that a /// function's argument types are well-formed immediately before diff --git a/src/librustc/traits/query/type_op/ascribe_user_type.rs b/src/librustc/traits/query/type_op/ascribe_user_type.rs index c663a65659c55..05a4d4336a7c2 100644 --- a/src/librustc/traits/query/type_op/ascribe_user_type.rs +++ b/src/librustc/traits/query/type_op/ascribe_user_type.rs @@ -21,25 +21,25 @@ impl<'tcx> AscribeUserType<'tcx> { } } -impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for AscribeUserType<'tcx> { +impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> { type QueryResponse = (); fn try_fast_path( - _tcx: TyCtxt<'gcx, 'tcx>, + _tcx: TyCtxt<'tcx>, _key: &ParamEnvAnd<'tcx, Self>, ) -> Option { None } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { tcx.type_op_ascribe_user_type(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, ()>, + v: &'a CanonicalizedQueryResponse<'tcx, ()>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } diff --git a/src/librustc/traits/query/type_op/custom.rs b/src/librustc/traits/query/type_op/custom.rs index 5933d2366e81c..72550e23460e6 100644 --- a/src/librustc/traits/query/type_op/custom.rs +++ b/src/librustc/traits/query/type_op/custom.rs @@ -14,9 +14,9 @@ pub struct CustomTypeOp { } impl CustomTypeOp { - pub fn new<'gcx, 'tcx, R>(closure: F, description: G) -> Self + pub fn new<'tcx, R>(closure: F, description: G) -> Self where - F: FnOnce(&InferCtxt<'_, 'gcx, 'tcx>) -> Fallible>, + F: FnOnce(&InferCtxt<'_, 'tcx>) -> Fallible>, G: Fn() -> String, { CustomTypeOp { @@ -26,9 +26,9 @@ impl CustomTypeOp { } } -impl<'gcx, 'tcx, F, R, G> super::TypeOp<'gcx, 'tcx> for CustomTypeOp +impl<'tcx, F, R, G> super::TypeOp<'tcx> for CustomTypeOp where - F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'gcx, 'tcx>) -> Fallible>, + F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'tcx>) -> Fallible>, G: Fn() -> String, { type Output = R; @@ -38,7 +38,7 @@ where /// (they will be given over to the NLL region solver). fn fully_perform( self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Fallible<(Self::Output, Option>>>)> { if cfg!(debug_assertions) { info!("fully_perform({:?})", self); @@ -59,8 +59,8 @@ where /// Executes `op` and then scrapes out all the "old style" region /// constraints that result, creating query-region-constraints. -fn scrape_region_constraints<'gcx, 'tcx, R>( - infcx: &InferCtxt<'_, 'gcx, 'tcx>, +fn scrape_region_constraints<'tcx, R>( + infcx: &InferCtxt<'_, 'tcx>, op: impl FnOnce() -> Fallible>, ) -> Fallible<(R, Option>>>)> { let mut fulfill_cx = TraitEngine::new(infcx.tcx); diff --git a/src/librustc/traits/query/type_op/eq.rs b/src/librustc/traits/query/type_op/eq.rs index c431178bb2a29..e8ec304f918a3 100644 --- a/src/librustc/traits/query/type_op/eq.rs +++ b/src/librustc/traits/query/type_op/eq.rs @@ -14,11 +14,11 @@ impl<'tcx> Eq<'tcx> { } } -impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> { +impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> { type QueryResponse = (); fn try_fast_path( - _tcx: TyCtxt<'gcx, 'tcx>, + _tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Eq<'tcx>>, ) -> Option { if key.value.a == key.value.b { @@ -29,14 +29,14 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> { } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { tcx.type_op_eq(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, ()>, + v: &'a CanonicalizedQueryResponse<'tcx, ()>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } diff --git a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs index 762e09b03acad..3beb4d64656c5 100644 --- a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs +++ b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs @@ -14,20 +14,20 @@ impl<'tcx> ImpliedOutlivesBounds<'tcx> { } } -impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds<'tcx> { +impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> { type QueryResponse = Vec>; fn try_fast_path( - _tcx: TyCtxt<'gcx, 'tcx>, + _tcx: TyCtxt<'tcx>, _key: &ParamEnvAnd<'tcx, Self>, ) -> Option { None } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { // FIXME this `unchecked_map` is only necessary because the // query is defined as taking a `ParamEnvAnd`; it should // take a `ImpliedOutlivesBounds` instead @@ -40,7 +40,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds< } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, + v: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { v } diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 1553d17e684fa..8dfb11230f248 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -23,7 +23,7 @@ pub mod subtype; /// "Type ops" are used in NLL to perform some particular action and /// extract out the resulting region constraints (or an error if it /// cannot be completed). -pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { +pub trait TypeOp<'tcx>: Sized + fmt::Debug { type Output; /// Processes the operation and all resulting obligations, @@ -31,7 +31,7 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { /// (they will be given over to the NLL region solver). fn fully_perform( self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Fallible<(Self::Output, Option>>>)>; } @@ -44,16 +44,16 @@ pub trait TypeOp<'gcx, '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<'gcx: 'tcx, 'tcx>: - fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'gcx> +pub trait QueryTypeOp<'tcx>: + fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'tcx> { - type QueryResponse: TypeFoldable<'tcx> + Lift<'gcx>; + type QueryResponse: TypeFoldable<'tcx> + Lift<'tcx>; /// Give query the option for a simple fast path that never /// actually hits the tcx cache lookup etc. Return `Some(r)` with /// a final result or `None` to do the full path. fn try_fast_path( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>, ) -> Option; @@ -64,29 +64,29 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: /// bad, because it would create subregion relationships that are /// not captured in the return value. fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible>; + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible>; /// Casts a lifted query result (which is in the gcx lifetime) /// into the tcx lifetime. This is always just an identity cast, /// but the generic code doesn't realize it -- put another way, in - /// the generic code, we have a `Lifted<'gcx, Self::QueryResponse>` + /// the generic code, we have a `Lifted<'tcx, Self::QueryResponse>` /// and we want to convert that to a `Self::QueryResponse`. This is /// not a priori valid, so we can't do it -- but in practice, it /// is always a no-op (e.g., the lifted form of a type, - /// `Ty<'gcx>`, is a subtype of `Ty<'tcx>`). So we have to push + /// `Ty<'tcx>`, is a subtype of `Ty<'tcx>`). So we have to push /// the operation into the impls that know more specifically what /// `QueryResponse` is. This operation would (maybe) be nicer with /// something like HKTs or GATs, since then we could make - /// `QueryResponse` parametric and `'gcx` and `'tcx` etc. + /// `QueryResponse` parametric and `'tcx` and `'tcx` etc. fn shrink_to_tcx_lifetime( - lifted_query_result: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, + lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>; fn fully_perform_into( query_key: ParamEnvAnd<'tcx, Self>, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, output_query_region_constraints: &mut Vec>, ) -> Fallible { if let Some(result) = QueryTypeOp::try_fast_path(infcx.tcx, &query_key) { @@ -133,15 +133,15 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: } } -impl<'gcx: 'tcx, 'tcx, Q> TypeOp<'gcx, 'tcx> for ParamEnvAnd<'tcx, Q> +impl<'tcx, Q> TypeOp<'tcx> for ParamEnvAnd<'tcx, Q> where - Q: QueryTypeOp<'gcx, 'tcx>, + Q: QueryTypeOp<'tcx>, { type Output = Q::QueryResponse; fn fully_perform( self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ) -> Fallible<(Self::Output, Option>>>)> { let mut qrc = vec![]; let r = Q::fully_perform_into(self, infcx, &mut qrc)?; diff --git a/src/librustc/traits/query/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs index 52a0c6042baf5..5a768d9d58fcd 100644 --- a/src/librustc/traits/query/type_op/normalize.rs +++ b/src/librustc/traits/query/type_op/normalize.rs @@ -18,13 +18,13 @@ where } } -impl<'gcx: 'tcx, 'tcx, T> super::QueryTypeOp<'gcx, 'tcx> for Normalize +impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize where - T: Normalizable<'gcx, 'tcx>, + T: Normalizable<'tcx>, { type QueryResponse = T; - fn try_fast_path(_tcx: TyCtxt<'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option { + fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option { if !key.value.value.has_projections() { Some(key.value.value) } else { @@ -33,99 +33,87 @@ where } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { T::type_op_method(tcx, canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, T>, + v: &'a CanonicalizedQueryResponse<'tcx, T>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> { T::shrink_to_tcx_lifetime(v) } } -pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx> + Copy { +pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy { fn type_op_method( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible>; + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, + ) -> Fallible>; - /// Converts from the `'gcx` (lifted) form of `Self` into the `tcx` + /// Converts from the `'tcx` (lifted) form of `Self` into the `tcx` /// form of `Self`. fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, Self>, + v: &'a CanonicalizedQueryResponse<'tcx, Self>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>; } -impl Normalizable<'gcx, 'tcx> for Ty<'tcx> -where - 'gcx: 'tcx, -{ +impl Normalizable<'tcx> for Ty<'tcx> { fn type_op_method( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, + ) -> Fallible> { tcx.type_op_normalize_ty(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, Self>, + v: &'a CanonicalizedQueryResponse<'tcx, Self>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } -impl Normalizable<'gcx, 'tcx> for ty::Predicate<'tcx> -where - 'gcx: 'tcx, -{ +impl Normalizable<'tcx> for ty::Predicate<'tcx> { fn type_op_method( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, + ) -> Fallible> { tcx.type_op_normalize_predicate(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, Self>, + v: &'a CanonicalizedQueryResponse<'tcx, Self>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } -impl Normalizable<'gcx, 'tcx> for ty::PolyFnSig<'tcx> -where - 'gcx: 'tcx, -{ +impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> { fn type_op_method( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, + ) -> Fallible> { tcx.type_op_normalize_poly_fn_sig(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, Self>, + v: &'a CanonicalizedQueryResponse<'tcx, Self>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } -impl Normalizable<'gcx, 'tcx> for ty::FnSig<'tcx> -where - 'gcx: 'tcx, -{ +impl Normalizable<'tcx> for ty::FnSig<'tcx> { fn type_op_method( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize>>, + ) -> Fallible> { tcx.type_op_normalize_fn_sig(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, Self>, + v: &'a CanonicalizedQueryResponse<'tcx, Self>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } diff --git a/src/librustc/traits/query/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs index 56a051e08e716..d4b36356ffb06 100644 --- a/src/librustc/traits/query/type_op/outlives.rs +++ b/src/librustc/traits/query/type_op/outlives.rs @@ -15,14 +15,11 @@ impl<'tcx> DropckOutlives<'tcx> { } } -impl super::QueryTypeOp<'gcx, 'tcx> for DropckOutlives<'tcx> -where - 'gcx: 'tcx, -{ +impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> { type QueryResponse = DropckOutlivesResult<'tcx>; fn try_fast_path( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>, ) -> Option { if trivial_dropck_outlives(tcx, key.value.dropped_ty) { @@ -33,9 +30,9 @@ where } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { // Subtle: note that we are not invoking // `infcx.at(...).dropck_outlives(...)` here, but rather the // underlying `dropck_outlives` query. This same underlying @@ -58,7 +55,7 @@ where } fn shrink_to_tcx_lifetime( - lifted_query_result: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, + lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { lifted_query_result } diff --git a/src/librustc/traits/query/type_op/prove_predicate.rs b/src/librustc/traits/query/type_op/prove_predicate.rs index 64fcc73187cf0..1efe66326d724 100644 --- a/src/librustc/traits/query/type_op/prove_predicate.rs +++ b/src/librustc/traits/query/type_op/prove_predicate.rs @@ -13,11 +13,11 @@ impl<'tcx> ProvePredicate<'tcx> { } } -impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> { +impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { type QueryResponse = (); fn try_fast_path( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>, ) -> Option { // Proving Sized, very often on "obviously sized" types like @@ -38,14 +38,14 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> { } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { tcx.type_op_prove_predicate(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, ()>, + v: &'a CanonicalizedQueryResponse<'tcx, ()>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } diff --git a/src/librustc/traits/query/type_op/subtype.rs b/src/librustc/traits/query/type_op/subtype.rs index a2f47211f4828..71c74999c2762 100644 --- a/src/librustc/traits/query/type_op/subtype.rs +++ b/src/librustc/traits/query/type_op/subtype.rs @@ -17,10 +17,10 @@ impl<'tcx> Subtype<'tcx> { } } -impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> { +impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> { type QueryResponse = (); - fn try_fast_path(_tcx: TyCtxt<'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> { + fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> { if key.value.sub == key.value.sup { Some(()) } else { @@ -29,14 +29,14 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> { } fn perform_query( - tcx: TyCtxt<'gcx, 'tcx>, - canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + tcx: TyCtxt<'tcx>, + canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { tcx.type_op_subtype(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResponse<'gcx, ()>, + v: &'a CanonicalizedQueryResponse<'tcx, ()>, ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 57a361d469eff..329a243d2d7f2 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -50,15 +50,15 @@ use std::iter; use std::rc::Rc; use crate::util::nodemap::{FxHashMap, FxHashSet}; -pub struct SelectionContext<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +pub struct SelectionContext<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, /// Freshener used specifically for entries on the obligation /// stack. This ensures that all entries on the stack at one time /// will have the same set of placeholder entries, which is /// important for checking for trait bounds that recursively /// require themselves. - freshener: TypeFreshener<'cx, 'gcx, 'tcx>, + freshener: TypeFreshener<'cx, 'tcx>, /// If `true`, indicates that the evaluation should be conservative /// and consider the possibility of types outside this crate. @@ -300,7 +300,7 @@ enum SelectionCandidate<'tcx> { impl<'a, 'tcx> ty::Lift<'tcx> for SelectionCandidate<'a> { type Lifted = SelectionCandidate<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { Some(match *self { BuiltinCandidate { has_nested } => BuiltinCandidate { has_nested }, ImplCandidate(def_id) => ImplCandidate(def_id), @@ -487,8 +487,8 @@ pub struct EvaluationCache<'tcx> { hashmap: Lock, WithDepNode>>, } -impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { - pub fn new(infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>) -> SelectionContext<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { + pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> { SelectionContext { infcx, freshener: infcx.freshener(), @@ -500,9 +500,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } pub fn intercrate( - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + infcx: &'cx InferCtxt<'cx, 'tcx>, mode: IntercrateMode, - ) -> SelectionContext<'cx, 'gcx, 'tcx> { + ) -> SelectionContext<'cx, 'tcx> { debug!("intercrate({:?})", mode); SelectionContext { infcx, @@ -515,9 +515,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } pub fn with_negative( - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + infcx: &'cx InferCtxt<'cx, 'tcx>, allow_negative_impls: bool, - ) -> SelectionContext<'cx, 'gcx, 'tcx> { + ) -> SelectionContext<'cx, 'tcx> { debug!("with_negative({:?})", allow_negative_impls); SelectionContext { infcx, @@ -530,9 +530,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { } pub fn with_query_mode( - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + infcx: &'cx InferCtxt<'cx, 'tcx>, query_mode: TraitQueryMode, - ) -> SelectionContext<'cx, 'gcx, 'tcx> { + ) -> SelectionContext<'cx, 'tcx> { debug!("with_query_mode({:?})", query_mode); SelectionContext { infcx, @@ -564,15 +564,15 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { self.intercrate_ambiguity_causes.take().unwrap_or(vec![]) } - pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'gcx, 'tcx> { + pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'tcx> { self.infcx } - pub fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + pub fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } - pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'gcx, 'tcx> { + pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'tcx> { self.infcx } @@ -3989,7 +3989,7 @@ impl WithDepNode { } } - pub fn get(&self, tcx: TyCtxt<'_, '_>) -> T { + pub fn get(&self, tcx: TyCtxt<'_>) -> T { tcx.dep_graph.read_index(self.dep_node); self.cached_value.clone() } diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 27891bed2b76e..3f1fcea35a050 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -69,7 +69,7 @@ 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, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, +pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, source_impl: DefId, source_substs: SubstsRef<'tcx>, @@ -110,7 +110,7 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, /// that impl, a less specialized impl, or the trait default, /// whichever applies. pub fn find_associated_item<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, item: &ty::AssocItem, substs: SubstsRef<'tcx>, @@ -150,7 +150,7 @@ pub fn find_associated_item<'tcx>( /// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies /// to. pub(super) fn specializes<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, (impl1_def_id, impl2_def_id): (DefId, DefId), ) -> bool { debug!("specializes({:?}, {:?})", impl1_def_id, impl2_def_id); @@ -209,7 +209,7 @@ 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, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, +fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, source_trait_ref: ty::TraitRef<'tcx>, target_impl: DefId) @@ -286,7 +286,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, // Query provider for `specialization_graph_of`. pub(super) fn specialization_graph_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_id: DefId, ) -> &'tcx specialization_graph::Graph { let mut sg = specialization_graph::Graph::new(); @@ -390,7 +390,7 @@ pub(super) fn specialization_graph_provider<'tcx>( /// Recovers the "impl X for Y" signature from `impl_def_id` and returns it as a /// string. -fn to_pretty_impl_header(tcx: TyCtxt<'_, '_>, impl_def_id: DefId) -> Option { +fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option { use std::fmt::Write; let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) { diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index 2e86d40a3ad54..a6eae6da922f6 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -81,9 +81,9 @@ enum Inserted { ShouldRecurseOn(DefId), } -impl<'gcx, 'tcx> Children { +impl<'tcx> Children { /// Insert an impl into this set of children without comparing to any existing impls. - fn insert_blindly(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) { + fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) { let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) { debug!("insert_blindly: impl_def_id={:?} sty={:?}", impl_def_id, sty); @@ -97,7 +97,7 @@ impl<'gcx, 'tcx> Children { /// Removes an impl from this set of children. Used when replacing /// an impl with a parent. The impl must be present in the list of /// children already. - fn remove_existing(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) { + fn remove_existing(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) { let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); let vec: &mut Vec; if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) { @@ -116,7 +116,7 @@ impl<'gcx, 'tcx> Children { /// specialization relationships. fn insert( &mut self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_def_id: DefId, simplified_self: Option, ) -> Result { @@ -278,7 +278,7 @@ impl Iterator for PotentialSiblings } } -impl<'gcx, 'tcx> Graph { +impl<'tcx> Graph { pub fn new() -> Graph { Graph { parent: Default::default(), @@ -291,7 +291,7 @@ impl<'gcx, 'tcx> Graph { /// information about the area of overlap is returned in the `Err`. pub fn insert( &mut self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_def_id: DefId, ) -> Result, OverlapError> { assert!(impl_def_id.is_local()); @@ -385,7 +385,7 @@ impl<'gcx, 'tcx> Graph { /// Insert cached metadata mapping from a child impl back to its parent. pub fn record_impl_from_cstore( &mut self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, parent: DefId, child: DefId, ) { @@ -413,7 +413,7 @@ pub enum Node { Trait(DefId), } -impl<'gcx, 'tcx> Node { +impl<'tcx> Node { pub fn is_from_trait(&self) -> bool { match *self { Node::Trait(..) => true, @@ -422,7 +422,7 @@ impl<'gcx, 'tcx> Node { } /// Iterate over the items defined directly by the given (impl or trait) node. - pub fn items(&self, tcx: TyCtxt<'gcx, 'tcx>) -> ty::AssocItemsIterator<'gcx, 'tcx> { + pub fn items(&self, tcx: TyCtxt<'tcx>) -> ty::AssocItemsIterator<'tcx> { tcx.associated_items(self.def_id()) } @@ -471,18 +471,18 @@ impl NodeItem { } } -impl<'gcx, 'tcx> Ancestors<'gcx> { +impl<'tcx> Ancestors<'tcx> { /// Search the items from the given ancestors, returning each definition /// with the given name and the given kind. // FIXME(#35870): avoid closures being unexported due to `impl Trait`. #[inline] pub fn defs( self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_item_name: Ident, trait_item_kind: ty::AssocKind, trait_def_id: DefId, - ) -> impl Iterator> + Captures<'gcx> + 'tcx { + ) -> impl Iterator> + Captures<'tcx> + 'tcx { self.flat_map(move |node| { use crate::ty::AssocKind::*; node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) { @@ -505,7 +505,7 @@ impl<'gcx, 'tcx> Ancestors<'gcx> { /// Walk up the specialization ancestors of a given impl, starting with that /// impl itself. pub fn ancestors( - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, start_from_impl: DefId, ) -> Ancestors<'tcx> { diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index e919f0ed2b4d6..129a400d28f4c 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -446,7 +446,7 @@ impl<'tcx> fmt::Display for traits::Clause<'tcx> { impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> { type Lifted = traits::SelectionError<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { super::Unimplemented => Some(super::Unimplemented), super::OutputTypeParameterMismatch(a, b, ref err) => { @@ -464,7 +464,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> { impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { type Lifted = traits::ObligationCauseCode<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { super::ReturnNoExpression => Some(super::ReturnNoExpression), super::MiscObligation => Some(super::MiscObligation), @@ -546,7 +546,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> { type Lifted = traits::DerivedObligationCause<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.parent_trait_ref).and_then(|trait_ref| tcx.lift(&*self.parent_code) .map(|code| traits::DerivedObligationCause { @@ -559,7 +559,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> { impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCause<'a> { type Lifted = traits::ObligationCause<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.code).map(|code| traits::ObligationCause { span: self.span, body_id: self.body_id, @@ -571,7 +571,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCause<'a> { // For codegen only. impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> { type Lifted = traits::Vtable<'tcx, ()>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match self.clone() { traits::VtableImpl(traits::VtableImplData { impl_def_id, @@ -691,7 +691,7 @@ EnumLiftImpl! { impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> { type Lifted = traits::Environment<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.clauses).map(|clauses| { traits::Environment { clauses, @@ -702,7 +702,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> { impl<'a, 'tcx, G: Lift<'tcx>> Lift<'tcx> for traits::InEnvironment<'a, G> { type Lifted = traits::InEnvironment<'tcx, G::Lifted>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.environment).and_then(|environment| { tcx.lift(&self.goal).map(|goal| { traits::InEnvironment { @@ -721,7 +721,7 @@ where { type Lifted = C::LiftedExClause; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { ::lift_ex_clause_to_tcx(self, tcx) } } @@ -733,7 +733,7 @@ where { type Lifted = C::LiftedDelayedLiteral; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { ::lift_delayed_literal_to_tcx(self, tcx) } } @@ -745,7 +745,7 @@ where { type Lifted = C::LiftedLiteral; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { ::lift_literal_to_tcx(self, tcx) } } @@ -754,7 +754,7 @@ where // TypeFoldable implementations. impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { traits::Obligation { cause: self.cause.clone(), recursion_depth: self.recursion_depth, @@ -887,7 +887,7 @@ EnumTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) .collect::>(); @@ -900,7 +900,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { } impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = (**self).fold_with(folder); folder.tcx().mk_goal(v) } @@ -941,7 +941,7 @@ BraceStructTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for traits::Clauses<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) .collect::>(); @@ -959,7 +959,7 @@ where C::Substitution: Clone, C::RegionConstraint: Clone, { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { ::fold_ex_clause_with( self, folder, diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index c5ff174e94436..c74913434262e 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -12,8 +12,8 @@ use crate::util::nodemap::FxHashSet; use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized}; -fn anonymize_predicate<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn anonymize_predicate<'tcx>( + tcx: TyCtxt<'tcx>, pred: &ty::Predicate<'tcx>, ) -> ty::Predicate<'tcx> { match *pred { @@ -46,13 +46,13 @@ fn anonymize_predicate<'gcx, 'tcx>( } } -struct PredicateSet<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct PredicateSet<'tcx> { + tcx: TyCtxt<'tcx>, set: FxHashSet>, } -impl PredicateSet<'gcx, 'tcx> { - fn new(tcx: TyCtxt<'gcx, 'tcx>) -> Self { +impl PredicateSet<'tcx> { + fn new(tcx: TyCtxt<'tcx>) -> Self { Self { tcx: tcx, set: Default::default() } } @@ -71,7 +71,7 @@ impl PredicateSet<'gcx, 'tcx> { } } -impl>> Extend for PredicateSet<'gcx, 'tcx> { +impl>> Extend for PredicateSet<'tcx> { fn extend>(&mut self, iter: I) { for pred in iter { self.insert(pred.as_ref()); @@ -89,36 +89,36 @@ impl>> Extend for PredicateSet<'gcx, 'tcx> { /// if we know that `T: Ord`, the elaborator would deduce that `T: PartialOrd` /// holds as well. Similarly, if we have `trait Foo: 'static`, and we know that /// `T: Foo`, then we know that `T: 'static`. -pub struct Elaborator<'gcx, 'tcx> { +pub struct Elaborator<'tcx> { stack: Vec>, - visited: PredicateSet<'gcx, 'tcx>, + visited: PredicateSet<'tcx>, } -pub fn elaborate_trait_ref<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn elaborate_trait_ref<'tcx>( + tcx: TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, -) -> Elaborator<'gcx, 'tcx> { +) -> Elaborator<'tcx> { elaborate_predicates(tcx, vec![trait_ref.to_predicate()]) } -pub fn elaborate_trait_refs<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn elaborate_trait_refs<'tcx>( + tcx: TyCtxt<'tcx>, trait_refs: impl Iterator>, -) -> Elaborator<'gcx, 'tcx> { +) -> Elaborator<'tcx> { let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect(); elaborate_predicates(tcx, predicates) } -pub fn elaborate_predicates<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn elaborate_predicates<'tcx>( + tcx: TyCtxt<'tcx>, mut predicates: Vec>, -) -> Elaborator<'gcx, 'tcx> { +) -> Elaborator<'tcx> { let mut visited = PredicateSet::new(tcx); predicates.retain(|pred| visited.insert(pred)); Elaborator { stack: predicates, visited } } -impl Elaborator<'gcx, 'tcx> { +impl Elaborator<'tcx> { pub fn filter_to_traits(self) -> FilterToTraits { FilterToTraits::new(self) } @@ -230,7 +230,7 @@ impl Elaborator<'gcx, 'tcx> { } } -impl Iterator for Elaborator<'gcx, 'tcx> { +impl Iterator for Elaborator<'tcx> { type Item = ty::Predicate<'tcx>; fn size_hint(&self) -> (usize, Option) { @@ -252,19 +252,19 @@ impl Iterator for Elaborator<'gcx, 'tcx> { // Supertrait iterator /////////////////////////////////////////////////////////////////////////// -pub type Supertraits<'gcx, 'tcx> = FilterToTraits>; +pub type Supertraits<'tcx> = FilterToTraits>; -pub fn supertraits<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn supertraits<'tcx>( + tcx: TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, -) -> Supertraits<'gcx, 'tcx> { +) -> Supertraits<'tcx> { elaborate_trait_ref(tcx, trait_ref).filter_to_traits() } -pub fn transitive_bounds<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn transitive_bounds<'tcx>( + tcx: TyCtxt<'tcx>, bounds: impl Iterator>, -) -> Supertraits<'gcx, 'tcx> { +) -> Supertraits<'tcx> { elaborate_trait_refs(tcx, bounds).filter_to_traits() } @@ -280,8 +280,8 @@ pub fn transitive_bounds<'gcx, 'tcx>( /// `Read + Write + Sync + Send`. /// Expansion is done via a DFS (depth-first search), and the `visited` field /// is used to avoid cycles. -pub struct TraitAliasExpander<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct TraitAliasExpander<'tcx> { + tcx: TyCtxt<'tcx>, stack: Vec>, } @@ -337,10 +337,10 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> { } } -pub fn expand_trait_aliases<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn expand_trait_aliases<'tcx>( + tcx: TyCtxt<'tcx>, trait_refs: impl IntoIterator, Span)>, -) -> TraitAliasExpander<'gcx, 'tcx> { +) -> TraitAliasExpander<'tcx> { let items: Vec<_> = trait_refs .into_iter() .map(|(trait_ref, span)| TraitAliasExpansionInfo::new(trait_ref, span)) @@ -348,7 +348,7 @@ pub fn expand_trait_aliases<'gcx, 'tcx>( TraitAliasExpander { tcx, stack: items } } -impl<'gcx, 'tcx> TraitAliasExpander<'gcx, 'tcx> { +impl<'tcx> TraitAliasExpander<'tcx> { /// If `item` is a trait alias and its predicate has not yet been visited, then expands `item` /// to the definition, pushes the resulting expansion onto `self.stack`, and returns `false`. /// Otherwise, immediately returns `true` if `item` is a regular trait, or `false` if it is a @@ -393,7 +393,7 @@ impl<'gcx, 'tcx> TraitAliasExpander<'gcx, 'tcx> { } } -impl<'gcx, 'tcx> Iterator for TraitAliasExpander<'gcx, 'tcx> { +impl<'tcx> Iterator for TraitAliasExpander<'tcx> { type Item = TraitAliasExpansionInfo<'tcx>; fn size_hint(&self) -> (usize, Option) { @@ -414,16 +414,16 @@ impl<'gcx, 'tcx> Iterator for TraitAliasExpander<'gcx, 'tcx> { // Iterator over def-IDs of supertraits /////////////////////////////////////////////////////////////////////////// -pub struct SupertraitDefIds<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct SupertraitDefIds<'tcx> { + tcx: TyCtxt<'tcx>, stack: Vec, visited: FxHashSet, } -pub fn supertrait_def_ids<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn supertrait_def_ids<'tcx>( + tcx: TyCtxt<'tcx>, trait_def_id: DefId, -) -> SupertraitDefIds<'gcx, 'tcx> { +) -> SupertraitDefIds<'tcx> { SupertraitDefIds { tcx, stack: vec![trait_def_id], @@ -431,7 +431,7 @@ pub fn supertrait_def_ids<'gcx, 'tcx>( } } -impl Iterator for SupertraitDefIds<'gcx, 'tcx> { +impl Iterator for SupertraitDefIds<'tcx> { type Item = DefId; fn next(&mut self) -> Option { @@ -489,7 +489,7 @@ impl<'tcx, I: Iterator>> 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, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, '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>,) @@ -552,7 +552,7 @@ pub fn predicate_for_trait_ref<'tcx>( } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn predicate_for_trait_def(self, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, diff --git a/src/librustc/ty/_match.rs b/src/librustc/ty/_match.rs index 213f556f9acac..6e10dc03a2869 100644 --- a/src/librustc/ty/_match.rs +++ b/src/librustc/ty/_match.rs @@ -19,19 +19,19 @@ use crate::mir::interpret::ConstValue; /// Like subtyping, matching is really a binary relation, so the only /// important thing about the result is Ok/Err. Also, matching never /// affects any type variables or unification state. -pub struct Match<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct Match<'tcx> { + tcx: TyCtxt<'tcx>, } -impl Match<'gcx, 'tcx> { - pub fn new(tcx: TyCtxt<'gcx, 'tcx>) -> Match<'gcx, 'tcx> { +impl Match<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>) -> Match<'tcx> { Match { tcx } } } -impl TypeRelation<'gcx, 'tcx> for Match<'gcx, 'tcx> { +impl TypeRelation<'tcx> for Match<'tcx> { fn tag(&self) -> &'static str { "Match" } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.tcx } + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } fn a_is_expected(&self) -> bool { true } // irrelevant fn relate_with_variance>(&mut self, diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index e1f86bee4babb..2a228ed79a484 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -103,10 +103,10 @@ pub struct OverloadedDeref<'tcx> { pub mutbl: hir::Mutability, } -impl<'gcx, 'tcx> OverloadedDeref<'tcx> { +impl<'tcx> OverloadedDeref<'tcx> { pub fn method_call( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: Ty<'tcx>, ) -> (DefId, SubstsRef<'tcx>) { let trait_def_id = match self.mutbl { diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index ea5d088d540fd..224f7d5f28dc3 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -108,7 +108,7 @@ pub fn encode_predicates<'tcx, E, C>(encoder: &mut E, } pub trait TyDecoder<'tcx>: Decoder { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx>; + fn tcx(&self) -> TyCtxt<'tcx>; fn peek_byte(&self) -> u8; diff --git a/src/librustc/ty/constness.rs b/src/librustc/ty/constness.rs index 466cb353c85e4..65b83224ae521 100644 --- a/src/librustc/ty/constness.rs +++ b/src/librustc/ty/constness.rs @@ -6,7 +6,7 @@ use syntax_pos::symbol::{sym, Symbol}; use crate::hir::map::blocks::FnLikeNode; use syntax::attr; -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Whether the `def_id` counts as const fn in your current crate, considering all active /// feature gates pub fn is_const_fn(self, def_id: DefId) -> bool { @@ -69,7 +69,7 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> { pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { /// only checks whether the function has a `const` modifier - fn is_const_fn_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { + fn is_const_fn_raw<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { let hir_id = tcx.hir().as_local_hir_id(def_id) .expect("Non-local call to local provider is_const_fn"); @@ -83,7 +83,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { } } - fn is_promotable_const_fn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { + fn is_promotable_const_fn<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { tcx.is_const_fn(def_id) && match tcx.lookup_stability(def_id) { Some(stab) => { if cfg!(debug_assertions) && stab.promotable { @@ -101,7 +101,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { } } - fn const_fn_is_allowed_fn_ptr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { + fn const_fn_is_allowed_fn_ptr<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { tcx.is_const_fn(def_id) && tcx.lookup_stability(def_id) .map(|stab| stab.allow_const_fn_ptr).unwrap_or(false) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 4e255edfe8563..a28da275ff12e 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -115,7 +115,7 @@ pub struct CtxtInterners<'tcx> { const_: InternedSet<'tcx, Const<'tcx>>, } -impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { +impl<'tcx> CtxtInterners<'tcx> { fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> { CtxtInterners { arena, @@ -137,8 +137,8 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { /// Intern a type #[inline(never)] fn intern_ty( - local: &CtxtInterners<'gcx>, - global: &CtxtInterners<'gcx>, + local: &CtxtInterners<'tcx>, + global: &CtxtInterners<'tcx>, st: TyKind<'tcx> ) -> Ty<'tcx> { let flags = super::flags::FlagComputation::for_sty(&st); @@ -164,7 +164,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { // This is safe because all the types the ty_struct can point to // already is in the local arena or the global arena - let ty_struct: TyS<'gcx> = unsafe { + let ty_struct: TyS<'tcx> = unsafe { mem::transmute(ty_struct) }; @@ -180,7 +180,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { // This is safe because all the types the ty_struct can point to // already is in the global arena - let ty_struct: TyS<'gcx> = unsafe { + let ty_struct: TyS<'tcx> = unsafe { mem::transmute(ty_struct) }; @@ -750,7 +750,7 @@ impl<'tcx> TypeckTables<'tcx> { } -impl<'a, 'gcx> HashStable> for TypeckTables<'gcx> { +impl<'a, 'tcx> HashStable> for TypeckTables<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { @@ -859,9 +859,9 @@ BraceStructLiftImpl! { /// Canonicalized user type annotation. -pub type CanonicalUserType<'gcx> = Canonical<'gcx, UserType<'gcx>>; +pub type CanonicalUserType<'tcx> = Canonical<'tcx, UserType<'tcx>>; -impl CanonicalUserType<'gcx> { +impl CanonicalUserType<'tcx> { /// Returns `true` if this represents a substitution of the form `[?0, ?1, ?2]`, /// i.e., each thing is mapped to a canonical variable with the same index. pub fn is_identity(&self) -> bool { @@ -1016,14 +1016,14 @@ pub struct FreeRegionInfo { /// /// [rustc guide]: https://rust-lang.github.io/rustc-guide/ty.html #[derive(Copy, Clone)] -pub struct TyCtxt<'gcx: 'tcx, 'tcx> { - gcx: &'gcx GlobalCtxt<'gcx>, - interners: &'gcx CtxtInterners<'gcx>, +pub struct TyCtxt<'tcx> { + gcx: &'tcx GlobalCtxt<'tcx>, + interners: &'tcx CtxtInterners<'tcx>, dummy: PhantomData<&'tcx ()>, } -impl<'gcx> Deref for TyCtxt<'gcx, '_> { - type Target = &'gcx GlobalCtxt<'gcx>; +impl<'tcx> Deref for TyCtxt<'tcx> { + type Target = &'tcx GlobalCtxt<'tcx>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.gcx @@ -1119,10 +1119,10 @@ pub struct GlobalCtxt<'tcx> { output_filenames: Arc, } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Gets the global `TyCtxt`. #[inline] - pub fn global_tcx(self) -> TyCtxt<'gcx, 'gcx> { + pub fn global_tcx(self) -> TyCtxt<'tcx> { TyCtxt { gcx: self.gcx, interners: &self.gcx.global_interners, @@ -1131,11 +1131,11 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } #[inline(always)] - pub fn hir(self) -> &'tcx hir_map::Map<'gcx> { + pub fn hir(self) -> &'tcx hir_map::Map<'tcx> { &self.hir_map } - pub fn alloc_steal_mir(self, mir: Body<'gcx>) -> &'gcx Steal> { + pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal> { self.arena.alloc(Steal::new(mir)) } @@ -1144,12 +1144,12 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { kind: AdtKind, variants: IndexVec, repr: ReprOptions) - -> &'gcx ty::AdtDef { + -> &'tcx ty::AdtDef { let def = ty::AdtDef::new(self, did, kind, variants, repr); self.arena.alloc(def) } - pub fn intern_const_alloc(self, alloc: Allocation) -> &'gcx Allocation { + pub fn intern_const_alloc(self, alloc: Allocation) -> &'tcx Allocation { self.allocation_interner.borrow_mut().intern(alloc, |alloc| { self.arena.alloc(alloc) }) @@ -1163,13 +1163,13 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { self.alloc_map.lock().create_memory_alloc(alloc) } - pub fn intern_stability(self, stab: attr::Stability) -> &'gcx attr::Stability { + pub fn intern_stability(self, stab: attr::Stability) -> &'tcx attr::Stability { self.stability_interner.borrow_mut().intern(stab, |stab| { self.arena.alloc(stab) }) } - pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails { + pub fn intern_layout(self, layout: LayoutDetails) -> &'tcx LayoutDetails { self.layout_interner.borrow_mut().intern(layout, |layout| { self.arena.alloc(layout) }) @@ -1201,7 +1201,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } /// Like lift, but only tries in the global tcx. - pub fn lift_to_global>(self, value: &T) -> Option { + pub fn lift_to_global>(self, value: &T) -> Option { value.lift_to_tcx(self.global_tcx()) } @@ -1343,11 +1343,11 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { self.sess.consider_optimizing(&cname, msg) } - pub fn lib_features(self) -> &'gcx middle::lib_features::LibFeatures { + pub fn lib_features(self) -> &'tcx middle::lib_features::LibFeatures { self.get_lib_features(LOCAL_CRATE) } - pub fn lang_items(self) -> &'gcx middle::lang_items::LanguageItems { + pub fn lang_items(self) -> &'tcx middle::lang_items::LanguageItems { self.get_lang_items(LOCAL_CRATE) } @@ -1385,15 +1385,15 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { else { None } } - pub fn stability(self) -> &'gcx stability::Index<'gcx> { + pub fn stability(self) -> &'tcx stability::Index<'tcx> { self.stability_index(LOCAL_CRATE) } - pub fn crates(self) -> &'gcx [CrateNum] { + pub fn crates(self) -> &'tcx [CrateNum] { self.all_crate_nums(LOCAL_CRATE) } - pub fn features(self) -> &'gcx feature_gate::Features { + pub fn features(self) -> &'tcx feature_gate::Features { self.features_query(LOCAL_CRATE) } @@ -1666,7 +1666,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn encode_metadata(self) -> EncodedMetadata { @@ -1674,14 +1674,13 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> { } } -impl<'gcx> GlobalCtxt<'gcx> { +impl<'tcx> GlobalCtxt<'tcx> { /// Call the closure with a local `TyCtxt` using the given arena. /// `interners` is a slot passed so we can create a CtxtInterners /// with the same lifetime as `arena`. - pub fn enter_local<'tcx, F, R>(&'gcx self, f: F) -> R + pub fn enter_local(&'tcx self, f: F) -> R where - F: FnOnce(TyCtxt<'gcx, 'tcx>) -> R, - 'gcx: 'tcx, + F: FnOnce(TyCtxt<'tcx>) -> R, { let tcx = TyCtxt { gcx: self, @@ -1722,7 +1721,7 @@ impl<'gcx> GlobalCtxt<'gcx> { /// e.g., `()` or `u8`, was interned in a different context. pub trait Lift<'tcx>: fmt::Debug { type Lifted: fmt::Debug + 'tcx; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option; + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option; } @@ -1730,7 +1729,7 @@ macro_rules! nop_lift { ($ty:ty => $lifted:ty) => { impl<'a, 'tcx> Lift<'tcx> for $ty { type Lifted = $lifted; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -1749,7 +1748,7 @@ macro_rules! nop_list_lift { ($ty:ty => $lifted:ty) => { impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> { type Lifted = &'tcx List<$lifted>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { if self.is_empty() { return Some(List::empty()); } @@ -1809,14 +1808,14 @@ pub mod tls { /// you should also have access to an ImplicitCtxt through the functions /// in this module. #[derive(Clone)] - pub struct ImplicitCtxt<'a, 'gcx: 'tcx, 'tcx> { + pub struct ImplicitCtxt<'a, 'tcx> { /// The current TyCtxt. Initially created by `enter_global` and updated /// by `enter_local` with a new local interner - pub tcx: TyCtxt<'gcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, /// The current query job, if any. This is updated by JobOwner::start in /// ty::query::plumbing when executing a query - pub query: Option>>, + pub query: Option>>, /// Where to store diagnostics for the current query job, if any. /// This is updated by JobOwner::start in ty::query::plumbing when executing a query @@ -1924,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, 'gcx: 'tcx, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'gcx, 'tcx>, + pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, f: F) -> R - where F: FnOnce(&ImplicitCtxt<'a, 'gcx, 'tcx>) -> R + where F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R { set_tlv(context as *const _ as usize, || { f(&context) @@ -1937,9 +1936,9 @@ pub mod tls { /// creating a initial TyCtxt and ImplicitCtxt. /// This happens once per rustc session and TyCtxts only exists /// inside the `f` function. - pub fn enter_global<'gcx, F, R>(gcx: &'gcx GlobalCtxt<'gcx>, f: F) -> R + pub fn enter_global<'tcx, F, R>(gcx: &'tcx GlobalCtxt<'tcx>, f: F) -> R where - F: FnOnce(TyCtxt<'gcx, 'gcx>) -> R, + F: FnOnce(TyCtxt<'tcx>) -> R, { // Update GCX_PTR to indicate there's a GlobalCtxt available GCX_PTR.with(|lock| { @@ -1977,7 +1976,7 @@ pub mod tls { /// This is used in the deadlock handler. pub unsafe fn with_global(f: F) -> R where - F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R, + F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> R, { let gcx = GCX_PTR.with(|lock| *lock.lock()); assert!(gcx != 0); @@ -2000,7 +1999,7 @@ pub mod tls { /// Allows access to the current ImplicitCtxt in a closure if one is available #[inline] pub fn with_context_opt(f: F) -> R - where F: for<'a, 'gcx, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'gcx, 'tcx>>) -> R + where F: for<'a, 'tcx> FnOnce(Option<&ImplicitCtxt<'a, 'tcx>>) -> R { let context = get_tlv(); if context == 0 { @@ -2008,9 +2007,9 @@ pub mod tls { } else { // We could get a ImplicitCtxt pointer from another thread. // Ensure that ImplicitCtxt is Sync - sync::assert_sync::>(); + sync::assert_sync::>(); - unsafe { f(Some(&*(context as *const ImplicitCtxt<'_, '_, '_>))) } + unsafe { f(Some(&*(context as *const ImplicitCtxt<'_, '_>))) } } } @@ -2018,25 +2017,25 @@ pub mod tls { /// Panics if there is no ImplicitCtxt available #[inline] pub fn with_context(f: F) -> R - where F: for<'a, 'gcx, 'tcx> FnOnce(&ImplicitCtxt<'a, 'gcx, '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"))) } /// Allows access to the current ImplicitCtxt whose tcx field has the same global /// interner as the tcx argument passed in. This means the closure is given an ImplicitCtxt - /// with the same 'gcx lifetime as the TyCtxt passed in. + /// with the same 'tcx lifetime as the TyCtxt passed in. /// This will panic if you pass it a TyCtxt which has a different global interner from /// the current ImplicitCtxt's tcx field. #[inline] - pub fn with_related_context<'gcx, 'tcx1, F, R>(tcx: TyCtxt<'gcx, 'tcx1>, f: F) -> R + pub fn with_related_context<'tcx, F, R>(tcx: TyCtxt<'tcx>, f: F) -> R where - F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R, + F: FnOnce(&ImplicitCtxt<'_, 'tcx>) -> R, { with_context(|context| { unsafe { assert!(ptr_eq(context.tcx.gcx, tcx.gcx)); - let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context); + let context: &ImplicitCtxt<'_, '_> = mem::transmute(context); f(context) } }) @@ -2044,19 +2043,19 @@ pub mod tls { /// Allows access to the current ImplicitCtxt whose tcx field has the same global /// interner and local interner as the tcx argument passed in. This means the closure - /// is given an ImplicitCtxt with the same 'tcx and 'gcx lifetimes as the TyCtxt passed in. + /// is given an ImplicitCtxt with the same 'tcx and 'tcx lifetimes as the TyCtxt passed in. /// This will panic if you pass it a TyCtxt which has a different global interner or /// a different local interner from the current ImplicitCtxt's tcx field. #[inline] - pub fn with_fully_related_context<'gcx, 'tcx, F, R>(tcx: TyCtxt<'gcx, 'tcx>, f: F) -> R + pub fn with_fully_related_context<'tcx, F, R>(tcx: TyCtxt<'tcx>, f: F) -> R where - F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R, + F: for<'b> FnOnce(&ImplicitCtxt<'b, 'tcx>) -> R, { with_context(|context| { unsafe { assert!(ptr_eq(context.tcx.gcx, tcx.gcx)); assert!(ptr_eq(context.tcx.interners, tcx.interners)); - let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context); + let context: &ImplicitCtxt<'_, '_> = mem::transmute(context); f(context) } }) @@ -2067,7 +2066,7 @@ pub mod tls { #[inline] pub fn with(f: F) -> R where - F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R, + F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> R, { with_context(|context| f(context.tcx)) } @@ -2077,7 +2076,7 @@ pub mod tls { #[inline] pub fn with_opt(f: F) -> R where - F: for<'gcx, 'tcx> FnOnce(Option>) -> R, + F: for<'tcx> FnOnce(Option>) -> R, { with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx))) } @@ -2101,7 +2100,7 @@ macro_rules! sty_debug_print { all_infer: usize, } - pub fn go(tcx: TyCtxt<'_, '_>) { + pub fn go(tcx: TyCtxt<'_>) { let mut total = DebugStat { total: 0, lt_infer: 0, @@ -2154,7 +2153,7 @@ macro_rules! sty_debug_print { }} } -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn print_debug_stats(self) { sty_debug_print!( self, @@ -2196,8 +2195,8 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> { } } -impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, TyS<'tcx>> { - fn borrow<'a>(&'a self) -> &'a TyKind<'lcx> { +impl<'tcx> Borrow> for Interned<'tcx, TyS<'tcx>> { + fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> { &self.0.sty } } @@ -2217,20 +2216,20 @@ impl<'tcx, T: Hash> Hash for Interned<'tcx, List> { } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, List>> { - fn borrow<'a>(&'a self) -> &'a [Ty<'lcx>] { +impl<'tcx> Borrow<[Ty<'tcx>]> for Interned<'tcx, List>> { + fn borrow<'a>(&'a self) -> &'a [Ty<'tcx>] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List> { +impl<'tcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List> { fn borrow<'a>(&'a self) -> &'a [CanonicalVarInfo] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, InternalSubsts<'tcx>> { - fn borrow<'a>(&'a self) -> &'a [Kind<'lcx>] { +impl<'tcx> Borrow<[Kind<'tcx>]> for Interned<'tcx, InternalSubsts<'tcx>> { + fn borrow<'a>(&'a self) -> &'a [Kind<'tcx>] { &self.0[..] } } @@ -2248,42 +2247,42 @@ impl<'tcx> Borrow for Interned<'tcx, RegionKind> { } } -impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, GoalKind<'tcx>> { - fn borrow<'a>(&'a self) -> &'a GoalKind<'lcx> { +impl<'tcx> Borrow> for Interned<'tcx, GoalKind<'tcx>> { + fn borrow<'a>(&'a self) -> &'a GoalKind<'tcx> { &self.0 } } -impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]> +impl<'tcx> Borrow<[ExistentialPredicate<'tcx>]> for Interned<'tcx, List>> { - fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] { + fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'tcx>] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Predicate<'lcx>]> +impl<'tcx> Borrow<[Predicate<'tcx>]> for Interned<'tcx, List>> { - fn borrow<'a>(&'a self) -> &'a [Predicate<'lcx>] { + fn borrow<'a>(&'a self) -> &'a [Predicate<'tcx>] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, Const<'tcx>> { - fn borrow<'a>(&'a self) -> &'a Const<'lcx> { +impl<'tcx> Borrow> for Interned<'tcx, Const<'tcx>> { + fn borrow<'a>(&'a self) -> &'a Const<'tcx> { &self.0 } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Clause<'lcx>]> +impl<'tcx> Borrow<[Clause<'tcx>]> for Interned<'tcx, List>> { - fn borrow<'a>(&'a self) -> &'a [Clause<'lcx>] { + fn borrow<'a>(&'a self) -> &'a [Clause<'tcx>] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Goal<'lcx>]> +impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List>> { - fn borrow<'a>(&'a self) -> &'a [Goal<'lcx>] { + fn borrow<'a>(&'a self) -> &'a [Goal<'tcx>] { &self.0[..] } } @@ -2293,21 +2292,10 @@ macro_rules! intern_method { $alloc_method:expr, $alloc_to_key:expr, $keep_in_local_tcx:expr) -> $ty:ty) => { - impl<'gcx, $lt_tcx> TyCtxt<'gcx, $lt_tcx> { + impl<$lt_tcx> TyCtxt<$lt_tcx> { pub fn $method(self, v: $alloc) -> &$lt_tcx $ty { let key = ($alloc_to_key)(&v); - let alloc = |v, interners: &'gcx CtxtInterners<'gcx>| { - // This transmutes $alloc<'tcx> to $alloc<'gcx> - let v = unsafe { - mem::transmute(v) - }; - let i: &$lt_tcx $ty = $alloc_method(&interners.arena, v); - // Cast to 'gcx - let i = unsafe { mem::transmute(i) }; - Interned(i) - }; - // HACK(eddyb) Depend on flags being accurate to // determine that all contents are in the global tcx. // See comments on Lift for why we can't use that. @@ -2321,11 +2309,11 @@ macro_rules! intern_method { v); } - alloc(v, &self.interners) + Interned($alloc_method(&self.interners.arena, v)) }).0 } else { self.global_interners.$name.borrow_mut().intern_ref(key, || { - alloc(v, &self.global_interners) + Interned($alloc_method(&self.global_interners.arena, v)) }).0 } } @@ -2403,7 +2391,7 @@ intern_method! { ) -> List } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Given a `fn` type, returns an equivalent `unsafe fn` type; /// that is, a `fn` type that is equivalent in every way for being /// unsafe. @@ -2772,7 +2760,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } - pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'gcx> { + pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'tcx> { if ts.len() == 0 { List::empty() } else { @@ -2938,7 +2926,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { lint::struct_lint_level(self.sess, lint, level, src, None, msg) } - pub fn in_scope_traits(self, id: HirId) -> Option<&'gcx StableVec> { + pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx StableVec> { self.in_scope_traits_map(id.owner) .and_then(|map| map.get(&id.local_id)) } @@ -2955,7 +2943,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } pub fn object_lifetime_defaults(self, id: HirId) - -> Option<&'gcx [ObjectLifetimeDefault]> + -> 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/erase_regions.rs b/src/librustc/ty/erase_regions.rs index 330343c250c66..999b4eff85697 100644 --- a/src/librustc/ty/erase_regions.rs +++ b/src/librustc/ty/erase_regions.rs @@ -8,13 +8,13 @@ pub(super) fn provide(providers: &mut ty::query::Providers<'_>) { }; } -fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { +fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { // N.B., use `super_fold_with` here. If we used `fold_with`, it // could invoke the `erase_regions_ty` query recursively. ty.super_fold_with(&mut RegionEraserVisitor { tcx }) } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Returns an equivalent value with all free regions removed (note /// that late-bound regions remain, because they are important for /// subtyping, but they are anonymized and normalized as well).. @@ -32,12 +32,12 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } -struct RegionEraserVisitor<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct RegionEraserVisitor<'tcx> { + tcx: TyCtxt<'tcx>, } -impl TypeFolder<'gcx, 'tcx> for RegionEraserVisitor<'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl TypeFolder<'tcx> for RegionEraserVisitor<'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 000e0854f4e97..d5e0450035038 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -183,8 +183,8 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { } } -impl<'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { - pub fn sort_string(&self, tcx: TyCtxt<'gcx, 'lcx>) -> Cow<'static, str> { +impl<'tcx> ty::TyS<'tcx> { + pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> { match self.sty { ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(), @@ -249,7 +249,7 @@ impl<'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn note_and_explain_type_err(self, db: &mut DiagnosticBuilder<'_>, err: &TypeError<'tcx>, diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index d32ad0f5c6d50..7aab1aef3b895 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -55,8 +55,8 @@ pub enum SimplifiedTypeGen /// then we can't say much about whether two types would unify. Put another way, /// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they /// are to be considered bound. -pub fn simplify_type<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn simplify_type<'tcx>( + tcx: TyCtxt<'tcx>, ty: Ty<'_>, can_simplify_params: bool, ) -> Option { diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index c79dad04df624..9da35824bd0be 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -45,8 +45,8 @@ use crate::util::nodemap::FxHashSet; /// To implement this conveniently, use the /// `BraceStructTypeFoldableImpl` etc macros found in `macros.rs`. pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self; - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self; + fn fold_with>(&self, folder: &mut F) -> Self { self.super_fold_with(folder) } @@ -155,8 +155,8 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { /// default implementation that does an "identity" fold. Within each /// identity fold, it should invoke `foo.fold_with(self)` to fold each /// sub-item. -pub trait TypeFolder<'gcx: 'tcx, 'tcx>: Sized { - fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx>; +pub trait TypeFolder<'tcx>: Sized { + fn tcx<'a>(&'a self) -> TyCtxt<'tcx>; fn fold_binder(&mut self, t: &Binder) -> Binder where T : TypeFoldable<'tcx> @@ -198,25 +198,25 @@ pub trait TypeVisitor<'tcx> : Sized { /////////////////////////////////////////////////////////////////////////// // Some sample folders -pub struct BottomUpFolder<'gcx, 'tcx, F, G, H> +pub struct BottomUpFolder<'tcx, F, G, H> where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>, { - pub tcx: TyCtxt<'gcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub ty_op: F, pub lt_op: G, pub ct_op: H, } -impl<'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'gcx, 'tcx, F, G, H> +impl<'tcx, F, G, H> TypeFolder<'tcx> for BottomUpFolder<'tcx, F, G, H> where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>, { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -239,7 +239,7 @@ where /////////////////////////////////////////////////////////////////////////// // Region folder -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Collects the free and escaping regions in `value` into `region_set`. Returns /// whether any late-bound regions were skipped pub fn collect_regions(self, @@ -365,8 +365,8 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { /// visited by this folder; only regions that occur free will be /// visited by `fld_r`. -pub struct RegionFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct RegionFolder<'a, 'tcx> { + tcx: TyCtxt<'tcx>, skipped_regions: &'a mut bool, /// Stores the index of a binder *just outside* the stuff we have @@ -381,13 +381,13 @@ pub struct RegionFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { &'a mut (dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx> + 'a), } -impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> RegionFolder<'a, 'tcx> { #[inline] pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, skipped_regions: &'a mut bool, fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>, - ) -> RegionFolder<'a, 'gcx, 'tcx> { + ) -> RegionFolder<'a, 'tcx> { RegionFolder { tcx, skipped_regions, @@ -397,8 +397,8 @@ impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -430,8 +430,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> { // Bound vars replacer /// Replaces the escaping bound vars (late bound regions or bound types) in a type. -struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +struct BoundVarReplacer<'a, 'tcx> { + tcx: TyCtxt<'tcx>, /// As with `RegionFolder`, represents the index of a binder *just outside* /// the ones we have visited. @@ -442,9 +442,9 @@ struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { fld_c: &'a mut (dyn FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx> + 'a), } -impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BoundVarReplacer<'a, 'tcx> { fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, fld_r: &'a mut F, fld_t: &'a mut G, fld_c: &'a mut H, @@ -464,8 +464,8 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -549,7 +549,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Replaces all regions bound by the given `Binder` with the /// results returned by the closure; the closure is expected to /// return a free region (relative to this binder), and hence the @@ -729,15 +729,15 @@ enum Direction { Out, } -struct Shifter<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct Shifter<'tcx> { + tcx: TyCtxt<'tcx>, current_index: ty::DebruijnIndex, amount: u32, direction: Direction, } -impl Shifter<'gcx, 'tcx> { - pub fn new(tcx: TyCtxt<'gcx, 'tcx>, amount: u32, direction: Direction) -> Self { +impl Shifter<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>, amount: u32, direction: Direction) -> Self { Shifter { tcx, current_index: ty::INNERMOST, @@ -747,8 +747,8 @@ impl Shifter<'gcx, 'tcx> { } } -impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl TypeFolder<'tcx> for Shifter<'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -826,8 +826,8 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> { } } -pub fn shift_region<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn shift_region<'tcx>( + tcx: TyCtxt<'tcx>, region: ty::Region<'tcx>, amount: u32, ) -> ty::Region<'tcx> { @@ -841,7 +841,7 @@ pub fn shift_region<'gcx, 'tcx>( } } -pub fn shift_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T +pub fn shift_vars<'tcx, T>(tcx: TyCtxt<'tcx>, value: &T, amount: u32) -> T where T: TypeFoldable<'tcx>, { @@ -851,7 +851,7 @@ where value.fold_with(&mut Shifter::new(tcx, amount, Direction::In)) } -pub fn shift_out_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T +pub fn shift_out_vars<'tcx, T>(tcx: TyCtxt<'tcx>, value: &T, amount: u32) -> T where T: TypeFoldable<'tcx>, { diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 023460096a882..b22bd21e9de43 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -21,7 +21,7 @@ pub struct DefIdForest { root_ids: SmallVec<[DefId; 1]>, } -impl<'gcx, 'tcx> DefIdForest { +impl<'tcx> DefIdForest { /// Creates an empty forest. pub fn empty() -> DefIdForest { DefIdForest { @@ -32,7 +32,7 @@ impl<'gcx, 'tcx> DefIdForest { /// Creates a forest consisting of a single tree representing the entire /// crate. #[inline] - pub fn full(tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest { + pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest { let crate_id = tcx.hir().local_def_id(CRATE_NODE_ID); DefIdForest::from_id(crate_id) } @@ -52,12 +52,12 @@ impl<'gcx, 'tcx> DefIdForest { } /// Tests whether the forest contains a given DefId. - pub fn contains(&self, tcx: TyCtxt<'gcx, 'tcx>, id: DefId) -> bool { + pub fn contains(&self, tcx: TyCtxt<'tcx>, id: DefId) -> bool { self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id)) } /// Calculate the intersection of a collection of forests. - pub fn intersection(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest + pub fn intersection(tcx: TyCtxt<'tcx>, iter: I) -> DefIdForest where I: IntoIterator, { @@ -94,7 +94,7 @@ impl<'gcx, 'tcx> DefIdForest { } /// Calculate the union of a collection of forests. - pub fn union(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest + pub fn union(tcx: TyCtxt<'tcx>, iter: I) -> DefIdForest where I: IntoIterator, { diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index b9e34e0cabc65..5ce750849f42d 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -51,7 +51,7 @@ mod def_id_forest; // This code should only compile in modules where the uninhabitedness of Foo is // visible. -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Checks whether a type is visibly uninhabited from a particular module. /// # Example /// ```rust @@ -106,9 +106,9 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } -impl<'gcx, 'tcx> AdtDef { +impl<'tcx> AdtDef { /// Calculate the forest of DefIds from which this adt is visibly uninhabited. - fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> DefIdForest { + fn uninhabited_from(&self, tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>) -> DefIdForest { // Non-exhaustive ADTs from other crates are always considered inhabited. if self.is_variant_list_non_exhaustive() && !self.did.is_local() { DefIdForest::empty() @@ -120,11 +120,11 @@ impl<'gcx, 'tcx> AdtDef { } } -impl<'gcx, 'tcx> VariantDef { +impl<'tcx> VariantDef { /// Calculate the forest of DefIds from which this variant is visibly uninhabited. pub fn uninhabited_from( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, adt_kind: AdtKind, ) -> DefIdForest { @@ -146,11 +146,11 @@ impl<'gcx, 'tcx> VariantDef { } } -impl<'gcx, 'tcx> FieldDef { +impl<'tcx> FieldDef { /// Calculate the forest of DefIds from which this field is visibly uninhabited. fn uninhabited_from( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, is_enum: bool, ) -> DefIdForest { @@ -176,9 +176,9 @@ impl<'gcx, 'tcx> FieldDef { } } -impl<'gcx, 'tcx> TyS<'tcx> { +impl<'tcx> TyS<'tcx> { /// Calculate the forest of DefIds from which this type is visibly uninhabited. - fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest { + fn uninhabited_from(&self, tcx: TyCtxt<'tcx>) -> DefIdForest { match self.sty { Adt(def, substs) => def.uninhabited_from(tcx, substs), diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 16df0da88207b..457d018f017d7 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -43,7 +43,7 @@ pub enum InstanceDef<'tcx> { } impl<'tcx> Instance<'tcx> { - pub fn ty(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> { + pub fn ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { let ty = tcx.type_of(self.def.def_id()); tcx.subst_and_normalize_erasing_regions( self.substs, @@ -52,7 +52,7 @@ impl<'tcx> Instance<'tcx> { ) } - fn fn_sig_noadjust(&self, tcx: TyCtxt<'tcx, 'tcx>) -> PolyFnSig<'tcx> { + fn fn_sig_noadjust(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { let ty = self.ty(tcx); match ty.sty { ty::FnDef(..) | @@ -102,7 +102,7 @@ impl<'tcx> Instance<'tcx> { } } - pub fn fn_sig(&self, tcx: TyCtxt<'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> { + pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { let mut fn_sig = self.fn_sig_noadjust(tcx); if let InstanceDef::VtableShim(..) = self.def { // Modify fn(self, ...) to fn(self: *mut Self, ...) @@ -133,11 +133,11 @@ impl<'tcx> InstanceDef<'tcx> { } #[inline] - pub fn attrs(&self, tcx: TyCtxt<'tcx, 'tcx>) -> ty::Attributes<'tcx> { + pub fn attrs(&self, tcx: TyCtxt<'tcx>) -> ty::Attributes<'tcx> { tcx.get_attrs(self.def_id()) } - pub fn is_inline(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool { + pub fn is_inline(&self, tcx: TyCtxt<'tcx>) -> bool { use crate::hir::map::DefPathData; let def_id = match *self { ty::InstanceDef::Item(def_id) => def_id, @@ -150,7 +150,7 @@ impl<'tcx> InstanceDef<'tcx> { } } - pub fn requires_local(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool { + pub fn requires_local(&self, tcx: TyCtxt<'tcx>) -> bool { if self.is_inline(tcx) { return true } @@ -200,7 +200,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> { } } -impl<'b, 'tcx> Instance<'tcx> { +impl<'tcx> Instance<'tcx> { pub fn new(def_id: DefId, substs: SubstsRef<'tcx>) -> Instance<'tcx> { assert!(!substs.has_escaping_bound_vars(), @@ -209,7 +209,7 @@ impl<'b, 'tcx> Instance<'tcx> { Instance { def: InstanceDef::Item(def_id), substs: substs } } - pub fn mono(tcx: TyCtxt<'tcx, 'b>, def_id: DefId) -> Instance<'tcx> { + pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { Instance::new(def_id, tcx.global_tcx().empty_substs_for_def_id(def_id)) } @@ -237,7 +237,7 @@ impl<'b, 'tcx> Instance<'tcx> { /// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return /// `Some`. pub fn resolve( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, @@ -291,7 +291,7 @@ impl<'b, 'tcx> Instance<'tcx> { } pub fn resolve_for_vtable( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, @@ -312,7 +312,7 @@ impl<'b, 'tcx> Instance<'tcx> { } pub fn resolve_closure( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, substs: ty::ClosureSubsts<'tcx>, requested_kind: ty::ClosureKind, @@ -325,14 +325,14 @@ impl<'b, 'tcx> Instance<'tcx> { } } - pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> { + pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> { let def_id = tcx.require_lang_item(DropInPlaceFnLangItem); let substs = tcx.intern_substs(&[ty.into()]); Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap() } pub fn fn_once_adapter_instance( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, closure_did: DefId, substs: ty::ClosureSubsts<'tcx>, ) -> Instance<'tcx> { @@ -366,7 +366,7 @@ impl<'b, 'tcx> Instance<'tcx> { } fn resolve_associated_item<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_item: &ty::AssocItem, param_env: ty::ParamEnv<'tcx>, trait_id: DefId, diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index efbae81a5dd52..70db4f19a4cdb 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -29,10 +29,10 @@ use rustc_target::abi::call::{ }; pub trait IntegerExt { - fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx>; + fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx>; fn from_attr(cx: &C, ity: attr::IntType) -> Integer; fn repr_discr<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, repr: &ReprOptions, min: i128, @@ -41,7 +41,7 @@ pub trait IntegerExt { } impl IntegerExt for Integer { - fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx> { + fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx> { match (*self, signed) { (I8, false) => tcx.types.u8, (I16, false) => tcx.types.u16, @@ -77,7 +77,7 @@ impl IntegerExt for Integer { /// N.B.: u128 values above i128::MAX will be treated as signed, but /// that shouldn't affect anything, other than maybe debuginfo. fn repr_discr<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, repr: &ReprOptions, min: i128, @@ -126,11 +126,11 @@ impl IntegerExt for Integer { } pub trait PrimitiveExt { - fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx>; + fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>; } impl PrimitiveExt for Primitive { - fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> { + fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match *self { Int(i, signed) => i.to_ty(tcx, signed), Float(FloatTy::F32) => tcx.types.f32, @@ -172,7 +172,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> { } fn layout_raw<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> { ty::tls::with_related_context(tcx, move |icx| { @@ -226,7 +226,7 @@ enum StructKind { Prefixed(Size, Align), } -impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> { +impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutDetails { let dl = self.data_layout(); let b_align = b.value.align(dl); @@ -1221,7 +1221,7 @@ enum SavedLocalEligibility { // Also included in the layout are the upvars and the discriminant. // These are included as fields on the "outer" layout; they are not part // of any variant. -impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> { +impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { /// Compute the eligibility and assignment of each local. fn generator_saved_local_eligibility(&self, info: &GeneratorLayout<'tcx>) -> (BitSet, IndexVec) { @@ -1606,7 +1606,7 @@ pub enum SizeSkeleton<'tcx> { impl<'tcx> SizeSkeleton<'tcx> { pub fn compute( ty: Ty<'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> Result, LayoutError<'tcx>> { debug_assert!(!ty.has_infer_types()); @@ -1728,21 +1728,21 @@ impl<'tcx> SizeSkeleton<'tcx> { } pub trait HasTyCtxt<'tcx>: HasDataLayout { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx>; + fn tcx(&self) -> TyCtxt<'tcx>; } pub trait HasParamEnv<'tcx> { fn param_env(&self) -> ty::ParamEnv<'tcx>; } -impl<'gcx, 'tcx> HasDataLayout for TyCtxt<'gcx, 'tcx> { +impl<'tcx> HasDataLayout for TyCtxt<'tcx> { fn data_layout(&self) -> &TargetDataLayout { &self.data_layout } } -impl<'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'gcx> { +impl<'tcx> HasTyCtxt<'tcx> for TyCtxt<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.global_tcx() } } @@ -1759,8 +1759,8 @@ impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> { } } -impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> { - fn tcx(&self) -> TyCtxt<'gcx, 'gcx> { +impl<'tcx, T: HasTyCtxt<'tcx>> HasTyCtxt<'tcx> for LayoutCx<'tcx, T> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx.tcx() } } @@ -1797,7 +1797,7 @@ impl MaybeResult for Result { pub type TyLayout<'tcx> = ::rustc_target::abi::TyLayout<'tcx, Ty<'tcx>>; -impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> { +impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> { type Ty = Ty<'tcx>; type TyLayout = Result, LayoutError<'tcx>>; @@ -1824,7 +1824,7 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> { } } -impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx, 'tcx>> { +impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> { type Ty = Ty<'tcx>; type TyLayout = Result, LayoutError<'tcx>>; @@ -1856,7 +1856,7 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx, 'tcx>> { } // Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users. -impl TyCtxt<'tcx, '_> { +impl TyCtxt<'tcx> { /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. #[inline] @@ -1870,7 +1870,7 @@ impl TyCtxt<'tcx, '_> { } } -impl ty::query::TyCtxtAt<'tcx, '_> { +impl ty::query::TyCtxtAt<'tcx> { /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. #[inline] @@ -2190,7 +2190,7 @@ struct Niche { impl Niche { fn reserve<'tcx>( &self, - cx: &LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>>, + cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, count: u128, ) -> Option<(u128, Scalar)> { if count > self.available { @@ -2206,7 +2206,7 @@ impl Niche { } } -impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> { +impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { /// Find the offset of a niche leaf field, starting from /// the given type and recursing through aggregates. // FIXME(eddyb) traverse already optimized enums. @@ -2442,23 +2442,23 @@ impl_stable_hash_for!(struct crate::ty::layout::AbiAndPrefAlign { pref }); -impl<'gcx> HashStable> for Align { +impl<'tcx> HashStable> for Align { fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, + hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { self.bytes().hash_stable(hcx, hasher); } } -impl<'gcx> HashStable> for Size { +impl<'tcx> HashStable> for Size { fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, + hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { self.bytes().hash_stable(hcx, hasher); } } -impl<'a, 'gcx> HashStable> for LayoutError<'gcx> +impl<'a, 'tcx> HashStable> for LayoutError<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 71955764e100b..2e39f0457475c 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -213,7 +213,7 @@ impl AssocItem { } } - pub fn signature<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> String { + pub fn signature<'tcx>(&self, tcx: TyCtxt<'tcx>) -> String { match self.kind { ty::AssocKind::Method => { // We skip the binder here because the binder would deanonymize all @@ -259,14 +259,14 @@ pub trait DefIdTree: Copy { } } -impl<'gcx, 'tcx> DefIdTree for TyCtxt<'gcx, 'tcx> { +impl<'tcx> DefIdTree for TyCtxt<'tcx> { fn parent(self, id: DefId) -> Option { self.def_key(id).parent.map(|index| DefId { index: index, ..id }) } } impl Visibility { - pub fn from_hir(visibility: &hir::Visibility, id: hir::HirId, tcx: TyCtxt<'_, '_>) -> Self { + pub fn from_hir(visibility: &hir::Visibility, id: hir::HirId, tcx: TyCtxt<'_>) -> Self { match visibility.node { hir::VisibilityKind::Public => Visibility::Public, hir::VisibilityKind::Crate(_) => Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)), @@ -569,7 +569,7 @@ impl<'tcx> TyS<'tcx> { } } -impl<'a, 'gcx> HashStable> for ty::TyS<'gcx> { +impl<'a, 'tcx> HashStable> for ty::TyS<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { @@ -592,7 +592,7 @@ pub type Ty<'tcx> = &'tcx TyS<'tcx>; impl<'tcx> serialize::UseSpecializedEncodable for Ty<'tcx> {} impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {} -pub type CanonicalTy<'gcx> = Canonical<'gcx, Ty<'gcx>>; +pub type CanonicalTy<'tcx> = Canonical<'tcx, Ty<'tcx>>; extern { /// A dummy type used to force List to by unsized without requiring fat pointers @@ -912,7 +912,7 @@ pub struct Generics { pub has_late_bound_regions: Option, } -impl<'gcx, 'tcx> Generics { +impl<'tcx> Generics { pub fn count(&self) -> usize { self.parent_count + self.params.len() } @@ -934,7 +934,7 @@ impl<'gcx, 'tcx> Generics { own_counts } - pub fn requires_monomorphization(&self, tcx: TyCtxt<'gcx, 'tcx>) -> bool { + pub fn requires_monomorphization(&self, tcx: TyCtxt<'tcx>) -> bool { if self.own_requires_monomorphization() { return true; } @@ -960,7 +960,7 @@ impl<'gcx, 'tcx> Generics { pub fn region_param( &'tcx self, param: &EarlyBoundRegion, - tcx: TyCtxt<'gcx, 'tcx>, + 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]; @@ -978,7 +978,7 @@ impl<'gcx, 'tcx> Generics { pub fn type_param( &'tcx self, param: &ParamTy, - tcx: TyCtxt<'gcx, 'tcx>, + 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]; @@ -996,7 +996,7 @@ impl<'gcx, 'tcx> Generics { pub fn const_param( &'tcx self, param: &ParamConst, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> &GenericParamDef { if let Some(index) = param.index.checked_sub(self.parent_count as u32) { let param = &self.params[index as usize]; @@ -1021,10 +1021,10 @@ pub struct GenericPredicates<'tcx> { impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {} impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {} -impl<'gcx, 'tcx> GenericPredicates<'tcx> { +impl<'tcx> GenericPredicates<'tcx> { pub fn instantiate( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, ) -> InstantiatedPredicates<'tcx> { let mut instantiated = InstantiatedPredicates::empty(); @@ -1034,7 +1034,7 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> { pub fn instantiate_own( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, ) -> InstantiatedPredicates<'tcx> { InstantiatedPredicates { @@ -1044,7 +1044,7 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> { fn instantiate_into( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, instantiated: &mut InstantiatedPredicates<'tcx>, substs: SubstsRef<'tcx>, ) { @@ -1056,7 +1056,7 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> { ); } - pub fn instantiate_identity(&self, tcx: TyCtxt<'gcx, 'tcx>) -> InstantiatedPredicates<'tcx> { + pub fn instantiate_identity(&self, tcx: TyCtxt<'tcx>) -> InstantiatedPredicates<'tcx> { let mut instantiated = InstantiatedPredicates::empty(); self.instantiate_identity_into(tcx, &mut instantiated); instantiated @@ -1064,7 +1064,7 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> { fn instantiate_identity_into( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, instantiated: &mut InstantiatedPredicates<'tcx>, ) { if let Some(def_id) = self.parent { @@ -1075,7 +1075,7 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> { pub fn instantiate_supertrait( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, poly_trait_ref: &ty::PolyTraitRef<'tcx>, ) -> InstantiatedPredicates<'tcx> { assert_eq!(self.parent, None); @@ -1142,7 +1142,7 @@ impl<'tcx> AsRef> for Predicate<'tcx> { } } -impl<'gcx, 'tcx> Predicate<'tcx> { +impl<'tcx> Predicate<'tcx> { /// Performs a substitution suitable for going from a /// poly-trait-ref to supertraits that must hold if that /// poly-trait-ref holds. This is slightly different from a normal @@ -1150,7 +1150,7 @@ impl<'gcx, 'tcx> Predicate<'tcx> { /// lengthy comment below for details. pub fn subst_supertrait( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_ref: &ty::PolyTraitRef<'tcx>, ) -> ty::Predicate<'tcx> { // The interaction between HRTB and supertraits is not entirely @@ -1309,7 +1309,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> { } #[inline] - pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_, '_>) -> PolyTraitRef<'tcx> { + pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_>) -> PolyTraitRef<'tcx> { // Note: unlike with `TraitRef::to_poly_trait_ref()`, // `self.0.trait_ref` is permitted to have escaping regions. // This is because here `self` has a `Binder` and so does our @@ -1771,7 +1771,7 @@ impl<'tcx, T> ParamEnvAnd<'tcx, T> { } } -impl<'a, 'gcx, T> HashStable> for ParamEnvAnd<'gcx, T> +impl<'a, 'tcx, T> HashStable> for ParamEnvAnd<'tcx, T> where T: HashStable> { fn hash_stable(&self, @@ -1853,7 +1853,7 @@ pub struct VariantDef { pub recovered: bool, } -impl<'gcx, 'tcx> VariantDef { +impl<'tcx> VariantDef { /// Creates a new `VariantDef`. /// /// `variant_did` is the `DefId` that identifies the enum variant (if this `VariantDef` @@ -1871,7 +1871,7 @@ impl<'gcx, 'tcx> VariantDef { /// If someone speeds up attribute loading to not be a performance concern, they can /// remove this hack and use the constructor `DefId` everywhere. pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ident: Ident, variant_did: Option, ctor_def_id: Option, @@ -2084,7 +2084,7 @@ impl_stable_hash_for!(struct ReprOptions { }); impl ReprOptions { - pub fn new(tcx: TyCtxt<'_, '_>, did: DefId) -> ReprOptions { + pub fn new(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions { let mut flags = ReprFlags::empty(); let mut size = None; let mut max_align = 0; @@ -2157,10 +2157,10 @@ impl ReprOptions { } } -impl<'gcx, 'tcx> AdtDef { +impl<'tcx> AdtDef { /// Creates a new `AdtDef`. fn new( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, did: DefId, kind: AdtKind, variants: IndexVec, @@ -2300,7 +2300,7 @@ impl<'gcx, 'tcx> AdtDef { } /// Returns `true` if this type has a destructor. - pub fn has_dtor(&self, tcx: TyCtxt<'gcx, 'tcx>) -> bool { + pub fn has_dtor(&self, tcx: TyCtxt<'tcx>) -> bool { self.destructor(tcx).is_some() } @@ -2311,7 +2311,7 @@ impl<'gcx, 'tcx> AdtDef { } #[inline] - pub fn predicates(&self, tcx: TyCtxt<'gcx, 'tcx>) -> &'tcx GenericPredicates<'gcx> { + pub fn predicates(&self, tcx: TyCtxt<'tcx>) -> &'tcx GenericPredicates<'tcx> { tcx.predicates_of(self.did) } @@ -2365,7 +2365,7 @@ impl<'gcx, 'tcx> AdtDef { #[inline] pub fn eval_explicit_discr( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, expr_did: DefId, ) -> Option> { let param_env = ParamEnv::empty(); @@ -2412,8 +2412,8 @@ impl<'gcx, 'tcx> AdtDef { #[inline] pub fn discriminants( &'tcx self, - tcx: TyCtxt<'gcx, 'tcx>, - ) -> impl Iterator)> + Captures<'gcx> { + tcx: TyCtxt<'tcx>, + ) -> impl Iterator)> + Captures<'tcx> { let repr_type = self.repr.discr_type(); let initial = repr_type.initial_discriminant(tcx.global_tcx()); let mut prev_discr = None::>; @@ -2443,7 +2443,7 @@ impl<'gcx, 'tcx> AdtDef { #[inline] pub fn discriminant_for_variant( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, variant_index: VariantIdx, ) -> Discr<'tcx> { let (val, offset) = self.discriminant_def_for_variant(variant_index); @@ -2480,7 +2480,7 @@ impl<'gcx, 'tcx> AdtDef { (expr_did, variant_index.as_u32() - explicit_index) } - pub fn destructor(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + pub fn destructor(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.adt_destructor(self.did) } @@ -2494,11 +2494,11 @@ impl<'gcx, 'tcx> AdtDef { /// /// Due to normalization being eager, this applies even if /// the associated type is behind a pointer (e.g., issue #31299). - pub fn sized_constraint(&self, tcx: TyCtxt<'gcx, 'tcx>) -> &'tcx [Ty<'tcx>] { + pub fn sized_constraint(&self, tcx: TyCtxt<'tcx>) -> &'tcx [Ty<'tcx>] { tcx.adt_sized_constraint(self.did).0 } - fn sized_constraint_for_ty(&self, tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Vec> { + fn sized_constraint_for_ty(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec> { let result = match ty.sty { Bool | Char | Int(..) | Uint(..) | Float(..) | RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) | @@ -2575,8 +2575,8 @@ impl<'gcx, 'tcx> AdtDef { } } -impl<'gcx, 'tcx> FieldDef { - pub fn ty(&self, tcx: TyCtxt<'gcx, 'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> { +impl<'tcx> FieldDef { + pub fn ty(&self, tcx: TyCtxt<'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> { tcx.type_of(self.did).subst(tcx, subst) } } @@ -2602,7 +2602,7 @@ impl<'tcx> ClosureKind { // This is the initial value used when doing upvar inference. pub const LATTICE_BOTTOM: ClosureKind = ClosureKind::Fn; - pub fn trait_did(&self, tcx: TyCtxt<'tcx, 'tcx>) -> DefId { + pub fn trait_did(&self, tcx: TyCtxt<'tcx>) -> DefId { match *self { ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem), ClosureKind::FnMut => { @@ -2630,7 +2630,7 @@ impl<'tcx> ClosureKind { /// Returns the representative scalar type for this closure kind. /// See `TyS::to_opt_closure_kind` for more details. - pub fn to_ty(self, tcx: TyCtxt<'_, 'tcx>) -> Ty<'tcx> { + pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match self { ty::ClosureKind::Fn => tcx.types.i8, ty::ClosureKind::FnMut => tcx.types.i16, @@ -2712,12 +2712,12 @@ impl BorrowKind { } #[derive(Debug, Clone)] -pub enum Attributes<'gcx> { +pub enum Attributes<'tcx> { Owned(Lrc<[ast::Attribute]>), - Borrowed(&'gcx [ast::Attribute]) + Borrowed(&'tcx [ast::Attribute]) } -impl<'gcx> ::std::ops::Deref for Attributes<'gcx> { +impl<'tcx> ::std::ops::Deref for Attributes<'tcx> { type Target = [ast::Attribute]; fn deref(&self) -> &[ast::Attribute] { @@ -2767,15 +2767,15 @@ pub enum ImplOverlapKind { Issue33140 } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { - pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> { +impl<'tcx> TyCtxt<'tcx> { + pub fn body_tables(self, body: hir::BodyId) -> &'tcx TypeckTables<'tcx> { self.typeck_tables_of(self.hir().body_owner_def_id(body)) } /// Returns an iterator of the `DefId`s for all body-owners in this /// crate. If you would prefer to iterate over the bodies /// themselves, you can do `self.hir().krate().body_ids.iter()`. - pub fn body_owners(self) -> impl Iterator + Captures<'gcx> + 'tcx { + pub fn body_owners(self) -> impl Iterator + Captures<'tcx> + 'tcx { self.hir().krate() .body_ids .iter() @@ -2899,7 +2899,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { }) } - pub fn associated_items(self, def_id: DefId) -> AssocItemsIterator<'gcx, 'tcx> { + pub fn associated_items(self, def_id: DefId) -> AssocItemsIterator<'tcx> { // Ideally, we would use `-> impl Iterator` here, but it falls // afoul of the conservative "capture [restrictions]" we put // in place, so we use a hand-written iterator. @@ -3007,8 +3007,8 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } /// Returns the possibly-auto-generated MIR of a `(DefId, Subst)` pair. - pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>) - -> &'gcx Body<'gcx> + pub fn instance_mir(self, instance: ty::InstanceDef<'tcx>) + -> &'tcx Body<'tcx> { match instance { ty::InstanceDef::Item(did) => { @@ -3027,7 +3027,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } /// Gets the attributes of a definition. - pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> { + pub fn get_attrs(self, did: DefId) -> Attributes<'tcx> { if let Some(id) = self.hir().as_local_hir_id(did) { Attributes::Borrowed(self.hir().attrs_by_hir_id(id)) } else { @@ -3122,13 +3122,13 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } -pub struct AssocItemsIterator<'gcx, 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, - def_ids: &'gcx [DefId], +pub struct AssocItemsIterator<'tcx> { + tcx: TyCtxt<'tcx>, + def_ids: &'tcx [DefId], next_index: usize, } -impl Iterator for AssocItemsIterator<'_, '_> { +impl Iterator for AssocItemsIterator<'_> { type Item = AssocItem; fn next(&mut self) -> Option { @@ -3138,7 +3138,7 @@ impl Iterator for AssocItemsIterator<'_, '_> { } } -fn associated_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> AssocItem { +fn associated_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> AssocItem { let id = tcx.hir().as_local_hir_id(def_id).unwrap(); let parent_id = tcx.hir().get_parent_item(id); let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id); @@ -3183,7 +3183,7 @@ pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]); /// such. /// - a Error, if a type contained itself. The representability /// check should catch this case. -fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> AdtSizedConstraint<'tcx> { +fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> AdtSizedConstraint<'tcx> { let def = tcx.adt_def(def_id); let result = tcx.mk_type_list(def.variants.iter().flat_map(|v| { @@ -3197,7 +3197,7 @@ fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> AdtSize AdtSizedConstraint(result) } -fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx [DefId] { +fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx [DefId] { let id = tcx.hir().as_local_hir_id(def_id).unwrap(); let item = tcx.hir().expect_item_by_hir_id(id); match item.node { @@ -3220,14 +3220,14 @@ fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tc } } -fn def_span<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Span { +fn def_span<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Span { tcx.hir().span_if_local(def_id).unwrap() } /// If the given `DefId` describes an item belonging to a trait, /// returns the `DefId` of the trait that the trait item belongs to; /// otherwise, returns `None`. -fn trait_of_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option { +fn trait_of_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option { tcx.opt_associated_item(def_id) .and_then(|associated_item| { match associated_item.container { @@ -3238,7 +3238,7 @@ fn trait_of_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option } /// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition. -pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Option { +pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option { if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { if let Node::Item(item) = tcx.hir().get_by_hir_id(hir_id) { if let hir::ItemKind::Existential(ref exist_ty) = item.node { @@ -3250,7 +3250,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Option { } /// See `ParamEnv` struct definition for details. -fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> ParamEnv<'tcx> { +fn param_env<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ParamEnv<'tcx> { // The param_env of an impl Trait type is its defining function's param_env if let Some(parent) = is_impl_trait_defn(tcx, def_id) { return param_env(tcx, parent); @@ -3285,23 +3285,23 @@ fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> ParamEnv<'tcx> { traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause) } -fn crate_disambiguator<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> CrateDisambiguator { +fn crate_disambiguator<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> CrateDisambiguator { assert_eq!(crate_num, LOCAL_CRATE); tcx.sess.local_crate_disambiguator() } -fn original_crate_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> Symbol { +fn original_crate_name<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> Symbol { assert_eq!(crate_num, LOCAL_CRATE); tcx.crate_name.clone() } -fn crate_hash<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> Svh { +fn crate_hash<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> Svh { assert_eq!(crate_num, LOCAL_CRATE); tcx.hir().crate_hash } fn instance_def_size_estimate<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, instance_def: InstanceDef<'tcx>, ) -> usize { match instance_def { @@ -3318,7 +3318,7 @@ fn instance_def_size_estimate<'tcx>( /// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`. /// /// See [`ImplOverlapKind::Issue33140`] for more details. -fn issue33140_self_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option> { +fn issue33140_self_ty<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option> { debug!("issue33140_self_ty({:?})", def_id); let trait_ref = tcx.impl_trait_ref(def_id).unwrap_or_else(|| { diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs index c24c0541ad71f..7d1403d1e9662 100644 --- a/src/librustc/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -45,7 +45,7 @@ pub enum Component<'tcx> { EscapingProjection(Vec>), } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Push onto `out` all the things that must outlive `'a` for the condition /// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**. pub fn push_outlives_components(&self, ty0: Ty<'tcx>, diff --git a/src/librustc/ty/print/mod.rs b/src/librustc/ty/print/mod.rs index d5bca55c2f1b1..8e157bdd259db 100644 --- a/src/librustc/ty/print/mod.rs +++ b/src/librustc/ty/print/mod.rs @@ -13,7 +13,7 @@ pub mod obsolete; // FIXME(eddyb) false positive, the lifetime parameters are used with `P: Printer<...>`. #[allow(unused_lifetimes)] -pub trait Print<'gcx, 'tcx, P> { +pub trait Print<'tcx, P> { type Output; type Error; @@ -28,7 +28,7 @@ pub trait Print<'gcx, 'tcx, P> { /// /// For pretty-printing/formatting in particular, see `PrettyPrinter`. // FIXME(eddyb) find a better name, this is more general than "printing". -pub trait Printer<'gcx: 'tcx, 'tcx>: Sized { +pub trait Printer<'tcx>: Sized { type Error; type Path; @@ -37,7 +37,7 @@ pub trait Printer<'gcx: 'tcx, 'tcx>: Sized { type DynExistential; type Const; - fn tcx(&'a self) -> TyCtxt<'gcx, 'tcx>; + fn tcx(&'a self) -> TyCtxt<'tcx>; fn print_def_path( self, @@ -302,7 +302,7 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option { } } -impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for ty::RegionKind { +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for ty::RegionKind { type Output = P::Region; type Error = P::Error; fn print(&self, cx: P) -> Result { @@ -310,7 +310,7 @@ impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for ty::Regi } } -impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for ty::Region<'_> { +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for ty::Region<'_> { type Output = P::Region; type Error = P::Error; fn print(&self, cx: P) -> Result { @@ -318,7 +318,7 @@ impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for ty::Regi } } -impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for Ty<'tcx> { +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for Ty<'tcx> { type Output = P::Type; type Error = P::Error; fn print(&self, cx: P) -> Result { @@ -326,7 +326,7 @@ impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for Ty<'tcx> } } -impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx ty::List> { type Output = P::DynExistential; @@ -336,7 +336,7 @@ impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> } } -impl<'gcx: 'tcx, 'tcx, P: Printer<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for &'tcx ty::Const<'tcx> { +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx ty::Const<'tcx> { type Output = P::Const; type Error = P::Error; fn print(&self, cx: P) -> Result { diff --git a/src/librustc/ty/print/obsolete.rs b/src/librustc/ty/print/obsolete.rs index a320eb47e6c1c..2bfe35d4f1c32 100644 --- a/src/librustc/ty/print/obsolete.rs +++ b/src/librustc/ty/print/obsolete.rs @@ -17,14 +17,14 @@ use syntax::ast; /// Same as `unique_type_name()` but with the result pushed onto the given /// `output` parameter. pub struct DefPathBasedNames<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, omit_disambiguators: bool, omit_local_crate_name: bool, } impl DefPathBasedNames<'tcx> { pub fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, omit_disambiguators: bool, omit_local_crate_name: bool, ) -> Self { diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index d55f1c8983610..95c5048b378f0 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -166,8 +166,8 @@ impl RegionHighlightMode { } /// Trait for printers that pretty-print using `fmt::Write` to the printer. -pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: - Printer<'gcx, 'tcx, +pub trait PrettyPrinter<'tcx>: + Printer<'tcx, Error = fmt::Error, Path = Self, Region = Self, @@ -190,7 +190,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: self, value: &ty::Binder, ) -> Result - where T: Print<'gcx, 'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> + where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> { value.skip_binder().print(self) } @@ -200,7 +200,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: mut self, mut elems: impl Iterator, ) -> Result - where T: Print<'gcx, 'tcx, Self, Output = Self, Error = Self::Error> + where T: Print<'tcx, Self, Output = Self, Error = Self::Error> { if let Some(first) = elems.next() { self = first.print(self)?; @@ -931,10 +931,10 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: } // HACK(eddyb) boxed to avoid moving around a large struct by-value. -pub struct FmtPrinter<'a, 'gcx, 'tcx, F>(Box>); +pub struct FmtPrinter<'a, 'tcx, F>(Box>); -pub struct FmtPrinterData<'a, 'gcx, 'tcx, F> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct FmtPrinterData<'a, 'tcx, F> { + tcx: TyCtxt<'tcx>, fmt: F, empty_path: bool, @@ -949,21 +949,21 @@ pub struct FmtPrinterData<'a, 'gcx, 'tcx, F> { pub name_resolver: Option Option>>, } -impl Deref for FmtPrinter<'a, 'gcx, 'tcx, F> { - type Target = FmtPrinterData<'a, 'gcx, 'tcx, F>; +impl Deref for FmtPrinter<'a, 'tcx, F> { + type Target = FmtPrinterData<'a, 'tcx, F>; fn deref(&self) -> &Self::Target { &self.0 } } -impl DerefMut for FmtPrinter<'_, '_, '_, F> { +impl DerefMut for FmtPrinter<'_, '_, F> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl FmtPrinter<'a, 'gcx, 'tcx, F> { - pub fn new(tcx: TyCtxt<'gcx, 'tcx>, fmt: F, ns: Namespace) -> Self { +impl FmtPrinter<'a, 'tcx, F> { + pub fn new(tcx: TyCtxt<'tcx>, fmt: F, ns: Namespace) -> Self { FmtPrinter(Box::new(FmtPrinterData { tcx, fmt, @@ -978,7 +978,7 @@ impl FmtPrinter<'a, 'gcx, 'tcx, F> { } } -impl TyCtxt<'_, '_> { +impl TyCtxt<'_> { // HACK(eddyb) get rid of `def_path_str` and/or pass `Namespace` explicitly always // (but also some things just print a `DefId` generally so maybe we need this?) fn guess_def_namespace(self, def_id: DefId) -> Namespace { @@ -1010,13 +1010,13 @@ impl TyCtxt<'_, '_> { } } -impl fmt::Write for FmtPrinter<'_, '_, '_, F> { +impl fmt::Write for FmtPrinter<'_, '_, F> { fn write_str(&mut self, s: &str) -> fmt::Result { self.fmt.write_str(s) } } -impl Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> { +impl Printer<'tcx> for FmtPrinter<'_, 'tcx, F> { type Error = fmt::Error; type Path = Self; @@ -1025,7 +1025,7 @@ impl Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> { type DynExistential = Self; type Const = Self; - fn tcx(&'a self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&'a self) -> TyCtxt<'tcx> { self.tcx } @@ -1222,7 +1222,7 @@ impl Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> { } } -impl PrettyPrinter<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> { +impl PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> { fn infer_ty_name(&self, id: ty::TyVid) -> Option { self.0.name_resolver.as_ref().and_then(|func| func(id)) } @@ -1243,7 +1243,7 @@ impl PrettyPrinter<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> self, value: &ty::Binder, ) -> Result - where T: Print<'gcx, 'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> + where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> { self.pretty_in_binder(value) } @@ -1317,7 +1317,7 @@ impl PrettyPrinter<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> } // HACK(eddyb) limited to `FmtPrinter` because of `region_highlight_mode`. -impl FmtPrinter<'_, '_, '_, F> { +impl FmtPrinter<'_, '_, F> { pub fn pretty_print_region( mut self, region: ty::Region<'_>, @@ -1416,12 +1416,12 @@ impl FmtPrinter<'_, '_, '_, F> { // HACK(eddyb) limited to `FmtPrinter` because of `binder_depth`, // `region_index` and `used_region_names`. -impl FmtPrinter<'_, 'gcx, 'tcx, F> { +impl FmtPrinter<'_, 'tcx, F> { pub fn pretty_in_binder( mut self, value: &ty::Binder, ) -> Result - where T: Print<'gcx, 'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx> + where T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx> { fn name_by_region_index(index: usize) -> InternedString { match index { @@ -1510,9 +1510,9 @@ impl FmtPrinter<'_, 'gcx, 'tcx, F> { } } -impl<'gcx: 'tcx, 'tcx, T, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> +impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder - where T: Print<'gcx, 'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx> + where T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx> { type Output = P; type Error = P::Error; @@ -1521,10 +1521,10 @@ impl<'gcx: 'tcx, 'tcx, T, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> } } -impl<'gcx: 'tcx, 'tcx, T, U, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> +impl<'tcx, T, U, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::OutlivesPredicate - where T: Print<'gcx, 'tcx, P, Output = P, Error = P::Error>, - U: Print<'gcx, 'tcx, P, Output = P, Error = P::Error>, + 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; @@ -1552,7 +1552,7 @@ macro_rules! forward_display_to_print { macro_rules! define_print_and_forward_display { (($self:ident, $cx:ident): $($ty:ty $print:block)+) => { - $(impl<'gcx: 'tcx, 'tcx, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for $ty { + $(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty { type Output = P; type Error = fmt::Error; fn print(&$self, $cx: P) -> Result { @@ -1585,7 +1585,7 @@ forward_display_to_print! { &'tcx ty::Const<'tcx>, // HACK(eddyb) these are exhaustive instead of generic, - // because `for<'gcx: 'tcx, 'tcx>` isn't possible yet. + // because `for<'tcx>` isn't possible yet. ty::Binder<&'tcx ty::List>>, ty::Binder>, ty::Binder>, diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index bd5f33eea7bc5..13d93f173e845 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -31,36 +31,36 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> { fn query(key: Self::Key) -> Query<'tcx>; // Don't use this method to access query results, instead use the methods on TyCtxt - fn query_cache<'a>(tcx: TyCtxt<'tcx, '_>) -> &'a Lock>; + fn query_cache<'a>(tcx: TyCtxt<'tcx>) -> &'a Lock>; - fn to_dep_node(tcx: TyCtxt<'tcx, '_>, key: &Self::Key) -> DepNode; + fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode; // Don't use this method to compute query results, instead use the methods on TyCtxt - fn compute(tcx: TyCtxt<'tcx, '_>, key: Self::Key) -> Self::Value; + fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value; fn hash_result( hcx: &mut StableHashingContext<'_>, result: &Self::Value ) -> Option; - fn handle_cycle_error(tcx: TyCtxt<'tcx, '_>, error: CycleError<'tcx>) -> Self::Value; + fn handle_cycle_error(tcx: TyCtxt<'tcx>, error: CycleError<'tcx>) -> Self::Value; } pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { - fn describe(tcx: TyCtxt<'_, '_>, key: Self::Key) -> Cow<'static, str>; + fn describe(tcx: TyCtxt<'_>, key: Self::Key) -> Cow<'static, str>; #[inline] - fn cache_on_disk(_: TyCtxt<'tcx, 'tcx>, _: Self::Key) -> bool { + fn cache_on_disk(_: TyCtxt<'tcx>, _: Self::Key) -> bool { false } - fn try_load_from_disk(_: TyCtxt<'tcx, 'tcx>, _: SerializedDepNodeIndex) -> Option { + fn try_load_from_disk(_: TyCtxt<'tcx>, _: SerializedDepNodeIndex) -> Option { bug!("QueryDescription::load_from_disk() called for an unsupported query.") } } impl<'tcx, M: QueryAccessors<'tcx, Key = DefId>> QueryDescription<'tcx> for M { - default fn describe(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Cow<'static, str> { + default fn describe(tcx: TyCtxt<'_>, def_id: DefId) -> Cow<'static, str> { if !tcx.sess.verbose() { format!("processing `{}`", tcx.def_path_str(def_id)).into() } else { @@ -71,7 +71,7 @@ impl<'tcx, M: QueryAccessors<'tcx, Key = DefId>> QueryDescription<'tcx> for M { } impl<'tcx> QueryDescription<'tcx> for queries::analysis<'tcx> { - fn describe(_tcx: TyCtxt<'_, '_>, _: CrateNum) -> Cow<'static, str> { + fn describe(_tcx: TyCtxt<'_>, _: CrateNum) -> Cow<'static, str> { "running analysis passes on this crate".into() } } @@ -80,12 +80,12 @@ macro_rules! impl_disk_cacheable_query( ($query_name:ident, |$tcx:tt, $key:tt| $cond:expr) => { impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> { #[inline] - fn cache_on_disk($tcx: TyCtxt<'tcx, 'tcx>, $key: Self::Key) -> bool { + fn cache_on_disk($tcx: TyCtxt<'tcx>, $key: Self::Key) -> bool { $cond } #[inline] - fn try_load_from_disk(tcx: TyCtxt<'tcx, 'tcx>, + fn try_load_from_disk(tcx: TyCtxt<'tcx>, id: SerializedDepNodeIndex) -> Option { tcx.queries.on_disk_cache.try_load_query_result(tcx, id) diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index f300d82e372e9..3d00de8c8c11c 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -75,9 +75,9 @@ impl<'tcx> QueryJob<'tcx> { /// Awaits for the query job to complete. #[cfg(parallel_compiler)] - pub(super) fn r#await<'lcx>( + pub(super) fn r#await( &self, - tcx: TyCtxt<'tcx, 'lcx>, + tcx: TyCtxt<'tcx>, span: Span, ) -> Result<(), CycleError<'tcx>> { tls::with_related_context(tcx, move |icx| { @@ -100,9 +100,9 @@ impl<'tcx> QueryJob<'tcx> { } #[cfg(not(parallel_compiler))] - pub(super) fn find_cycle_in_stack<'lcx>( + pub(super) fn find_cycle_in_stack( &self, - tcx: TyCtxt<'tcx, 'lcx>, + tcx: TyCtxt<'tcx>, span: Span, ) -> CycleError<'tcx> { // Get the current executing query (waiter) and find the waitee amongst its parents @@ -338,7 +338,7 @@ fn connected_to_root<'tcx>( // Deterministically pick an query from a list #[cfg(parallel_compiler)] fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc>)>( - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, queries: &'a [T], f: F, ) -> &'a T { @@ -366,7 +366,7 @@ fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc>)>( fn remove_cycle<'tcx>( jobs: &mut Vec>>, wakelist: &mut Vec>>, - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, ) -> bool { let mut visited = FxHashSet::default(); let mut stack = Vec::new(); @@ -505,7 +505,7 @@ pub unsafe fn handle_deadlock() { /// There may be multiple cycles involved in a deadlock, so this searches /// all active queries for cycles before finally resuming all the waiters at once. #[cfg(parallel_compiler)] -fn deadlock(tcx: TyCtxt<'_, '_>, registry: &rayon_core::Registry) { +fn deadlock(tcx: TyCtxt<'_>, registry: &rayon_core::Registry) { let on_panic = OnDrop(|| { eprintln!("deadlock handler panicked, aborting process"); process::abort(); diff --git a/src/librustc/ty/query/keys.rs b/src/librustc/ty/query/keys.rs index af13bbc24efd9..30a3e53dddfbb 100644 --- a/src/librustc/ty/query/keys.rs +++ b/src/librustc/ty/query/keys.rs @@ -22,7 +22,7 @@ pub(super) trait Key: Clone + Hash + Eq + Debug { /// In the event that a cycle occurs, if no explicit span has been /// given for a query with key `self`, what span should we use? - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span; + fn default_span(&self, tcx: TyCtxt<'_>) -> Span; } impl<'tcx> Key for ty::InstanceDef<'tcx> { @@ -30,7 +30,7 @@ impl<'tcx> Key for ty::InstanceDef<'tcx> { LOCAL_CRATE } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.def_id()) } } @@ -40,7 +40,7 @@ impl<'tcx> Key for ty::Instance<'tcx> { LOCAL_CRATE } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.def_id()) } } @@ -50,7 +50,7 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> { self.instance.query_crate() } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.instance.default_span(tcx) } } @@ -59,7 +59,7 @@ impl Key for CrateNum { fn query_crate(&self) -> CrateNum { *self } - fn default_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -68,7 +68,7 @@ impl Key for DefIndex { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -77,7 +77,7 @@ impl Key for DefId { fn query_crate(&self) -> CrateNum { self.krate } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(*self) } } @@ -86,7 +86,7 @@ impl Key for (DefId, DefId) { fn query_crate(&self) -> CrateNum { self.0.krate } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.1.default_span(tcx) } } @@ -95,7 +95,7 @@ impl Key for (CrateNum, DefId) { fn query_crate(&self) -> CrateNum { self.0 } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.1.default_span(tcx) } } @@ -104,7 +104,7 @@ impl Key for (DefId, SimplifiedType) { fn query_crate(&self) -> CrateNum { self.0.krate } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.0.default_span(tcx) } } @@ -113,7 +113,7 @@ impl<'tcx> Key for (DefId, SubstsRef<'tcx>) { fn query_crate(&self) -> CrateNum { self.0.krate } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.0.default_span(tcx) } } @@ -122,7 +122,7 @@ impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) { fn query_crate(&self) -> CrateNum { self.1.def_id().krate } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.1.def_id()) } } @@ -131,7 +131,7 @@ impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -140,7 +140,7 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx> { fn query_crate(&self) -> CrateNum { self.def_id().krate } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.def_id()) } } @@ -149,7 +149,7 @@ impl<'tcx> Key for ty::Const<'tcx> { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -158,7 +158,7 @@ impl<'tcx> Key for Ty<'tcx> { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -167,7 +167,7 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -176,7 +176,7 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> { fn query_crate(&self) -> CrateNum { self.value.query_crate() } - fn default_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.value.default_span(tcx) } } @@ -185,7 +185,7 @@ impl<'tcx> Key for traits::Environment<'tcx> { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -194,7 +194,7 @@ impl Key for InternedString { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } @@ -209,7 +209,7 @@ where LOCAL_CRATE } - fn default_span(&self, _tcx: TyCtxt<'_, '_>) -> Span { + fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index bc28396a6f9f8..72ebd3276c7a7 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -158,7 +158,7 @@ impl<'sess> OnDiskCache<'sess> { pub fn serialize<'tcx, E>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, encoder: &mut E, ) -> Result<(), E::Error> where @@ -316,7 +316,7 @@ impl<'sess> OnDiskCache<'sess> { return Ok(()); - fn sorted_cnums_including_local_crate(tcx: TyCtxt<'_, '_>) -> Vec { + fn sorted_cnums_including_local_crate(tcx: TyCtxt<'_>) -> Vec { let mut cnums = vec![LOCAL_CRATE]; cnums.extend_from_slice(&tcx.crates()[..]); cnums.sort_unstable(); @@ -330,7 +330,7 @@ impl<'sess> OnDiskCache<'sess> { /// Loads a diagnostic emitted during the previous compilation session. pub fn load_diagnostics<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, dep_node_index: SerializedDepNodeIndex, ) -> Vec { let diagnostics: Option = self.load_indexed( @@ -359,7 +359,7 @@ impl<'sess> OnDiskCache<'sess> { /// the given `SerializedDepNodeIndex`; otherwise returns `None`. pub fn try_load_query_result<'tcx, T>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, dep_node_index: SerializedDepNodeIndex, ) -> Option where @@ -389,7 +389,7 @@ impl<'sess> OnDiskCache<'sess> { fn load_indexed<'tcx, T>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, dep_node_index: SerializedDepNodeIndex, index: &FxHashMap, debug_tag: &'static str, @@ -430,7 +430,7 @@ impl<'sess> OnDiskCache<'sess> { // Session that don't occur in the current one. For these, the mapping // maps to None. fn compute_cnum_map( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, prev_cnums: &[(u32, String, CrateDisambiguator)], ) -> IndexVec> { tcx.dep_graph.with_ignore(|| { @@ -464,7 +464,7 @@ impl<'sess> OnDiskCache<'sess> { /// we use for crate metadata decoding in that it can rebase spans and /// eventually will also handle things that contain `Ty` instances. struct CacheDecoder<'a, 'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, opaque: opaque::Decoder<'a>, source_map: &'a SourceMap, cnum_map: &'a IndexVec>, @@ -532,7 +532,7 @@ fn decode_tagged<'a, 'tcx, D, T, V>(decoder: &mut D, impl<'a, 'tcx> ty_codec::TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> { #[inline] - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -751,7 +751,7 @@ impl<'a, 'tcx, T: Decodable> SpecializedDecoder> //- ENCODING ------------------------------------------------------------------- struct CacheEncoder<'a, 'tcx, E: ty_codec::TyEncoder> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, encoder: &'a mut E, type_shorthands: FxHashMap, usize>, predicate_shorthands: FxHashMap, usize>, @@ -1080,7 +1080,7 @@ impl<'a> SpecializedDecoder for opaque::Decoder<'a> { } fn encode_query_results<'a, 'tcx, Q, E>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, encoder: &mut CacheEncoder<'a, 'tcx, E>, query_result_index: &mut EncodedQueryResultIndex, ) -> Result<(), E::Error> diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 662d653b2a173..0051832c5df80 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> { /// for some compile-time benchmarks. #[inline(always)] pub(super) fn try_get( - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key, ) -> TryGetJob<'a, 'tcx, Q> { @@ -247,22 +247,22 @@ pub(super) enum TryGetJob<'a, 'tcx: 'a, D: QueryDescription<'tcx> + 'a> { Cycle(D::Value), } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Executes a job by changing the ImplicitCtxt to point to the /// new query job while it executes. It returns the diagnostics /// captured during execution and the actual result. #[inline(always)] pub(super) fn start_query( self, - job: Lrc>, + job: Lrc>, diagnostics: Option<&Lock>>, compute: F, ) -> R where - F: for<'lcx> FnOnce(TyCtxt<'gcx, 'lcx>) -> R, + F: FnOnce(TyCtxt<'tcx>) -> R, { // The TyCtxt stored in TLS has the same global interner lifetime - // as `self`, so we use `with_related_context` to relate the 'gcx lifetimes + // as `self`, so we use `with_related_context` to relate the 'tcx lifetimes // when accessing the ImplicitCtxt tls::with_related_context(self, move |current_icx| { // Update the ImplicitCtxt to point to our new query job @@ -285,11 +285,11 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { #[cold] pub(super) fn report_cycle( self, - CycleError { usage, cycle: stack }: CycleError<'gcx>, + CycleError { usage, cycle: stack }: CycleError<'tcx>, ) -> DiagnosticBuilder<'tcx> { assert!(!stack.is_empty()); - let fix_span = |span: Span, query: &Query<'gcx>| { + let fix_span = |span: Span, query: &Query<'tcx>| { self.sess.source_map().def_span(query.default_span(self, span)) }; @@ -351,7 +351,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } #[inline(never)] - pub(super) fn get_query>( + pub(super) fn get_query>( self, span: Span, key: Q::Key) @@ -439,7 +439,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { result } - fn load_from_disk_and_cache_in_memory>( + fn load_from_disk_and_cache_in_memory>( self, key: Q::Key, prev_dep_node_index: SerializedDepNodeIndex, @@ -507,7 +507,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { #[inline(never)] #[cold] - fn incremental_verify_ich>( + fn incremental_verify_ich>( self, result: &Q::Value, dep_node: &DepNode, @@ -533,10 +533,10 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } #[inline(always)] - fn force_query_with_job>( + fn force_query_with_job>( self, key: Q::Key, - job: JobOwner<'_, 'gcx, Q>, + job: JobOwner<'_, 'tcx, Q>, dep_node: DepNode) -> (Q::Value, DepNodeIndex) { // If the following assertion triggers, it can have two reasons: @@ -597,7 +597,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { /// side-effects -- e.g., in order to report errors for erroneous programs. /// /// Note: The optimization is only available during incr. comp. - pub(super) fn ensure_query>(self, key: Q::Key) -> () { + pub(super) fn ensure_query>(self, key: Q::Key) -> () { let dep_node = Q::to_dep_node(self, &key); if dep_node.kind.is_eval_always() { @@ -623,7 +623,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } #[allow(dead_code)] - fn force_query>( + fn force_query>( self, key: Q::Key, span: Span, @@ -873,7 +873,7 @@ macro_rules! define_queries_inner { } } - pub fn describe(&self, tcx: TyCtxt<'_, '_>) -> Cow<'static, str> { + pub fn describe(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> { let (r, name) = match *self { $(Query::$name(key) => { (queries::$name::describe(tcx, key), stringify!($name)) @@ -887,7 +887,7 @@ macro_rules! define_queries_inner { } // FIXME(eddyb) Get more valid Span's on queries. - pub fn default_span(&self, tcx: TyCtxt<$tcx, '_>, span: Span) -> Span { + pub fn default_span(&self, tcx: TyCtxt<$tcx>, span: Span) -> Span { if !span.is_dummy() { return span; } @@ -953,20 +953,20 @@ macro_rules! define_queries_inner { } #[inline(always)] - fn query_cache<'a>(tcx: TyCtxt<$tcx, '_>) -> &'a Lock> { + fn query_cache<'a>(tcx: TyCtxt<$tcx>) -> &'a Lock> { &tcx.queries.$name } #[allow(unused)] #[inline(always)] - fn to_dep_node(tcx: TyCtxt<$tcx, '_>, key: &Self::Key) -> DepNode { + fn to_dep_node(tcx: TyCtxt<$tcx>, key: &Self::Key) -> DepNode { use crate::dep_graph::DepConstructor::*; DepNode::new(tcx, $node(*key)) } #[inline] - fn compute(tcx: TyCtxt<'tcx, '_>, key: Self::Key) -> Self::Value { + fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value { __query_compute::$name(move || { let provider = tcx.queries.providers.get(key.query_crate()) // HACK(eddyb) it's possible crates may be loaded after @@ -987,7 +987,7 @@ macro_rules! define_queries_inner { } fn handle_cycle_error( - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, error: CycleError<'tcx> ) -> Self::Value { handle_cycle_error!([$($modifiers)*][tcx, error]) @@ -995,11 +995,11 @@ macro_rules! define_queries_inner { })* #[derive(Copy, Clone)] - pub struct TyCtxtEnsure<'gcx, 'tcx> { - pub tcx: TyCtxt<'gcx, 'tcx>, + pub struct TyCtxtEnsure<'tcx> { + pub tcx: TyCtxt<'tcx>, } - impl TyCtxtEnsure<$tcx, 'lcx> { + impl TyCtxtEnsure<$tcx> { $($(#[$attr])* #[inline(always)] pub fn $name(self, key: $K) { @@ -1008,24 +1008,24 @@ macro_rules! define_queries_inner { } #[derive(Copy, Clone)] - pub struct TyCtxtAt<'gcx, 'tcx> { - pub tcx: TyCtxt<'gcx, 'tcx>, + pub struct TyCtxtAt<'tcx> { + pub tcx: TyCtxt<'tcx>, pub span: Span, } - impl Deref for TyCtxtAt<'gcx, 'tcx> { - type Target = TyCtxt<'gcx, 'tcx>; + impl Deref for TyCtxtAt<'tcx> { + type Target = TyCtxt<'tcx>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.tcx } } - impl TyCtxt<$tcx, 'lcx> { + impl TyCtxt<$tcx> { /// Returns a transparent wrapper for `TyCtxt`, which ensures queries /// are executed instead of just returing their results. #[inline(always)] - pub fn ensure(self) -> TyCtxtEnsure<$tcx, 'lcx> { + pub fn ensure(self) -> TyCtxtEnsure<$tcx> { TyCtxtEnsure { tcx: self, } @@ -1034,7 +1034,7 @@ macro_rules! define_queries_inner { /// Returns a transparent wrapper for `TyCtxt` which uses /// `span` as the location of queries performed through it. #[inline(always)] - pub fn at(self, span: Span) -> TyCtxtAt<$tcx, 'lcx> { + pub fn at(self, span: Span) -> TyCtxtAt<$tcx> { TyCtxtAt { tcx: self, span @@ -1048,7 +1048,7 @@ macro_rules! define_queries_inner { })* } - impl TyCtxtAt<$tcx, 'lcx> { + impl TyCtxtAt<$tcx> { $($(#[$attr])* #[inline(always)] pub fn $name(self, key: $K) -> $V { @@ -1089,12 +1089,12 @@ macro_rules! define_provider_struct { (tcx: $tcx:tt, input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => { pub struct Providers<$tcx> { - $(pub $name: fn(TyCtxt<$tcx, $tcx>, $K) -> $R,)* + $(pub $name: fn(TyCtxt<$tcx>, $K) -> $R,)* } impl<$tcx> Default for Providers<$tcx> { fn default() -> Self { - $(fn $name<$tcx>(_: TyCtxt<$tcx, $tcx>, key: $K) -> $R { + $(fn $name<$tcx>(_: TyCtxt<$tcx>, key: $K) -> $R { bug!("tcx.{}({:?}) unsupported by its crate", stringify!($name), key); })* @@ -1147,7 +1147,7 @@ macro_rules! define_provider_struct { /// then `force_from_dep_node()` should not fail for it. Otherwise, you can just /// add it to the "We don't have enough information to reconstruct..." group in /// the match below. -pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> bool { +pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool { use crate::dep_graph::RecoverKey; // We must avoid ever having to call force_from_dep_node() for a @@ -1233,7 +1233,7 @@ macro_rules! impl_load_from_cache { impl DepNode { // Check whether the query invocation corresponding to the given // DepNode is eligible for on-disk-caching. - pub fn cache_on_disk(&self, tcx: TyCtxt<'_, '_>) -> bool { + pub fn cache_on_disk(&self, tcx: TyCtxt<'_>) -> bool { use crate::ty::query::queries; use crate::ty::query::QueryDescription; @@ -1251,7 +1251,7 @@ macro_rules! impl_load_from_cache { // above `cache_on_disk` methods returns true. // Also, as a sanity check, it expects that the corresponding query // invocation has been marked as green already. - pub fn load_from_on_disk_cache(&self, tcx: TyCtxt<'_, '_>) { + pub fn load_from_on_disk_cache(&self, tcx: TyCtxt<'_>) { match self.kind { $(DepKind::$dep_kind => { debug_assert!(tcx.dep_graph diff --git a/src/librustc/ty/query/values.rs b/src/librustc/ty/query/values.rs index 5c6b2e172d3c3..0149f75716477 100644 --- a/src/librustc/ty/query/values.rs +++ b/src/librustc/ty/query/values.rs @@ -4,36 +4,36 @@ use crate::ty::util::NeedsDrop; use syntax::symbol::InternedString; pub(super) trait Value<'tcx>: Sized { - fn from_cycle_error(tcx: TyCtxt<'tcx, 'tcx>) -> Self; + fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self; } impl<'tcx, T> Value<'tcx> for T { - default fn from_cycle_error(tcx: TyCtxt<'tcx, 'tcx>) -> T { + default fn from_cycle_error(tcx: TyCtxt<'tcx>) -> T { tcx.sess.abort_if_errors(); bug!("Value::from_cycle_error called without errors"); } } impl<'tcx> Value<'tcx> for Ty<'tcx> { - fn from_cycle_error(tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> { + fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Ty<'tcx> { tcx.types.err } } impl<'tcx> Value<'tcx> for ty::SymbolName { - fn from_cycle_error(_: TyCtxt<'tcx, 'tcx>) -> Self { + fn from_cycle_error(_: TyCtxt<'tcx>) -> Self { ty::SymbolName { name: InternedString::intern("") } } } impl<'tcx> Value<'tcx> for NeedsDrop { - fn from_cycle_error(_: TyCtxt<'tcx, 'tcx>) -> Self { + fn from_cycle_error(_: TyCtxt<'tcx>) -> Self { NeedsDrop(false) } } impl<'tcx> Value<'tcx> for AdtSizedConstraint<'tcx> { - fn from_cycle_error(tcx: TyCtxt<'tcx, 'tcx>) -> Self { + fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self { AdtSizedConstraint(tcx.intern_type_list(&[tcx.types.err])) } } diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 2bd38ff70d4c5..98fd5d1a9818d 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -22,8 +22,8 @@ pub enum Cause { ExistentialRegionBound, // relating an existential region bound } -pub trait TypeRelation<'gcx: 'tcx, 'tcx>: Sized { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx>; +pub trait TypeRelation<'tcx>: Sized { + fn tcx(&self) -> TyCtxt<'tcx>; /// Returns a static string we can use for printouts. fn tag(&self) -> &'static str; @@ -94,27 +94,22 @@ pub trait TypeRelation<'gcx: 'tcx, 'tcx>: Sized { } pub trait Relate<'tcx>: TypeFoldable<'tcx> { - fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) -> RelateResult<'tcx, Self> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a; + fn relate>( + relation: &mut R, + a: &Self, + b: &Self, + ) -> RelateResult<'tcx, Self>; } /////////////////////////////////////////////////////////////////////////// // Relate impls impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::TypeAndMut<'tcx>, b: &ty::TypeAndMut<'tcx>, - ) -> RelateResult<'tcx, ty::TypeAndMut<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::TypeAndMut<'tcx>> { debug!("{}.mts({:?}, {:?})", relation.tag(), a, @@ -133,17 +128,12 @@ impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> { } } -pub fn relate_substs<'a, 'gcx, 'tcx, R>( +pub fn relate_substs>( relation: &mut R, variances: Option<&[ty::Variance]>, a_subst: SubstsRef<'tcx>, b_subst: SubstsRef<'tcx>, -) -> RelateResult<'tcx, SubstsRef<'tcx>> -where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, -{ +) -> RelateResult<'tcx, SubstsRef<'tcx>> { let tcx = relation.tcx(); let params = a_subst.iter().zip(b_subst).enumerate().map(|(i, (a, b))| { @@ -155,16 +145,11 @@ where } impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>, - ) -> RelateResult<'tcx, ty::FnSig<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::FnSig<'tcx>> { let tcx = relation.tcx(); if a.c_variadic != b.c_variadic { @@ -199,16 +184,11 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> { } impl<'tcx> Relate<'tcx> for ast::Unsafety { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ast::Unsafety, b: &ast::Unsafety, - ) -> RelateResult<'tcx, ast::Unsafety> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ast::Unsafety> { if a != b { Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b))) } else { @@ -218,16 +198,11 @@ impl<'tcx> Relate<'tcx> for ast::Unsafety { } impl<'tcx> Relate<'tcx> for abi::Abi { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &abi::Abi, b: &abi::Abi, - ) -> RelateResult<'tcx, abi::Abi> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, abi::Abi> { if a == b { Ok(*a) } else { @@ -237,16 +212,11 @@ impl<'tcx> Relate<'tcx> for abi::Abi { } impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::ProjectionTy<'tcx>, b: &ty::ProjectionTy<'tcx>, - ) -> RelateResult<'tcx, ty::ProjectionTy<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::ProjectionTy<'tcx>> { if a.item_def_id != b.item_def_id { Err(TypeError::ProjectionMismatched( expected_found(relation, &a.item_def_id, &b.item_def_id))) @@ -261,16 +231,11 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> { } impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::ExistentialProjection<'tcx>, b: &ty::ExistentialProjection<'tcx>, - ) -> RelateResult<'tcx, ty::ExistentialProjection<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::ExistentialProjection<'tcx>> { if a.item_def_id != b.item_def_id { Err(TypeError::ProjectionMismatched( expected_found(relation, &a.item_def_id, &b.item_def_id))) @@ -287,16 +252,11 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> { } impl<'tcx> Relate<'tcx> for Vec> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &Vec>, b: &Vec>, - ) -> RelateResult<'tcx, Vec>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, Vec>> { // To be compatible, `a` and `b` must be for precisely the // same set of traits and item names. We always require that // projection bounds lists are sorted by trait-def-id and item-name, @@ -314,16 +274,11 @@ impl<'tcx> Relate<'tcx> for Vec> { } impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::TraitRef<'tcx>, b: &ty::TraitRef<'tcx>, - ) -> RelateResult<'tcx, ty::TraitRef<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::TraitRef<'tcx>> { // Different traits cannot be related if a.def_id != b.def_id { Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id))) @@ -335,16 +290,11 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> { } impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::ExistentialTraitRef<'tcx>, b: &ty::ExistentialTraitRef<'tcx>, - ) -> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>> { // Different traits cannot be related if a.def_id != b.def_id { Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id))) @@ -365,16 +315,11 @@ TupleStructTypeFoldableImpl! { } impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &GeneratorWitness<'tcx>, b: &GeneratorWitness<'tcx>, - ) -> RelateResult<'tcx, GeneratorWitness<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, GeneratorWitness<'tcx>> { assert_eq!(a.0.len(), b.0.len()); let tcx = relation.tcx(); let types = tcx.mk_type_list(a.0.iter().zip(b.0).map(|(a, b)| relation.relate(a, b)))?; @@ -383,16 +328,11 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> { } impl<'tcx> Relate<'tcx> for Ty<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &Ty<'tcx>, b: &Ty<'tcx>, - ) -> RelateResult<'tcx, Ty<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, Ty<'tcx>> { relation.tys(a, b) } } @@ -400,16 +340,11 @@ impl<'tcx> Relate<'tcx> for Ty<'tcx> { /// The main "type relation" routine. Note that this does not handle /// inference artifacts, so you should filter those out before calling /// it. -pub fn super_relate_tys<'a, 'gcx, 'tcx, R>( +pub fn super_relate_tys>( relation: &mut R, a: Ty<'tcx>, b: Ty<'tcx>, -) -> RelateResult<'tcx, Ty<'tcx>> -where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, -{ +) -> RelateResult<'tcx, Ty<'tcx>> { let tcx = relation.tcx(); debug!("super_relate_tys: a={:?} b={:?}", a, b); match (&a.sty, &b.sty) { @@ -604,16 +539,11 @@ where /// The main "const relation" routine. Note that this does not handle /// inference artifacts, so you should filter those out before calling /// it. -pub fn super_relate_consts<'a, 'gcx, 'tcx, R>( +pub fn super_relate_consts>( relation: &mut R, a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, -) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> -where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, -{ +) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { let tcx = relation.tcx(); let eagerly_eval = |x: &'tcx ty::Const<'tcx>| { @@ -688,12 +618,11 @@ where } impl<'tcx> Relate<'tcx> for &'tcx ty::List> { - fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) -> RelateResult<'tcx, Self> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + fn relate>( + relation: &mut R, + a: &Self, + b: &Self, + ) -> RelateResult<'tcx, Self> { if a.len() != b.len() { return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))); } @@ -713,104 +642,73 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List> { } impl<'tcx> Relate<'tcx> for ty::ClosureSubsts<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::ClosureSubsts<'tcx>, b: &ty::ClosureSubsts<'tcx>, - ) -> RelateResult<'tcx, ty::ClosureSubsts<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::ClosureSubsts<'tcx>> { let substs = relate_substs(relation, None, a.substs, b.substs)?; Ok(ty::ClosureSubsts { substs }) } } impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::GeneratorSubsts<'tcx>, b: &ty::GeneratorSubsts<'tcx>, - ) -> RelateResult<'tcx, ty::GeneratorSubsts<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::GeneratorSubsts<'tcx>> { let substs = relate_substs(relation, None, a.substs, b.substs)?; Ok(ty::GeneratorSubsts { substs }) } } impl<'tcx> Relate<'tcx> for SubstsRef<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &SubstsRef<'tcx>, b: &SubstsRef<'tcx>, - ) -> RelateResult<'tcx, SubstsRef<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, SubstsRef<'tcx>> { relate_substs(relation, None, a, b) } } impl<'tcx> Relate<'tcx> for ty::Region<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::Region<'tcx>, b: &ty::Region<'tcx>, - ) -> RelateResult<'tcx, ty::Region<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::Region<'tcx>> { relation.regions(*a, *b) } } impl<'tcx> Relate<'tcx> for &'tcx ty::Const<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &&'tcx ty::Const<'tcx>, b: &&'tcx ty::Const<'tcx>, - ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { relation.consts(*a, *b) } } impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::Binder, b: &ty::Binder, - ) -> RelateResult<'tcx, ty::Binder> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::Binder> { relation.binders(a, b) } } impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc { - fn relate<'a, 'gcx, R>(relation: &mut R, a: &Rc, b: &Rc) -> RelateResult<'tcx, Rc> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + fn relate>( + relation: &mut R, + a: &Rc, + b: &Rc, + ) -> RelateResult<'tcx, Rc> { let a: &T = a; let b: &T = b; Ok(Rc::new(relation.relate(a, b)?)) @@ -818,12 +716,11 @@ impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc { } impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Box { - fn relate<'a, 'gcx, R>(relation: &mut R, a: &Box, b: &Box) -> RelateResult<'tcx, Box> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + fn relate>( + relation: &mut R, + a: &Box, + b: &Box, + ) -> RelateResult<'tcx, Box> { let a: &T = a; let b: &T = b; Ok(Box::new(relation.relate(a, b)?)) @@ -831,16 +728,11 @@ impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Box { } impl<'tcx> Relate<'tcx> for Kind<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &Kind<'tcx>, b: &Kind<'tcx>, - ) -> RelateResult<'tcx, Kind<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'a + 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, Kind<'tcx>> { match (a.unpack(), b.unpack()) { (UnpackedKind::Lifetime(a_lt), UnpackedKind::Lifetime(b_lt)) => { Ok(relation.relate(&a_lt, &b_lt)?.into()) @@ -865,16 +757,11 @@ impl<'tcx> Relate<'tcx> for Kind<'tcx> { } impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::TraitPredicate<'tcx>, b: &ty::TraitPredicate<'tcx>, - ) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>> { Ok(ty::TraitPredicate { trait_ref: relation.relate(&a.trait_ref, &b.trait_ref)?, }) @@ -882,16 +769,11 @@ impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> { } impl<'tcx> Relate<'tcx> for ty::ProjectionPredicate<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &ty::ProjectionPredicate<'tcx>, b: &ty::ProjectionPredicate<'tcx>, - ) -> RelateResult<'tcx, ty::ProjectionPredicate<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, ty::ProjectionPredicate<'tcx>> { Ok(ty::ProjectionPredicate { projection_ty: relation.relate(&a.projection_ty, &b.projection_ty)?, ty: relation.relate(&a.ty, &b.ty)?, @@ -900,16 +782,11 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionPredicate<'tcx> { } impl<'tcx> Relate<'tcx> for traits::WhereClause<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::WhereClause<'tcx>, b: &traits::WhereClause<'tcx>, - ) -> RelateResult<'tcx, traits::WhereClause<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::WhereClause<'tcx>> { use crate::traits::WhereClause::*; match (a, b) { (Implemented(a_pred), Implemented(b_pred)) => { @@ -940,16 +817,11 @@ impl<'tcx> Relate<'tcx> for traits::WhereClause<'tcx> { } impl<'tcx> Relate<'tcx> for traits::WellFormed<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::WellFormed<'tcx>, b: &traits::WellFormed<'tcx>, - ) -> RelateResult<'tcx, traits::WellFormed<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::WellFormed<'tcx>> { use crate::traits::WellFormed::*; match (a, b) { (Trait(a_pred), Trait(b_pred)) => Ok(Trait(relation.relate(a_pred, b_pred)?)), @@ -960,16 +832,11 @@ impl<'tcx> Relate<'tcx> for traits::WellFormed<'tcx> { } impl<'tcx> Relate<'tcx> for traits::FromEnv<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::FromEnv<'tcx>, b: &traits::FromEnv<'tcx>, - ) -> RelateResult<'tcx, traits::FromEnv<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::FromEnv<'tcx>> { use crate::traits::FromEnv::*; match (a, b) { (Trait(a_pred), Trait(b_pred)) => Ok(Trait(relation.relate(a_pred, b_pred)?)), @@ -980,16 +847,11 @@ impl<'tcx> Relate<'tcx> for traits::FromEnv<'tcx> { } impl<'tcx> Relate<'tcx> for traits::DomainGoal<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::DomainGoal<'tcx>, b: &traits::DomainGoal<'tcx>, - ) -> RelateResult<'tcx, traits::DomainGoal<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::DomainGoal<'tcx>> { use crate::traits::DomainGoal::*; match (a, b) { (Holds(a_wc), Holds(b_wc)) => Ok(Holds(relation.relate(a_wc, b_wc)?)), @@ -1006,16 +868,11 @@ impl<'tcx> Relate<'tcx> for traits::DomainGoal<'tcx> { } impl<'tcx> Relate<'tcx> for traits::Goal<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::Goal<'tcx>, b: &traits::Goal<'tcx>, - ) -> RelateResult<'tcx, traits::Goal<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::Goal<'tcx>> { use crate::traits::GoalKind::*; match (a, b) { (Implies(a_clauses, a_goal), Implies(b_clauses, b_goal)) => { @@ -1055,16 +912,11 @@ impl<'tcx> Relate<'tcx> for traits::Goal<'tcx> { } impl<'tcx> Relate<'tcx> for traits::Goals<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::Goals<'tcx>, b: &traits::Goals<'tcx>, - ) -> RelateResult<'tcx, traits::Goals<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::Goals<'tcx>> { if a.len() != b.len() { return Err(TypeError::Mismatch); } @@ -1076,16 +928,11 @@ impl<'tcx> Relate<'tcx> for traits::Goals<'tcx> { } impl<'tcx> Relate<'tcx> for traits::Clause<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::Clause<'tcx>, b: &traits::Clause<'tcx>, - ) -> RelateResult<'tcx, traits::Clause<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::Clause<'tcx>> { use crate::traits::Clause::*; match (a, b) { (Implies(a_clause), Implies(b_clause)) => { @@ -1104,16 +951,11 @@ impl<'tcx> Relate<'tcx> for traits::Clause<'tcx> { } impl<'tcx> Relate<'tcx> for traits::Clauses<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::Clauses<'tcx>, b: &traits::Clauses<'tcx>, - ) -> RelateResult<'tcx, traits::Clauses<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::Clauses<'tcx>> { if a.len() != b.len() { return Err(TypeError::Mismatch); } @@ -1125,16 +967,11 @@ impl<'tcx> Relate<'tcx> for traits::Clauses<'tcx> { } impl<'tcx> Relate<'tcx> for traits::ProgramClause<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::ProgramClause<'tcx>, b: &traits::ProgramClause<'tcx>, - ) -> RelateResult<'tcx, traits::ProgramClause<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::ProgramClause<'tcx>> { Ok(traits::ProgramClause { goal: relation.relate(&a.goal, &b.goal)?, hypotheses: relation.relate(&a.hypotheses, &b.hypotheses)?, @@ -1144,16 +981,11 @@ impl<'tcx> Relate<'tcx> for traits::ProgramClause<'tcx> { } impl<'tcx> Relate<'tcx> for traits::Environment<'tcx> { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::Environment<'tcx>, b: &traits::Environment<'tcx>, - ) -> RelateResult<'tcx, traits::Environment<'tcx>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::Environment<'tcx>> { Ok(traits::Environment { clauses: relation.relate(&a.clauses, &b.clauses)?, }) @@ -1164,16 +996,11 @@ impl<'tcx, G> Relate<'tcx> for traits::InEnvironment<'tcx, G> where G: Relate<'tcx>, { - fn relate<'a, 'gcx, R>( + fn relate>( relation: &mut R, a: &traits::InEnvironment<'tcx, G>, b: &traits::InEnvironment<'tcx, G>, - ) -> RelateResult<'tcx, traits::InEnvironment<'tcx, G>> - where - R: TypeRelation<'gcx, 'tcx>, - 'gcx: 'tcx, - 'tcx: 'a, - { + ) -> RelateResult<'tcx, traits::InEnvironment<'tcx, G>> { Ok(traits::InEnvironment { environment: relation.relate(&a.environment, &b.environment)?, goal: relation.relate(&a.goal, &b.goal)?, @@ -1184,12 +1011,10 @@ where /////////////////////////////////////////////////////////////////////////// // Error handling -pub fn expected_found<'a, 'gcx, 'tcx, R, T>(relation: &mut R, a: &T, b: &T) -> ExpectedFound +pub fn expected_found(relation: &mut R, a: &T, b: &T) -> ExpectedFound where - R: TypeRelation<'gcx, 'tcx>, + R: TypeRelation<'tcx>, T: Clone, - 'gcx: 'a + 'tcx, - 'tcx: 'a, { expected_found_bool(relation.a_is_expected(), a, b) } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 35c61f83fceb2..9756e9c872bc3 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -337,14 +337,14 @@ CloneTypeFoldableAndLiftImpls! { // FIXME(eddyb) replace all the uses of `Option::map` with `?`. impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) { type Lifted = (A::Lifted, B::Lifted); - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.0).and_then(|a| tcx.lift(&self.1).map(|b| (a, b))) } } impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>, C: Lift<'tcx>> Lift<'tcx> for (A, B, C) { type Lifted = (A::Lifted, B::Lifted, C::Lifted); - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.0).and_then(|a| { tcx.lift(&self.1).and_then(|b| tcx.lift(&self.2).map(|c| (a, b, c))) }) @@ -353,7 +353,7 @@ impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>, C: Lift<'tcx>> Lift<'tcx> for (A, B, C) impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option { type Lifted = Option; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { Some(ref x) => tcx.lift(x).map(Some), None => Some(None) @@ -363,7 +363,7 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option { impl<'tcx, T: Lift<'tcx>, E: Lift<'tcx>> Lift<'tcx> for Result { type Lifted = Result; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { Ok(ref x) => tcx.lift(x).map(Ok), Err(ref e) => tcx.lift(e).map(Err) @@ -373,14 +373,14 @@ impl<'tcx, T: Lift<'tcx>, E: Lift<'tcx>> Lift<'tcx> for Result { impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Box { type Lifted = Box; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&**self).map(Box::new) } } impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] { type Lifted = Vec; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { // type annotation needed to inform `projection_must_outlive` let mut result : Vec<>::Lifted> = Vec::with_capacity(self.len()); @@ -397,14 +397,14 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] { impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec { type Lifted = Vec; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self[..]) } } impl<'tcx, I: Idx, T: Lift<'tcx>> Lift<'tcx> for IndexVec { type Lifted = IndexVec; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { self.iter() .map(|e| tcx.lift(e)) .collect() @@ -413,7 +413,7 @@ impl<'tcx, I: Idx, T: Lift<'tcx>> Lift<'tcx> for IndexVec { impl<'a, 'tcx> Lift<'tcx> for ty::TraitRef<'a> { type Lifted = ty::TraitRef<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.substs).map(|substs| ty::TraitRef { def_id: self.def_id, substs, @@ -423,7 +423,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitRef<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialTraitRef<'a> { type Lifted = ty::ExistentialTraitRef<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.substs).map(|substs| ty::ExistentialTraitRef { def_id: self.def_id, substs, @@ -433,7 +433,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialTraitRef<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> { type Lifted = ty::ExistentialPredicate<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match self { ty::ExistentialPredicate::Trait(x) => { tcx.lift(x).map(ty::ExistentialPredicate::Trait) @@ -450,7 +450,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> { type Lifted = ty::TraitPredicate<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option> { tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate { trait_ref, }) @@ -459,7 +459,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> { type Lifted = ty::SubtypePredicate<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option> { tcx.lift(&(self.a, self.b)).map(|(a, b)| ty::SubtypePredicate { a_is_expected: self.a_is_expected, a, @@ -470,14 +470,14 @@ impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> { impl<'tcx, A: Copy + Lift<'tcx>, B: Copy + Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate { type Lifted = ty::OutlivesPredicate; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b)) } } impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> { type Lifted = ty::ProjectionTy<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option> { tcx.lift(&self.substs).map(|substs| { ty::ProjectionTy { item_def_id: self.item_def_id, @@ -489,7 +489,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> { type Lifted = ty::ProjectionPredicate<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option> { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option> { tcx.lift(&(self.projection_ty, self.ty)).map(|(projection_ty, ty)| { ty::ProjectionPredicate { projection_ty, @@ -501,7 +501,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialProjection<'a> { type Lifted = ty::ExistentialProjection<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.substs).map(|substs| { ty::ExistentialProjection { substs, @@ -514,7 +514,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialProjection<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::Predicate<'a> { type Lifted = ty::Predicate<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { ty::Predicate::Trait(ref binder) => { tcx.lift(binder).map(ty::Predicate::Trait) @@ -554,14 +554,14 @@ impl<'a, 'tcx> Lift<'tcx> for ty::Predicate<'a> { impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder { type Lifted = ty::Binder; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(self.skip_binder()).map(ty::Binder::bind) } } impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> { type Lifted = ty::ParamEnv<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.caller_bounds).map(|caller_bounds| { ty::ParamEnv { reveal: self.reveal, @@ -574,7 +574,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> { impl<'a, 'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::ParamEnvAnd<'a, T> { type Lifted = ty::ParamEnvAnd<'tcx, T::Lifted>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.param_env).and_then(|param_env| { tcx.lift(&self.value).map(|value| { ty::ParamEnvAnd { @@ -588,7 +588,7 @@ impl<'a, 'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::ParamEnvAnd<'a, T> { impl<'a, 'tcx> Lift<'tcx> for ty::ClosureSubsts<'a> { type Lifted = ty::ClosureSubsts<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.substs).map(|substs| { ty::ClosureSubsts { substs } }) @@ -597,7 +597,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ClosureSubsts<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::GeneratorSubsts<'a> { type Lifted = ty::GeneratorSubsts<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.substs).map(|substs| { ty::GeneratorSubsts { substs } }) @@ -606,7 +606,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::GeneratorSubsts<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjustment<'a> { type Lifted = ty::adjustment::Adjustment<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.kind).and_then(|kind| { tcx.lift(&self.target).map(|target| { ty::adjustment::Adjustment { kind, target } @@ -617,7 +617,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjustment<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjust<'a> { type Lifted = ty::adjustment::Adjust<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { ty::adjustment::Adjust::NeverToAny => Some(ty::adjustment::Adjust::NeverToAny), @@ -635,7 +635,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjust<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::OverloadedDeref<'a> { type Lifted = ty::adjustment::OverloadedDeref<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.region).map(|region| { ty::adjustment::OverloadedDeref { region, @@ -647,7 +647,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::OverloadedDeref<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> { type Lifted = ty::adjustment::AutoBorrow<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { ty::adjustment::AutoBorrow::Ref(r, m) => { tcx.lift(&r).map(|r| ty::adjustment::AutoBorrow::Ref(r, m)) @@ -661,7 +661,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> { type Lifted = ty::GenSig<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&(self.yield_ty, self.return_ty)) .map(|(yield_ty, return_ty)| { ty::GenSig { @@ -674,7 +674,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> { type Lifted = ty::FnSig<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.inputs_and_output).map(|x| { ty::FnSig { inputs_and_output: x, @@ -688,7 +688,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> { impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::error::ExpectedFound { type Lifted = ty::error::ExpectedFound; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(&self.expected).and_then(|expected| { tcx.lift(&self.found).map(|found| { ty::error::ExpectedFound { @@ -702,7 +702,7 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::error::ExpectedFound { impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> { type Lifted = ty::error::TypeError<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { use crate::ty::error::TypeError::*; Some(match *self { @@ -739,7 +739,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> { impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> { type Lifted = ty::InstanceDef<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match *self { ty::InstanceDef::Item(def_id) => Some(ty::InstanceDef::Item(def_id)), @@ -795,7 +795,7 @@ BraceStructLiftImpl! { /// AdtDefs are basically the same as a DefId. impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::AdtDef { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self { + fn super_fold_with>(&self, _folder: &mut F) -> Self { *self } @@ -805,7 +805,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::AdtDef { } impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> (T, U) { + fn super_fold_with>(&self, folder: &mut F) -> (T, U) { (self.0.fold_with(folder), self.1.fold_with(folder)) } @@ -822,7 +822,7 @@ EnumTypeFoldableImpl! { } impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { Rc::new((**self).fold_with(folder)) } @@ -832,7 +832,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc { } impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let content: T = (**self).fold_with(folder); box content } @@ -843,7 +843,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box { } impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { self.iter().map(|t| t.fold_with(folder)).collect() } @@ -853,7 +853,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec { } impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { self.iter().map(|t| t.fold_with(folder)).collect::>().into_boxed_slice() } @@ -863,11 +863,11 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> { } impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { self.map_bound_ref(|ty| ty.fold_with(folder)) } - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn fold_with>(&self, folder: &mut F) -> Self { folder.fold_binder(self) } @@ -885,7 +885,7 @@ BraceStructTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_existential_predicates(&v) } @@ -904,7 +904,7 @@ EnumTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); folder.tcx().intern_type_list(&v) } @@ -915,7 +915,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); folder.tcx().intern_projs(&v) } @@ -926,7 +926,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List { } impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { use crate::ty::InstanceDef::*; Self { substs: self.substs.fold_with(folder), @@ -976,7 +976,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { Self { instance: self.instance.fold_with(folder), promoted: self.promoted @@ -989,7 +989,7 @@ impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let sty = match self.sty { ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)), ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)), @@ -1041,7 +1041,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { } } - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn fold_with>(&self, folder: &mut F) -> Self { folder.fold_ty(*self) } @@ -1124,11 +1124,11 @@ BraceStructTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for ty::Region<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self { + fn super_fold_with>(&self, _folder: &mut F) -> Self { *self } - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn fold_with>(&self, folder: &mut F) -> Self { folder.fold_region(*self) } @@ -1189,7 +1189,7 @@ BraceStructTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_predicates(&v) } @@ -1274,7 +1274,7 @@ BraceStructTypeFoldableImpl! { } impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { self.iter().map(|x| x.fold_with(folder)).collect() } @@ -1310,7 +1310,7 @@ EnumTypeFoldableImpl! { } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let ty = self.ty.fold_with(folder); let val = self.val.fold_with(folder); folder.tcx().mk_const(ty::Const { @@ -1319,7 +1319,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { }) } - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn fold_with>(&self, folder: &mut F) -> Self { folder.fold_const(*self) } @@ -1333,7 +1333,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { match *self { ConstValue::ByRef(ptr, alloc) => ConstValue::ByRef(ptr, alloc), ConstValue::Infer(ic) => ConstValue::Infer(ic.fold_with(folder)), @@ -1360,7 +1360,7 @@ impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> { } impl<'tcx> TypeFoldable<'tcx> for InferConst<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self { + fn super_fold_with>(&self, _folder: &mut F) -> Self { *self } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index dc2d96ee8b946..ed4a2cd7a298b 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -324,7 +324,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// Divides the closure substs into their respective /// components. Single source of truth with respect to the /// ordering. - fn split(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> SplitClosureSubsts<'tcx> { + fn split(self, def_id: DefId, tcx: TyCtxt<'_>) -> SplitClosureSubsts<'tcx> { let generics = tcx.generics_of(def_id); let parent_len = generics.parent_count; SplitClosureSubsts { @@ -338,7 +338,7 @@ impl<'tcx> ClosureSubsts<'tcx> { pub fn upvar_tys( self, def_id: DefId, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, ) -> impl Iterator> + 'tcx { let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { @@ -353,7 +353,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// Returns the closure kind for this closure; may return a type /// variable during inference. To get the closure kind during /// inference, use `infcx.closure_kind(def_id, substs)`. - pub fn closure_kind_ty(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> Ty<'tcx> { + pub fn closure_kind_ty(self, def_id: DefId, tcx: TyCtxt<'_>) -> Ty<'tcx> { self.split(def_id, tcx).closure_kind_ty } @@ -361,7 +361,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// closure; may contain type variables during inference. To get /// the closure signature during inference, use /// `infcx.fn_sig(def_id)`. - pub fn closure_sig_ty(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> Ty<'tcx> { + pub fn closure_sig_ty(self, def_id: DefId, tcx: TyCtxt<'_>) -> Ty<'tcx> { self.split(def_id, tcx).closure_sig_ty } @@ -370,7 +370,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// there are no type variables. /// /// If you have an inference context, use `infcx.closure_kind()`. - pub fn closure_kind(self, def_id: DefId, tcx: TyCtxt<'tcx, 'tcx>) -> ty::ClosureKind { + pub fn closure_kind(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> ty::ClosureKind { self.split(def_id, tcx).closure_kind_ty.to_opt_closure_kind().unwrap() } @@ -379,7 +379,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// there are no type variables. /// /// If you have an inference context, use `infcx.closure_sig()`. - pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> { + pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { let ty = self.closure_sig_ty(def_id, tcx); match ty.sty { ty::FnPtr(sig) => sig, @@ -403,7 +403,7 @@ struct SplitGeneratorSubsts<'tcx> { } impl<'tcx> GeneratorSubsts<'tcx> { - fn split(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> SplitGeneratorSubsts<'tcx> { + fn split(self, def_id: DefId, tcx: TyCtxt<'_>) -> SplitGeneratorSubsts<'tcx> { let generics = tcx.generics_of(def_id); let parent_len = generics.parent_count; SplitGeneratorSubsts { @@ -419,7 +419,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { /// It contains a tuple of all the types that could end up on a generator frame. /// The state transformation MIR pass may only produce layouts which mention types /// in this tuple. Upvars are not counted here. - pub fn witness(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> Ty<'tcx> { + pub fn witness(self, def_id: DefId, tcx: TyCtxt<'_>) -> Ty<'tcx> { self.split(def_id, tcx).witness } @@ -427,7 +427,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { pub fn upvar_tys( self, def_id: DefId, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, ) -> impl Iterator> + 'tcx { let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { @@ -440,12 +440,12 @@ impl<'tcx> GeneratorSubsts<'tcx> { } /// Returns the type representing the yield type of the generator. - pub fn yield_ty(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> Ty<'tcx> { + pub fn yield_ty(self, def_id: DefId, tcx: TyCtxt<'_>) -> Ty<'tcx> { self.split(def_id, tcx).yield_ty } /// Returns the type representing the return type of the generator. - pub fn return_ty(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> Ty<'tcx> { + pub fn return_ty(self, def_id: DefId, tcx: TyCtxt<'_>) -> Ty<'tcx> { self.split(def_id, tcx).return_ty } @@ -455,13 +455,13 @@ impl<'tcx> GeneratorSubsts<'tcx> { /// N.B., some bits of the code prefers to see this wrapped in a /// binder, but it never contains bound regions. Probably this /// function should be removed. - pub fn poly_sig(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> PolyGenSig<'tcx> { + pub fn poly_sig(self, def_id: DefId, tcx: TyCtxt<'_>) -> PolyGenSig<'tcx> { ty::Binder::dummy(self.sig(def_id, tcx)) } /// Returns the "generator signature", which consists of its yield /// and return types. - pub fn sig(self, def_id: DefId, tcx: TyCtxt<'_, '_>) -> GenSig<'tcx> { + pub fn sig(self, def_id: DefId, tcx: TyCtxt<'_>) -> GenSig<'tcx> { ty::GenSig { yield_ty: self.yield_ty(def_id, tcx), return_ty: self.return_ty(def_id, tcx), @@ -469,7 +469,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { } } -impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { +impl<'tcx> GeneratorSubsts<'tcx> { /// Generator have not been resumed yet pub const UNRESUMED: usize = 0; /// Generator has returned / is completed @@ -483,7 +483,7 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { /// The valid variant indices of this Generator. #[inline] - pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>) -> Range { + pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range { // FIXME requires optimized MIR let num_variants = tcx.generator_layout(def_id).variant_fields.len(); (VariantIdx::new(0)..VariantIdx::new(num_variants)) @@ -495,7 +495,7 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { pub fn discriminant_for_variant( &self, def_id: DefId, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, variant_index: VariantIdx, ) -> Discr<'tcx> { // Generators don't support explicit discriminant values, so they are @@ -510,8 +510,8 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { pub fn discriminants( &'tcx self, def_id: DefId, - tcx: TyCtxt<'gcx, 'tcx>, - ) -> impl Iterator)> + Captures<'gcx> { + tcx: TyCtxt<'tcx>, + ) -> impl Iterator)> + Captures<'tcx> { self.variant_range(def_id, tcx).map(move |index| { (index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) }) }) @@ -531,7 +531,7 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { /// The type of the state discriminant used in the generator type. #[inline] - pub fn discr_ty(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + pub fn discr_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { tcx.types.u32 } @@ -545,8 +545,8 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { pub fn state_tys( self, def_id: DefId, - tcx: TyCtxt<'gcx, 'tcx>, - ) -> impl Iterator> + Captures<'gcx>> { + tcx: TyCtxt<'tcx>, + ) -> impl Iterator> + Captures<'tcx>> { let layout = tcx.generator_layout(def_id); layout.variant_fields.iter().map(move |variant| { variant.iter().map(move |field| { @@ -561,7 +561,7 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> { pub fn prefix_tys( self, def_id: DefId, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> impl Iterator> { self.upvar_tys(def_id, tcx) } @@ -578,7 +578,7 @@ impl<'tcx> UpvarSubsts<'tcx> { pub fn upvar_tys( self, def_id: DefId, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, ) -> impl Iterator> + 'tcx { let upvar_kinds = match self { UpvarSubsts::Closure(substs) => substs.split(def_id, tcx).upvar_kinds, @@ -605,10 +605,10 @@ pub enum ExistentialPredicate<'tcx> { AutoTrait(DefId), } -impl<'gcx, 'tcx> ExistentialPredicate<'tcx> { +impl<'tcx> ExistentialPredicate<'tcx> { /// Compares via an ordering that will not change if modules are reordered or other changes are /// made to the tree. In particular, this ordering is preserved across incremental compilations. - pub fn stable_cmp(&self, tcx: TyCtxt<'gcx, 'tcx>, other: &Self) -> Ordering { + pub fn stable_cmp(&self, tcx: TyCtxt<'tcx>, other: &Self) -> Ordering { use self::ExistentialPredicate::*; match (*self, *other) { (Trait(_), Trait(_)) => Ordering::Equal, @@ -624,8 +624,8 @@ impl<'gcx, 'tcx> ExistentialPredicate<'tcx> { } } -impl<'gcx, 'tcx> Binder> { - pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> { +impl<'tcx> Binder> { + pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> { use crate::ty::ToPredicate; match *self.skip_binder() { ExistentialPredicate::Trait(tr) => Binder(tr).with_self_ty(tcx, self_ty).to_predicate(), @@ -757,7 +757,7 @@ impl<'tcx> TraitRef<'tcx> { /// Returns a `TraitRef` of the form `P0: Foo` where `Pi` /// are the parameters defined on trait. - pub fn identity<'gcx>(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId) -> TraitRef<'tcx> { + pub fn identity(tcx: TyCtxt<'tcx>, def_id: DefId) -> TraitRef<'tcx> { TraitRef { def_id, substs: InternalSubsts::identity_for_item(tcx, def_id), @@ -778,7 +778,7 @@ impl<'tcx> TraitRef<'tcx> { } pub fn from_method( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, trait_id: DefId, substs: SubstsRef<'tcx>, ) -> ty::TraitRef<'tcx> { @@ -822,7 +822,7 @@ pub struct ExistentialTraitRef<'tcx> { pub substs: SubstsRef<'tcx>, } -impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> { +impl<'tcx> ExistentialTraitRef<'tcx> { pub fn input_types<'b>(&'b self) -> impl DoubleEndedIterator> + 'b { // Select only the "input types" from a trait-reference. For // now this is all the types that appear in the @@ -832,7 +832,7 @@ impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> { } pub fn erase_self_ty( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_ref: ty::TraitRef<'tcx>, ) -> ty::ExistentialTraitRef<'tcx> { // Assert there is a Self. @@ -848,7 +848,7 @@ impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> { /// we convert the principal trait-ref into a normal trait-ref, /// you must give *some* self type. A common choice is `mk_err()` /// or some placeholder type. - pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef<'tcx> { + pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef<'tcx> { // otherwise the escaping vars would be captured by the binder // debug_assert!(!self_ty.has_escaping_bound_vars()); @@ -870,7 +870,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> { /// we convert the principal trait-ref into a normal trait-ref, /// you must give *some* self type. A common choice is `mk_err()` /// or some placeholder type. - pub fn with_self_ty(&self, tcx: TyCtxt<'_, 'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> { + pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> { self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty)) } } @@ -1004,7 +1004,7 @@ impl<'tcx> ProjectionTy<'tcx> { /// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the /// associated item named `item_name`. pub fn from_ref_and_name( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, trait_ref: ty::TraitRef<'tcx>, item_name: Ident, ) -> ProjectionTy<'tcx> { @@ -1022,7 +1022,7 @@ impl<'tcx> ProjectionTy<'tcx> { /// Extracts the underlying trait reference from this projection. /// For example, if this is a projection of `::Item`, /// then this function would return a `T: Iterator` trait reference. - pub fn trait_ref(&self, tcx: TyCtxt<'_, '_>) -> ty::TraitRef<'tcx> { + pub fn trait_ref(&self, tcx: TyCtxt<'_>) -> ty::TraitRef<'tcx> { let def_id = tcx.associated_item(self.item_def_id).container.id(); ty::TraitRef { def_id, @@ -1126,7 +1126,7 @@ pub struct ParamTy { pub name: InternedString, } -impl<'gcx, 'tcx> ParamTy { +impl<'tcx> ParamTy { pub fn new(index: u32, name: InternedString) -> ParamTy { ParamTy { index, name: name } } @@ -1139,7 +1139,7 @@ impl<'gcx, 'tcx> ParamTy { ParamTy::new(def.index, def.name) } - pub fn to_ty(self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { tcx.mk_ty_param(self.index, self.name) } @@ -1158,7 +1158,7 @@ pub struct ParamConst { pub name: InternedString, } -impl<'gcx, 'tcx> ParamConst { +impl<'tcx> ParamConst { pub fn new(index: u32, name: InternedString) -> ParamConst { ParamConst { index, name } } @@ -1167,7 +1167,7 @@ impl<'gcx, 'tcx> ParamConst { ParamConst::new(def.index, def.name) } - pub fn to_const(self, tcx: TyCtxt<'gcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx Const<'tcx> { + pub fn to_const(self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> &'tcx Const<'tcx> { tcx.mk_const_param(self.index, self.name, ty) } } @@ -1422,12 +1422,12 @@ pub struct ExistentialProjection<'tcx> { pub type PolyExistentialProjection<'tcx> = Binder>; -impl<'tcx, 'gcx> ExistentialProjection<'tcx> { +impl<'tcx> ExistentialProjection<'tcx> { /// Extracts the underlying existential trait reference from this projection. /// For example, if this is a projection of `exists T. ::Item == X`, /// then this function would return a `exists T. T: Iterator` existential trait /// reference. - pub fn trait_ref(&self, tcx: TyCtxt<'_, '_>) -> ty::ExistentialTraitRef<'tcx> { + pub fn trait_ref(&self, tcx: TyCtxt<'_>) -> ty::ExistentialTraitRef<'tcx> { let def_id = tcx.associated_item(self.item_def_id).container.id(); ty::ExistentialTraitRef{ def_id, @@ -1437,7 +1437,7 @@ impl<'tcx, 'gcx> ExistentialProjection<'tcx> { pub fn with_self_ty( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>, ) -> ty::ProjectionPredicate<'tcx> { // otherwise the escaping regions would be captured by the binders @@ -1453,10 +1453,10 @@ impl<'tcx, 'gcx> ExistentialProjection<'tcx> { } } -impl<'tcx, 'gcx> PolyExistentialProjection<'tcx> { +impl<'tcx> PolyExistentialProjection<'tcx> { pub fn with_self_ty( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>, ) -> ty::PolyProjectionPredicate<'tcx> { self.map_bound(|p| p.with_self_ty(tcx, self_ty)) @@ -1670,7 +1670,7 @@ impl RegionKind { /// of the impl, and for all the other highlighted regions, it /// would return the `DefId` of the function. In other cases (not shown), this /// function might return the `DefId` of a closure. - pub fn free_region_binding_scope(&self, tcx: TyCtxt<'_, '_>) -> DefId { + pub fn free_region_binding_scope(&self, tcx: TyCtxt<'_>) -> DefId { match self { ty::ReEarlyBound(br) => { tcx.parent(br.def_id).unwrap() @@ -1682,7 +1682,7 @@ impl RegionKind { } /// Type utilities -impl<'gcx, 'tcx> TyS<'tcx> { +impl<'tcx> TyS<'tcx> { #[inline] pub fn is_unit(&self) -> bool { match self.sty { @@ -1705,7 +1705,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { /// `ty.conservative_is_privately_uninhabited` implies that any value of type `ty` /// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero /// size, to account for partial initialisation. See #49298 for details.) - pub fn conservative_is_privately_uninhabited(&self, tcx: TyCtxt<'gcx, 'tcx>) -> bool { + pub fn conservative_is_privately_uninhabited(&self, tcx: TyCtxt<'tcx>) -> bool { // FIXME(varkor): we can make this less conversative by substituting concrete // type arguments. match self.sty { @@ -1817,7 +1817,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { } } - pub fn sequence_element_type(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + pub fn sequence_element_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match self.sty { Array(ty, _) | Slice(ty) => ty, Str => tcx.mk_mach_uint(ast::UintTy::U8), @@ -1825,7 +1825,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { } } - pub fn simd_type(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + pub fn simd_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match self.sty { Adt(def, substs) => { def.non_enum_variant().fields[0].ty(tcx, substs) @@ -1834,7 +1834,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { } } - pub fn simd_size(&self, _cx: TyCtxt<'_, '_>) -> usize { + pub fn simd_size(&self, _cx: TyCtxt<'_>) -> usize { match self.sty { Adt(def, _) => def.non_enum_variant().fields.len(), _ => bug!("simd_size called on invalid type") @@ -2054,7 +2054,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { } } - pub fn fn_sig(&self, tcx: TyCtxt<'gcx, 'tcx>) -> PolyFnSig<'tcx> { + pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { match self.sty { FnDef(def_id, substs) => { tcx.fn_sig(def_id).subst(tcx, substs) @@ -2102,7 +2102,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { /// If the type contains variants, returns the valid range of variant indices. /// FIXME This requires the optimized MIR in the case of generators. #[inline] - pub fn variant_range(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option> { + pub fn variant_range(&self, tcx: TyCtxt<'tcx>) -> Option> { match self.sty { TyKind::Adt(adt, _) => Some(adt.variant_range()), TyKind::Generator(def_id, substs, _) => Some(substs.variant_range(def_id, tcx)), @@ -2116,7 +2116,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { #[inline] pub fn discriminant_for_variant( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, variant_index: VariantIdx, ) -> Option> { match self.sty { @@ -2207,7 +2207,7 @@ impl<'gcx, 'tcx> TyS<'tcx> { /// /// Returning true means the type is known to be sized. Returning /// `false` means nothing -- could be sized, might not be. - pub fn is_trivially_sized(&self, tcx: TyCtxt<'_, 'tcx>) -> bool { + pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool { match self.sty { ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | @@ -2257,7 +2257,7 @@ static_assert_size!(Const<'_>, 40); impl<'tcx> Const<'tcx> { #[inline] - pub fn from_scalar(tcx: TyCtxt<'_, 'tcx>, val: Scalar, ty: Ty<'tcx>) -> &'tcx Self { + pub fn from_scalar(tcx: TyCtxt<'tcx>, val: Scalar, ty: Ty<'tcx>) -> &'tcx Self { tcx.mk_const(Self { val: ConstValue::Scalar(val), ty, @@ -2266,7 +2266,7 @@ impl<'tcx> Const<'tcx> { #[inline] pub fn from_bits( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, bits: u128, ty: ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> &'tcx Self { @@ -2278,22 +2278,22 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn zero_sized(tcx: TyCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> &'tcx Self { + pub fn zero_sized(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> &'tcx Self { Self::from_scalar(tcx, Scalar::zst(), ty) } #[inline] - pub fn from_bool(tcx: TyCtxt<'_, 'tcx>, v: bool) -> &'tcx Self { + pub fn from_bool(tcx: TyCtxt<'tcx>, v: bool) -> &'tcx Self { Self::from_bits(tcx, v as u128, ParamEnv::empty().and(tcx.types.bool)) } #[inline] - pub fn from_usize(tcx: TyCtxt<'_, 'tcx>, n: u64) -> &'tcx Self { + pub fn from_usize(tcx: TyCtxt<'tcx>, n: u64) -> &'tcx Self { Self::from_bits(tcx, n as u128, ParamEnv::empty().and(tcx.types.usize)) } #[inline] - pub fn to_bits(&self, tcx: TyCtxt<'_, 'tcx>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option { + pub fn to_bits(&self, tcx: TyCtxt<'tcx>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option { if self.ty != ty.value { return None; } @@ -2310,7 +2310,7 @@ impl<'tcx> Const<'tcx> { #[inline] pub fn assert_bits( &self, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Option { assert_eq!(self.ty, ty.value); @@ -2320,7 +2320,7 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn assert_bool(&self, tcx: TyCtxt<'_, '_>) -> Option { + pub fn assert_bool(&self, tcx: TyCtxt<'_>) -> Option { self.assert_bits(tcx, ParamEnv::empty().and(tcx.types.bool)).and_then(|v| match v { 0 => Some(false), 1 => Some(true), @@ -2329,18 +2329,18 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn assert_usize(&self, tcx: TyCtxt<'_, '_>) -> Option { + pub fn assert_usize(&self, tcx: TyCtxt<'_>) -> Option { self.assert_bits(tcx, ParamEnv::empty().and(tcx.types.usize)).map(|v| v as u64) } #[inline] - pub fn unwrap_bits(&self, tcx: TyCtxt<'_, '_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> u128 { + pub fn unwrap_bits(&self, tcx: TyCtxt<'_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> u128 { self.assert_bits(tcx, ty).unwrap_or_else(|| bug!("expected bits of {}, got {:#?}", ty.value, self)) } #[inline] - pub fn unwrap_usize(&self, tcx: TyCtxt<'_, '_>) -> u64 { + pub fn unwrap_usize(&self, tcx: TyCtxt<'_>) -> u64 { self.assert_usize(tcx).unwrap_or_else(|| bug!("expected constant usize, got {:#?}", self)) } diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index a47217138aa1a..5a97d8bb72510 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -138,7 +138,7 @@ impl<'tcx> Kind<'tcx> { impl<'a, 'tcx> Lift<'tcx> for Kind<'a> { type Lifted = Kind<'tcx>; - fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option { + fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option { match self.unpack() { UnpackedKind::Lifetime(lt) => tcx.lift(<).map(|lt| lt.into()), UnpackedKind::Type(ty) => tcx.lift(&ty).map(|ty| ty.into()), @@ -148,7 +148,7 @@ impl<'a, 'tcx> Lift<'tcx> for Kind<'a> { } impl<'tcx> TypeFoldable<'tcx> for Kind<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { match self.unpack() { UnpackedKind::Lifetime(lt) => lt.fold_with(folder).into(), UnpackedKind::Type(ty) => ty.fold_with(folder).into(), @@ -182,9 +182,9 @@ pub type InternalSubsts<'tcx> = List>; pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>; -impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { +impl<'a, 'tcx> InternalSubsts<'tcx> { /// Creates a `InternalSubsts` that maps each generic parameter to itself. - pub fn identity_for_item(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId) -> SubstsRef<'tcx> { + pub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx> { Self::for_item(tcx, def_id, |param, _| { tcx.mk_param_from_def(param) }) @@ -194,7 +194,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { /// var bound at index `0`. For types, we use a `BoundVar` index equal to /// the type parameter index. For regions, we use the `BoundRegion::BrNamed` /// variant (which has a `DefId`). - pub fn bound_vars_for_item(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId) -> SubstsRef<'tcx> { + pub fn bound_vars_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx> { Self::for_item(tcx, def_id, |param, _| { match param.kind { ty::GenericParamDefKind::Type { .. } => { @@ -230,7 +230,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { /// The closures get to observe the `InternalSubsts` as they're /// being built, which can be used to correctly /// substitute defaults of generic parameters. - pub fn for_item(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> + pub fn for_item(tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx> where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>, { @@ -243,7 +243,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { pub fn extend_to( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F, ) -> SubstsRef<'tcx> @@ -259,7 +259,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { fn fill_item( substs: &mut SmallVec<[Kind<'tcx>; 8]>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, defs: &ty::Generics, mk_kind: &mut F, ) where @@ -373,7 +373,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { /// parameters (e.g., method parameters) on top of that base. pub fn rebase_onto( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, source_ancestor: DefId, target_substs: SubstsRef<'tcx>, ) -> SubstsRef<'tcx> { @@ -381,13 +381,13 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> { tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned()) } - pub fn truncate_to(&self, tcx: TyCtxt<'gcx, 'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> { + pub fn truncate_to(&self, tcx: TyCtxt<'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> { tcx.mk_substs(self.iter().take(generics.count()).cloned()) } } impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> { - fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + fn super_fold_with>(&self, folder: &mut F) -> Self { let params: SmallVec<[_; 8]> = self.iter().map(|k| k.fold_with(folder)).collect(); // If folding doesn't change the substs, it's faster to avoid @@ -414,22 +414,22 @@ impl<'tcx> serialize::UseSpecializedDecodable for SubstsRef<'tcx> {} // there is more information available (for better errors). pub trait Subst<'tcx>: Sized { - fn subst<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: &[Kind<'tcx>]) -> Self { + fn subst(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>]) -> Self { self.subst_spanned(tcx, substs, None) } - fn subst_spanned<'gcx>( + fn subst_spanned( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option, ) -> Self; } impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { - fn subst_spanned<'gcx>( + fn subst_spanned( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option, ) -> T { @@ -446,8 +446,8 @@ impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { /////////////////////////////////////////////////////////////////////////// // The actual substitution engine itself is a type folder. -struct SubstFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +struct SubstFolder<'a, 'tcx> { + tcx: TyCtxt<'tcx>, substs: &'a [Kind<'tcx>], /// The location for which the substitution is performed, if available. @@ -463,8 +463,8 @@ struct SubstFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { binders_passed: u32, } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx } +impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } fn fold_binder>(&mut self, t: &ty::Binder) -> ty::Binder { self.binders_passed += 1; @@ -547,7 +547,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> SubstFolder<'a, 'tcx> { fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> { // Look up the type in the substitutions. It really should be in there. let opt_ty = self.substs.get(p.index as usize).map(|k| k.unpack()); diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index 1f99d97605c79..c40d4d5b9cc35 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -46,7 +46,7 @@ pub struct TraitImpls { non_blanket_impls: FxHashMap>, } -impl<'gcx, 'tcx> TraitDef { +impl<'tcx> TraitDef { pub fn new(def_id: DefId, unsafety: hir::Unsafety, paren_sugar: bool, @@ -66,14 +66,14 @@ impl<'gcx, 'tcx> TraitDef { pub fn ancestors( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, of_impl: DefId, - ) -> specialization_graph::Ancestors<'gcx> { + ) -> specialization_graph::Ancestors<'tcx> { specialization_graph::ancestors(tcx, self.def_id, of_impl) } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn for_each_impl(self, def_id: DefId, mut f: F) { let impls = self.trait_impls_of(def_id); @@ -151,7 +151,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { // Query provider for `trait_impls_of`. pub(super) fn trait_impls_of_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_id: DefId, ) -> &'tcx TraitImpls { let mut impls = TraitImpls::default(); diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 57319db63404a..8b1d9d97276e6 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -51,10 +51,10 @@ impl<'tcx> fmt::Display for Discr<'tcx> { impl<'tcx> Discr<'tcx> { /// Adds `1` to the value and wraps around if the maximum for the type is reached. - pub fn wrap_incr<'gcx>(self, tcx: TyCtxt<'gcx, 'tcx>) -> Self { + pub fn wrap_incr(self, tcx: TyCtxt<'tcx>) -> Self { self.checked_add(tcx, 1).0 } - pub fn checked_add<'gcx>(self, tcx: TyCtxt<'gcx, 'tcx>, n: u128) -> (Self, bool) { + pub fn checked_add(self, tcx: TyCtxt<'tcx>, n: u128) -> (Self, bool) { let (int, signed) = match self.ty.sty { Int(ity) => (Integer::from_attr(&tcx, SignedInt(ity)), true), Uint(uty) => (Integer::from_attr(&tcx, UnsignedInt(uty)), false), @@ -104,17 +104,17 @@ impl<'tcx> Discr<'tcx> { } pub trait IntTypeExt { - fn to_ty<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>; + fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>; fn disr_incr<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, val: Option>, ) -> Option>; - fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Discr<'tcx>; + fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Discr<'tcx>; } impl IntTypeExt for attr::IntType { - fn to_ty<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> { + fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match *self { SignedInt(ast::IntTy::I8) => tcx.types.i8, SignedInt(ast::IntTy::I16) => tcx.types.i16, @@ -131,7 +131,7 @@ impl IntTypeExt for attr::IntType { } } - fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Discr<'tcx> { + fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Discr<'tcx> { Discr { val: 0, ty: self.to_ty(tcx) @@ -140,7 +140,7 @@ impl IntTypeExt for attr::IntType { fn disr_incr<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, val: Option>, ) -> Option> { if let Some(val) = val { @@ -183,7 +183,7 @@ pub enum Representability { impl<'tcx> ty::ParamEnv<'tcx> { pub fn can_type_implement_copy( self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, self_type: Ty<'tcx>, ) -> Result<(), CopyImplementationError<'tcx>> { // FIXME: (@jroesch) float this code up @@ -232,7 +232,7 @@ impl<'tcx> ty::ParamEnv<'tcx> { } } -impl<'tcx> TyCtxt<'tcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { /// Creates a hash of the type `Ty` which will be the same no matter what crate /// context it's calculated within. This is used by the `type_id` intrinsic. pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64 { @@ -253,7 +253,7 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> { } } -impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { +impl<'tcx> TyCtxt<'tcx> { pub fn has_error_field(self, ty: Ty<'tcx>) -> bool { if let ty::Adt(def, substs) = ty.sty { for field in def.all_fields() { @@ -628,7 +628,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { ) -> Result, Ty<'tcx>> { use crate::ty::fold::TypeFolder; - struct OpaqueTypeExpander<'gcx, 'tcx> { + struct OpaqueTypeExpander<'tcx> { // Contains the DefIds of the opaque types that are currently being // expanded. When we expand an opaque type we insert the DefId of // that type, and when we finish expanding that type we remove the @@ -636,10 +636,10 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { seen_opaque_tys: FxHashSet, primary_def_id: DefId, found_recursion: bool, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, } - impl<'gcx, 'tcx> OpaqueTypeExpander<'gcx, 'tcx> { + impl<'tcx> OpaqueTypeExpander<'tcx> { fn expand_opaque_ty( &mut self, def_id: DefId, @@ -662,8 +662,8 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { } } - impl<'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpaqueTypeExpander<'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -701,7 +701,7 @@ impl<'tcx> ty::TyS<'tcx> { /// winds up being reported as an error during NLL borrow check. pub fn is_copy_modulo_regions( &'tcx self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, span: Span, ) -> bool { @@ -716,7 +716,7 @@ impl<'tcx> ty::TyS<'tcx> { /// actually carry lifetime requirements. pub fn is_sized( &'tcx self, - tcx_at: TyCtxtAt<'tcx, 'tcx>, + tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> bool { tcx_at.is_sized_raw(param_env.and(self)) @@ -731,7 +731,7 @@ impl<'tcx> ty::TyS<'tcx> { /// effectively an implementation detail. pub fn is_freeze( &'tcx self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, span: Span, ) -> bool { @@ -745,7 +745,7 @@ impl<'tcx> ty::TyS<'tcx> { /// (Note that this implies that if `ty` has a destructor attached, /// then `needs_drop` will definitely return `true` for `ty`.) #[inline] - pub fn needs_drop(&'tcx self, tcx: TyCtxt<'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool { + pub fn needs_drop(&'tcx self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool { tcx.needs_drop_raw(param_env.and(self)).0 } @@ -764,7 +764,7 @@ impl<'tcx> ty::TyS<'tcx> { /// Check whether a type is representable. This means it cannot contain unboxed /// structural recursion. This check is needed for structs and enums. - pub fn is_representable(&'tcx self, tcx: TyCtxt<'tcx, 'tcx>, sp: Span) -> Representability { + pub fn is_representable(&'tcx self, tcx: TyCtxt<'tcx>, sp: Span) -> Representability { // Iterate until something non-representable is found fn fold_repr>(iter: It) -> Representability { iter.fold(Representability::Representable, |r1, r2| { @@ -779,7 +779,7 @@ impl<'tcx> ty::TyS<'tcx> { } fn are_inner_types_recursive<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, sp: Span, seen: &mut Vec>, representable_cache: &mut FxHashMap, Representability>, @@ -839,7 +839,7 @@ impl<'tcx> ty::TyS<'tcx> { // Does the type `ty` directly (without indirection through a pointer) // contain any types on stack `seen`? fn is_type_structurally_recursive<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, sp: Span, seen: &mut Vec>, representable_cache: &mut FxHashMap, Representability>, @@ -860,7 +860,7 @@ impl<'tcx> ty::TyS<'tcx> { } fn is_type_structurally_recursive_inner<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, sp: Span, seen: &mut Vec>, representable_cache: &mut FxHashMap, Representability>, @@ -937,7 +937,7 @@ impl<'tcx> ty::TyS<'tcx> { } } -fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { +fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { let (param_env, ty) = query.into_parts(); let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem); tcx.infer_ctxt() @@ -950,7 +950,7 @@ fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'t )) } -fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { +fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { let (param_env, ty) = query.into_parts(); let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem); tcx.infer_ctxt() @@ -963,7 +963,7 @@ fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<' )) } -fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { +fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { let (param_env, ty) = query.into_parts(); let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem); tcx.infer_ctxt() @@ -980,7 +980,7 @@ fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty< pub struct NeedsDrop(pub bool); fn needs_drop_raw<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> NeedsDrop { let (param_env, ty) = query.into_parts(); diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 1ed88f395a943..65feb4c08d994 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -15,7 +15,7 @@ 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, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, +pub fn obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, ty: Ty<'tcx>, @@ -41,7 +41,7 @@ pub fn obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, /// well-formed. For example, if there is a trait `Set` defined like /// `trait Set`, then the trait reference `Foo: Set` is WF /// if `Bar: Eq`. -pub fn trait_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, '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>, @@ -53,7 +53,7 @@ pub fn trait_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, wf.normalize() } -pub fn predicate_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, +pub fn predicate_obligations<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, predicate: &ty::Predicate<'tcx>, @@ -101,8 +101,8 @@ pub fn predicate_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, wf.normalize() } -struct WfPredicates<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +struct WfPredicates<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, span: Span, @@ -138,7 +138,7 @@ enum Elaborate { None, } -impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> WfPredicates<'a, 'tcx> { fn cause(&mut self, code: traits::ObligationCauseCode<'tcx>) -> traits::ObligationCause<'tcx> { traits::ObligationCause::new(self.span, self.body_id, code) } @@ -508,8 +508,8 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { /// they declare `trait SomeTrait : 'static`, for example, then /// `'static` would appear in the list. The hard work is done by /// `ty::required_region_bounds`, see that for more information. -pub fn object_region_bounds<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn object_region_bounds<'tcx>( + tcx: TyCtxt<'tcx>, existential_predicates: ty::Binder<&'tcx ty::List>>, ) -> Vec> { // Since we don't actually *know* the self type for an object, diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 45a92daab0dfb..4a36d441d3d9f 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -231,7 +231,7 @@ fn compatible_borrow_kinds(borrow_kind1: ty::BorrowKind, } impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { - pub fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.bccx.tcx } + pub fn tcx(&self) -> TyCtxt<'tcx> { self.bccx.tcx } pub fn each_issued_loan(&self, node: hir::ItemLocalId, mut op: F) -> bool where F: FnMut(&Loan<'tcx>) -> bool, diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 7a8a62edea1a3..4d03b58179db0 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -45,7 +45,7 @@ pub enum PatternSource<'tcx> { /// /// In this latter case, this function will return `PatternSource::LetDecl` /// with a reference to the let -fn get_pattern_source<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> { +fn get_pattern_source<'tcx>(tcx: TyCtxt<'tcx>, pat: &Pat) -> PatternSource<'tcx> { let parent = tcx.hir().get_parent_node_by_hir_id(pat.hir_id); diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 8bdfa1352cbe0..b1854a06693cc 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -251,7 +251,7 @@ fn check_mutability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, } impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { - pub fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.bccx.tcx } + pub fn tcx(&self) -> TyCtxt<'tcx> { self.bccx.tcx } /// Guarantees that `cmt` is assignable, or reports an error. fn guarantee_assignment_valid(&mut self, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index e8644d2416db7..9b0dce50dd0cb 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -53,7 +53,7 @@ pub struct LoanDataFlowOperator; pub type LoanDataFlow<'tcx> = DataFlowContext<'tcx, LoanDataFlowOperator>; -pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) { tcx.par_body_owners(|body_owner_def_id| { tcx.ensure().borrowck(body_owner_def_id); }); @@ -73,7 +73,7 @@ pub struct AnalysisData<'tcx> { pub move_data: move_data::FlowedMoveData<'tcx>, } -fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId) -> &'tcx BorrowCheckResult { +fn borrowck<'tcx>(tcx: TyCtxt<'tcx>, owner_def_id: DefId) -> &'tcx BorrowCheckResult { assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck()); debug!("borrowck(body_owner_def_id={:?})", owner_def_id); @@ -193,7 +193,7 @@ where /// Accessor for introspective clients inspecting `AnalysisData` and /// the `BorrowckCtxt` itself , e.g., the flowgraph visualizer. pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body_id: hir::BodyId, cfg: &cfg::CFG, ) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>) { @@ -220,7 +220,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( // Type definitions pub struct BorrowckCtxt<'a, 'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, // tables for the current thing we are checking; set to // Some in `borrowck_fn` and cleared later @@ -388,7 +388,7 @@ pub enum LoanPathElem<'tcx> { LpInterior(Option, InteriorKind), } -fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_, '_>) -> HirId { +fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId { let closure_id = tcx.hir().local_def_id_to_node_id(closure_id); match tcx.hir().get(closure_id) { Node::Expr(expr) => match expr.node { diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 38bf590a36fb8..9feea64f18235 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -223,7 +223,7 @@ impl MoveData<'tcx> { /// Returns the existing move path index for `lp`, if any, and otherwise adds a new index for /// `lp` and any of its base paths that do not yet have an index. - pub fn move_path(&self, tcx: TyCtxt<'tcx, 'tcx>, lp: Rc>) -> MovePathIndex { + pub fn move_path(&self, tcx: TyCtxt<'tcx>, lp: Rc>) -> MovePathIndex { if let Some(&index) = self.path_map.borrow().get(&lp) { return index; } @@ -312,7 +312,7 @@ impl MoveData<'tcx> { /// Adds a new move entry for a move of `lp` that occurs at location `id` with kind `kind`. pub fn add_move( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, orig_lp: Rc>, id: hir::ItemLocalId, kind: MoveKind, @@ -344,7 +344,7 @@ impl MoveData<'tcx> { fn add_move_helper( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, lp: Rc>, id: hir::ItemLocalId, kind: MoveKind, @@ -372,7 +372,7 @@ impl MoveData<'tcx> { /// `span`. pub fn add_assignment( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, lp: Rc>, assign_id: hir::ItemLocalId, span: Span, @@ -405,7 +405,7 @@ impl MoveData<'tcx> { fn add_assignment_helper( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, lp: Rc>, assign_id: hir::ItemLocalId, span: Span, diff --git a/src/librustc_borrowck/dataflow.rs b/src/librustc_borrowck/dataflow.rs index a42fbb72c03a8..f5d311b35d738 100644 --- a/src/librustc_borrowck/dataflow.rs +++ b/src/librustc_borrowck/dataflow.rs @@ -27,7 +27,7 @@ pub enum EntryOrExit { #[derive(Clone)] pub struct DataFlowContext<'tcx, O> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, /// a name for the analysis using this dataflow instance analysis_name: &'static str, @@ -225,7 +225,7 @@ pub enum KillFrom { impl<'tcx, O: DataFlowOperator> DataFlowContext<'tcx, O> { pub fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, analysis_name: &'static str, body: Option<&hir::Body>, cfg: &cfg::CFG, diff --git a/src/librustc_codegen_llvm/allocator.rs b/src/librustc_codegen_llvm/allocator.rs index 27ec939dd2933..02a05fd110200 100644 --- a/src/librustc_codegen_llvm/allocator.rs +++ b/src/librustc_codegen_llvm/allocator.rs @@ -9,7 +9,7 @@ use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; use crate::ModuleLlvm; use crate::llvm::{self, False, True}; -pub(crate) unsafe fn codegen(tcx: TyCtxt<'_, '_>, mods: &mut ModuleLlvm, kind: AllocatorKind) { +pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut ModuleLlvm, kind: AllocatorKind) { let llcx = &*mods.llcx; let llmod = mods.llmod(); let usize = match &tcx.sess.target.target.target_pointer_width[..] { diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index f68f3de118574..4735588f29a02 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -367,7 +367,7 @@ pub fn provide_extern(providers: &mut Providers<'_>) { }; } -fn wasm_import_module(tcx: TyCtxt<'_, '_>, id: DefId) -> Option { +fn wasm_import_module(tcx: TyCtxt<'_>, id: DefId) -> Option { tcx.wasm_import_module_map(id.krate) .get(&id) .map(|s| CString::new(&s[..]).unwrap()) diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 6f3f9d4cb8b55..3638730707f3f 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -89,7 +89,7 @@ pub fn create_informational_target_machine( } pub fn create_target_machine( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, find_features: bool, ) -> &'static mut llvm::TargetMachine { target_machine_factory(&tcx.sess, tcx.backend_optimization_level(LOCAL_CRATE), find_features)() diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 9d2cd8618872a..04645dacfec58 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -41,8 +41,8 @@ use rustc::hir::CodegenFnAttrs; use crate::value::Value; -pub fn write_compressed_metadata<'gcx>( - tcx: TyCtxt<'gcx, 'gcx>, +pub fn write_compressed_metadata<'tcx>( + tcx: TyCtxt<'tcx>, metadata: &EncodedMetadata, llvm_module: &mut ModuleLlvm, ) { @@ -103,7 +103,7 @@ pub fn iter_globals(llmod: &'ll llvm::Module) -> ValueIter<'ll> { } } -pub fn compile_codegen_unit(tcx: TyCtxt<'tcx, 'tcx>, cgu_name: InternedString) { +pub fn compile_codegen_unit(tcx: TyCtxt<'tcx>, cgu_name: InternedString) { let start_time = Instant::now(); let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); @@ -124,7 +124,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'tcx, 'tcx>, cgu_name: InternedString) { submit_codegened_module_to_llvm(&LlvmCodegenBackend(()), tcx, module, cost); fn module_codegen<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cgu_name: InternedString, ) -> ModuleCodegen { let cgu = tcx.codegen_unit(cgu_name); diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 2febba6766d53..9102ba91df816 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -66,7 +66,7 @@ impl ty::layout::HasDataLayout for Builder<'_, '_, '_> { } impl ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.cx.tcx } } diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 0a780fecf41de..967fe877fd1ad 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -35,7 +35,7 @@ use crate::abi::Abi; /// `llvm::Context` so that several compilation units may be optimized in parallel. /// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`. pub struct CodegenCx<'ll, 'tcx: 'll> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub check_overflow: bool, pub use_dll_storage_attrs: bool, pub tls_model: llvm::ThreadLocalMode, @@ -141,7 +141,7 @@ pub fn is_pie_binary(sess: &Session) -> bool { } pub unsafe fn create_module( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, llcx: &'ll llvm::Context, mod_name: &str, ) -> &'ll llvm::Module { @@ -208,7 +208,7 @@ pub unsafe fn create_module( impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { crate fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, codegen_unit: Arc>, llvm_module: &'ll crate::ModuleLlvm, ) -> Self { @@ -839,7 +839,7 @@ impl HasTargetSpec for CodegenCx<'ll, 'tcx> { } impl ty::layout::HasTyCtxt<'tcx> for CodegenCx<'ll, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 3c37240b1660c..d43adc9cb92c5 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -894,7 +894,7 @@ fn pointer_type_metadata( } pub fn compile_unit_metadata( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, codegen_unit_name: &str, debug_context: &CrateDebugContext<'ll, '_>, ) -> &'ll DIDescriptor { diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 9a0860bc4b09f..e03de7799d3a5 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -105,21 +105,21 @@ mod va_arg; pub struct LlvmCodegenBackend(()); impl ExtraBackendMethods for LlvmCodegenBackend { - fn new_metadata(&self, tcx: TyCtxt<'_, '_>, mod_name: &str) -> ModuleLlvm { + fn new_metadata(&self, tcx: TyCtxt<'_>, mod_name: &str) -> ModuleLlvm { ModuleLlvm::new_metadata(tcx, mod_name) } - fn write_compressed_metadata<'gcx>( + fn write_compressed_metadata<'tcx>( &self, - tcx: TyCtxt<'gcx, 'gcx>, + tcx: TyCtxt<'tcx>, metadata: &EncodedMetadata, llvm_module: &mut ModuleLlvm, ) { base::write_compressed_metadata(tcx, metadata, llvm_module) } - fn codegen_allocator<'gcx>( + fn codegen_allocator<'tcx>( &self, - tcx: TyCtxt<'gcx, 'gcx>, + tcx: TyCtxt<'tcx>, mods: &mut ModuleLlvm, kind: AllocatorKind, ) { @@ -127,7 +127,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend { } fn compile_codegen_unit<'a, 'tcx: 'a>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cgu_name: InternedString, ) { base::compile_codegen_unit(tcx, cgu_name); @@ -288,7 +288,7 @@ impl CodegenBackend for LlvmCodegenBackend { fn codegen_crate<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, rx: mpsc::Receiver>, @@ -367,7 +367,7 @@ unsafe impl Send for ModuleLlvm { } unsafe impl Sync for ModuleLlvm { } impl ModuleLlvm { - fn new(tcx: TyCtxt<'_, '_>, mod_name: &str) -> Self { + fn new(tcx: TyCtxt<'_>, mod_name: &str) -> Self { unsafe { let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names()); let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _; @@ -379,7 +379,7 @@ impl ModuleLlvm { } } - fn new_metadata(tcx: TyCtxt<'_, '_>, mod_name: &str) -> Self { + fn new_metadata(tcx: TyCtxt<'_>, mod_name: &str) -> Self { unsafe { let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names()); let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _; diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 260c07a7b6287..c605c2e47c943 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -25,7 +25,7 @@ pub struct LinkerInfo { } impl LinkerInfo { - pub fn new(tcx: TyCtxt<'_, '_>) -> LinkerInfo { + pub fn new(tcx: TyCtxt<'_>) -> LinkerInfo { LinkerInfo { exports: tcx.sess.crate_types.borrow().iter().map(|&c| { (c, exported_symbols(tcx, c)) @@ -1012,7 +1012,7 @@ impl<'a> Linker for WasmLd<'a> { } } -fn exported_symbols(tcx: TyCtxt<'_, '_>, crate_type: CrateType) -> Vec { +fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec { if let Some(ref exports) = tcx.sess.target.target.options.override_export_symbols { return exports.clone() } diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index e1693b7c2ef1b..aeff73c7e5216 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -21,7 +21,7 @@ pub type ExportedSymbols = FxHashMap< Arc>, >; -pub fn threshold(tcx: TyCtxt<'_, '_>) -> SymbolExportLevel { +pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel { crates_export_threshold(&tcx.sess.crate_types.borrow()) } @@ -47,7 +47,7 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExpor } fn reachable_non_generics_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cnum: CrateNum, ) -> &'tcx DefIdMap { assert_eq!(cnum, LOCAL_CRATE); @@ -157,7 +157,7 @@ fn reachable_non_generics_provider<'tcx>( tcx.arena.alloc(reachable_non_generics) } -fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { let export_threshold = threshold(tcx); if let Some(&level) = tcx.reachable_non_generics(def_id.krate).get(&def_id) { @@ -167,12 +167,12 @@ fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id } } -fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { tcx.reachable_non_generics(def_id.krate).contains_key(&def_id) } fn exported_symbols_provider_local<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cnum: CrateNum, ) -> Arc, SymbolExportLevel)>> { assert_eq!(cnum, LOCAL_CRATE); @@ -274,7 +274,7 @@ fn exported_symbols_provider_local<'tcx>( } fn upstream_monomorphizations_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cnum: CrateNum, ) -> &'tcx DefIdMap, CrateNum>> { debug_assert!(cnum == LOCAL_CRATE); @@ -323,14 +323,14 @@ fn upstream_monomorphizations_provider<'tcx>( } fn upstream_monomorphizations_for_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> Option<&'tcx FxHashMap, CrateNum>> { debug_assert!(!def_id.is_local()); tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id) } -fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_, '_>, def_id: DefId) -> bool { +fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> bool { if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { !tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id) } else { @@ -352,7 +352,7 @@ pub fn provide_extern(providers: &mut Providers<'_>) { providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider; } -fn symbol_export_level(tcx: TyCtxt<'_, '_>, sym_def_id: DefId) -> SymbolExportLevel { +fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel { // We export anything that's not mangled at the "C" layer as it probably has // to do with ABI concerns. We do not, however, apply such treatment to // special symbols in the standard library for various plumbing between diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 5a7ca4af4b867..309187ca2eaa3 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -375,7 +375,7 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool { pub fn start_async_codegen( backend: B, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, metadata: EncodedMetadata, coordinator_receive: Receiver>, total_cgus: usize, @@ -996,7 +996,7 @@ enum MainThreadWorkerState { fn start_executing_work( backend: B, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, crate_info: &CrateInfo, shared_emitter: SharedEmitter, codegen_worker_send: Sender>, @@ -1863,7 +1863,7 @@ impl OngoingCodegen { pub fn submit_pre_codegened_module_to_llvm( &self, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, module: ModuleCodegen, ) { self.wait_for_signal_to_codegen_item(); @@ -1874,7 +1874,7 @@ impl OngoingCodegen { submit_codegened_module_to_llvm(&self.backend, tcx, module, cost); } - pub fn codegen_finished(&self, tcx: TyCtxt<'_, '_>) { + pub fn codegen_finished(&self, tcx: TyCtxt<'_>) { self.wait_for_signal_to_codegen_item(); self.check_for_errors(tcx.sess); drop(self.coordinator_send.send(Box::new(Message::CodegenComplete::))); @@ -1913,7 +1913,7 @@ impl OngoingCodegen { pub fn submit_codegened_module_to_llvm( _backend: &B, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, module: ModuleCodegen, cost: u64, ) { @@ -1926,7 +1926,7 @@ pub fn submit_codegened_module_to_llvm( pub fn submit_post_lto_module_to_llvm( _backend: &B, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, module: CachedModuleCodegen, ) { let llvm_work_item = WorkItem::CopyPostLtoArtifacts(module); @@ -1938,7 +1938,7 @@ pub fn submit_post_lto_module_to_llvm( pub fn submit_pre_lto_module_to_llvm( _backend: &B, - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, module: CachedModuleCodegen, ) { let filename = pre_lto_bitcode_filename(&module.name); @@ -1963,7 +1963,7 @@ pub fn pre_lto_bitcode_filename(module_name: &str) -> String { format!("{}.{}", module_name, PRE_LTO_BC_EXT) } -fn msvc_imps_needed(tcx: TyCtxt<'_, '_>) -> bool { +fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool { // This should never be true (because it's not supported). If it is true, // something is wrong with commandline arg validation. assert!(!(tcx.sess.opts.cg.linker_plugin_lto.enabled() && diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 9c34b5e4f7927..ca686453b6d4e 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -480,7 +480,7 @@ pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX; pub fn codegen_crate( backend: B, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, rx: mpsc::Receiver>, @@ -702,7 +702,7 @@ impl Drop for AbortCodegenOnDrop { } } -fn assert_and_save_dep_graph<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +fn assert_and_save_dep_graph<'tcx>(tcx: TyCtxt<'tcx>) { time(tcx.sess, "assert dep graph", || ::rustc_incremental::assert_dep_graph(tcx)); @@ -713,7 +713,7 @@ fn assert_and_save_dep_graph<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } impl CrateInfo { - pub fn new(tcx: TyCtxt<'_, '_>) -> CrateInfo { + pub fn new(tcx: TyCtxt<'_>) -> CrateInfo { let mut info = CrateInfo { panic_runtime: None, compiler_builtins: None, @@ -779,7 +779,7 @@ impl CrateInfo { } } -fn is_codegened_item(tcx: TyCtxt<'_, '_>, id: DefId) -> bool { +fn is_codegened_item(tcx: TyCtxt<'_>, id: DefId) -> bool { let (all_mono_items, _) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); all_mono_items.contains(&id) @@ -849,7 +849,7 @@ pub fn provide_both(providers: &mut Providers<'_>) { }; } -fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse { +fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse { if !tcx.dep_graph.is_fully_enabled() { return CguReuse::No } diff --git a/src/librustc_codegen_ssa/common.rs b/src/librustc_codegen_ssa/common.rs index 66baf06bfb46d..e22d4db6dcb9a 100644 --- a/src/librustc_codegen_ssa/common.rs +++ b/src/librustc_codegen_ssa/common.rs @@ -122,7 +122,7 @@ mod temp_stable_hash_impls { } } -pub fn langcall(tcx: TyCtxt<'_, '_>, span: Option, msg: &str, li: LangItem) -> DefId { +pub fn langcall(tcx: TyCtxt<'_>, span: Option, msg: &str, li: LangItem) -> DefId { tcx.lang_items().require(li).unwrap_or_else(|s| { let msg = format!("{} {}", msg, s); match span { diff --git a/src/librustc_codegen_ssa/debuginfo/type_names.rs b/src/librustc_codegen_ssa/debuginfo/type_names.rs index 943fd254030d2..9dd6bf77a0407 100644 --- a/src/librustc_codegen_ssa/debuginfo/type_names.rs +++ b/src/librustc_codegen_ssa/debuginfo/type_names.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::FxHashSet; // the work twice. The `qualified` parameter only affects the first level of the // type name, further levels (i.e., type parameters) are always fully qualified. pub fn compute_debuginfo_type_name<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, t: Ty<'tcx>, qualified: bool, ) -> String { @@ -22,7 +22,7 @@ pub fn compute_debuginfo_type_name<'tcx>( // Pushes the name of the type as it should be stored in debuginfo on the // `output` String. See also compute_debuginfo_type_name(). pub fn push_debuginfo_type_name<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, t: Ty<'tcx>, qualified: bool, output: &mut String, @@ -211,7 +211,7 @@ pub fn push_debuginfo_type_name<'tcx>( } fn push_item_name( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, qualified: bool, output: &mut String, @@ -233,7 +233,7 @@ pub fn push_debuginfo_type_name<'tcx>( // would be possible but with inlining and LTO we have to use the least // common denominator - otherwise we would run into conflicts. fn push_type_params<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, output: &mut String, visited: &mut FxHashSet>, diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 160e554f8565c..2f95c9a7d8bb4 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -31,20 +31,20 @@ impl<'tcx, T> Backend<'tcx> for T where } pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send { - fn new_metadata(&self, sess: TyCtxt<'_, '_>, mod_name: &str) -> Self::Module; - fn write_compressed_metadata<'gcx>( + fn new_metadata(&self, sess: TyCtxt<'_>, mod_name: &str) -> Self::Module; + fn write_compressed_metadata<'tcx>( &self, - tcx: TyCtxt<'gcx, 'gcx>, + tcx: TyCtxt<'tcx>, metadata: &EncodedMetadata, llvm_module: &mut Self::Module, ); - fn codegen_allocator<'gcx>( + fn codegen_allocator<'tcx>( &self, - tcx: TyCtxt<'gcx, 'gcx>, + tcx: TyCtxt<'tcx>, mods: &mut Self::Module, kind: AllocatorKind, ); - fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx, 'tcx>, cgu_name: InternedString); + fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString); // If find_features is true this won't access `sess.crate_types` by assuming // that `is_pie_binary` is false. When we discover LLVM target features // `sess.crate_types` is uninitialized so we cannot access it. diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 1bf03c0c45c6d..7a7a50a25faf0 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -35,7 +35,7 @@ pub trait CodegenBackend { fn provide_extern(&self, _providers: &mut Providers<'_>); fn codegen_crate<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, rx: mpsc::Receiver>, diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index cc6e368f11b3b..942c2d13fac87 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -36,7 +36,7 @@ pub mod symbol_names_test; /// error in codegen. This is used to write compile-fail tests /// that actually test that compilation succeeds without /// reporting an error. -pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_, '_>) { +pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) { if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) { if tcx.has_attr(def_id, sym::rustc_error) { tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful"); diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 89b35b4cc6114..ba74f79eba302 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -112,7 +112,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn symbol_name(tcx: TyCtxt<'tcx, 'tcx>, instance: Instance<'tcx>) -> InternedString { +fn symbol_name(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> InternedString { let def_id = instance.def_id(); let substs = instance.substs; diff --git a/src/librustc_codegen_utils/symbol_names/legacy.rs b/src/librustc_codegen_utils/symbol_names/legacy.rs index 9645af5309e78..72eb4969aa8a6 100644 --- a/src/librustc_codegen_utils/symbol_names/legacy.rs +++ b/src/librustc_codegen_utils/symbol_names/legacy.rs @@ -14,7 +14,7 @@ use std::fmt::{self, Write}; use std::mem::{self, discriminant}; pub(super) fn mangle( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, instantiating_crate: Option, ) -> String { @@ -69,7 +69,7 @@ pub(super) fn mangle( } fn get_symbol_hash<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, // instance this name will be for instance: Instance<'tcx>, @@ -180,7 +180,7 @@ impl SymbolPath { } struct SymbolPrinter<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, path: SymbolPath, // When `true`, `finalize_pending_component` isn't used. @@ -194,7 +194,7 @@ struct SymbolPrinter<'tcx> { // `PrettyPrinter` aka pretty printing of e.g. types in paths, // symbol names should have their own printing machinery. -impl Printer<'tcx, 'tcx> for SymbolPrinter<'tcx> { +impl Printer<'tcx> for SymbolPrinter<'tcx> { type Error = fmt::Error; type Path = Self; @@ -203,7 +203,7 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'tcx> { type DynExistential = Self; type Const = Self; - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -360,7 +360,7 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'tcx> { } } -impl PrettyPrinter<'tcx, 'tcx> for SymbolPrinter<'tcx> { +impl PrettyPrinter<'tcx> for SymbolPrinter<'tcx> { fn region_should_not_be_omitted( &self, _region: ty::Region<'_>, @@ -371,7 +371,7 @@ impl PrettyPrinter<'tcx, 'tcx> for SymbolPrinter<'tcx> { mut self, mut elems: impl Iterator, ) -> Result - where T: Print<'tcx, 'tcx, Self, Output = Self, Error = 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_codegen_utils/symbol_names/v0.rs b/src/librustc_codegen_utils/symbol_names/v0.rs index 7e78b9ea88769..8a54fb6bbc4ca 100644 --- a/src/librustc_codegen_utils/symbol_names/v0.rs +++ b/src/librustc_codegen_utils/symbol_names/v0.rs @@ -13,7 +13,7 @@ use std::fmt::Write; use std::ops::Range; pub(super) fn mangle( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, instantiating_crate: Option, ) -> String { @@ -76,7 +76,7 @@ struct BinderLevel { } struct SymbolMangler<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, compress: Option>>, binders: Vec, out: String, @@ -214,7 +214,7 @@ impl SymbolMangler<'tcx> { } } -impl Printer<'tcx, 'tcx> for SymbolMangler<'tcx> { +impl Printer<'tcx> for SymbolMangler<'tcx> { type Error = !; type Path = Self; @@ -223,7 +223,7 @@ impl Printer<'tcx, 'tcx> for SymbolMangler<'tcx> { type DynExistential = Self; type Const = Self; - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustc_codegen_utils/symbol_names_test.rs b/src/librustc_codegen_utils/symbol_names_test.rs index 93b8a969d0b60..f48d1f2853c52 100644 --- a/src/librustc_codegen_utils/symbol_names_test.rs +++ b/src/librustc_codegen_utils/symbol_names_test.rs @@ -11,7 +11,7 @@ use syntax::symbol::{Symbol, sym}; const SYMBOL_NAME: Symbol = sym::rustc_symbol_name; const DEF_PATH: Symbol = sym::rustc_def_path; -pub fn report_symbol_names<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn report_symbol_names<'tcx>(tcx: TyCtxt<'tcx>) { // if the `rustc_attrs` feature is not enabled, then the // attributes we are interested in cannot be present anyway, so // skip the walk. @@ -26,7 +26,7 @@ pub fn report_symbol_names<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } struct SymbolNamesTest<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl SymbolNamesTest<'tcx> { diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 4f19a7bbc8b92..e70c510b779c1 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -157,7 +157,7 @@ impl PpSourceMode { fn call_with_pp_support<'tcx, A, F>( &self, sess: &'tcx Session, - tcx: Option>, + tcx: Option>, f: F, ) -> A where @@ -188,7 +188,7 @@ impl PpSourceMode { _ => panic!("Should use call_with_pp_support_hir"), } } - fn call_with_pp_support_hir<'tcx, A, F>(&self, tcx: TyCtxt<'tcx, 'tcx>, f: F) -> A + fn call_with_pp_support_hir<'tcx, A, F>(&self, tcx: TyCtxt<'tcx>, f: F) -> A where F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate) -> A, { @@ -269,7 +269,7 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn { struct NoAnn<'hir> { sess: &'hir Session, - tcx: Option>, + tcx: Option>, } impl<'hir> PrinterSupport for NoAnn<'hir> { @@ -310,7 +310,7 @@ impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> { struct IdentifiedAnnotation<'hir> { sess: &'hir Session, - tcx: Option>, + tcx: Option>, } impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> { @@ -454,7 +454,7 @@ impl<'a> pprust::PpAnn for HygieneAnnotation<'a> { } struct TypedAnnotation<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: Cell<&'a ty::TypeckTables<'tcx>>, } @@ -617,7 +617,7 @@ impl UserIdentifiedItem { fn print_flowgraph<'tcx, W: Write>( variants: Vec, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, code: blocks::Code<'tcx>, mode: PpFlowGraphMode, mut out: W, @@ -754,7 +754,7 @@ pub fn print_after_parsing(sess: &Session, } pub fn print_after_hir_lowering<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, input: &Input, krate: &ast::Crate, ppm: PpMode, @@ -866,7 +866,7 @@ pub fn print_after_hir_lowering<'tcx>( // with a different callback than the standard driver, so that isn't easy. // Instead, we call that function ourselves. fn print_with_analysis<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ppm: PpMode, uii: Option, ofile: Option<&Path>, diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 0ddcc42ef123c..6d667aa008f70 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -51,7 +51,7 @@ use std::io::Write; use syntax::ast; use syntax_pos::Span; -pub fn assert_dep_graph<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn assert_dep_graph<'tcx>(tcx: TyCtxt<'tcx>) { tcx.dep_graph.with_ignore(|| { if tcx.sess.opts.debugging_opts.dump_dep_graph { dump_graph(tcx); @@ -90,7 +90,7 @@ type Sources = Vec<(Span, DefId, DepNode)>; type Targets = Vec<(Span, ast::Name, hir::HirId, DepNode)>; struct IfThisChanged<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, if_this_changed: Sources, then_this_would_need: Targets, } @@ -185,7 +185,7 @@ impl Visitor<'tcx> for IfThisChanged<'tcx> { } fn check_paths<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_would_need: &Targets, ) { @@ -218,7 +218,7 @@ fn check_paths<'tcx>( } } -fn dump_graph(tcx: TyCtxt<'_, '_>) { +fn dump_graph(tcx: TyCtxt<'_>) { let path: String = env::var("RUST_DEP_GRAPH").unwrap_or_else(|_| "dep_graph".to_string()); let query = tcx.dep_graph.query(); diff --git a/src/librustc_incremental/assert_module_sources.rs b/src/librustc_incremental/assert_module_sources.rs index 12f81f337d356..f502d0475460e 100644 --- a/src/librustc_incremental/assert_module_sources.rs +++ b/src/librustc_incremental/assert_module_sources.rs @@ -35,7 +35,7 @@ const MODULE: Symbol = sym::module; const CFG: Symbol = sym::cfg; const KIND: Symbol = sym::kind; -pub fn assert_module_sources<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn assert_module_sources<'tcx>(tcx: TyCtxt<'tcx>) { tcx.dep_graph.with_ignore(|| { if tcx.sess.opts.incremental.is_none() { return; @@ -60,7 +60,7 @@ pub fn assert_module_sources<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } struct AssertModuleSource<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, available_cgus: BTreeSet, } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index e281636e9a1ce..e2e4a4ebcb056 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -206,7 +206,7 @@ impl Assertion { } } -pub fn check_dirty_clean_annotations<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check_dirty_clean_annotations<'tcx>(tcx: TyCtxt<'tcx>) { // can't add `#[rustc_dirty]` etc without opting in to this feature if !tcx.features().rustc_attrs { return; @@ -235,7 +235,7 @@ pub fn check_dirty_clean_annotations<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } pub struct DirtyCleanVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, checked_attrs: FxHashSet, } @@ -537,7 +537,7 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> { /// /// Also make sure that the `label` and `except` fields do not /// both exist. -fn check_config(tcx: TyCtxt<'_, '_>, attr: &Attribute) -> bool { +fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool { debug!("check_config(attr={:?})", attr); let config = &tcx.sess.parse_sess.config; debug!("check_config: config={:?}", config); @@ -572,7 +572,7 @@ fn check_config(tcx: TyCtxt<'_, '_>, attr: &Attribute) -> bool { } } -fn expect_associated_value(tcx: TyCtxt<'_, '_>, item: &NestedMetaItem) -> ast::Name { +fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> ast::Name { if let Some(value) = item.value_str() { value } else { @@ -590,7 +590,7 @@ fn expect_associated_value(tcx: TyCtxt<'_, '_>, item: &NestedMetaItem) -> ast::N // the HIR. It is used to verfiy that we really ran checks for all annotated // nodes. pub struct FindAllAttrs<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, attr_names: Vec, found_attrs: Vec<&'tcx Attribute>, } diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index adcd06d719cd9..d9bcc0b2a83c7 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -15,7 +15,7 @@ use super::fs::*; use super::file_format; use super::work_product; -pub fn dep_graph_tcx_init<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn dep_graph_tcx_init<'tcx>(tcx: TyCtxt<'tcx>) { if !tcx.dep_graph.is_fully_enabled() { return } diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index f31718fe50776..49c79ec09f5e2 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -15,7 +15,7 @@ use super::dirty_clean; use super::file_format; use super::work_product; -pub fn save_dep_graph<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn save_dep_graph<'tcx>(tcx: TyCtxt<'tcx>) { debug!("save_dep_graph()"); tcx.dep_graph.with_ignore(|| { let sess = tcx.sess; @@ -129,7 +129,7 @@ fn save_in(sess: &Session, path_buf: PathBuf, encode: F) } } -fn encode_dep_graph(tcx: TyCtxt<'_, '_>, encoder: &mut Encoder) { +fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut Encoder) { // First encode the commandline arguments hash tcx.sess.opts.dep_tracking_hash().encode(encoder).unwrap(); @@ -233,7 +233,7 @@ fn encode_work_product_index(work_products: &FxHashMap, encoder: &mut Encoder) { +fn encode_query_cache(tcx: TyCtxt<'_>, encoder: &mut Encoder) { time(tcx.sess, "serialize query result cache", || { tcx.serialize_query_result_cache(encoder).unwrap(); }) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index d76ae18741213..cb995907a51fe 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -791,14 +791,14 @@ pub fn default_provide_extern(providers: &mut ty::query::Providers<'_>) { declare_box_region_type!( pub BoxedGlobalCtxt, - for('gcx), - (&'gcx GlobalCtxt<'gcx>) -> ((), ()) + for('tcx), + (&'tcx GlobalCtxt<'tcx>) -> ((), ()) ); impl BoxedGlobalCtxt { pub fn enter(&mut self, f: F) -> R where - F: for<'tcx> FnOnce(TyCtxt<'tcx, 'tcx>) -> R, + F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> R, { self.access(|gcx| ty::tls::enter_global(gcx, |tcx| f(tcx))) } @@ -866,7 +866,7 @@ pub fn create_global_ctxt( }); yield BoxedGlobalCtxt::initial_yield(()); - box_region_allow_access!(for('gcx), (&'gcx GlobalCtxt<'gcx>), (gcx)); + box_region_allow_access!(for('tcx), (&'tcx GlobalCtxt<'tcx>), (gcx)); if sess.opts.debugging_opts.query_stats { gcx.queries.print_stats(); @@ -878,7 +878,7 @@ pub fn create_global_ctxt( /// Runs the resolution, type-checking, region checking and other /// miscellaneous analysis passes on the crate. -fn analysis<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Result<()> { +fn analysis<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Result<()> { assert_eq!(cnum, LOCAL_CRATE); let sess = tcx.sess; @@ -996,7 +996,7 @@ fn analysis<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Result<()> { } fn encode_and_write_metadata<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, outputs: &OutputFilenames, ) -> (middle::cstore::EncodedMetadata, bool) { #[derive(PartialEq, Eq, PartialOrd, Ord)] @@ -1059,7 +1059,7 @@ fn encode_and_write_metadata<'tcx>( /// be discarded. pub fn start_codegen<'tcx>( codegen_backend: &dyn CodegenBackend, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, rx: mpsc::Receiver>, outputs: &OutputFilenames, ) -> Box { diff --git a/src/librustc_interface/proc_macro_decls.rs b/src/librustc_interface/proc_macro_decls.rs index 49f892ac299f4..9e1ef6b022d9b 100644 --- a/src/librustc_interface/proc_macro_decls.rs +++ b/src/librustc_interface/proc_macro_decls.rs @@ -6,11 +6,11 @@ use rustc::ty::query::Providers; use syntax::attr; use syntax::symbol::sym; -pub fn find<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Option { +pub fn find<'tcx>(tcx: TyCtxt<'tcx>) -> Option { tcx.proc_macro_decls_static(LOCAL_CRATE) } -fn proc_macro_decls_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Option { +fn proc_macro_decls_static<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Option { assert_eq!(cnum, LOCAL_CRATE); let mut finder = Finder { decls: None }; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 5eff28b194b98..ec8a9c6fbb2a8 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -75,7 +75,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn lint_mod<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn lint_mod<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { lint::late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new()); } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index edaacf7749407..a843ee6d45d8f 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -519,11 +519,11 @@ enum FfiResult<'tcx> { }, } -fn is_zst<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, did: DefId, ty: Ty<'tcx>) -> bool { +fn is_zst<'tcx>(tcx: TyCtxt<'tcx>, did: DefId, ty: Ty<'tcx>) -> bool { tcx.layout_of(tcx.param_env(did).and(ty)).map(|layout| layout.is_zst()).unwrap_or(false) } -fn ty_is_known_nonnull<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { +fn ty_is_known_nonnull<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { match ty.sty { ty::FnPtr(_) => true, ty::Ref(..) => true, @@ -556,7 +556,7 @@ fn ty_is_known_nonnull<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { /// core::ptr::NonNull, and #[repr(transparent)] newtypes. /// FIXME: This duplicates code in codegen. fn is_repr_nullable_ptr<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ty_def: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>, diff --git a/src/librustc_macros/src/query.rs b/src/librustc_macros/src/query.rs index 8b7dc557c59ca..0474d2a2e3b3a 100644 --- a/src/librustc_macros/src/query.rs +++ b/src/librustc_macros/src/query.rs @@ -327,7 +327,7 @@ fn add_query_description_impl( quote! { #[inline] fn try_load_from_disk( - #tcx: TyCtxt<'tcx, 'tcx>, + #tcx: TyCtxt<'tcx>, #id: SerializedDepNodeIndex ) -> Option { #block @@ -338,7 +338,7 @@ fn add_query_description_impl( quote! { #[inline] fn try_load_from_disk( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, id: SerializedDepNodeIndex ) -> Option { tcx.queries.on_disk_cache.try_load_query_result(tcx, id) @@ -350,7 +350,7 @@ fn add_query_description_impl( quote! { #[inline] #[allow(unused_variables)] - fn cache_on_disk(#tcx: TyCtxt<'tcx, 'tcx>, #key: Self::Key) -> bool { + fn cache_on_disk(#tcx: TyCtxt<'tcx>, #key: Self::Key) -> bool { #expr } @@ -367,7 +367,7 @@ fn add_query_description_impl( quote! { #[allow(unused_variables)] fn describe( - #tcx: TyCtxt<'_, '_>, + #tcx: TyCtxt<'_>, #key: #arg, ) -> Cow<'static, str> { format!(#desc).into() diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 7d07331cfff70..86536b179f222 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -40,11 +40,12 @@ macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $($name:ident => $compute:block)*) => { pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) { - $(fn $name<$lt:$lt, T>($tcx: TyCtxt<$lt, $lt>, def_id_arg: T) - -> as - QueryConfig<$lt>>::Value - where T: IntoArgs, - { + // HACK(eddyb) `$lt: $lt` forces `$lt` to be early-bound, which + // allows the associated type in the return type to be normalized. + $(fn $name<$lt: $lt, T: IntoArgs>( + $tcx: TyCtxt<$lt>, + def_id_arg: T, + ) -> as QueryConfig<$lt>>::Value { #[allow(unused_variables)] let ($def_id, $other) = def_id_arg.into_args(); assert!(!$def_id.is_local()); @@ -550,7 +551,7 @@ impl CrateStore for cstore::CStore { self.do_postorder_cnums_untracked() } - fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata { + fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx>) -> EncodedMetadata { encoder::encode_metadata(tcx) } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 9ec31e33f9e06..a3cd33209076b 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -39,7 +39,7 @@ pub struct DecodeContext<'a, 'tcx: 'a> { opaque: opaque::Decoder<'a>, cdata: Option<&'a CrateMetadata>, sess: Option<&'a Session>, - tcx: Option>, + tcx: Option>, // Cache the last used source_file for translating spans as an optimization. last_source_file_index: usize, @@ -55,7 +55,7 @@ pub trait Metadata<'a, 'tcx>: Copy { fn raw_bytes(self) -> &'a [u8]; fn cdata(self) -> Option<&'a CrateMetadata> { None } fn sess(self) -> Option<&'a Session> { None } - fn tcx(self) -> Option> { + fn tcx(self) -> Option> { None } @@ -116,14 +116,14 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, &'a Session) { } } -impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, TyCtxt<'tcx, 'tcx>) { +impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, TyCtxt<'tcx>) { fn raw_bytes(self) -> &'a [u8] { self.0.raw_bytes() } fn cdata(self) -> Option<&'a CrateMetadata> { Some(self.0) } - fn tcx(self) -> Option> { + fn tcx(self) -> Option> { Some(self.1) } } @@ -148,7 +148,7 @@ impl<'a, 'tcx: 'a, T: Decodable> LazySeq { } impl<'a, 'tcx> DecodeContext<'a, 'tcx> { - pub fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + pub fn tcx(&self) -> TyCtxt<'tcx> { self.tcx.expect("missing TyCtxt in DecodeContext") } @@ -173,7 +173,7 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> { impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> { #[inline] - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx.expect("missing TyCtxt in DecodeContext") } @@ -548,7 +548,7 @@ impl<'a, 'tcx> CrateMetadata { fn get_variant( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item: &Entry<'_>, index: DefIndex, parent_did: DefId, @@ -589,7 +589,7 @@ impl<'a, 'tcx> CrateMetadata { ) } - pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> &'tcx ty::AdtDef { + pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef { let item = self.entry(item_id); let did = self.local_def_id(item_id); @@ -617,7 +617,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_predicates( &self, item_id: DefIndex, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> ty::GenericPredicates<'tcx> { self.entry(item_id).predicates.unwrap().decode((self, tcx)) } @@ -625,7 +625,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_predicates_defined_on( &self, item_id: DefIndex, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> ty::GenericPredicates<'tcx> { self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx)) } @@ -633,7 +633,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_super_predicates( &self, item_id: DefIndex, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> ty::GenericPredicates<'tcx> { let super_predicates = match self.entry(item_id).kind { EntryKind::Trait(data) => data.decode(self).super_predicates, @@ -651,7 +651,7 @@ impl<'a, 'tcx> CrateMetadata { self.entry(item_id).generics.unwrap().decode((self, sess)) } - pub fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> { + pub fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { self.entry(id).ty.unwrap().decode((self, tcx)) } @@ -704,7 +704,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_impl_trait( &self, id: DefIndex, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option> { self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx))) } @@ -712,7 +712,7 @@ impl<'a, 'tcx> CrateMetadata { /// Iterates over all the stability attributes in the given crate. pub fn get_lib_features( &self, - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, ) -> &'tcx [(ast::Name, Option)] { // FIXME: For a proc macro crate, not sure whether we should return the "host" // features or an empty Vec. Both don't cause ICEs. @@ -722,7 +722,7 @@ impl<'a, 'tcx> CrateMetadata { } /// Iterates over the language items in the given crate. - pub fn get_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [(DefId, usize)] { + pub fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] { if self.proc_macros.is_some() { // Proc macro crates do not export any lang-items to the target. &[] @@ -885,7 +885,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn maybe_get_optimized_mir( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, id: DefIndex, ) -> Option> { match self.is_proc_macro(id) { @@ -1019,7 +1019,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_inherent_implementations_for_type( &self, - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, id: DefIndex, ) -> &'tcx [DefId] { tcx.arena.alloc_from_iter(self.entry(id) @@ -1030,7 +1030,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_implementations_for_trait( &self, - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, filter: Option, ) -> &'tcx [DefId] { if self.proc_macros.is_some() { @@ -1085,7 +1085,7 @@ impl<'a, 'tcx> CrateMetadata { } } - pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [ForeignModule] { + pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] { if self.proc_macros.is_some() { // Proc macro crates do not have any *target* foreign modules. &[] @@ -1096,7 +1096,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn get_dylib_dependency_formats( &self, - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, ) -> &'tcx [(CrateNum, LinkagePreference)] { tcx.arena.alloc_from_iter(self.root .dylib_dependency_formats @@ -1108,7 +1108,7 @@ impl<'a, 'tcx> CrateMetadata { })) } - pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [lang_items::LangItem] { + pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] { if self.proc_macros.is_some() { // Proc macro crates do not depend on any target weak lang-items. &[] @@ -1131,7 +1131,7 @@ impl<'a, 'tcx> CrateMetadata { pub fn exported_symbols( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> { if self.proc_macros.is_some() { // If this crate is a custom derive crate, then we're not even going to @@ -1187,7 +1187,7 @@ impl<'a, 'tcx> CrateMetadata { } } - pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> { + pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { let sig = match self.entry(id).kind { EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).sig, diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 5c73ee43c059c..dbf140afda24d 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -42,7 +42,7 @@ use rustc::hir::intravisit; pub struct EncodeContext<'tcx> { opaque: opaque::Encoder, - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, entries_index: Index<'tcx>, @@ -1816,7 +1816,7 @@ impl EncodeContext<'tcx> { } struct ImplVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impls: FxHashMap>, } @@ -1863,7 +1863,7 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> { // will allow us to slice the metadata to the precise length that we just // generated regardless of trailing bytes that end up in it. -pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata { +pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx>) -> EncodedMetadata { let mut encoder = opaque::Encoder::new(vec![]); encoder.emit_raw_bytes(METADATA_HEADER); @@ -1905,7 +1905,7 @@ pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata { EncodedMetadata { raw_data: result } } -pub fn get_repr_options<'tcx, 'gcx>(tcx: TyCtxt<'tcx, 'gcx>, did: DefId) -> ReprOptions { +pub fn get_repr_options<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> ReprOptions { let ty = tcx.type_of(did); match ty.sty { ty::Adt(ref def, _) => return def.repr, diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs index 63260312fa6de..0ce103cfa40dc 100644 --- a/src/librustc_metadata/foreign_modules.rs +++ b/src/librustc_metadata/foreign_modules.rs @@ -3,7 +3,7 @@ use rustc::hir; use rustc::middle::cstore::ForeignModule; use rustc::ty::TyCtxt; -pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec { +pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> Vec { let mut collector = Collector { tcx, modules: Vec::new(), @@ -13,7 +13,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec { } struct Collector<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, modules: Vec, } diff --git a/src/librustc_metadata/link_args.rs b/src/librustc_metadata/link_args.rs index 576b0da1fd8e2..cd6270046faab 100644 --- a/src/librustc_metadata/link_args.rs +++ b/src/librustc_metadata/link_args.rs @@ -4,7 +4,7 @@ use rustc::ty::TyCtxt; use rustc_target::spec::abi::Abi; use syntax::symbol::sym; -pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec { +pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> Vec { let mut collector = Collector { args: Vec::new(), }; diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index ef74fdf8a9e54..7b335b3b4832d 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -11,7 +11,7 @@ use syntax::feature_gate::{self, GateIssue}; use syntax::symbol::{Symbol, sym}; use syntax::{span_err, struct_span_err}; -pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec { +pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> Vec { let mut collector = Collector { tcx, libs: Vec::new(), @@ -29,7 +29,7 @@ pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { } struct Collector<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, libs: Vec, } diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index 5accf2abdadbf..f6f2cfbfc0886 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -122,7 +122,7 @@ impl LocalsStateAtExit { impl<'tcx> BorrowSet<'tcx> { pub fn build( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, locals_are_invalidated_at_exit: bool, move_data: &MoveData<'tcx>, @@ -160,8 +160,8 @@ impl<'tcx> BorrowSet<'tcx> { } } -struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +struct GatherBorrows<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, idx_vec: IndexVec>, location_map: FxHashMap, @@ -181,7 +181,7 @@ struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> { locals_state_at_exit: LocalsStateAtExit, } -impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> { fn visit_assign( &mut self, assigned_place: &mir::Place<'tcx>, @@ -288,7 +288,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> GatherBorrows<'a, 'tcx> { /// If this is a two-phase borrow, then we will record it /// as "pending" until we find the activating use. diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 359e3be860df0..6a70a23729c26 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -43,7 +43,7 @@ enum StorageDeadOrDrop<'tcx> { Destructor(Ty<'tcx>), } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { pub(super) fn report_use_of_moved_or_uninitialized( &mut self, location: Location, @@ -1903,7 +1903,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { /// helps explain. pub(super) fn emit( &self, - cx: &mut MirBorrowckCtxt<'_, '_, 'tcx>, + cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut DiagnosticBuilder<'_>, ) -> String { match self { diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index a124c78ab6796..7eb296353a494 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -18,7 +18,7 @@ use super::{MirBorrowckCtxt}; pub(super) struct IncludingDowncast(pub(super) bool); -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure /// is moved after being invoked. /// @@ -403,7 +403,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime /// name where required. pub(super) fn get_name_for_ty(&self, ty: Ty<'tcx>, counter: usize) -> String { @@ -547,7 +547,7 @@ impl UseSpans { } } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Finds the spans associated to a move or copy of move_place at location. pub(super) fn move_spans( &self, diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs index c0b199f1798d4..5a57db2a6724e 100644 --- a/src/librustc_mir/borrow_check/flows.rs +++ b/src/librustc_mir/borrow_check/flows.rs @@ -22,20 +22,20 @@ use std::fmt; use std::rc::Rc; // (forced to be `pub` due to its use as an associated type below.) -crate struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> { - borrows: FlowAtLocation<'tcx, Borrows<'b, 'gcx, 'tcx>>, - pub uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>, - pub ever_inits: FlowAtLocation<'tcx, EverInitializedPlaces<'b, 'gcx, 'tcx>>, +crate struct Flows<'b, 'tcx: 'b> { + borrows: FlowAtLocation<'tcx, Borrows<'b, 'tcx>>, + pub uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'tcx>>, + pub ever_inits: FlowAtLocation<'tcx, EverInitializedPlaces<'b, 'tcx>>, /// Polonius Output pub polonius_output: Option>>, } -impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> { +impl<'b, 'tcx> Flows<'b, 'tcx> { crate fn new( - borrows: FlowAtLocation<'tcx, Borrows<'b, 'gcx, 'tcx>>, - uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>, - ever_inits: FlowAtLocation<'tcx, EverInitializedPlaces<'b, 'gcx, 'tcx>>, + borrows: FlowAtLocation<'tcx, Borrows<'b, 'tcx>>, + uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'tcx>>, + ever_inits: FlowAtLocation<'tcx, EverInitializedPlaces<'b, 'tcx>>, polonius_output: Option>>, ) -> Self { Flows { @@ -70,7 +70,7 @@ macro_rules! each_flow { }; } -impl<'b, 'gcx, 'tcx> FlowsAtLocation for Flows<'b, 'gcx, 'tcx> { +impl<'b, 'tcx> FlowsAtLocation for Flows<'b, 'tcx> { fn reset_to_entry_of(&mut self, bb: BasicBlock) { each_flow!(self, reset_to_entry_of(bb)); } @@ -92,7 +92,7 @@ impl<'b, 'gcx, 'tcx> FlowsAtLocation for Flows<'b, 'gcx, 'tcx> { } } -impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> { +impl<'b, 'tcx> fmt::Display for Flows<'b, 'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut s = String::new(); diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 60ad8921c0b3d..82fee9ea48f03 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -87,7 +87,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> BorrowCheckResult<'tcx> { +fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> BorrowCheckResult<'tcx> { let input_body = tcx.mir_validated(def_id); debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id)); @@ -100,11 +100,11 @@ fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> BorrowCheckResu opt_closure_req } -fn do_mir_borrowck<'a, 'gcx, 'tcx>( - infcx: &InferCtxt<'a, 'gcx, 'tcx>, - input_body: &Body<'gcx>, +fn do_mir_borrowck<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + input_body: &Body<'tcx>, def_id: DefId, -) -> BorrowCheckResult<'gcx> { +) -> BorrowCheckResult<'tcx> { debug!("do_mir_borrowck(def_id = {:?})", def_id); let tcx = infcx.tcx; @@ -423,8 +423,8 @@ fn downgrade_if_error(diag: &mut Diagnostic) { } } -pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +pub struct MirBorrowckCtxt<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, body: &'cx Body<'tcx>, mir_def_id: DefId, move_data: &'cx MoveData<'tcx>, @@ -508,8 +508,8 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> { // 2. loans made in overlapping scopes do not conflict // 3. assignments do not affect things loaned out as immutable // 4. moves do not affect things loaned out in any way -impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - type FlowState = Flows<'cx, 'gcx, 'tcx>; +impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx> { + type FlowState = Flows<'cx, 'tcx>; fn body(&self) -> &'cx Body<'tcx> { self.body @@ -920,7 +920,7 @@ impl InitializationRequiringAction { } } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Checks an access to the given place to see if it is allowed. Examines the set of borrows /// that are in scope, as well as which paths have been initialized, to ensure that (a) the /// place is initialized and (b) it is not borrowed in some way that would prevent this @@ -933,7 +933,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place_span: (&Place<'tcx>, Span), kind: (AccessDepth, ReadOrWrite), is_local_mutation_allowed: LocalMutationIsAllowed, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { let (sd, rw) = kind; @@ -996,7 +996,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place_span: (&Place<'tcx>, Span), sd: AccessDepth, rw: ReadOrWrite, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) -> bool { debug!( "check_access_for_conflict(location={:?}, place_span={:?}, sd={:?}, rw={:?})", @@ -1148,7 +1148,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place_span: (&Place<'tcx>, Span), kind: AccessDepth, mode: MutateMode, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { // Write of P[i] or *P, or WriteAndRead of any P, requires P init'd. match mode { @@ -1195,7 +1195,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &mut self, location: Location, (rvalue, span): (&Rvalue<'tcx>, Span), - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { match *rvalue { Rvalue::Ref(_ /*rgn*/, bk, ref place) => { @@ -1382,7 +1382,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &mut self, location: Location, (operand, span): (&Operand<'tcx>, Span), - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { match *operand { Operand::Copy(ref place) => { @@ -1515,7 +1515,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &mut self, location: Location, span: Span, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { // Two-phase borrow support: For each activation that is newly // generated at this statement, check if it interferes with @@ -1547,13 +1547,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn check_if_reassignment_to_immutable_state( &mut self, location: Location, local: Local, place_span: (&Place<'tcx>, Span), - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { debug!("check_if_reassignment_to_immutable_state({:?})", local); @@ -1573,7 +1573,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { location: Location, desired_action: InitializationRequiringAction, place_span: (&Place<'tcx>, Span), - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1641,7 +1641,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { location: Location, desired_action: InitializationRequiringAction, place_span: (&Place<'tcx>, Span), - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1728,7 +1728,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &mut self, location: Location, (place, span): (&Place<'tcx>, Span), - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { debug!("check_if_assigned_path_is_moved place: {:?}", place); // recur down place; dispatch to external checks when necessary @@ -1811,12 +1811,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - fn check_parent_of_field<'cx, 'gcx, 'tcx>( - this: &mut MirBorrowckCtxt<'cx, 'gcx, 'tcx>, + fn check_parent_of_field<'cx, 'tcx>( + this: &mut MirBorrowckCtxt<'cx, 'tcx>, location: Location, base: &Place<'tcx>, span: Span, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { // rust-lang/rust#21232: Until Rust allows reads from the // initialized parts of partially initialized structs, we @@ -1905,7 +1905,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { (place, span): (&Place<'tcx>, Span), kind: ReadOrWrite, is_local_mutation_allowed: LocalMutationIsAllowed, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, location: Location, ) -> bool { debug!( @@ -2036,7 +2036,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn is_local_ever_initialized(&self, local: Local, - flow_state: &Flows<'cx, 'gcx, 'tcx>) + flow_state: &Flows<'cx, 'tcx>) -> Option { let mpi = self.move_data.rev_lookup.find_local(local); @@ -2053,7 +2053,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn add_used_mut<'d>( &mut self, root_place: RootPlace<'d, 'tcx>, - flow_state: &Flows<'cx, 'gcx, 'tcx>, + flow_state: &Flows<'cx, 'tcx>, ) { match root_place { RootPlace { diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index a010338a08d12..402654c44ac15 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -96,7 +96,7 @@ impl BorrowedContentSource<'tcx> { } } - fn from_call(func: Ty<'tcx>, tcx: TyCtxt<'_, 'tcx>) -> Option { + fn from_call(func: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option { match func.sty { ty::FnDef(def_id, substs) => { let trait_id = tcx.trait_of_item(def_id)?; @@ -119,7 +119,7 @@ impl BorrowedContentSource<'tcx> { } } -impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { pub(crate) fn report_move_errors(&mut self, move_errors: Vec<(Place<'tcx>, MoveError<'tcx>)>) { let grouped_errors = self.group_move_errors(move_errors); for error in grouped_errors { diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index ccdde320df06e..d3c23cfd65a66 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -24,7 +24,7 @@ pub(super) enum AccessKind { Move, } -impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { pub(super) fn report_mutability_error( &mut self, access_place: &Place<'tcx>, @@ -522,8 +522,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { } } -fn suggest_ampmut_self<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn suggest_ampmut_self<'tcx>( + tcx: TyCtxt<'tcx>, local_decl: &mir::LocalDecl<'tcx>, ) -> (Span, String) { let sp = local_decl.source_info.span; @@ -555,8 +555,8 @@ fn suggest_ampmut_self<'gcx, 'tcx>( // // This implementation attempts to emulate AST-borrowck prioritization // by trying (3.), then (2.) and finally falling back on (1.). -fn suggest_ampmut<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn suggest_ampmut<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, local: Local, local_decl: &mir::LocalDecl<'tcx>, @@ -623,7 +623,7 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool { /// | ---------- use `&'a mut String` here to make mutable /// ``` fn annotate_struct_field( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, field: &mir::Field, ) -> Option<(Span, String)> { diff --git a/src/librustc_mir/borrow_check/nll/constraint_generation.rs b/src/librustc_mir/borrow_check/nll/constraint_generation.rs index 4a9aad2e80abc..18c542de27268 100644 --- a/src/librustc_mir/borrow_check/nll/constraint_generation.rs +++ b/src/librustc_mir/borrow_check/nll/constraint_generation.rs @@ -13,8 +13,8 @@ use rustc::ty::fold::TypeFoldable; use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty}; use rustc::ty::subst::SubstsRef; -pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>( - infcx: &InferCtxt<'cx, 'gcx, 'tcx>, +pub(super) fn generate_constraints<'cx, 'tcx>( + infcx: &InferCtxt<'cx, 'tcx>, liveness_constraints: &mut LivenessValues, all_facts: &mut Option, location_table: &LocationTable, @@ -35,15 +35,15 @@ pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>( } /// 'cg = the duration of the constraint generation process itself. -struct ConstraintGeneration<'cg, 'cx: 'cg, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cg InferCtxt<'cx, 'gcx, 'tcx>, +struct ConstraintGeneration<'cg, 'cx: 'cg, 'tcx: 'cx> { + infcx: &'cg InferCtxt<'cx, 'tcx>, all_facts: &'cg mut Option, location_table: &'cg LocationTable, liveness_constraints: &'cg mut LivenessValues, borrow_set: &'cg BorrowSet<'tcx>, } -impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx, 'tcx> { +impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> { fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) { self.super_basic_block_data(bb, data); } @@ -177,7 +177,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx } } -impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> { +impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> { /// Some variable with type `live_ty` is "regular live" at /// `location` -- i.e., it may be used later. This means that all /// regions appearing in the type `live_ty` must be live at diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs index 5563bdcaebf27..4d7ab90a4b3ef 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs @@ -12,7 +12,7 @@ use rustc_data_structures::fx::FxHashSet; crate fn find<'tcx>( body: &Body<'tcx>, regioncx: &Rc>, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, region_vid: RegionVid, start_point: Location, ) -> Option { @@ -27,15 +27,15 @@ crate fn find<'tcx>( uf.find() } -struct UseFinder<'cx, 'gcx: 'tcx, 'tcx: 'cx> { +struct UseFinder<'cx, 'tcx: 'cx> { body: &'cx Body<'tcx>, regioncx: &'cx Rc>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, region_vid: RegionVid, start_point: Location, } -impl<'cx, 'gcx, 'tcx> UseFinder<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> UseFinder<'cx, 'tcx> { fn find(&mut self) -> Option { let mut queue = VecDeque::new(); let mut visited = FxHashSet::default(); @@ -99,9 +99,9 @@ impl<'cx, 'gcx, 'tcx> UseFinder<'cx, 'gcx, 'tcx> { } } -struct DefUseVisitor<'cx, 'gcx: 'tcx, 'tcx: 'cx> { +struct DefUseVisitor<'cx, 'tcx: 'cx> { body: &'cx Body<'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, region_vid: RegionVid, def_use_result: Option, } @@ -112,7 +112,7 @@ enum DefUseResult { UseDrop { local: Local }, } -impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for DefUseVisitor<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> Visitor<'tcx> for DefUseVisitor<'cx, 'tcx> { fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) { let local_ty = self.body.local_decls[local].ty; diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs index a8b197135b0a0..4bc2f7064bef4 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs @@ -51,9 +51,9 @@ impl BorrowExplanation { _ => true, } } - pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'gcx, 'tcx>( + pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'tcx>( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, err: &mut DiagnosticBuilder<'_>, borrow_desc: &str, @@ -207,7 +207,7 @@ impl BorrowExplanation { } } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Returns structured explanation for *why* the borrow contains the /// point from `location`. This is key for the "3-point errors" /// [described in the NLL RFC][d]. diff --git a/src/librustc_mir/borrow_check/nll/facts.rs b/src/librustc_mir/borrow_check/nll/facts.rs index fdeec036ad043..d84afeac18523 100644 --- a/src/librustc_mir/borrow_check/nll/facts.rs +++ b/src/librustc_mir/borrow_check/nll/facts.rs @@ -15,7 +15,7 @@ crate type AllFacts = PoloniusAllFacts; crate trait AllFactsExt { /// Returns `true` if there is a need to gather `AllFacts` given the /// current `-Z` flags. - fn enabled(tcx: TyCtxt<'_, '_>) -> bool; + fn enabled(tcx: TyCtxt<'_>) -> bool; fn write_to_dir( &self, @@ -26,7 +26,7 @@ crate trait AllFactsExt { impl AllFactsExt for AllFacts { /// Return - fn enabled(tcx: TyCtxt<'_, '_>) -> bool { + fn enabled(tcx: TyCtxt<'_>) -> bool { tcx.sess.opts.debugging_opts.nll_facts || tcx.sess.opts.debugging_opts.polonius } diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 12433ca365d68..8ce9cf60eeb95 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -17,8 +17,8 @@ use rustc::mir::TerminatorKind; use rustc::mir::{Operand, BorrowKind}; use rustc_data_structures::graph::dominators::Dominators; -pub(super) fn generate_invalidates<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(super) fn generate_invalidates<'tcx>( + tcx: TyCtxt<'tcx>, all_facts: &mut Option, location_table: &LocationTable, body: &Body<'tcx>, @@ -43,8 +43,8 @@ pub(super) fn generate_invalidates<'gcx, 'tcx>( } } -struct InvalidationGenerator<'cx, 'tcx: 'cx, 'gcx: 'tcx> { - tcx: TyCtxt<'gcx, 'tcx>, +struct InvalidationGenerator<'cx, 'tcx: 'cx> { + tcx: TyCtxt<'tcx>, all_facts: &'cx mut AllFacts, location_table: &'cx LocationTable, body: &'cx Body<'tcx>, @@ -54,7 +54,7 @@ struct InvalidationGenerator<'cx, 'tcx: 'cx, 'gcx: 'tcx> { /// Visits the whole MIR and generates `invalidates()` facts. /// Most of the code implementing this was stolen from `borrow_check/mod.rs`. -impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { +impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> { fn visit_statement( &mut self, statement: &Statement<'tcx>, @@ -258,7 +258,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { } } -impl<'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { +impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> { /// Simulates mutation of a place. fn mutate_place( &mut self, diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index a260f5460e504..5dd7b7452733c 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -46,8 +46,8 @@ use self::universal_regions::UniversalRegions; /// scraping out the set of universal regions (e.g., region parameters) /// declared on the function. That set will need to be given to /// `compute_regions`. -pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( - infcx: &InferCtxt<'cx, 'gcx, 'tcx>, +pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'tcx>( + infcx: &InferCtxt<'cx, 'tcx>, def_id: DefId, param_env: ty::ParamEnv<'tcx>, body: &mut Body<'tcx>, @@ -69,22 +69,22 @@ pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( /// Computes the (non-lexical) regions from the input MIR. /// /// This may result in errors being reported. -pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( - infcx: &InferCtxt<'cx, 'gcx, 'tcx>, +pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>( + infcx: &InferCtxt<'cx, 'tcx>, def_id: DefId, universal_regions: UniversalRegions<'tcx>, body: &Body<'tcx>, upvars: &[Upvar], location_table: &LocationTable, - param_env: ty::ParamEnv<'gcx>, - flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'cx, 'gcx, 'tcx>>, + param_env: ty::ParamEnv<'tcx>, + flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'cx, 'tcx>>, move_data: &MoveData<'tcx>, borrow_set: &BorrowSet<'tcx>, errors_buffer: &mut Vec, ) -> ( RegionInferenceContext<'tcx>, Option>>, - Option>, + Option>, ) { let mut all_facts = if AllFacts::enabled(infcx.tcx) { Some(AllFacts::default()) @@ -210,8 +210,8 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( (regioncx, polonius_output, closure_region_requirements) } -fn dump_mir_results<'a, 'gcx, 'tcx>( - infcx: &InferCtxt<'a, 'gcx, 'tcx>, +fn dump_mir_results<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, source: MirSource<'tcx>, body: &Body<'tcx>, regioncx: &RegionInferenceContext<'_>, @@ -271,8 +271,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( }; } -fn dump_annotation<'a, 'gcx, 'tcx>( - infcx: &InferCtxt<'a, 'gcx, 'tcx>, +fn dump_annotation<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, body: &Body<'tcx>, mir_def_id: DefId, regioncx: &RegionInferenceContext<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 85937848eca96..04ff54e9a5e45 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -239,7 +239,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { &self, body: &Body<'tcx>, upvars: &[Upvar], - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, mir_def_id: DefId, fr: RegionVid, outlived_fr: RegionVid, @@ -359,7 +359,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { &self, body: &Body<'tcx>, upvars: &[Upvar], - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, mir_def_id: DefId, _fr: RegionVid, outlived_fr: RegionVid, @@ -424,7 +424,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { &self, body: &Body<'tcx>, upvars: &[Upvar], - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, mir_def_id: DefId, fr: RegionVid, outlived_fr: RegionVid, @@ -516,7 +516,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { &self, body: &Body<'tcx>, upvars: &[Upvar], - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, mir_def_id: DefId, fr: RegionVid, fr_is_local: bool, @@ -585,7 +585,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// ``` fn add_static_impl_trait_suggestion( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, diag: &mut DiagnosticBuilder<'_>, fr: RegionVid, // We need to pass `fr_name` - computing it again will label it twice. @@ -671,7 +671,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, borrow_region: RegionVid, outlived_region: RegionVid, ) -> (ConstraintCategory, bool, Span, Option) { @@ -752,7 +752,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Returns `true` if a closure is inferred to be an `FnMut` closure. - crate fn is_closure_fn_mut(&self, infcx: &InferCtxt<'_, '_, 'tcx>, fr: RegionVid) -> bool { + crate fn is_closure_fn_mut(&self, infcx: &InferCtxt<'_, 'tcx>, fr: RegionVid) -> bool { if let Some(ty::ReFree(free_region)) = self.to_error_region(fr) { if let ty::BoundRegion::BrEnv = free_region.bound_region { if let DefiningTy::Closure(def_id, substs) = self.universal_regions.defining_ty { diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index a263d3be3a547..1ec30897e92da 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -151,7 +151,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// and then return the name `'1` for us to use. crate fn give_region_a_name( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, @@ -194,7 +194,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// named variants. fn give_name_from_error_region( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, mir_def_id: DefId, fr: RegionVid, counter: &mut usize, @@ -303,7 +303,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// ``` fn get_named_span( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, error_region: &RegionKind, name: InternedString, ) -> Span { @@ -331,7 +331,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// ``` fn give_name_if_anonymous_region_appears_in_arguments( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, mir_def_id: DefId, fr: RegionVid, @@ -359,7 +359,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { fn give_name_if_we_can_match_hir_ty_from_argument( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, mir_def_id: DefId, needle_fr: RegionVid, @@ -405,7 +405,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// ``` fn give_name_if_we_cannot_match_hir_ty( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, needle_fr: RegionVid, argument_ty: Ty<'tcx>, @@ -461,7 +461,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// to highlighting that closest type instead. fn give_name_if_we_can_match_hir_ty( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, needle_fr: RegionVid, argument_ty: Ty<'tcx>, argument_hir_ty: &hir::Ty, @@ -653,7 +653,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// ``` fn give_name_if_anonymous_region_appears_in_upvars( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, upvars: &[Upvar], fr: RegionVid, counter: &mut usize, @@ -675,7 +675,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// or be early bound (named, not in argument). fn give_name_if_anonymous_region_appears_in_output( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, mir_def_id: DefId, fr: RegionVid, @@ -735,7 +735,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { fn give_name_if_anonymous_region_appears_in_yield_ty( &self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, mir_def_id: DefId, fr: RegionVid, 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 882a52a0c4565..5afc0514a5671 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 @@ -10,7 +10,7 @@ use syntax_pos::symbol::Symbol; impl<'tcx> RegionInferenceContext<'tcx> { crate fn get_var_name_and_span_for_region( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, upvars: &[Upvar], fr: RegionVid, @@ -35,7 +35,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>, + tcx: TyCtxt<'tcx>, fr: RegionVid, ) -> Option { let upvar_index = self @@ -69,7 +69,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// declared. crate fn get_upvar_name_and_span_for_region( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, upvars: &[Upvar], upvar_index: usize, ) -> (Symbol, Span) { @@ -91,7 +91,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// user - in particular, index 0 is not the implicit self parameter. crate fn get_argument_index_for_region( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, fr: RegionVid, ) -> Option { let implicit_inputs = self.universal_regions.defining_ty.implicit_inputs(); diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index 13606f61a689c..2b38fcee47960 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -370,7 +370,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`. - crate fn annotate(&self, tcx: TyCtxt<'_, 'tcx>, err: &mut DiagnosticBuilder<'_>) { + crate fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut DiagnosticBuilder<'_>) { self.universal_regions.annotate(tcx, err) } @@ -397,14 +397,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// Performs region inference and report errors if we see any /// unsatisfiable constraints. If this is a closure, returns the /// region requirements to propagate to our creator, if any. - pub(super) fn solve<'gcx>( + pub(super) fn solve( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, errors_buffer: &mut Vec, - ) -> Option> { + ) -> Option> { common::time_ext( infcx.tcx.sess.time_extended(), Some(infcx.tcx.sess), @@ -413,14 +413,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) } - fn solve_inner<'gcx>( + fn solve_inner( &mut self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, errors_buffer: &mut Vec, - ) -> Option> { + ) -> Option> { self.propagate_constraints(body); // If this is a closure, we can propagate unsatisfied @@ -578,12 +578,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// whether the "type tests" produced by typeck were satisfied; /// type tests encode type-outlives relationships like `T: /// 'a`. See `TypeTest` for more details. - fn check_type_tests<'gcx>( + fn check_type_tests( &self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, mir_def_id: DefId, - mut propagated_outlives_requirements: Option<&mut Vec>>, + mut propagated_outlives_requirements: Option<&mut Vec>>, errors_buffer: &mut Vec, ) { let tcx = infcx.tcx; @@ -722,12 +722,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// The idea then is to lower the `T: 'X` constraint into multiple /// bounds -- e.g., if `'X` is the union of two free lifetimes, /// `'1` and `'2`, then we would create `T: '1` and `T: '2`. - fn try_promote_type_test<'gcx>( + fn try_promote_type_test( &self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, type_test: &TypeTest<'tcx>, - propagated_outlives_requirements: &mut Vec>, + propagated_outlives_requirements: &mut Vec>, ) -> bool { let tcx = infcx.tcx; @@ -794,7 +794,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// When we promote a type test `T: 'r`, we have to convert the /// type `T` into something we can store in a query result (so - /// something allocated for `'gcx`). This is problematic if `ty` + /// something allocated for `'tcx`). This is problematic if `ty` /// contains regions. During the course of NLL region checking, we /// will have replaced all of those regions with fresh inference /// variables. To create a test subject, we want to replace those @@ -803,11 +803,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// fallible process. Presuming we do find a suitable region, we /// will represent it with a `ReClosureBound`, which is a /// `RegionKind` variant that can be allocated in the gcx. - fn try_promote_type_test_subject<'gcx>( + fn try_promote_type_test_subject( &self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, ty: Ty<'tcx>, - ) -> Option> { + ) -> Option> { let tcx = infcx.tcx; let gcx = tcx.global_tcx(); @@ -943,7 +943,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// `point`. fn eval_verify_bound( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, generic_ty: Ty<'tcx>, lower_bound: RegionVid, @@ -976,7 +976,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { fn eval_if_eq( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, generic_ty: Ty<'tcx>, lower_bound: RegionVid, @@ -1022,7 +1022,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// higher-ranked things and so forth, and right now the inference /// context is not permitted to make more inference variables. So /// we use this kind of hacky solution. - fn normalize_to_scc_representatives(&self, tcx: TyCtxt<'_, 'tcx>, value: T) -> T + fn normalize_to_scc_representatives(&self, tcx: TyCtxt<'tcx>, value: T) -> T where T: TypeFoldable<'tcx>, { @@ -1102,13 +1102,13 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// If `propagated_outlives_requirements` is `Some`, then we will /// push unsatisfied obligations into there. Otherwise, we'll /// report them as errors. - fn check_universal_regions<'gcx>( + fn check_universal_regions( &self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, - mut propagated_outlives_requirements: Option<&mut Vec>>, + mut propagated_outlives_requirements: Option<&mut Vec>>, errors_buffer: &mut Vec, ) { for (fr, fr_definition) in self.definitions.iter_enumerated() { @@ -1147,14 +1147,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// /// Things that are to be propagated are accumulated into the /// `outlives_requirements` vector. - fn check_universal_region<'gcx>( + fn check_universal_region( &self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, longer_fr: RegionVid, - propagated_outlives_requirements: &mut Option<&mut Vec>>, + propagated_outlives_requirements: &mut Option<&mut Vec>>, errors_buffer: &mut Vec, ) { debug!("check_universal_region(fr={:?})", longer_fr); @@ -1215,11 +1215,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { &self, longer_fr: RegionVid, shorter_fr: RegionVid, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, upvars: &[Upvar], mir_def_id: DefId, - propagated_outlives_requirements: &mut Option<&mut Vec>>, + propagated_outlives_requirements: &mut Option<&mut Vec>>, errors_buffer: &mut Vec, ) -> Option { // If it is known that `fr: o`, carry on. @@ -1280,9 +1280,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { Some(ErrorReported) } - fn check_bound_universal_region<'gcx>( + fn check_bound_universal_region( &self, - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, body: &Body<'tcx>, _mir_def_id: DefId, longer_fr: RegionVid, @@ -1365,17 +1365,17 @@ impl<'tcx> RegionDefinition<'tcx> { } } -pub trait ClosureRegionRequirementsExt<'gcx, 'tcx> { +pub trait ClosureRegionRequirementsExt<'tcx> { fn apply_requirements( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, closure_def_id: DefId, closure_substs: SubstsRef<'tcx>, ) -> Vec>; fn subst_closure_mapping( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, closure_mapping: &IndexVec>, value: &T, ) -> T @@ -1383,7 +1383,7 @@ pub trait ClosureRegionRequirementsExt<'gcx, 'tcx> { T: TypeFoldable<'tcx>; } -impl<'gcx, 'tcx> ClosureRegionRequirementsExt<'gcx, 'tcx> for ClosureRegionRequirements<'gcx> { +impl<'tcx> ClosureRegionRequirementsExt<'tcx> for ClosureRegionRequirements<'tcx> { /// Given an instance T of the closure type, this method /// instantiates the "extra" requirements that we computed for the /// closure into the inference context. This has the effect of @@ -1398,7 +1398,7 @@ impl<'gcx, 'tcx> ClosureRegionRequirementsExt<'gcx, 'tcx> for ClosureRegionRequi /// requirements. fn apply_requirements( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, closure_def_id: DefId, closure_substs: SubstsRef<'tcx>, ) -> Vec> { @@ -1453,7 +1453,7 @@ impl<'gcx, 'tcx> ClosureRegionRequirementsExt<'gcx, 'tcx> for ClosureRegionRequi fn subst_closure_mapping( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, closure_mapping: &IndexVec>, value: &T, ) -> T diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index b5fe3d7c8b329..704e9315e7f55 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -6,7 +6,7 @@ use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; /// Replaces all free regions appearing in the MIR with fresh /// inference variables, returning the number of variables created. -pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, '_, 'tcx>, body: &mut Body<'tcx>) { +pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, 'tcx>, body: &mut Body<'tcx>) { debug!("renumber_mir()"); debug!("renumber_mir: body.arg_count={:?}", body.arg_count); @@ -17,7 +17,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>, + infcx: &InferCtxt<'_, 'tcx>, value: &T, ) -> T where @@ -33,11 +33,11 @@ where }) } -struct NLLVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +struct NLLVisitor<'a, 'tcx> { + infcx: &'a InferCtxt<'a, 'tcx>, } -impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> NLLVisitor<'a, 'tcx> { fn renumber_regions(&mut self, value: &T) -> T where T: TypeFoldable<'tcx>, @@ -46,7 +46,7 @@ impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'tcx> { fn visit_body(&mut self, body: &mut Body<'tcx>) { for promoted in body.promoted.iter_mut() { self.visit_body(promoted); 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 01dd60cc4891c..563514b922cbc 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 @@ -13,9 +13,9 @@ use rustc::ty::subst::UnpackedKind; use rustc::ty::{self, TyCtxt}; use syntax_pos::DUMMY_SP; -crate struct ConstraintConversion<'a, 'gcx: 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, +crate struct ConstraintConversion<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, + tcx: TyCtxt<'tcx>, universal_regions: &'a UniversalRegions<'tcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, @@ -25,9 +25,9 @@ crate struct ConstraintConversion<'a, 'gcx: 'tcx, 'tcx: 'a> { constraints: &'a mut MirTypeckRegionConstraints<'tcx>, } -impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { crate fn new( - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, + infcx: &'a InferCtxt<'a, 'tcx>, universal_regions: &'a UniversalRegions<'tcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, @@ -150,8 +150,8 @@ impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> { } } -impl<'a, 'b, 'gcx, 'tcx> TypeOutlivesDelegate<'tcx> - for &'a mut ConstraintConversion<'b, 'gcx, 'tcx> +impl<'a, 'b, 'tcx> TypeOutlivesDelegate<'tcx> + for &'a mut ConstraintConversion<'b, 'tcx> { fn push_sub_region_constraint( &mut self, diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs index 361353f8df4c8..ca42f249dc19b 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs @@ -55,7 +55,7 @@ crate struct CreateResult<'tcx> { } crate fn create( - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, implicit_region_bound: Option>, universal_regions: &Rc>, @@ -219,8 +219,8 @@ impl UniversalRegionRelations<'tcx> { } } -struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> { - infcx: &'this InferCtxt<'this, 'gcx, 'tcx>, +struct UniversalRegionRelationsBuilder<'this, 'tcx: 'this> { + infcx: &'this InferCtxt<'this, 'tcx>, param_env: ty::ParamEnv<'tcx>, universal_regions: Rc>, implicit_region_bound: Option>, @@ -231,7 +231,7 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> { region_bound_pairs: RegionBoundPairs<'tcx>, } -impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> { +impl UniversalRegionRelationsBuilder<'cx, 'tcx> { crate fn create(mut self) -> CreateResult<'tcx> { let unnormalized_input_output_tys = self .universal_regions diff --git a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs index 353c5a39b61b9..3954d62ad5c77 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs @@ -17,7 +17,7 @@ use syntax_pos::Span; use super::{Locations, TypeChecker}; -impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> TypeChecker<'a, 'tcx> { pub(super) fn equate_inputs_and_outputs( &mut self, body: &Body<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs index 240588b1c88d3..3b138bc126257 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs @@ -25,11 +25,11 @@ mod trace; /// /// N.B., this computation requires normalization; therefore, it must be /// performed before -pub(super) fn generate<'gcx, 'tcx>( - typeck: &mut TypeChecker<'_, 'gcx, 'tcx>, +pub(super) fn generate<'tcx>( + typeck: &mut TypeChecker<'_, 'tcx>, body: &Body<'tcx>, elements: &Rc, - flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'gcx, 'tcx>>, + flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'tcx>>, move_data: &MoveData<'tcx>, location_table: &LocationTable, ) { @@ -75,7 +75,7 @@ pub(super) fn generate<'gcx, 'tcx>( // some region `R` in its type where `R` is not known to outlive a free // region (i.e., where `R` may be valid for just a subset of the fn body). fn compute_live_locals( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, free_regions: &FxHashSet, body: &Body<'tcx>, ) -> Vec { diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index 828cb4cdcd04f..48e45e9452569 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -31,10 +31,10 @@ use std::rc::Rc; /// `dropck_outlives` result of the variable's type (in particular, /// this respects `#[may_dangle]` annotations). pub(super) fn trace( - typeck: &mut TypeChecker<'_, 'gcx, 'tcx>, + typeck: &mut TypeChecker<'_, 'tcx>, body: &Body<'tcx>, elements: &Rc, - flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'gcx, 'tcx>>, + flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'tcx>>, move_data: &MoveData<'tcx>, live_locals: Vec, location_table: &LocationTable, @@ -58,15 +58,14 @@ pub(super) fn trace( } /// Contextual state for the type-liveness generator. -struct LivenessContext<'me, 'typeck, 'flow, 'gcx, 'tcx> +struct LivenessContext<'me, 'typeck, 'flow, 'tcx> where 'typeck: 'me, 'flow: 'me, 'tcx: 'typeck + 'flow, - 'gcx: 'tcx, { /// Current type-checker, giving us our inference context etc. - typeck: &'me mut TypeChecker<'typeck, 'gcx, 'tcx>, + typeck: &'me mut TypeChecker<'typeck, 'tcx>, /// Defines the `PointIndex` mapping elements: &'me RegionValueElements, @@ -82,7 +81,7 @@ where /// Results of dataflow tracking which variables (and paths) have been /// initialized. - flow_inits: &'me mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'flow, 'gcx, 'tcx>>, + flow_inits: &'me mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'flow, 'tcx>>, /// Index indicating where each variable is assigned, used, or /// dropped. @@ -97,14 +96,13 @@ struct DropData<'tcx> { region_constraint_data: Option>>>, } -struct LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> +struct LivenessResults<'me, 'typeck, 'flow, 'tcx> where 'typeck: 'me, 'flow: 'me, 'tcx: 'typeck + 'flow, - 'gcx: 'tcx, { - cx: LivenessContext<'me, 'typeck, 'flow, 'gcx, 'tcx>, + cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>, /// Set of points that define the current local. defs: HybridBitSet, @@ -125,8 +123,8 @@ where stack: Vec, } -impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> { - fn new(cx: LivenessContext<'me, 'typeck, 'flow, 'gcx, 'tcx>) -> Self { +impl LivenessResults<'me, 'typeck, 'flow, 'tcx> { + fn new(cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>) -> Self { let num_points = cx.elements.num_points(); LivenessResults { cx, @@ -392,7 +390,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'gcx, 'tcx> { } } -impl LivenessContext<'_, '_, '_, '_, 'tcx> { +impl LivenessContext<'_, '_, '_, 'tcx> { /// Returns `true` if the local variable (or some part of it) is initialized in /// the terminator of `block`. We need to check this to determine if a /// DROP of some local variable will have an effect -- note that @@ -504,7 +502,7 @@ impl LivenessContext<'_, '_, '_, '_, 'tcx> { fn make_all_regions_live( elements: &RegionValueElements, - typeck: &mut TypeChecker<'_, '_, 'tcx>, + typeck: &mut TypeChecker<'_, 'tcx>, value: impl TypeFoldable<'tcx>, live_at: &HybridBitSet, location_table: &LocationTable, @@ -536,7 +534,7 @@ impl LivenessContext<'_, '_, '_, '_, 'tcx> { } fn compute_drop_data( - typeck: &mut TypeChecker<'_, 'gcx, 'tcx>, + typeck: &mut TypeChecker<'_, 'tcx>, dropped_ty: Ty<'tcx>, ) -> DropData<'tcx> { debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,); diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index bbfffc68b9692..77e0b54781c94 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -109,16 +109,16 @@ mod relate_tys; /// constraints for the regions in the types of variables /// - `flow_inits` -- results of a maybe-init dataflow analysis /// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis -pub(crate) fn type_check<'gcx, 'tcx>( - infcx: &InferCtxt<'_, 'gcx, 'tcx>, - param_env: ty::ParamEnv<'gcx>, +pub(crate) fn type_check<'tcx>( + infcx: &InferCtxt<'_, 'tcx>, + param_env: ty::ParamEnv<'tcx>, body: &Body<'tcx>, mir_def_id: DefId, universal_regions: &Rc>, location_table: &LocationTable, borrow_set: &BorrowSet<'tcx>, all_facts: &mut Option, - flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'gcx, 'tcx>>, + flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'tcx>>, move_data: &MoveData<'tcx>, elements: &Rc, ) -> MirTypeckResults<'tcx> { @@ -175,16 +175,16 @@ pub(crate) fn type_check<'gcx, 'tcx>( } } -fn type_check_internal<'a, 'gcx, 'tcx, R>( - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +fn type_check_internal<'a, 'tcx, R>( + infcx: &'a InferCtxt<'a, 'tcx>, mir_def_id: DefId, - param_env: ty::ParamEnv<'gcx>, + param_env: ty::ParamEnv<'tcx>, body: &'a Body<'tcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: ty::Region<'tcx>, borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>, universal_region_relations: &'a UniversalRegionRelations<'tcx>, - mut extra: impl FnMut(&mut TypeChecker<'a, 'gcx, 'tcx>) -> R, + mut extra: impl FnMut(&mut TypeChecker<'a, 'tcx>) -> R, ) -> R where { let mut checker = TypeChecker::new( infcx, @@ -235,7 +235,7 @@ fn translate_outlives_facts(cx: &mut BorrowCheckContext<'_, '_>) { } } -fn mirbug(tcx: TyCtxt<'_, '_>, span: Span, msg: &str) { +fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: &str) { // We sometimes see MIR failures (notably predicate failures) due to // the fact that we check rvalue sized predicates here. So use `delay_span_bug` // to avoid reporting bugs in those cases. @@ -251,15 +251,15 @@ enum FieldAccessError { /// The sanitize_XYZ methods here take an MIR object and compute its /// type, calling `span_mirbug` and returning an error type if there /// is a problem. -struct TypeVerifier<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> { - cx: &'a mut TypeChecker<'b, 'gcx, 'tcx>, +struct TypeVerifier<'a, 'b: 'a, 'tcx: 'b> { + cx: &'a mut TypeChecker<'b, 'tcx>, body: &'b Body<'tcx>, last_span: Span, mir_def_id: DefId, errors_reported: bool, } -impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> { +impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { fn visit_span(&mut self, span: &Span) { if !span.is_dummy() { self.last_span = *span; @@ -380,8 +380,8 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> { } } -impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { - fn new(cx: &'a mut TypeChecker<'b, 'gcx, 'tcx>, body: &'b Body<'tcx>) -> Self { +impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { + fn new(cx: &'a mut TypeChecker<'b, 'tcx>, body: &'b Body<'tcx>) -> Self { TypeVerifier { body, mir_def_id: cx.mir_def_id, @@ -391,7 +391,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.cx.infcx.tcx } @@ -455,7 +455,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { PlaceBase::Static(box Static { kind, ty: sty }) => { let sty = self.sanitize_type(place, sty); let check_err = - |verifier: &mut TypeVerifier<'a, 'b, 'gcx, 'tcx>, + |verifier: &mut TypeVerifier<'a, 'b, 'tcx>, place: &Place<'tcx>, ty, sty| { @@ -830,9 +830,9 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { /// constraints needed for it to be valid and well-typed. Along the /// way, it accrues region constraints -- these can later be used by /// NLL region checking. -struct TypeChecker<'a, 'gcx: 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, - param_env: ty::ParamEnv<'gcx>, +struct TypeChecker<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, last_span: Span, /// User type annotations are shared between the main MIR and the MIR of /// all of the promoted items. @@ -895,7 +895,7 @@ crate struct MirTypeckRegionConstraints<'tcx> { impl MirTypeckRegionConstraints<'tcx> { fn placeholder_region( &mut self, - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, placeholder: ty::PlaceholderRegion, ) -> ty::Region<'tcx> { let placeholder_index = self.placeholder_indices.insert(placeholder); @@ -977,12 +977,12 @@ impl Locations { } } -impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> TypeChecker<'a, 'tcx> { fn new( - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, + infcx: &'a InferCtxt<'a, 'tcx>, body: &'a Body<'tcx>, mir_def_id: DefId, - param_env: ty::ParamEnv<'gcx>, + param_env: ty::ParamEnv<'tcx>, region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: ty::Region<'tcx>, borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>, @@ -1078,7 +1078,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { &mut self, locations: Locations, category: ConstraintCategory, - op: impl type_op::TypeOp<'gcx, 'tcx, Output = R>, + op: impl type_op::TypeOp<'tcx, Output = R>, ) -> Fallible { let (r, opt_data) = op.fully_perform(self.infcx)?; @@ -1313,7 +1313,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { Ok(()) } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -2504,7 +2504,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { fn prove_closure_bounds( &mut self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, location: Location, @@ -2652,7 +2652,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { fn normalize(&mut self, value: T, location: impl NormalizeLocation) -> T where - T: type_op::normalize::Normalizable<'gcx, 'tcx> + Copy, + T: type_op::normalize::Normalizable<'tcx> + Copy, { debug!("normalize(value={:?}, location={:?})", value, location); let param_env = self.param_env; diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index 87544754f5de9..5ced356299fc9 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -17,7 +17,7 @@ use rustc::ty::{self, Ty}; /// N.B., the type `a` is permitted to have unresolved inference /// variables, but not the type `b`. pub(super) fn relate_types<'tcx>( - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, a: Ty<'tcx>, v: ty::Variance, b: Ty<'tcx>, @@ -34,8 +34,8 @@ pub(super) fn relate_types<'tcx>( Ok(()) } -struct NllTypeRelatingDelegate<'me, 'bccx: 'me, 'gcx: 'tcx, 'tcx: 'bccx> { - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, +struct NllTypeRelatingDelegate<'me, 'bccx: 'me, 'tcx: 'bccx> { + infcx: &'me InferCtxt<'me, 'tcx>, borrowck_context: Option<&'me mut BorrowCheckContext<'bccx, 'tcx>>, /// Where (and why) is this relation taking place? @@ -45,9 +45,9 @@ struct NllTypeRelatingDelegate<'me, 'bccx: 'me, 'gcx: 'tcx, 'tcx: 'bccx> { category: ConstraintCategory, } -impl NllTypeRelatingDelegate<'me, 'bccx, 'gcx, 'tcx> { +impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { fn new( - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + infcx: &'me InferCtxt<'me, 'tcx>, borrowck_context: Option<&'me mut BorrowCheckContext<'bccx, 'tcx>>, locations: Locations, category: ConstraintCategory, @@ -61,7 +61,7 @@ impl NllTypeRelatingDelegate<'me, 'bccx, 'gcx, 'tcx> { } } -impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> { +impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> { fn create_next_universe(&mut self) -> ty::UniverseIndex { self.infcx.create_next_universe() } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 6e64a6fae58d6..df0110ed3e39b 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -106,7 +106,7 @@ impl<'tcx> DefiningTy<'tcx> { /// not a closure or generator, there are no upvars, and hence it /// will be an empty list. The order of types in this list will /// match up with the upvar order in the HIR, typesystem, and MIR. - pub fn upvar_tys(self, tcx: TyCtxt<'_, 'tcx>) -> impl Iterator> + 'tcx { + pub fn upvar_tys(self, tcx: TyCtxt<'tcx>) -> impl Iterator> + 'tcx { match self { DefiningTy::Closure(def_id, substs) => Either::Left(substs.upvar_tys(def_id, tcx)), DefiningTy::Generator(def_id, substs, _) => { @@ -194,7 +194,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// signature. This will also compute the relationships that are /// known between those regions. pub fn new( - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, mir_def_id: DefId, param_env: ty::ParamEnv<'tcx>, ) -> Self { @@ -218,7 +218,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// `'1: '2`, then the caller would impose the constraint that /// `V[1]: V[2]`. pub fn closure_mapping( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, closure_substs: SubstsRef<'tcx>, expected_num_vars: usize, closure_base_def_id: DefId, @@ -305,7 +305,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// that this region imposes on others. The methods in this file /// handle the part about dumping the inference context internal /// state. - crate fn annotate(&self, tcx: TyCtxt<'_, 'tcx>, err: &mut DiagnosticBuilder<'_>) { + crate fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut DiagnosticBuilder<'_>) { match self.defining_ty { DefiningTy::Closure(def_id, substs) => { err.note(&format!( @@ -363,8 +363,8 @@ impl<'tcx> UniversalRegions<'tcx> { } } -struct UniversalRegionsBuilder<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +struct UniversalRegionsBuilder<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, mir_def_id: DefId, mir_hir_id: HirId, param_env: ty::ParamEnv<'tcx>, @@ -372,7 +372,7 @@ struct UniversalRegionsBuilder<'cx, 'gcx: 'tcx, 'tcx: 'cx> { const FR: NLLRegionVariableOrigin = NLLRegionVariableOrigin::FreeRegion; -impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { fn build(self) -> UniversalRegions<'tcx> { debug!("build(mir_def_id={:?})", self.mir_def_id); @@ -639,7 +639,7 @@ trait InferCtxtExt<'tcx> { ); } -impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> { fn replace_free_regions_with_nll_infer_vars( &self, origin: NLLRegionVariableOrigin, @@ -744,7 +744,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> { /// Replaces all free regions in `value` with region vids, as /// returned by `to_region_vid`. - pub fn fold_to_region_vids(&self, tcx: TyCtxt<'_, 'tcx>, value: &T) -> T + pub fn fold_to_region_vids(&self, tcx: TyCtxt<'tcx>, value: &T) -> T where T: TypeFoldable<'tcx>, { @@ -757,7 +757,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> { /// Iterates over the late-bound regions defined on fn_def_id and /// invokes `f` with the liberated form of each one. fn for_each_late_bound_region_defined_on<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, fn_def_id: DefId, mut f: impl FnMut(ty::Region<'tcx>), ) { diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index 978f12af9a1ad..aa2b177e54ed8 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -22,9 +22,9 @@ pub(super) enum Control { } /// Encapsulates the idea of iterating over every borrow that involves a particular path -pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S>( +pub(super) fn each_borrow_involving_path<'tcx, F, I, S>( s: &mut S, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, _location: Location, access_place: (AccessDepth, &Place<'tcx>), diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index 542cdf273695d..a8f28b64b4953 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -12,7 +12,7 @@ crate trait PlaceExt<'tcx> { /// for borrows of raw pointer dereferents as well as shared references. fn ignore_borrow( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, locals_state_at_exit: &LocalsStateAtExit, ) -> bool; @@ -21,7 +21,7 @@ crate trait PlaceExt<'tcx> { impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { fn ignore_borrow( &self, - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, locals_state_at_exit: &LocalsStateAtExit, ) -> bool { diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index c1cbfd9e3c0ba..64ca00defc9c0 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -24,8 +24,8 @@ crate enum PlaceConflictBias { /// Helper function for checking if places conflict with a mutable borrow and deep access depth. /// This is used to check for places conflicting outside of the borrow checking code (such as in /// dataflow). -crate fn places_conflict<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +crate fn places_conflict<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, borrow_place: &Place<'tcx>, access_place: &Place<'tcx>, @@ -46,8 +46,8 @@ crate fn places_conflict<'gcx, 'tcx>( /// access depth. The `bias` parameter is used to determine how the unknowable (comparing runtime /// array indices, for example) should be interpreted - this depends on what the caller wants in /// order to make the conservative choice and preserve soundness. -pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(super) fn borrow_conflicts_with_place<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, borrow_place: &Place<'tcx>, borrow_kind: BorrowKind, @@ -83,8 +83,8 @@ pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>( }) } -fn place_components_conflict<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn place_components_conflict<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, borrow_projections: (&PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>), borrow_kind: BorrowKind, @@ -298,8 +298,8 @@ fn place_components_conflict<'gcx, 'tcx>( // Given that the bases of `elem1` and `elem2` are always either equal // or disjoint (and have the same type!), return the overlap situation // between `elem1` and `elem2`. -fn place_base_conflict<'gcx: 'tcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn place_base_conflict<'tcx>( + tcx: TyCtxt<'tcx>, elem1: &PlaceBase<'tcx>, elem2: &PlaceBase<'tcx>, ) -> Overlap { @@ -365,8 +365,8 @@ fn place_base_conflict<'gcx: 'tcx, 'tcx>( // Given that the bases of `elem1` and `elem2` are always either equal // or disjoint (and have the same type!), return the overlap situation // between `elem1` and `elem2`. -fn place_projection_conflict<'gcx: 'tcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn place_projection_conflict<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, pi1: &Projection<'tcx>, pi2: &Projection<'tcx>, diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index dd4aac0330c1e..79045eea53cb1 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -37,9 +37,9 @@ impl<'tcx> IsPrefixOf<'tcx> for Place<'tcx> { } -pub(super) struct Prefixes<'cx, 'gcx: 'tcx, 'tcx: 'cx> { +pub(super) struct Prefixes<'cx, 'tcx: 'cx> { body: &'cx Body<'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, kind: PrefixSet, next: Option<&'cx Place<'tcx>>, } @@ -56,7 +56,7 @@ pub(super) enum PrefixSet { Supporting, } -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +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`. @@ -64,7 +64,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &self, place: &'cx Place<'tcx>, kind: PrefixSet, - ) -> Prefixes<'cx, 'gcx, 'tcx> { + ) -> Prefixes<'cx, 'tcx> { Prefixes { next: Some(place), kind, @@ -74,7 +74,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } -impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> { type Item = &'cx Place<'tcx>; fn next(&mut self) -> Option { let mut cursor = self.next?; diff --git a/src/librustc_mir/borrow_check/used_muts.rs b/src/librustc_mir/borrow_check/used_muts.rs index 7b2f662c7033d..e609ddbbe95ff 100644 --- a/src/librustc_mir/borrow_check/used_muts.rs +++ b/src/librustc_mir/borrow_check/used_muts.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashSet; use crate::borrow_check::MirBorrowckCtxt; -impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes /// of the `unused_mut` lint. /// @@ -46,13 +46,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// MIR visitor for collecting used mutable variables. /// The 'visit lifetime represents the duration of the MIR walk. -struct GatherUsedMutsVisitor<'visit, 'cx: 'visit, 'gcx: 'tcx, 'tcx: 'cx> { +struct GatherUsedMutsVisitor<'visit, 'cx: 'visit, 'tcx: 'cx> { temporary_used_locals: FxHashSet, never_initialized_mut_locals: &'visit mut FxHashSet, - mbcx: &'visit mut MirBorrowckCtxt<'cx, 'gcx, 'tcx>, + mbcx: &'visit mut MirBorrowckCtxt<'cx, 'tcx>, } -impl GatherUsedMutsVisitor<'_, '_, '_, '_> { +impl GatherUsedMutsVisitor<'_, '_, '_> { fn remove_never_initialized_mut_locals(&mut self, into: &Place<'_>) { // Remove any locals that we found were initialized from the // `never_initialized_mut_locals` set. At the end, the only remaining locals will @@ -65,7 +65,7 @@ impl GatherUsedMutsVisitor<'_, '_, '_, '_> { } } -impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'gcx, 'tcx> { +impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tcx> { fn visit_terminator_kind( &mut self, kind: &TerminatorKind<'tcx>, diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index e8b0def0a54ed..69de862362811 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -22,7 +22,7 @@ use syntax_pos::Span; use super::lints; /// Construct the MIR for a given `DefId`. -pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> { +pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Body<'tcx> { let id = tcx.hir().as_local_hir_id(def_id).unwrap(); // Figure out what primary body this item has. @@ -172,7 +172,7 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> { // BuildMir -- walks a crate, looking for fn items and methods to build MIR from fn liberated_closure_env_ty<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, closure_expr_id: hir::HirId, body_id: hir::BodyId, ) -> Ty<'tcx> { @@ -489,7 +489,7 @@ macro_rules! unpack { }; } -fn should_abort_on_panic<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, fn_def_id: DefId, abi: Abi) -> bool { +fn should_abort_on_panic<'tcx>(tcx: TyCtxt<'tcx>, fn_def_id: DefId, abi: Abi) -> bool { // Not callable from C, so we can safely unwind through these if abi == Abi::Rust || abi == Abi::RustCall { return false; } @@ -515,7 +515,7 @@ fn should_abort_on_panic<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, fn_def_id: DefId, abi: A /////////////////////////////////////////////////////////////////////////// /// the main entry point for building MIR for a function -struct ArgInfo<'gcx>(Ty<'gcx>, Option, Option<&'gcx hir::Pat>, Option); +struct ArgInfo<'tcx>(Ty<'tcx>, Option, Option<&'tcx hir::Pat>, Option); fn construct_fn<'a, 'tcx, A>( hir: Cx<'a, 'tcx>, diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index fb031f9e7ec16..7d05e7be26eb9 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -44,7 +44,7 @@ const DETECTOR_SNAPSHOT_PERIOD: isize = 256; /// of a function's generic parameter will require knowledge about the bounds on the generic /// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument. pub(crate) fn mk_eval_cx<'mir, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, span: Span, param_env: ty::ParamEnv<'tcx>, ) -> CompileTimeEvalContext<'mir, 'tcx> { @@ -53,7 +53,7 @@ pub(crate) fn mk_eval_cx<'mir, 'tcx>( } pub(crate) fn eval_promoted<'mir, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cid: GlobalId<'tcx>, body: &'mir mir::Body<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -394,7 +394,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, fn find_foreign_static( _def_id: DefId, - _tcx: TyCtxtAt<'tcx, 'tcx>, + _tcx: TyCtxtAt<'tcx>, ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { err!(ReadForeignStatic) } @@ -467,7 +467,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, // this function uses `unwrap` copiously, because an already validated constant must have valid // fields and can thus never fail outside of compiler bugs pub fn const_field<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, variant: Option, field: mir::Field, @@ -492,7 +492,7 @@ pub fn const_field<'tcx>( // this function uses `unwrap` copiously, because an already validated constant must have valid // fields and can thus never fail outside of compiler bugs pub fn const_variant_index<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, val: &'tcx ty::Const<'tcx>, ) -> VariantIdx { @@ -512,7 +512,7 @@ pub fn error_to_const_error<'mir, 'tcx>( } fn validate_and_turn_into_const<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, constant: RawConst<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { @@ -555,7 +555,7 @@ fn validate_and_turn_into_const<'tcx>( } pub fn const_eval_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { // see comment in const_eval_provider for what we're doing here @@ -579,7 +579,7 @@ pub fn const_eval_provider<'tcx>( } pub fn const_eval_raw_provider<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc::mir::interpret::ConstEvalRawResult<'tcx> { // Because the constant is computed twice (once per value of `Reveal`), we are at risk of diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index dc2893cb3303d..e8a32477f1c3f 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -46,8 +46,8 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>, /// is no need to maintain separate drop flags to track such state. // // FIXME: we have to do something for moving slice patterns. -fn place_contents_drop_state_cannot_differ<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn place_contents_drop_state_cannot_differ<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, place: &mir::Place<'tcx>, ) -> bool { @@ -74,8 +74,8 @@ fn place_contents_drop_state_cannot_differ<'gcx, 'tcx>( } } -pub(crate) fn on_lookup_result_bits<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn on_lookup_result_bits<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, move_data: &MoveData<'tcx>, lookup_result: LookupResult, @@ -93,8 +93,8 @@ pub(crate) fn on_lookup_result_bits<'gcx, 'tcx, F>( } } -pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn on_all_children_bits<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, move_data: &MoveData<'tcx>, move_path_index: MovePathIndex, @@ -102,8 +102,8 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>( ) where F: FnMut(MovePathIndex), { - fn is_terminal_path<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, + fn is_terminal_path<'tcx>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, move_data: &MoveData<'tcx>, path: MovePathIndex, @@ -112,8 +112,8 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>( tcx, body, &move_data.move_paths[path].place) } - fn on_all_children_bits<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, + fn on_all_children_bits<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, move_data: &MoveData<'tcx>, move_path_index: MovePathIndex, @@ -136,10 +136,10 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>( on_all_children_bits(tcx, body, move_data, move_path_index, &mut each_child); } -pub(crate) fn on_all_drop_children_bits<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn on_all_drop_children_bits<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, - ctxt: &MoveDataParamEnv<'gcx, 'tcx>, + ctxt: &MoveDataParamEnv<'tcx>, path: MovePathIndex, mut each_child: F, ) where @@ -160,10 +160,10 @@ pub(crate) fn on_all_drop_children_bits<'gcx, 'tcx, F>( }) } -pub(crate) fn drop_flag_effects_for_function_entry<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, - ctxt: &MoveDataParamEnv<'gcx, 'tcx>, + ctxt: &MoveDataParamEnv<'tcx>, mut callback: F, ) where F: FnMut(MovePathIndex, DropFlagState), @@ -178,10 +178,10 @@ pub(crate) fn drop_flag_effects_for_function_entry<'gcx, 'tcx, F>( } } -pub(crate) fn drop_flag_effects_for_location<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn drop_flag_effects_for_location<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, - ctxt: &MoveDataParamEnv<'gcx, 'tcx>, + ctxt: &MoveDataParamEnv<'tcx>, loc: Location, mut callback: F, ) where @@ -211,8 +211,8 @@ pub(crate) fn drop_flag_effects_for_location<'gcx, 'tcx, F>( ); } -pub(crate) fn for_location_inits<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn for_location_inits<'tcx, F>( + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, move_data: &MoveData<'tcx>, loc: Location, diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index ba38ef91ebe46..ba1a22c8d42eb 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -29,8 +29,8 @@ newtype_index! { /// `BorrowIndex`, and maps each such index to a `BorrowData` /// describing the borrow. These indexes are used for representing the /// borrows in compact bitvectors. -pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct Borrows<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, borrow_set: Rc>, @@ -133,9 +133,9 @@ fn precompute_borrows_out_of_scope<'tcx>( } } -impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Borrows<'a, 'tcx> { crate fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, nonlexical_regioncx: Rc>, borrow_set: &Rc>, @@ -234,7 +234,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'tcx> { type Idx = BorrowIndex; fn name() -> &'static str { "borrows" } fn bits_per_block(&self) -> usize { @@ -330,14 +330,14 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> BitSetOperator for Borrows<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitSetOperator for Borrows<'a, 'tcx> { #[inline] fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { inout_set.union(in_set) // "maybe" means we union effects of both preds } } -impl<'a, 'gcx, 'tcx> InitialFlow for Borrows<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InitialFlow for Borrows<'a, 'tcx> { #[inline] fn bottom_value() -> bool { false // bottom = nothing is reserved or activated yet diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 4148ffc465cf4..3e14949ffc946 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -63,23 +63,23 @@ pub(super) mod borrows; /// Similarly, at a given `drop` statement, the set-intersection /// between this data and `MaybeUninitializedPlaces` yields the set of /// places that would require a dynamic drop-flag at that statement. -pub struct MaybeInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct MaybeInitializedPlaces<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, } -impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, ) -> Self { MaybeInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } -impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> { fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data } } @@ -118,23 +118,23 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 'tcx /// Similarly, at a given `drop` statement, the set-intersection /// between this data and `MaybeInitializedPlaces` yields the set of /// places that would require a dynamic drop-flag at that statement. -pub struct MaybeUninitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct MaybeUninitializedPlaces<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, } -impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, ) -> Self { MaybeUninitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } -impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'tcx> { fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data } } @@ -172,23 +172,23 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, 't /// Similarly, at a given `drop` statement, the set-difference between /// this data and `MaybeInitializedPlaces` yields the set of places /// that would require a dynamic drop-flag at that statement. -pub struct DefinitelyInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct DefinitelyInitializedPlaces<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, } -impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, ) -> Self { DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } -impl<'a, 'gcx, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> { fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data } } @@ -221,28 +221,28 @@ impl<'a, 'gcx, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, ' /// c = S; // {a, b, c, d } /// } /// ``` -pub struct EverInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> { - tcx: TyCtxt<'gcx, 'tcx>, +pub struct EverInitializedPlaces<'a, 'tcx: 'a> { + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, } -impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx: 'a> EverInitializedPlaces<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>, + mdpe: &'a MoveDataParamEnv<'tcx>, ) -> Self { EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } -impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'tcx> { fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data } } -impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> { fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { @@ -253,7 +253,7 @@ impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> { fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { @@ -264,7 +264,7 @@ impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> { fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { @@ -275,7 +275,7 @@ impl<'a, 'gcx, 'tcx> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'tcx> { type Idx = MovePathIndex; fn name() -> &'static str { "maybe_init" } fn bits_per_block(&self) -> usize { @@ -328,7 +328,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 't } } -impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'tcx> { type Idx = MovePathIndex; fn name() -> &'static str { "maybe_uninit" } fn bits_per_block(&self) -> usize { @@ -386,7 +386,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, } } -impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> { type Idx = MovePathIndex; fn name() -> &'static str { "definite_init" } fn bits_per_block(&self) -> usize { @@ -442,7 +442,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'gc } } -impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'tcx> { type Idx = InitIndex; fn name() -> &'static str { "ever_init" } fn bits_per_block(&self) -> usize { @@ -519,28 +519,28 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc } } -impl<'a, 'gcx, 'tcx> BitSetOperator for MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitSetOperator for MaybeInitializedPlaces<'a, 'tcx> { #[inline] fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { inout_set.union(in_set) // "maybe" means we union effects of both preds } } -impl<'a, 'gcx, 'tcx> BitSetOperator for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitSetOperator for MaybeUninitializedPlaces<'a, 'tcx> { #[inline] fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { inout_set.union(in_set) // "maybe" means we union effects of both preds } } -impl<'a, 'gcx, 'tcx> BitSetOperator for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitSetOperator for DefinitelyInitializedPlaces<'a, 'tcx> { #[inline] fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { inout_set.intersect(in_set) // "definitely" means we intersect effects of both preds } } -impl<'a, 'gcx, 'tcx> BitSetOperator for EverInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> BitSetOperator for EverInitializedPlaces<'a, 'tcx> { #[inline] fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { inout_set.union(in_set) // inits from both preds are in scope @@ -557,28 +557,28 @@ impl<'a, 'gcx, 'tcx> BitSetOperator for EverInitializedPlaces<'a, 'gcx, 'tcx> { // propagating, or you start at all-ones and then use Intersect as // your merge when propagating. -impl<'a, 'gcx, 'tcx> InitialFlow for MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InitialFlow for MaybeInitializedPlaces<'a, 'tcx> { #[inline] fn bottom_value() -> bool { false // bottom = uninitialized } } -impl<'a, 'gcx, 'tcx> InitialFlow for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InitialFlow for MaybeUninitializedPlaces<'a, 'tcx> { #[inline] fn bottom_value() -> bool { false // bottom = initialized (start_block_effect counters this at outset) } } -impl<'a, 'gcx, 'tcx> InitialFlow for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InitialFlow for DefinitelyInitializedPlaces<'a, 'tcx> { #[inline] fn bottom_value() -> bool { true // bottom = initialized (start_block_effect counters this at outset) } } -impl<'a, 'gcx, 'tcx> InitialFlow for EverInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InitialFlow for EverInitializedPlaces<'a, 'tcx> { #[inline] fn bottom_value() -> bool { false // bottom = no initialized variables by default diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 10e46507d5a26..d8fbfa956a106 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -116,13 +116,13 @@ pub(crate) fn has_rustc_mir_with(attrs: &[ast::Attribute], name: Symbol) -> Opti return None; } -pub struct MoveDataParamEnv<'gcx, 'tcx> { +pub struct MoveDataParamEnv<'tcx> { pub(crate) move_data: MoveData<'tcx>, - pub(crate) param_env: ty::ParamEnv<'gcx>, + pub(crate) param_env: ty::ParamEnv<'tcx>, } -pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>( - tcx: TyCtxt<'gcx, 'tcx>, +pub(crate) fn do_dataflow<'a, 'tcx, BD, P>( + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, def_id: DefId, attributes: &[ast::Attribute], @@ -138,13 +138,13 @@ where flow_state.run(tcx, def_id, attributes, p) } -impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> +impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx>, { pub(crate) fn run

( self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, attributes: &[ast::Attribute], p: P, diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 3acbf2a2f6987..7c738b75e0722 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -12,15 +12,15 @@ use super::{LocationMap, MoveData, MovePath, MovePathLookup, MovePathIndex, Move use super::{MoveError, InitIndex, Init, InitLocation, LookupResult, InitKind}; use super::IllegalMoveOriginKind::*; -struct MoveDataBuilder<'a, 'gcx: 'tcx, 'tcx: 'a> { +struct MoveDataBuilder<'a, 'tcx: 'a> { body: &'a Body<'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, data: MoveData<'tcx>, errors: Vec<(Place<'tcx>, MoveError<'tcx>)>, } -impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { - fn new(body: &'a Body<'tcx>, tcx: TyCtxt<'gcx, 'tcx>) -> Self { +impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { + fn new(body: &'a Body<'tcx>, tcx: TyCtxt<'tcx>) -> Self { let mut move_paths = IndexVec::new(); let mut path_map = IndexVec::new(); let mut init_path_map = IndexVec::new(); @@ -83,7 +83,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { } } -impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { +impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { /// This creates a MovePath for a given place, returning an `MovePathError` /// if that place can't be moved from. /// @@ -178,7 +178,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { fn finalize( self ) -> Result, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> { @@ -202,9 +202,9 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { } } -pub(super) fn gather_moves<'gcx, 'tcx>( +pub(super) fn gather_moves<'tcx>( body: &Body<'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Result, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> { let mut builder = MoveDataBuilder::new(body, tcx); @@ -226,7 +226,7 @@ pub(super) fn gather_moves<'gcx, 'tcx>( builder.finalize() } -impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { fn gather_args(&mut self) { for arg in self.body.args_iter() { let path = self.data.rev_lookup.locals[arg]; @@ -253,12 +253,12 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> { } } -struct Gatherer<'b, 'a: 'b, 'gcx: 'tcx, 'tcx: 'a> { - builder: &'b mut MoveDataBuilder<'a, 'gcx, 'tcx>, +struct Gatherer<'b, 'a: 'b, 'tcx: 'a> { + builder: &'b mut MoveDataBuilder<'a, 'tcx>, loc: Location, } -impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { +impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { fn gather_statement(&mut self, stmt: &Statement<'tcx>) { match stmt.kind { StatementKind::Assign(ref place, ref rval) => { diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index 33b8134eec918..938450c63aefc 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -205,7 +205,7 @@ impl fmt::Debug for Init { } impl Init { - crate fn span<'gcx>(&self, body: &Body<'gcx>) -> Span { + crate fn span<'tcx>(&self, body: &Body<'tcx>) -> Span { match self.location { InitLocation::Argument(local) => body.local_decls[local].source_info.span, InitLocation::Statement(location) => body.source_info(location).span, @@ -305,10 +305,10 @@ impl<'tcx> MoveError<'tcx> { } } -impl<'gcx, 'tcx> MoveData<'tcx> { +impl<'tcx> MoveData<'tcx> { pub fn gather_moves( body: &Body<'tcx>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Result, MoveError<'tcx>)>)> { builder::gather_moves(body, tcx) } diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs index c03ca8e669eb4..2cd04631118d1 100644 --- a/src/librustc_mir/hair/constant.rs +++ b/src/librustc_mir/hair/constant.rs @@ -11,7 +11,7 @@ crate enum LitToConstError { crate fn lit_to_const<'tcx>( lit: &'tcx ast::LitKind, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, neg: bool, ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 434f538cc6de4..236d36c7661cf 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -22,8 +22,8 @@ use crate::hair::constant::{lit_to_const, LitToConstError}; #[derive(Clone)] pub struct Cx<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, - infcx: &'a InferCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, + infcx: &'a InferCtxt<'a, 'tcx>, pub root_lint_level: hir::HirId, pub param_env: ty::ParamEnv<'tcx>, @@ -52,7 +52,7 @@ pub struct Cx<'a, 'tcx: 'a> { } impl<'a, 'tcx> Cx<'a, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'tcx, '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); @@ -200,7 +200,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { ty.needs_drop(self.tcx.global_tcx(), param_env) } - pub fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + pub fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -218,7 +218,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { } impl UserAnnotatedTyHelpers<'tcx> for Cx<'_, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx() } diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 71a274f456a0e..1d7c450f69506 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -195,7 +195,7 @@ pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pattern<'tcx } struct LiteralExpander<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl LiteralExpander<'tcx> { @@ -350,7 +350,7 @@ impl<'p, 'tcx> FromIterator; 2]>> for Matrix<'p, 'tc } pub struct MatchCheckCtxt<'a, 'tcx: 'a> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, /// The module in which the match occurs. This is necessary for /// checking inhabited-ness of types because whether a type is (visibly) /// inhabited can depend on whether it was defined in the current module or @@ -365,7 +365,7 @@ pub struct MatchCheckCtxt<'a, 'tcx: 'a> { impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { pub fn create_and_enter( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, module: DefId, f: F, @@ -829,7 +829,7 @@ struct IntRange<'tcx> { } impl<'tcx> IntRange<'tcx> { - fn from_ctor(tcx: TyCtxt<'tcx, 'tcx>, ctor: &Constructor<'tcx>) -> Option> { + fn from_ctor(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>) -> Option> { // Floating-point ranges are permitted and we don't want // to consider them when constructing integer ranges. fn is_integral<'tcx>(ty: Ty<'tcx>) -> bool { @@ -867,7 +867,7 @@ impl<'tcx> IntRange<'tcx> { } } - fn from_pat(tcx: TyCtxt<'tcx, 'tcx>, mut pat: &Pattern<'tcx>) -> Option> { + fn from_pat(tcx: TyCtxt<'tcx>, mut pat: &Pattern<'tcx>) -> Option> { let range = loop { match pat.kind { box PatternKind::Constant { value } => break ConstantValue(value), @@ -887,7 +887,7 @@ impl<'tcx> IntRange<'tcx> { } // The return value of `signed_bias` should be XORed with an endpoint to encode/decode it. - fn signed_bias(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> u128 { + fn signed_bias(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> u128 { match ty.sty { ty::Int(ity) => { let bits = Integer::from_attr(&tcx, SignedInt(ity)).size().bits() as u128; @@ -899,7 +899,7 @@ impl<'tcx> IntRange<'tcx> { /// Converts a `RangeInclusive` to a `ConstantValue` or inclusive `ConstantRange`. fn range_to_ctor( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, r: RangeInclusive, ) -> Constructor<'tcx> { @@ -917,7 +917,7 @@ impl<'tcx> IntRange<'tcx> { /// by the values covered by `self`: i.e., `ranges \ self` (in set notation). fn subtract_from( self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ranges: Vec>, ) -> Vec> { let ranges = ranges.into_iter().filter_map(|r| { @@ -987,7 +987,7 @@ enum MissingCtors<'tcx> { // to compute the full set.) fn compute_missing_ctors<'a, 'tcx: 'a>( info: MissingCtorsInfo, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, all_ctors: &Vec>, used_ctors: &Vec>, ) -> MissingCtors<'tcx> { @@ -1423,7 +1423,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>, // meaning all other types will compare unequal and thus equal patterns often do not cause the // second pattern to lint about unreachable match arms. fn slice_pat_covered_by_const<'tcx>( - tcx: TyCtxt<'tcx, '_>, + tcx: TyCtxt<'tcx>, _span: Span, const_val: &'tcx ty::Const<'tcx>, prefix: &[Pattern<'tcx>], @@ -1475,7 +1475,7 @@ fn slice_pat_covered_by_const<'tcx>( // Whether to evaluate a constructor using exhaustive integer matching. This is true if the // constructor is a range or constant with an integer type. -fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx, 'tcx>, ctor: &Constructor<'tcx>) -> bool { +fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>) -> bool { let ty = match ctor { ConstantValue(value) => value.ty, ConstantRange(_, _, ty, _) => ty, @@ -1521,7 +1521,7 @@ fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx, 'tcx>, ctor: &Constructor<' /// between every pair of boundary points. (This essentially sums up to performing the intuitive /// merging operation depicted above.) fn split_grouped_constructors<'p, 'a: 'p, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ctors: Vec>, &Matrix(ref m): &Matrix<'p, 'tcx>, ty: Ty<'tcx>, @@ -1599,7 +1599,7 @@ fn split_grouped_constructors<'p, 'a: 'p, 'tcx: 'a>( /// Checks whether there exists any shared value in either `ctor` or `pat` by intersecting them. fn constructor_intersects_pattern<'p, 'a: 'p, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>, pat: &'p Pattern<'tcx>, ) -> Option; 2]>> { @@ -1627,7 +1627,7 @@ fn constructor_intersects_pattern<'p, 'a: 'p, 'tcx: 'a>( } fn constructor_covered_by_range<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>, pat: &Pattern<'tcx>, ) -> Result { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 0a60ed19b9a47..e7fd308070c9b 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -26,7 +26,7 @@ use std::slice; use syntax::ptr::P; use syntax_pos::{Span, DUMMY_SP, MultiSpan}; -pub(crate) fn check_match<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +pub(crate) fn check_match<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { let body_id = if let Some(id) = tcx.hir().as_local_hir_id(def_id) { tcx.hir().body_owned_by(id) } else { @@ -48,7 +48,7 @@ fn create_e0004<'a>(sess: &'a Session, sp: Span, error_message: String) -> Diagn } struct MatchVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body_owner: DefId, tables: &'a ty::TypeckTables<'tcx>, param_env: ty::ParamEnv<'tcx>, diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 566acccc5a0e6..e0e14852c577a 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -327,7 +327,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } pub struct PatternContext<'a, 'tcx: 'a> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub param_env: ty::ParamEnv<'tcx>, pub tables: &'a ty::TypeckTables<'tcx>, pub substs: SubstsRef<'tcx>, @@ -336,7 +336,7 @@ pub struct PatternContext<'a, 'tcx: 'a> { impl<'a, 'tcx> Pattern<'tcx> { pub fn from_hir( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>, pat: &'tcx hir::Pat, @@ -354,7 +354,7 @@ impl<'a, 'tcx> Pattern<'tcx> { impl<'a, 'tcx> PatternContext<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>, tables: &'a ty::TypeckTables<'tcx>, ) -> Self { @@ -1059,7 +1059,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } impl UserAnnotatedTyHelpers<'tcx> for PatternContext<'_, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -1247,7 +1247,7 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { } pub fn compare_const_vals<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>, ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, diff --git a/src/librustc_mir/hair/util.rs b/src/librustc_mir/hair/util.rs index 5eadb581ba500..4e014855df5e0 100644 --- a/src/librustc_mir/hair/util.rs +++ b/src/librustc_mir/hair/util.rs @@ -2,7 +2,7 @@ use rustc::hir; use rustc::ty::{self, CanonicalUserType, TyCtxt, UserType}; crate trait UserAnnotatedTyHelpers<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx>; + fn tcx(&self) -> TyCtxt<'tcx>; fn tables(&self) -> &ty::TypeckTables<'tcx>; diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 45c1f71e95043..f985c6000b5b2 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -31,7 +31,7 @@ pub struct InterpretCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> { pub machine: M, /// The results of the type checker, from rustc. - pub tcx: TyCtxtAt<'tcx, 'tcx>, + pub tcx: TyCtxtAt<'tcx>, /// Bounds in scope for polymorphic evaluations. pub(crate) param_env: ty::ParamEnv<'tcx>, @@ -170,7 +170,7 @@ where M: Machine<'mir, 'tcx>, { #[inline] - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { *self.tcx } } @@ -196,7 +196,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpretCx<'mir, 'tcx, M> } impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> { - pub fn new(tcx: TyCtxtAt<'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, machine: M) -> Self { + pub fn new(tcx: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>, machine: M) -> Self { InterpretCx { machine, tcx, diff --git a/src/librustc_mir/interpret/intrinsics/type_name.rs b/src/librustc_mir/interpret/intrinsics/type_name.rs index a44a20adbca0e..c92d501140f26 100644 --- a/src/librustc_mir/interpret/intrinsics/type_name.rs +++ b/src/librustc_mir/interpret/intrinsics/type_name.rs @@ -10,11 +10,11 @@ use std::fmt::Write; use rustc::mir::interpret::{Allocation, ConstValue}; struct AbsolutePathPrinter<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, path: String, } -impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { +impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { type Error = std::fmt::Error; type Path = Self; @@ -23,7 +23,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { type DynExistential = Self; type Const = Self; - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -167,7 +167,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { } } } -impl PrettyPrinter<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { +impl PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> { fn region_should_not_be_omitted( &self, _region: ty::Region<'_>, @@ -178,7 +178,7 @@ impl PrettyPrinter<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { mut self, mut elems: impl Iterator, ) -> Result - where T: Print<'tcx, 'tcx, Self, Output = Self, Error = Self::Error> + where T: Print<'tcx, Self, Output = Self, Error = Self::Error> { if let Some(first) = elems.next() { self = first.print(self)?; @@ -212,7 +212,7 @@ impl Write for AbsolutePathPrinter<'_> { /// Produces an absolute path representation of the given type. See also the documentation on /// `std::any::type_name` -pub fn type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx ty::Const<'tcx> { +pub fn type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> &'tcx ty::Const<'tcx> { let alloc = alloc_type_name(tcx, ty); tcx.mk_const(ty::Const { val: ConstValue::Slice { @@ -225,7 +225,7 @@ pub fn type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx ty::Const } /// Directly returns an `Allocation` containing an absolute path representation of the given type. -pub(super) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx Allocation { +pub(super) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> &'tcx Allocation { let path = AbsolutePathPrinter { tcx, path: String::new() }.print_type(ty).unwrap().path; let alloc = Allocation::from_byte_aligned_bytes(path.into_bytes()); tcx.intern_const_alloc(alloc) diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 97e65733bd409..58ee952879d9d 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -137,7 +137,7 @@ pub trait Machine<'mir, 'tcx>: Sized { /// This allocation will then be fed to `tag_allocation` to initialize the "extra" state. fn find_foreign_static( def_id: DefId, - tcx: TyCtxtAt<'tcx, 'tcx>, + tcx: TyCtxtAt<'tcx>, ) -> InterpResult<'tcx, Cow<'tcx, Allocation>>; /// Called for all binary operations on integer(-like) types when one operand is a pointer diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index d9f522ab12f24..e724c377df73d 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -66,7 +66,7 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> { pub extra: M::MemoryExtra, /// Lets us implement `HasDataLayout`, which is awfully convenient. - pub(super) tcx: TyCtxtAt<'tcx, 'tcx>, + pub(super) tcx: TyCtxtAt<'tcx>, } impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for Memory<'mir, 'tcx, M> { @@ -94,7 +94,7 @@ where } impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { - pub fn new(tcx: TyCtxtAt<'tcx, 'tcx>) -> Self { + pub fn new(tcx: TyCtxtAt<'tcx>) -> Self { Memory { alloc_map: M::MemoryMap::default(), dead_alloc_map: FxHashMap::default(), @@ -324,7 +324,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { /// another static), those inner references only exist in "resolved" form. fn get_static_alloc( id: AllocId, - tcx: TyCtxtAt<'tcx, 'tcx>, + tcx: TyCtxtAt<'tcx>, memory_extra: &M::MemoryExtra, ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { let alloc = tcx.alloc_map.lock().get(id); diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index f52fa0cd48272..0032e84b266c8 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -46,7 +46,7 @@ pub(crate) struct InfiniteLoopDetector<'mir, 'tcx> { impl<'mir, 'tcx> InfiniteLoopDetector<'mir, 'tcx> { pub fn observe_and_analyze( &mut self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, span: Span, memory: &Memory<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>, stack: &[Frame<'mir, 'tcx>], diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 621fb8a4b22b3..55151a9b33eb9 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -7,7 +7,7 @@ use rustc::mir::{self, Body, TerminatorKind}; use rustc::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt}; use rustc::ty::subst::InternalSubsts; -pub fn check(tcx: TyCtxt<'tcx, 'tcx>, body: &Body<'tcx>, def_id: DefId) { +pub fn check(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get_by_hir_id(hir_id)) { @@ -16,7 +16,7 @@ pub fn check(tcx: TyCtxt<'tcx, 'tcx>, body: &Body<'tcx>, def_id: DefId) { } fn check_fn_for_unconditional_recursion( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, fn_kind: FnKind<'_>, body: &Body<'tcx>, def_id: DefId, diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 0b7dbfeacda59..aa86a1c110490 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -282,7 +282,7 @@ impl<'tcx> InliningMap<'tcx> { } pub fn collect_crate_mono_items<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode, ) -> (FxHashSet>, InliningMap<'tcx>) { let roots = time(tcx.sess, "collecting roots", || { @@ -316,7 +316,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, 'tcx>, + tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode, ) -> Vec> { debug!("Collecting roots"); @@ -349,7 +349,7 @@ fn collect_roots<'tcx>( // Collect all monomorphized items reachable from `starting_point` fn collect_items_rec<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, starting_point: MonoItem<'tcx>, visited: MTRef<'_, MTLock>>>, recursion_depths: &mut DefIdMap, @@ -417,7 +417,7 @@ fn collect_items_rec<'a, 'tcx: 'a>( } fn record_accesses<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, caller: MonoItem<'tcx>, callees: &[MonoItem<'tcx>], inlining_map: MTRef<'_, MTLock>>, @@ -435,7 +435,7 @@ fn record_accesses<'tcx>( } fn check_recursion_limit<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, recursion_depths: &mut DefIdMap, ) -> (DefId, usize) { @@ -469,7 +469,7 @@ fn check_recursion_limit<'tcx>( (def_id, recursion_depth) } -fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, instance: Instance<'tcx>) { +fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) { let type_length = instance.substs.types().flat_map(|ty| ty.walk()).count(); let const_length = instance.substs.consts().flat_map(|ct| ct.ty.walk()).count(); debug!(" => type length={}, const length={}", type_length, const_length); @@ -519,7 +519,7 @@ fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, instance: Instance<'tc } struct MirNeighborCollector<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a mir::Body<'tcx>, output: &'a mut Vec>, param_substs: SubstsRef<'tcx>, @@ -684,7 +684,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { } fn visit_drop_use<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, is_direct_call: bool, output: &mut Vec>, @@ -694,7 +694,7 @@ fn visit_drop_use<'tcx>( } fn visit_fn_use<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, is_direct_call: bool, output: &mut Vec>, @@ -709,7 +709,7 @@ fn visit_fn_use<'tcx>( } fn visit_instance_use<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>, is_direct_call: bool, output: &mut Vec>, @@ -748,7 +748,7 @@ fn visit_instance_use<'tcx>( // Returns true if we should codegen an instance in the local crate. // Returns false if we can just link to the upstream crate and therefore don't // need a mono item. -fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, instance: &Instance<'tcx>) -> bool { +fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) -> bool { let def_id = match instance.def { ty::InstanceDef::Item(def_id) => def_id, ty::InstanceDef::VtableShim(..) | @@ -783,7 +783,7 @@ fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, instance: &Instanc return true; fn is_available_upstream_generic<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, ) -> bool { @@ -849,7 +849,7 @@ fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, instance: &Instanc /// Finally, there is also the case of custom unsizing coercions, e.g., for /// smart pointers such as `Rc` and `Arc`. fn find_vtable_types_for_unsizing<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source_ty: Ty<'tcx>, target_ty: Ty<'tcx>, ) -> (Ty<'tcx>, Ty<'tcx>) { @@ -923,7 +923,7 @@ fn create_fn_mono_item<'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> { /// Creates a `MonoItem` for each method that is referenced by the vtable for /// the given trait/impl pair. fn create_mono_items_for_vtable_methods<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_ty: Ty<'tcx>, impl_ty: Ty<'tcx>, output: &mut Vec>, @@ -959,7 +959,7 @@ fn create_mono_items_for_vtable_methods<'tcx>( //=----------------------------------------------------------------------------- struct RootCollector<'a, 'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode, output: &'a mut Vec>, entry_fn: Option<(DefId, EntryFnType)>, @@ -1117,13 +1117,13 @@ impl RootCollector<'_, 'v> { } } -fn item_requires_monomorphization<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn item_requires_monomorphization<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { let generics = tcx.generics_of(def_id); generics.requires_monomorphization(tcx) } fn create_mono_items_for_default_impls<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item: &'tcx hir::Item, output: &mut Vec>, ) { @@ -1189,7 +1189,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, 'tcx>, + tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut Vec>, ) { @@ -1220,7 +1220,7 @@ fn collect_miri<'tcx>( /// Scan the MIR in order to find function calls, closures, and drop-glue fn collect_neighbours<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, output: &mut Vec>, ) { @@ -1250,7 +1250,7 @@ fn collect_neighbours<'tcx>( } } -fn def_id_to_string<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> String { +fn def_id_to_string<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> String { let mut output = String::new(); let printer = DefPathBasedNames::new(tcx, false, false); printer.push_def_path(def_id, &mut output); @@ -1258,7 +1258,7 @@ fn def_id_to_string<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> String { } fn collect_const<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, constant: &'tcx ty::Const<'tcx>, param_substs: SubstsRef<'tcx>, output: &mut Vec>, diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 1450534af5e56..595e599c1150a 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -48,7 +48,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { } } - fn symbol_name(&self, tcx: TyCtxt<'tcx, 'tcx>) -> ty::SymbolName { + fn symbol_name(&self, tcx: TyCtxt<'tcx>) -> ty::SymbolName { match *self.as_mono_item() { MonoItem::Fn(instance) => tcx.symbol_name(instance), MonoItem::Static(def_id) => { @@ -62,7 +62,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { } } } - fn instantiation_mode(&self, tcx: TyCtxt<'tcx, 'tcx>) -> InstantiationMode { + fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode { let inline_in_all_cgus = tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| { tcx.sess.opts.optimize != OptLevel::No @@ -106,7 +106,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { } } - fn explicit_linkage(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Option { + fn explicit_linkage(&self, tcx: TyCtxt<'tcx>) -> Option { let def_id = match *self.as_mono_item() { MonoItem::Fn(ref instance) => instance.def_id(), MonoItem::Static(def_id) => def_id, @@ -142,7 +142,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { /// Similarly, if a vtable method has such a signature, and therefore can't /// be used, we can just not emit it and have a placeholder (a null pointer, /// which will never be accessed) in its place. - fn is_instantiable(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool { + fn is_instantiable(&self, tcx: TyCtxt<'tcx>) -> bool { debug!("is_instantiable({:?})", self); let (def_id, substs) = match *self.as_mono_item() { MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs), @@ -154,7 +154,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { tcx.substitute_normalize_and_test_predicates((def_id, &substs)) } - fn to_string(&self, tcx: TyCtxt<'tcx, 'tcx>, debug: bool) -> String { + fn to_string(&self, tcx: TyCtxt<'tcx>, debug: bool) -> String { return match *self.as_mono_item() { MonoItem::Fn(instance) => { to_string_internal(tcx, "fn ", instance, debug) @@ -169,7 +169,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { }; fn to_string_internal<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, prefix: &str, instance: Instance<'tcx>, debug: bool, @@ -182,7 +182,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug { } } - fn local_span(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Option { + fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option { match *self.as_mono_item() { MonoItem::Fn(Instance { def, .. }) => { tcx.hir().as_local_hir_id(def.def_id()) diff --git a/src/librustc_mir/monomorphize/mod.rs b/src/librustc_mir/monomorphize/mod.rs index 667c0d7b29c5e..b36cf49ef1e45 100644 --- a/src/librustc_mir/monomorphize/mod.rs +++ b/src/librustc_mir/monomorphize/mod.rs @@ -6,7 +6,7 @@ pub mod collector; pub mod partitioning; pub fn custom_coerce_unsize_info<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source_ty: Ty<'tcx>, target_ty: Ty<'tcx>, ) -> CustomCoerceUnsized { diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index f05ccc45c9c4c..4abc067438231 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -121,12 +121,12 @@ pub enum PartitioningStrategy { } // Anything we can't find a proper codegen unit for goes into this. -fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_>) -> InternedString { +fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_>) -> InternedString { name_builder.build_cgu_name(LOCAL_CRATE, &["fallback"], Some("cgu")) } pub fn partition<'tcx, I>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mono_items: I, strategy: PartitioningStrategy, inlining_map: &InliningMap<'tcx>, @@ -204,7 +204,7 @@ struct PostInliningPartitioning<'tcx> { } fn place_root_mono_items<'tcx, I>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mono_items: I, ) -> PreInliningPartitioning<'tcx> where @@ -280,7 +280,7 @@ where } fn mono_item_linkage_and_visibility( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mono_item: &MonoItem<'tcx>, can_be_internalized: &mut bool, export_generics: bool, @@ -298,7 +298,7 @@ fn mono_item_linkage_and_visibility( } fn mono_item_visibility( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mono_item: &MonoItem<'tcx>, can_be_internalized: &mut bool, export_generics: bool, @@ -443,7 +443,7 @@ fn mono_item_visibility( } } -fn default_visibility(tcx: TyCtxt<'_, '_>, id: DefId, is_generic: bool) -> Visibility { +fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibility { if !tcx.sess.target.target.options.default_hidden_visibility { return Visibility::Default } @@ -468,7 +468,7 @@ fn default_visibility(tcx: TyCtxt<'_, '_>, id: DefId, is_generic: bool) -> Visib } fn merge_codegen_units<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, initial_partitioning: &mut PreInliningPartitioning<'tcx>, target_cgu_count: usize, ) { @@ -592,7 +592,7 @@ fn place_inlined_mono_items<'tcx>(initial_partitioning: PreInliningPartitioning< } fn internalize_symbols<'tcx>( - _tcx: TyCtxt<'tcx, 'tcx>, + _tcx: TyCtxt<'tcx>, partitioning: &mut PostInliningPartitioning<'tcx>, inlining_map: &InliningMap<'tcx>, ) { @@ -659,7 +659,7 @@ fn internalize_symbols<'tcx>( } fn characteristic_def_id_of_mono_item<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mono_item: MonoItem<'tcx>, ) -> Option { match mono_item { @@ -708,8 +708,8 @@ fn characteristic_def_id_of_mono_item<'tcx>( type CguNameCache = FxHashMap<(DefId, bool), InternedString>; fn compute_codegen_unit_name( - tcx: TyCtxt<'_, '_>, - name_builder: &mut CodegenUnitNameBuilder<'_, '_>, + tcx: TyCtxt<'_>, + name_builder: &mut CodegenUnitNameBuilder<'_>, def_id: DefId, volatile: bool, cache: &mut CguNameCache, @@ -763,13 +763,13 @@ fn compute_codegen_unit_name( } fn numbered_codegen_unit_name( - name_builder: &mut CodegenUnitNameBuilder<'_, '_>, + name_builder: &mut CodegenUnitNameBuilder<'_>, index: usize, ) -> InternedString { name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(index)) } -fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'tcx, 'tcx>, label: &str, cgus: I) +fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'tcx>, label: &str, cgus: I) where I: Iterator>, 'tcx: 'a + 'b, @@ -797,7 +797,7 @@ where } #[inline(never)] // give this a place in the profiler -fn assert_symbols_are_distinct<'a, 'tcx: 'a, I>(tcx: TyCtxt<'tcx, 'tcx>, mono_items: I) +fn assert_symbols_are_distinct<'a, 'tcx: 'a, I>(tcx: TyCtxt<'tcx>, mono_items: I) where I: Iterator>, { @@ -842,7 +842,7 @@ where } fn collect_and_partition_mono_items<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cnum: CrateNum, ) -> (Arc, Arc>>>) { assert_eq!(cnum, LOCAL_CRATE); diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index ea11901672a23..4b3b1f9d4dabc 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -26,7 +26,7 @@ pub fn provide(providers: &mut Providers<'_>) { providers.mir_shims = make_shim; } -fn make_shim<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> { +fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> { debug!("make_shim({:?})", instance); let mut result = match instance { @@ -164,7 +164,7 @@ fn local_decls_for_sig<'tcx>(sig: &ty::FnSig<'tcx>, span: Span) } fn build_drop_shim<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>, ) -> Body<'tcx> { @@ -255,7 +255,7 @@ fn build_drop_shim<'tcx>( pub struct DropShimElaborator<'a, 'tcx: 'a> { pub body: &'a Body<'tcx>, pub patch: MirPatch<'tcx>, - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub param_env: ty::ParamEnv<'tcx>, } @@ -270,7 +270,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> { fn patch(&mut self) -> &mut MirPatch<'tcx> { &mut self.patch } fn body(&self) -> &'a Body<'tcx> { self.body } - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } fn param_env(&self) -> ty::ParamEnv<'tcx> { self.param_env } @@ -305,7 +305,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> { } /// Builds a `Clone::clone` shim for `self_ty`. Here, `def_id` is `Clone::clone`. -fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -> Body<'tcx> { +fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -> Body<'tcx> { debug!("build_clone_shim(def_id={:?})", def_id); let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty); @@ -336,7 +336,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, self_ty: Ty<'t } struct CloneShimBuilder<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, local_decls: IndexVec>, blocks: IndexVec>, @@ -345,7 +345,7 @@ struct CloneShimBuilder<'tcx> { } impl CloneShimBuilder<'tcx> { - fn new(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -> Self { + fn new(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -> Self { // we must subst the self_ty because it's // otherwise going to be TySelf and we can't index // or access fields of a Place of type TySelf. @@ -685,7 +685,7 @@ impl CloneShimBuilder<'tcx> { /// If `untuple_args` is a vec of types, the second argument of the /// function will be untupled as these types. fn build_call_shim<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, rcvr_adjustment: Adjustment, call_kind: CallKind, @@ -835,7 +835,7 @@ fn build_call_shim<'tcx>( body } -pub fn build_adt_ctor<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ctor_id: DefId) -> &'tcx Body<'tcx> { +pub fn build_adt_ctor<'tcx>(tcx: TyCtxt<'tcx>, ctor_id: DefId) -> &'tcx Body<'tcx> { debug_assert!(tcx.is_constructor(ctor_id)); let span = tcx.hir().span_if_local(ctor_id) diff --git a/src/librustc_mir/transform/add_call_guards.rs b/src/librustc_mir/transform/add_call_guards.rs index 56c824167e185..892b99f94e868 100644 --- a/src/librustc_mir/transform/add_call_guards.rs +++ b/src/librustc_mir/transform/add_call_guards.rs @@ -33,7 +33,7 @@ pub use self::AddCallGuards::*; impl MirPass for AddCallGuards { fn run_pass<'tcx>( &self, - _tcx: TyCtxt<'tcx, 'tcx>, + _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { 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 673b13a22d3d7..12e7ab2189695 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -40,14 +40,14 @@ use crate::util; pub struct AddMovesForPackedDrops; impl MirPass for AddMovesForPackedDrops { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { debug!("add_moves_for_packed_drops({:?} @ {:?})", src, body.span); add_moves_for_packed_drops(tcx, body, src.def_id()); } } pub fn add_moves_for_packed_drops<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, def_id: DefId, ) { @@ -56,7 +56,7 @@ pub fn add_moves_for_packed_drops<'tcx>( } fn add_moves_for_packed_drops_patch<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, ) -> MirPatch<'tcx> { @@ -86,7 +86,7 @@ fn add_moves_for_packed_drops_patch<'tcx>( } fn add_move_for_packed_drop<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, patch: &mut MirPatch<'tcx>, terminator: &Terminator<'tcx>, diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index a67fce9028a32..c478eaf573153 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -48,7 +48,7 @@ fn is_stable<'tcx>( /// Determine whether this type may have a reference in it, recursing below compound types but /// not below references. -fn may_have_reference<'gcx, 'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'gcx, 'tcx>) -> bool { +fn may_have_reference<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool { match ty.sty { // Primitive types that are not references ty::Bool | ty::Char | @@ -76,7 +76,7 @@ fn may_have_reference<'gcx, 'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'gcx, 'tcx>) -> bool impl MirPass for AddRetag { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 0adb37b8722a3..80a31efd0d3fe 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -25,7 +25,7 @@ pub struct UnsafetyChecker<'a, 'tcx: 'a> { source_scope_local_data: &'a IndexVec, violations: Vec, source_info: SourceInfo, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, /// Mark an `unsafe` block as used, so we don't lint it. used_unsafe: FxHashSet, @@ -38,7 +38,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { min_const_fn: bool, body: &'a Body<'tcx>, source_scope_local_data: &'a IndexVec, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> Self { // sanity check @@ -481,7 +481,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> { } fn check_unused_unsafe<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, used_unsafe: &FxHashSet, unsafe_blocks: &'a mut Vec<(hir::HirId, bool)>, @@ -506,7 +506,7 @@ fn check_unused_unsafe<'a, 'tcx>( hir::intravisit::Visitor::visit_body(&mut visitor, body); } -fn unsafety_check_result<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> UnsafetyCheckResult { +fn unsafety_check_result<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> UnsafetyCheckResult { debug!("unsafety_violations({:?})", def_id); // N.B., this borrow is valid because all the consumers of @@ -545,7 +545,7 @@ fn unsafety_check_result<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Unsafe } } -fn unsafe_derive_on_repr_packed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +fn unsafe_derive_on_repr_packed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { let lint_hir_id = tcx.hir().as_local_hir_id(def_id).unwrap_or_else(|| bug!("checking unsafety for non-local def id {:?}", def_id)); @@ -566,7 +566,7 @@ fn unsafe_derive_on_repr_packed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { /// Returns the `HirId` for an enclosing scope that is also `unsafe`. fn is_enclosed( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, used_unsafe: &FxHashSet, id: hir::HirId, ) -> Option<(String, hir::HirId)> { @@ -590,7 +590,7 @@ fn is_enclosed( } } -fn report_unused_unsafe(tcx: TyCtxt<'_, '_>, used_unsafe: &FxHashSet, id: hir::HirId) { +fn report_unused_unsafe(tcx: TyCtxt<'_>, used_unsafe: &FxHashSet, id: hir::HirId) { let span = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(id)); let msg = "unnecessary `unsafe` block"; let mut db = tcx.struct_span_lint_hir(UNUSED_UNSAFE, id, span, msg); @@ -602,7 +602,7 @@ fn report_unused_unsafe(tcx: TyCtxt<'_, '_>, used_unsafe: &FxHashSet db.emit(); } -fn builtin_derive_def_id<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option { +fn builtin_derive_def_id<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option { debug!("builtin_derive_def_id({:?})", def_id); if let Some(impl_def_id) = tcx.impl_of_method(def_id) { if tcx.has_attr(impl_def_id, sym::automatically_derived) { @@ -618,7 +618,7 @@ fn builtin_derive_def_id<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option } } -pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { debug!("check_unsafety({:?})", def_id); // closures are handled by their parent fn. diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index fb4fdf73a9389..83040a71cbadd 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -29,7 +29,7 @@ pub struct DeleteNonCodegenStatements; impl MirPass for CleanupNonCodegenStatements { fn run_pass<'tcx>( &self, - _tcx: TyCtxt<'tcx, 'tcx>, + _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index dfc2e7e7c9d86..fc4efdf8f39aa 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -33,7 +33,7 @@ pub struct ConstProp; impl MirPass for ConstProp { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>, ) { @@ -87,7 +87,7 @@ type Const<'tcx> = OpTy<'tcx>; /// Finds optimization opportunities on the MIR. struct ConstPropagator<'mir, 'tcx> { ecx: InterpretCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, places: IndexVec>>, can_const_prop: IndexVec, @@ -115,7 +115,7 @@ impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> { impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> { #[inline] - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } } @@ -123,7 +123,7 @@ impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> { impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { fn new( body: &mut Body<'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, ) -> ConstPropagator<'mir, 'tcx> { let param_env = tcx.param_env(source.def_id()); @@ -602,7 +602,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } fn type_size_of<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> Option { diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index aeb3ed5a2eca8..e84308fd947a4 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -32,7 +32,7 @@ pub struct CopyPropagation; impl MirPass for CopyPropagation { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index 87704f1221656..41943d86332dd 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -8,7 +8,7 @@ pub struct Deaggregator; impl MirPass for Deaggregator { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/dump_mir.rs b/src/librustc_mir/transform/dump_mir.rs index 96be0e6f6a9d7..375a917763817 100644 --- a/src/librustc_mir/transform/dump_mir.rs +++ b/src/librustc_mir/transform/dump_mir.rs @@ -20,7 +20,7 @@ impl MirPass for Marker { fn run_pass<'tcx>( &self, - _tcx: TyCtxt<'tcx, 'tcx>, + _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>, ) { @@ -39,7 +39,7 @@ impl fmt::Display for Disambiguator { } pub fn on_mir_pass<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, pass_num: &dyn fmt::Display, pass_name: &str, source: MirSource<'tcx>, @@ -57,7 +57,7 @@ pub fn on_mir_pass<'tcx>( } } -pub fn emit_mir<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, outputs: &OutputFilenames) -> io::Result<()> { +pub fn emit_mir<'tcx>(tcx: TyCtxt<'tcx>, outputs: &OutputFilenames) -> io::Result<()> { let path = outputs.path(OutputType::Mir); let mut f = File::create(&path)?; mir_util::write_mir_pretty(tcx, None, &mut f)?; diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index bf6237fa91acf..584a2fd1341d3 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -21,7 +21,7 @@ use syntax_pos::Span; pub struct ElaborateDrops; impl MirPass for ElaborateDrops { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { debug!("elaborate_drops({:?} @ {:?})", src, body.span); let def_id = src.def_id(); @@ -74,10 +74,10 @@ impl MirPass for ElaborateDrops { /// to not be reachable, because they are `drop` terminators /// that can't drop anything. fn find_dead_unwinds<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: hir::def_id::DefId, - env: &MoveDataParamEnv<'tcx, 'tcx>, + env: &MoveDataParamEnv<'tcx>, ) -> BitSet { debug!("find_dead_unwinds({:?})", body.span); // We only need to do this pass once, because unwind edges can only @@ -138,9 +138,9 @@ struct InitializationData { impl InitializationData { fn apply_location<'tcx>( &mut self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, - env: &MoveDataParamEnv<'tcx, 'tcx>, + env: &MoveDataParamEnv<'tcx>, loc: Location, ) { drop_flag_effects_for_location(tcx, body, env, loc, |path, df| { @@ -186,7 +186,7 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> { self.ctxt.body } - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.ctxt.tcx } @@ -286,11 +286,11 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> { } struct ElaborateDropsCtxt<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, - env: &'a MoveDataParamEnv<'tcx, 'tcx>, - flow_inits: DataflowResults<'tcx, MaybeInitializedPlaces<'a, 'tcx, 'tcx>>, - flow_uninits: DataflowResults<'tcx, MaybeUninitializedPlaces<'a, 'tcx, 'tcx>>, + env: &'a MoveDataParamEnv<'tcx>, + flow_inits: DataflowResults<'tcx, MaybeInitializedPlaces<'a, 'tcx>>, + flow_uninits: DataflowResults<'tcx, MaybeUninitializedPlaces<'a, 'tcx>>, drop_flags: FxHashMap, patch: MirPatch<'tcx>, } diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index 39d5770ee9a09..5a29ea21a7a04 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -11,11 +11,11 @@ use rustc::mir::visit::{MutVisitor, TyContext}; use crate::transform::{MirPass, MirSource}; struct EraseRegionsVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl EraseRegionsVisitor<'tcx> { - pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Self { + pub fn new(tcx: TyCtxt<'tcx>) -> Self { EraseRegionsVisitor { tcx, } @@ -50,7 +50,7 @@ impl MutVisitor<'tcx> for EraseRegionsVisitor<'tcx> { pub struct EraseRegions; impl MirPass for EraseRegions { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { EraseRegionsVisitor::new(tcx).visit_body(body); } } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index d369fec8c1e67..761bbb53800c7 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -169,7 +169,7 @@ struct SuspensionPoint { } struct TransformVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, state_adt_ref: &'tcx AdtDef, state_substs: SubstsRef<'tcx>, @@ -311,7 +311,7 @@ impl MutVisitor<'tcx> for TransformVisitor<'tcx> { } fn make_generator_state_argument_indirect<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, body: &mut Body<'tcx>, ) { @@ -336,7 +336,7 @@ fn make_generator_state_argument_indirect<'tcx>( DerefArgVisitor.visit_body(body); } -fn make_generator_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &mut Body<'tcx>) { +fn make_generator_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let ref_gen_ty = body.local_decls.raw[1].ty; let pin_did = tcx.lang_items().pin_type().unwrap(); @@ -415,7 +415,7 @@ struct LivenessInfo { } fn locals_live_across_suspend_points( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, source: MirSource<'tcx>, movable: bool, @@ -678,7 +678,7 @@ impl<'body, 'tcx: 'body, 's> StorageConflictVisitor<'body, 'tcx, 's> { } fn compute_layout<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, upvars: &Vec>, interior: Ty<'tcx>, @@ -800,7 +800,7 @@ fn insert_switch<'tcx>( } } -fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, body: &mut Body<'tcx>) { +fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, body: &mut Body<'tcx>) { use crate::util::elaborate_drops::{elaborate_drop, Unwind}; use crate::util::patch::MirPatch; use crate::shim::DropShimElaborator; @@ -850,7 +850,7 @@ fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, body: } fn create_generator_drop_shim<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, transform: &TransformVisitor<'tcx>, def_id: DefId, source: MirSource<'tcx>, @@ -942,7 +942,7 @@ fn insert_term_block<'tcx>(body: &mut Body<'tcx>, kind: TerminatorKind<'tcx>) -> } fn insert_panic_block<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, message: AssertMessage<'tcx>, ) -> BasicBlock { @@ -974,7 +974,7 @@ fn insert_panic_block<'tcx>( } fn create_generator_resume_function<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, transform: TransformVisitor<'tcx>, def_id: DefId, source: MirSource<'tcx>, @@ -1094,7 +1094,7 @@ where impl MirPass for StateTransform { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 55c035f2858a2..687993a2c5286 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -40,7 +40,7 @@ struct CallSite<'tcx> { impl MirPass for Inline { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>, ) { @@ -51,7 +51,7 @@ impl MirPass for Inline { } struct Inliner<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, } @@ -634,7 +634,7 @@ impl Inliner<'tcx> { } fn type_size_of<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> Option { diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 2194b780ab967..c338e1ebe936f 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -12,7 +12,7 @@ use crate::transform::{MirPass, MirSource}; pub struct InstCombine; impl MirPass for InstCombine { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { // We only run when optimizing MIR (at any level). if tcx.sess.opts.debugging_opts.mir_opt_level == 0 { return @@ -62,12 +62,12 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> { /// Finds optimization opportunities on the MIR. struct OptimizationFinder<'b, 'tcx> { body: &'b Body<'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, optimizations: OptimizationList<'tcx>, } impl OptimizationFinder<'b, 'tcx> { - fn new(body: &'b Body<'tcx>, tcx: TyCtxt<'tcx, 'tcx>) -> OptimizationFinder<'b, 'tcx> { + fn new(body: &'b Body<'tcx>, tcx: TyCtxt<'tcx>) -> OptimizationFinder<'b, 'tcx> { OptimizationFinder { body, tcx, diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index 34a982f72761f..5c8e712cc2523 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -12,7 +12,7 @@ pub struct Lower128Bit; impl MirPass for Lower128Bit { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { @@ -27,7 +27,7 @@ impl MirPass for Lower128Bit { } impl Lower128Bit { - fn lower_128bit_ops<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, body: &mut Body<'tcx>) { + fn lower_128bit_ops<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let mut new_blocks = Vec::new(); let cur_len = body.basic_blocks().len(); @@ -128,7 +128,7 @@ fn check_lang_item_type<'tcx, D>( lhs: &Operand<'tcx>, rhs: &Operand<'tcx>, local_decls: &D, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> DefId where D: HasLocalDecls<'tcx>, @@ -148,7 +148,7 @@ where fn lower_to<'tcx, D>( statement: &Statement<'tcx>, local_decls: &D, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option<(LangItem, RhsKind)> where D: HasLocalDecls<'tcx>, @@ -179,7 +179,7 @@ enum RhsKind { } impl RhsKind { - fn ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Option> { + fn ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Option> { match *self { RhsKind::Unchanged => None, RhsKind::ForceU128 => Some(tcx.types.u128), diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 6f369acec6440..3caee069a7f82 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -50,13 +50,13 @@ pub(crate) fn provide(providers: &mut Providers<'_>) { }; } -fn is_mir_available<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn is_mir_available<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { tcx.mir_keys(def_id.krate).contains(&def_id) } /// Finds the full set of `DefId`s within the current crate that have /// MIR associated with them. -fn mir_keys<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, krate: CrateNum) -> &'tcx DefIdSet { +fn mir_keys<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx DefIdSet { assert_eq!(krate, LOCAL_CRATE); let mut set = DefIdSet::default(); @@ -67,7 +67,7 @@ fn mir_keys<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, krate: CrateNum) -> &'tcx DefIdSet { // Additionally, tuple struct/variant constructors have MIR, but // they don't have a BodyId, so we need to build them separately. struct GatherCtors<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, set: &'a mut DefIdSet, } impl<'a, 'tcx> Visitor<'tcx> for GatherCtors<'a, 'tcx> { @@ -94,7 +94,7 @@ fn mir_keys<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, krate: CrateNum) -> &'tcx DefIdSet { tcx.arena.alloc(set) } -fn mir_built<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal> { +fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal> { let mir = build::mir_build(tcx, def_id); tcx.alloc_steal_mir(mir) } @@ -143,14 +143,14 @@ pub trait MirPass { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>, ); } pub fn run_passes( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, instance: InstanceDef<'tcx>, mir_phase: MirPhase, @@ -197,7 +197,7 @@ pub fn run_passes( } } -fn mir_const<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal> { +fn mir_const<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal> { // Unsafety check uses the raw mir, so make sure it is run let _ = tcx.unsafety_check_result(def_id); @@ -211,7 +211,7 @@ fn mir_const<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal, def_id: DefId) -> &'tcx Steal> { +fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal> { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind_by_hir_id(hir_id) { // Ensure that we compute the `mir_const_qualif` for constants at @@ -228,7 +228,7 @@ fn mir_validated(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx Body<'tcx> { +fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Body<'tcx> { if tcx.is_constructor(def_id) { // There's no reason to run all of the MIR passes on constructors when // we can just output the MIR we want directly. This also saves const diff --git a/src/librustc_mir/transform/no_landing_pads.rs b/src/librustc_mir/transform/no_landing_pads.rs index 6f3f2269d44d2..841db80fc7dbb 100644 --- a/src/librustc_mir/transform/no_landing_pads.rs +++ b/src/librustc_mir/transform/no_landing_pads.rs @@ -9,12 +9,12 @@ use crate::transform::{MirPass, MirSource}; pub struct NoLandingPads; impl MirPass for NoLandingPads { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { no_landing_pads(tcx, body) } } -pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &mut Body<'tcx>) { +pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { if tcx.sess.no_landing_pads() { NoLandingPads.visit_body(body); } diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index f3d05f065ce73..84d3f8f4c462b 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -148,7 +148,7 @@ pub fn collect_temps(body: &Body<'_>, } struct Promoter<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, source: &'a mut Body<'tcx>, promoted: Body<'tcx>, temps: &'a mut IndexVec, @@ -371,7 +371,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> { pub fn promote_candidates<'tcx>( body: &mut Body<'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, mut temps: IndexVec, candidates: Vec, ) { diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 125411a717d1e..c9fac3bbe2596 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -124,7 +124,7 @@ impl IndexMut for PerQualif { } struct ConstCx<'a, 'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, mode: Mode, body: &'a Body<'tcx>, @@ -652,7 +652,7 @@ impl Deref for Checker<'a, 'tcx> { } impl<'a, 'tcx> Checker<'a, 'tcx> { - fn new(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, body: &'a Body<'tcx>, mode: Mode) -> Self { + fn new(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>, mode: Mode) -> Self { assert!(def_id.is_local()); let mut rpo = traversal::reverse_postorder(body); let temps = promote_consts::collect_temps(body, &mut rpo); @@ -1468,7 +1468,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn mir_const_qualif<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> (u8, &'tcx BitSet) { +fn mir_const_qualif<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> (u8, &'tcx BitSet) { // N.B., this `borrow()` is guaranteed to be valid (i.e., the value // cannot yet be stolen), because `mir_validated()`, which steals // from `mir_const(), forces this query to execute before @@ -1486,7 +1486,7 @@ fn mir_const_qualif<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> (u8, &'tcx pub struct QualifyAndPromoteConstants; impl MirPass for QualifyAndPromoteConstants { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { // There's not really any point in promoting errorful MIR. if body.return_ty().references_error() { tcx.sess.delay_span_bug(body.span, "QualifyAndPromoteConstants: MIR had errors"); @@ -1659,7 +1659,7 @@ impl MirPass for QualifyAndPromoteConstants { } } -fn args_required_const(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Option> { +fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { let attrs = tcx.get_attrs(def_id); let attr = attrs.iter().find(|a| a.check_name(sym::rustc_args_required_const))?; let mut ret = FxHashSet::default(); diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index 7f5afb2394a46..9781300966ab9 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -8,7 +8,7 @@ use syntax_pos::Span; type McfResult = Result<(), (Span, Cow<'static, str>)>; -pub fn is_min_const_fn(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, body: &'a Body<'tcx>) -> McfResult { +pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -> McfResult { let mut current = def_id; loop { let predicates = tcx.predicates_of(current); @@ -75,7 +75,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, body: &'a Body<'t Ok(()) } -fn check_ty(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>, span: Span, fn_def_id: DefId) -> McfResult { +fn check_ty(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span, fn_def_id: DefId) -> McfResult { for ty in ty.walk() { match ty.sty { ty::Ref(_, _, hir::Mutability::MutMutable) => return Err(( @@ -120,7 +120,7 @@ fn check_ty(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>, span: Span, fn_def_id: DefId) } fn check_rvalue( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, rvalue: &Rvalue<'tcx>, span: Span, @@ -200,7 +200,7 @@ fn check_rvalue( } fn check_statement( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, statement: &Statement<'tcx>, ) -> McfResult { @@ -270,7 +270,7 @@ fn check_place( } fn check_terminator( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, terminator: &Terminator<'tcx>, ) -> McfResult { @@ -366,7 +366,7 @@ fn check_terminator( /// for being called from stable `const fn`s (`min_const_fn`). /// /// Adding more intrinsics requires sign-off from @rust-lang/lang. -fn is_intrinsic_whitelisted(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn is_intrinsic_whitelisted(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { match &tcx.item_name(def_id).as_str()[..] { | "size_of" | "min_align_of" diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index 1a23fdce050b0..69f1ef096fb85 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -9,7 +9,7 @@ use crate::util::patch::MirPatch; /// code for these. pub struct RemoveNoopLandingPads; -pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &mut Body<'tcx>) { +pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { if tcx.sess.no_landing_pads() { return } @@ -21,7 +21,7 @@ pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &mut Body<' impl MirPass for RemoveNoopLandingPads { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 1d57f5e27164d..c4601229653cf 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -25,7 +25,7 @@ use crate::dataflow::has_rustc_mir_with; pub struct SanityCheck; impl MirPass for SanityCheck { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) { let def_id = src.def_id(); if !tcx.has_attr(def_id, sym::rustc_mir) { debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id)); @@ -84,7 +84,7 @@ impl MirPass for SanityCheck { /// expression form above, then that emits an error as well, but those /// errors are not intended to be used for unit tests.) pub fn sanity_check_via_rustc_peek<'tcx, O>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, _attributes: &[ast::Attribute], @@ -103,7 +103,7 @@ pub fn sanity_check_via_rustc_peek<'tcx, O>( } fn each_block<'tcx, O>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, body: &Body<'tcx>, results: &DataflowResults<'tcx, O>, bb: mir::BasicBlock, @@ -218,7 +218,7 @@ fn each_block<'tcx, O>( } fn is_rustc_peek<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, terminator: &'a Option>, ) -> Option<(&'a [mir::Operand<'tcx>], Span)> { if let Some(mir::Terminator { ref kind, source_info, .. }) = *terminator { diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index ba3a00517ffb0..e5774692e93e0 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -59,7 +59,7 @@ impl MirPass for SimplifyCfg { fn run_pass<'tcx>( &self, - _tcx: TyCtxt<'tcx, 'tcx>, + _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { @@ -298,7 +298,7 @@ pub fn remove_dead_blocks(body: &mut Body<'_>) { pub struct SimplifyLocals; impl MirPass for SimplifyLocals { - fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { let mut marker = DeclMarker { locals: BitSet::new_empty(body.local_decls.len()) }; marker.visit_body(body); // Return pointer and arguments are always live diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index a1c3fec32fcf1..228a060f6119f 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -21,7 +21,7 @@ impl MirPass for SimplifyBranches { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 4e961d80f4c82..08b10a5d33741 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -39,7 +39,7 @@ pub struct UniformArrayMoveOut; impl MirPass for UniformArrayMoveOut { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { @@ -55,7 +55,7 @@ impl MirPass for UniformArrayMoveOut { struct UniformArrayMoveOutVisitor<'a, 'tcx: 'a> { body: &'a Body<'tcx>, patch: &'a mut MirPatch<'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> { @@ -166,7 +166,7 @@ pub struct RestoreSubsliceArrayMoveOut; impl MirPass for RestoreSubsliceArrayMoveOut { fn run_pass<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>, ) { diff --git a/src/librustc_mir/util/alignment.rs b/src/librustc_mir/util/alignment.rs index b23ce28f30120..6245d9c208b69 100644 --- a/src/librustc_mir/util/alignment.rs +++ b/src/librustc_mir/util/alignment.rs @@ -5,7 +5,7 @@ use rustc::mir::*; /// than its containing struct (because it is within a packed /// struct). pub fn is_disaligned<'tcx, L>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, local_decls: &L, param_env: ty::ParamEnv<'tcx>, place: &Place<'tcx>, @@ -34,7 +34,7 @@ where } } -fn is_within_packed<'tcx, L>(tcx: TyCtxt<'tcx, 'tcx>, local_decls: &L, place: &Place<'tcx>) -> bool +fn is_within_packed<'tcx, L>(tcx: TyCtxt<'tcx>, local_decls: &L, place: &Place<'tcx>) -> bool where L: HasLocalDecls<'tcx>, { diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 551cccf3d7d7f..f1aaa857dd3f3 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -788,7 +788,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { } } -impl BorrowckErrors<'tcx> for TyCtxt<'gcx, 'tcx> { +impl BorrowckErrors<'tcx> for TyCtxt<'tcx> { fn struct_span_err_with_code>( self, sp: S, diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index f6cc1033b777c..0d7d6b4094ad4 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -75,7 +75,7 @@ pub trait DropElaborator<'a, 'tcx: 'a>: fmt::Debug { fn patch(&mut self) -> &mut MirPatch<'tcx>; fn body(&self) -> &'a Body<'tcx>; - fn tcx(&self) -> TyCtxt<'tcx, 'tcx>; + fn tcx(&self) -> TyCtxt<'tcx>; fn param_env(&self) -> ty::ParamEnv<'tcx>; fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle; @@ -126,7 +126,7 @@ where place.ty(self.elaborator.body(), self.tcx()).ty } - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.elaborator.tcx() } diff --git a/src/librustc_mir/util/graphviz.rs b/src/librustc_mir/util/graphviz.rs index 0746434c184b5..7b154a9d46fa3 100644 --- a/src/librustc_mir/util/graphviz.rs +++ b/src/librustc_mir/util/graphviz.rs @@ -9,7 +9,7 @@ use super::pretty::dump_mir_def_ids; /// Write a graphviz DOT graph of a list of MIRs. pub fn write_mir_graphviz<'tcx, W>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, single: Option, w: &mut W, ) -> io::Result<()> @@ -35,7 +35,7 @@ pub fn graphviz_safe_def_name(def_id: DefId) -> String { /// Write a graphviz DOT graph of the MIR. pub fn write_mir_fn_graphviz<'tcx, W>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, body: &Body<'_>, w: &mut W, @@ -138,8 +138,8 @@ fn write_edges(source: BasicBlock, body: &Body<'_>, w: &mut W) -> io:: /// Write the graphviz DOT label for the overall graph. This is essentially a block of text that /// will appear below the graph, showing the type of the `fn` this MIR represents and the types of /// all the variables and temporaries. -fn write_graph_label<'gcx, 'tcx, W: Write>( - tcx: TyCtxt<'gcx, 'tcx>, +fn write_graph_label<'tcx, W: Write>( + tcx: TyCtxt<'tcx>, def_id: DefId, body: &Body<'_>, w: &mut W, diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 39840432c690e..cf0fc09472b6c 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -255,7 +255,7 @@ fn block<'tcx>( } pub fn dump_mir<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, pass_name: &str, source: MirSource<'tcx>, body: &Body<'tcx>, @@ -272,7 +272,7 @@ pub fn dump_mir<'tcx>( } fn dump_matched_mir_node<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, pass_name: &str, node_path: &str, source: MirSource<'tcx>, @@ -295,7 +295,7 @@ fn dump_matched_mir_node<'tcx>( } pub fn write_mir_fn<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &Body<'tcx>, w: &mut dyn Write, diff --git a/src/librustc_mir/util/mod.rs b/src/librustc_mir/util/mod.rs index 3563ad43051dc..36c5a1a2f59e5 100644 --- a/src/librustc_mir/util/mod.rs +++ b/src/librustc_mir/util/mod.rs @@ -21,8 +21,8 @@ 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<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +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(); diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 8bf491acc26d9..2c2643e9b42e8 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -62,8 +62,8 @@ pub enum PassWhere { /// or `typeck` appears in the name. /// - `foo & nll | bar & typeck` == match if `foo` and `nll` both appear in the name /// or `typeck` and `bar` both appear in the name. -pub fn dump_mir<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn dump_mir<'tcx, F>( + tcx: TyCtxt<'tcx>, pass_num: Option<&dyn Display>, pass_name: &str, disambiguator: &dyn Display, @@ -93,8 +93,8 @@ pub fn dump_mir<'gcx, 'tcx, F>( ); } -pub fn dump_enabled<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn dump_enabled<'tcx>( + tcx: TyCtxt<'tcx>, pass_name: &str, source: MirSource<'tcx>, ) -> bool { @@ -117,8 +117,8 @@ pub fn dump_enabled<'gcx, 'tcx>( // `def_path_str()` would otherwise trigger `type_of`, and this can // run while we are already attempting to evaluate `type_of`. -fn dump_matched_mir_node<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +fn dump_matched_mir_node<'tcx, F>( + tcx: TyCtxt<'tcx>, pass_num: Option<&dyn Display>, pass_name: &str, node_path: &str, @@ -158,7 +158,7 @@ fn dump_matched_mir_node<'gcx, 'tcx, F>( /// Also used by other bits of code (e.g., NLL inference) that dump /// graphviz data or other things. fn dump_path( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, extension: &str, pass_num: Option<&dyn Display>, pass_name: &str, @@ -225,7 +225,7 @@ fn dump_path( /// bits of code (e.g., NLL inference) that dump graphviz data or /// other things, and hence takes the extension as an argument. pub(crate) fn create_dump_file( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, extension: &str, pass_num: Option<&dyn Display>, pass_name: &str, @@ -240,8 +240,8 @@ pub(crate) fn create_dump_file( } /// Write out a human-readable textual representation for the given MIR. -pub fn write_mir_pretty<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn write_mir_pretty<'tcx>( + tcx: TyCtxt<'tcx>, single: Option, w: &mut dyn Write, ) -> io::Result<()> { @@ -279,8 +279,8 @@ pub fn write_mir_pretty<'gcx, 'tcx>( Ok(()) } -pub fn write_mir_fn<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn write_mir_fn<'tcx, F>( + tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &Body<'tcx>, extra_data: &mut F, @@ -303,8 +303,8 @@ where } /// Write out a human-readable textual representation for the given basic block. -pub fn write_basic_block<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn write_basic_block<'tcx, F>( + tcx: TyCtxt<'tcx>, block: BasicBlock, body: &Body<'tcx>, extra_data: &mut F, @@ -370,13 +370,13 @@ 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<'gcx, 'tcx, F>( - tcx: TyCtxt<'gcx, 'tcx>, +fn write_extra<'tcx, F>( + tcx: TyCtxt<'tcx>, write: &mut dyn Write, mut visit_op: F, ) -> io::Result<()> where - F: FnMut(&mut ExtraComments<'gcx, 'tcx>), + F: FnMut(&mut ExtraComments<'tcx>), { let mut extra_comments = ExtraComments { _tcx: tcx, @@ -389,12 +389,12 @@ where Ok(()) } -struct ExtraComments<'gcx, 'tcx> { - _tcx: TyCtxt<'gcx, 'tcx>, // don't need it now, but bet we will soon +struct ExtraComments<'tcx> { + _tcx: TyCtxt<'tcx>, // don't need it now, but bet we will soon comments: Vec, } -impl ExtraComments<'gcx, 'tcx> { +impl ExtraComments<'tcx> { fn push(&mut self, lines: &str) { for line in lines.split('\n') { self.comments.push(line.to_string()); @@ -402,7 +402,7 @@ impl ExtraComments<'gcx, 'tcx> { } } -impl Visitor<'tcx> for ExtraComments<'gcx, 'tcx> { +impl Visitor<'tcx> for ExtraComments<'tcx> { fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) { self.super_constant(constant, location); let Constant { span, ty, user_ty, literal } = constant; @@ -453,7 +453,7 @@ impl Visitor<'tcx> for ExtraComments<'gcx, 'tcx> { } } -fn comment(tcx: TyCtxt<'_, '_>, SourceInfo { span, scope }: SourceInfo) -> String { +fn comment(tcx: TyCtxt<'_>, SourceInfo { span, scope }: SourceInfo) -> String { format!( "scope {} at {}", scope.index(), @@ -463,7 +463,7 @@ fn comment(tcx: TyCtxt<'_, '_>, SourceInfo { span, scope }: SourceInfo) -> Strin /// Prints local variables in a scope tree. fn write_scope_tree( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, body: &Body<'_>, scope_tree: &FxHashMap>, w: &mut dyn Write, @@ -538,8 +538,8 @@ fn write_scope_tree( /// Write out a human-readable textual representation of the MIR's `fn` type and the types of its /// local variables (both user-defined bindings and compiler temporaries). -pub fn write_mir_intro<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn write_mir_intro<'tcx>( + tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &Body<'_>, w: &mut dyn Write, @@ -570,7 +570,7 @@ pub fn write_mir_intro<'gcx, 'tcx>( } fn write_mir_sig( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, src: MirSource<'tcx>, body: &Body<'_>, w: &mut dyn Write, @@ -642,7 +642,7 @@ fn write_user_type_annotations(body: &Body<'_>, w: &mut dyn Write) -> io::Result Ok(()) } -pub fn dump_mir_def_ids(tcx: TyCtxt<'_, '_>, single: Option) -> Vec { +pub fn dump_mir_def_ids(tcx: TyCtxt<'_>, single: Option) -> Vec { if let Some(i) = single { vec![i] } else { diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index 5ed731347bb13..8f790d1328572 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -14,7 +14,7 @@ use rustc::ty::TyCtxt; use syntax::ast::Attribute; use syntax::symbol::sym; -pub fn test_layout<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn test_layout<'tcx>(tcx: TyCtxt<'tcx>) { if tcx.features().rustc_attrs { // if the `rustc_attrs` feature is not enabled, don't bother testing layout tcx.hir() @@ -24,7 +24,7 @@ pub fn test_layout<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } struct VarianceTest<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> { @@ -105,7 +105,7 @@ impl VarianceTest<'tcx> { } struct UnwrapLayoutCx<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, } @@ -119,7 +119,7 @@ impl LayoutOf for UnwrapLayoutCx<'tcx> { } impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } } diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 4c361e975b2e0..efa4bd65c0bcd 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -45,7 +45,7 @@ struct CheckLoopVisitor<'a, 'hir: 'a> { cx: Context, } -fn check_mod_loops<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_loops<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckLoopVisitor { sess: &tcx.sess, hir_map: &tcx.hir(), diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 845290467b91e..7230b69468126 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -39,7 +39,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn const_is_rvalue_promotable_to_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn const_is_rvalue_promotable_to_static<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { assert!(def_id.is_local()); let hir_id = tcx.hir().as_local_hir_id(def_id) @@ -48,7 +48,7 @@ fn const_is_rvalue_promotable_to_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: D tcx.rvalue_promotable_map(def_id).contains(&body_id.hir_id.local_id) } -fn rvalue_promotable_map<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ItemLocalSet { +fn rvalue_promotable_map<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ItemLocalSet { let outer_def_id = tcx.closure_base_def_id(def_id); if outer_def_id != def_id { return tcx.rvalue_promotable_map(outer_def_id); @@ -75,7 +75,7 @@ fn rvalue_promotable_map<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx } struct CheckCrateVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, in_fn: bool, in_static: bool, mut_rvalue_borrows: HirIdSet, @@ -120,9 +120,9 @@ impl BitOr for Promotability { } } -impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { +impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { // Returns true iff all the values of the type are promotable. - fn type_promotability(&mut self, ty: Ty<'gcx>) -> Promotability { + fn type_promotability(&mut self, ty: Ty<'tcx>) -> Promotability { debug!("type_promotability({})", ty); if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) && @@ -593,7 +593,7 @@ fn check_adjustments<'a, 'tcx>( Promotable } -impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> { +impl<'a, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'tcx> { fn consume(&mut self, _consume_id: hir::HirId, _consume_span: Span, diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index f5cb04c743250..d3ac597160fd6 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -30,11 +30,11 @@ impl<'v> ItemLikeVisitor<'v> for RegistrarFinder { } /// Finds the function marked with `#[plugin_registrar]`, if any. -pub fn find_plugin_registrar<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Option { +pub fn find_plugin_registrar<'tcx>(tcx: TyCtxt<'tcx>) -> Option { tcx.plugin_registrar_fn(LOCAL_CRATE) } -fn plugin_registrar_fn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Option { +fn plugin_registrar_fn<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Option { assert_eq!(cnum, LOCAL_CRATE); let mut finder = RegistrarFinder { registrars: Vec::new() }; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index a2da014c912d1..5610982c01e98 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -49,7 +49,7 @@ mod error_codes; /// manually. Second, it doesn't visit some type components like signatures of fn types, or traits /// in `impl Trait`, see individual comments in `DefIdVisitorSkeleton::visit_ty`. trait DefIdVisitor<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx>; + fn tcx(&self) -> TyCtxt<'tcx>; fn shallow(&self) -> bool { false } fn skip_assoc_tys(&self) -> bool { false } fn visit_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool; @@ -79,7 +79,7 @@ where { def_id_visitor: &'v mut V, visited_opaque_tys: FxHashSet, - dummy: PhantomData>, + dummy: PhantomData>, } impl<'tcx, V> DefIdVisitorSkeleton<'_, 'tcx, V> @@ -224,7 +224,7 @@ where } fn def_id_visibility<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> (ty::Visibility, Span, &'static str) { match tcx.hir().as_local_hir_id(def_id) { @@ -329,7 +329,7 @@ fn def_id_visibility<'tcx>( // Set the correct `TypeckTables` for the given `item_id` (or an empty table if // there is no `TypeckTables` for the item). fn item_tables<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, hir_id: hir::HirId, empty_tables: &'a ty::TypeckTables<'tcx>, ) -> &'a ty::TypeckTables<'tcx> { @@ -340,7 +340,7 @@ fn item_tables<'a, 'tcx>( fn min<'tcx>( vis1: ty::Visibility, vis2: ty::Visibility, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> ty::Visibility { if vis1.is_at_least(vis2, tcx) { vis2 } else { vis1 } } @@ -352,7 +352,7 @@ fn min<'tcx>( /// in crates that have been updated to use pub(restricted). //////////////////////////////////////////////////////////////////////////////// struct PubRestrictedVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, has_pub_restricted: bool, } @@ -370,13 +370,13 @@ impl Visitor<'tcx> for PubRestrictedVisitor<'tcx> { //////////////////////////////////////////////////////////////////////////////// struct FindMin<'a, 'tcx, VL: VisibilityLike> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &'a AccessLevels, min: VL, } impl<'a, 'tcx, VL: VisibilityLike> DefIdVisitor<'tcx> for FindMin<'a, 'tcx, VL> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx } + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } fn shallow(&self) -> bool { VL::SHALLOW } fn skip_assoc_tys(&self) -> bool { true } fn visit_def_id(&mut self, def_id: DefId, _kind: &str, _descr: &dyn fmt::Display) -> bool { @@ -394,7 +394,7 @@ trait VisibilityLike: Sized { // associated types for which we can't determine visibility precisely. fn of_impl<'a, 'tcx>( hir_id: hir::HirId, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &'a AccessLevels, ) -> Self { let mut find = FindMin { tcx, access_levels, min: Self::MAX }; @@ -438,7 +438,7 @@ impl VisibilityLike for Option { //////////////////////////////////////////////////////////////////////////////// struct EmbargoVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, // Accessibility levels for reachable nodes. access_levels: AccessLevels, @@ -830,7 +830,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, 'tcx> { } impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.ev.tcx } + fn tcx(&self) -> TyCtxt<'tcx> { self.ev.tcx } fn visit_def_id(&mut self, def_id: DefId, _kind: &str, _descr: &dyn fmt::Display) -> bool { if let Some(hir_id) = self.ev.tcx.hir().as_local_hir_id(def_id) { self.ev.update(hir_id, self.access_level); @@ -847,7 +847,7 @@ impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> { ////////////////////////////////////////////////////////////////////////////////////// struct NamePrivacyVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, current_item: hir::HirId, empty_tables: &'a ty::TypeckTables<'tcx>, @@ -974,7 +974,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { //////////////////////////////////////////////////////////////////////////////////////////// struct TypePrivacyVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, current_item: DefId, in_body: bool, @@ -1193,7 +1193,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { } impl DefIdVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx } + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } fn visit_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool { self.check_def_id(def_id, kind, descr) } @@ -1207,7 +1207,7 @@ impl DefIdVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { /////////////////////////////////////////////////////////////////////////////// struct ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, access_levels: &'a AccessLevels, in_variant: bool, // Set of errors produced by this obsolete visitor. @@ -1551,7 +1551,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { /////////////////////////////////////////////////////////////////////////////// struct SearchInterfaceForPrivateItemsVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_id: hir::HirId, item_def_id: DefId, span: Span, @@ -1649,14 +1649,14 @@ impl SearchInterfaceForPrivateItemsVisitor<'tcx> { } impl DefIdVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx } + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } fn visit_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool { self.check_def_id(def_id, kind, descr) } } struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, has_pub_restricted: bool, old_error_set: &'a HirIdSet, } @@ -1832,7 +1832,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn check_mod_privacy<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_privacy<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { let empty_tables = ty::TypeckTables::empty(None); // Check privacy of names not checked in previous compilation stages. @@ -1859,7 +1859,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { intravisit::walk_mod(&mut visitor, module, hir_id); } -fn privacy_access_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, krate: CrateNum) -> &'tcx AccessLevels { +fn privacy_access_levels<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx AccessLevels { assert_eq!(krate, LOCAL_CRATE); // Build up a set of all exported items in the AST. This is a set of all @@ -1883,7 +1883,7 @@ fn privacy_access_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, krate: CrateNum) -> &'tc tcx.arena.alloc(visitor.access_levels) } -fn check_private_in_public<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, krate: CrateNum) { +fn check_private_in_public<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) { assert_eq!(krate, LOCAL_CRATE); let access_levels = tcx.privacy_access_levels(LOCAL_CRATE); diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 3b4ea384a09a3..f9dd4436434f5 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -77,7 +77,7 @@ macro_rules! access_from_vis { pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput> { save_ctxt: SaveContext<'l, 'tcx>, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, dumper: &'ll mut JsonDumper, span: SpanUtils<'l>, diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 139fd640d628c..fb9f872880eac 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -52,7 +52,7 @@ use log::{debug, error, info}; pub struct SaveContext<'l, 'tcx: 'l> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, tables: &'l ty::TypeckTables<'tcx>, access_levels: &'l AccessLevels, span_utils: SpanUtils<'tcx>, @@ -1115,7 +1115,7 @@ impl<'b> SaveHandler for CallbackHandler<'b> { } pub fn process_crate<'l, 'tcx, H: SaveHandler>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, krate: &ast::Crate, cratename: &str, input: &'l Input, diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index 7a519ac2ebea8..d5a4904195857 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -45,19 +45,19 @@ use std::marker::PhantomData; use self::unify::*; #[derive(Copy, Clone, Debug)] -crate struct ChalkArenas<'gcx> { - _phantom: PhantomData<&'gcx ()>, +crate struct ChalkArenas<'tcx> { + _phantom: PhantomData<&'tcx ()>, } #[derive(Copy, Clone)] -crate struct ChalkContext<'gcx> { - _arenas: ChalkArenas<'gcx>, - tcx: TyCtxt<'gcx, 'gcx>, +crate struct ChalkContext<'tcx> { + _arenas: ChalkArenas<'tcx>, + tcx: TyCtxt<'tcx>, } #[derive(Copy, Clone)] -crate struct ChalkInferenceContext<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +crate struct ChalkInferenceContext<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, } #[derive(Copy, Clone, Debug)] @@ -126,12 +126,12 @@ impl context::Context for ChalkArenas<'tcx> { } } -impl context::AggregateOps> for ChalkContext<'gcx> { +impl context::AggregateOps> for ChalkContext<'tcx> { fn make_solution( &self, - root_goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, - mut simplified_answers: impl context::AnswerStream>, - ) -> Option>> { + root_goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, + mut simplified_answers: impl context::AnswerStream>, + ) -> Option>> { use chalk_engine::SimplifiedAnswer; debug!("make_solution(root_goal = {:?})", root_goal); @@ -176,12 +176,12 @@ impl context::AggregateOps> for ChalkContext<'gcx> { } } -impl context::ContextOps> for ChalkContext<'gcx> { +impl context::ContextOps> 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<'gcx, InEnvironment<'gcx, Goal<'gcx>>> + goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>> ) -> bool { use rustc::traits::{WellFormed, WhereClause}; @@ -216,8 +216,8 @@ impl context::ContextOps> for ChalkContext<'gcx> { /// - the environment and goal found by substitution `S` into `arg`. fn instantiate_ucanonical_goal( &self, - arg: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, - op: impl context::WithInstantiatedUCanonicalGoal, Output = R>, + arg: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, + op: impl context::WithInstantiatedUCanonicalGoal, Output = R>, ) -> R { self.tcx.infer_ctxt().enter_with_canonical(DUMMY_SP, arg, |ref infcx, arg, subst| { let chalk_infcx = &mut ChalkInferenceContext { @@ -230,8 +230,8 @@ impl context::ContextOps> for ChalkContext<'gcx> { fn instantiate_ex_clause( &self, _num_universes: usize, - arg: &Canonical<'gcx, ChalkExClause<'gcx>>, - op: impl context::WithInstantiatedExClause, Output = R>, + arg: &Canonical<'tcx, ChalkExClause<'tcx>>, + op: impl context::WithInstantiatedExClause, Output = R>, ) -> R { self.tcx.infer_ctxt().enter_with_canonical(DUMMY_SP, &arg.upcast(), |ref infcx, arg, _| { let chalk_infcx = &mut ChalkInferenceContext { @@ -242,31 +242,31 @@ impl context::ContextOps> for ChalkContext<'gcx> { } /// Returns `true` if this solution has no region constraints. - fn empty_constraints(ccs: &Canonical<'gcx, ConstrainedSubst<'gcx>>) -> bool { + fn empty_constraints(ccs: &Canonical<'tcx, ConstrainedSubst<'tcx>>) -> bool { ccs.value.constraints.is_empty() } fn inference_normalized_subst_from_ex_clause( - canon_ex_clause: &'a Canonical<'gcx, ChalkExClause<'gcx>>, - ) -> &'a CanonicalVarValues<'gcx> { + canon_ex_clause: &'a Canonical<'tcx, ChalkExClause<'tcx>>, + ) -> &'a CanonicalVarValues<'tcx> { &canon_ex_clause.value.subst } fn inference_normalized_subst_from_subst( - canon_subst: &'a Canonical<'gcx, ConstrainedSubst<'gcx>>, - ) -> &'a CanonicalVarValues<'gcx> { + canon_subst: &'a Canonical<'tcx, ConstrainedSubst<'tcx>>, + ) -> &'a CanonicalVarValues<'tcx> { &canon_subst.value.subst } fn canonical( - u_canon: &'a Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, - ) -> &'a Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { + u_canon: &'a Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, + ) -> &'a Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>> { u_canon } fn is_trivial_substitution( - u_canon: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, - canonical_subst: &Canonical<'gcx, ConstrainedSubst<'gcx>>, + u_canon: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, + canonical_subst: &Canonical<'tcx, ConstrainedSubst<'tcx>>, ) -> bool { let subst = &canonical_subst.value.subst; assert_eq!(u_canon.variables.len(), subst.var_values.len()); @@ -297,7 +297,7 @@ impl context::ContextOps> for ChalkContext<'gcx> { }) } - fn num_universes(canon: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>) -> usize { + fn num_universes(canon: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>) -> usize { canon.max_universe.index() + 1 } @@ -306,21 +306,21 @@ impl context::ContextOps> for ChalkContext<'gcx> { /// but for the universes of universally quantified names. fn map_goal_from_canonical( _map: &UniverseMap, - value: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, - ) -> Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { + value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, + ) -> Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>> { *value // FIXME universe maps not implemented yet } fn map_subst_from_canonical( _map: &UniverseMap, - value: &Canonical<'gcx, ConstrainedSubst<'gcx>>, - ) -> Canonical<'gcx, ConstrainedSubst<'gcx>> { + value: &Canonical<'tcx, ConstrainedSubst<'tcx>>, + ) -> Canonical<'tcx, ConstrainedSubst<'tcx>> { value.clone() // FIXME universe maps not implemented yet } } -impl context::InferenceTable, ChalkArenas<'tcx>> - for ChalkInferenceContext<'cx, 'gcx, 'tcx> +impl context::InferenceTable, ChalkArenas<'tcx>> + for ChalkInferenceContext<'cx, 'tcx> { fn into_goal(&self, domain_goal: DomainGoal<'tcx>) -> Goal<'tcx> { self.infcx.tcx.mk_goal(GoalKind::DomainGoal(domain_goal)) @@ -363,8 +363,8 @@ impl context::InferenceTable, ChalkArenas<'tcx>> } } -impl context::TruncateOps, ChalkArenas<'tcx>> - for ChalkInferenceContext<'cx, 'gcx, 'tcx> +impl context::TruncateOps, ChalkArenas<'tcx>> + for ChalkInferenceContext<'cx, 'tcx> { fn truncate_goal( &mut self, @@ -381,8 +381,8 @@ impl context::TruncateOps, ChalkArenas<'tcx>> } } -impl context::UnificationOps, ChalkArenas<'tcx>> - for ChalkInferenceContext<'cx, 'gcx, 'tcx> +impl context::UnificationOps, ChalkArenas<'tcx>> + for ChalkInferenceContext<'cx, 'tcx> { fn program_clauses( &self, @@ -418,7 +418,7 @@ impl context::UnificationOps, ChalkArenas<'tcx>> fn canonicalize_goal( &mut self, value: &InEnvironment<'tcx, Goal<'tcx>>, - ) -> Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { + ) -> Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>> { let mut _orig_values = OriginalQueryValues::default(); self.infcx.canonicalize_query(value, &mut _orig_values) } @@ -426,7 +426,7 @@ impl context::UnificationOps, ChalkArenas<'tcx>> fn canonicalize_ex_clause( &mut self, value: &ChalkExClause<'tcx>, - ) -> Canonical<'gcx, ChalkExClause<'gcx>> { + ) -> Canonical<'tcx, ChalkExClause<'tcx>> { self.infcx.canonicalize_response(value) } @@ -434,15 +434,15 @@ impl context::UnificationOps, ChalkArenas<'tcx>> &mut self, subst: CanonicalVarValues<'tcx>, constraints: Vec>, - ) -> Canonical<'gcx, ConstrainedSubst<'gcx>> { + ) -> Canonical<'tcx, ConstrainedSubst<'tcx>> { self.infcx.canonicalize_response(&ConstrainedSubst { subst, constraints }) } fn u_canonicalize_goal( &mut self, - value: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, + value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, ) -> ( - Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, + Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap, ) { (value.clone(), UniverseMap) @@ -470,7 +470,7 @@ impl context::UnificationOps, ChalkArenas<'tcx>> fn sink_answer_subset( &self, - value: &Canonical<'gcx, ConstrainedSubst<'gcx>>, + value: &Canonical<'tcx, ConstrainedSubst<'tcx>>, ) -> Canonical<'tcx, ConstrainedSubst<'tcx>> { value.clone() } @@ -478,7 +478,7 @@ impl context::UnificationOps, ChalkArenas<'tcx>> fn lift_delayed_literal( &self, value: DelayedLiteral>, - ) -> DelayedLiteral> { + ) -> DelayedLiteral> { match self.infcx.tcx.lift_to_global(&value) { Some(literal) => literal, None => bug!("cannot lift {:?}", value), @@ -508,13 +508,13 @@ type ChalkHhGoal<'tcx> = HhGoal>; type ChalkExClause<'tcx> = ExClause>; -impl Debug for ChalkContext<'gcx> { +impl Debug for ChalkContext<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ChalkContext") } } -impl Debug for ChalkInferenceContext<'cx, 'gcx, 'tcx> { +impl Debug for ChalkInferenceContext<'cx, 'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ChalkInferenceContext") } @@ -527,7 +527,7 @@ impl ChalkContextLift<'tcx> for ChalkArenas<'a> { fn lift_ex_clause_to_tcx( ex_clause: &ChalkExClause<'a>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option { Some(ChalkExClause { subst: tcx.lift(&ex_clause.subst)?, @@ -539,7 +539,7 @@ impl ChalkContextLift<'tcx> for ChalkArenas<'a> { fn lift_delayed_literal_to_tcx( literal: &DelayedLiteral>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option { Some(match literal { DelayedLiteral::CannotProve(()) => DelayedLiteral::CannotProve(()), @@ -553,7 +553,7 @@ impl ChalkContextLift<'tcx> for ChalkArenas<'a> { fn lift_literal_to_tcx( literal: &Literal>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, ) -> Option { Some(match literal { Literal::Negative(goal) => Literal::Negative(tcx.lift(goal)?), @@ -563,7 +563,7 @@ impl ChalkContextLift<'tcx> for ChalkArenas<'a> { } impl ExClauseFold<'tcx> for ChalkArenas<'tcx> { - fn fold_ex_clause_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>( + fn fold_ex_clause_with>( ex_clause: &ChalkExClause<'tcx>, folder: &mut F, ) -> ChalkExClause<'tcx> { @@ -600,13 +600,13 @@ BraceStructLiftImpl! { } } -trait Upcast<'tcx, 'gcx: 'tcx>: 'gcx { +trait Upcast<'tcx>: 'tcx { type Upcasted: 'tcx; fn upcast(&self) -> Self::Upcasted; } -impl<'tcx, 'gcx: 'tcx> Upcast<'tcx, 'gcx> for DelayedLiteral> { +impl<'tcx> Upcast<'tcx> for DelayedLiteral> { type Upcasted = DelayedLiteral>; fn upcast(&self) -> Self::Upcasted { @@ -621,7 +621,7 @@ impl<'tcx, 'gcx: 'tcx> Upcast<'tcx, 'gcx> for DelayedLiteral> } } -impl<'tcx, 'gcx: 'tcx> Upcast<'tcx, 'gcx> for Literal> { +impl<'tcx> Upcast<'tcx> for Literal> { type Upcasted = Literal>; fn upcast(&self) -> Self::Upcasted { @@ -632,7 +632,7 @@ impl<'tcx, 'gcx: 'tcx> Upcast<'tcx, 'gcx> for Literal> { } } -impl<'tcx, 'gcx: 'tcx> Upcast<'tcx, 'gcx> for ExClause> { +impl<'tcx> Upcast<'tcx> for ExClause> { type Upcasted = ExClause>; fn upcast(&self) -> Self::Upcasted { @@ -651,8 +651,8 @@ impl<'tcx, 'gcx: 'tcx> Upcast<'tcx, 'gcx> for ExClause> { } } -impl<'tcx, 'gcx: 'tcx, T> Upcast<'tcx, 'gcx> for Canonical<'gcx, T> - where T: Upcast<'tcx, 'gcx> +impl<'tcx, T> Upcast<'tcx> for Canonical<'tcx, T> + where T: Upcast<'tcx> { type Upcasted = Canonical<'tcx, T::Upcasted>; @@ -673,7 +673,7 @@ crate fn provide(p: &mut Providers<'_>) { } crate fn evaluate_goal<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, goal: ChalkCanonicalGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, traits::query::NoSolution> { use crate::lowering::Lower; diff --git a/src/librustc_traits/chalk_context/program_clauses/builtin.rs b/src/librustc_traits/chalk_context/program_clauses/builtin.rs index 3c9b335e77769..71e18d2b6f949 100644 --- a/src/librustc_traits/chalk_context/program_clauses/builtin.rs +++ b/src/librustc_traits/chalk_context/program_clauses/builtin.rs @@ -15,7 +15,7 @@ use crate::generic_types; /// `Implemented(ty: Trait) :- Implemented(nested: Trait)...` /// where `Trait` is specified by `trait_def_id`. fn builtin_impl_clause( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, nested: &[Kind<'tcx>], trait_def_id: DefId, @@ -43,7 +43,7 @@ fn builtin_impl_clause( } crate fn assemble_builtin_unsize_impls<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, unsize_def_id: DefId, source: Ty<'tcx>, target: Ty<'tcx>, @@ -119,7 +119,7 @@ crate fn assemble_builtin_unsize_impls<'tcx>( } crate fn assemble_builtin_sized_impls<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, sized_def_id: DefId, ty: Ty<'tcx>, clauses: &mut Vec>, @@ -223,7 +223,7 @@ crate fn assemble_builtin_sized_impls<'tcx>( } crate fn assemble_builtin_copy_clone_impls<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, ty: Ty<'tcx>, clauses: &mut Vec>, diff --git a/src/librustc_traits/chalk_context/program_clauses/mod.rs b/src/librustc_traits/chalk_context/program_clauses/mod.rs index ae2283c3672e7..a49ca400f5a21 100644 --- a/src/librustc_traits/chalk_context/program_clauses/mod.rs +++ b/src/librustc_traits/chalk_context/program_clauses/mod.rs @@ -19,7 +19,7 @@ use self::primitive::*; use self::builtin::*; fn assemble_clauses_from_impls<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, clauses: &mut Vec>, ) { @@ -33,7 +33,7 @@ fn assemble_clauses_from_impls<'tcx>( } fn assemble_clauses_from_assoc_ty_values<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, clauses: &mut Vec>, ) { @@ -48,7 +48,7 @@ fn assemble_clauses_from_assoc_ty_values<'tcx>( }); } -impl ChalkInferenceContext<'cx, 'gcx, 'tcx> { +impl ChalkInferenceContext<'cx, 'tcx> { pub(super) fn program_clauses_impl( &self, environment: &Environment<'tcx>, diff --git a/src/librustc_traits/chalk_context/program_clauses/primitive.rs b/src/librustc_traits/chalk_context/program_clauses/primitive.rs index fd7b5ec55b08b..cdcf73d3c3a3b 100644 --- a/src/librustc_traits/chalk_context/program_clauses/primitive.rs +++ b/src/librustc_traits/chalk_context/program_clauses/primitive.rs @@ -16,7 +16,7 @@ use crate::generic_types; use std::iter; crate fn wf_clause_for_raw_ptr<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, mutbl: hir::Mutability, ) -> Clauses<'tcx> { let ptr_ty = generic_types::raw_ptr(tcx, mutbl); @@ -33,7 +33,7 @@ crate fn wf_clause_for_raw_ptr<'tcx>( } crate fn wf_clause_for_fn_ptr<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, arity_and_output: usize, variadic: bool, unsafety: hir::Unsafety, @@ -53,7 +53,7 @@ crate fn wf_clause_for_fn_ptr<'tcx>( tcx.mk_clauses(iter::once(wf_clause)) } -crate fn wf_clause_for_slice<'tcx>(tcx: TyCtxt<'_, 'tcx>) -> Clauses<'tcx> { +crate fn wf_clause_for_slice<'tcx>(tcx: TyCtxt<'tcx>) -> Clauses<'tcx> { let ty = generic_types::bound(tcx, 0); let slice_ty = tcx.mk_slice(ty); @@ -83,7 +83,7 @@ crate fn wf_clause_for_slice<'tcx>(tcx: TyCtxt<'_, 'tcx>) -> Clauses<'tcx> { } crate fn wf_clause_for_array<'tcx>( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, length: &'tcx ty::Const<'tcx>, ) -> Clauses<'tcx> { let ty = generic_types::bound(tcx, 0); @@ -114,7 +114,7 @@ crate fn wf_clause_for_array<'tcx>( tcx.mk_clauses(iter::once(wf_clause)) } -crate fn wf_clause_for_tuple<'tcx>(tcx: TyCtxt<'_, 'tcx>, arity: usize) -> Clauses<'tcx> { +crate fn wf_clause_for_tuple<'tcx>(tcx: TyCtxt<'tcx>, arity: usize) -> Clauses<'tcx> { let type_list = generic_types::type_list(tcx, arity); let tuple_ty = tcx.mk_ty(ty::Tuple(type_list)); @@ -155,7 +155,7 @@ crate fn wf_clause_for_tuple<'tcx>(tcx: TyCtxt<'_, 'tcx>, arity: usize) -> Claus tcx.mk_clauses(iter::once(wf_clause)) } -crate fn wf_clause_for_ref<'tcx>(tcx: TyCtxt<'_, 'tcx>, mutbl: hir::Mutability) -> Clauses<'tcx> { +crate fn wf_clause_for_ref<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Clauses<'tcx> { let region = tcx.mk_region( ty::ReLateBound(ty::INNERMOST, ty::BoundRegion::BrAnon(0)) ); @@ -179,7 +179,7 @@ crate fn wf_clause_for_ref<'tcx>(tcx: TyCtxt<'_, 'tcx>, mutbl: hir::Mutability) tcx.mk_clauses(iter::once(wf_clause)) } -crate fn wf_clause_for_fn_def<'tcx>(tcx: TyCtxt<'_, 'tcx>, def_id: DefId) -> Clauses<'tcx> { +crate fn wf_clause_for_fn_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { let fn_def = generic_types::fn_def(tcx, def_id); let wf_clause = ProgramClause { diff --git a/src/librustc_traits/chalk_context/resolvent_ops.rs b/src/librustc_traits/chalk_context/resolvent_ops.rs index ff2cfc87297de..1e8b02659dc6a 100644 --- a/src/librustc_traits/chalk_context/resolvent_ops.rs +++ b/src/librustc_traits/chalk_context/resolvent_ops.rs @@ -25,8 +25,8 @@ use syntax_pos::DUMMY_SP; use super::{ChalkInferenceContext, ChalkArenas, ChalkExClause, ConstrainedSubst}; use super::unify::*; -impl context::ResolventOps, ChalkArenas<'tcx>> - for ChalkInferenceContext<'cx, 'gcx, 'tcx> +impl context::ResolventOps, ChalkArenas<'tcx>> + for ChalkInferenceContext<'cx, 'tcx> { fn resolvent_clause( &mut self, @@ -34,7 +34,7 @@ impl context::ResolventOps, ChalkArenas<'tcx>> goal: &DomainGoal<'tcx>, subst: &CanonicalVarValues<'tcx>, clause: &Clause<'tcx>, - ) -> Fallible>> { + ) -> Fallible>> { use chalk_engine::context::UnificationOps; debug!("resolvent_clause(goal = {:?}, clause = {:?})", goal, clause); @@ -106,8 +106,8 @@ impl context::ResolventOps, ChalkArenas<'tcx>> &mut self, ex_clause: ChalkExClause<'tcx>, selected_goal: &InEnvironment<'tcx, Goal<'tcx>>, - answer_table_goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, - canonical_answer_subst: &Canonical<'gcx, ConstrainedSubst<'gcx>>, + answer_table_goal: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, + canonical_answer_subst: &Canonical<'tcx, ConstrainedSubst<'tcx>>, ) -> Fallible> { debug!( "apply_answer_subst(ex_clause = {:?}, selected_goal = {:?})", @@ -139,15 +139,15 @@ impl context::ResolventOps, ChalkArenas<'tcx>> } } -struct AnswerSubstitutor<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +struct AnswerSubstitutor<'cx, 'tcx: 'cx> { + infcx: &'cx InferCtxt<'cx, 'tcx>, environment: Environment<'tcx>, answer_subst: CanonicalVarValues<'tcx>, binder_index: ty::DebruijnIndex, ex_clause: ChalkExClause<'tcx>, } -impl AnswerSubstitutor<'cx, 'gcx, 'tcx> { +impl AnswerSubstitutor<'cx, 'tcx> { fn unify_free_answer_var( &mut self, answer_var: ty::BoundVar, @@ -169,8 +169,8 @@ impl AnswerSubstitutor<'cx, 'gcx, 'tcx> { } } -impl TypeRelation<'gcx, 'tcx> for AnswerSubstitutor<'cx, 'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { +impl TypeRelation<'tcx> for AnswerSubstitutor<'cx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } diff --git a/src/librustc_traits/chalk_context/unify.rs b/src/librustc_traits/chalk_context/unify.rs index abb4812734123..7ae0e8548fae6 100644 --- a/src/librustc_traits/chalk_context/unify.rs +++ b/src/librustc_traits/chalk_context/unify.rs @@ -10,8 +10,8 @@ crate struct UnificationResult<'tcx> { crate constraints: Vec>, } -crate fn unify<'me, 'gcx, 'tcx, T: Relate<'tcx>>( - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, +crate fn unify<'me, 'tcx, T: Relate<'tcx>>( + infcx: &'me InferCtxt<'me, 'tcx>, environment: Environment<'tcx>, variance: ty::Variance, a: &T, @@ -42,16 +42,16 @@ crate fn unify<'me, 'gcx, 'tcx, T: Relate<'tcx>>( }) } -struct ChalkTypeRelatingDelegate<'me, 'gcx: 'tcx, 'tcx: 'me> { - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, +struct ChalkTypeRelatingDelegate<'me, 'tcx: 'me> { + infcx: &'me InferCtxt<'me, 'tcx>, environment: Environment<'tcx>, goals: Vec>>, constraints: Vec>, } -impl ChalkTypeRelatingDelegate<'me, 'gcx, 'tcx> { +impl ChalkTypeRelatingDelegate<'me, 'tcx> { fn new( - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + infcx: &'me InferCtxt<'me, 'tcx>, environment: Environment<'tcx>, ) -> Self { Self { @@ -63,7 +63,7 @@ impl ChalkTypeRelatingDelegate<'me, 'gcx, 'tcx> { } } -impl TypeRelatingDelegate<'tcx> for &mut ChalkTypeRelatingDelegate<'_, '_, 'tcx> { +impl TypeRelatingDelegate<'tcx> for &mut ChalkTypeRelatingDelegate<'_, 'tcx> { fn create_next_universe(&mut self) -> ty::UniverseIndex { self.infcx.create_next_universe() } diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 02b9b078fca91..3abd7e90cf10f 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -18,7 +18,7 @@ crate fn provide(p: &mut Providers<'_>) { } fn dropck_outlives<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonical_goal: CanonicalTyGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, NoSolution> { debug!("dropck_outlives(goal={:#?})", canonical_goal); @@ -146,8 +146,8 @@ fn dropck_outlives<'tcx>( /// Returns a set of constraints that needs to be satisfied in /// order for `ty` to be valid for destruction. -fn dtorck_constraint_for_ty<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn dtorck_constraint_for_ty<'tcx>( + tcx: TyCtxt<'tcx>, span: Span, for_ty: Ty<'tcx>, depth: usize, @@ -280,7 +280,7 @@ fn dtorck_constraint_for_ty<'gcx, 'tcx>( /// Calculates the dtorck constraint for a type. crate fn adt_dtorck_constraint<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> Result, NoSolution> { let def = tcx.adt_def(def_id); diff --git a/src/librustc_traits/evaluate_obligation.rs b/src/librustc_traits/evaluate_obligation.rs index be3a8340e6006..360b6c25c36c0 100644 --- a/src/librustc_traits/evaluate_obligation.rs +++ b/src/librustc_traits/evaluate_obligation.rs @@ -14,7 +14,7 @@ crate fn provide(p: &mut Providers<'_>) { } fn evaluate_obligation<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonical_goal: CanonicalPredicateGoal<'tcx>, ) -> Result { tcx.infer_ctxt().enter_with_canonical( diff --git a/src/librustc_traits/generic_types.rs b/src/librustc_traits/generic_types.rs index dca7fb0dae3d4..bd2ed94b18d59 100644 --- a/src/librustc_traits/generic_types.rs +++ b/src/librustc_traits/generic_types.rs @@ -6,7 +6,7 @@ use rustc::hir; use rustc::hir::def_id::DefId; use rustc_target::spec::abi; -crate fn bound(tcx: TyCtxt<'_, 'tcx>, index: u32) -> Ty<'tcx> { +crate fn bound(tcx: TyCtxt<'tcx>, index: u32) -> Ty<'tcx> { let ty = ty::Bound( ty::INNERMOST, ty::BoundVar::from_u32(index).into() @@ -14,7 +14,7 @@ crate fn bound(tcx: TyCtxt<'_, 'tcx>, index: u32) -> Ty<'tcx> { tcx.mk_ty(ty) } -crate fn raw_ptr(tcx: TyCtxt<'_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tcx> { +crate fn raw_ptr(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Ty<'tcx> { tcx.mk_ptr(ty::TypeAndMut { ty: bound(tcx, 0), mutbl, @@ -22,7 +22,7 @@ crate fn raw_ptr(tcx: TyCtxt<'_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tcx> { } crate fn fn_ptr( - tcx: TyCtxt<'_, 'tcx>, + tcx: TyCtxt<'tcx>, arity_and_output: usize, c_variadic: bool, unsafety: hir::Unsafety, @@ -44,7 +44,7 @@ crate fn fn_ptr( tcx.mk_fn_ptr(fn_sig) } -crate fn type_list(tcx: TyCtxt<'_, 'tcx>, arity: usize) -> SubstsRef<'tcx> { +crate fn type_list(tcx: TyCtxt<'tcx>, arity: usize) -> SubstsRef<'tcx> { tcx.mk_substs( (0..arity).into_iter() .map(|i| ty::BoundVar::from(i)) @@ -53,7 +53,7 @@ crate fn type_list(tcx: TyCtxt<'_, 'tcx>, arity: usize) -> SubstsRef<'tcx> { ) } -crate fn ref_ty(tcx: TyCtxt<'_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tcx> { +crate fn ref_ty(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Ty<'tcx> { let region = tcx.mk_region( ty::ReLateBound(ty::INNERMOST, ty::BoundRegion::BrAnon(0)) ); @@ -64,17 +64,17 @@ crate fn ref_ty(tcx: TyCtxt<'_, 'tcx>, mutbl: hir::Mutability) -> Ty<'tcx> { }) } -crate fn fn_def(tcx: TyCtxt<'_, 'tcx>, def_id: DefId) -> Ty<'tcx> { +crate fn fn_def(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.mk_ty(ty::FnDef(def_id, InternalSubsts::bound_vars_for_item(tcx, def_id))) } -crate fn closure(tcx: TyCtxt<'_, 'tcx>, def_id: DefId) -> Ty<'tcx> { +crate fn closure(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.mk_closure(def_id, ty::ClosureSubsts { substs: InternalSubsts::bound_vars_for_item(tcx, def_id), }) } -crate fn generator(tcx: TyCtxt<'_, 'tcx>, def_id: DefId) -> Ty<'tcx> { +crate fn generator(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.mk_generator(def_id, ty::GeneratorSubsts { substs: InternalSubsts::bound_vars_for_item(tcx, def_id), }, hir::GeneratorMovability::Movable) diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs index 1bb04eab4c4bb..8e789e0408f0a 100644 --- a/src/librustc_traits/implied_outlives_bounds.rs +++ b/src/librustc_traits/implied_outlives_bounds.rs @@ -23,7 +23,7 @@ crate fn provide(p: &mut Providers<'_>) { } fn implied_outlives_bounds<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, goal: CanonicalTyGoal<'tcx>, ) -> Result< &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec>>>, @@ -37,7 +37,7 @@ fn implied_outlives_bounds<'tcx>( } fn compute_implied_outlives_bounds<'tcx>( - infcx: &InferCtxt<'_, '_, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx> ) -> Fallible>> { diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index bab74e80ea6e9..d1bad6b4d1ee2 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -12,12 +12,12 @@ use rustc::hir::def_id::DefId; use rustc_data_structures::fx::FxHashSet; struct ClauseVisitor<'a, 'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, round: &'a mut FxHashSet>, } impl ClauseVisitor<'a, 'tcx> { - fn new(tcx: TyCtxt<'tcx, 'tcx>, round: &'a mut FxHashSet>) -> Self { + fn new(tcx: TyCtxt<'tcx>, round: &'a mut FxHashSet>) -> Self { ClauseVisitor { tcx, round, @@ -128,7 +128,7 @@ impl ClauseVisitor<'a, 'tcx> { } crate fn program_clauses_for_env<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, environment: Environment<'tcx>, ) -> Clauses<'tcx> { debug!("program_clauses_for_env(environment={:?})", environment); @@ -160,7 +160,7 @@ crate fn program_clauses_for_env<'tcx>( ); } -crate fn environment<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Environment<'tcx> { +crate fn environment<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Environment<'tcx> { use super::{Lower, IntoFromEnvGoal}; use rustc::hir::{Node, TraitItemKind, ImplItemKind, ItemKind, ForeignItemKind}; diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 59cd58ea23d14..2a6613101614d 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -155,7 +155,7 @@ impl<'tcx> IntoWellFormedGoal for DomainGoal<'tcx> { } } -crate fn program_clauses_for<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { +crate fn program_clauses_for<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { // FIXME(eddyb) this should only be using `def_kind`. match tcx.def_key(def_id).disambiguated_data.data { DefPathData::TypeNs(..) => match tcx.def_kind(def_id) { @@ -181,7 +181,7 @@ crate fn program_clauses_for<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Cl } } -fn program_clauses_for_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { +fn program_clauses_for_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { // `trait Trait where WC { .. } // P0 == Self` // Rule Implemented-From-Env (see rustc guide) @@ -294,7 +294,7 @@ fn program_clauses_for_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Cl ) } -fn program_clauses_for_impl(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { +fn program_clauses_for_impl(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { return List::empty(); } @@ -337,7 +337,7 @@ fn program_clauses_for_impl(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Clauses<' tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::bind(clause)))) } -pub fn program_clauses_for_type_def<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { +pub fn program_clauses_for_type_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> { // Rule WellFormed-Type // // `struct Ty where WC1, ..., WCm` @@ -412,7 +412,7 @@ pub fn program_clauses_for_type_def<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId } pub fn program_clauses_for_associated_type_def<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_id: DefId, ) -> Clauses<'tcx> { // Rule ProjectionEq-Placeholder @@ -550,7 +550,7 @@ pub fn program_clauses_for_associated_type_def<'tcx>( } pub fn program_clauses_for_associated_type_value<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_id: DefId, ) -> Clauses<'tcx> { // Rule Normalize-From-Impl (see rustc guide) @@ -611,7 +611,7 @@ pub fn program_clauses_for_associated_type_value<'tcx>( tcx.mk_clauses(iter::once(normalize_clause)) } -pub fn dump_program_clauses<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn dump_program_clauses<'tcx>(tcx: TyCtxt<'tcx>) { if !tcx.features().rustc_attrs { return; } @@ -623,7 +623,7 @@ pub fn dump_program_clauses<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } struct ClauseDumper<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ClauseDumper<'tcx> { diff --git a/src/librustc_traits/normalize_erasing_regions.rs b/src/librustc_traits/normalize_erasing_regions.rs index 5dec1613f1e95..bfa1a80bb320f 100644 --- a/src/librustc_traits/normalize_erasing_regions.rs +++ b/src/librustc_traits/normalize_erasing_regions.rs @@ -12,7 +12,7 @@ crate fn provide(p: &mut Providers<'_>) { } fn normalize_ty_after_erasing_regions<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, goal: ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Ty<'tcx> { debug!("normalize_ty_after_erasing_regions(goal={:#?})", goal); diff --git a/src/librustc_traits/normalize_projection_ty.rs b/src/librustc_traits/normalize_projection_ty.rs index 448d42dc9b051..7e0ca5b00183d 100644 --- a/src/librustc_traits/normalize_projection_ty.rs +++ b/src/librustc_traits/normalize_projection_ty.rs @@ -15,7 +15,7 @@ crate fn provide(p: &mut Providers<'_>) { } fn normalize_projection_ty<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, goal: CanonicalProjectionGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> { debug!("normalize_provider(goal={:#?})", goal); diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index f2ceff6185e92..dcbb0dffba8f2 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -35,7 +35,7 @@ crate fn provide(p: &mut Providers<'_>) { } fn type_op_ascribe_user_type<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, AscribeUserType<'tcx>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { tcx.infer_ctxt() @@ -56,13 +56,13 @@ fn type_op_ascribe_user_type<'tcx>( }) } -struct AscribeUserTypeCx<'me, 'gcx: 'tcx, 'tcx: 'me> { - infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, +struct AscribeUserTypeCx<'me, 'tcx: 'me> { + infcx: &'me InferCtxt<'me, 'tcx>, param_env: ParamEnv<'tcx>, fulfill_cx: &'me mut dyn TraitEngine<'tcx>, } -impl AscribeUserTypeCx<'me, 'gcx, 'tcx> { +impl AscribeUserTypeCx<'me, 'tcx> { fn normalize(&mut self, value: T) -> T where T: TypeFoldable<'tcx>, @@ -94,7 +94,7 @@ impl AscribeUserTypeCx<'me, 'gcx, 'tcx> { ); } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } @@ -167,7 +167,7 @@ impl AscribeUserTypeCx<'me, 'gcx, 'tcx> { } fn type_op_eq<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Eq<'tcx>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { tcx.infer_ctxt() @@ -181,12 +181,12 @@ fn type_op_eq<'tcx>( } fn type_op_normalize( - infcx: &InferCtxt<'_, 'gcx, 'tcx>, + infcx: &InferCtxt<'_, 'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx>, key: ParamEnvAnd<'tcx, Normalize>, ) -> Fallible where - T: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx>, + T: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx>, { let (param_env, Normalize { value }) = key.into_parts(); let Normalized { value, obligations } = infcx @@ -197,7 +197,7 @@ where } fn type_op_normalize_ty( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, NoSolution> { tcx.infer_ctxt() @@ -205,7 +205,7 @@ fn type_op_normalize_ty( } fn type_op_normalize_predicate( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Predicate<'tcx>>>, NoSolution> { tcx.infer_ctxt() @@ -213,7 +213,7 @@ fn type_op_normalize_predicate( } fn type_op_normalize_fn_sig( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>, NoSolution> { tcx.infer_ctxt() @@ -221,7 +221,7 @@ fn type_op_normalize_fn_sig( } fn type_op_normalize_poly_fn_sig( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>, NoSolution> { tcx.infer_ctxt() @@ -229,7 +229,7 @@ fn type_op_normalize_poly_fn_sig( } fn type_op_subtype<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Subtype<'tcx>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { tcx.infer_ctxt() @@ -243,7 +243,7 @@ fn type_op_subtype<'tcx>( } fn type_op_prove_predicate<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { tcx.infer_ctxt() diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 2c9309a1696cf..c4d841ede0797 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -40,8 +40,8 @@ use rustc_data_structures::fx::FxHashSet; #[derive(Debug)] pub struct PathSeg(pub DefId, pub usize); -pub trait AstConv<'gcx, 'tcx> { - fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx>; +pub trait AstConv<'tcx> { + fn tcx<'a>(&'a self) -> TyCtxt<'tcx>; /// Returns the set of bounds in scope for the type parameter with /// the given id. @@ -115,7 +115,7 @@ enum GenericArgPosition { MethodCall, } -impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { +impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { pub fn ast_region_to_region(&self, lifetime: &hir::Lifetime, def: Option<&ty::GenericParamDef>) @@ -208,7 +208,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// Report error if there is an explicit type parameter when using `impl Trait`. fn check_impl_trait( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, span: Span, seg: &hir::PathSegment, generics: &ty::Generics, @@ -239,7 +239,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// Checks that the correct number of generic arguments have been provided. /// Used specifically for function calls. pub fn check_generic_arg_count_for_call( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, span: Span, def: &ty::Generics, seg: &hir::PathSegment, @@ -271,7 +271,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// Checks that the correct number of generic arguments have been provided. /// This is used both for datatypes and function calls. fn check_generic_arg_count( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, span: Span, def: &ty::Generics, args: &hir::GenericArgs, @@ -462,7 +462,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// - `inferred_kind`: if no parameter was provided, and inference is enabled, then /// creates a suitable inference variable. pub fn create_substs_for_generic_args<'b>( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, parent_substs: &[Kind<'tcx>], has_self: bool, @@ -1810,7 +1810,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { has_err } - pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_, '_>, span: Span) { + pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span) { let mut err = struct_span_err!(tcx.sess, span, E0229, "associated type bindings are not allowed here"); err.span_label(span, "associated type not allowed here").emit(); @@ -2415,14 +2415,14 @@ pub struct Bounds<'tcx> { pub implicitly_sized: Option, } -impl<'gcx, 'tcx> Bounds<'tcx> { +impl<'tcx> Bounds<'tcx> { /// Converts a bounds list into a flat set of predicates (like /// where-clauses). Because some of our bounds listings (e.g., /// regions) don't include the self-type, you must supply the /// self-type here (the `param_ty` parameter). pub fn predicates( &self, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, param_ty: Ty<'tcx>, ) -> Vec<(ty::Predicate<'tcx>, Span)> { // If it could be sized, and is, add the `Sized` predicate. diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index b882b696938ac..3aa050fb56d86 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -22,7 +22,7 @@ use std::cmp; use super::report_unexpected_variant_res; -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// `discrim_span` argument having a `Span` indicates that this pattern is part of a match /// expression arm guard, and it points to the match discriminant to add context in type errors. /// In the following example, `discrim_span` corresponds to the `a + b` expression: @@ -41,7 +41,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// ``` pub fn check_pat_walk( &self, - pat: &'gcx hir::Pat, + pat: &'tcx hir::Pat, mut expected: Ty<'tcx>, mut def_bm: ty::BindingMode, discrim_span: Option, @@ -613,9 +613,9 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); pub fn check_match( &self, - expr: &'gcx hir::Expr, - discrim: &'gcx hir::Expr, - arms: &'gcx [hir::Arm], + expr: &'tcx hir::Expr, + discrim: &'tcx hir::Expr, + arms: &'tcx [hir::Arm], expected: Expectation<'tcx>, match_src: hir::MatchSource, ) -> Ty<'tcx> { @@ -769,7 +769,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); /// When the previously checked expression (the scrutinee) diverges, /// warn the user about the match arms being unreachable. - fn warn_arms_when_scrutinee_diverges(&self, arms: &'gcx [hir::Arm], source_if: bool) { + fn warn_arms_when_scrutinee_diverges(&self, arms: &'tcx [hir::Arm], source_if: bool) { if self.diverges.get().always() { let msg = if source_if { "block in `if` expression" } else { "arm" }; for arm in arms { @@ -782,8 +782,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); fn if_fallback_coercion( &self, span: Span, - then_expr: &'gcx hir::Expr, - coercion: &mut CoerceMany<'gcx, 'tcx, '_, rustc::hir::Arm>, + then_expr: &'tcx hir::Expr, + coercion: &mut CoerceMany<'tcx, '_, rustc::hir::Arm>, ) { // If this `if` expr is the parent's function return expr, // the cause of the type coercion is the return type, point at it. (#25228) @@ -839,8 +839,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); fn if_cause( &self, span: Span, - then_expr: &'gcx hir::Expr, - else_expr: &'gcx hir::Expr, + then_expr: &'tcx hir::Expr, + else_expr: &'tcx hir::Expr, then_ty: Ty<'tcx>, else_ty: Ty<'tcx>, ) -> ObligationCause<'tcx> { @@ -941,8 +941,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); fn demand_discriminant_type( &self, - arms: &'gcx [hir::Arm], - discrim: &'gcx hir::Expr, + arms: &'tcx [hir::Arm], + discrim: &'tcx hir::Expr, ) -> Ty<'tcx> { // Not entirely obvious: if matches may create ref bindings, we want to // use the *precise* type of the discriminant, *not* some supertype, as @@ -1020,9 +1020,9 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); fn check_pat_struct( &self, - pat: &'gcx hir::Pat, + pat: &'tcx hir::Pat, qpath: &hir::QPath, - fields: &'gcx [Spanned], + fields: &'tcx [Spanned], etc: bool, expected: Ty<'tcx>, def_bm: ty::BindingMode, @@ -1088,7 +1088,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); &self, pat: &hir::Pat, qpath: &hir::QPath, - subpats: &'gcx [P], + subpats: &'tcx [P], ddpos: Option, expected: Ty<'tcx>, def_bm: ty::BindingMode, @@ -1192,7 +1192,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); pat_id: hir::HirId, span: Span, variant: &'tcx ty::VariantDef, - fields: &'gcx [Spanned], + fields: &'tcx [Spanned], etc: bool, def_bm: ty::BindingMode, ) -> bool { diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index ce92551c0133f..80c6c13b57e93 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -20,8 +20,8 @@ enum AutoderefKind { Overloaded, } -pub struct Autoderef<'a, 'gcx: 'tcx, 'tcx: 'a> { - infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, +pub struct Autoderef<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, body_id: hir::HirId, param_env: ty::ParamEnv<'tcx>, steps: Vec<(Ty<'tcx>, AutoderefKind)>, @@ -34,7 +34,7 @@ pub struct Autoderef<'a, 'gcx: 'tcx, 'tcx: 'a> { reached_recursion_limit: bool } -impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> { type Item = (Ty<'tcx>, usize); fn next(&mut self) -> Option { @@ -85,13 +85,13 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { - pub fn new(infcx: &'a InferCtxt<'a, 'gcx, '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, 'gcx, 'tcx> + -> Autoderef<'a, 'tcx> { Autoderef { infcx, @@ -157,7 +157,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { /// Returns the final type, generating an error if it is an /// unresolved inference variable. - pub fn unambiguous_final_ty(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { + pub fn unambiguous_final_ty(&self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> { fcx.structurally_resolved_type(self.span, self.cur_ty) } @@ -172,12 +172,12 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { } /// Returns the adjustment steps. - pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, needs: Needs) + pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) -> Vec> { fcx.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(fcx, needs)) } - pub fn adjust_steps_as_infer_ok(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, needs: Needs) + pub fn adjust_steps_as_infer_ok(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) -> InferOk<'tcx, Vec>> { let mut obligations = vec![]; let targets = self.steps.iter().skip(1).map(|&(ty, _)| ty) @@ -230,7 +230,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { self.reached_recursion_limit } - pub fn finalize(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) { + pub fn finalize(self, fcx: &FnCtxt<'a, 'tcx>) { fcx.register_predicates(self.into_obligations()); } @@ -239,8 +239,8 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { } } -pub fn report_autoderef_recursion_limit_error<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +pub fn report_autoderef_recursion_limit_error<'tcx>( + tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>, ) { @@ -264,8 +264,8 @@ pub fn report_autoderef_recursion_limit_error<'gcx, 'tcx>( } } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { + pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> { Autoderef::new(self, self.param_env, self.body_id, span, base_ty) } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 8e13bbed89e78..0207f18ac81d5 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -18,7 +18,7 @@ use rustc::hir; /// Checks that it is legal to call methods of the trait corresponding /// to `trait_id` (this only cares about the trait, not the specific /// method that is called). -pub fn check_legal_trait_for_method_call(tcx: TyCtxt<'_, '_>, span: Span, trait_id: DefId) { +pub fn check_legal_trait_for_method_call(tcx: TyCtxt<'_>, span: Span, trait_id: DefId) { if tcx.lang_items().drop_trait() == Some(trait_id) { struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method") .span_label(span, "explicit destructor calls not allowed") @@ -33,12 +33,12 @@ enum CallStep<'tcx> { Overloaded(MethodCallee<'tcx>), } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_call( &self, - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, - arg_exprs: &'gcx [hir::Expr], + call_expr: &'tcx hir::Expr, + callee_expr: &'tcx hir::Expr, + arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, ) -> Ty<'tcx> { let original_callee_ty = self.check_expr(callee_expr); @@ -78,10 +78,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn try_overloaded_call_step( &self, - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, - arg_exprs: &'gcx [hir::Expr], - autoderef: &Autoderef<'a, 'gcx, 'tcx>, + call_expr: &'tcx hir::Expr, + callee_expr: &'tcx hir::Expr, + arg_exprs: &'tcx [hir::Expr], + autoderef: &Autoderef<'a, 'tcx>, ) -> Option> { let adjusted_ty = autoderef.unambiguous_final_ty(self); debug!( @@ -165,7 +165,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &self, call_expr: &hir::Expr, adjusted_ty: Ty<'tcx>, - opt_arg_exprs: Option<&'gcx [hir::Expr]>, + opt_arg_exprs: Option<&'tcx [hir::Expr]>, ) -> Option<(Option>, MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. for &(opt_trait_def_id, method_name, borrow) in &[ @@ -265,7 +265,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &self, call_expr: &hir::Expr, callee_ty: Ty<'tcx>, - arg_exprs: &'gcx [hir::Expr], + arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, ) -> Ty<'tcx> { let (fn_sig, def_span) = match callee_ty.sty { @@ -440,7 +440,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn confirm_deferred_closure_call( &self, call_expr: &hir::Expr, - arg_exprs: &'gcx [hir::Expr], + arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, fn_sig: ty::FnSig<'tcx>, ) -> Ty<'tcx> { @@ -473,7 +473,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn confirm_overloaded_call( &self, call_expr: &hir::Expr, - arg_exprs: &'gcx [hir::Expr], + arg_exprs: &'tcx [hir::Expr], expected: Expectation<'tcx>, method_callee: MethodCallee<'tcx>, ) -> Ty<'tcx> { @@ -492,9 +492,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } #[derive(Debug)] -pub struct DeferredCallResolution<'gcx: 'tcx, 'tcx> { - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, +pub struct DeferredCallResolution<'tcx> { + call_expr: &'tcx hir::Expr, + callee_expr: &'tcx hir::Expr, adjusted_ty: Ty<'tcx>, adjustments: Vec>, fn_sig: ty::FnSig<'tcx>, @@ -502,8 +502,8 @@ pub struct DeferredCallResolution<'gcx: 'tcx, 'tcx> { closure_substs: ty::ClosureSubsts<'tcx>, } -impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { - pub fn resolve(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) { +impl<'a, 'tcx> DeferredCallResolution<'tcx> { + pub fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) { debug!("DeferredCallResolution::resolve() {:?}", self); // we should not be invoked until the closure kind has been diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index f8cad733ca1c8..e70090dd85a42 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -74,7 +74,7 @@ enum PointerKind<'tcx> { OfParam(&'tcx ty::ParamTy), } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Returns the kind of unsize information of t, or None /// if t is unknown. fn pointer_kind(&self, t: Ty<'tcx>, span: Span) -> @@ -158,11 +158,11 @@ impl From for CastError { } } -fn make_invalid_casting_error<'a, 'gcx, 'tcx>(sess: &'a Session, +fn make_invalid_casting_error<'a, 'tcx>(sess: &'a Session, span: Span, expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, - fcx: &FnCtxt<'a, 'gcx, 'tcx>) + fcx: &FnCtxt<'a, 'tcx>) -> DiagnosticBuilder<'a> { type_error_struct!(sess, span, expr_ty, E0606, "casting `{}` as `{}` is invalid", @@ -170,8 +170,8 @@ fn make_invalid_casting_error<'a, 'gcx, 'tcx>(sess: &'a Session, fcx.ty_to_string(cast_ty)) } -impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { - pub fn new(fcx: &FnCtxt<'a, 'gcx, 'tcx>, +impl<'a, 'tcx> CastCheck<'tcx> { + pub fn new(fcx: &FnCtxt<'a, 'tcx>, expr: &'tcx hir::Expr, expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, @@ -198,7 +198,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } } - fn report_cast_error(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, e: CastError) { + fn report_cast_error(&self, fcx: &FnCtxt<'a, 'tcx>, e: CastError) { match e { CastError::ErrorReported => { // an error has already been reported @@ -326,7 +326,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } } - fn report_cast_to_unsized_type(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) { + fn report_cast_to_unsized_type(&self, fcx: &FnCtxt<'a, 'tcx>) { if self.cast_ty.references_error() || self.expr_ty.references_error() { return; } @@ -386,7 +386,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { err.emit(); } - fn trivial_cast_lint(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) { + fn trivial_cast_lint(&self, fcx: &FnCtxt<'a, 'tcx>) { let t_cast = self.cast_ty; let t_expr = self.expr_ty; let type_asc_or = if fcx.tcx.features().type_ascription { @@ -412,7 +412,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { err.emit(); } - pub fn check(mut self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) { + pub fn check(mut self, fcx: &FnCtxt<'a, 'tcx>) { self.expr_ty = fcx.structurally_resolved_type(self.span, self.expr_ty); self.cast_ty = fcx.structurally_resolved_type(self.span, self.cast_ty); @@ -443,7 +443,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { /// Checks a cast, and report an error if one exists. In some cases, this /// can return Ok and create type errors in the fcx rather than returning /// directly. coercion-cast is handled in check instead of here. - fn do_check(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Result { + fn do_check(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result { use rustc::ty::cast::IntTy::*; use rustc::ty::cast::CastTy::*; @@ -532,7 +532,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } fn check_ptr_ptr_cast(&self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, m_expr: ty::TypeAndMut<'tcx>, m_cast: ty::TypeAndMut<'tcx>) -> Result { @@ -573,7 +573,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } fn check_fptr_ptr_cast(&self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, m_cast: ty::TypeAndMut<'tcx>) -> Result { // fptr-ptr cast. must be to thin ptr @@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } fn check_ptr_addr_cast(&self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, m_expr: ty::TypeAndMut<'tcx>) -> Result { // ptr-addr cast. must be from thin ptr @@ -599,7 +599,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } fn check_ref_cast(&self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, m_expr: ty::TypeAndMut<'tcx>, m_cast: ty::TypeAndMut<'tcx>) -> Result { @@ -624,7 +624,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } fn check_addr_ptr_cast(&self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, m_cast: TypeAndMut<'tcx>) -> Result { // ptr-addr cast. pointer must be thin. @@ -635,12 +635,12 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } } - fn try_coercion_cast(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> bool { + fn try_coercion_cast(&self, fcx: &FnCtxt<'a, 'tcx>) -> bool { fcx.try_coerce(self.expr, self.expr_ty, self.cast_ty, AllowTwoPhase::No).is_ok() } } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn type_is_known_to_be_sized_modulo_regions(&self, ty: Ty<'tcx>, span: Span) -> bool { let lang_item = self.tcx.require_lang_item(lang_items::SizedTraitLangItem); traits::type_known_to_meet_bound_modulo_regions(self, self.param_env, ty, lang_item, span) diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index b894fc8c83c10..6c0deededdc73 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -32,12 +32,12 @@ struct ClosureSignatures<'tcx> { liberated_sig: ty::FnSig<'tcx>, } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_expr_closure( &self, expr: &hir::Expr, _capture: hir::CaptureClause, - decl: &'gcx hir::FnDecl, + decl: &'tcx hir::FnDecl, body_id: hir::BodyId, gen: Option, expected: Expectation<'tcx>, @@ -62,8 +62,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &self, expr: &hir::Expr, opt_kind: Option, - decl: &'gcx hir::FnDecl, - body: &'gcx hir::Body, + decl: &'tcx hir::FnDecl, + body: &'tcx hir::Body, gen: Option, expected_sig: Option>, ) -> Ty<'tcx> { @@ -592,7 +592,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr_def_id: DefId, decl: &hir::FnDecl, ) -> ty::PolyFnSig<'tcx> { - let astconv: &dyn AstConv<'_, '_> = self; + let astconv: &dyn AstConv<'_> = self; // First, convert the types that the user supplied (if any). let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a)); @@ -624,7 +624,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// so should yield an error, but returns back a signature where /// all parameters are of type `TyErr`. fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> { - let astconv: &dyn AstConv<'_, '_> = self; + let astconv: &dyn AstConv<'_> = self; let supplied_arguments = decl.inputs.iter().map(|a| { // Convert the types that the user supplied (if any), but ignore them. diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index f95021f0cb088..e1623fe49e772 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -71,8 +71,8 @@ use syntax::ptr::P; use syntax::symbol::sym; use syntax_pos; -struct Coerce<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct Coerce<'a, 'tcx> { + fcx: &'a FnCtxt<'a, 'tcx>, cause: ObligationCause<'tcx>, use_lub: bool, /// Determines whether or not allow_two_phase_borrow is set on any @@ -84,8 +84,8 @@ struct Coerce<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { allow_two_phase: AllowTwoPhase, } -impl<'a, 'gcx, 'tcx> Deref for Coerce<'a, 'gcx, 'tcx> { - type Target = FnCtxt<'a, 'gcx, 'tcx>; +impl<'a, 'tcx> Deref for Coerce<'a, 'tcx> { + type Target = FnCtxt<'a, 'tcx>; fn deref(&self) -> &Self::Target { &self.fcx } @@ -120,8 +120,8 @@ fn success<'tcx>(adj: Vec>, }) } -impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { - fn new(fcx: &'f FnCtxt<'f, 'gcx, 'tcx>, +impl<'f, 'tcx> Coerce<'f, 'tcx> { + fn new(fcx: &'f FnCtxt<'f, 'tcx>, cause: ObligationCause<'tcx>, allow_two_phase: AllowTwoPhase) -> Self { Coerce { @@ -792,7 +792,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Attempt to coerce an expression to a type, and return the /// adjusted type of the expression, if successful. /// Adjustments are only recorded if the coercion succeeded. @@ -1004,29 +1004,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// } /// let final_ty = coerce.complete(fcx); /// ``` -pub struct CoerceMany<'gcx, 'tcx, 'exprs, E> - where 'gcx: 'tcx, E: 'exprs + AsCoercionSite, -{ +pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> { expected_ty: Ty<'tcx>, final_ty: Option>, - expressions: Expressions<'gcx, 'exprs, E>, + expressions: Expressions<'tcx, 'exprs, E>, pushed: usize, } /// The type of a `CoerceMany` that is storing up the expressions into /// a buffer. We use this in `check/mod.rs` for things like `break`. -pub type DynamicCoerceMany<'gcx, 'tcx> = CoerceMany<'gcx, 'tcx, 'gcx, P>; +pub type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, P>; -enum Expressions<'gcx, 'exprs, E> - where E: 'exprs + AsCoercionSite, -{ - Dynamic(Vec<&'gcx hir::Expr>), +enum Expressions<'tcx, 'exprs, E: AsCoercionSite> { + Dynamic(Vec<&'tcx hir::Expr>), UpFront(&'exprs [E]), } -impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> - where 'gcx: 'tcx, E: 'exprs + AsCoercionSite, -{ +impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { /// The usual case; collect the set of expressions dynamically. /// If the full set of coercion sites is known before hand, /// consider `with_coercion_sites()` instead to avoid allocation. @@ -1045,7 +1039,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> Self::make(expected_ty, Expressions::UpFront(coercion_sites)) } - fn make(expected_ty: Ty<'tcx>, expressions: Expressions<'gcx, 'exprs, E>) -> Self { + fn make(expected_ty: Ty<'tcx>, expressions: Expressions<'tcx, 'exprs, E>) -> Self { CoerceMany { expected_ty, final_ty: None, @@ -1080,9 +1074,9 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> /// calls to `coerce` may come back and add adjustments and things /// if necessary. pub fn coerce<'a>(&mut self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, cause: &ObligationCause<'tcx>, - expression: &'gcx hir::Expr, + expression: &'tcx hir::Expr, expression_ty: Ty<'tcx>) { self.coerce_inner(fcx, @@ -1105,7 +1099,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> /// 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, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, cause: &ObligationCause<'tcx>, augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>), label_unit_as_expected: bool) @@ -1122,9 +1116,9 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> /// is a forced-unit case, and hence `expression_ty` must be /// `Nil`. fn coerce_inner<'a>(&mut self, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, cause: &ObligationCause<'tcx>, - expression: Option<&'gcx hir::Expr>, + expression: Option<&'tcx hir::Expr>, mut expression_ty: Ty<'tcx>, augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>, label_expression_as_expected: bool) @@ -1270,9 +1264,9 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> expected: Ty<'tcx>, found: Ty<'tcx>, err: TypeError<'tcx>, - fcx: &FnCtxt<'a, 'gcx, 'tcx>, + fcx: &FnCtxt<'a, 'tcx>, id: hir::HirId, - expression: Option<(&'gcx hir::Expr, hir::HirId)>, + expression: Option<(&'tcx hir::Expr, hir::HirId)>, ) -> DiagnosticBuilder<'a> { let mut db = fcx.report_mismatched_types(cause, expected, found, err); @@ -1317,7 +1311,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> db } - pub fn complete<'a>(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { + pub fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> { if let Some(final_ty) = self.final_ty { final_ty } else { diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 32ac7cd69e2e3..beaa32b0bd354 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -24,7 +24,7 @@ use super::{Inherited, FnCtxt, potentially_plural_count}; /// - `impl_trait_ref`: the TraitRef corresponding to the trait implementation pub fn compare_impl_method<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_m: &ty::AssocItem, impl_m_span: Span, trait_m: &ty::AssocItem, @@ -76,7 +76,7 @@ pub fn compare_impl_method<'tcx>( } fn compare_predicate_entailment<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_m: &ty::AssocItem, impl_m_span: Span, trait_m: &ty::AssocItem, @@ -359,7 +359,7 @@ fn compare_predicate_entailment<'tcx>( } fn check_region_bounds_on_impl_method<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, span: Span, impl_m: &ty::AssocItem, trait_m: &ty::AssocItem, @@ -410,7 +410,7 @@ fn check_region_bounds_on_impl_method<'tcx>( Ok(()) } -fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>, +fn extract_spans_for_error_reporting<'a, 'tcx>(infcx: &infer::InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, terr: &TypeError<'_>, cause: &ObligationCause<'tcx>, @@ -500,7 +500,7 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a } fn compare_self_type<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_m: &ty::AssocItem, impl_m_span: Span, trait_m: &ty::AssocItem, @@ -585,7 +585,7 @@ fn compare_self_type<'tcx>( } fn compare_number_of_generics<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_: &ty::AssocItem, _impl_span: Span, trait_: &ty::AssocItem, @@ -700,7 +700,7 @@ fn compare_number_of_generics<'tcx>( } fn compare_number_of_method_arguments<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_m: &ty::AssocItem, impl_m_span: Span, trait_m: &ty::AssocItem, @@ -785,7 +785,7 @@ fn compare_number_of_method_arguments<'tcx>( } fn compare_synthetic_generics<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_m: &ty::AssocItem, trait_m: &ty::AssocItem, ) -> Result<(), ErrorReported> { @@ -958,7 +958,7 @@ fn compare_synthetic_generics<'tcx>( } pub fn compare_const_impl<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_c: &ty::AssocItem, impl_c_span: Span, trait_c: &ty::AssocItem, diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 87fc90f53abca..69a3f090b0a8d 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -14,7 +14,7 @@ use errors::{Applicability, DiagnosticBuilder}; use super::method::probe; -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Requires that the two types unify, and prints an error message if // they don't. pub fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) { diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 1e6ae1e030912..8f80c9a9f5bef 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -30,7 +30,7 @@ use syntax_pos::Span; /// cannot do `struct S; impl Drop for S { ... }`). /// pub fn check_drop_impl<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, drop_impl_did: DefId, ) -> Result<(), ErrorReported> { let dtor_self_type = tcx.type_of(drop_impl_did); @@ -65,7 +65,7 @@ pub fn check_drop_impl<'tcx>( } fn ensure_drop_params_and_item_params_correspond<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, drop_impl_did: DefId, drop_impl_ty: Ty<'tcx>, self_type_did: DefId, @@ -141,7 +141,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>( /// Confirms that every predicate imposed by dtor_predicates is /// implied by assuming the predicates attached to self_type_did. fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, drop_impl_did: DefId, dtor_predicates: &ty::GenericPredicates<'tcx>, self_type_did: DefId, @@ -287,8 +287,8 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( /// this conservative assumption (and thus assume the obligation of /// ensuring that they do not access data nor invoke methods of /// values that have been previously dropped). -pub fn check_safety_of_destructor_if_necessary<'a, 'gcx, 'tcx>( - rcx: &mut RegionCtxt<'a, 'gcx, 'tcx>, +pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>( + rcx: &mut RegionCtxt<'a, 'tcx>, ty: Ty<'tcx>, span: Span, body_id: hir::HirId, diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 3785c3c8684b4..bd2db8facd44e 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -12,14 +12,14 @@ use syntax_pos::Span; use super::FnCtxt; use crate::util::nodemap::FxHashMap; -struct InteriorVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct InteriorVisitor<'a, 'tcx: 'a> { + fcx: &'a FnCtxt<'a, 'tcx>, types: FxHashMap, usize>, - region_scope_tree: &'gcx region::ScopeTree, + region_scope_tree: &'tcx region::ScopeTree, expr_count: usize, } -impl<'a, 'gcx, 'tcx> InteriorVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { fn record(&mut self, ty: Ty<'tcx>, scope: Option, @@ -75,7 +75,7 @@ impl<'a, 'gcx, 'tcx> InteriorVisitor<'a, 'gcx, 'tcx> { } } -pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +pub fn resolve_interior<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>, def_id: DefId, body_id: hir::BodyId, interior: Ty<'tcx>) { @@ -136,7 +136,7 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, // This visitor has to have the same visit_expr calls as RegionResolutionVisitor in // librustc/middle/region.rs since `expr_count` is compared against the results // there. -impl<'a, 'gcx, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 0b800fe8247c7..7f690b6e828a8 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -14,7 +14,7 @@ use rustc::hir; use std::iter; fn equate_intrinsic_type<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, it: &hir::ForeignItem, n_tps: usize, abi: Abi, @@ -79,7 +79,7 @@ pub fn intrisic_operation_unsafety(intrinsic: &str) -> hir::Unsafety { /// Remember to add all intrinsics here, in librustc_codegen_llvm/intrinsic.rs, /// and in libcore/intrinsics.rs -pub fn check_intrinsic_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, it: &hir::ForeignItem) { +pub fn check_intrinsic_type<'tcx>(tcx: TyCtxt<'tcx>, it: &hir::ForeignItem) { let param = |n| tcx.mk_ty_param(n, InternedString::intern(&format!("P{}", n))); let name = it.ident.as_str(); @@ -399,7 +399,7 @@ pub fn check_intrinsic_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, it: &hir::ForeignItem } /// Type-check `extern "platform-intrinsic" { ... }` functions. -pub fn check_platform_intrinsic_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, it: &hir::ForeignItem) { +pub fn check_platform_intrinsic_type<'tcx>(tcx: TyCtxt<'tcx>, it: &hir::ForeignItem) { let param = |n| { let name = InternedString::intern(&format!("P{}", n)); tcx.mk_ty_param(n, name) diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 493486321ac2f..25ca4668a1020 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -16,15 +16,15 @@ use syntax_pos::Span; use std::ops::Deref; -struct ConfirmContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct ConfirmContext<'a, 'tcx> { + fcx: &'a FnCtxt<'a, 'tcx>, span: Span, - self_expr: &'gcx hir::Expr, - call_expr: &'gcx hir::Expr, + self_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr, } -impl<'a, 'gcx, 'tcx> Deref for ConfirmContext<'a, 'gcx, 'tcx> { - type Target = FnCtxt<'a, 'gcx, 'tcx>; +impl<'a, 'tcx> Deref for ConfirmContext<'a, 'tcx> { + type Target = FnCtxt<'a, 'tcx>; fn deref(&self) -> &Self::Target { &self.fcx } @@ -35,12 +35,12 @@ pub struct ConfirmResult<'tcx> { pub illegal_sized_bound: bool, } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn confirm_method( &self, span: Span, - self_expr: &'gcx hir::Expr, - call_expr: &'gcx hir::Expr, + self_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr, unadjusted_self_ty: Ty<'tcx>, pick: probe::Pick<'tcx>, segment: &hir::PathSegment, @@ -57,12 +57,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { - fn new(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { + fn new(fcx: &'a FnCtxt<'a, 'tcx>, span: Span, - self_expr: &'gcx hir::Expr, - call_expr: &'gcx hir::Expr) - -> ConfirmContext<'a, 'gcx, 'tcx> { + self_expr: &'tcx hir::Expr, + call_expr: &'tcx hir::Expr) + -> ConfirmContext<'a, 'tcx> { ConfirmContext { fcx, span, @@ -263,7 +263,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { } fn extract_existential_trait_ref(&mut self, self_ty: Ty<'tcx>, mut closure: F) -> R - where F: FnMut(&mut ConfirmContext<'a, 'gcx, 'tcx>, + where F: FnMut(&mut ConfirmContext<'a, 'tcx>, Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>) -> R diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 213d53cf48254..6990277482a1e 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -100,7 +100,7 @@ pub enum CandidateSource { TraitSource(DefId /* trait id */), } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Determines whether the type `self_ty` supports a method name `method_name` or not. pub fn method_exists(&self, method_name: ast::Ident, @@ -178,8 +178,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self_ty: Ty<'tcx>, segment: &hir::PathSegment, span: Span, - call_expr: &'gcx hir::Expr, - self_expr: &'gcx hir::Expr) + call_expr: &'tcx hir::Expr, + self_expr: &'tcx hir::Expr) -> Result, MethodError<'tcx>> { debug!("lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})", segment.ident, @@ -249,7 +249,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { span: Span, method_name: ast::Ident, self_ty: Ty<'tcx>, - call_expr: &'gcx hir::Expr, + call_expr: &'tcx hir::Expr, scope: ProbeScope) -> probe::PickResult<'tcx> { let mode = probe::Mode::MethodCall; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 5aab440dc16d0..3c60ba219fad6 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -45,8 +45,8 @@ pub use self::PickKind::*; #[derive(Clone, Copy)] pub struct IsSuggestion(pub bool); -struct ProbeContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct ProbeContext<'a, 'tcx> { + fcx: &'a FnCtxt<'a, 'tcx>, span: Span, mode: Mode, method_name: Option, @@ -55,7 +55,7 @@ struct ProbeContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { /// This is the OriginalQueryValues for the steps queries /// that are answered in steps. orig_steps_var_values: OriginalQueryValues<'tcx>, - steps: Lrc>>, + steps: Lrc>>, inherent_candidates: Vec>, extension_candidates: Vec>, @@ -79,8 +79,8 @@ struct ProbeContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { is_suggestion: IsSuggestion, } -impl<'a, 'gcx, 'tcx> Deref for ProbeContext<'a, 'gcx, 'tcx> { - type Target = FnCtxt<'a, 'gcx, 'tcx>; +impl<'a, 'tcx> Deref for ProbeContext<'a, 'tcx> { + type Target = FnCtxt<'a, 'tcx>; fn deref(&self) -> &Self::Target { &self.fcx } @@ -200,7 +200,7 @@ pub enum ProbeScope { AllTraits, } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// This is used to offer suggestions to users. It returns methods /// that could have been called which have the desired return /// type. Some effort is made to rule out methods that, if called, @@ -270,7 +270,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { scope: ProbeScope, op: OP) -> Result> - where OP: FnOnce(ProbeContext<'a, 'gcx, 'tcx>) -> Result> + where OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result> { let mut orig_values = OriginalQueryValues::default(); let param_env_and_self_ty = @@ -395,10 +395,10 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { providers.method_autoderef_steps = method_autoderef_steps; } -fn method_autoderef_steps<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'gcx>, +fn method_autoderef_steps<'tcx>( + tcx: TyCtxt<'tcx>, goal: CanonicalTyGoal<'tcx>, -) -> MethodAutoderefStepsResult<'gcx> { +) -> MethodAutoderefStepsResult<'tcx> { debug!("method_autoderef_steps({:?})", goal); tcx.infer_ctxt().enter_with_canonical(DUMMY_SP, &goal, |ref infcx, goal, inference_vars| { @@ -464,16 +464,16 @@ fn method_autoderef_steps<'gcx, 'tcx>( } -impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { - fn new(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +impl<'a, 'tcx> ProbeContext<'a, 'tcx> { + fn new(fcx: &'a FnCtxt<'a, 'tcx>, span: Span, mode: Mode, method_name: Option, return_type: Option>, orig_steps_var_values: OriginalQueryValues<'tcx>, - steps: Lrc>>, + steps: Lrc>>, is_suggestion: IsSuggestion) - -> ProbeContext<'a, 'gcx, 'tcx> { + -> ProbeContext<'a, 'tcx> { ProbeContext { fcx, span, @@ -535,7 +535,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } } - fn assemble_probe(&mut self, self_ty: &Canonical<'gcx, QueryResponse<'gcx, Ty<'gcx>>>) { + fn assemble_probe(&mut self, self_ty: &Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>) { debug!("assemble_probe: self_ty={:?}", self_ty); let lang_items = self.tcx.lang_items(); @@ -811,7 +811,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { fn elaborate_bounds(&mut self, bounds: impl Iterator>, mut mk_cand: F) - where F: for<'b> FnMut(&mut ProbeContext<'b, 'gcx, 'tcx>, + where F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>, ty::PolyTraitRef<'tcx>, ty::AssocItem) { @@ -1045,7 +1045,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { .next() } - fn pick_by_value_method(&mut self, step: &CandidateStep<'gcx>, self_ty: Ty<'tcx>) + fn pick_by_value_method(&mut self, step: &CandidateStep<'tcx>, self_ty: Ty<'tcx>) -> Option> { //! For each type `T` in the step list, this attempts to find a @@ -1076,7 +1076,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } fn pick_autorefd_method(&mut self, - step: &CandidateStep<'gcx>, + step: &CandidateStep<'tcx>, self_ty: Ty<'tcx>, mutbl: hir::Mutability) -> Option> { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index c4157bb60e9da..71bcf2bc05638 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -24,7 +24,7 @@ use std::cmp::Ordering; use super::{MethodError, NoMatchData, CandidateSource}; use super::probe::Mode; -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool { let tcx = self.tcx; match ty.sty { @@ -69,7 +69,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { item_name: ast::Ident, source: SelfSource<'b>, error: MethodError<'tcx>, - args: Option<&'gcx [hir::Expr]>, + args: Option<&'tcx [hir::Expr]>, ) { let orig_span = span; let mut span = span; @@ -775,12 +775,12 @@ impl Ord for TraitInfo { } /// Retrieves all traits in this crate and any dependent crates. -pub fn all_traits<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>) -> Vec { +pub fn all_traits<'tcx>(tcx: TyCtxt<'tcx>) -> Vec { tcx.all_traits(LOCAL_CRATE).iter().map(|&def_id| TraitInfo { def_id }).collect() } /// Computes all traits in this crate and any dependent crates. -fn compute_all_traits<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>) -> Vec { +fn compute_all_traits<'tcx>(tcx: TyCtxt<'tcx>) -> Vec { use hir::itemlikevisit; let mut traits = vec![]; @@ -818,7 +818,7 @@ fn compute_all_traits<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>) -> Vec { let mut external_mods = FxHashSet::default(); fn handle_external_res( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, traits: &mut Vec, external_mods: &mut FxHashSet, res: Res, @@ -857,16 +857,16 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { } } -struct UsePlacementFinder<'tcx, 'gcx> { +struct UsePlacementFinder<'tcx> { target_module: hir::HirId, span: Option, found_use: bool, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, } -impl UsePlacementFinder<'tcx, 'gcx> { +impl UsePlacementFinder<'tcx> { fn check( - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, krate: &'tcx hir::Crate, target_module: hir::HirId, ) -> (Option, bool) { @@ -881,7 +881,7 @@ impl UsePlacementFinder<'tcx, 'gcx> { } } -impl hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx, 'gcx> { +impl hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> { fn visit_mod( &mut self, module: &'tcx hir::Mod, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d62536ccb4669..4a25c7323c37f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -194,8 +194,8 @@ impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> { /// Here, the function `foo()` and the closure passed to /// `bar()` will each have their own `FnCtxt`, but they will /// share the inherited fields. -pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - infcx: InferCtxt<'a, 'gcx, 'tcx>, +pub struct Inherited<'a, 'tcx: 'a> { + infcx: InferCtxt<'a, 'tcx>, tables: MaybeInProgressTables<'a, 'tcx>, @@ -214,7 +214,7 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { // decision. We keep these deferred resolutions grouped by the // def-id of the closure, so that once we decide, we can easily go // back and process them. - deferred_call_resolutions: RefCell>>>, + deferred_call_resolutions: RefCell>>>, deferred_cast_checks: RefCell>>, @@ -237,8 +237,8 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { body_id: Option, } -impl<'a, 'gcx, 'tcx> Deref for Inherited<'a, 'gcx, 'tcx> { - type Target = InferCtxt<'a, 'gcx, 'tcx>; +impl<'a, 'tcx> Deref for Inherited<'a, 'tcx> { + type Target = InferCtxt<'a, 'tcx>; fn deref(&self) -> &Self::Target { &self.infcx } @@ -262,7 +262,7 @@ pub enum Expectation<'tcx> { ExpectRvalueLikeUnsized(Ty<'tcx>), } -impl<'a, 'gcx, 'tcx> Expectation<'tcx> { +impl<'a, 'tcx> Expectation<'tcx> { // Disregard "castable to" expectations because they // can lead us astray. Consider for example `if cond // {22} else {c} as u8` -- if we propagate the @@ -279,7 +279,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { // an expected type. Otherwise, we might write parts of the type // when checking the 'then' block which are incompatible with the // 'else' branch. - fn adjust_for_branches(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Expectation<'tcx> { + fn adjust_for_branches(&self, fcx: &FnCtxt<'a, 'tcx>) -> Expectation<'tcx> { match *self { ExpectHasType(ety) => { let ety = fcx.shallow_resolve(ety); @@ -315,7 +315,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { /// which still is useful, because it informs integer literals and the like. /// See the test case `test/run-pass/coerce-expect-unsized.rs` and #20169 /// for examples of where this comes up,. - fn rvalue_hint(fcx: &FnCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> { + fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> { match fcx.tcx.struct_tail(ty).sty { ty::Slice(_) | ty::Str | ty::Dynamic(..) => { ExpectRvalueLikeUnsized(ty) @@ -327,7 +327,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { // Resolves `expected` by a single level if it is a variable. If // there is no expected type or resolution is not possible (e.g., // no constraints yet present), just returns `None`. - fn resolve(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Expectation<'tcx> { + fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) -> Expectation<'tcx> { match self { NoExpectation => NoExpectation, ExpectCastableToType(t) => { @@ -342,7 +342,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { } } - fn to_option(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Option> { + fn to_option(self, fcx: &FnCtxt<'a, 'tcx>) -> Option> { match self.resolve(fcx) { NoExpectation => None, ExpectCastableToType(ty) | @@ -355,7 +355,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { /// a **hard constraint** (i.e., something that must be satisfied /// for the program to type-check). `only_has_type` will return /// such a constraint, if it exists. - fn only_has_type(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) -> Option> { + fn only_has_type(self, fcx: &FnCtxt<'a, 'tcx>) -> Option> { match self.resolve(fcx) { ExpectHasType(ty) => Some(ty), NoExpectation | ExpectCastableToType(_) | ExpectRvalueLikeUnsized(_) => None, @@ -364,7 +364,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> { /// Like `only_has_type`, but instead of returning `None` if no /// hard constraint exists, creates a fresh type variable. - fn coercion_target_type(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, span: Span) -> Ty<'tcx> { + fn coercion_target_type(self, fcx: &FnCtxt<'a, 'tcx>, span: Span) -> Ty<'tcx> { self.only_has_type(fcx) .unwrap_or_else(|| { fcx.next_ty_var(TypeVariableOrigin { @@ -491,21 +491,21 @@ impl Diverges { } } -pub struct BreakableCtxt<'gcx: 'tcx, 'tcx> { +pub struct BreakableCtxt<'tcx> { may_break: bool, // this is `null` for loops where break with a value is illegal, // such as `while`, `for`, and `while let` - coerce: Option>, + coerce: Option>, } -pub struct EnclosingBreakables<'gcx: 'tcx, 'tcx> { - stack: Vec>, +pub struct EnclosingBreakables<'tcx> { + stack: Vec>, by_id: HirIdMap, } -impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> { - fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'gcx, 'tcx> { +impl<'tcx> EnclosingBreakables<'tcx> { + fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'tcx> { let ix = *self.by_id.get(&target_id).unwrap_or_else(|| { bug!("could not find enclosing breakable with id {}", target_id); }); @@ -513,7 +513,7 @@ impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> { } } -pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { +pub struct FnCtxt<'a, 'tcx: 'a> { body_id: hir::HirId, /// The parameter environment used for proving trait obligations @@ -530,7 +530,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// expects the types within the function to be consistent. err_count_on_creation: usize, - ret_coercion: Option>>, + ret_coercion: Option>>, ret_coercion_span: RefCell>, yield_ty: Option>, @@ -573,13 +573,13 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// Whether any child nodes have any type errors. has_errors: Cell, - enclosing_breakables: RefCell>, + enclosing_breakables: RefCell>, - inh: &'a Inherited<'a, 'gcx, 'tcx>, + inh: &'a Inherited<'a, 'tcx>, } -impl<'a, 'gcx, 'tcx> Deref for FnCtxt<'a, 'gcx, 'tcx> { - type Target = Inherited<'a, 'gcx, 'tcx>; +impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> { + type Target = Inherited<'a, 'tcx>; fn deref(&self) -> &Self::Target { &self.inh } @@ -587,14 +587,14 @@ impl<'a, 'gcx, 'tcx> Deref for FnCtxt<'a, 'gcx, 'tcx> { /// Helper type of a temporary returned by `Inherited::build(...)`. /// Necessary because we can't write the following bound: -/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(Inherited<'b, 'gcx, 'tcx>)`. -pub struct InheritedBuilder<'gcx, 'tcx> { - infcx: infer::InferCtxtBuilder<'gcx, 'tcx>, +/// `F: for<'b, 'tcx> where 'tcx FnOnce(Inherited<'b, 'tcx>)`. +pub struct InheritedBuilder<'tcx> { + infcx: infer::InferCtxtBuilder<'tcx>, def_id: DefId, } -impl Inherited<'_, 'gcx, 'tcx> { - pub fn build(tcx: TyCtxt<'gcx, 'gcx>, def_id: DefId) -> InheritedBuilder<'gcx, 'tcx> { +impl Inherited<'_, 'tcx> { + pub fn build(tcx: TyCtxt<'tcx>, def_id: DefId) -> InheritedBuilder<'tcx> { let hir_id_root = if def_id.is_local() { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); DefId::local(hir_id.owner) @@ -609,18 +609,18 @@ impl Inherited<'_, 'gcx, 'tcx> { } } -impl<'gcx, 'tcx> InheritedBuilder<'gcx, 'tcx> { - fn enter(&'tcx mut self, f: F) -> R +impl<'tcx> InheritedBuilder<'tcx> { + fn enter(&mut self, f: F) -> R where - F: for<'a> FnOnce(Inherited<'a, 'gcx, 'tcx>) -> R, + F: for<'a> FnOnce(Inherited<'a, 'tcx>) -> R, { let def_id = self.def_id; self.infcx.enter(|infcx| f(Inherited::new(infcx, def_id))) } } -impl Inherited<'a, 'gcx, 'tcx> { - fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> Self { +impl Inherited<'a, 'tcx> { + fn new(infcx: InferCtxt<'a, 'tcx>, def_id: DefId) -> Self { let tcx = infcx.tcx; let item_id = tcx.hir().as_local_hir_id(def_id); let body_id = item_id.and_then(|id| tcx.hir().maybe_body_owned_by_by_hir_id(id)); @@ -686,7 +686,7 @@ impl Inherited<'a, 'gcx, 'tcx> { } struct CheckItemTypesVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { @@ -697,33 +697,33 @@ impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { } } -pub fn check_wf_new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Result<(), ErrorReported> { +pub fn check_wf_new<'tcx>(tcx: TyCtxt<'tcx>) -> Result<(), ErrorReported> { tcx.sess.track_errors(|| { let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx); tcx.hir().krate().par_visit_all_item_likes(&mut visit); }) } -fn check_mod_item_types<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_item_types<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx }); } -fn typeck_item_bodies<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) { +fn typeck_item_bodies<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) { debug_assert!(crate_num == LOCAL_CRATE); tcx.par_body_owners(|body_owner_def_id| { tcx.ensure().typeck_tables_of(body_owner_def_id); }); } -fn check_item_well_formed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +fn check_item_well_formed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { wfcheck::check_item_well_formed(tcx, def_id); } -fn check_trait_item_well_formed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +fn check_trait_item_well_formed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { wfcheck::check_trait_item(tcx, def_id); } -fn check_impl_item_well_formed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +fn check_impl_item_well_formed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { wfcheck::check_impl_item(tcx, def_id); } @@ -743,7 +743,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn adt_destructor<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option { +fn adt_destructor<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option { tcx.calculate_dtor(def_id, &mut dropck::check_drop_impl) } @@ -757,7 +757,7 @@ fn adt_destructor<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, id: hir::HirId, ) -> Option<(hir::BodyId, Option<&'tcx hir::FnDecl>)> { match tcx.hir().get_by_hir_id(id) { @@ -797,7 +797,7 @@ fn primary_body_of<'tcx>( } } -fn has_typeck_tables<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn has_typeck_tables<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { // Closures' tables come from their outermost function, // as they are part of the same "inference environment". let outer_def_id = tcx.closure_base_def_id(def_id); @@ -809,11 +809,11 @@ fn has_typeck_tables<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { primary_body_of(tcx, id).is_some() } -fn used_trait_imports<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx DefIdSet { +fn used_trait_imports<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx DefIdSet { &*tcx.typeck_tables_of(def_id).used_trait_imports } -fn typeck_tables_of<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::TypeckTables<'tcx> { +fn typeck_tables_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::TypeckTables<'tcx> { // Closures' tables come from their outermost function, // as they are part of the same "inference environment". let outer_def_id = tcx.closure_base_def_id(def_id); @@ -913,19 +913,19 @@ fn typeck_tables_of<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::T tables } -fn check_abi<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, span: Span, abi: Abi) { +fn check_abi<'tcx>(tcx: TyCtxt<'tcx>, span: Span, abi: Abi) { if !tcx.sess.target.target.is_abi_supported(abi) { struct_span_err!(tcx.sess, span, E0570, "The ABI `{}` is not supported for the current target", abi).emit() } } -struct GatherLocalsVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct GatherLocalsVisitor<'a, 'tcx: 'a> { + fcx: &'a FnCtxt<'a, 'tcx>, parent_id: hir::HirId, } -impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> { fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option>) -> Ty<'tcx> { match ty_opt { None => { @@ -949,13 +949,13 @@ impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { +impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } // Add explicitly-declared locals. - fn visit_local(&mut self, local: &'gcx hir::Local) { + fn visit_local(&mut self, local: &'tcx hir::Local) { let local_ty = match local.ty { Some(ref ty) => { let o_ty = self.fcx.to_ty(&ty); @@ -990,7 +990,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> { } // Add pattern bindings. - fn visit_pat(&mut self, p: &'gcx hir::Pat) { + fn visit_pat(&mut self, p: &'tcx hir::Pat) { if let PatKind::Binding(_, _, ident, _) = p.node { let var_ty = self.assign(p.span, p.hir_id, None); @@ -1010,7 +1010,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> { } // Don't descend into the bodies of nested closures - fn visit_fn(&mut self, _: intravisit::FnKind<'gcx>, _: &'gcx hir::FnDecl, + fn visit_fn(&mut self, _: intravisit::FnKind<'tcx>, _: &'tcx hir::FnDecl, _: hir::BodyId, _: Span, _: hir::HirId) { } } @@ -1034,14 +1034,14 @@ struct GeneratorTypes<'tcx> { /// /// * ... /// * inherited: other fields inherited from the enclosing fn (if any) -fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, +fn check_fn<'a, 'tcx>(inherited: &'a Inherited<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, fn_sig: ty::FnSig<'tcx>, - decl: &'gcx hir::FnDecl, + decl: &'tcx hir::FnDecl, fn_id: hir::HirId, - body: &'gcx hir::Body, + body: &'tcx hir::Body, can_be_generator: Option) - -> (FnCtxt<'a, 'gcx, 'tcx>, Option>) + -> (FnCtxt<'a, 'tcx>, Option>) { let mut fn_sig = fn_sig.clone(); @@ -1281,7 +1281,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, (fcx, gen_ty) } -fn check_struct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, id: hir::HirId, span: Span) { +fn check_struct<'tcx>(tcx: TyCtxt<'tcx>, id: hir::HirId, span: Span) { 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 @@ -1295,7 +1295,7 @@ fn check_struct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, id: hir::HirId, span: Span) { check_packed(tcx, span, def_id); } -fn check_union<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, id: hir::HirId, span: Span) { +fn check_union<'tcx>(tcx: TyCtxt<'tcx>, id: hir::HirId, span: Span) { 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 @@ -1304,7 +1304,7 @@ fn check_union<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, id: hir::HirId, span: Span) { check_packed(tcx, span, def_id); } -fn check_opaque<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, span: Span) { +fn check_opaque<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, span: Span) { if let Err(partially_expanded_type) = tcx.try_expand_impl_trait_type(def_id, substs) { let mut err = struct_span_err!( tcx.sess, span, E0720, @@ -1320,7 +1320,7 @@ fn check_opaque<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, substs: SubstsRef< } } -pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, it: &'tcx hir::Item) { +pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) { debug!( "check_item_type(it.hir_id={}, it.name={})", it.hir_id, @@ -1419,7 +1419,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, it: &'tcx hir::Item) { } } -fn maybe_check_static_with_link_section(tcx: TyCtxt<'_, '_>, id: DefId, span: Span) { +fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: DefId, span: Span) { // Only restricted on wasm32 target for now if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") { return @@ -1457,14 +1457,14 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_, '_>, id: DefId, span: Sp } } -fn check_on_unimplemented<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_def_id: DefId, item: &hir::Item) { +fn check_on_unimplemented<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, item: &hir::Item) { let item_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id); // an error would be reported if this fails. let _ = traits::OnUnimplementedDirective::of_item(tcx, trait_def_id, item_def_id); } fn report_forbidden_specialization<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem, parent_impl: DefId, ) { @@ -1491,7 +1491,7 @@ fn report_forbidden_specialization<'tcx>( } fn check_specialization_validity<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def: &ty::TraitDef, trait_item: &ty::AssocItem, impl_id: DefId, @@ -1518,7 +1518,7 @@ fn check_specialization_validity<'tcx>( } fn check_impl_items_against_trait<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_span: Span, impl_id: DefId, impl_trait_ref: ty::TraitRef<'tcx>, @@ -1680,7 +1680,7 @@ fn check_impl_items_against_trait<'tcx>( /// Checks whether a type can be represented in memory. In particular, it /// identifies types that contain themselves without indirection through a /// pointer, which would mean their size is unbounded. -fn check_representable<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, item_def_id: DefId) -> bool { +fn check_representable<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, item_def_id: DefId) -> bool { let rty = tcx.type_of(item_def_id); // Check that it is possible to represent this type. This call identifies @@ -1702,7 +1702,7 @@ fn check_representable<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, item_def_id: Def return true; } -pub fn check_simd<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, def_id: DefId) { +pub fn check_simd<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, def_id: DefId) { let t = tcx.type_of(def_id); if let ty::Adt(def, substs) = t.sty { if def.is_struct() { @@ -1731,7 +1731,7 @@ pub fn check_simd<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, def_id: DefId) { } } -fn check_packed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, def_id: DefId) { +fn check_packed<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, def_id: DefId) { let repr = tcx.adt_def(def_id).repr; if repr.packed() { for attr in tcx.get_attrs(def_id).iter() { @@ -1756,7 +1756,7 @@ fn check_packed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, def_id: DefId) { } fn check_packed_inner<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, stack: &mut Vec, ) -> bool { @@ -1787,7 +1787,7 @@ fn check_packed_inner<'tcx>( false } -fn check_transparent<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, def_id: DefId) { +fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, def_id: DefId) { let adt = tcx.adt_def(def_id); if !adt.repr.transparent() { return; @@ -1868,7 +1868,7 @@ fn check_transparent<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sp: Span, def_id: DefId) { #[allow(trivial_numeric_casts)] pub fn check_enum<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, sp: Span, vs: &'tcx [hir::Variant], id: hir::HirId, @@ -1933,8 +1933,8 @@ pub fn check_enum<'tcx>( check_transparent(tcx, sp, def_id); } -fn report_unexpected_variant_res<'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'tcx>, +fn report_unexpected_variant_res<'tcx>( + tcx: TyCtxt<'tcx>, res: Res, span: Span, qpath: &QPath, @@ -1945,8 +1945,8 @@ fn report_unexpected_variant_res<'gcx, 'tcx>( hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false))); } -impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } @@ -2074,11 +2074,11 @@ enum TupleArgumentsFlag { TupleArguments, } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn new(inh: &'a Inherited<'a, 'gcx, 'tcx>, +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, 'gcx, 'tcx> { + -> FnCtxt<'a, 'tcx> { FnCtxt { body_id, param_env, @@ -2167,22 +2167,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn record_deferred_call_resolution(&self, closure_def_id: DefId, - r: DeferredCallResolution<'gcx, 'tcx>) { + 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> + -> Vec> { let mut deferred_call_resolutions = self.deferred_call_resolutions.borrow_mut(); deferred_call_resolutions.remove(&closure_def_id).unwrap_or(vec![]) } pub fn tag(&self) -> String { - let self_ptr: *const FnCtxt<'_, '_, '_> = self; - format!("{:?}", self_ptr) + format!("{:p}", self) } pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> { @@ -2667,7 +2666,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn lookup_indexing(&self, expr: &hir::Expr, - base_expr: &'gcx hir::Expr, + base_expr: &'tcx hir::Expr, base_ty: Ty<'tcx>, idx_ty: Ty<'tcx>, needs: Needs) @@ -2694,7 +2693,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn try_index_step(&self, expr: &hir::Expr, base_expr: &hir::Expr, - autoderef: &Autoderef<'a, 'gcx, 'tcx>, + autoderef: &Autoderef<'a, 'tcx>, needs: Needs, index_ty: Ty<'tcx>) -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> @@ -2820,7 +2819,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { sp: Span, expr_sp: Span, method: Result, ()>, - args_no_rcvr: &'gcx [hir::Expr], + args_no_rcvr: &'tcx [hir::Expr], tuple_arguments: TupleArgumentsFlag, expected: Expectation<'tcx>) -> Ty<'tcx> { @@ -2881,7 +2880,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn obligations_for_self_ty<'b>(&'b self, self_ty: ty::TyVid) -> impl Iterator, traits::PredicateObligation<'tcx>)> - + Captures<'gcx> + 'b + + Captures<'tcx> + 'b { // FIXME: consider using `sub_root_var` here so we // can see through subtyping. @@ -2930,7 +2929,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr_sp: Span, fn_inputs: &[Ty<'tcx>], expected_arg_tys: &[Ty<'tcx>], - args: &'gcx [hir::Expr], + args: &'tcx [hir::Expr], c_variadic: bool, tuple_arguments: TupleArgumentsFlag, def_span: Option) { @@ -3198,20 +3197,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn check_expr_eq_type(&self, - expr: &'gcx hir::Expr, + 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: &'gcx hir::Expr, + 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: &'gcx hir::Expr, + 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); @@ -3246,7 +3245,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn check_expr_coercable_to_type(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, expected: Ty<'tcx>) -> Ty<'tcx> { let ty = self.check_expr_with_hint(expr, expected); // checks don't need two phase @@ -3254,22 +3253,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn check_expr_with_hint(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, expected: Ty<'tcx>) -> Ty<'tcx> { self.check_expr_with_expectation(expr, ExpectHasType(expected)) } fn check_expr_with_expectation(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, expected: Expectation<'tcx>) -> Ty<'tcx> { self.check_expr_with_expectation_and_needs(expr, expected, Needs::None) } - fn check_expr(&self, expr: &'gcx hir::Expr) -> Ty<'tcx> { + fn check_expr(&self, expr: &'tcx hir::Expr) -> Ty<'tcx> { self.check_expr_with_expectation(expr, NoExpectation) } - fn check_expr_with_needs(&self, expr: &'gcx hir::Expr, needs: Needs) -> Ty<'tcx> { + fn check_expr_with_needs(&self, expr: &'tcx hir::Expr, needs: Needs) -> Ty<'tcx> { self.check_expr_with_expectation_and_needs(expr, NoExpectation, needs) } @@ -3344,10 +3343,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Checks a method call. fn check_method_call(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, segment: &hir::PathSegment, span: Span, - args: &'gcx [hir::Expr], + args: &'tcx [hir::Expr], expected: Expectation<'tcx>, needs: Needs) -> Ty<'tcx> { let rcvr = &args[0]; @@ -3386,7 +3385,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected) } - fn check_return_expr(&self, return_expr: &'gcx hir::Expr) { + fn check_return_expr(&self, return_expr: &'tcx hir::Expr) { let ret_coercion = self.ret_coercion .as_ref() @@ -3405,9 +3404,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Check field access expressions fn check_field(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, needs: Needs, - base: &'gcx hir::Expr, + 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, @@ -3682,7 +3681,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr_id: hir::HirId, span: Span, variant: &'tcx ty::VariantDef, - ast_fields: &'gcx [hir::Field], + ast_fields: &'tcx [hir::Field], check_completeness: bool) -> bool { let tcx = self.tcx; @@ -3788,8 +3787,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn check_struct_fields_on_error(&self, - fields: &'gcx [hir::Field], - base_expr: &'gcx Option>) { + fields: &'tcx [hir::Field], + base_expr: &'tcx Option>) { for field in fields { self.check_expr(&field.expr); } @@ -3860,8 +3859,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr: &hir::Expr, expected: Expectation<'tcx>, qpath: &QPath, - fields: &'gcx [hir::Field], - base_expr: &'gcx Option>) -> Ty<'tcx> + fields: &'tcx [hir::Field], + base_expr: &'tcx Option>) -> Ty<'tcx> { // Find the relevant variant let (variant, adt_ty) = @@ -3927,7 +3926,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// 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: &'gcx hir::Expr, + expr: &'tcx hir::Expr, expected: Expectation<'tcx>, needs: Needs) -> Ty<'tcx> { debug!(">> type-checking: expr={:?} expected={:?}", @@ -3975,7 +3974,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn check_expr_kind( &self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, expected: Expectation<'tcx>, needs: Needs ) -> Ty<'tcx> { @@ -4648,10 +4647,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// The expected type is `()` and is passsed to the function for the purposes of diagnostics. fn check_assign( &self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, expected: Expectation<'tcx>, - lhs: &'gcx hir::Expr, - rhs: &'gcx hir::Expr, + lhs: &'tcx hir::Expr, + rhs: &'tcx hir::Expr, ) -> Ty<'tcx> { let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace); let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty); @@ -4786,8 +4785,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } pub fn check_decl_initializer(&self, - local: &'gcx hir::Local, - init: &'gcx hir::Expr) -> Ty<'tcx> + 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). @@ -4813,7 +4812,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - pub fn check_decl_local(&self, local: &'gcx hir::Local) { + pub fn check_decl_local(&self, local: &'tcx hir::Local) { let t = self.local_ty(local.span, local.hir_id).decl_ty; self.write_ty(local.hir_id, t); @@ -4836,7 +4835,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) { + pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) { // Don't do all the complex logic below for `DeclItem`. match stmt.node { hir::StmtKind::Item(..) => return, @@ -4871,7 +4870,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.has_errors.set(self.has_errors.get() | old_has_errors); } - pub fn check_block_no_value(&self, blk: &'gcx 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)); @@ -4883,7 +4882,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn check_block_with_expected(&self, - blk: &'gcx hir::Block, + blk: &'tcx hir::Block, expected: Expectation<'tcx>) -> Ty<'tcx> { let prev = { let mut fcx_ps = self.ps.borrow_mut(); @@ -5075,7 +5074,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn suggest_mismatched_types_on_tail( &self, err: &mut DiagnosticBuilder<'tcx>, - expression: &'gcx hir::Expr, + expression: &'tcx hir::Expr, expected: Ty<'tcx>, found: Ty<'tcx>, cause_span: Span, @@ -5158,7 +5157,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// it suggests adding a semicolon. fn suggest_missing_semicolon(&self, err: &mut DiagnosticBuilder<'tcx>, - expression: &'gcx hir::Expr, + expression: &'tcx hir::Expr, expected: Ty<'tcx>, cause_span: Span) { if expected.is_unit() { @@ -5255,7 +5254,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// with `expected_ty`. If so, it suggests removing the semicolon. fn consider_hint_about_removing_semicolon( &self, - blk: &'gcx hir::Block, + blk: &'tcx hir::Block, expected_ty: Ty<'tcx>, err: &mut DiagnosticBuilder<'_>, ) { @@ -5271,7 +5270,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn could_remove_semicolon( &self, - blk: &'gcx hir::Block, + blk: &'tcx hir::Block, expected_ty: Ty<'tcx>, ) -> Option { // Be helpful when the user wrote `{... expr;}` and @@ -5634,8 +5633,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn with_breakable_ctxt R, R>(&self, id: hir::HirId, - ctxt: BreakableCtxt<'gcx, 'tcx>, f: F) - -> (BreakableCtxt<'gcx, 'tcx>, R) { + ctxt: BreakableCtxt<'tcx>, f: F) + -> (BreakableCtxt<'tcx>, R) { let index; { let mut enclosing_breakables = self.enclosing_breakables.borrow_mut(); @@ -5692,7 +5691,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } -pub fn check_bounds_are_used<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, generics: &ty::Generics, ty: Ty<'tcx>) { +pub fn check_bounds_are_used<'tcx>(tcx: TyCtxt<'tcx>, generics: &ty::Generics, ty: Ty<'tcx>) { let own_counts = generics.own_counts(); debug!( "check_bounds_are_used(n_tys={}, n_cts={}, ty={:?})", diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 51a9103f73d8b..1c129882d9c10 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -11,13 +11,13 @@ use syntax_pos::Span; use syntax::ast::Ident; use rustc::hir; -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Checks a `a = b` pub fn check_binop_assign(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, op: hir::BinOp, - lhs_expr: &'gcx hir::Expr, - rhs_expr: &'gcx hir::Expr) -> Ty<'tcx> + 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); @@ -44,10 +44,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// Checks a potentially overloaded binary operator. pub fn check_binop(&self, - expr: &'gcx hir::Expr, + expr: &'tcx hir::Expr, op: hir::BinOp, - lhs_expr: &'gcx hir::Expr, - rhs_expr: &'gcx hir::Expr) -> Ty<'tcx> + lhs_expr: &'tcx hir::Expr, + rhs_expr: &'tcx hir::Expr) -> Ty<'tcx> { let tcx = self.tcx; @@ -105,9 +105,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn enforce_builtin_binop_types(&self, - lhs_expr: &'gcx hir::Expr, + lhs_expr: &'tcx hir::Expr, lhs_ty: Ty<'tcx>, - rhs_expr: &'gcx hir::Expr, + rhs_expr: &'tcx hir::Expr, rhs_ty: Ty<'tcx>, op: hir::BinOp) -> Ty<'tcx> @@ -143,9 +143,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn check_overloaded_binop(&self, - expr: &'gcx hir::Expr, - lhs_expr: &'gcx hir::Expr, - rhs_expr: &'gcx hir::Expr, + 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>) @@ -515,8 +515,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// to print the normal "implementation of `std::ops::Add` might be missing" note fn check_str_addition( &self, - lhs_expr: &'gcx hir::Expr, - rhs_expr: &'gcx hir::Expr, + lhs_expr: &'tcx hir::Expr, + rhs_expr: &'tcx hir::Expr, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>, err: &mut errors::DiagnosticBuilder<'_>, @@ -612,7 +612,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } pub fn check_user_unop(&self, - ex: &'gcx hir::Expr, + ex: &'tcx hir::Expr, operand_ty: Ty<'tcx>, op: hir::UnOp) -> Ty<'tcx> diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index c3b6fb21e38d6..bf3381d206b5a 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -107,8 +107,8 @@ macro_rules! ignore_err { /////////////////////////////////////////////////////////////////////////// // PUBLIC ENTRY POINTS -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn regionck_expr(&self, body: &'gcx hir::Body) { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { + pub fn regionck_expr(&self, body: &'tcx hir::Body) { let subject = self.tcx.hir().body_owner_def_id(body.id()); let id = body.value.hir_id; let mut rcx = RegionCtxt::new( @@ -161,7 +161,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// rest of type check and because sometimes we need type /// inference to have completed before we can determine which /// constraints to add. - pub fn regionck_fn(&self, fn_id: hir::HirId, body: &'gcx hir::Body) { + pub fn regionck_fn(&self, fn_id: hir::HirId, body: &'tcx hir::Body) { debug!("regionck_fn(id={})", fn_id); let subject = self.tcx.hir().body_owner_def_id(body.id()); let hir_id = body.value.hir_id; @@ -191,10 +191,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /////////////////////////////////////////////////////////////////////////// // INTERNALS -pub struct RegionCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - pub fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +pub struct RegionCtxt<'a, 'tcx> { + pub fcx: &'a FnCtxt<'a, 'tcx>, - pub region_scope_tree: &'gcx region::ScopeTree, + pub region_scope_tree: &'tcx region::ScopeTree, outlives_environment: OutlivesEnvironment<'tcx>, @@ -212,8 +212,8 @@ pub struct RegionCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { subject_def_id: DefId, } -impl<'a, 'gcx, 'tcx> Deref for RegionCtxt<'a, 'gcx, 'tcx> { - type Target = FnCtxt<'a, 'gcx, 'tcx>; +impl<'a, 'tcx> Deref for RegionCtxt<'a, 'tcx> { + type Target = FnCtxt<'a, 'tcx>; fn deref(&self) -> &Self::Target { &self.fcx } @@ -222,14 +222,14 @@ impl<'a, 'gcx, 'tcx> Deref for RegionCtxt<'a, 'gcx, 'tcx> { pub struct RepeatingScope(hir::HirId); pub struct Subject(DefId); -impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { pub fn new( - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, + fcx: &'a FnCtxt<'a, 'tcx>, RepeatingScope(initial_repeating_scope): RepeatingScope, initial_body_id: hir::HirId, Subject(subject): Subject, param_env: ty::ParamEnv<'tcx>, - ) -> RegionCtxt<'a, 'gcx, 'tcx> { + ) -> RegionCtxt<'a, 'tcx> { let region_scope_tree = fcx.tcx.region_scope_tree(subject); let outlives_environment = OutlivesEnvironment::new(param_env); RegionCtxt { @@ -302,7 +302,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { fn visit_fn_body( &mut self, id: hir::HirId, // the id of the fn itself - body: &'gcx hir::Body, + body: &'tcx hir::Body, span: Span, ) { // When we enter a function, we can derive @@ -437,7 +437,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { // (..) FIXME(#3238) should use visit_pat, not visit_arm/visit_local, // However, right now we run into an issue whereby some free // regions are not properly related if they appear within the @@ -446,14 +446,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { // hierarchy, and in particular the relationships between free // regions, until regionck, as described in #3238. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } fn visit_fn( &mut self, - fk: intravisit::FnKind<'gcx>, - _: &'gcx hir::FnDecl, + fk: intravisit::FnKind<'tcx>, + _: &'tcx hir::FnDecl, body_id: hir::BodyId, span: Span, hir_id: hir::HirId, @@ -486,7 +486,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { //visit_pat: visit_pat, // (..) see above - fn visit_arm(&mut self, arm: &'gcx hir::Arm) { + fn visit_arm(&mut self, arm: &'tcx hir::Arm) { // see above for p in &arm.pats { self.constrain_bindings_in_pat(p); @@ -494,14 +494,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { intravisit::walk_arm(self, arm); } - fn visit_local(&mut self, l: &'gcx hir::Local) { + fn visit_local(&mut self, l: &'tcx hir::Local) { // see above self.constrain_bindings_in_pat(&l.pat); self.link_local(l); intravisit::walk_local(self, l); } - fn visit_expr(&mut self, expr: &'gcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr) { debug!( "regionck::visit_expr(e={:?}, repeating_scope={:?})", expr, self.repeating_scope @@ -717,7 +717,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { fn constrain_cast(&mut self, cast_expr: &hir::Expr, source_expr: &hir::Expr) { debug!( "constrain_cast(cast_expr={:?}, source_expr={:?})", @@ -758,7 +758,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { } } - fn check_expr_fn_block(&mut self, expr: &'gcx hir::Expr, body_id: hir::BodyId) { + fn check_expr_fn_block(&mut self, expr: &'tcx hir::Expr, body_id: hir::BodyId) { let repeating_scope = self.set_repeating_scope(body_id.hir_id); intravisit::walk_expr(self, expr); self.set_repeating_scope(repeating_scope); @@ -830,7 +830,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { /// Creates a temporary `MemCategorizationContext` and pass it to the closure. fn with_mc(&self, f: F) -> R where - F: for<'b> FnOnce(mc::MemCategorizationContext<'b, 'gcx, 'tcx>) -> R, + F: for<'b> FnOnce(mc::MemCategorizationContext<'b, 'tcx>) -> R, { f(mc::MemCategorizationContext::with_infer( &self.infcx, diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 2f3861b8d3478..bba108aa282a9 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -45,8 +45,8 @@ use rustc_data_structures::fx::FxIndexMap; use syntax::ast; use syntax_pos::Span; -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn closure_analyze(&self, body: &'gcx hir::Body) { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { + pub fn closure_analyze(&self, body: &'tcx hir::Body) { InferBorrowKindVisitor { fcx: self }.visit_body(body); // it's our job to process these. @@ -54,16 +54,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } -struct InferBorrowKindVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct InferBorrowKindVisitor<'a, 'tcx> { + fcx: &'a FnCtxt<'a, 'tcx>, } -impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { +impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_expr(&mut self, expr: &'gcx hir::Expr) { + fn visit_expr(&mut self, expr: &'tcx hir::Expr) { if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.node { let body = self.fcx.tcx.hir().body(body_id); self.visit_body(body); @@ -75,7 +75,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn analyze_closure( &self, closure_hir_id: hir::HirId, @@ -282,8 +282,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } -struct InferBorrowKind<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, +struct InferBorrowKind<'a, 'tcx> { + fcx: &'a FnCtxt<'a, 'tcx>, // The def-id of the closure whose kind and upvar accesses are being inferred. closure_def_id: DefId, @@ -305,7 +305,7 @@ struct InferBorrowKind<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { adjust_upvar_captures: ty::UpvarCaptureMap<'tcx>, } -impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> { fn adjust_upvar_borrow_kind_for_consume( &mut self, cmt: &mc::cmt_<'tcx>, @@ -581,7 +581,7 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { fn consume( &mut self, _consume_id: hir::HirId, @@ -651,6 +651,6 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> { } } -fn var_name(tcx: TyCtxt<'_, '_>, var_hir_id: hir::HirId) -> ast::Name { +fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> ast::Name { tcx.hir().name_by_hir_id(var_hir_id) } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 83711a32e23a5..8baf6d03e1d9f 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -23,19 +23,19 @@ use rustc::hir; /// This is necessary because we can't write the following bound: /// /// ```rust -/// F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(FnCtxt<'b, 'gcx, 'tcx>) +/// F: for<'b, 'tcx> where 'tcx FnOnce(FnCtxt<'b, 'tcx>) /// ``` -struct CheckWfFcxBuilder<'gcx, 'tcx> { - inherited: super::InheritedBuilder<'gcx, 'tcx>, +struct CheckWfFcxBuilder<'tcx> { + inherited: super::InheritedBuilder<'tcx>, id: hir::HirId, span: Span, param_env: ty::ParamEnv<'tcx>, } -impl<'gcx, 'tcx> CheckWfFcxBuilder<'gcx, 'tcx> { - fn with_fcx(&'tcx mut self, f: F) +impl<'tcx> CheckWfFcxBuilder<'tcx> { + fn with_fcx(&mut self, f: F) where - F: for<'b> FnOnce(&FnCtxt<'b, 'gcx, 'tcx>, TyCtxt<'gcx, 'gcx>) -> Vec>, + F: for<'b> FnOnce(&FnCtxt<'b, 'tcx>, TyCtxt<'tcx>) -> Vec>, { let id = self.id; let span = self.span; @@ -68,7 +68,7 @@ impl<'gcx, 'tcx> CheckWfFcxBuilder<'gcx, 'tcx> { /// We do this check as a pre-pass before checking fn bodies because if these constraints are /// not included it frequently leads to confusing errors in fn bodies. So it's better to check /// the types first. -pub fn check_item_well_formed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +pub fn check_item_well_formed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let item = tcx.hir().expect_item_by_hir_id(hir_id); @@ -156,7 +156,7 @@ pub fn check_item_well_formed<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { } } -pub fn check_trait_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +pub fn check_trait_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let trait_item = tcx.hir().expect_trait_item(hir_id); @@ -167,7 +167,7 @@ pub fn check_trait_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig); } -pub fn check_impl_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +pub fn check_impl_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let impl_item = tcx.hir().expect_impl_item(hir_id); @@ -179,7 +179,7 @@ pub fn check_impl_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { } fn check_associated_item<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_id: hir::HirId, span: Span, sig_if_method: Option<&hir::MethodSig>, @@ -227,18 +227,18 @@ fn check_associated_item<'tcx>( }) } -fn for_item<'gcx: 'tcx, 'tcx>( - tcx: TyCtxt<'gcx, 'gcx>, +fn for_item<'tcx>( + tcx: TyCtxt<'tcx>, item: &hir::Item, -) -> CheckWfFcxBuilder<'gcx, 'tcx> { +) -> CheckWfFcxBuilder<'tcx> { for_id(tcx, item.hir_id, item.span) } -fn for_id<'gcx: 'tcx, 'tcx>( - tcx: TyCtxt<'gcx, 'gcx>, +fn for_id<'tcx>( + tcx: TyCtxt<'tcx>, id: hir::HirId, span: Span, -) -> CheckWfFcxBuilder<'gcx, 'tcx> { +) -> CheckWfFcxBuilder<'tcx> { let def_id = tcx.hir().local_def_id_from_hir_id(id); CheckWfFcxBuilder { inherited: Inherited::build(tcx, def_id), @@ -250,12 +250,12 @@ fn for_id<'gcx: 'tcx, 'tcx>( /// In a type definition, we check that to ensure that the types of the fields are well-formed. fn check_type_defn<'tcx, F>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item: &hir::Item, all_sized: bool, mut lookup_fields: F, ) where - F: for<'fcx, 'gcx, 'tcx2> FnMut(&FnCtxt<'fcx, 'gcx, 'tcx2>) -> Vec>, + F: for<'fcx> FnMut(&FnCtxt<'fcx, 'tcx>) -> Vec>, { for_item(tcx, item).with_fcx(|fcx, fcx_tcx| { let variants = lookup_fields(fcx); @@ -323,7 +323,7 @@ fn check_type_defn<'tcx, F>( }); } -fn check_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item) { +fn check_trait<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item) { debug!("check_trait: {:?}", item.hir_id); let trait_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id); @@ -346,7 +346,7 @@ fn check_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item) { }); } -fn check_item_fn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item) { +fn check_item_fn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item) { for_item(tcx, item).with_fcx(|fcx, tcx| { let def_id = fcx.tcx.hir().local_def_id_from_hir_id(item.hir_id); let sig = fcx.tcx.fn_sig(def_id); @@ -359,7 +359,7 @@ fn check_item_fn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item) { } fn check_item_type<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_id: hir::HirId, ty_span: Span, allow_foreign_ty: bool, @@ -392,7 +392,7 @@ fn check_item_type<'tcx>( } fn check_impl<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item: &hir::Item, ast_self_ty: &hir::Ty, ast_trait_ref: &Option, @@ -433,9 +433,9 @@ fn check_impl<'tcx>( } /// Checks where-clauses and inline bounds that are declared on `def_id`. -fn check_where_clauses<'gcx, 'fcx, 'tcx>( - tcx: TyCtxt<'gcx, 'gcx>, - fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, +fn check_where_clauses<'tcx, 'fcx>( + tcx: TyCtxt<'tcx>, + fcx: &FnCtxt<'fcx, 'tcx>, span: Span, def_id: DefId, return_ty: Option>, @@ -586,9 +586,9 @@ fn check_where_clauses<'gcx, 'fcx, 'tcx>( } } -fn check_fn_or_method<'fcx, 'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'gcx>, - fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, +fn check_fn_or_method<'fcx, 'tcx>( + tcx: TyCtxt<'tcx>, + fcx: &FnCtxt<'fcx, 'tcx>, span: Span, sig: ty::PolyFnSig<'tcx>, def_id: DefId, @@ -629,9 +629,9 @@ fn check_fn_or_method<'fcx, 'gcx, 'tcx>( /// fn b() -> Foo { .. } /// ``` /// -fn check_existential_types<'fcx, 'gcx, 'tcx>( - tcx: TyCtxt<'gcx, 'gcx>, - fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, +fn check_existential_types<'fcx, 'tcx>( + tcx: TyCtxt<'tcx>, + fcx: &FnCtxt<'fcx, 'tcx>, fn_def_id: DefId, span: Span, ty: Ty<'tcx>, @@ -768,7 +768,7 @@ fn check_existential_types<'fcx, 'gcx, 'tcx>( substituted_predicates } -fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, +fn check_method_receiver<'fcx, 'tcx>(fcx: &FnCtxt<'fcx, 'tcx>, method_sig: &hir::MethodSig, method: &ty::AssocItem, self_ty: Ty<'tcx>) @@ -851,8 +851,8 @@ fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, /// N.B., there are cases this function returns `true` but causes an error to be emitted, /// particularly when `receiver_ty` derefs to a type that is the same as `self_ty` but has the /// wrong lifetime. Be careful of this if you are calling this function speculatively. -fn receiver_is_valid<'fcx, 'tcx, 'gcx>( - fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, +fn receiver_is_valid<'fcx, 'tcx>( + fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'tcx>, self_ty: Ty<'tcx>, @@ -944,7 +944,7 @@ fn receiver_is_valid<'fcx, 'tcx, 'gcx>( } fn check_variances_for_type_defn<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item: &hir::Item, hir_generics: &hir::Generics, ) { @@ -985,7 +985,7 @@ fn check_variances_for_type_defn<'tcx>( } } -fn report_bivariance<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, span: Span, param_name: ast::Name) { +fn report_bivariance<'tcx>(tcx: TyCtxt<'tcx>, span: Span, param_name: ast::Name) { let mut err = error_392(tcx, span, param_name); let suggested_marker_id = tcx.lang_items().phantom_data(); @@ -998,7 +998,7 @@ fn report_bivariance<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, span: Span, param_name: ast: err.emit(); } -fn reject_shadowing_parameters(tcx: TyCtxt<'_, '_>, def_id: DefId) { +fn reject_shadowing_parameters(tcx: TyCtxt<'_>, def_id: DefId) { let generics = tcx.generics_of(def_id); let parent = tcx.generics_of(generics.parent.unwrap()); let impl_params: FxHashMap<_, _> = parent.params.iter().flat_map(|param| match param.kind { @@ -1028,8 +1028,8 @@ 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, 'gcx, 'tcx>( - fcx: &FnCtxt<'a, 'gcx, 'tcx>, +fn check_false_global_bounds<'a, 'tcx>( + fcx: &FnCtxt<'a, 'tcx>, span: Span, id: hir::HirId) { @@ -1064,11 +1064,11 @@ fn check_false_global_bounds<'a, 'gcx, 'tcx>( } pub struct CheckTypeWellFormedVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } -impl CheckTypeWellFormedVisitor<'gcx> { - pub fn new(tcx: TyCtxt<'gcx, 'gcx>) -> CheckTypeWellFormedVisitor<'gcx> { +impl CheckTypeWellFormedVisitor<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>) -> CheckTypeWellFormedVisitor<'tcx> { CheckTypeWellFormedVisitor { tcx, } @@ -1107,7 +1107,7 @@ struct AdtField<'tcx> { span: Span, } -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> { let fields = struct_def.fields().iter().map(|field| { let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id)); @@ -1145,7 +1145,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn error_392<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, span: Span, param_name: ast::Name, ) -> DiagnosticBuilder<'tcx> { @@ -1155,7 +1155,7 @@ fn error_392<'tcx>( err } -fn error_194(tcx: TyCtxt<'_, '_>, span: Span, trait_decl_span: Span, name: &str) { +fn error_194(tcx: TyCtxt<'_>, span: Span, trait_decl_span: Span, name: &str) { struct_span_err!(tcx.sess, span, E0194, "type parameter `{}` shadows another type parameter of the same name", name) diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index cc9097ea8c83b..5be822897407b 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -31,8 +31,8 @@ use syntax_pos::Span; // so instead all of the replacement happens at the end in // resolve_type_vars_in_body, which creates a new TypeTables which // doesn't contain any inference types. -impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::TypeckTables<'gcx> { +impl<'a, 'tcx> FnCtxt<'a, 'tcx> { + pub fn resolve_type_vars_in_body(&self, body: &'tcx hir::Body) -> &'tcx ty::TypeckTables<'tcx> { let item_id = self.tcx.hir().body_owner(body.id()); let item_def_id = self.tcx.hir().local_def_id(item_id); @@ -97,22 +97,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // there, it applies a few ad-hoc checks that were not convenient to // do elsewhere. -struct WritebackCx<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { - fcx: &'cx FnCtxt<'cx, 'gcx, 'tcx>, +struct WritebackCx<'cx, 'tcx: 'cx> { + fcx: &'cx FnCtxt<'cx, 'tcx>, - tables: ty::TypeckTables<'gcx>, + tables: ty::TypeckTables<'tcx>, - body: &'gcx hir::Body, + body: &'tcx hir::Body, rustc_dump_user_substs: bool, } -impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { fn new( - fcx: &'cx FnCtxt<'cx, 'gcx, 'tcx>, - body: &'gcx hir::Body, + fcx: &'cx FnCtxt<'cx, 'tcx>, + body: &'tcx hir::Body, rustc_dump_user_substs: bool, - ) -> WritebackCx<'cx, 'gcx, 'tcx> { + ) -> WritebackCx<'cx, 'tcx> { let owner = body.id().hir_id; WritebackCx { @@ -123,11 +123,11 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } } - fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.fcx.tcx } - fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'gcx>) { + fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) { debug!("write_ty_to_tables({:?}, {:?})", hir_id, ty); assert!(!ty.needs_infer() && !ty.has_placeholders()); self.tables.node_types_mut().insert(hir_id, ty); @@ -234,12 +234,12 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { // below. In general, a function is made into a `visitor` if it must // traffic in node-ids or update tables in the type context etc. -impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { +impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::None } - fn visit_expr(&mut self, e: &'gcx hir::Expr) { + fn visit_expr(&mut self, e: &'tcx hir::Expr) { self.fix_scalar_builtin_expr(e); self.fix_index_builtin_expr(e); @@ -268,12 +268,12 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { intravisit::walk_expr(self, e); } - fn visit_block(&mut self, b: &'gcx hir::Block) { + fn visit_block(&mut self, b: &'tcx hir::Block) { self.visit_node_id(b.span, b.hir_id); intravisit::walk_block(self, b); } - fn visit_pat(&mut self, p: &'gcx hir::Pat) { + fn visit_pat(&mut self, p: &'tcx hir::Pat) { match p.node { hir::PatKind::Binding(..) => { if let Some(&bm) = self.fcx.tables.borrow().pat_binding_modes().get(p.hir_id) { @@ -298,14 +298,14 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { intravisit::walk_pat(self, p); } - fn visit_local(&mut self, l: &'gcx hir::Local) { + fn visit_local(&mut self, l: &'tcx hir::Local) { intravisit::walk_local(self, l); let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty; let var_ty = self.resolve(&var_ty, &l.span); self.write_ty_to_tables(l.hir_id, var_ty); } - fn visit_ty(&mut self, hir_ty: &'gcx hir::Ty) { + fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty) { intravisit::walk_ty(self, hir_ty); let ty = self.fcx.node_ty(hir_ty.hir_id); let ty = self.resolve(&ty, &hir_ty.span); @@ -313,7 +313,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { } } -impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { fn visit_upvar_capture_map(&mut self) { for (upvar_id, upvar_capture) in self.fcx.tables.borrow().upvar_capture_map.iter() { let new_upvar_capture = match *upvar_capture { @@ -746,7 +746,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { fn resolve(&self, x: &T, span: &dyn Locatable) -> T::Lifted where - T: TypeFoldable<'tcx> + ty::Lift<'gcx>, + T: TypeFoldable<'tcx> + ty::Lift<'tcx>, { let x = x.fold_with(&mut Resolver::new(self.fcx, span, self.body)); if let Some(lifted) = self.tcx().lift_to_global(&x) { @@ -762,24 +762,24 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } trait Locatable { - fn to_span(&self, tcx: TyCtxt<'_, '_>) -> Span; + fn to_span(&self, tcx: TyCtxt<'_>) -> Span; } impl Locatable for Span { - fn to_span(&self, _: TyCtxt<'_, '_>) -> Span { + fn to_span(&self, _: TyCtxt<'_>) -> Span { *self } } impl Locatable for DefIndex { - fn to_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn to_span(&self, tcx: TyCtxt<'_>) -> Span { let hir_id = tcx.hir().def_index_to_hir_id(*self); tcx.hir().span_by_hir_id(hir_id) } } impl Locatable for hir::HirId { - fn to_span(&self, tcx: TyCtxt<'_, '_>) -> Span { + fn to_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.hir().span_by_hir_id(*self) } } @@ -788,19 +788,19 @@ impl Locatable for hir::HirId { // The Resolver. This is the type folding engine that detects // unresolved types and so forth. -struct Resolver<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { - tcx: TyCtxt<'gcx, 'tcx>, - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, +struct Resolver<'cx, 'tcx: 'cx> { + tcx: TyCtxt<'tcx>, + infcx: &'cx InferCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, - body: &'gcx hir::Body, + body: &'tcx hir::Body, } -impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> { +impl<'cx, 'tcx> Resolver<'cx, 'tcx> { fn new( - fcx: &'cx FnCtxt<'cx, 'gcx, 'tcx>, + fcx: &'cx FnCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, - body: &'gcx hir::Body, - ) -> Resolver<'cx, 'gcx, 'tcx> { + body: &'tcx hir::Body, + ) -> Resolver<'cx, 'tcx> { Resolver { tcx: fcx.tcx, infcx: fcx, @@ -818,8 +818,8 @@ impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> { } } -impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Resolver<'cx, 'gcx, 'tcx> { - fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx> { +impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { + fn tcx<'a>(&'a self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 5f4f88d954490..c724500b9ede8 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -13,7 +13,7 @@ use rustc::util::nodemap::DefIdSet; use rustc_data_structures::fx::FxHashMap; -pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) { let mut used_trait_imports = DefIdSet::default(); for &body_id in tcx.hir().krate().bodies.keys() { let item_def_id = tcx.hir().body_owner_def_id(body_id); @@ -46,7 +46,7 @@ impl ItemLikeVisitor<'v> for CheckVisitor<'tcx> { } struct CheckVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, used_trait_imports: DefIdSet, } @@ -70,7 +70,7 @@ impl CheckVisitor<'tcx> { } } -fn unused_crates_lint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +fn unused_crates_lint<'tcx>(tcx: TyCtxt<'tcx>) { let lint = lint::builtin::UNUSED_EXTERN_CRATES; // Collect first the crates that are completely unused. These we @@ -195,7 +195,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } struct CollectExternCrateVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, crates_to_lint: &'a mut Vec, } diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 1eb3d108f786c..a690eefdf1343 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -17,7 +17,7 @@ use rustc::hir::def_id::DefId; use hir::Node; use rustc::hir::{self, ItemKind}; -pub fn check_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_def_id: DefId) { +pub fn check_trait<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) { Checker { tcx, trait_def_id } .check(tcx.lang_items().drop_trait(), visit_implementation_of_drop) .check(tcx.lang_items().copy_trait(), visit_implementation_of_copy) @@ -27,14 +27,14 @@ pub fn check_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_def_id: DefId) { } struct Checker<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, } impl<'tcx> Checker<'tcx> { fn check(&self, trait_def_id: Option, mut f: F) -> &Self where - F: FnMut(TyCtxt<'tcx, 'tcx>, DefId), + F: FnMut(TyCtxt<'tcx>, DefId), { if Some(self.trait_def_id) == trait_def_id { for &impl_id in self.tcx.hir().trait_impls(self.trait_def_id) { @@ -46,7 +46,7 @@ impl<'tcx> Checker<'tcx> { } } -fn visit_implementation_of_drop<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_did: DefId) { +fn visit_implementation_of_drop<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) { if let ty::Adt(..) = tcx.type_of(impl_did).sty { /* do nothing */ } else { @@ -74,7 +74,7 @@ fn visit_implementation_of_drop<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_did: DefId) } } -fn visit_implementation_of_copy<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_did: DefId) { +fn visit_implementation_of_copy<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) { debug!("visit_implementation_of_copy: impl_did={:?}", impl_did); let impl_hir_id = if let Some(n) = tcx.hir().as_local_hir_id(impl_did) { @@ -141,7 +141,7 @@ fn visit_implementation_of_copy<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_did: DefId) } } -fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx, 'tcx>, impl_did: DefId) { +fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: DefId) { debug!("visit_implementation_of_coerce_unsized: impl_did={:?}", impl_did); @@ -154,7 +154,7 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx, 'tcx>, impl_did: Def } } -fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_did: DefId) { +fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) { debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did); if impl_did.is_local() { @@ -322,7 +322,7 @@ fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl } } -pub fn coerce_unsized_info<'gcx>(gcx: TyCtxt<'gcx, 'gcx>, impl_did: DefId) -> CoerceUnsizedInfo { +pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did); let coerce_unsized_trait = gcx.lang_items().coerce_unsized_trait().unwrap(); @@ -355,9 +355,9 @@ pub fn coerce_unsized_info<'gcx>(gcx: TyCtxt<'gcx, 'gcx>, impl_did: DefId) -> Co gcx.infer_ctxt().enter(|infcx| { let cause = ObligationCause::misc(span, impl_hir_id); - let check_mutbl = |mt_a: ty::TypeAndMut<'gcx>, - mt_b: ty::TypeAndMut<'gcx>, - mk_ptr: &dyn Fn(Ty<'gcx>) -> Ty<'gcx>| { + let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, + mt_b: ty::TypeAndMut<'tcx>, + mk_ptr: &dyn Fn(Ty<'tcx>) -> Ty<'tcx>| { if (mt_a.mutbl, mt_b.mutbl) == (hir::MutImmutable, hir::MutMutable) { infcx.report_mismatched_types(&cause, mk_ptr(mt_b.ty), diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index d6c2d56a9adf7..6088c03fc0681 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -18,7 +18,7 @@ use syntax_pos::Span; /// On-demand query: yields a map containing all types mapped to their inherent impls. pub fn crate_inherent_impls<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, crate_num: CrateNum, ) -> &'tcx CrateInherentImpls { assert_eq!(crate_num, LOCAL_CRATE); @@ -33,7 +33,7 @@ pub fn crate_inherent_impls<'tcx>( } /// On-demand query: yields a vector of the inherent impls for a specific type. -pub fn inherent_impls<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty_def_id: DefId) -> &'tcx [DefId] { +pub fn inherent_impls<'tcx>(tcx: TyCtxt<'tcx>, ty_def_id: DefId) -> &'tcx [DefId] { assert!(ty_def_id.is_local()); // NB. Until we adopt the red-green dep-tracking algorithm (see @@ -68,7 +68,7 @@ pub fn inherent_impls<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty_def_id: DefId) -> &'tcx } struct InherentCollect<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impls_map: CrateInherentImpls, } diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index d557a9c871b12..aae1b1777a30f 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -5,14 +5,14 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::traits::{self, IntercrateMode}; use rustc::ty::TyCtxt; -pub fn crate_inherent_impls_overlap_check<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) { +pub fn crate_inherent_impls_overlap_check<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) { assert_eq!(crate_num, LOCAL_CRATE); let krate = tcx.hir().krate(); krate.visit_all_item_likes(&mut InherentOverlapChecker { tcx }); } struct InherentOverlapChecker<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl InherentOverlapChecker<'tcx> { diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 3be46722ecccd..7816d8e2ba550 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -18,7 +18,7 @@ mod inherent_impls_overlap; mod orphan; mod unsafety; -fn check_impl<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: HirId) { +fn check_impl<'tcx>(tcx: TyCtxt<'tcx>, hir_id: HirId) { let impl_def_id = tcx.hir().local_def_id_from_hir_id(hir_id); // If there are no traits, then this implementation must have a @@ -41,7 +41,7 @@ fn check_impl<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: HirId) { } fn enforce_trait_manually_implementable( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, impl_def_id: DefId, trait_def_id: DefId, ) { @@ -97,7 +97,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<'_, '_>, + tcx: TyCtxt<'_>, impl_def_id: DefId, trait_def_id: DefId, ) { @@ -132,7 +132,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn coherent_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { +fn coherent_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) { let impls = tcx.hir().trait_impls(def_id); for &impl_id in impls { check_impl(tcx, impl_id); @@ -143,7 +143,7 @@ fn coherent_trait<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) { builtin::check_trait(tcx, def_id); } -pub fn check_coherence<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check_coherence<'tcx>(tcx: TyCtxt<'tcx>) { for &trait_def_id in tcx.hir().krate().trait_impls.keys() { tcx.ensure().coherent_trait(trait_def_id); } @@ -159,7 +159,7 @@ pub fn check_coherence<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { /// Overlap: no two impls for the same trait are implemented for the /// same type. Likewise, no two inherent impls for a given type /// constructor provide a method with the same name. -fn check_impl_overlap<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: HirId) { +fn check_impl_overlap<'tcx>(tcx: TyCtxt<'tcx>, hir_id: HirId) { let impl_def_id = tcx.hir().local_def_id_from_hir_id(hir_id); let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); let trait_def_id = trait_ref.def_id; diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 4e81102fd3b84..43063d7b8d12a 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -6,13 +6,13 @@ use rustc::ty::{self, TyCtxt}; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir; -pub fn check<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check<'tcx>(tcx: TyCtxt<'tcx>) { let mut orphan = OrphanChecker { tcx }; tcx.hir().krate().visit_all_item_likes(&mut orphan); } struct OrphanChecker<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index c3a97bc538941..c41a0e1514e68 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -5,13 +5,13 @@ use rustc::ty::TyCtxt; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::{self, Unsafety}; -pub fn check<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn check<'tcx>(tcx: TyCtxt<'tcx>) { let mut unsafety = UnsafetyChecker { tcx }; tcx.hir().krate().visit_all_item_likes(&mut unsafety); } struct UnsafetyChecker<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl UnsafetyChecker<'tcx> { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index e1af8d8f46f70..542ced1595319 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -56,7 +56,7 @@ struct OnlySelfBounds(bool); /////////////////////////////////////////////////////////////////////////// // Main entry point -fn collect_mod_item_types<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn collect_mod_item_types<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module( module_def_id, &mut CollectItemTypesVisitor { tcx }.as_deep_visitor() @@ -97,14 +97,14 @@ pub fn provide(providers: &mut Providers<'_>) { /// `get_type_parameter_bounds` requests, drawing the information from /// the AST (`hir::Generics`), recursively. pub struct ItemCtxt<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_def_id: DefId, } /////////////////////////////////////////////////////////////////////////// struct CollectItemTypesVisitor<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { @@ -161,7 +161,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { // Utility types and common code for the above passes. impl ItemCtxt<'tcx> { - pub fn new(tcx: TyCtxt<'tcx, 'tcx>, item_def_id: DefId) -> ItemCtxt<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> ItemCtxt<'tcx> { ItemCtxt { tcx, item_def_id } } @@ -170,8 +170,8 @@ impl ItemCtxt<'tcx> { } } -impl AstConv<'tcx, 'tcx> for ItemCtxt<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { +impl AstConv<'tcx> for ItemCtxt<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -254,7 +254,7 @@ impl AstConv<'tcx, 'tcx> for ItemCtxt<'tcx> { } fn type_param_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, (item_def_id, def_id): (DefId, DefId), ) -> &'tcx ty::GenericPredicates<'tcx> { use rustc::hir::*; @@ -381,7 +381,7 @@ impl ItemCtxt<'tcx> { /// parameter with ID `param_id`. We use this so as to avoid running /// `ast_ty_to_ty`, because we want to avoid triggering an all-out /// conversion of the type to avoid inducing unnecessary cycles. -fn is_param<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ast_ty: &hir::Ty, param_id: hir::HirId) -> bool { +fn is_param<'tcx>(tcx: TyCtxt<'tcx>, ast_ty: &hir::Ty, param_id: hir::HirId) -> bool { if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node { match path.res { Res::SelfTy(Some(def_id), None) | Res::Def(DefKind::TyParam, def_id) => { @@ -394,7 +394,7 @@ fn is_param<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ast_ty: &hir::Ty, param_id: hir::HirI } } -fn convert_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item_id: hir::HirId) { +fn convert_item<'tcx>(tcx: TyCtxt<'tcx>, item_id: hir::HirId) { let it = tcx.hir().expect_item_by_hir_id(item_id); debug!("convert: item {} with id {}", it.ident, it.hir_id); let def_id = tcx.hir().local_def_id_from_hir_id(item_id); @@ -476,7 +476,7 @@ fn convert_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item_id: hir::HirId) { } } -fn convert_trait_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_item_id: hir::HirId) { +fn convert_trait_item<'tcx>(tcx: TyCtxt<'tcx>, trait_item_id: hir::HirId) { let trait_item = tcx.hir().expect_trait_item(trait_item_id); let def_id = tcx.hir().local_def_id_from_hir_id(trait_item.hir_id); tcx.generics_of(def_id); @@ -497,7 +497,7 @@ fn convert_trait_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_item_id: hir::HirId) tcx.predicates_of(def_id); } -fn convert_impl_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_item_id: hir::HirId) { +fn convert_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item_id: hir::HirId) { let def_id = tcx.hir().local_def_id_from_hir_id(impl_item_id); tcx.generics_of(def_id); tcx.type_of(def_id); @@ -507,7 +507,7 @@ fn convert_impl_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, impl_item_id: hir::HirId) { } } -fn convert_variant_ctor<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ctor_id: hir::HirId) { +fn convert_variant_ctor<'tcx>(tcx: TyCtxt<'tcx>, ctor_id: hir::HirId) { let def_id = tcx.hir().local_def_id_from_hir_id(ctor_id); tcx.generics_of(def_id); tcx.type_of(def_id); @@ -515,7 +515,7 @@ fn convert_variant_ctor<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ctor_id: hir::HirId) { } fn convert_enum_variant_types<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, variants: &[hir::Variant], ) { @@ -567,7 +567,7 @@ fn convert_enum_variant_types<'tcx>( } fn convert_variant<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, variant_did: Option, ctor_did: Option, ident: Ident, @@ -623,7 +623,7 @@ fn convert_variant<'tcx>( ) } -fn adt_def<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::AdtDef { +fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AdtDef { use rustc::hir::*; let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); @@ -691,7 +691,7 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::AdtDef { /// of `trait_def_id` are converted and stored. This also ensures that /// the transitive super-predicates are converted. fn super_predicates_of<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, trait_def_id: DefId, ) -> &'tcx ty::GenericPredicates<'tcx> { debug!("super_predicates(trait_def_id={:?})", trait_def_id); @@ -744,7 +744,7 @@ fn super_predicates_of<'tcx>( }) } -fn trait_def<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::TraitDef { +fn trait_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::TraitDef { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let item = tcx.hir().expect_item_by_hir_id(hir_id); @@ -775,9 +775,9 @@ fn trait_def<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::TraitDef tcx.arena.alloc(def) } -fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, node: Node<'tcx>) -> Option { +fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option { struct LateBoundRegionsDetector<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, outer_index: ty::DebruijnIndex, has_late_bound_regions: Option, } @@ -834,7 +834,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, node: Node<'tcx>) -> Op } fn has_late_bound_regions<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, generics: &'tcx hir::Generics, decl: &'tcx hir::FnDecl, ) -> Option { @@ -883,7 +883,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, node: Node<'tcx>) -> Op } } -fn generics_of<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Generics { +fn generics_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::Generics { use rustc::hir::*; let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); @@ -1126,7 +1126,7 @@ fn generics_of<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Generi }) } -fn report_assoc_ty_on_inherent_impl<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, span: Span) { +fn report_assoc_ty_on_inherent_impl<'tcx>(tcx: TyCtxt<'tcx>, span: Span) { span_err!( tcx.sess, span, @@ -1135,7 +1135,7 @@ fn report_assoc_ty_on_inherent_impl<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, span: Span) { ); } -fn type_of<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { +fn type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { checked_type_of(tcx, def_id, true).unwrap() } @@ -1144,7 +1144,7 @@ fn type_of<'tcx>(tcx: TyCtxt<'tcx, '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, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, fail: bool, ) -> Option> { @@ -1472,13 +1472,13 @@ pub fn checked_type_of<'tcx>( }) } -fn find_existential_constraints<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { +fn find_existential_constraints<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { use rustc::hir::{ImplItem, Item, TraitItem}; debug!("find_existential_constraints({:?})", def_id); struct ConstraintLocator<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, // (first found type span, actual type, mapping from the existential type's generic // parameters to the concrete type's generic parameters) @@ -1690,7 +1690,7 @@ fn find_existential_constraints<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> } } -fn fn_sig<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig<'tcx> { +fn fn_sig<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::PolyFnSig<'tcx> { use rustc::hir::*; use rustc::hir::Node::*; @@ -1766,7 +1766,7 @@ fn fn_sig<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig<'tcx> { } } -fn impl_trait_ref<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option> { +fn impl_trait_ref<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option> { let icx = ItemCtxt::new(tcx, def_id); let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); @@ -1781,7 +1781,7 @@ fn impl_trait_ref<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> hir::ImplPolarity { +fn impl_polarity<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> hir::ImplPolarity { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); match tcx.hir().expect_item_by_hir_id(hir_id).node { hir::ItemKind::Impl(_, polarity, ..) => polarity, @@ -1795,7 +1795,7 @@ fn impl_polarity<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> hir::ImplPolar /// screen out those that do not appear in any where-clauses etc using /// `resolve_lifetime::early_bound_lifetimes`. fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, generics: &'a hir::Generics, ) -> impl Iterator + Captures<'tcx> { generics @@ -1813,7 +1813,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( /// lifetime constraints. This includes all predicates returned by `explicit_predicates_of`, plus /// inferred constraints concerning which regions outlive other regions. fn predicates_defined_on<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> &'tcx ty::GenericPredicates<'tcx> { debug!("predicates_defined_on({:?})", def_id); @@ -1843,7 +1843,7 @@ fn predicates_defined_on<'tcx>( /// 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, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> &'tcx ty::GenericPredicates<'tcx> { let mut result = tcx.predicates_defined_on(def_id); @@ -1873,7 +1873,7 @@ fn predicates_of<'tcx>( /// Returns a list of user-specified type predicates for the definition with ID `def_id`. /// N.B., this does not include any implied/inferred constraints. fn explicit_predicates_of<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> &'tcx ty::GenericPredicates<'tcx> { use rustc::hir::*; @@ -2214,7 +2214,7 @@ fn explicit_predicates_of<'tcx>( /// predicates) to one (`T: Foo`) to many (`T: Bar` adds `T: Bar` /// and `::X == i32`). fn predicates_from_bound<'tcx>( - astconv: &dyn AstConv<'tcx, 'tcx>, + astconv: &dyn AstConv<'tcx>, param_ty: Ty<'tcx>, bound: &hir::GenericBound, ) -> Vec<(ty::Predicate<'tcx>, Span)> { @@ -2236,7 +2236,7 @@ fn predicates_from_bound<'tcx>( } fn compute_sig_of_foreign_fn_decl<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, decl: &hir::FnDecl, abi: abi::Abi, @@ -2280,7 +2280,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( fty } -fn is_foreign_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { +fn is_foreign_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { match tcx.hir().get_if_local(def_id) { Some(Node::ForeignItem(..)) => true, Some(_) => false, @@ -2288,7 +2288,7 @@ fn is_foreign_item<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { } } -fn static_mutability<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option { +fn static_mutability<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option { match tcx.hir().get_if_local(def_id) { Some(Node::Item(&hir::Item { node: hir::ItemKind::Static(_, mutbl, _), .. @@ -2302,7 +2302,7 @@ fn static_mutability<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option, + tcx: TyCtxt<'_>, id: DefId, attr: &ast::Attribute, whitelist: &FxHashMap>, @@ -2396,7 +2396,7 @@ fn from_target_feature( } } -fn linkage_by_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, name: &str) -> Linkage { +fn linkage_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Linkage { use rustc::mir::mono::Linkage::*; // Use the names from src/llvm/docs/LangRef.rst here. Most types are only @@ -2431,7 +2431,7 @@ fn linkage_by_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId, name: &str) -> } } -fn codegen_fn_attrs<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, id: DefId) -> CodegenFnAttrs { +fn codegen_fn_attrs<'tcx>(tcx: TyCtxt<'tcx>, id: DefId) -> CodegenFnAttrs { let attrs = tcx.get_attrs(id); let mut codegen_fn_attrs = CodegenFnAttrs::new(); diff --git a/src/librustc_typeck/constrained_generic_params.rs b/src/librustc_typeck/constrained_generic_params.rs index 3d424ce89dbc5..79a04b9423a8e 100644 --- a/src/librustc_typeck/constrained_generic_params.rs +++ b/src/librustc_typeck/constrained_generic_params.rs @@ -87,7 +87,7 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector { } pub fn identify_constrained_generic_params<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, predicates: &ty::GenericPredicates<'tcx>, impl_trait_ref: Option>, input_parameters: &mut FxHashSet, @@ -138,7 +138,7 @@ pub fn identify_constrained_generic_params<'tcx>( /// by 0. I should probably pick a less tangled example, but I can't /// think of any. pub fn setup_constraining_predicates<'tcx>( - tcx: TyCtxt<'_, '_>, + tcx: TyCtxt<'_>, predicates: &mut [(ty::Predicate<'tcx>, Span)], impl_trait_ref: Option>, input_parameters: &mut FxHashSet, diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index e13a664be0564..52fa0d8ebdc41 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -49,7 +49,7 @@ use syntax_pos::Span; /// impl<'a> Trait for Bar { type X = &'a i32; } /// // ^ 'a is unused and appears in assoc type, error /// ``` -pub fn impl_wf_check<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn impl_wf_check<'tcx>(tcx: TyCtxt<'tcx>) { // We will tag this as part of the WF check -- logically, it is, // but it's one that we must perform earlier than the rest of // WfCheck. @@ -58,7 +58,7 @@ pub fn impl_wf_check<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { } } -fn check_mod_impl_wf<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { +fn check_mod_impl_wf<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) { tcx.hir().visit_item_likes_in_module( module_def_id, &mut ImplWfCheck { tcx } @@ -73,7 +73,7 @@ pub fn provide(providers: &mut Providers<'_>) { } struct ImplWfCheck<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> { @@ -93,7 +93,7 @@ impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> { } fn enforce_impl_params_are_constrained<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, impl_def_id: DefId, impl_item_refs: &[hir::ImplItemRef], ) { @@ -172,7 +172,7 @@ fn enforce_impl_params_are_constrained<'tcx>( // used elsewhere are not projected back out. } -fn report_unused_parameter(tcx: TyCtxt<'_, '_>, span: Span, kind: &str, name: &str) { +fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: &str) { struct_span_err!( tcx.sess, span, E0207, "the {} parameter `{}` is not constrained by the \ @@ -184,7 +184,7 @@ fn report_unused_parameter(tcx: TyCtxt<'_, '_>, span: Span, kind: &str, name: &s /// 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, 'tcx>, + tcx: TyCtxt<'tcx>, impl_item_refs: &[hir::ImplItemRef], ) { let mut seen_type_items = FxHashMap::default(); diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index ce8bb975f9866..79674e4baeba0 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -124,7 +124,7 @@ pub struct TypeAndSubsts<'tcx> { ty: Ty<'tcx>, } -fn check_type_alias_enum_variants_enabled<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, span: Span) { +fn check_type_alias_enum_variants_enabled<'tcx>(tcx: TyCtxt<'tcx>, span: Span) { if !tcx.features().type_alias_enum_variants { let mut err = tcx.sess.struct_span_err( span, @@ -139,7 +139,7 @@ fn check_type_alias_enum_variants_enabled<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, s } } -fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_, '_>, decl: &hir::FnDecl, abi: Abi, span: Span) { +fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl, abi: Abi, span: Span) { if decl.c_variadic && !(abi == Abi::C || abi == Abi::Cdecl) { let mut err = struct_span_err!(tcx.sess, span, E0045, "C-variadic function must have C or cdecl calling convention"); @@ -148,7 +148,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_, '_>, decl: &hir::FnDecl, abi: Abi } fn require_same_types<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, cause: &ObligationCause<'tcx>, expected: Ty<'tcx>, actual: Ty<'tcx>, @@ -176,7 +176,7 @@ fn require_same_types<'tcx>( }) } -fn check_main_fn_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, main_def_id: DefId) { +fn check_main_fn_ty<'tcx>(tcx: TyCtxt<'tcx>, main_def_id: DefId) { let main_id = tcx.hir().as_local_hir_id(main_def_id).unwrap(); let main_span = tcx.def_span(main_def_id); let main_t = tcx.type_of(main_def_id); @@ -241,7 +241,7 @@ fn check_main_fn_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, main_def_id: DefId) { } } -fn check_start_fn_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, start_def_id: DefId) { +fn check_start_fn_ty<'tcx>(tcx: TyCtxt<'tcx>, start_def_id: DefId) { let start_id = tcx.hir().as_local_hir_id(start_def_id).unwrap(); let start_span = tcx.def_span(start_def_id); let start_t = tcx.type_of(start_def_id); @@ -298,7 +298,7 @@ fn check_start_fn_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, start_def_id: DefId) { } } -fn check_for_entry_fn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +fn check_for_entry_fn<'tcx>(tcx: TyCtxt<'tcx>) { match tcx.entry_fn(LOCAL_CRATE) { Some((def_id, EntryFnType::Main)) => check_main_fn_ty(tcx, def_id), Some((def_id, EntryFnType::Start)) => check_start_fn_ty(tcx, def_id), @@ -315,7 +315,7 @@ pub fn provide(providers: &mut Providers<'_>) { impl_wf_check::provide(providers); } -pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Result<(), ErrorReported> { +pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) -> Result<(), ErrorReported> { tcx.sess.profiler(|p| p.start_activity("type-check crate")); // this ensures that later parts of type checking can assume that items @@ -376,7 +376,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Result<(), ErrorReported> { /// A quasi-deprecated helper used in rustdoc and clippy to get /// the type from a HIR node. -pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> { +pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> { // In case there are any projections, etc., find the "environment" // def-ID that will be used to determine the traits/predicates in // scope. This is derived from the enclosing item-like thing. @@ -388,7 +388,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> } pub fn hir_trait_to_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, hir_trait: &hir::TraitRef, ) -> (ty::PolyTraitRef<'tcx>, Bounds<'tcx>) { // In case there are any projections, etc., find the "environment" diff --git a/src/librustc_typeck/outlives/explicit.rs b/src/librustc_typeck/outlives/explicit.rs index 9d621407caf5f..40a57788c0710 100644 --- a/src/librustc_typeck/outlives/explicit.rs +++ b/src/librustc_typeck/outlives/explicit.rs @@ -18,7 +18,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> { pub fn explicit_predicates_of( &mut self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: DefId, ) -> &RequiredPredicates<'tcx> { self.map.entry(def_id).or_insert_with(|| { diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 73a1be0027ae4..a2f9a2bb50a2a 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -15,7 +15,7 @@ use super::utils::*; /// was generated by walking the items in the crate. This will /// now be filled with inferred predicates. pub fn infer_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, explicit_map: &mut ExplicitPredicatesMap<'tcx>, ) -> FxHashMap> { debug!("infer_predicates"); @@ -44,7 +44,7 @@ pub fn infer_predicates<'tcx>( } pub struct InferVisitor<'cx, 'tcx: 'cx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, global_inferred_outlives: &'cx mut FxHashMap>, predicates_added: &'cx mut bool, explicit_map: &'cx mut ExplicitPredicatesMap<'tcx>, @@ -117,7 +117,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { } fn insert_required_predicates_to_be_wf<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, field_ty: Ty<'tcx>, global_inferred_outlives: &FxHashMap>, required_predicates: &mut RequiredPredicates<'tcx>, @@ -255,7 +255,7 @@ pub struct IgnoreSelfTy(bool); /// can ignore, but we will want to process `U: 'static`, /// applying the substitution as above. pub fn check_explicit_predicates<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, def_id: &DefId, substs: &[Kind<'tcx>], required_predicates: &mut RequiredPredicates<'tcx>, diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 03e1a6e4d44bc..ad538b0effedf 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -21,7 +21,7 @@ pub fn provide(providers: &mut Providers<'_>) { } fn inferred_outlives_of<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, item_def_id: DefId, ) -> &'tcx [ty::Predicate<'tcx>] { let id = tcx @@ -71,7 +71,7 @@ fn inferred_outlives_of<'tcx>( } fn inferred_outlives_crate<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, crate_num: CrateNum, ) -> &'tcx CratePredicatesMap<'tcx> { assert_eq!(crate_num, LOCAL_CRATE); diff --git a/src/librustc_typeck/outlives/test.rs b/src/librustc_typeck/outlives/test.rs index 7055bbd3c51d2..4690cb9eada2e 100644 --- a/src/librustc_typeck/outlives/test.rs +++ b/src/librustc_typeck/outlives/test.rs @@ -3,14 +3,14 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::ty::TyCtxt; use syntax::symbol::sym; -pub fn test_inferred_outlives<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn test_inferred_outlives<'tcx>(tcx: TyCtxt<'tcx>) { tcx.hir() .krate() .visit_all_item_likes(&mut OutlivesTest { tcx }); } struct OutlivesTest<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> { diff --git a/src/librustc_typeck/outlives/utils.rs b/src/librustc_typeck/outlives/utils.rs index 2aa2efbb6236b..c6b0da3fe474c 100644 --- a/src/librustc_typeck/outlives/utils.rs +++ b/src/librustc_typeck/outlives/utils.rs @@ -11,7 +11,7 @@ pub type RequiredPredicates<'tcx> = BTreeSet, t /// Given a requirement `T: 'a` or `'b: 'a`, deduce the /// outlives_component and add it to `required_predicates` pub fn insert_outlives_predicate<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, kind: Kind<'tcx>, outlived_region: Region<'tcx>, required_predicates: &mut RequiredPredicates<'tcx>, @@ -125,7 +125,7 @@ pub fn insert_outlives_predicate<'tcx>( } } -fn is_free_region<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, region: Region<'_>) -> bool { +fn is_free_region<'tcx>(tcx: TyCtxt<'tcx>, region: Region<'_>) -> bool { // First, screen for regions that might appear in a type header. match region { // These correspond to `T: 'a` relationships: diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 5433afa2a7b89..59213ac3c1342 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -124,7 +124,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.build_constraints_for_item(def_id); } - fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { self.terms_cx.tcx } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 22422081bc44e..40168e917e996 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -35,7 +35,7 @@ pub fn provide(providers: &mut Providers<'_>) { } fn crate_variances<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, crate_num: CrateNum, ) -> &'tcx CrateVariancesMap<'tcx> { assert_eq!(crate_num, LOCAL_CRATE); @@ -45,7 +45,7 @@ fn crate_variances<'tcx>( tcx.arena.alloc(solve::solve_constraints(constraints_cx)) } -fn variances_of<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item_def_id: DefId) -> &'tcx [ty::Variance] { +fn variances_of<'tcx>(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> &'tcx [ty::Variance] { let id = tcx.hir().as_local_hir_id(item_def_id).expect("expected local def-id"); let unsupported = || { // Variance not relevant. diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index 4f8bb0c4e462d..b120f995ad3a6 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -48,7 +48,7 @@ impl<'a> fmt::Debug for VarianceTerm<'a> { // The first pass over the crate simply builds up the set of inferreds. pub struct TermsContext<'a, 'tcx: 'a> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub arena: &'a TypedArena>, // For marker types, UnsafeCell, and other lang items where @@ -65,7 +65,7 @@ pub struct TermsContext<'a, 'tcx: 'a> { } pub fn determine_parameters_to_be_inferred<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, arena: &'a mut TypedArena>, ) -> TermsContext<'a, 'tcx> { let mut terms_cx = TermsContext { @@ -86,7 +86,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>( terms_cx } -fn lang_items(tcx: TyCtxt<'_, '_>) -> Vec<(hir::HirId, Vec)> { +fn lang_items(tcx: TyCtxt<'_>) -> Vec<(hir::HirId, Vec)> { let lang_items = tcx.lang_items(); let all = vec![ (lang_items.phantom_data(), vec![ty::Covariant]), diff --git a/src/librustc_typeck/variance/test.rs b/src/librustc_typeck/variance/test.rs index f43c200425505..cefc200f5cba8 100644 --- a/src/librustc_typeck/variance/test.rs +++ b/src/librustc_typeck/variance/test.rs @@ -3,12 +3,12 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::ty::TyCtxt; use syntax::symbol::sym; -pub fn test_variance<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { +pub fn test_variance<'tcx>(tcx: TyCtxt<'tcx>) { tcx.hir().krate().visit_all_item_likes(&mut VarianceTest { tcx }); } struct VarianceTest<'tcx> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, } impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> { diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index b0f274ac6b791..3dcf77e6d7d54 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -313,10 +313,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { lifetime_predicates } - fn extract_for_generics<'c, 'd>( + fn extract_for_generics( &self, - tcx: TyCtxt<'c, 'd>, - pred: ty::Predicate<'d>, + tcx: TyCtxt<'tcx>, + pred: ty::Predicate<'tcx>, ) -> FxHashSet { pred.walk_tys() .flat_map(|t| { @@ -448,13 +448,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // * Fn bounds are handled specially - instead of leaving it as 'T: Fn(), = // K', we use the dedicated syntax 'T: Fn() -> K' // * We explcitly add a '?Sized' bound if we didn't find any 'Sized' predicates for a type - fn param_env_to_generics<'c, 'cx>( + fn param_env_to_generics( &self, - tcx: TyCtxt<'c, 'cx>, + tcx: TyCtxt<'tcx>, param_env_def_id: DefId, - param_env: ty::ParamEnv<'cx>, + param_env: ty::ParamEnv<'tcx>, mut existing_predicates: Vec, - vid_to_region: FxHashMap>, + vid_to_region: FxHashMap>, ) -> Generics { debug!( "param_env_to_generics(param_env_def_id={:?}, param_env={:?}, \ @@ -776,7 +776,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { vec.sort_by_cached_key(|x| format!("{:?}", x)) } - fn is_fn_ty(&self, tcx: TyCtxt<'_, '_>, ty: &Type) -> bool { + fn is_fn_ty(&self, tcx: TyCtxt<'_>, ty: &Type) -> bool { match &ty { &&Type::ResolvedPath { ref did, .. } => { *did == tcx.require_lang_item(lang_items::FnTraitLangItem) @@ -789,13 +789,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { } // Replaces all ReVars in a type with ty::Region's, using the provided map -struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { +struct RegionReplacer<'a, 'tcx> { vid_to_region: &'a FxHashMap>, - tcx: TyCtxt<'gcx, 'tcx>, + tcx: TyCtxt<'tcx>, } -impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionReplacer<'a, 'gcx, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { +impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 559dcaf5a8d3b..43cb3dd7261c8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -4432,7 +4432,7 @@ where // Start of code copied from rust-clippy -pub fn path_to_def_local(tcx: TyCtxt<'_, '_>, path: &[Symbol]) -> Option { +pub fn path_to_def_local(tcx: TyCtxt<'_>, path: &[Symbol]) -> Option { let krate = tcx.hir().krate(); let mut items = krate.module.item_ids.clone(); let mut path_it = path.iter().peekable(); @@ -4457,7 +4457,7 @@ pub fn path_to_def_local(tcx: TyCtxt<'_, '_>, path: &[Symbol]) -> Option } } -pub fn path_to_def(tcx: TyCtxt<'_, '_>, path: &[Symbol]) -> Option { +pub fn path_to_def(tcx: TyCtxt<'_>, path: &[Symbol]) -> Option { let crates = tcx.crates(); let krate = crates diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index b48ed12cc6baa..985bb02614b61 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -44,7 +44,7 @@ pub type ExternalPaths = FxHashMap, clean::TypeKind)>; pub struct DocContext<'tcx> { - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub resolver: Rc>>, /// The stack of module NodeIds up till this point pub crate_name: Option, diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 7fc3e5a097920..75cad9ec8ff33 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -60,7 +60,7 @@ impl CodegenBackend for TheBackend { fn codegen_crate<'a, 'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, _metadata: EncodedMetadata, _need_metadata_module: bool, _rx: mpsc::Receiver> diff --git a/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs b/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs index 00190ed12b4d6..9534ddbbc6471 100644 --- a/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs +++ b/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs @@ -11,26 +11,26 @@ use rustc::ty::{Ty, TyCtxt}; fn ty_by_ref( ty_val: Ty<'_>, ty_ref: &Ty<'_>, //~ ERROR passing `Ty<'_>` by reference - ty_ctxt_val: TyCtxt<'_, '_>, - ty_ctxt_ref: &TyCtxt<'_, '_>, //~ ERROR passing `TyCtxt<'_, '_>` by reference + ty_ctxt_val: TyCtxt<'_>, + ty_ctxt_ref: &TyCtxt<'_>, //~ ERROR passing `TyCtxt<'_>` by reference ) { } -fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} +fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} //~^ ERROR passing `Ty<'_>` by reference -//~^^ ERROR passing `TyCtxt<'_, '_>` by reference +//~^^ ERROR passing `TyCtxt<'_>` by reference trait T { fn ty_by_ref_in_trait( ty_val: Ty<'_>, ty_ref: &Ty<'_>, //~ ERROR passing `Ty<'_>` by reference - ty_ctxt_val: TyCtxt<'_, '_>, - ty_ctxt_ref: &TyCtxt<'_, '_>, //~ ERROR passing `TyCtxt<'_, '_>` by reference + ty_ctxt_val: TyCtxt<'_>, + ty_ctxt_ref: &TyCtxt<'_>, //~ ERROR passing `TyCtxt<'_>` by reference ); - fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>); + fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>); //~^ ERROR passing `Ty<'_>` by reference - //~^^ ERROR passing `TyCtxt<'_, '_>` by reference + //~^^ ERROR passing `TyCtxt<'_>` by reference } struct Foo; @@ -39,26 +39,26 @@ impl T for Foo { fn ty_by_ref_in_trait( ty_val: Ty<'_>, ty_ref: &Ty<'_>, - ty_ctxt_val: TyCtxt<'_, '_>, - ty_ctxt_ref: &TyCtxt<'_, '_>, + ty_ctxt_val: TyCtxt<'_>, + ty_ctxt_ref: &TyCtxt<'_>, ) { } - fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} + fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} } impl Foo { fn ty_by_ref_assoc( ty_val: Ty<'_>, ty_ref: &Ty<'_>, //~ ERROR passing `Ty<'_>` by reference - ty_ctxt_val: TyCtxt<'_, '_>, - ty_ctxt_ref: &TyCtxt<'_, '_>, //~ ERROR passing `TyCtxt<'_, '_>` by reference + ty_ctxt_val: TyCtxt<'_>, + ty_ctxt_ref: &TyCtxt<'_>, //~ ERROR passing `TyCtxt<'_>` by reference ) { } - fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} + fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} //~^ ERROR passing `Ty<'_>` by reference - //~^^ ERROR passing `TyCtxt<'_, '_>` by reference + //~^^ ERROR passing `TyCtxt<'_>` by reference } fn main() {} diff --git a/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.stderr b/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.stderr index 94440f0385a92..0f9f24b98a08c 100644 --- a/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.stderr +++ b/src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.stderr @@ -10,23 +10,23 @@ note: lint level defined here LL | #![deny(ty_pass_by_reference)] | ^^^^^^^^^^^^^^^^^^^^ -error: passing `TyCtxt<'_, '_>` by reference +error: passing `TyCtxt<'_>` by reference --> $DIR/pass_ty_by_ref.rs:15:18 | -LL | ty_ctxt_ref: &TyCtxt<'_, '_>, - | ^^^^^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_, '_>` +LL | ty_ctxt_ref: &TyCtxt<'_>, + | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference --> $DIR/pass_ty_by_ref.rs:19:28 | -LL | fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} +LL | fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} | ^^^^^^^ help: try passing by value: `Ty<'_>` -error: passing `TyCtxt<'_, '_>` by reference +error: passing `TyCtxt<'_>` by reference --> $DIR/pass_ty_by_ref.rs:19:55 | -LL | fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} - | ^^^^^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_, '_>` +LL | fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} + | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference --> $DIR/pass_ty_by_ref.rs:26:17 @@ -34,23 +34,23 @@ error: passing `Ty<'_>` by reference LL | ty_ref: &Ty<'_>, | ^^^^^^^ help: try passing by value: `Ty<'_>` -error: passing `TyCtxt<'_, '_>` by reference +error: passing `TyCtxt<'_>` by reference --> $DIR/pass_ty_by_ref.rs:28:22 | -LL | ty_ctxt_ref: &TyCtxt<'_, '_>, - | ^^^^^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_, '_>` +LL | ty_ctxt_ref: &TyCtxt<'_>, + | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference --> $DIR/pass_ty_by_ref.rs:31:41 | -LL | fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>); +LL | fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>); | ^^^^^^^ help: try passing by value: `Ty<'_>` -error: passing `TyCtxt<'_, '_>` by reference +error: passing `TyCtxt<'_>` by reference --> $DIR/pass_ty_by_ref.rs:31:68 | -LL | fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>); - | ^^^^^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_, '_>` +LL | fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>); + | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference --> $DIR/pass_ty_by_ref.rs:53:17 @@ -58,23 +58,23 @@ error: passing `Ty<'_>` by reference LL | ty_ref: &Ty<'_>, | ^^^^^^^ help: try passing by value: `Ty<'_>` -error: passing `TyCtxt<'_, '_>` by reference +error: passing `TyCtxt<'_>` by reference --> $DIR/pass_ty_by_ref.rs:55:22 | -LL | ty_ctxt_ref: &TyCtxt<'_, '_>, - | ^^^^^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_, '_>` +LL | ty_ctxt_ref: &TyCtxt<'_>, + | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference --> $DIR/pass_ty_by_ref.rs:59:38 | -LL | fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} +LL | fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} | ^^^^^^^ help: try passing by value: `Ty<'_>` -error: passing `TyCtxt<'_, '_>` by reference +error: passing `TyCtxt<'_>` by reference --> $DIR/pass_ty_by_ref.rs:59:65 | -LL | fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_, '_>) {} - | ^^^^^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_, '_>` +LL | fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} + | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: aborting due to 12 previous errors diff --git a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs index fa019dfe3ae09..56033100344a6 100644 --- a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs +++ b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs @@ -13,8 +13,8 @@ macro_rules! qualified_macro { fn ty_in_macro( ty_q: ty::Ty<'_>, ty: Ty<'_>, - ty_ctxt_q: ty::TyCtxt<'_, '_>, - ty_ctxt: TyCtxt<'_, '_>, + ty_ctxt_q: ty::TyCtxt<'_>, + ty_ctxt: TyCtxt<'_>, ) { println!("{}", stringify!($a)); } @@ -24,8 +24,8 @@ macro_rules! qualified_macro { fn ty_qualified( ty_q: ty::Ty<'_>, //~ ERROR usage of qualified `ty::Ty<'_>` ty: Ty<'_>, - ty_ctxt_q: ty::TyCtxt<'_, '_>, //~ ERROR usage of qualified `ty::TyCtxt<'_, '_>` - ty_ctxt: TyCtxt<'_, '_>, + ty_ctxt_q: ty::TyCtxt<'_>, //~ ERROR usage of qualified `ty::TyCtxt<'_>` + ty_ctxt: TyCtxt<'_>, ) { } diff --git a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr index 445546ab6eec0..c3642e6a4ba74 100644 --- a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr +++ b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr @@ -10,11 +10,11 @@ note: lint level defined here LL | #![deny(usage_of_qualified_ty)] | ^^^^^^^^^^^^^^^^^^^^^ -error: usage of qualified `ty::TyCtxt<'_, '_>` +error: usage of qualified `ty::TyCtxt<'_>` --> $DIR/qualified_ty_ty_ctxt.rs:27:16 | -LL | ty_ctxt_q: ty::TyCtxt<'_, '_>, - | ^^^^^^^^^^^^^^^^^^ help: try using it unqualified: `TyCtxt<'_, '_>` +LL | ty_ctxt_q: ty::TyCtxt<'_>, + | ^^^^^^^^^^^^^^ help: try using it unqualified: `TyCtxt<'_>` error: aborting due to 2 previous errors From afc39bbf2447844569e872468f9440d430b81a46 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 14 Jun 2019 01:32:15 +0300 Subject: [PATCH 2/2] Run `rustfmt --file-lines ...` for changes from previous commits. --- src/librustc/ich/impls_syntax.rs | 10 +- src/librustc/ich/impls_ty.rs | 26 +- src/librustc/infer/at.rs | 27 +- .../infer/canonical/query_response.rs | 5 +- src/librustc/infer/equate.rs | 7 +- .../infer/error_reporting/need_type_info.rs | 5 +- src/librustc/infer/freshen.rs | 3 +- src/librustc/infer/glb.rs | 11 +- src/librustc/infer/lattice.rs | 13 +- .../infer/lexical_region_resolve/graphviz.rs | 22 +- .../infer/lexical_region_resolve/mod.rs | 5 +- src/librustc/infer/lub.rs | 11 +- src/librustc/infer/outlives/env.rs | 7 +- src/librustc/infer/resolve.rs | 8 +- src/librustc/infer/sub.rs | 7 +- src/librustc/lint/context.rs | 5 +- src/librustc/middle/entry.rs | 5 +- src/librustc/middle/exported_symbols.rs | 6 +- src/librustc/middle/expr_use_visitor.rs | 28 +- src/librustc/middle/mem_categorization.rs | 20 +- src/librustc/middle/region.rs | 6 +- src/librustc/middle/resolve_lifetime.rs | 7 +- src/librustc/mir/tcx.rs | 7 +- src/librustc/traits/chalk_fulfill.rs | 2 +- src/librustc/traits/codegen/mod.rs | 14 +- src/librustc/traits/coherence.rs | 10 +- src/librustc/traits/error_reporting.rs | 7 +- src/librustc/traits/fulfill.rs | 51 +-- src/librustc/traits/mod.rs | 7 +- src/librustc/traits/project.rs | 159 ++++----- src/librustc/traits/query/type_op/mod.rs | 4 +- src/librustc/traits/specialize/mod.rs | 24 +- .../traits/specialize/specialization_graph.rs | 7 +- src/librustc/traits/util.rs | 23 +- src/librustc/ty/adjustment.rs | 6 +- src/librustc/ty/context.rs | 44 ++- src/librustc/ty/fold.rs | 7 +- src/librustc/ty/layout.rs | 19 +- src/librustc/ty/mod.rs | 32 +- src/librustc/ty/print/mod.rs | 4 +- src/librustc/ty/print/obsolete.rs | 6 +- src/librustc/ty/print/pretty.rs | 52 ++- src/librustc/ty/query/job.rs | 6 +- src/librustc/ty/query/on_disk_cache.rs | 6 +- src/librustc/ty/query/plumbing.rs | 28 +- src/librustc/ty/structural_impls.rs | 4 +- src/librustc/ty/sty.rs | 18 +- src/librustc/ty/subst.rs | 21 +- src/librustc/ty/util.rs | 23 +- src/librustc/ty/wf.rs | 42 +-- src/librustc_codegen_llvm/lib.rs | 6 +- .../debuginfo/type_names.rs | 7 +- .../symbol_names/legacy.rs | 8 +- src/librustc_incremental/assert_dep_graph.rs | 6 +- src/librustc_interface/passes.rs | 2 +- src/librustc_metadata/decoder.rs | 19 +- src/librustc_mir/borrow_check/mod.rs | 23 +- .../region_infer/error_reporting/var_name.rs | 7 +- src/librustc_mir/borrow_check/nll/renumber.rs | 5 +- .../nll/type_check/constraint_conversion.rs | 4 +- src/librustc_mir/borrow_check/prefixes.rs | 7 +- src/librustc_mir/dataflow/impls/mod.rs | 25 +- src/librustc_mir/hair/cx/mod.rs | 3 +- .../interpret/intrinsics/type_name.rs | 8 +- src/librustc_mir/monomorphize/collector.rs | 11 +- src/librustc_mir/monomorphize/partitioning.rs | 5 +- src/librustc_mir/shim.rs | 6 +- src/librustc_mir/transform/add_call_guards.rs | 7 +- .../transform/add_moves_for_packed_drops.rs | 6 +- src/librustc_mir/transform/add_retag.rs | 7 +- .../transform/cleanup_post_borrowck.rs | 7 +- src/librustc_mir/transform/const_prop.rs | 7 +- src/librustc_mir/transform/copy_prop.rs | 7 +- src/librustc_mir/transform/deaggregator.rs | 7 +- src/librustc_mir/transform/dump_mir.rs | 7 +- src/librustc_mir/transform/generator.rs | 7 +- src/librustc_mir/transform/inline.rs | 7 +- src/librustc_mir/transform/lower_128bit.rs | 7 +- src/librustc_mir/transform/mod.rs | 7 +- .../transform/remove_noop_landing_pads.rs | 7 +- src/librustc_mir/transform/simplify.rs | 7 +- .../transform/simplify_branches.rs | 7 +- .../transform/uniform_array_move_out.rs | 14 +- src/librustc_mir/util/mod.rs | 5 +- src/librustc_mir/util/pretty.rs | 12 +- src/librustc_privacy/lib.rs | 6 +- src/librustc_traits/chalk_context/mod.rs | 15 +- .../program_clauses/primitive.rs | 5 +- src/librustc_traits/chalk_context/unify.rs | 7 +- .../implied_outlives_bounds.rs | 2 +- src/librustc_typeck/check/_match.rs | 3 +- src/librustc_typeck/check/autoderef.rs | 32 +- src/librustc_typeck/check/cast.rs | 77 +++-- src/librustc_typeck/check/coercion.rs | 51 +-- src/librustc_typeck/check/compare_method.rs | 19 +- src/librustc_typeck/check/dropck.rs | 5 +- .../check/generator_interior.rs | 10 +- src/librustc_typeck/check/method/confirm.rs | 17 +- src/librustc_typeck/check/method/mod.rs | 30 +- src/librustc_typeck/check/method/probe.rs | 77 +++-- src/librustc_typeck/check/mod.rs | 315 +++++++++--------- src/librustc_typeck/check/op.rs | 70 ++-- src/librustc_typeck/check/wfcheck.rs | 28 +- src/librustc_typeck/coherence/mod.rs | 12 +- src/librustc_typeck/collect.rs | 17 +- src/librustc_typeck/impl_wf_check.rs | 5 +- src/librustc_typeck/variance/mod.rs | 5 +- 107 files changed, 813 insertions(+), 1159 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index f72248701d14b..4f618457d6c6a 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> for feature_gate::Features { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher, + ) { // 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 3a46a7e2afb5b..9b144b1ba3d2a 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> -for &'tcx ty::List - where T: HashStable> { +impl<'a, 'tcx, T> HashStable> for &'tcx ty::List +where + T: HashStable>, +{ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { @@ -41,7 +42,8 @@ for &'tcx ty::List } impl<'a, 'tcx, T> ToStableHashKey> for &'tcx ty::List - where T: HashStable> +where + T: HashStable>, { type KeyType = Fingerprint; @@ -119,18 +121,22 @@ impl<'a> HashStable> for ty::RegionVid { impl<'a, 'tcx> HashStable> for ty::ConstVid<'tcx> { #[inline] - fn hash_stable(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher, + ) { self.index.hash_stable(hcx, hasher); } } impl<'tcx> HashStable> for ty::BoundVar { #[inline] - fn hash_stable(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher, + ) { self.index().hash_stable(hcx, hasher); } } diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 2d99e8a57e01f..0bb939889a89a 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(self, - expected: T, - actual: T) - -> Trace<'a, 'tcx> - where T: ToTrace<'tcx> + pub fn trace(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(self, - a_is_expected: bool, - a: T, - b: T) - -> Trace<'a, 'tcx> - where T: ToTrace<'tcx> + pub fn trace_exp(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 59b46b41c8dbd..8b11ebf9b924b 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( &mut self, canonical_key: &Canonical<'tcx, K>, - operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) - -> Fallible, + operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K) -> Fallible, ) -> Fallible> where K: TypeFoldable<'tcx>, @@ -126,7 +125,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { pub fn make_query_response_ignoring_pending_obligations( &self, inference_vars: CanonicalVarValues<'tcx>, - answer: T + answer: T, ) -> Canonical<'tcx, QueryResponse<'tcx, >::Lifted>> where T: Debug + Lift<'tcx> + TypeFoldable<'tcx>, diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index f9fdc66cf3dae..39d8241e6b427 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 830d6adc1b872..362a680f53c9a 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, 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 20331232dc741..645f2b0233800 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 8e4796dc83d5a..7f184d3424f2f 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 18a30e259ebfc..c7766636e04e0 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 758a01bc52be5..aa4bbcad6d5bc 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, 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 944969e2214d2..16f5a9d3b36c4 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>, -) { +) -> (LexicalRegionResolutions<'tcx>, Vec>) { 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 6e1ca9e7ed041..2a9f5856eb855 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 ff27bbf7db24c..4b5df444148be 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( - &mut self, - infcx: Option<&InferCtxt<'a, 'tcx>>, - outlives_bounds: I, - ) where + fn add_outlives_bounds(&mut self, infcx: Option<&InferCtxt<'a, 'tcx>>, outlives_bounds: I) + where I: IntoIterator>, { // 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 5ca79bfa7bc1e..810c64185a71d 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)>, + pub first_unresolved: Option<(Ty<'tcx>, Option)>, } 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 0284e087b7e83..ed84e3f63ae1b 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 c4a37d83866cf..468d909e5497b 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 704be9600fa4d..d9e7caebb9829 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 78a3e3ff2681c..202788093046a 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 80c26c132f614..61770e6f48705 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 bc87aa8f872b4..3b21b81df7b43 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> { // 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> { + fn helper<'a, 'tcx>( + mc: &MemCategorizationContext<'a, 'tcx>, + expr: &hir::Expr, + adjustments: &[adjustment::Adjustment<'tcx>], + ) -> McResult> { 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 546d51e9124ad..8b1eeeb7f51b7 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 e187a3ced3f4b..8bc3158bd3c7d 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 4a8f503b14f8a..afabcdfadd03c 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 b1941b876d7c1..0c7c94b684a9f 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 a5d44f5f2637a..bb4095333f19d 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(&self, - fulfill_cx: &mut FulfillmentContext<'tcx>, - result: &T) - -> T::Lifted - where T: TypeFoldable<'tcx> + ty::Lift<'tcx> + fn drain_fulfillment_cx_or_panic( + &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 949cc62f62c4f..d8087af60acdf 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 99ced254dcad9..42bde3563492f 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>> + var_map: FxHashMap, 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 eaad696ba391c..5e2c949c7d8d6 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>> { + fn select( + &mut self, + selcx: &mut SelectionContext<'a, 'tcx>, + ) -> Result<(), Vec>> { 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>> - { + infcx: &InferCtxt<'_, 'tcx>, + ) -> Result<(), Vec>> { 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>> - { + fn select_where_possible( + &mut self, + infcx: &InferCtxt<'_, 'tcx>, + ) -> Result<(), Vec>> { 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>) -> Vec> { @@ -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> -{ +fn trait_ref_type_vars<'a, 'tcx>( + selcx: &mut SelectionContext<'a, 'tcx>, + t: ty::PolyTraitRef<'tcx>, +) -> Vec> { 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 83162a1e12c25..f5c91a77517cd 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>> - where T : TypeFoldable<'tcx> + value: &T, +) -> Result>> +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 75dd4d53b3644..d189bb231163e 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>>, - MismatchedProjectionTypes<'tcx>> -{ + obligation: &PolyProjectionObligation<'tcx>, +) -> Result>>, 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>>, - MismatchedProjectionTypes<'tcx>> -{ + obligation: &ProjectionObligation<'tcx>, +) -> Result>>, 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>) - -> Ty<'tcx> -{ + obligations: &mut Vec>, +) -> 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>) - -> Option> -{ + obligations: &mut Vec>, +) -> Option> { 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, ProjectionTyError<'tcx>> -{ + obligation: &ProjectionTyObligation<'tcx>, +) -> Result, 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> + env_predicates: I, +) where + I: IntoIterator>, { 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 `>::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 -{ + assoc_ty_def_id: DefId, +) -> specialization_graph::NodeItem { 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 - { + pub fn from_poly_projection_predicate( + selcx: &mut SelectionContext<'cx, 'tcx>, + predicate: &ty::PolyProjectionPredicate<'tcx>, + ) -> Option { 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 8dfb11230f248..b298edfec5944 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 3f1fcea35a050..3d47e94fb007c 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, ()> { +fn fulfill_implication<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + source_trait_ref: ty::TraitRef<'tcx>, + target_impl: DefId, +) -> Result, ()> { 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 a6eae6da922f6..f736c5ef9b1c0 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 c74913434262e..b6a1ab9fe709a 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, } -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>> 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>) -{ +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>) { 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 2a228ed79a484..9ba99768215a6 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 a28da275ff12e..e5d06532b3a16 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, - repr: ReprOptions) - -> &'tcx ty::AdtDef { + pub fn alloc_adt_def( + self, + did: DefId, + kind: AdtKind, + variants: IndexVec, + 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: 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: 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> for Interned<'tcx, GoalKind<'tcx>> { } impl<'tcx> Borrow<[ExistentialPredicate<'tcx>]> - for Interned<'tcx, List>> { + for Interned<'tcx, List>> +{ fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'tcx>] { &self.0[..] } } -impl<'tcx> Borrow<[Predicate<'tcx>]> - for Interned<'tcx, List>> { +impl<'tcx> Borrow<[Predicate<'tcx>]> for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Predicate<'tcx>] { &self.0[..] } @@ -2273,15 +2275,13 @@ impl<'tcx> Borrow> for Interned<'tcx, Const<'tcx>> { } } -impl<'tcx> Borrow<[Clause<'tcx>]> -for Interned<'tcx, List>> { +impl<'tcx> Borrow<[Clause<'tcx>]> for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Clause<'tcx>] { &self.0[..] } } -impl<'tcx> Borrow<[Goal<'tcx>]> -for Interned<'tcx, List>> { +impl<'tcx> Borrow<[Goal<'tcx>]> for Interned<'tcx, List>> { 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 9da35824bd0be..8b98a2916a766 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( - tcx: TyCtxt<'tcx>, - fld_r: &'a mut F, - fld_t: &'a mut G, - fld_c: &'a mut H, - ) -> Self + fn new(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 70db4f19a4cdb..6cee2709b636d 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> for Align { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher, + ) { self.bytes().hash_stable(hcx, hasher); } } impl<'tcx> HashStable> for Size { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'tcx>, - hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'tcx>, + hasher: &mut StableHasher, + ) { self.bytes().hash_stable(hcx, hasher); } } -impl<'a, 'tcx> HashStable> for LayoutError<'tcx> -{ +impl<'a, 'tcx> HashStable> for LayoutError<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2e39f0457475c..c932586c078bd 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> for ParamEnvAnd<'tcx, T> - where T: HashStable> +where + T: HashStable>, { fn hash_stable(&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> { + pub fn eval_explicit_discr(&self, tcx: TyCtxt<'tcx>, expr_did: DefId) -> Option> { 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 8e157bdd259db..092e7c6f3fffb 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> -{ +impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx ty::List> { type Output = P::DynExistential; type Error = P::Error; fn print(&self, cx: P) -> Result { diff --git a/src/librustc/ty/print/obsolete.rs b/src/librustc/ty/print/obsolete.rs index 2bfe35d4f1c32..16fb334803926 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 95c5048b378f0..b79d7f06cd6aa 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( - self, - value: &ty::Binder, - ) -> Result - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> + fn in_binder(self, value: &ty::Binder) -> Result + where + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, { value.skip_binder().print(self) } /// Print comma-separated elements. - fn comma_sep( - mut self, - mut elems: impl Iterator, - ) -> Result - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + fn comma_sep(mut self, mut elems: impl Iterator) -> Result + 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 PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> { Ok(self) } - fn in_binder( - self, - value: &ty::Binder, - ) -> Result - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx> + fn in_binder(self, value: &ty::Binder) -> Result + where + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, { self.pretty_in_binder(value) } @@ -1417,11 +1411,9 @@ impl FmtPrinter<'_, '_, F> { // HACK(eddyb) limited to `FmtPrinter` because of `binder_depth`, // `region_index` and `used_region_names`. impl FmtPrinter<'_, 'tcx, F> { - pub fn pretty_in_binder( - mut self, - value: &ty::Binder, - ) -> Result - where T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx> + pub fn pretty_in_binder(mut self, value: &ty::Binder) -> Result + 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 FmtPrinter<'_, 'tcx, F> { } } -impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> - for ty::Binder - where T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx> +impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder +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 - 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 +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 3d00de8c8c11c..dcc467a61b541 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 72ebd3276c7a7..6f83991a2daa2 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 0051832c5df80..48e68167f824c 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>( - self, - span: Span, - key: Q::Key) - -> Q::Value { + pub(super) fn get_query>(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>( - self, - key: Q::Key, - span: Span, - dep_node: DepNode - ) { + fn force_query>(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 9756e9c872bc3..a4efb566e13e8 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>(&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 { +impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder { fn super_fold_with>(&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 ed4a2cd7a298b..810a26d373648 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> { + pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'tcx>) -> impl Iterator> { 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 { + pub fn assert_bits(&self, tcx: TyCtxt<'_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option { 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 5a97d8bb72510..79dcd327f52d4 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( - &self, - tcx: TyCtxt<'tcx>, - def_id: DefId, - mut mk_kind: F, - ) -> SubstsRef<'tcx> + pub fn extend_to(&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, - ) -> Self; + fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option) -> Self; } impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T { - fn subst_spanned( - &self, - tcx: TyCtxt<'tcx>, - substs: &[Kind<'tcx>], - span: Option, - ) -> T { + fn subst_spanned(&self, tcx: TyCtxt<'tcx>, substs: &[Kind<'tcx>], span: Option) -> T { let mut folder = SubstFolder { tcx, substs, span, diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 8b1d9d97276e6..a3b99f143d055 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>, - ) -> Option>; + fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx>, val: Option>) -> Option>; 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>, - ) -> Option> { + fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx>, val: Option>) -> Option> { 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 `>::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 65feb4c08d994..6b2f00e5f703f 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>> -{ +pub fn obligations<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + body_id: hir::HirId, + ty: Ty<'tcx>, + span: Span, +) -> Option>> { 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`, then the trait reference `Foo: Set` 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> -{ +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> { 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> -{ +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> { 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 e03de7799d3a5..a0dd767a3a8ff 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 9dd6bf77a0407..8f0bb6ee19837 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 72eb4969aa8a6..22b7e0a2fb0c9 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( - mut self, - mut elems: impl Iterator, - ) -> Result - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + fn comma_sep(mut self, mut elems: impl Iterator) -> Result + 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 6d667aa008f70..a43347a2197c3 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 cb995907a51fe..69cb696f4c580 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>, - 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 a3cd33209076b..4bafe16b8e66d 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> { + pub fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option> { 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)] { + pub fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option)] { // 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> { + pub fn maybe_get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Option> { 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 82fee9ea48f03..161a08c5773e7 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 - { + fn is_local_ever_initialized( + &self, + local: Local, + flow_state: &Flows<'cx, 'tcx>, + ) -> Option { 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 5afc0514a5671..6ce925cc7d12a 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 { + crate fn get_upvar_index_for_region(&self, tcx: TyCtxt<'tcx>, fr: RegionVid) -> Option { 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 704e9315e7f55..c1d1185cf177a 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 563514b922cbc..d86702773e3f5 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 79045eea53cb1..b35bcc09a235b 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 3e14949ffc946..50d9bbf4cc324 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 236d36c7661cf..7740042c783fc 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 c92d501140f26..5ca3531c98bb1 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( - mut self, - mut elems: impl Iterator, - ) -> Result - where T: Print<'tcx, Self, Output = Self, Error = Self::Error> + fn comma_sep(mut self, mut elems: impl Iterator) -> Result + 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 aa86a1c110490..e530c56ed6f3a 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> { +fn collect_roots<'tcx>(tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode) -> Vec> { 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>, -) { +fn collect_miri<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut Vec>) { 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 4abc067438231..a821cb2cfdad2 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>, } -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>, { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 4b3b1f9d4dabc..f5a22ea09315f 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>, -) -> Body<'tcx> { +fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) -> 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 892b99f94e868..c08c33bc6ff8b 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 12e7ab2189695..a111669f14982 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 c478eaf573153..ee040bf65901c 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 83040a71cbadd..6ee14160bbd1b 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 fc4efdf8f39aa..2ec5c192726b0 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 e84308fd947a4..c850b48e074ab 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 41943d86332dd..1b42a0dffb894 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 375a917763817..243820ba7d027 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 761bbb53800c7..9c7aedc12a27b 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 687993a2c5286..1cbdc2a2de26e 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 5c8e712cc2523..f0aa189804f7d 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 3caee069a7f82..04dce326e69de 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -141,12 +141,7 @@ pub trait MirPass { default_name::() } - 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 69f1ef096fb85..7b3cdc835ebb1 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 e5774692e93e0..ac15f52d9ec5b 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 228a060f6119f..0c63a8d9c96b1 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 08b10a5d33741..90b52b76155db 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 36c5a1a2f59e5..719029dbaac77 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 2c2643e9b42e8..fc46adb702c8d 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 5610982c01e98..c2cb2f4d1745e 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 d5a4904195857..2b678919ce41b 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -179,10 +179,7 @@ impl context::AggregateOps> for ChalkContext<'tcx> { impl context::ContextOps> 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>> 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> { } 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 cdcf73d3c3a3b..8e4b9da6de268 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 7ae0e8548fae6..d66faa92336fe 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 8e789e0408f0a..7f9ebdc79c276 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>> { let tcx = infcx.tcx; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 3aa050fb56d86..9ffbbd384c6d5 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, - ) -> 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 80c6c13b57e93..dc4969d7ad2db 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> { + pub fn adjust_steps(&self, fcx: &FnCtxt<'a, 'tcx>, needs: Needs) -> Vec> { 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>> { + pub fn adjust_steps_as_infer_ok( + &self, + fcx: &FnCtxt<'a, 'tcx>, + needs: Needs, + ) -> InferOk<'tcx, Vec>> { 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 e70090dd85a42..53101499af1dc 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -158,12 +158,13 @@ impl From 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, 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, 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 { + fn check_ptr_ptr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_expr: ty::TypeAndMut<'tcx>, + m_cast: ty::TypeAndMut<'tcx>, + ) -> Result { 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 { + fn check_fptr_ptr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_cast: ty::TypeAndMut<'tcx>, + ) -> Result { // 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 { + fn check_ptr_addr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_expr: ty::TypeAndMut<'tcx>, + ) -> Result { // 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 { + fn check_ref_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_expr: ty::TypeAndMut<'tcx>, + m_cast: ty::TypeAndMut<'tcx>, + ) -> Result { // 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 { + fn check_addr_ptr_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + m_cast: TypeAndMut<'tcx>, + ) -> Result { // 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 e1623fe49e772..a56196ccf82f5 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -121,9 +121,11 @@ fn success<'tcx>(adj: Vec>, } 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 beaa32b0bd354..088ac0e8ba6c8 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) { +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) { 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 8f80c9a9f5bef..2003782e7adca 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; impl Drop for S { ... }`). /// -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 bd2db8facd44e..5f9aa5fbabe04 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 25ca4668a1020..5df0010b63eb2 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(&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 6990277482a1e..b492197870b75 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, 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, 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 3c60ba219fad6..661883f2ac11d 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(&'a self, - span: Span, - mode: Mode, - method_name: Option, - return_type: Option>, - is_suggestion: IsSuggestion, - self_ty: Ty<'tcx>, - scope_expr_id: hir::HirId, - scope: ProbeScope, - op: OP) - -> Result> - where OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result> + fn probe_op( + &'a self, + span: Span, + mode: Mode, + method_name: Option, + return_type: Option>, + is_suggestion: IsSuggestion, + self_ty: Ty<'tcx>, + scope_expr_id: hir::HirId, + scope: ProbeScope, + op: OP, + ) -> Result> + where + OP: FnOnce(ProbeContext<'a, 'tcx>) -> Result>, { 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, - return_type: Option>, - orig_steps_var_values: OriginalQueryValues<'tcx>, - steps: Lrc>>, - is_suggestion: IsSuggestion) - -> ProbeContext<'a, 'tcx> { + fn new( + fcx: &'a FnCtxt<'a, 'tcx>, + span: Span, + mode: Mode, + method_name: Option, + return_type: Option>, + orig_steps_var_values: OriginalQueryValues<'tcx>, + steps: Lrc>>, + 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(&mut self, - bounds: impl Iterator>, - mut mk_cand: F) - where F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>, - ty::PolyTraitRef<'tcx>, - ty::AssocItem) + fn elaborate_bounds( + &mut self, + bounds: impl Iterator>, + 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> - { + fn pick_by_value_method( + &mut self, + step: &CandidateStep<'tcx>, + self_ty: Ty<'tcx>, + ) -> Option> { //! 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> { + fn pick_autorefd_method( + &mut self, + step: &CandidateStep<'tcx>, + self_ty: Ty<'tcx>, + mutbl: hir::Mutability, + ) -> Option> { 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 4a25c7323c37f..3a30e31f89e2a 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) - -> (FnCtxt<'a, 'tcx>, Option>) -{ +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, +) -> (FnCtxt<'a, 'tcx>, Option>) { 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, -) -> bool { +fn check_packed_inner<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, stack: &mut Vec) -> 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> - { + fn remove_deferred_call_resolutions( + &self, + closure_def_id: DefId, + ) -> Vec> { 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, ()>, - 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, ()>, + 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, traits::PredicateObligation<'tcx>)> - + Captures<'tcx> + 'b - { + fn obligations_for_self_ty<'b>( + &'b self, + self_ty: ty::TyVid, + ) -> impl Iterator, 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) { + 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, + ) { 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>) { + fn check_struct_fields_on_error( + &self, + fields: &'tcx [hir::Field], + base_expr: &'tcx Option>, + ) { 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>) -> Ty<'tcx> - { + fn check_expr_struct( + &self, + expr: &hir::Expr, + expected: Expectation<'tcx>, + qpath: &QPath, + fields: &'tcx [hir::Field], + base_expr: &'tcx Option>, + ) -> 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 { + fn could_remove_semicolon(&self, blk: &'tcx hir::Block, expected_ty: Ty<'tcx>) -> Option { // 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 R, R>(&self, id: hir::HirId, - ctxt: BreakableCtxt<'tcx>, f: F) - -> (BreakableCtxt<'tcx>, R) { + fn with_breakable_ctxt 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 1c129882d9c10..93855a3b68a7f 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 = 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 8baf6d03e1d9f..77ac2b96160a6 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 7816d8e2ba550..4336e861ce216 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 542ced1595319..d4b2c200297d2 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> { +pub fn checked_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fail: bool) -> Option> { 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 52fa0d8ebdc41..b833d8555ee0a 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 40168e917e996..ea458842acce6 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);