1
Fork 0

rustc: replace TyCtxt<'a, 'gcx, 'tcx> with TyCtxt<'tcx, 'gcx, 'tcx>.

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-11 22:03:44 +03:00
parent 3f511ade5b
commit 37799a5552
292 changed files with 1824 additions and 1838 deletions

View file

@ -8,7 +8,7 @@ use crate::hir::{self, PatKind};
use crate::hir::def_id::DefId; use crate::hir::def_id::DefId;
struct CFGBuilder<'a, 'tcx: 'a> { struct CFGBuilder<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
owner_def_id: DefId, owner_def_id: DefId,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
graph: CFGGraph, graph: CFGGraph,
@ -30,7 +30,7 @@ struct LoopScope {
break_index: CFGIndex, // where to go on a `break` break_index: CFGIndex, // where to go on a `break`
} }
pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn construct<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
body: &hir::Body) -> CFG { body: &hir::Body) -> CFG {
let mut graph = graph::Graph::new(); let mut graph = graph::Graph::new();
let entry = graph.add_node(CFGNodeData::Entry); let entry = graph.add_node(CFGNodeData::Entry);

View file

@ -12,7 +12,7 @@ pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
pub type Edge<'a> = &'a cfg::CFGEdge; pub type Edge<'a> = &'a cfg::CFGEdge;
pub struct LabelledCFG<'a, 'tcx: 'a> { pub struct LabelledCFG<'a, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
pub cfg: &'a cfg::CFG, pub cfg: &'a cfg::CFG,
pub name: String, pub name: String,
/// `labelled_edges` controls whether we emit labels on the edges /// `labelled_edges` controls whether we emit labels on the edges

View file

@ -49,7 +49,7 @@ pub type CFGNode = graph::Node<CFGNodeData>;
pub type CFGEdge = graph::Edge<CFGEdgeData>; pub type CFGEdge = graph::Edge<CFGEdgeData>;
impl CFG { impl CFG {
pub fn new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn new<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
body: &hir::Body) -> CFG { body: &hir::Body) -> CFG {
construct::construct(tcx, body) construct::construct(tcx, body)
} }

View file

@ -204,7 +204,7 @@ macro_rules! define_dep_nodes {
impl DepNode { impl DepNode {
#[allow(unreachable_code, non_snake_case)] #[allow(unreachable_code, non_snake_case)]
#[inline(always)] #[inline(always)]
pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
dep: DepConstructor<'gcx>) dep: DepConstructor<'gcx>)
-> DepNode -> DepNode
where 'gcx: 'a + 'tcx, where 'gcx: 'a + 'tcx,
@ -442,49 +442,49 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
]); ]);
pub trait RecoverKey<'tcx>: Sized { pub trait RecoverKey<'tcx>: Sized {
fn recover(tcx: TyCtxt<'_, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>; fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>;
} }
impl RecoverKey<'tcx> for CrateNum { impl RecoverKey<'tcx> for CrateNum {
fn recover(tcx: TyCtxt<'_, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> { fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.krate) dep_node.extract_def_id(tcx).map(|id| id.krate)
} }
} }
impl RecoverKey<'tcx> for DefId { impl RecoverKey<'tcx> for DefId {
fn recover(tcx: TyCtxt<'_, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> { fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx) dep_node.extract_def_id(tcx)
} }
} }
impl RecoverKey<'tcx> for DefIndex { impl RecoverKey<'tcx> for DefIndex {
fn recover(tcx: TyCtxt<'_, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> { fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.index) dep_node.extract_def_id(tcx).map(|id| id.index)
} }
} }
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug {
const CAN_RECONSTRUCT_QUERY_KEY: bool; const CAN_RECONSTRUCT_QUERY_KEY: bool;
/// This method turns the parameters of a DepNodeConstructor into an opaque /// This method turns the parameters of a DepNodeConstructor into an opaque
/// Fingerprint to be used in DepNode. /// Fingerprint to be used in DepNode.
/// Not all DepNodeParams support being turned into a Fingerprint (they /// Not all DepNodeParams support being turned into a Fingerprint (they
/// don't need to if the corresponding DepNode is anonymous). /// don't need to if the corresponding DepNode is anonymous).
fn to_fingerprint(&self, _: TyCtxt<'a, 'gcx, 'tcx>) -> Fingerprint { fn to_fingerprint(&self, _: TyCtxt<'tcx, 'gcx, 'tcx>) -> Fingerprint {
panic!("Not implemented. Accidentally called on anonymous node?") panic!("Not implemented. Accidentally called on anonymous node?")
} }
fn to_debug_str(&self, _: TyCtxt<'a, 'gcx, 'tcx>) -> String { fn to_debug_str(&self, _: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
format!("{:?}", self) format!("{:?}", self)
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
where T: HashStable<StableHashingContext<'a>> + fmt::Debug where T: HashStable<StableHashingContext<'tcx>> + fmt::Debug
{ {
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false; default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
default fn to_fingerprint(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Fingerprint { default fn to_fingerprint(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Fingerprint {
let mut hcx = tcx.create_stable_hashing_context(); let mut hcx = tcx.create_stable_hashing_context();
let mut hasher = StableHasher::new(); let mut hasher = StableHasher::new();
@ -493,36 +493,36 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T
hasher.finish() hasher.finish()
} }
default fn to_debug_str(&self, _: TyCtxt<'a, 'gcx, 'tcx>) -> String { default fn to_debug_str(&self, _: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
format!("{:?}", *self) format!("{:?}", *self)
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefId { impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefId {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; 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 tcx.def_path_hash(*self).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
tcx.def_path_str(*self) tcx.def_path_str(*self)
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefIndex { impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefIndex {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; 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 tcx.hir().definitions().def_path_hash(*self).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
tcx.def_path_str(DefId::local(*self)) tcx.def_path_str(DefId::local(*self))
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for CrateNum { impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for CrateNum {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
@ -533,12 +533,12 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for CrateNum {
tcx.def_path_hash(def_id).0 tcx.def_path_hash(def_id).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
tcx.crate_name(*self).as_str().to_string() tcx.crate_name(*self).as_str().to_string()
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, DefId) { impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) {
const CAN_RECONSTRUCT_QUERY_KEY: bool = false; const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
// We actually would not need to specialize the implementation of this // We actually would not need to specialize the implementation of this
@ -553,7 +553,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, De
def_path_hash_0.0.combine(def_path_hash_1.0) def_path_hash_0.0.combine(def_path_hash_1.0)
} }
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
let (def_id_0, def_id_1) = *self; let (def_id_0, def_id_1) = *self;
format!("({}, {})", format!("({}, {})",
@ -562,7 +562,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, De
} }
} }
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for HirId { impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for HirId {
const CAN_RECONSTRUCT_QUERY_KEY: bool = false; const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
// We actually would not need to specialize the implementation of this // We actually would not need to specialize the implementation of this

View file

@ -604,7 +604,7 @@ impl DepGraph {
/// Try to mark a dep-node which existed in the previous compilation session as green. /// Try to mark a dep-node which existed in the previous compilation session as green.
fn try_mark_previous_green<'tcx>( fn try_mark_previous_green<'tcx>(
&self, &self,
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
data: &DepGraphData, data: &DepGraphData,
prev_dep_node_index: SerializedDepNodeIndex, prev_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode dep_node: &DepNode
@ -791,7 +791,7 @@ impl DepGraph {
#[inline(never)] #[inline(never)]
fn emit_diagnostics<'tcx>( fn emit_diagnostics<'tcx>(
&self, &self,
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
data: &DepGraphData, data: &DepGraphData,
dep_node_index: DepNodeIndex, dep_node_index: DepNodeIndex,
did_allocation: bool, did_allocation: bool,
@ -842,7 +842,7 @@ impl DepGraph {
// //
// This method will only load queries that will end up in the disk cache. // This method will only load queries that will end up in the disk cache.
// Other queries will not be executed. // Other queries will not be executed.
pub fn exec_cache_promotions<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn exec_cache_promotions<'a, 'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) {
let green_nodes: Vec<DepNode> = { let green_nodes: Vec<DepNode> = {
let data = self.data.as_ref().unwrap(); let data = self.data.as_ref().unwrap();
data.colors.values.indices().filter_map(|prev_index| { data.colors.values.indices().filter_map(|prev_index| {

View file

@ -33,7 +33,7 @@ impl DepGraphSafe for DefId {
/// The type context itself can be used to access all kinds of tracked /// The type context itself can be used to access all kinds of tracked
/// state, but those accesses should always generate read events. /// state, but those accesses should always generate read events.
impl<'a, 'gcx, 'tcx> DepGraphSafe for TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> DepGraphSafe for TyCtxt<'tcx, 'gcx, 'tcx> {
} }
/// Tuples make it easy to build up state. /// Tuples make it easy to build up state.

View file

@ -87,11 +87,11 @@ impl Target {
} }
} }
struct CheckAttrVisitor<'a, 'tcx: 'a> { struct CheckAttrVisitor<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
} }
impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { impl CheckAttrVisitor<'tcx> {
/// Checks any attribute. /// Checks any attribute.
fn check_attributes(&self, item: &hir::Item, target: Target) { fn check_attributes(&self, item: &hir::Item, target: Target) {
if target == Target::Fn || target == Target::Const { if target == Target::Fn || target == Target::Const {
@ -310,7 +310,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> { impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
@ -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, 'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module( tcx.hir().visit_item_likes_in_module(
module_def_id, module_def_id,
&mut CheckAttrVisitor { tcx }.as_deep_visitor() &mut CheckAttrVisitor { tcx }.as_deep_visitor()

View file

@ -55,7 +55,7 @@ impl Visitor<'tcx> for LocalCollector {
} }
struct CaptureCollector<'a, 'tcx> { struct CaptureCollector<'a, 'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
locals: &'a FxHashSet<HirId>, locals: &'a FxHashSet<HirId>,
upvars: FxIndexMap<HirId, hir::Upvar>, upvars: FxIndexMap<HirId, hir::Upvar>,
} }

View file

@ -205,8 +205,8 @@ for &'b mut T {
} }
} }
impl<'a, 'gcx, 'lcx> StableHashingContextProvider<'a> for TyCtxt<'a, 'gcx, 'lcx> { impl StableHashingContextProvider<'lcx> for TyCtxt<'lcx, 'gcx, 'lcx> {
fn get_stable_hashing_context(&self) -> StableHashingContext<'a> { fn get_stable_hashing_context(&self) -> StableHashingContext<'lcx> {
(*self).create_stable_hashing_context() (*self).create_stable_hashing_context()
} }
} }

View file

@ -277,7 +277,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>, infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>,
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
variables: SmallVec<[CanonicalVarInfo; 8]>, variables: SmallVec<[CanonicalVarInfo; 8]>,
query_state: &'cx mut OriginalQueryValues<'tcx>, query_state: &'cx mut OriginalQueryValues<'tcx>,
// Note that indices is only used once `var_values` is big enough to be // Note that indices is only used once `var_values` is big enough to be
@ -290,7 +290,7 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
} }
impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> { impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.tcx self.tcx
} }
@ -501,7 +501,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
fn canonicalize<V>( fn canonicalize<V>(
value: &V, value: &V,
infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>, infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>,
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalize_region_mode: &dyn CanonicalizeRegionMode, canonicalize_region_mode: &dyn CanonicalizeRegionMode,
query_state: &mut OriginalQueryValues<'tcx>, query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonicalized<'gcx, V> ) -> Canonicalized<'gcx, V>

View file

@ -478,7 +478,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
/// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]` /// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]`
/// we'll return a substitution `subst` with: /// we'll return a substitution `subst` with:
/// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`. /// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`.
pub fn make_identity<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self { pub fn make_identity<'a>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Self {
use crate::ty::subst::UnpackedKind; use crate::ty::subst::UnpackedKind;
CanonicalVarValues { CanonicalVarValues {

View file

@ -29,7 +29,7 @@ use crate::ty::subst::{Kind, UnpackedKind};
use crate::ty::{self, BoundVar, InferConst, Lift, Ty, TyCtxt}; use crate::ty::{self, BoundVar, InferConst, Lift, Ty, TyCtxt};
use crate::util::captures::Captures; use crate::util::captures::Captures;
impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> { impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
/// The "main method" for a canonicalized trait query. Given the /// The "main method" for a canonicalized trait query. Given the
/// canonical key `canonical_key`, this method will create a new /// canonical key `canonical_key`, this method will create a new
/// inference context, instantiate the key, and run your operation /// inference context, instantiate the key, and run your operation
@ -647,7 +647,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
/// Given the region obligations and constraints scraped from the infcx, /// Given the region obligations and constraints scraped from the infcx,
/// creates query region constraints. /// creates query region constraints.
pub fn make_query_outlives<'tcx>( pub fn make_query_outlives<'tcx>(
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>)>, outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>)>,
region_constraints: &RegionConstraintData<'tcx>, region_constraints: &RegionConstraintData<'tcx>,
) -> Vec<QueryRegionConstraint<'tcx>> { ) -> Vec<QueryRegionConstraint<'tcx>> {

View file

@ -14,7 +14,11 @@ use crate::ty::{self, TyCtxt};
impl<'tcx, V> Canonical<'tcx, V> { impl<'tcx, V> Canonical<'tcx, V> {
/// Instantiate the wrapped value, replacing each canonical value /// Instantiate the wrapped value, replacing each canonical value
/// with the value given in `var_values`. /// 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, '_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>,
) -> V
where where
V: TypeFoldable<'tcx>, V: TypeFoldable<'tcx>,
{ {
@ -29,7 +33,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
/// V, replacing each of the canonical variables. /// V, replacing each of the canonical variables.
pub fn substitute_projected<T>( pub fn substitute_projected<T>(
&self, &self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>, var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> &T, projection_fn: impl FnOnce(&V) -> &T,
) -> T ) -> T
@ -46,7 +50,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
/// must be values for the set of canonical variables that appear in /// must be values for the set of canonical variables that appear in
/// `value`. /// `value`.
pub(super) fn substitute_value<'a, 'tcx, T>( pub(super) fn substitute_value<'a, 'tcx, T>(
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>, var_values: &CanonicalVarValues<'tcx>,
value: &'a T, value: &'a T,
) -> T ) -> T

View file

@ -63,7 +63,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
a: Ty<'tcx>, a: Ty<'tcx>,
b: Ty<'tcx>) b: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>> -> RelateResult<'tcx, Ty<'tcx>>
where R: TypeRelation<'infcx, 'gcx, 'tcx> where R: TypeRelation<'gcx, 'tcx>
{ {
let a_is_expected = relation.a_is_expected(); let a_is_expected = relation.a_is_expected();
@ -123,7 +123,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
b: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>,
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
where where
R: TypeRelation<'infcx, 'gcx, 'tcx>, R: TypeRelation<'gcx, 'tcx>,
{ {
let a_is_expected = relation.a_is_expected(); let a_is_expected = relation.a_is_expected();
@ -207,7 +207,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
} }
impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { pub fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -413,8 +413,8 @@ struct Generalization<'tcx> {
needs_wf: bool, needs_wf: bool,
} }
impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, 'tcx> { impl TypeRelation<'gcx, 'tcx> for Generalizer<'_, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -24,12 +24,10 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Equate<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> impl TypeRelation<'gcx, 'tcx> for Equate<'combine, 'infcx, 'gcx, 'tcx> {
for Equate<'combine, 'infcx, 'gcx, 'tcx>
{
fn tag(&self) -> &'static str { "Equate" } fn tag(&self) -> &'static str { "Equate" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }

View file

@ -67,7 +67,7 @@ mod need_type_info;
pub mod nice_region_error; pub mod nice_region_error;
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn note_and_explain_region( pub fn note_and_explain_region(
self, self,
region_scope_tree: &region::ScopeTree, region_scope_tree: &region::ScopeTree,
@ -445,13 +445,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
use ty::print::Printer; use ty::print::Printer;
use ty::subst::Kind; use ty::subst::Kind;
struct AbsolutePathPrinter<'a, 'gcx, 'tcx> { struct AbsolutePathPrinter<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
} }
struct NonTrivialPath; struct NonTrivialPath;
impl<'gcx, 'tcx> Printer<'gcx, 'tcx> for AbsolutePathPrinter<'_, 'gcx, 'tcx> { impl<'gcx, 'tcx> Printer<'gcx, 'tcx> for AbsolutePathPrinter<'gcx, 'tcx> {
type Error = NonTrivialPath; type Error = NonTrivialPath;
type Path = Vec<String>; type Path = Vec<String>;
@ -460,7 +460,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
type DynExistential = !; type DynExistential = !;
type Const = !; type Const = !;
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -81,8 +81,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
// walk the types like &mut Vec<&u8> and &u8 looking for the HIR // walk the types like &mut Vec<&u8> and &u8 looking for the HIR
// where that lifetime appears. This allows us to highlight the // where that lifetime appears. This allows us to highlight the
// specific part of the type in the error message. // specific part of the type in the error message.
struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { struct FindNestedTypeVisitor<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
// The bound_region corresponding to the Refree(freeregion) // The bound_region corresponding to the Refree(freeregion)
// associated with the anonymous region we are looking for. // associated with the anonymous region we are looking for.
bound_region: ty::BoundRegion, bound_region: ty::BoundRegion,
@ -92,7 +92,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
current_index: ty::DebruijnIndex, current_index: ty::DebruijnIndex,
} }
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { impl Visitor<'gcx> for FindNestedTypeVisitor<'gcx, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
@ -208,14 +208,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
// and would walk the types like Vec<Ref> in the above example and Ref looking for the HIR // and would walk the types like Vec<Ref> in the above example and Ref looking for the HIR
// where that lifetime appears. This allows us to highlight the // where that lifetime appears. This allows us to highlight the
// specific part of the type in the error message. // specific part of the type in the error message.
struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { struct TyPathVisitor<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
found_it: bool, found_it: bool,
bound_region: ty::BoundRegion, bound_region: ty::BoundRegion,
current_index: ty::DebruijnIndex, current_index: ty::DebruijnIndex,
} }
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> { impl Visitor<'gcx> for TyPathVisitor<'gcx, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }

View file

@ -56,7 +56,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {
Self { infcx, error: None, regions: Some((span, sub, sup)), tables } Self { infcx, error: None, regions: Some((span, sub, sup)), tables }
} }
fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -321,14 +321,14 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
) { ) {
// HACK(eddyb) maybe move this in a more central location. // HACK(eddyb) maybe move this in a more central location.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct Highlighted<'a, 'gcx, 'tcx, T> { struct Highlighted<'gcx, 'tcx, T> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
highlight: RegionHighlightMode, highlight: RegionHighlightMode,
value: T, value: T,
} }
impl<'a, 'gcx, 'tcx, T> Highlighted<'a, 'gcx, 'tcx, T> { impl<'gcx, 'tcx, T> Highlighted<'gcx, 'tcx, T> {
fn map<U>(self, f: impl FnOnce(T) -> U) -> Highlighted<'a, 'gcx, 'tcx, U> { fn map<U>(self, f: impl FnOnce(T) -> U) -> Highlighted<'gcx, 'tcx, U> {
Highlighted { Highlighted {
tcx: self.tcx, tcx: self.tcx,
highlight: self.highlight, highlight: self.highlight,
@ -337,8 +337,8 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx, T> fmt::Display for Highlighted<'a, 'gcx, 'tcx, T> impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T>
where T: for<'b, 'c> Print<'gcx, 'tcx, where T: for<'a, 'b, 'c> Print<'gcx, 'tcx,
FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>, FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>,
Error = fmt::Error, Error = fmt::Error,
>, >,

View file

@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -143,7 +143,7 @@ pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -21,12 +21,10 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Glb<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> impl TypeRelation<'gcx, 'tcx> for Glb<'combine, 'infcx, 'gcx, 'tcx> {
for Glb<'combine, 'infcx, 'gcx, 'tcx>
{
fn tag(&self) -> &'static str { "Glb" } fn tag(&self) -> &'static str { "Glb" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }

View file

@ -27,7 +27,7 @@ use crate::ty::TyVar;
use crate::ty::{self, Ty}; use crate::ty::{self, Ty};
use crate::ty::relate::{RelateResult, TypeRelation}; use crate::ty::relate::{RelateResult, TypeRelation};
pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'f, 'gcx, 'tcx> { pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'gcx, 'tcx> {
fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>; fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>;
fn cause(&self) -> &ObligationCause<'tcx>; fn cause(&self) -> &ObligationCause<'tcx>;

View file

@ -103,7 +103,7 @@ struct LexicalResolver<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
} }
impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.region_rels.tcx self.region_rels.tcx
} }
@ -136,7 +136,7 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
/// Initially, the value for all variables is set to `'empty`, the /// Initially, the value for all variables is set to `'empty`, the
/// empty region. The `expansion` phase will grow this larger. /// 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, '_, 'tcx>) -> LexicalRegionResolutions<'tcx> {
LexicalRegionResolutions { LexicalRegionResolutions {
error_region: tcx.lifetimes.re_static, error_region: tcx.lifetimes.re_static,
values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars()) values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars())
@ -785,7 +785,7 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
} }
impl<'tcx> LexicalRegionResolutions<'tcx> { impl<'tcx> LexicalRegionResolutions<'tcx> {
fn normalize<T>(&self, tcx: TyCtxt<'_, '_, 'tcx>, value: T) -> T fn normalize<T>(&self, tcx: TyCtxt<'tcx, '_, 'tcx>, value: T) -> T
where where
T: TypeFoldable<'tcx>, T: TypeFoldable<'tcx>,
{ {

View file

@ -21,12 +21,10 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Lub<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> impl TypeRelation<'gcx, 'tcx> for Lub<'combine, 'infcx, 'gcx, 'tcx> {
for Lub<'combine, 'infcx, 'gcx, 'tcx>
{
fn tag(&self) -> &'static str { "Lub" } fn tag(&self) -> &'static str { "Lub" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() } fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }

View file

@ -102,8 +102,8 @@ impl SuppressRegionErrors {
} }
} }
pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct InferCtxt<'a, 'gcx, 'tcx> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
/// During type-checking/inference of a body, `in_progress_tables` /// During type-checking/inference of a body, `in_progress_tables`
/// contains a reference to the tables being built up, which are /// contains a reference to the tables being built up, which are
@ -465,13 +465,13 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
/// Helper type of a temporary returned by `tcx.infer_ctxt()`. /// Helper type of a temporary returned by `tcx.infer_ctxt()`.
/// Necessary because we can't write the following bound: /// Necessary because we can't write the following bound:
/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`. /// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`.
pub struct InferCtxtBuilder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct InferCtxtBuilder<'gcx, 'tcx> {
global_tcx: TyCtxt<'a, 'gcx, 'gcx>, global_tcx: TyCtxt<'gcx, 'gcx, 'gcx>,
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>, fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> { impl TyCtxt<'gcx, 'gcx, 'gcx> {
pub fn infer_ctxt(self) -> InferCtxtBuilder<'a, 'gcx, 'tcx> { pub fn infer_ctxt<'tcx>(self) -> InferCtxtBuilder<'gcx, 'tcx> {
InferCtxtBuilder { InferCtxtBuilder {
global_tcx: self, global_tcx: self,
fresh_tables: None, fresh_tables: None,
@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> {
} }
} }
impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> { impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
/// Used only by `rustc_typeck` during body type-checking/inference, /// Used only by `rustc_typeck` during body type-checking/inference,
/// will initialize `in_progress_tables` with fresh `TypeckTables`. /// will initialize `in_progress_tables` with fresh `TypeckTables`.
pub fn with_fresh_in_progress_tables(mut self, table_owner: DefId) -> Self { pub fn with_fresh_in_progress_tables(mut self, table_owner: DefId) -> Self {
@ -498,7 +498,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
&'tcx mut self, &'tcx mut self,
span: Span, span: Span,
canonical: &Canonical<'tcx, T>, canonical: &Canonical<'tcx, T>,
f: impl for<'b> FnOnce(InferCtxt<'b, 'gcx, 'tcx>, T, CanonicalVarValues<'tcx>) -> R, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>, T, CanonicalVarValues<'tcx>) -> R,
) -> R ) -> R
where where
T: TypeFoldable<'tcx>, T: TypeFoldable<'tcx>,
@ -510,7 +510,7 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
}) })
} }
pub fn enter<R>(&'tcx mut self, f: impl for<'b> FnOnce(InferCtxt<'b, 'gcx, 'tcx>) -> R) -> R { pub fn enter<R>(&'tcx mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R {
let InferCtxtBuilder { let InferCtxtBuilder {
global_tcx, global_tcx,
ref fresh_tables, ref fresh_tables,
@ -1600,7 +1600,7 @@ impl<'a, 'gcx, 'tcx> ShallowResolver<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -1641,7 +1641,7 @@ impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {
} }
} }
pub fn dummy(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> TypeTrace<'tcx> { pub fn dummy(tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> TypeTrace<'tcx> {
TypeTrace { TypeTrace {
cause: ObligationCause::dummy(), cause: ObligationCause::dummy(),
values: Types(ExpectedFound { values: Types(ExpectedFound {

View file

@ -494,11 +494,11 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) {
} }
} }
impl<D> TypeRelation<'me, 'gcx, 'tcx> for TypeRelating<'me, 'gcx, 'tcx, D> impl<D> TypeRelation<'gcx, 'tcx> for TypeRelating<'me, 'gcx, 'tcx, D>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
{ {
fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -823,11 +823,11 @@ where
universe: ty::UniverseIndex, universe: ty::UniverseIndex,
} }
impl<D> TypeRelation<'me, 'gcx, 'tcx> for TypeGeneralizer<'me, 'gcx, 'tcx, D> impl<D> TypeRelation<'gcx, 'tcx> for TypeGeneralizer<'me, 'gcx, 'tcx, D>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
{ {
fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -552,8 +552,8 @@ impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx>
} }
} }
struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> { struct ReverseMapper<'gcx, 'tcx> {
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
/// If errors have already been reported in this fn, we suppress /// If errors have already been reported in this fn, we suppress
/// our own errors because they are sometimes derivative. /// our own errors because they are sometimes derivative.
@ -567,9 +567,9 @@ struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
hidden_ty: Option<Ty<'tcx>>, hidden_ty: Option<Ty<'tcx>>,
} }
impl<'cx, 'gcx, 'tcx> ReverseMapper<'cx, 'gcx, 'tcx> { impl ReverseMapper<'gcx, 'tcx> {
fn new( fn new(
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
tainted_by_errors: bool, tainted_by_errors: bool,
opaque_type_def_id: DefId, opaque_type_def_id: DefId,
map: FxHashMap<Kind<'tcx>, Kind<'gcx>>, map: FxHashMap<Kind<'tcx>, Kind<'gcx>>,
@ -599,8 +599,8 @@ impl<'cx, 'gcx, 'tcx> ReverseMapper<'cx, 'gcx, 'tcx> {
} }
} }
impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx> { impl TypeFolder<'gcx, 'tcx> for ReverseMapper<'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'_, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -29,7 +29,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
/// avoid making arbitrary choices. See /// avoid making arbitrary choices. See
/// `TransitiveRelation::postdom_upper_bound` for more details. /// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_free_regions<'a, 'gcx>(&self, pub fn lub_free_regions<'a, 'gcx>(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
r_a: Region<'tcx>, r_a: Region<'tcx>,
r_b: Region<'tcx>) r_b: Region<'tcx>)
-> Region<'tcx> { -> Region<'tcx> {
@ -90,7 +90,7 @@ impl_stable_hash_for!(struct FreeRegionMap<'tcx> {
impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> { impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> {
type Lifted = FreeRegionMap<'tcx>; type Lifted = FreeRegionMap<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<FreeRegionMap<'tcx>> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<FreeRegionMap<'tcx>> {
self.relation.maybe_map(|&fr| tcx.lift(&fr)) self.relation.maybe_map(|&fr| tcx.lift(&fr))
.map(|relation| FreeRegionMap { relation }) .map(|relation| FreeRegionMap { relation })
} }

View file

@ -233,7 +233,7 @@ where
// See the comments on `process_registered_region_obligations` for the meaning // See the comments on `process_registered_region_obligations` for the meaning
// of these fields. // of these fields.
delegate: D, delegate: D,
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
verify_bound: VerifyBoundCx<'cx, 'gcx, 'tcx>, verify_bound: VerifyBoundCx<'cx, 'gcx, 'tcx>,
} }
@ -260,7 +260,7 @@ where
{ {
pub fn new( pub fn new(
delegate: D, delegate: D,
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,

View file

@ -13,7 +13,7 @@ use crate::util::captures::Captures;
/// accrues them into the `region_obligations` code, but for NLL we /// accrues them into the `region_obligations` code, but for NLL we
/// use something else. /// use something else.
pub struct VerifyBoundCx<'cx, 'gcx: 'tcx, 'tcx: 'cx> { pub struct VerifyBoundCx<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
@ -21,7 +21,7 @@ pub struct VerifyBoundCx<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
pub fn new( pub fn new(
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,

View file

@ -22,7 +22,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
/// refactor the constraint set. /// refactor the constraint set.
pub fn leak_check( pub fn leak_check(
&mut self, &mut self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
overly_polymorphic: bool, overly_polymorphic: bool,
placeholder_map: &PlaceholderMap<'tcx>, placeholder_map: &PlaceholderMap<'tcx>,
_snapshot: &CombinedSnapshot<'_, 'tcx>, _snapshot: &CombinedSnapshot<'_, 'tcx>,
@ -109,7 +109,7 @@ impl<'tcx> TaintSet<'tcx> {
fn fixed_point( fn fixed_point(
&mut self, &mut self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
undo_log: &[UndoLog<'tcx>], undo_log: &[UndoLog<'tcx>],
verifys: &[Verify<'tcx>], verifys: &[Verify<'tcx>],
) { ) {

View file

@ -700,7 +700,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
pub fn lub_regions( pub fn lub_regions(
&mut self, &mut self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
origin: SubregionOrigin<'tcx>, origin: SubregionOrigin<'tcx>,
a: Region<'tcx>, a: Region<'tcx>,
b: Region<'tcx>, b: Region<'tcx>,
@ -722,7 +722,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
pub fn glb_regions( pub fn glb_regions(
&mut self, &mut self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
origin: SubregionOrigin<'tcx>, origin: SubregionOrigin<'tcx>,
a: Region<'tcx>, a: Region<'tcx>,
b: Region<'tcx>, b: Region<'tcx>,
@ -744,7 +744,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
pub fn opportunistic_resolve_var( pub fn opportunistic_resolve_var(
&mut self, &mut self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
rid: RegionVid, rid: RegionVid,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
let vid = self.unification_table.probe_value(rid).min_vid; let vid = self.unification_table.probe_value(rid).min_vid;
@ -760,7 +760,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
fn combine_vars( fn combine_vars(
&mut self, &mut self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
t: CombineMapType, t: CombineMapType,
a: Region<'tcx>, a: Region<'tcx>,
b: Region<'tcx>, b: Region<'tcx>,
@ -850,7 +850,7 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> {
} }
impl<'a, 'gcx, 'tcx> GenericKind<'tcx> { impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
pub fn to_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { pub fn to_ty(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Ty<'tcx> {
match *self { match *self {
GenericKind::Param(ref p) => p.to_ty(tcx), GenericKind::Param(ref p) => p.to_ty(tcx),
GenericKind::Projection(ref p) => tcx.mk_projection(p.item_def_id, p.substs), GenericKind::Projection(ref p) => tcx.mk_projection(p.item_def_id, p.substs),

View file

@ -24,7 +24,7 @@ impl<'a, 'gcx, 'tcx> OpportunisticVarResolver<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -177,7 +177,7 @@ struct FullTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -31,11 +31,9 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Sub<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> impl TypeRelation<'gcx, 'tcx> for Sub<'combine, 'infcx, 'gcx, 'tcx> {
for Sub<'combine, 'infcx, 'gcx, 'tcx>
{
fn tag(&self) -> &'static str { "Sub" } fn tag(&self) -> &'static str { "Sub" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.infcx.tcx } fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.fields.infcx.tcx }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }
fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R

View file

@ -10,7 +10,7 @@ use std::marker::PhantomData;
use std::cell::RefMut; use std::cell::RefMut;
pub trait ToType { pub trait ToType {
fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>; fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Ty<'tcx>;
} }
impl UnifyKey for ty::IntVid { impl UnifyKey for ty::IntVid {
@ -52,7 +52,7 @@ impl UnifyKey for ty::RegionVid {
} }
impl ToType for IntVarValue { impl ToType for IntVarValue {
fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Ty<'tcx> {
match *self { match *self {
ty::IntType(i) => tcx.mk_mach_int(i), ty::IntType(i) => tcx.mk_mach_int(i),
ty::UintType(i) => tcx.mk_mach_uint(i), ty::UintType(i) => tcx.mk_mach_uint(i),
@ -72,7 +72,7 @@ impl UnifyKey for ty::FloatVid {
impl EqUnifyValue for FloatVarValue {} impl EqUnifyValue for FloatVarValue {}
impl ToType for FloatVarValue { impl ToType for FloatVarValue {
fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Ty<'tcx> {
tcx.mk_mach_float(self.0) tcx.mk_mach_float(self.0)
} }
} }

View file

@ -509,7 +509,7 @@ impl LintStore {
/// Context for lint checking after type checking. /// Context for lint checking after type checking.
pub struct LateContext<'a, 'tcx: 'a> { pub struct LateContext<'a, 'tcx: 'a> {
/// Type context we're checking in. /// Type context we're checking in.
pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
/// Side-tables for the body we are in. /// Side-tables for the body we are in.
// FIXME: Make this lazy to avoid running the TypeckTables query? // FIXME: Make this lazy to avoid running the TypeckTables query?
@ -780,11 +780,11 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
/// } /// }
/// ``` /// ```
pub fn get_def_path(&self, def_id: DefId) -> Vec<Symbol> { pub fn get_def_path(&self, def_id: DefId) -> Vec<Symbol> {
pub struct AbsolutePathPrinter<'a, 'tcx> { pub struct AbsolutePathPrinter<'tcx> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
} }
impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> { impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> {
type Error = !; type Error = !;
type Path = Vec<Symbol>; type Path = Vec<Symbol>;
@ -793,7 +793,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
type DynExistential = (); type DynExistential = ();
type Const = (); type Const = ();
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx, 'tcx> {
self.tcx self.tcx
} }
@ -1372,7 +1372,7 @@ macro_rules! late_lint_pass_impl {
late_lint_methods!(late_lint_pass_impl, [], ['tcx]); late_lint_methods!(late_lint_pass_impl, [], ['tcx]);
fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
module_def_id: DefId, module_def_id: DefId,
pass: T, 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>>( pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
module_def_id: DefId, module_def_id: DefId,
builtin_lints: T, builtin_lints: T,
) { ) {
@ -1424,7 +1424,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>>( fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
pass: T pass: T
) { ) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
@ -1460,7 +1460,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
} }
fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
builtin_lints: T builtin_lints: T
) { ) {
let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap(); let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap();
@ -1494,7 +1494,7 @@ fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
/// Performs lint checking on a crate. /// Performs lint checking on a crate.
pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
builtin_lints: impl FnOnce() -> T + Send, builtin_lints: impl FnOnce() -> T + Send,
) { ) {
join(|| { join(|| {

View file

@ -766,7 +766,7 @@ pub fn maybe_lint_level_root(tcx: TyCtxt<'_, '_, '_>, id: hir::HirId) -> bool {
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
} }
fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum) fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, cnum: CrateNum)
-> &'tcx LintLevelMap -> &'tcx LintLevelMap
{ {
assert_eq!(cnum, LOCAL_CRATE); assert_eq!(cnum, LOCAL_CRATE);
@ -787,12 +787,12 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
tcx.arena.alloc(builder.levels.build_map()) tcx.arena.alloc(builder.levels.build_map())
} }
struct LintLevelMapBuilder<'a, 'tcx: 'a> { struct LintLevelMapBuilder<'tcx> {
levels: levels::LintLevelsBuilder<'tcx>, levels: levels::LintLevelsBuilder<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
} }
impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> { impl LintLevelMapBuilder<'tcx> {
fn with_lint_attrs<F>(&mut self, fn with_lint_attrs<F>(&mut self,
id: hir::HirId, id: hir::HirId,
attrs: &[ast::Attribute], attrs: &[ast::Attribute],
@ -808,7 +808,7 @@ impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> { impl intravisit::Visitor<'tcx> for LintLevelMapBuilder<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
intravisit::NestedVisitorMap::All(&self.tcx.hir()) intravisit::NestedVisitorMap::All(&self.tcx.hir())
} }

View file

@ -264,7 +264,7 @@ macro_rules! BraceStructLiftImpl {
{ {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<$lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<$lifted> {
$(let $field = tcx.lift(&self.$field)?;)* $(let $field = tcx.lift(&self.$field)?;)*
Some(Self::Lifted { $($field),* }) Some(Self::Lifted { $($field),* })
} }
@ -283,7 +283,7 @@ macro_rules! EnumLiftImpl {
{ {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<$lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<$lifted> {
EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output()) EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output())
} }
} }

View file

@ -212,7 +212,7 @@ pub trait CrateStore {
// utility functions // utility functions
fn encode_metadata<'a, 'tcx>(&self, fn encode_metadata<'a, 'tcx>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>) tcx: TyCtxt<'tcx, 'tcx, 'tcx>)
-> EncodedMetadata; -> EncodedMetadata;
fn metadata_encoding_version(&self) -> &[u8]; fn metadata_encoding_version(&self) -> &[u8];
} }

View file

@ -26,7 +26,7 @@ use syntax_pos;
// explored. For example, if it's a live Node::Item that is a // 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 // function, then we should explore its block to check for codes that
// may need to be marked as live. // may need to be marked as live.
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn should_explore<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
hir_id: hir::HirId) -> bool { hir_id: hir::HirId) -> bool {
match tcx.hir().find_by_hir_id(hir_id) { match tcx.hir().find_by_hir_id(hir_id) {
Some(Node::Item(..)) | Some(Node::Item(..)) |
@ -41,7 +41,7 @@ fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct MarkSymbolVisitor<'a, 'tcx: 'a> { struct MarkSymbolVisitor<'a, 'tcx: 'a> {
worklist: Vec<hir::HirId>, worklist: Vec<hir::HirId>,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
live_symbols: FxHashSet<hir::HirId>, live_symbols: FxHashSet<hir::HirId>,
repr_has_repr_c: bool, repr_has_repr_c: bool,
@ -353,7 +353,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
struct LifeSeeder<'k, 'tcx: 'k> { struct LifeSeeder<'k, 'tcx: 'k> {
worklist: Vec<hir::HirId>, worklist: Vec<hir::HirId>,
krate: &'k hir::Crate, krate: &'k hir::Crate,
tcx: TyCtxt<'k, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
// see `MarkSymbolVisitor::struct_constructors` // see `MarkSymbolVisitor::struct_constructors`
struct_constructors: FxHashMap<hir::HirId, hir::HirId>, struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
} }
@ -424,7 +424,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
} }
fn create_and_seed_worklist<'a, 'tcx>( fn create_and_seed_worklist<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
access_levels: &privacy::AccessLevels, access_levels: &privacy::AccessLevels,
krate: &hir::Crate, krate: &hir::Crate,
) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) { ) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) {
@ -451,7 +451,7 @@ fn create_and_seed_worklist<'a, 'tcx>(
(life_seeder.worklist, life_seeder.struct_constructors) (life_seeder.worklist, life_seeder.struct_constructors)
} }
fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn find_live<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
access_levels: &privacy::AccessLevels, access_levels: &privacy::AccessLevels,
krate: &hir::Crate) krate: &hir::Crate)
-> FxHashSet<hir::HirId> { -> FxHashSet<hir::HirId> {
@ -471,12 +471,12 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
symbol_visitor.live_symbols symbol_visitor.live_symbols
} }
struct DeadVisitor<'a, 'tcx: 'a> { struct DeadVisitor<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
live_symbols: FxHashSet<hir::HirId>, live_symbols: FxHashSet<hir::HirId>,
} }
impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { impl DeadVisitor<'tcx> {
fn should_warn_about_item(&mut self, item: &hir::Item) -> bool { fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
let should_warn = match item.node { let should_warn = match item.node {
hir::ItemKind::Static(..) hir::ItemKind::Static(..)
@ -554,7 +554,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { impl Visitor<'tcx> for DeadVisitor<'tcx> {
/// Walk nested items in place so that we don't report dead-code /// Walk nested items in place so that we don't report dead-code
/// on inner functions when the outer function is already getting /// on inner functions when the outer function is already getting
/// an error. We could do this also by checking the parents, but /// an error. We could do this also by checking the parents, but
@ -660,7 +660,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
} }
} }
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir().krate(); let krate = tcx.hir().krate();
let live_symbols = find_live(tcx, access_levels, krate); let live_symbols = find_live(tcx, access_levels, krate);

View file

@ -81,7 +81,7 @@ pub enum Linkage {
Dynamic, Dynamic,
} }
pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) {
let sess = &tcx.sess; let sess = &tcx.sess;
let fmts = sess.crate_types.borrow().iter().map(|&ty| { let fmts = sess.crate_types.borrow().iter().map(|&ty| {
let linkage = calculate_type(tcx, ty); let linkage = calculate_type(tcx, ty);
@ -92,7 +92,7 @@ pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
sess.dependency_formats.set(fmts); sess.dependency_formats.set(fmts);
} }
fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
ty: config::CrateType) -> DependencyList { ty: config::CrateType) -> DependencyList {
let sess = &tcx.sess; let sess = &tcx.sess;
@ -267,7 +267,7 @@ fn add_library(tcx: TyCtxt<'_, '_, '_>,
} }
} }
fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<DependencyList> { fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Option<DependencyList> {
let sess = &tcx.sess; let sess = &tcx.sess;
let crates = cstore::used_crates(tcx, RequireStatic); let crates = cstore::used_crates(tcx, RequireStatic);
if !crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) { if !crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) {
@ -324,7 +324,7 @@ fn activate_injected_dep(injected: Option<CrateNum>,
// After the linkage for a crate has been determined we need to verify that // 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. // there's only going to be one allocator in the output.
fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) { fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, list: &[Linkage]) {
let sess = &tcx.sess; let sess = &tcx.sess;
if list.len() == 0 { if list.len() == 0 {
return return

View file

@ -267,7 +267,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
/// ///
/// See also `with_infer`, which is used *during* typeck. /// See also `with_infer`, which is used *during* typeck.
pub fn new(delegate: &'a mut (dyn Delegate<'tcx>+'a), pub fn new(delegate: &'a mut (dyn Delegate<'tcx>+'a),
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
body_owner: DefId, body_owner: DefId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_expr(&body.value); self.consume_expr(&body.value);
} }
fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.mc.tcx self.mc.tcx
} }

View file

@ -16,7 +16,7 @@ use crate::ty::{self, TyCtxt, Region};
/// This stuff is a bit convoluted and should be refactored, but as we /// This stuff is a bit convoluted and should be refactored, but as we
/// transition to NLL, it'll all go away anyhow. /// transition to NLL, it'll all go away anyhow.
pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> { pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
/// The context used to fetch the region maps. /// The context used to fetch the region maps.
pub context: DefId, pub context: DefId,
@ -30,7 +30,7 @@ pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> {
pub fn new( pub fn new(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
context: DefId, context: DefId,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
free_regions: &'a FreeRegionMap<'tcx>, free_regions: &'a FreeRegionMap<'tcx>,

View file

@ -10,7 +10,7 @@ use syntax_pos::{Span, sym};
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
use crate::hir; use crate::hir;
fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) { fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module( tcx.hir().visit_item_likes_in_module(
module_def_id, module_def_id,
&mut ItemVisitor { tcx }.as_deep_visitor() &mut ItemVisitor { tcx }.as_deep_visitor()
@ -24,19 +24,19 @@ pub fn provide(providers: &mut Providers<'_>) {
}; };
} }
struct ItemVisitor<'a, 'tcx: 'a> { struct ItemVisitor<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx> tcx: TyCtxt<'tcx, 'tcx, 'tcx>
} }
struct ExprVisitor<'a, 'tcx: 'a> { struct ExprVisitor<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tables: &'tcx ty::TypeckTables<'tcx>, tables: &'tcx ty::TypeckTables<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
} }
/// If the type is `Option<T>`, it will return `T`, otherwise /// If the type is `Option<T>`, it will return `T`, otherwise
/// the type itself. Works on most `Option`-like types. /// the type itself. Works on most `Option`-like types.
fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
ty: Ty<'tcx>) ty: Ty<'tcx>)
-> Ty<'tcx> { -> Ty<'tcx> {
let (def, substs) = match ty.sty { let (def, substs) = match ty.sty {
@ -66,7 +66,7 @@ fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty ty
} }
impl<'a, 'tcx> ExprVisitor<'a, 'tcx> { impl ExprVisitor<'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool { fn def_id_is_transmute(&self, def_id: DefId) -> bool {
self.tcx.fn_sig(def_id).abi() == RustIntrinsic && self.tcx.fn_sig(def_id).abi() == RustIntrinsic &&
self.tcx.item_name(def_id) == sym::transmute self.tcx.item_name(def_id) == sym::transmute
@ -131,7 +131,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> { impl Visitor<'tcx> for ItemVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::None NestedVisitorMap::None
} }
@ -146,7 +146,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> { impl Visitor<'tcx> for ExprVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::None NestedVisitorMap::None
} }

View file

@ -104,14 +104,14 @@ impl LanguageItems {
)* )*
} }
struct LanguageItemCollector<'a, 'tcx: 'a> { struct LanguageItemCollector<'tcx> {
items: LanguageItems, items: LanguageItems,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
/// A mapping from the name of the lang item to its order and the form it must be of. /// 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)>, item_refs: FxHashMap<&'static str, (usize, Target)>,
} }
impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
fn visit_item(&mut self, item: &hir::Item) { fn visit_item(&mut self, item: &hir::Item) {
if let Some((value, span)) = extract(&item.attrs) { if let Some((value, span)) = extract(&item.attrs) {
let actual_target = Target::from_item(item); let actual_target = Target::from_item(item);
@ -159,8 +159,8 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { impl LanguageItemCollector<'tcx> {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItemCollector<'a, 'tcx> { fn new(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> LanguageItemCollector<'tcx> {
let mut item_refs = FxHashMap::default(); let mut item_refs = FxHashMap::default();
$( item_refs.insert($name, ($variant as usize, $target)); )* $( 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. /// Traverse and collect all the lang items in all crates.
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItems { pub fn collect<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> LanguageItems {
// Initialize the collector. // Initialize the collector.
let mut collector = LanguageItemCollector::new(tcx); let mut collector = LanguageItemCollector::new(tcx);
@ -402,7 +402,7 @@ language_item_table! {
Rc, "rc", rc, Target::Struct; Rc, "rc", rc, Target::Struct;
} }
impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> { impl<'a, 'tcx, 'gcx> TyCtxt<'gcx, 'tcx, 'gcx> {
/// Returns the `DefId` for a given `LangItem`. /// Returns the `DefId` for a given `LangItem`.
/// If not found, fatally abort compilation. /// If not found, fatally abort compilation.
pub fn require_lang_item(&self, lang_item: LangItem) -> DefId { pub fn require_lang_item(&self, lang_item: LangItem) -> DefId {

View file

@ -37,13 +37,13 @@ impl LibFeatures {
} }
} }
pub struct LibFeatureCollector<'a, 'tcx: 'a> { pub struct LibFeatureCollector<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
lib_features: LibFeatures, lib_features: LibFeatures,
} }
impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> { impl LibFeatureCollector<'tcx> {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatureCollector<'a, 'tcx> { fn new(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> LibFeatureCollector<'tcx> {
LibFeatureCollector { LibFeatureCollector {
tcx, tcx,
lib_features: LibFeatures::new(), lib_features: LibFeatures::new(),
@ -130,7 +130,7 @@ impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> { impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir()) NestedVisitorMap::All(&self.tcx.hir())
} }
@ -142,7 +142,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> {
} }
} }
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatures { pub fn collect<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> LibFeatures {
let mut collector = LibFeatureCollector::new(tcx); let mut collector = LibFeatureCollector::new(tcx);
intravisit::walk_crate(&mut collector, tcx.hir().krate()); intravisit::walk_crate(&mut collector, tcx.hir().krate());
collector.lib_features collector.lib_features

View file

@ -166,7 +166,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_, '_>) -> Strin
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
@ -181,7 +181,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
fn visit_arm(&mut self, a: &'tcx hir::Arm) { visit_arm(self, a); } 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, 'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module( tcx.hir().visit_item_likes_in_module(
module_def_id, module_def_id,
&mut IrMaps::new(tcx, module_def_id).as_deep_visitor(), &mut IrMaps::new(tcx, module_def_id).as_deep_visitor(),
@ -256,8 +256,8 @@ enum VarKind {
CleanExit CleanExit
} }
struct IrMaps<'a, 'tcx: 'a> { struct IrMaps<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
body_owner: DefId, body_owner: DefId,
num_live_nodes: usize, num_live_nodes: usize,
num_vars: usize, num_vars: usize,
@ -268,8 +268,8 @@ struct IrMaps<'a, 'tcx: 'a> {
lnks: Vec<LiveNodeKind>, lnks: Vec<LiveNodeKind>,
} }
impl<'a, 'tcx> IrMaps<'a, 'tcx> { impl IrMaps<'tcx> {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, body_owner: DefId) -> IrMaps<'a, 'tcx> { fn new(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, body_owner: DefId) -> IrMaps<'tcx> {
IrMaps { IrMaps {
tcx, tcx,
body_owner, body_owner,
@ -352,7 +352,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
} }
} }
fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>, fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'tcx>,
fk: FnKind<'tcx>, fk: FnKind<'tcx>,
decl: &'tcx hir::FnDecl, decl: &'tcx hir::FnDecl,
body_id: hir::BodyId, body_id: hir::BodyId,
@ -374,7 +374,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
} }
} }
debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps<'_, '_>); debug!("creating fn_maps: {:p}", &fn_maps);
let body = ir.tcx.hir().body(body_id); let body = ir.tcx.hir().body(body_id);
@ -411,7 +411,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
lsets.warn_about_unused_args(body, entry_ln); lsets.warn_about_unused_args(body, entry_ln);
} }
fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P<hir::Pat>) { fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
// For struct patterns, take note of which fields used shorthand // For struct patterns, take note of which fields used shorthand
// (`x` rather than `x: x`). // (`x` rather than `x: x`).
let mut shorthand_field_ids = HirIdSet::default(); let mut shorthand_field_ids = HirIdSet::default();
@ -457,19 +457,19 @@ fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P<hir::Pat>) {
}); });
} }
fn visit_local<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, local: &'tcx hir::Local) { fn visit_local<'a, 'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local) {
add_from_pat(ir, &local.pat); add_from_pat(ir, &local.pat);
intravisit::walk_local(ir, local); intravisit::walk_local(ir, local);
} }
fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) { fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) {
for pat in &arm.pats { for pat in &arm.pats {
add_from_pat(ir, pat); add_from_pat(ir, pat);
} }
intravisit::walk_arm(ir, arm); intravisit::walk_arm(ir, arm);
} }
fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) {
match expr.node { match expr.node {
// live nodes required for uses or definitions of variables: // live nodes required for uses or definitions of variables:
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
@ -681,7 +681,7 @@ const ACC_WRITE: u32 = 2;
const ACC_USE: u32 = 4; const ACC_USE: u32 = 4;
struct Liveness<'a, 'tcx: 'a> { struct Liveness<'a, 'tcx: 'a> {
ir: &'a mut IrMaps<'a, 'tcx>, ir: &'a mut IrMaps<'tcx>,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
s: Specials, s: Specials,
successors: Vec<LiveNode>, successors: Vec<LiveNode>,
@ -695,7 +695,7 @@ struct Liveness<'a, 'tcx: 'a> {
} }
impl<'a, 'tcx> Liveness<'a, 'tcx> { impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn new(ir: &'a mut IrMaps<'a, 'tcx>, body: hir::BodyId) -> Liveness<'a, 'tcx> { fn new(ir: &'a mut IrMaps<'tcx>, body: hir::BodyId) -> Liveness<'a, 'tcx> {
// Special nodes and variables: // Special nodes and variables:
// - exit_ln represents the end of the fn, either by return or panic // - exit_ln represents the end of the fn, either by return or panic
// - implicit_ret_var is a pseudo-variable that represents // - implicit_ret_var is a pseudo-variable that represents

View file

@ -288,7 +288,7 @@ impl HirNode for hir::Pat {
#[derive(Clone)] #[derive(Clone)]
pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
pub body_owner: DefId, pub body_owner: DefId,
pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>, pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
pub region_scope_tree: &'a region::ScopeTree, pub region_scope_tree: &'a region::ScopeTree,
@ -400,7 +400,7 @@ impl MutabilityCategory {
} }
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> { impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn new(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
body_owner: DefId, body_owner: DefId,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,

View file

@ -27,7 +27,7 @@ use crate::hir::intravisit;
// Returns true if the given item must be inlined because it may be // Returns true if the given item must be inlined because it may be
// monomorphized or it was marked with `#[inline]`. This will only return // monomorphized or it was marked with `#[inline]`. This will only return
// true for functions. // true for functions.
fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
item: &hir::Item, item: &hir::Item,
attrs: CodegenFnAttrs) -> bool { attrs: CodegenFnAttrs) -> bool {
if attrs.requests_inline() { if attrs.requests_inline() {
@ -44,7 +44,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
} }
fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
impl_item: &hir::ImplItem, impl_item: &hir::ImplItem,
impl_src: DefId) -> bool { impl_src: DefId) -> bool {
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id()); let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
@ -67,7 +67,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Information needed while computing reachability. // Information needed while computing reachability.
struct ReachableContext<'a, 'tcx: 'a> { struct ReachableContext<'a, 'tcx: 'a> {
// The type context. // The type context.
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
// The set of items which must be exported in the linkage sense. // The set of items which must be exported in the linkage sense.
reachable_symbols: HirIdSet, 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 items are used from inlinable code through method call syntax or UFCS, or their
// trait is a lang item. // trait is a lang item.
struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> { struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
access_levels: &'a privacy::AccessLevels, access_levels: &'a privacy::AccessLevels,
worklist: &'a mut Vec<hir::HirId>, worklist: &'a mut Vec<hir::HirId>,
} }
@ -391,7 +391,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
#[derive(Clone, HashStable)] #[derive(Clone, HashStable)]
pub struct ReachableSet(pub Lrc<HirIdSet>); pub struct ReachableSet(pub Lrc<HirIdSet>);
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> ReachableSet { fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, crate_num: CrateNum) -> ReachableSet {
debug_assert!(crate_num == LOCAL_CRATE); debug_assert!(crate_num == LOCAL_CRATE);
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);

View file

@ -358,8 +358,8 @@ pub struct Context {
parent: Option<(Scope, ScopeDepth)>, parent: Option<(Scope, ScopeDepth)>,
} }
struct RegionResolutionVisitor<'a, 'tcx: 'a> { struct RegionResolutionVisitor<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
// The number of expressions and patterns visited in the current body // The number of expressions and patterns visited in the current body
expr_and_pat_count: usize, expr_and_pat_count: usize,
@ -646,7 +646,7 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`, /// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives. /// returns the outermost `Scope` that the region outlives.
pub fn early_free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn early_free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
br: &ty::EarlyBoundRegion) br: &ty::EarlyBoundRegion)
-> Scope { -> Scope {
let param_owner = tcx.parent(br.def_id).unwrap(); let param_owner = tcx.parent(br.def_id).unwrap();
@ -677,7 +677,7 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`, /// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives. /// returns the outermost `Scope` that the region outlives.
pub fn free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, fr: &ty::FreeRegion) pub fn free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>, fr: &ty::FreeRegion)
-> Scope { -> Scope {
let param_owner = match fr.bound_region { let param_owner = match fr.bound_region {
ty::BoundRegion::BrNamed(def_id, _) => { ty::BoundRegion::BrNamed(def_id, _) => {
@ -734,7 +734,7 @@ impl<'tcx> ScopeTree {
} }
/// Records the lifetime of a local variable as `cx.var_parent` /// Records the lifetime of a local variable as `cx.var_parent`
fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_, '_>, fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_>,
var_id: hir::ItemLocalId, var_id: hir::ItemLocalId,
_sp: Span) { _sp: Span) {
match visitor.cx.var_parent { match visitor.cx.var_parent {
@ -748,7 +748,7 @@ fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_, '_>,
} }
} }
fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk: &'tcx hir::Block) { fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx hir::Block) {
debug!("resolve_block(blk.hir_id={:?})", blk.hir_id); debug!("resolve_block(blk.hir_id={:?})", blk.hir_id);
let prev_cx = visitor.cx; let prev_cx = visitor.cx;
@ -816,7 +816,7 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk:
visitor.cx = prev_cx; visitor.cx = prev_cx;
} }
fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, arm: &'tcx hir::Arm) { fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, arm: &'tcx hir::Arm) {
let prev_cx = visitor.cx; let prev_cx = visitor.cx;
visitor.enter_scope( visitor.enter_scope(
@ -838,7 +838,7 @@ fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, arm: &
visitor.cx = prev_cx; visitor.cx = prev_cx;
} }
fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &'tcx hir::Pat) { fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir::Pat) {
visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node }); visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node });
// If this is a binding then record the lifetime of that binding. // If this is a binding then record the lifetime of that binding.
@ -855,7 +855,7 @@ fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &
debug!("resolve_pat - post-increment {} pat = {:?}", visitor.expr_and_pat_count, pat); debug!("resolve_pat - post-increment {} pat = {:?}", visitor.expr_and_pat_count, pat);
} }
fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) { fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, stmt: &'tcx hir::Stmt) {
let stmt_id = stmt.hir_id.local_id; let stmt_id = stmt.hir_id.local_id;
debug!("resolve_stmt(stmt.id={:?})", stmt_id); debug!("resolve_stmt(stmt.id={:?})", stmt_id);
@ -874,7 +874,7 @@ fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt:
visitor.cx.parent = prev_parent; visitor.cx.parent = prev_parent;
} }
fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: &'tcx hir::Expr) { fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx hir::Expr) {
debug!("resolve_expr - pre-increment {} expr = {:?}", visitor.expr_and_pat_count, expr); debug!("resolve_expr - pre-increment {} expr = {:?}", visitor.expr_and_pat_count, expr);
let prev_cx = visitor.cx; let prev_cx = visitor.cx;
@ -977,7 +977,7 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
visitor.cx = prev_cx; visitor.cx = prev_cx;
} }
fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
pat: Option<&'tcx hir::Pat>, pat: Option<&'tcx hir::Pat>,
init: Option<&'tcx hir::Expr>) { init: Option<&'tcx hir::Expr>) {
debug!("resolve_local(pat={:?}, init={:?})", pat, init); debug!("resolve_local(pat={:?}, init={:?})", pat, init);
@ -1128,7 +1128,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
/// | E& as ... /// | E& as ...
/// | ( E& ) /// | ( E& )
fn record_rvalue_scope_if_borrow_expr<'a, 'tcx>( fn record_rvalue_scope_if_borrow_expr<'a, 'tcx>(
visitor: &mut RegionResolutionVisitor<'a, 'tcx>, visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr, expr: &hir::Expr,
blk_id: Option<Scope>) blk_id: Option<Scope>)
{ {
@ -1178,7 +1178,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
/// | <rvalue> /// | <rvalue>
/// ///
/// Note: ET is intended to match "rvalues or places based on rvalues". /// Note: ET is intended to match "rvalues or places based on rvalues".
fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr, expr: &hir::Expr,
blk_scope: Option<Scope>) { blk_scope: Option<Scope>) {
let mut expr = expr; let mut expr = expr;
@ -1205,7 +1205,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
} }
} }
impl<'a, 'tcx> RegionResolutionVisitor<'a, 'tcx> { impl<'a, 'tcx> RegionResolutionVisitor<'tcx> {
/// Records the current parent (if any) as the parent of `child_scope`. /// Records the current parent (if any) as the parent of `child_scope`.
/// Returns the depth of `child_scope`. /// Returns the depth of `child_scope`.
fn record_child_scope(&mut self, child_scope: Scope) -> ScopeDepth { fn record_child_scope(&mut self, child_scope: Scope) -> ScopeDepth {
@ -1235,7 +1235,7 @@ impl<'a, 'tcx> RegionResolutionVisitor<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::None NestedVisitorMap::None
} }
@ -1327,7 +1327,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
} }
} }
fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId)
-> &'tcx ScopeTree -> &'tcx ScopeTree
{ {
let closure_base_def_id = tcx.closure_base_def_id(def_id); let closure_base_def_id = tcx.closure_base_def_id(def_id);

View file

@ -218,7 +218,7 @@ impl_stable_hash_for!(struct crate::middle::resolve_lifetime::ResolveLifetimes {
}); });
struct LifetimeContext<'a, 'tcx: 'a> { struct LifetimeContext<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
map: &'a mut NamedRegionMap, map: &'a mut NamedRegionMap,
scope: ScopeRef<'a>, scope: ScopeRef<'a>,
@ -369,7 +369,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
/// directly, but rather use `named_region_map`, `is_late_bound_map`, /// directly, but rather use `named_region_map`, `is_late_bound_map`,
/// etc. /// etc.
fn resolve_lifetimes<'tcx>( fn resolve_lifetimes<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
for_krate: CrateNum, for_krate: CrateNum,
) -> &'tcx ResolveLifetimes { ) -> &'tcx ResolveLifetimes {
assert_eq!(for_krate, LOCAL_CRATE); assert_eq!(for_krate, LOCAL_CRATE);
@ -398,7 +398,7 @@ fn resolve_lifetimes<'tcx>(
tcx.arena.alloc(rl) tcx.arena.alloc(rl)
} }
fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap { fn krate<'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> NamedRegionMap {
let krate = tcx.hir().krate(); let krate = tcx.hir().krate();
let mut map = NamedRegionMap { let mut map = NamedRegionMap {
defs: Default::default(), defs: Default::default(),
@ -1169,7 +1169,7 @@ fn signal_shadowing_problem(
// if one of the label shadows a lifetime or another label. // if one of the label shadows a lifetime or another label.
fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
struct GatherLabels<'a, 'tcx: 'a> { struct GatherLabels<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
scope: ScopeRef<'a>, scope: ScopeRef<'a>,
labels_in_fn: &'a mut Vec<ast::Ident>, labels_in_fn: &'a mut Vec<ast::Ident>,
} }

View file

@ -106,7 +106,7 @@ impl_stable_hash_for!(struct self::Index<'tcx> {
// A private tree-walker for producing an Index. // A private tree-walker for producing an Index.
struct Annotator<'a, 'tcx: 'a> { struct Annotator<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
index: &'a mut Index<'tcx>, index: &'a mut Index<'tcx>,
parent_stab: Option<&'tcx Stability>, parent_stab: Option<&'tcx Stability>,
parent_depr: Option<DeprecationEntry>, parent_depr: Option<DeprecationEntry>,
@ -317,7 +317,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
} }
struct MissingStabilityAnnotations<'a, 'tcx: 'a> { struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
access_levels: &'a AccessLevels, access_levels: &'a AccessLevels,
} }
@ -390,7 +390,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
} }
impl<'a, 'tcx> Index<'tcx> { impl<'a, 'tcx> Index<'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Index<'tcx> { pub fn new(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Index<'tcx> {
let is_staged_api = let is_staged_api =
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.sess.opts.debugging_opts.force_unstable_if_unmarked ||
tcx.features().staged_api; tcx.features().staged_api;
@ -466,7 +466,7 @@ impl<'a, 'tcx> Index<'tcx> {
/// Cross-references the feature names of unstable APIs with enabled /// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors. /// 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, 'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor()); tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor());
} }
@ -501,8 +501,8 @@ pub fn deprecation_in_effect(since: &str) -> bool {
} }
} }
struct Checker<'a, 'tcx: 'a> { struct Checker<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
} }
/// Result of `TyCtxt::eval_stability`. /// Result of `TyCtxt::eval_stability`.
@ -521,7 +521,7 @@ pub enum EvalResult {
Unmarked, Unmarked,
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
// See issue #38412. // See issue #38412.
fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool { fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
// Check if `def_id` is a trait method. // Check if `def_id` is a trait method.
@ -752,7 +752,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { impl Visitor<'tcx> for Checker<'tcx> {
/// Because stability levels are scoped lexically, we want to walk /// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable /// nested items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
@ -827,7 +827,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> { pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> {
self.lookup_deprecation_entry(id).map(|depr| depr.attr) self.lookup_deprecation_entry(id).map(|depr| depr.attr)
} }
@ -836,7 +836,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Given the list of enabled features that were not language features (i.e., that /// 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 /// 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. /// libraries, identify activated features that don't exist and error about them.
pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
if tcx.stability().staged_api[&LOCAL_CRATE] { if tcx.stability().staged_api[&LOCAL_CRATE] {
@ -921,7 +921,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
} }
fn unnecessary_stable_feature_lint<'a, 'tcx>( fn unnecessary_stable_feature_lint<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
span: Span, span: Span,
feature: Symbol, feature: Symbol,
since: Symbol since: Symbol

View file

@ -18,13 +18,13 @@ macro_rules! weak_lang_items {
($($name:ident, $item:ident, $sym:ident;)*) => ( ($($name:ident, $item:ident, $sym:ident;)*) => (
struct Context<'a, 'tcx: 'a> { struct Context<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
items: &'a mut lang_items::LanguageItems, items: &'a mut lang_items::LanguageItems,
} }
/// Checks the crate for usage of weak lang items, returning a vector of all the /// 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. /// language items required by this crate, but not defined yet.
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
items: &mut lang_items::LanguageItems) { items: &mut lang_items::LanguageItems) {
// These are never called by user code, they're generated by the compiler. // 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 // They will never implicitly be added to the `missing` array unless we do
@ -72,7 +72,7 @@ pub fn whitelisted(tcx: TyCtxt<'_, '_, '_>, lang_item: lang_items::LangItem) ->
false false
} }
fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn verify<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
items: &lang_items::LanguageItems) { items: &lang_items::LanguageItems) {
// We only need to check for the presence of weak lang items if we're // We only need to check for the presence of weak lang items if we're
// emitting something that's not an rlib. // emitting something that's not an rlib.
@ -142,7 +142,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
} }
} }
impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> { impl<'a, 'tcx, 'gcx> TyCtxt<'gcx, 'tcx, 'gcx> {
pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool { pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool {
let lang_items = self.lang_items(); let lang_items = self.lang_items();
let did = Some(item_def_id); let did = Some(item_def_id);

View file

@ -76,7 +76,7 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
pub fn struct_error(&self, pub fn struct_error(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>, tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str) message: &str)
-> Result<DiagnosticBuilder<'tcx>, ErrorHandled> -> Result<DiagnosticBuilder<'tcx>, ErrorHandled>
{ {
@ -84,7 +84,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
} }
pub fn report_as_error(&self, pub fn report_as_error(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>, tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str message: &str
) -> ErrorHandled { ) -> ErrorHandled {
let err = self.struct_error(tcx, message); let err = self.struct_error(tcx, message);
@ -98,7 +98,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
} }
pub fn report_as_lint(&self, pub fn report_as_lint(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>, tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str, message: &str,
lint_root: hir::HirId, lint_root: hir::HirId,
span: Option<Span>, span: Option<Span>,
@ -131,7 +131,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
fn struct_generic( fn struct_generic(
&self, &self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>, tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str, message: &str,
lint_root: Option<hir::HirId>, lint_root: Option<hir::HirId>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> { ) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
@ -173,7 +173,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
} }
pub fn struct_error<'a, 'gcx, 'tcx>( pub fn struct_error<'a, 'gcx, 'tcx>(
tcx: TyCtxtAt<'a, 'gcx, 'tcx>, tcx: TyCtxtAt<'gcx, 'tcx>,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'tcx> { ) -> DiagnosticBuilder<'tcx> {
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg) struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)

View file

@ -69,7 +69,7 @@ pub fn specialized_encode_alloc_id<
E: Encoder, E: Encoder,
>( >(
encoder: &mut E, encoder: &mut E,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
alloc_id: AllocId, alloc_id: AllocId,
) -> Result<(), E::Error> { ) -> Result<(), E::Error> {
let alloc: GlobalAlloc<'tcx> = let alloc: GlobalAlloc<'tcx> =
@ -150,8 +150,7 @@ impl<'s> AllocDecodingSession<'s> {
pub fn decode_alloc_id<'a, 'tcx, D>(&self, pub fn decode_alloc_id<'a, 'tcx, D>(&self,
decoder: &mut D) decoder: &mut D)
-> Result<AllocId, D::Error> -> Result<AllocId, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
// Read the index of the allocation // Read the index of the allocation
let idx = decoder.read_u32()? as usize; let idx = decoder.read_u32()? as usize;

View file

@ -1241,7 +1241,7 @@ impl<'tcx> Terminator<'tcx> {
impl<'tcx> TerminatorKind<'tcx> { impl<'tcx> TerminatorKind<'tcx> {
pub fn if_<'a, 'gcx>( pub fn if_<'a, 'gcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
cond: Operand<'tcx>, cond: Operand<'tcx>,
t: BasicBlock, t: BasicBlock,
f: BasicBlock, f: BasicBlock,
@ -2324,7 +2324,7 @@ impl<'tcx> Operand<'tcx> {
/// with given `DefId` and substs. Since this is used to synthesize /// with given `DefId` and substs. Since this is used to synthesize
/// MIR, assumes `user_ty` is None. /// MIR, assumes `user_ty` is None.
pub fn function_handle<'a>( pub fn function_handle<'a>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
def_id: DefId, def_id: DefId,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
span: Span, span: Span,

View file

@ -48,7 +48,7 @@ pub enum MonoItem<'tcx> {
} }
impl<'tcx> MonoItem<'tcx> { impl<'tcx> MonoItem<'tcx> {
pub fn size_estimate<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> usize { pub fn size_estimate<'a>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> usize {
match *self { match *self {
MonoItem::Fn(instance) => { MonoItem::Fn(instance) => {
// Estimate the size of a function based on how many statements // 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<'a, 'tcx, 'tcx>) -> SymbolName { pub fn symbol_name(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> SymbolName {
match *self { match *self {
MonoItem::Fn(instance) => tcx.symbol_name(instance), MonoItem::Fn(instance) => tcx.symbol_name(instance),
MonoItem::Static(def_id) => { MonoItem::Static(def_id) => {
@ -88,7 +88,7 @@ impl<'tcx> MonoItem<'tcx> {
} }
pub fn instantiation_mode(&self, pub fn instantiation_mode(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>) tcx: TyCtxt<'tcx, 'tcx, 'tcx>)
-> InstantiationMode { -> InstantiationMode {
let inline_in_all_cgus = let inline_in_all_cgus =
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| { tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| {
@ -133,7 +133,7 @@ impl<'tcx> MonoItem<'tcx> {
} }
} }
pub fn explicit_linkage(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Linkage> { pub fn explicit_linkage(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Option<Linkage> {
let def_id = match *self { let def_id = match *self {
MonoItem::Fn(ref instance) => instance.def_id(), MonoItem::Fn(ref instance) => instance.def_id(),
MonoItem::Static(def_id) => def_id, MonoItem::Static(def_id) => def_id,
@ -169,7 +169,7 @@ impl<'tcx> MonoItem<'tcx> {
/// Similarly, if a vtable method has such a signature, and therefore can't /// 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, /// be used, we can just not emit it and have a placeholder (a null pointer,
/// which will never be accessed) in its place. /// which will never be accessed) in its place.
pub fn is_instantiable(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool { pub fn is_instantiable(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> bool {
debug!("is_instantiable({:?})", self); debug!("is_instantiable({:?})", self);
let (def_id, substs) = match *self { let (def_id, substs) = match *self {
MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs), MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs),
@ -181,7 +181,7 @@ impl<'tcx> MonoItem<'tcx> {
tcx.substitute_normalize_and_test_predicates((def_id, &substs)) tcx.substitute_normalize_and_test_predicates((def_id, &substs))
} }
pub fn to_string(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, debug: bool) -> String { pub fn to_string(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>, debug: bool) -> String {
return match *self { return match *self {
MonoItem::Fn(instance) => { MonoItem::Fn(instance) => {
to_string_internal(tcx, "fn ", instance, debug) to_string_internal(tcx, "fn ", instance, debug)
@ -195,7 +195,7 @@ impl<'tcx> MonoItem<'tcx> {
} }
}; };
fn to_string_internal<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn to_string_internal<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
prefix: &str, prefix: &str,
instance: Instance<'tcx>, instance: Instance<'tcx>,
debug: bool) debug: bool)
@ -208,7 +208,7 @@ impl<'tcx> MonoItem<'tcx> {
} }
} }
pub fn local_span(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Span> { pub fn local_span(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Option<Span> {
match *self { match *self {
MonoItem::Fn(Instance { def, .. }) => { MonoItem::Fn(Instance { def, .. }) => {
tcx.hir().as_local_hir_id(def.def_id()) tcx.hir().as_local_hir_id(def.def_id())
@ -334,7 +334,7 @@ impl<'tcx> CodegenUnit<'tcx> {
base_n::encode(hash, base_n::CASE_INSENSITIVE) base_n::encode(hash, base_n::CASE_INSENSITIVE)
} }
pub fn estimate_size<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn estimate_size<'a>(&mut self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) {
// Estimate the size of a codegen unit as (approximately) the number of MIR // Estimate the size of a codegen unit as (approximately) the number of MIR
// statements it corresponds to. // statements it corresponds to.
self.size_estimate = Some(self.items.keys().map(|mi| mi.size_estimate(tcx)).sum()); self.size_estimate = Some(self.items.keys().map(|mi| mi.size_estimate(tcx)).sum());
@ -370,7 +370,7 @@ impl<'tcx> CodegenUnit<'tcx> {
} }
pub fn items_in_deterministic_order<'a>(&self, pub fn items_in_deterministic_order<'a>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>) tcx: TyCtxt<'tcx, 'tcx, 'tcx>)
-> Vec<(MonoItem<'tcx>, -> Vec<(MonoItem<'tcx>,
(Linkage, Visibility))> { (Linkage, Visibility))> {
// The codegen tests rely on items being process in the same order as // The codegen tests rely on items being process in the same order as
@ -378,7 +378,7 @@ impl<'tcx> CodegenUnit<'tcx> {
#[derive(PartialEq, Eq, PartialOrd, Ord)] #[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct ItemSortKey(Option<HirId>, SymbolName); pub struct ItemSortKey(Option<HirId>, SymbolName);
fn item_sort_key<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn item_sort_key<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
item: MonoItem<'tcx>) -> ItemSortKey { item: MonoItem<'tcx>) -> ItemSortKey {
ItemSortKey(match item { ItemSortKey(match item {
MonoItem::Fn(ref instance) => { MonoItem::Fn(ref instance) => {
@ -415,7 +415,7 @@ impl<'tcx> CodegenUnit<'tcx> {
items items
} }
pub fn codegen_dep_node(&self, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> DepNode { pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> DepNode {
DepNode::new(tcx, DepConstructor::CompileCodegenUnit(self.name().clone())) DepNode::new(tcx, DepConstructor::CompileCodegenUnit(self.name().clone()))
} }
} }
@ -445,14 +445,13 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for CodegenUnit<'tcx> {
} }
} }
pub struct CodegenUnitNameBuilder<'a, 'gcx: 'tcx, 'tcx: 'a> { pub struct CodegenUnitNameBuilder<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
cache: FxHashMap<CrateNum, String>, cache: FxHashMap<CrateNum, String>,
} }
impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> { impl CodegenUnitNameBuilder<'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Self {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
CodegenUnitNameBuilder { CodegenUnitNameBuilder {
tcx, tcx,
cache: Default::default(), cache: Default::default(),

View file

@ -33,7 +33,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
/// not carry a `Ty` for `T`.) /// not carry a `Ty` for `T`.)
/// ///
/// Note that the resulting type has not been normalized. /// Note that the resulting type has not been normalized.
pub fn field_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, f: &Field) -> Ty<'tcx> pub fn field_ty(self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>, f: &Field) -> Ty<'tcx>
{ {
let answer = match self.ty.sty { let answer = match self.ty.sty {
ty::Adt(adt_def, substs) => { ty::Adt(adt_def, substs) => {
@ -57,7 +57,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
/// Convenience wrapper around `projection_ty_core` for /// Convenience wrapper around `projection_ty_core` for
/// `PlaceElem`, where we can just use the `Ty` that is already /// `PlaceElem`, where we can just use the `Ty` that is already
/// stored inline on field projection elems. /// stored inline on field projection elems.
pub fn projection_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn projection_ty(self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
elem: &PlaceElem<'tcx>) elem: &PlaceElem<'tcx>)
-> PlaceTy<'tcx> -> PlaceTy<'tcx>
{ {
@ -71,7 +71,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
/// (which should be trivial when `T` = `Ty`). /// (which should be trivial when `T` = `Ty`).
pub fn projection_ty_core<V, T>( pub fn projection_ty_core<V, T>(
self, self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
elem: &ProjectionElem<V, T>, elem: &ProjectionElem<V, T>,
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>) mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>)
-> PlaceTy<'tcx> -> PlaceTy<'tcx>
@ -121,7 +121,7 @@ BraceStructTypeFoldableImpl! {
} }
impl<'tcx> Place<'tcx> { impl<'tcx> Place<'tcx> {
pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PlaceTy<'tcx> pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> PlaceTy<'tcx>
where D: HasLocalDecls<'tcx> where D: HasLocalDecls<'tcx>
{ {
match *self { match *self {
@ -141,7 +141,7 @@ pub enum RvalueInitializationState {
} }
impl<'tcx> Rvalue<'tcx> { impl<'tcx> Rvalue<'tcx> {
pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Ty<'tcx>
where D: HasLocalDecls<'tcx> where D: HasLocalDecls<'tcx>
{ {
match *self { match *self {
@ -222,7 +222,7 @@ impl<'tcx> Rvalue<'tcx> {
} }
impl<'tcx> Operand<'tcx> { impl<'tcx> Operand<'tcx> {
pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Ty<'tcx>
where D: HasLocalDecls<'tcx> where D: HasLocalDecls<'tcx>
{ {
match self { match self {
@ -234,7 +234,7 @@ impl<'tcx> Operand<'tcx> {
} }
impl<'tcx> BinOp { impl<'tcx> BinOp {
pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
lhs_ty: Ty<'tcx>, lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>) rhs_ty: Ty<'tcx>)
-> Ty<'tcx> { -> Ty<'tcx> {

View file

@ -47,12 +47,12 @@ pub struct AutoTraitInfo<'cx> {
pub vid_to_region: FxHashMap<ty::RegionVid, ty::Region<'cx>>, pub vid_to_region: FxHashMap<ty::RegionVid, ty::Region<'cx>>,
} }
pub struct AutoTraitFinder<'a, 'tcx: 'a> { pub struct AutoTraitFinder<'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
} }
impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { impl<'tcx> AutoTraitFinder<'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self { pub fn new(tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Self {
AutoTraitFinder { tcx } AutoTraitFinder { tcx }
} }
@ -232,7 +232,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { impl AutoTraitFinder<'tcx> {
// The core logic responsible for computing the bounds for our synthesized impl. // The core logic responsible for computing the bounds for our synthesized impl.
// //
// To calculate the bounds, we call SelectionContext.select in a loop. Like FulfillmentContext, // To calculate the bounds, we call SelectionContext.select in a loop. Like FulfillmentContext,
@ -834,11 +834,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
// Replaces all ReVars in a type with ty::Region's, using the provided map // 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, 'gcx: 'a + 'tcx, 'tcx: 'a> {
vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>, vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionReplacer<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionReplacer<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -18,7 +18,7 @@ use crate::ty::fold::TypeFoldable;
/// that type check should guarantee to us that all nested /// that type check should guarantee to us that all nested
/// obligations *could be* resolved if we wanted to. /// obligations *could be* resolved if we wanted to.
/// Assumes that this is run after the entire crate has been successfully type-checked. /// Assumes that this is run after the entire crate has been successfully type-checked.
pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'a, 'tcx, 'tcx>, pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'tcx, 'tcx, 'tcx>,
(param_env, trait_ref): (param_env, trait_ref):
(ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>))
-> Vtable<'tcx, ()> -> Vtable<'tcx, ()>
@ -74,7 +74,7 @@ pub fn codegen_fulfill_obligation<'a, 'tcx>(ty: TyCtxt<'a, 'tcx, 'tcx>,
}) })
} }
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'a, 'tcx> TyCtxt<'tcx, 'tcx, 'tcx> {
/// Monomorphizes a type from the AST by first applying the /// Monomorphizes a type from the AST by first applying the
/// in-scope substitutions and then normalizing any associated /// in-scope substitutions and then normalizing any associated
/// types. /// types.

View file

@ -49,7 +49,7 @@ pub fn add_placeholder_note(err: &mut errors::DiagnosticBuilder<'_>) {
/// with a suitably-freshened `ImplHeader` with those types /// with a suitably-freshened `ImplHeader` with those types
/// substituted. Otherwise, invokes `no_overlap`. /// substituted. Otherwise, invokes `no_overlap`.
pub fn overlapping_impls<'gcx, F1, F2, R>( pub fn overlapping_impls<'gcx, F1, F2, R>(
tcx: TyCtxt<'_, 'gcx, 'gcx>, tcx: TyCtxt<'gcx, 'gcx, 'gcx>,
impl1_def_id: DefId, impl1_def_id: DefId,
impl2_def_id: DefId, impl2_def_id: DefId,
intercrate_mode: IntercrateMode, intercrate_mode: IntercrateMode,
@ -183,7 +183,7 @@ fn overlap_within_probe(
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder }) Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
} }
pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>) trait_ref: ty::TraitRef<'tcx>)
-> Option<Conflict> -> Option<Conflict>
{ {
@ -229,7 +229,7 @@ pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
} }
} }
pub fn trait_ref_is_local_or_fundamental<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn trait_ref_is_local_or_fundamental<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>) trait_ref: ty::TraitRef<'tcx>)
-> bool { -> bool {
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental) trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
@ -246,7 +246,7 @@ pub enum OrphanCheckErr<'tcx> {
/// ///
/// 1. All type parameters in `Self` must be "covered" by some local type constructor. /// 1. All type parameters in `Self` must be "covered" by some local type constructor.
/// 2. Some local type must appear in `Self`. /// 2. Some local type must appear in `Self`.
pub fn orphan_check<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn orphan_check<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
impl_def_id: DefId) impl_def_id: DefId)
-> Result<(), OrphanCheckErr<'tcx>> -> Result<(), OrphanCheckErr<'tcx>>
{ {

View file

@ -78,7 +78,7 @@ impl<T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T {
} }
impl dyn TraitEngine<'tcx> { impl dyn TraitEngine<'tcx> {
pub fn new(tcx: TyCtxt<'_, '_, 'tcx>) -> Box<Self> { pub fn new(tcx: TyCtxt<'tcx, '_, 'tcx>) -> Box<Self> {
if tcx.sess.opts.debugging_opts.chalk { if tcx.sess.opts.debugging_opts.chalk {
Box::new(ChalkFulfillmentContext::new()) Box::new(ChalkFulfillmentContext::new())
} else { } else {

View file

@ -1249,7 +1249,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
found: ty::PolyTraitRef<'tcx>) found: ty::PolyTraitRef<'tcx>)
-> DiagnosticBuilder<'tcx> -> DiagnosticBuilder<'tcx>
{ {
fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: &ty::TraitRef<'tcx>) -> String { trait_ref: &ty::TraitRef<'tcx>) -> String {
let inputs = trait_ref.substs.type_at(1); let inputs = trait_ref.substs.type_at(1);
let sig = if let ty::Tuple(inputs) = inputs.sty { let sig = if let ty::Tuple(inputs) = inputs.sty {
@ -1294,7 +1294,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn recursive_type_with_infinite_size_error(self, pub fn recursive_type_with_infinite_size_error(self,
type_def_id: DefId) type_def_id: DefId)
-> DiagnosticBuilder<'tcx> -> DiagnosticBuilder<'tcx>
@ -1457,7 +1457,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ParamToVarFolder<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ParamToVarFolder<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.infcx.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.infcx.tcx }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Param(ty::ParamTy {name, .. }) = ty.sty { if let ty::Param(ty::ParamTy {name, .. }) = ty.sty {

View file

@ -140,7 +140,7 @@ pub struct ObligationCause<'tcx> {
} }
impl<'tcx> ObligationCause<'tcx> { impl<'tcx> ObligationCause<'tcx> {
pub fn span<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Span { pub fn span<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Span {
match self.code { match self.code {
ObligationCauseCode::CompareImplMethodObligation { .. } | ObligationCauseCode::CompareImplMethodObligation { .. } |
ObligationCauseCode::MainFunctionType | ObligationCauseCode::MainFunctionType |
@ -365,7 +365,7 @@ impl<'tcx> DomainGoal<'tcx> {
impl<'tcx> GoalKind<'tcx> { impl<'tcx> GoalKind<'tcx> {
pub fn from_poly_domain_goal<'a, 'gcx>( pub fn from_poly_domain_goal<'a, 'gcx>(
domain_goal: PolyDomainGoal<'tcx>, domain_goal: PolyDomainGoal<'tcx>,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
) -> GoalKind<'tcx> { ) -> GoalKind<'tcx> {
match domain_goal.no_bound_vars() { match domain_goal.no_bound_vars() {
Some(p) => p.into_goal(), Some(p) => p.into_goal(),
@ -710,7 +710,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>(
} }
} }
fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
region_context: DefId, region_context: DefId,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>, elaborated_env: ty::ParamEnv<'tcx>,
@ -795,7 +795,7 @@ fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// FIXME: this is gonna need to be removed ... // FIXME: this is gonna need to be removed ...
/// Normalizes the parameter environment, reporting errors if they occur. /// Normalizes the parameter environment, reporting errors if they occur.
pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
region_context: DefId, region_context: DefId,
unnormalized_env: ty::ParamEnv<'tcx>, unnormalized_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>) cause: ObligationCause<'tcx>)
@ -936,7 +936,7 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
/// environment. If this returns false, then either normalize /// environment. If this returns false, then either normalize
/// encountered an error or one of the predicates did not hold. Used /// encountered an error or one of the predicates did not hold. Used
/// when creating vtables to check for unsatisfiable methods. /// when creating vtables to check for unsatisfiable methods.
fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
predicates: Vec<ty::Predicate<'tcx>>) predicates: Vec<ty::Predicate<'tcx>>)
-> bool -> bool
{ {
@ -965,7 +965,7 @@ fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
result result
} }
fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
key: (DefId, SubstsRef<'tcx>)) key: (DefId, SubstsRef<'tcx>))
-> bool -> bool
{ {
@ -984,7 +984,7 @@ fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
/// that come from `trait_ref`, including its supertraits. /// that come from `trait_ref`, including its supertraits.
#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`. #[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
fn vtable_methods<'a, 'tcx>( fn vtable_methods<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>) trait_ref: ty::PolyTraitRef<'tcx>)
-> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>]
{ {
@ -1207,16 +1207,16 @@ where
fn lift_ex_clause_to_tcx<'a, 'gcx>( fn lift_ex_clause_to_tcx<'a, 'gcx>(
ex_clause: &chalk_engine::ExClause<Self>, ex_clause: &chalk_engine::ExClause<Self>,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
) -> Option<Self::LiftedExClause>; ) -> Option<Self::LiftedExClause>;
fn lift_delayed_literal_to_tcx<'a, 'gcx>( fn lift_delayed_literal_to_tcx<'a, 'gcx>(
ex_clause: &chalk_engine::DelayedLiteral<Self>, ex_clause: &chalk_engine::DelayedLiteral<Self>,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
) -> Option<Self::LiftedDelayedLiteral>; ) -> Option<Self::LiftedDelayedLiteral>;
fn lift_literal_to_tcx<'a, 'gcx>( fn lift_literal_to_tcx<'a, 'gcx>(
ex_clause: &chalk_engine::Literal<Self>, ex_clause: &chalk_engine::Literal<Self>,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
) -> Option<Self::LiftedLiteral>; ) -> Option<Self::LiftedLiteral>;
} }

View file

@ -83,7 +83,7 @@ pub enum MethodViolationCode {
UndispatchableReceiver, UndispatchableReceiver,
} }
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'a, 'tcx> TyCtxt<'tcx, 'tcx, 'tcx> {
/// Returns the object safety violations that affect /// Returns the object safety violations that affect
/// astconv -- currently, `Self` in supertraits. This is needed /// astconv -- currently, `Self` in supertraits. This is needed
@ -703,7 +703,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
} }
} }
pub(super) fn is_object_safe_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub(super) fn is_object_safe_provider<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
trait_def_id: DefId) -> bool { trait_def_id: DefId) -> bool {
tcx.object_safety_violations(trait_def_id).is_empty() tcx.object_safety_violations(trait_def_id).is_empty()
} }

View file

@ -52,7 +52,7 @@ fn parse_error(tcx: TyCtxt<'_, '_, '_>, span: Span,
} }
impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
fn parse(tcx: TyCtxt<'a, 'gcx, 'tcx>, fn parse(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
items: &[NestedMetaItem], items: &[NestedMetaItem],
span: Span, span: Span,
@ -133,7 +133,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
} }
pub fn of_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn of_item(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
impl_def_id: DefId) impl_def_id: DefId)
-> Result<Option<Self>, ErrorReported> -> Result<Option<Self>, ErrorReported>
@ -165,7 +165,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
} }
pub fn evaluate(&self, pub fn evaluate(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>, trait_ref: ty::TraitRef<'tcx>,
options: &[(Symbol, Option<String>)]) options: &[(Symbol, Option<String>)])
-> OnUnimplementedNote -> OnUnimplementedNote
@ -215,7 +215,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
} }
impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString { impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
fn try_parse(tcx: TyCtxt<'a, 'gcx, 'tcx>, fn try_parse(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
from: LocalInternedString, from: LocalInternedString,
err_sp: Span) err_sp: Span)
@ -228,7 +228,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
fn verify( fn verify(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
span: Span, span: Span,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorReported> {
@ -274,7 +274,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
pub fn format( pub fn format(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>, trait_ref: ty::TraitRef<'tcx>,
options: &FxHashMap<Symbol, String>, options: &FxHashMap<Symbol, String>,
) -> String { ) -> String {

View file

@ -323,7 +323,7 @@ impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> {
} }
impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for 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<'c, 'gcx, 'tcx> { fn tcx<'c>(&'c self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.selcx.tcx() self.selcx.tcx()
} }
@ -836,7 +836,7 @@ struct Progress<'tcx> {
} }
impl<'tcx> Progress<'tcx> { impl<'tcx> Progress<'tcx> {
fn error<'a,'gcx>(tcx: TyCtxt<'a,'gcx,'tcx>) -> Self { fn error<'a,'gcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Self {
Progress { Progress {
ty: tcx.types.err, ty: tcx.types.err,
obligations: vec![], obligations: vec![],

View file

@ -87,7 +87,7 @@ pub struct DropckOutlivesResult<'tcx> {
impl<'tcx> DropckOutlivesResult<'tcx> { impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn report_overflows( pub fn report_overflows(
&self, &self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
span: Span, span: Span,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) { ) {
@ -106,7 +106,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn into_kinds_reporting_overflows( pub fn into_kinds_reporting_overflows(
self, self,
tcx: TyCtxt<'_, '_, 'tcx>, tcx: TyCtxt<'tcx, '_, 'tcx>,
span: Span, span: Span,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) -> Vec<Kind<'tcx>> { ) -> Vec<Kind<'tcx>> {
@ -190,7 +190,7 @@ impl_stable_hash_for!(struct DtorckConstraint<'tcx> {
/// ///
/// Note also that `needs_drop` requires a "global" type (i.e., one /// Note also that `needs_drop` requires a "global" type (i.e., one
/// with erased regions), but this function does not. /// 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, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty { match ty.sty {
// None of these types have a destructor and hence they do not // None of these types have a destructor and hence they do not
// require anything in particular to outlive the dtor's // require anything in particular to outlive the dtor's

View file

@ -83,7 +83,7 @@ struct QueryNormalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
} }
impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx> { impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx> {
fn tcx<'c>(&'c self) -> TyCtxt<'c, 'gcx, 'tcx> { fn tcx<'c>(&'c self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -10,7 +10,7 @@
use crate::ty::{self, Ty, TyCtxt}; use crate::ty::{self, Ty, TyCtxt};
use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::fold::{TypeFoldable, TypeFolder};
impl<'cx, 'tcx> TyCtxt<'cx, 'tcx, 'tcx> { impl<'cx, 'tcx> TyCtxt<'tcx, 'tcx, 'tcx> {
/// Erase the regions in `value` and then fully normalize all the /// Erase the regions in `value` and then fully normalize all the
/// types found within. The result will also have regions erased. /// types found within. The result will also have regions erased.
/// ///
@ -62,13 +62,13 @@ impl<'cx, 'tcx> TyCtxt<'cx, 'tcx, 'tcx> {
} }
} }
struct NormalizeAfterErasingRegionsFolder<'cx, 'tcx: 'cx> { struct NormalizeAfterErasingRegionsFolder<'tcx> {
tcx: TyCtxt<'cx, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
} }
impl<'cx, 'tcx> TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'cx, 'tcx> { impl TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -25,14 +25,14 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for AscribeUserType<'tcx>
type QueryResponse = (); type QueryResponse = ();
fn try_fast_path( fn try_fast_path(
_tcx: TyCtxt<'_, 'gcx, 'tcx>, _tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
_key: &ParamEnvAnd<'tcx, Self>, _key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
None None
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> {
tcx.type_op_ascribe_user_type(canonicalized) tcx.type_op_ascribe_user_type(canonicalized)

View file

@ -18,7 +18,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
type QueryResponse = (); type QueryResponse = ();
fn try_fast_path( fn try_fast_path(
_tcx: TyCtxt<'_, 'gcx, 'tcx>, _tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
key: &ParamEnvAnd<'tcx, Eq<'tcx>>, key: &ParamEnvAnd<'tcx, Eq<'tcx>>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
if key.value.a == key.value.b { if key.value.a == key.value.b {
@ -29,7 +29,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> {
tcx.type_op_eq(canonicalized) tcx.type_op_eq(canonicalized)

View file

@ -18,14 +18,14 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds<
type QueryResponse = Vec<OutlivesBound<'tcx>>; type QueryResponse = Vec<OutlivesBound<'tcx>>;
fn try_fast_path( fn try_fast_path(
_tcx: TyCtxt<'_, 'gcx, 'tcx>, _tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
_key: &ParamEnvAnd<'tcx, Self>, _key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
None None
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> {
// FIXME this `unchecked_map` is only necessary because the // FIXME this `unchecked_map` is only necessary because the

View file

@ -53,7 +53,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>:
/// actually hits the tcx cache lookup etc. Return `Some(r)` with /// actually hits the tcx cache lookup etc. Return `Some(r)` with
/// a final result or `None` to do the full path. /// a final result or `None` to do the full path.
fn try_fast_path( fn try_fast_path(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
key: &ParamEnvAnd<'tcx, Self>, key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse>; ) -> Option<Self::QueryResponse>;
@ -64,7 +64,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>:
/// bad, because it would create subregion relationships that are /// bad, because it would create subregion relationships that are
/// not captured in the return value. /// not captured in the return value.
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>>; ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>>;

View file

@ -24,7 +24,7 @@ where
{ {
type QueryResponse = T; type QueryResponse = T;
fn try_fast_path(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> { fn try_fast_path(_tcx: TyCtxt<'tcx, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
if !key.value.value.has_projections() { if !key.value.value.has_projections() {
Some(key.value.value) Some(key.value.value)
} else { } else {
@ -33,7 +33,7 @@ where
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> {
T::type_op_method(tcx, canonicalized) T::type_op_method(tcx, canonicalized)
@ -48,7 +48,7 @@ where
pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx> + Copy { pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx> + Copy {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>>; ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>>;
@ -64,7 +64,7 @@ where
'gcx: 'tcx, 'gcx: 'tcx,
{ {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> {
tcx.type_op_normalize_ty(canonicalized) tcx.type_op_normalize_ty(canonicalized)
@ -82,7 +82,7 @@ where
'gcx: 'tcx, 'gcx: 'tcx,
{ {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> {
tcx.type_op_normalize_predicate(canonicalized) tcx.type_op_normalize_predicate(canonicalized)
@ -100,7 +100,7 @@ where
'gcx: 'tcx, 'gcx: 'tcx,
{ {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> {
tcx.type_op_normalize_poly_fn_sig(canonicalized) tcx.type_op_normalize_poly_fn_sig(canonicalized)
@ -118,7 +118,7 @@ where
'gcx: 'tcx, 'gcx: 'tcx,
{ {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> {
tcx.type_op_normalize_fn_sig(canonicalized) tcx.type_op_normalize_fn_sig(canonicalized)

View file

@ -22,7 +22,7 @@ where
type QueryResponse = DropckOutlivesResult<'tcx>; type QueryResponse = DropckOutlivesResult<'tcx>;
fn try_fast_path( fn try_fast_path(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
key: &ParamEnvAnd<'tcx, Self>, key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
if trivial_dropck_outlives(tcx, key.value.dropped_ty) { if trivial_dropck_outlives(tcx, key.value.dropped_ty) {
@ -33,7 +33,7 @@ where
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> {
// Subtle: note that we are not invoking // Subtle: note that we are not invoking

View file

@ -17,7 +17,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
type QueryResponse = (); type QueryResponse = ();
fn try_fast_path( fn try_fast_path(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
key: &ParamEnvAnd<'tcx, Self>, key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
// Proving Sized, very often on "obviously sized" types like // Proving Sized, very often on "obviously sized" types like
@ -38,7 +38,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> {
tcx.type_op_prove_predicate(canonicalized) tcx.type_op_prove_predicate(canonicalized)

View file

@ -20,7 +20,7 @@ impl<'tcx> Subtype<'tcx> {
impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> { impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
type QueryResponse = (); type QueryResponse = ();
fn try_fast_path(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> { fn try_fast_path(_tcx: TyCtxt<'tcx, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> {
if key.value.sub == key.value.sup { if key.value.sub == key.value.sup {
Some(()) Some(())
} else { } else {
@ -29,7 +29,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> { ) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> {
tcx.type_op_subtype(canonicalized) tcx.type_op_subtype(canonicalized)

View file

@ -300,7 +300,7 @@ enum SelectionCandidate<'tcx> {
impl<'a, 'tcx> ty::Lift<'tcx> for SelectionCandidate<'a> { impl<'a, 'tcx> ty::Lift<'tcx> for SelectionCandidate<'a> {
type Lifted = SelectionCandidate<'tcx>; type Lifted = SelectionCandidate<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
Some(match *self { Some(match *self {
BuiltinCandidate { has_nested } => BuiltinCandidate { has_nested }, BuiltinCandidate { has_nested } => BuiltinCandidate { has_nested },
ImplCandidate(def_id) => ImplCandidate(def_id), ImplCandidate(def_id) => ImplCandidate(def_id),
@ -568,7 +568,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
self.infcx self.infcx
} }
pub fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> { pub fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -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, /// that impl, a less specialized impl, or the trait default,
/// whichever applies. /// whichever applies.
pub fn find_associated_item<'a, 'tcx>( pub fn find_associated_item<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
item: &ty::AssocItem, item: &ty::AssocItem,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
@ -149,7 +149,7 @@ pub fn find_associated_item<'a, 'tcx>(
/// Specialization is determined by the sets of types to which the impls apply; /// Specialization is determined by the sets of types to which the impls apply;
/// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies /// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies
/// to. /// to.
pub(super) fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub(super) fn specializes<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
(impl1_def_id, impl2_def_id): (DefId, DefId)) (impl1_def_id, impl2_def_id): (DefId, DefId))
-> bool -> bool
{ {
@ -286,7 +286,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
// Query provider for `specialization_graph_of`. // Query provider for `specialization_graph_of`.
pub(super) fn specialization_graph_provider<'a, 'tcx>( pub(super) fn specialization_graph_provider<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
trait_id: DefId, trait_id: DefId,
) -> &'tcx specialization_graph::Graph { ) -> &'tcx specialization_graph::Graph {
let mut sg = specialization_graph::Graph::new(); let mut sg = specialization_graph::Graph::new();

View file

@ -84,7 +84,7 @@ enum Inserted {
impl<'a, 'gcx, 'tcx> Children { impl<'a, 'gcx, 'tcx> Children {
/// Insert an impl into this set of children without comparing to any existing impls. /// Insert an impl into this set of children without comparing to any existing impls.
fn insert_blindly(&mut self, fn insert_blindly(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
impl_def_id: DefId) { impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); 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) { if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
@ -100,7 +100,7 @@ impl<'a, 'gcx, 'tcx> Children {
/// an impl with a parent. The impl must be present in the list of /// an impl with a parent. The impl must be present in the list of
/// children already. /// children already.
fn remove_existing(&mut self, fn remove_existing(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
impl_def_id: DefId) { impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
let vec: &mut Vec<DefId>; let vec: &mut Vec<DefId>;
@ -119,7 +119,7 @@ impl<'a, 'gcx, 'tcx> Children {
/// Attempt to insert an impl into this set of children, while comparing for /// Attempt to insert an impl into this set of children, while comparing for
/// specialization relationships. /// specialization relationships.
fn insert(&mut self, fn insert(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
impl_def_id: DefId, impl_def_id: DefId,
simplified_self: Option<SimplifiedType>) simplified_self: Option<SimplifiedType>)
-> Result<Inserted, OverlapError> -> Result<Inserted, OverlapError>
@ -294,7 +294,7 @@ impl<'a, 'gcx, 'tcx> Graph {
/// conflicts with it (has overlap, but neither specializes the other), /// conflicts with it (has overlap, but neither specializes the other),
/// information about the area of overlap is returned in the `Err`. /// information about the area of overlap is returned in the `Err`.
pub fn insert(&mut self, pub fn insert(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
impl_def_id: DefId) impl_def_id: DefId)
-> Result<Option<FutureCompatOverlapError>, OverlapError> { -> Result<Option<FutureCompatOverlapError>, OverlapError> {
assert!(impl_def_id.is_local()); assert!(impl_def_id.is_local());
@ -387,7 +387,7 @@ impl<'a, 'gcx, 'tcx> Graph {
/// Insert cached metadata mapping from a child impl back to its parent. /// Insert cached metadata mapping from a child impl back to its parent.
pub fn record_impl_from_cstore(&mut self, pub fn record_impl_from_cstore(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
parent: DefId, parent: DefId,
child: DefId) { child: DefId) {
if self.parent.insert(child, parent).is_some() { if self.parent.insert(child, parent).is_some() {
@ -425,8 +425,8 @@ impl<'a, 'gcx, 'tcx> Node {
/// Iterate over the items defined directly by the given (impl or trait) node. /// Iterate over the items defined directly by the given (impl or trait) node.
pub fn items( pub fn items(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
) -> ty::AssocItemsIterator<'a, 'gcx, 'tcx> { ) -> ty::AssocItemsIterator<'gcx, 'tcx> {
tcx.associated_items(self.def_id()) tcx.associated_items(self.def_id())
} }
@ -475,18 +475,18 @@ impl<T> NodeItem<T> {
} }
} }
impl<'a, 'gcx, 'tcx> Ancestors<'gcx> { impl<'gcx, 'tcx> Ancestors<'gcx> {
/// Search the items from the given ancestors, returning each definition /// Search the items from the given ancestors, returning each definition
/// with the given name and the given kind. /// with the given name and the given kind.
// FIXME(#35870): avoid closures being unexported due to `impl Trait`. // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
#[inline] #[inline]
pub fn defs( pub fn defs(
self, self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_item_name: Ident, trait_item_name: Ident,
trait_item_kind: ty::AssocKind, trait_item_kind: ty::AssocKind,
trait_def_id: DefId, trait_def_id: DefId,
) -> impl Iterator<Item = NodeItem<ty::AssocItem>> + Captures<'gcx> + Captures<'tcx> + 'a { ) -> impl Iterator<Item = NodeItem<ty::AssocItem>> + Captures<'gcx> + 'tcx {
self.flat_map(move |node| { self.flat_map(move |node| {
use crate::ty::AssocKind::*; use crate::ty::AssocKind::*;
node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) { node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) {

View file

@ -446,7 +446,7 @@ impl<'tcx> fmt::Display for traits::Clause<'tcx> {
impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> { impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> {
type Lifted = traits::SelectionError<'tcx>; type Lifted = traits::SelectionError<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
match *self { match *self {
super::Unimplemented => Some(super::Unimplemented), super::Unimplemented => Some(super::Unimplemented),
super::OutputTypeParameterMismatch(a, b, ref err) => { 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> { impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
type Lifted = traits::ObligationCauseCode<'tcx>; type Lifted = traits::ObligationCauseCode<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
match *self { match *self {
super::ReturnNoExpression => Some(super::ReturnNoExpression), super::ReturnNoExpression => Some(super::ReturnNoExpression),
super::MiscObligation => Some(super::MiscObligation), 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> { impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> {
type Lifted = traits::DerivedObligationCause<'tcx>; type Lifted = traits::DerivedObligationCause<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.parent_trait_ref).and_then(|trait_ref| tcx.lift(&self.parent_trait_ref).and_then(|trait_ref|
tcx.lift(&*self.parent_code) tcx.lift(&*self.parent_code)
.map(|code| traits::DerivedObligationCause { .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> { impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCause<'a> {
type Lifted = traits::ObligationCause<'tcx>; type Lifted = traits::ObligationCause<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.code).map(|code| traits::ObligationCause { tcx.lift(&self.code).map(|code| traits::ObligationCause {
span: self.span, span: self.span,
body_id: self.body_id, body_id: self.body_id,
@ -571,7 +571,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCause<'a> {
// For codegen only. // For codegen only.
impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> { impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
type Lifted = traits::Vtable<'tcx, ()>; type Lifted = traits::Vtable<'tcx, ()>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
match self.clone() { match self.clone() {
traits::VtableImpl(traits::VtableImplData { traits::VtableImpl(traits::VtableImplData {
impl_def_id, impl_def_id,
@ -691,7 +691,7 @@ EnumLiftImpl! {
impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> { impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> {
type Lifted = traits::Environment<'tcx>; type Lifted = traits::Environment<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.clauses).map(|clauses| { tcx.lift(&self.clauses).map(|clauses| {
traits::Environment { traits::Environment {
clauses, 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> { impl<'a, 'tcx, G: Lift<'tcx>> Lift<'tcx> for traits::InEnvironment<'a, G> {
type Lifted = traits::InEnvironment<'tcx, G::Lifted>; type Lifted = traits::InEnvironment<'tcx, G::Lifted>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.environment).and_then(|environment| { tcx.lift(&self.environment).and_then(|environment| {
tcx.lift(&self.goal).map(|goal| { tcx.lift(&self.goal).map(|goal| {
traits::InEnvironment { traits::InEnvironment {
@ -721,7 +721,7 @@ where
{ {
type Lifted = C::LiftedExClause; type Lifted = C::LiftedExClause;
fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
<C as traits::ChalkContextLift>::lift_ex_clause_to_tcx(self, tcx) <C as traits::ChalkContextLift>::lift_ex_clause_to_tcx(self, tcx)
} }
} }
@ -733,7 +733,7 @@ where
{ {
type Lifted = C::LiftedDelayedLiteral; type Lifted = C::LiftedDelayedLiteral;
fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
<C as traits::ChalkContextLift>::lift_delayed_literal_to_tcx(self, tcx) <C as traits::ChalkContextLift>::lift_delayed_literal_to_tcx(self, tcx)
} }
} }
@ -745,7 +745,7 @@ where
{ {
type Lifted = C::LiftedLiteral; type Lifted = C::LiftedLiteral;
fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
<C as traits::ChalkContextLift>::lift_literal_to_tcx(self, tcx) <C as traits::ChalkContextLift>::lift_literal_to_tcx(self, tcx)
} }
} }

View file

@ -12,7 +12,7 @@ use crate::util::nodemap::FxHashSet;
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized}; use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
pred: &ty::Predicate<'tcx>) pred: &ty::Predicate<'tcx>)
-> ty::Predicate<'tcx> { -> ty::Predicate<'tcx> {
match *pred { match *pred {
@ -45,13 +45,13 @@ fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
} }
} }
struct PredicateSet<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { struct PredicateSet<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
set: FxHashSet<ty::Predicate<'tcx>>, set: FxHashSet<ty::Predicate<'tcx>>,
} }
impl<'a, 'gcx, 'tcx> PredicateSet<'a, 'gcx, 'tcx> { impl PredicateSet<'gcx, 'tcx> {
fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self { fn new(tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Self {
Self { tcx: tcx, set: Default::default() } Self { tcx: tcx, set: Default::default() }
} }
@ -70,7 +70,7 @@ impl<'a, 'gcx, 'tcx> PredicateSet<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx, T: AsRef<ty::Predicate<'tcx>>> Extend<T> for PredicateSet<'a, 'gcx, 'tcx> { impl<T: AsRef<ty::Predicate<'tcx>>> Extend<T> for PredicateSet<'gcx, 'tcx> {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) { fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
for pred in iter { for pred in iter {
self.insert(pred.as_ref()); self.insert(pred.as_ref());
@ -88,39 +88,39 @@ impl<'a, 'gcx, 'tcx, T: AsRef<ty::Predicate<'tcx>>> Extend<T> for PredicateSet<'
/// if we know that `T: Ord`, the elaborator would deduce that `T: PartialOrd` /// 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 /// holds as well. Similarly, if we have `trait Foo: 'static`, and we know that
/// `T: Foo`, then we know that `T: 'static`. /// `T: Foo`, then we know that `T: 'static`.
pub struct Elaborator<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct Elaborator<'gcx, 'tcx> {
stack: Vec<ty::Predicate<'tcx>>, stack: Vec<ty::Predicate<'tcx>>,
visited: PredicateSet<'a, 'gcx, 'tcx>, visited: PredicateSet<'gcx, 'tcx>,
} }
pub fn elaborate_trait_ref<'cx, 'gcx, 'tcx>( pub fn elaborate_trait_ref<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>) trait_ref: ty::PolyTraitRef<'tcx>)
-> Elaborator<'cx, 'gcx, 'tcx> -> Elaborator<'gcx, 'tcx>
{ {
elaborate_predicates(tcx, vec![trait_ref.to_predicate()]) elaborate_predicates(tcx, vec![trait_ref.to_predicate()])
} }
pub fn elaborate_trait_refs<'cx, 'gcx, 'tcx>( pub fn elaborate_trait_refs<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>) trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Elaborator<'cx, 'gcx, 'tcx> -> Elaborator<'gcx, 'tcx>
{ {
let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect(); let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect();
elaborate_predicates(tcx, predicates) elaborate_predicates(tcx, predicates)
} }
pub fn elaborate_predicates<'cx, 'gcx, 'tcx>( pub fn elaborate_predicates<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
mut predicates: Vec<ty::Predicate<'tcx>>) mut predicates: Vec<ty::Predicate<'tcx>>)
-> Elaborator<'cx, 'gcx, 'tcx> -> Elaborator<'gcx, 'tcx>
{ {
let mut visited = PredicateSet::new(tcx); let mut visited = PredicateSet::new(tcx);
predicates.retain(|pred| visited.insert(pred)); predicates.retain(|pred| visited.insert(pred));
Elaborator { stack: predicates, visited } Elaborator { stack: predicates, visited }
} }
impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> { impl Elaborator<'gcx, 'tcx> {
pub fn filter_to_traits(self) -> FilterToTraits<Self> { pub fn filter_to_traits(self) -> FilterToTraits<Self> {
FilterToTraits::new(self) FilterToTraits::new(self)
} }
@ -232,7 +232,7 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
} }
} }
impl<'cx, 'gcx, 'tcx> Iterator for Elaborator<'cx, 'gcx, 'tcx> { impl Iterator for Elaborator<'gcx, 'tcx> {
type Item = ty::Predicate<'tcx>; type Item = ty::Predicate<'tcx>;
fn size_hint(&self) -> (usize, Option<usize>) { fn size_hint(&self) -> (usize, Option<usize>) {
@ -254,17 +254,17 @@ impl<'cx, 'gcx, 'tcx> Iterator for Elaborator<'cx, 'gcx, 'tcx> {
// Supertrait iterator // Supertrait iterator
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
pub type Supertraits<'cx, 'gcx, 'tcx> = FilterToTraits<Elaborator<'cx, 'gcx, 'tcx>>; pub type Supertraits<'gcx, 'tcx> = FilterToTraits<Elaborator<'gcx, 'tcx>>;
pub fn supertraits<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>, pub fn supertraits<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>) trait_ref: ty::PolyTraitRef<'tcx>)
-> Supertraits<'cx, 'gcx, 'tcx> { -> Supertraits<'gcx, 'tcx> {
elaborate_trait_ref(tcx, trait_ref).filter_to_traits() elaborate_trait_ref(tcx, trait_ref).filter_to_traits()
} }
pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>, pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>) bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Supertraits<'cx, 'gcx, 'tcx> { -> Supertraits<'gcx, 'tcx> {
elaborate_trait_refs(tcx, bounds).filter_to_traits() elaborate_trait_refs(tcx, bounds).filter_to_traits()
} }
@ -280,8 +280,8 @@ pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
/// `Read + Write + Sync + Send`. /// `Read + Write + Sync + Send`.
/// Expansion is done via a DFS (depth-first search), and the `visited` field /// Expansion is done via a DFS (depth-first search), and the `visited` field
/// is used to avoid cycles. /// is used to avoid cycles.
pub struct TraitAliasExpander<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct TraitAliasExpander<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
stack: Vec<TraitAliasExpansionInfo<'tcx>>, stack: Vec<TraitAliasExpansionInfo<'tcx>>,
} }
@ -338,9 +338,9 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> {
} }
pub fn expand_trait_aliases<'cx, 'gcx, 'tcx>( pub fn expand_trait_aliases<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)> trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>
) -> TraitAliasExpander<'cx, 'gcx, 'tcx> { ) -> TraitAliasExpander<'gcx, 'tcx> {
let items: Vec<_> = trait_refs let items: Vec<_> = trait_refs
.into_iter() .into_iter()
.map(|(trait_ref, span)| TraitAliasExpansionInfo::new(trait_ref, span)) .map(|(trait_ref, span)| TraitAliasExpansionInfo::new(trait_ref, span))
@ -348,7 +348,7 @@ pub fn expand_trait_aliases<'cx, 'gcx, 'tcx>(
TraitAliasExpander { tcx, stack: items } TraitAliasExpander { tcx, stack: items }
} }
impl<'cx, 'gcx, 'tcx> TraitAliasExpander<'cx, 'gcx, 'tcx> { impl<'cx, 'gcx, 'tcx> TraitAliasExpander<'gcx, 'tcx> {
/// If `item` is a trait alias and its predicate has not yet been visited, then expands `item` /// 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`. /// 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 /// Otherwise, immediately returns `true` if `item` is a regular trait, or `false` if it is a
@ -393,7 +393,7 @@ impl<'cx, 'gcx, 'tcx> TraitAliasExpander<'cx, 'gcx, 'tcx> {
} }
} }
impl<'cx, 'gcx, 'tcx> Iterator for TraitAliasExpander<'cx, 'gcx, 'tcx> { impl<'cx, 'gcx, 'tcx> Iterator for TraitAliasExpander<'gcx, 'tcx> {
type Item = TraitAliasExpansionInfo<'tcx>; type Item = TraitAliasExpansionInfo<'tcx>;
fn size_hint(&self) -> (usize, Option<usize>) { fn size_hint(&self) -> (usize, Option<usize>) {
@ -414,15 +414,15 @@ impl<'cx, 'gcx, 'tcx> Iterator for TraitAliasExpander<'cx, 'gcx, 'tcx> {
// Iterator over def-IDs of supertraits // Iterator over def-IDs of supertraits
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
pub struct SupertraitDefIds<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct SupertraitDefIds<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
stack: Vec<DefId>, stack: Vec<DefId>,
visited: FxHashSet<DefId>, visited: FxHashSet<DefId>,
} }
pub fn supertrait_def_ids<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>, pub fn supertrait_def_ids<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_def_id: DefId) trait_def_id: DefId)
-> SupertraitDefIds<'cx, 'gcx, 'tcx> -> SupertraitDefIds<'gcx, 'tcx>
{ {
SupertraitDefIds { SupertraitDefIds {
tcx, tcx,
@ -431,7 +431,7 @@ pub fn supertrait_def_ids<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
} }
} }
impl<'cx, 'gcx, 'tcx> Iterator for SupertraitDefIds<'cx, 'gcx, 'tcx> { impl Iterator for SupertraitDefIds<'gcx, 'tcx> {
type Item = DefId; type Item = DefId;
fn next(&mut self) -> Option<DefId> { fn next(&mut self) -> Option<DefId> {
@ -552,7 +552,7 @@ pub fn predicate_for_trait_ref<'tcx>(
} }
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn predicate_for_trait_def(self, pub fn predicate_for_trait_def(self,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,

View file

@ -19,19 +19,19 @@ use crate::mir::interpret::ConstValue;
/// Like subtyping, matching is really a binary relation, so the only /// Like subtyping, matching is really a binary relation, so the only
/// important thing about the result is Ok/Err. Also, matching never /// important thing about the result is Ok/Err. Also, matching never
/// affects any type variables or unification state. /// affects any type variables or unification state.
pub struct Match<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct Match<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx> tcx: TyCtxt<'tcx, 'gcx, 'tcx>
} }
impl<'a, 'gcx, 'tcx> Match<'a, 'gcx, 'tcx> { impl Match<'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Match<'a, 'gcx, 'tcx> { pub fn new(tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Match<'gcx, 'tcx> {
Match { tcx } Match { tcx }
} }
} }
impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Match<'a, 'gcx, 'tcx> { impl TypeRelation<'gcx, 'tcx> for Match<'gcx, 'tcx> {
fn tag(&self) -> &'static str { "Match" } fn tag(&self) -> &'static str { "Match" }
fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.tcx } fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.tcx }
fn a_is_expected(&self) -> bool { true } // irrelevant fn a_is_expected(&self) -> bool { true } // irrelevant
fn relate_with_variance<T: Relate<'tcx>>(&mut self, fn relate_with_variance<T: Relate<'tcx>>(&mut self,

View file

@ -104,7 +104,7 @@ pub struct OverloadedDeref<'tcx> {
} }
impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> { impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> {
pub fn method_call(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, source: Ty<'tcx>) pub fn method_call(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>, source: Ty<'tcx>)
-> (DefId, SubstsRef<'tcx>) { -> (DefId, SubstsRef<'tcx>) {
let trait_def_id = match self.mutbl { let trait_def_id = match self.mutbl {
hir::MutImmutable => tcx.lang_items().deref_trait(), hir::MutImmutable => tcx.lang_items().deref_trait(),

View file

@ -107,9 +107,8 @@ pub fn encode_predicates<'tcx, E, C>(encoder: &mut E,
Ok(()) Ok(())
} }
pub trait TyDecoder<'a, 'tcx: 'a>: Decoder { pub trait TyDecoder<'tcx>: Decoder {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx, 'tcx>;
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
fn peek_byte(&self) -> u8; fn peek_byte(&self) -> u8;
@ -135,7 +134,7 @@ pub trait TyDecoder<'a, 'tcx: 'a>: Decoder {
pub fn decode_arena_allocable<'a, 'tcx, D, T: ArenaAllocatable + Decodable>( pub fn decode_arena_allocable<'a, 'tcx, D, T: ArenaAllocatable + Decodable>(
decoder: &mut D decoder: &mut D
) -> Result<&'tcx T, D::Error> ) -> Result<&'tcx T, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?)) Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
@ -145,7 +144,7 @@ pub fn decode_arena_allocable<'a, 'tcx, D, T: ArenaAllocatable + Decodable>(
pub fn decode_arena_allocable_slice<'a, 'tcx, D, T: ArenaAllocatable + Decodable>( pub fn decode_arena_allocable_slice<'a, 'tcx, D, T: ArenaAllocatable + Decodable>(
decoder: &mut D decoder: &mut D
) -> Result<&'tcx [T], D::Error> ) -> Result<&'tcx [T], D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?)) Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
@ -153,7 +152,7 @@ pub fn decode_arena_allocable_slice<'a, 'tcx, D, T: ArenaAllocatable + Decodable
#[inline] #[inline]
pub fn decode_cnum<'a, 'tcx, D>(decoder: &mut D) -> Result<CrateNum, D::Error> pub fn decode_cnum<'a, 'tcx, D>(decoder: &mut D) -> Result<CrateNum, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
let cnum = CrateNum::from_u32(u32::decode(decoder)?); let cnum = CrateNum::from_u32(u32::decode(decoder)?);
@ -162,7 +161,7 @@ pub fn decode_cnum<'a, 'tcx, D>(decoder: &mut D) -> Result<CrateNum, D::Error>
#[inline] #[inline]
pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error> pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
// Handle shorthands first, if we have an usize > 0x80. // Handle shorthands first, if we have an usize > 0x80.
@ -183,7 +182,7 @@ pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
#[inline] #[inline]
pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D) pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
-> Result<ty::GenericPredicates<'tcx>, D::Error> -> Result<ty::GenericPredicates<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
Ok(ty::GenericPredicates { Ok(ty::GenericPredicates {
@ -207,7 +206,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error> pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
@ -217,7 +216,7 @@ pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D:
#[inline] #[inline]
pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error> pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?)) Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
@ -226,7 +225,7 @@ pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D
#[inline] #[inline]
pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D) pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::List<Ty<'tcx>>, D::Error> -> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
@ -236,7 +235,7 @@ pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D) pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::AdtDef, D::Error> -> Result<&'tcx ty::AdtDef, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
let def_id = DefId::decode(decoder)?; let def_id = DefId::decode(decoder)?;
@ -246,7 +245,7 @@ pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D) pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error> -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
@ -257,7 +256,7 @@ pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D) pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
-> Result<CanonicalVarInfos<'tcx>, D::Error> -> Result<CanonicalVarInfos<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
@ -270,7 +269,7 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_const<'a, 'tcx, D>(decoder: &mut D) pub fn decode_const<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::Const<'tcx>, D::Error> -> Result<&'tcx ty::Const<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?)) Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
@ -279,7 +278,7 @@ pub fn decode_const<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D) pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx Allocation, D::Error> -> Result<&'tcx Allocation, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?)) Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?))

View file

@ -6,7 +6,7 @@ use syntax_pos::symbol::{sym, Symbol};
use crate::hir::map::blocks::FnLikeNode; use crate::hir::map::blocks::FnLikeNode;
use syntax::attr; use syntax::attr;
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'a, 'tcx> TyCtxt<'tcx, 'tcx, 'tcx> {
/// Whether the `def_id` counts as const fn in your current crate, considering all active /// Whether the `def_id` counts as const fn in your current crate, considering all active
/// feature gates /// feature gates
pub fn is_const_fn(self, def_id: DefId) -> bool { pub fn is_const_fn(self, def_id: DefId) -> bool {
@ -69,7 +69,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
/// only checks whether the function has a `const` modifier /// only checks whether the function has a `const` modifier
fn is_const_fn_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { fn is_const_fn_raw<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId) -> bool {
let hir_id = tcx.hir().as_local_hir_id(def_id) let hir_id = tcx.hir().as_local_hir_id(def_id)
.expect("Non-local call to local provider is_const_fn"); .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<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { fn is_promotable_const_fn<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId) -> bool {
tcx.is_const_fn(def_id) && match tcx.lookup_stability(def_id) { tcx.is_const_fn(def_id) && match tcx.lookup_stability(def_id) {
Some(stab) => { Some(stab) => {
if cfg!(debug_assertions) && stab.promotable { 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<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { fn const_fn_is_allowed_fn_ptr<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId) -> bool {
tcx.is_const_fn(def_id) && tcx.is_const_fn(def_id) &&
tcx.lookup_stability(def_id) tcx.lookup_stability(def_id)
.map(|stab| stab.allow_const_fn_ptr).unwrap_or(false) .map(|stab| stab.allow_const_fn_ptr).unwrap_or(false)

View file

@ -1119,7 +1119,7 @@ pub struct GlobalCtxt<'tcx> {
output_filenames: Arc<OutputFilenames>, output_filenames: Arc<OutputFilenames>,
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Gets the global `TyCtxt`. /// Gets the global `TyCtxt`.
#[inline] #[inline]
pub fn global_tcx(self) -> TyCtxt<'gcx, 'gcx, 'gcx> { pub fn global_tcx(self) -> TyCtxt<'gcx, 'gcx, 'gcx> {
@ -1131,7 +1131,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
#[inline(always)] #[inline(always)]
pub fn hir(self) -> &'a hir_map::Map<'gcx> { pub fn hir(self) -> &'tcx hir_map::Map<'gcx> {
&self.hir_map &self.hir_map
} }
@ -1469,7 +1469,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
#[inline(always)] #[inline(always)]
pub fn create_stable_hashing_context(self) -> StableHashingContext<'a> { pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> {
let krate = self.gcx.hir_map.forest.untracked_krate(); let krate = self.gcx.hir_map.forest.untracked_krate();
StableHashingContext::new(self.sess, StableHashingContext::new(self.sess,
@ -1666,7 +1666,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'a, 'tcx> TyCtxt<'tcx, 'tcx, 'tcx> {
pub fn encode_metadata(self) pub fn encode_metadata(self)
-> EncodedMetadata -> EncodedMetadata
{ {
@ -1725,7 +1725,7 @@ impl<'gcx> GlobalCtxt<'gcx> {
/// e.g., `()` or `u8`, was interned in a different context. /// e.g., `()` or `u8`, was interned in a different context.
pub trait Lift<'tcx>: fmt::Debug { pub trait Lift<'tcx>: fmt::Debug {
type Lifted: fmt::Debug + 'tcx; type Lifted: fmt::Debug + 'tcx;
fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted>; fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted>;
} }
@ -1733,7 +1733,7 @@ macro_rules! nop_lift {
($ty:ty => $lifted:ty) => { ($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for $ty { impl<'a, 'tcx> Lift<'tcx> for $ty {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
} }
@ -1752,7 +1752,7 @@ macro_rules! nop_list_lift {
($ty:ty => $lifted:ty) => { ($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> { impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
type Lifted = &'tcx List<$lifted>; type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Self::Lifted> {
if self.is_empty() { if self.is_empty() {
return Some(List::empty()); return Some(List::empty());
} }
@ -1978,7 +1978,7 @@ pub mod tls {
/// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local. /// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local.
/// This is used in the deadlock handler. /// This is used in the deadlock handler.
pub unsafe fn with_global<F, R>(f: F) -> R pub unsafe fn with_global<F, R>(f: F) -> R
where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'tcx, 'gcx, 'tcx>) -> R
{ {
let gcx = GCX_PTR.with(|lock| *lock.lock()); let gcx = GCX_PTR.with(|lock| *lock.lock());
assert!(gcx != 0); assert!(gcx != 0);
@ -2030,7 +2030,7 @@ pub mod tls {
/// This will panic if you pass it a TyCtxt which has a different global interner from /// This will panic if you pass it a TyCtxt which has a different global interner from
/// the current ImplicitCtxt's tcx field. /// the current ImplicitCtxt's tcx field.
#[inline] #[inline]
pub fn with_related_context<'a, 'gcx, 'tcx1, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx1>, f: F) -> R pub fn with_related_context<'gcx, 'tcx1, F, R>(tcx: TyCtxt<'tcx1, 'gcx, 'tcx1>, f: F) -> R
where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R
{ {
with_context(|context| { with_context(|context| {
@ -2048,7 +2048,7 @@ pub mod tls {
/// This will panic if you pass it a TyCtxt which has a different global interner or /// 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. /// a different local interner from the current ImplicitCtxt's tcx field.
#[inline] #[inline]
pub fn with_fully_related_context<'a, 'gcx, 'tcx, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx>, f: F) -> R pub fn with_fully_related_context<'gcx, 'tcx, F, R>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>, f: F) -> R
where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R
{ {
with_context(|context| { with_context(|context| {
@ -2065,7 +2065,7 @@ pub mod tls {
/// Panics if there is no ImplicitCtxt available /// Panics if there is no ImplicitCtxt available
#[inline] #[inline]
pub fn with<F, R>(f: F) -> R pub fn with<F, R>(f: F) -> R
where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'tcx, 'gcx, 'tcx>) -> R
{ {
with_context(|context| f(context.tcx)) with_context(|context| f(context.tcx))
} }
@ -2074,7 +2074,7 @@ pub mod tls {
/// The closure is passed None if there is no ImplicitCtxt available /// The closure is passed None if there is no ImplicitCtxt available
#[inline] #[inline]
pub fn with_opt<F, R>(f: F) -> R pub fn with_opt<F, R>(f: F) -> R
where F: for<'a, 'gcx, 'tcx> FnOnce(Option<TyCtxt<'a, 'gcx, 'tcx>>) -> R where F: for<'a, 'gcx, 'tcx> FnOnce(Option<TyCtxt<'tcx, 'gcx, 'tcx>>) -> R
{ {
with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx))) with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx)))
} }
@ -2151,7 +2151,7 @@ macro_rules! sty_debug_print {
}} }}
} }
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { impl<'a, 'tcx> TyCtxt<'tcx, 'tcx, 'tcx> {
pub fn print_debug_stats(self) { pub fn print_debug_stats(self) {
sty_debug_print!( sty_debug_print!(
self, self,
@ -2400,7 +2400,7 @@ intern_method! {
) -> List<CanonicalVarInfo> ) -> List<CanonicalVarInfo>
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Given a `fn` type, returns an equivalent `unsafe fn` type; /// Given a `fn` type, returns an equivalent `unsafe fn` type;
/// that is, a `fn` type that is equivalent in every way for being /// that is, a `fn` type that is equivalent in every way for being
/// unsafe. /// unsafe.

View file

@ -8,13 +8,13 @@ pub(super) fn provide(providers: &mut ty::query::Providers<'_>) {
}; };
} }
fn erase_regions_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { fn erase_regions_ty<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
// N.B., use `super_fold_with` here. If we used `fold_with`, it // N.B., use `super_fold_with` here. If we used `fold_with`, it
// could invoke the `erase_regions_ty` query recursively. // could invoke the `erase_regions_ty` query recursively.
ty.super_fold_with(&mut RegionEraserVisitor { tcx }) ty.super_fold_with(&mut RegionEraserVisitor { tcx })
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Returns an equivalent value with all free regions removed (note /// Returns an equivalent value with all free regions removed (note
/// that late-bound regions remain, because they are important for /// that late-bound regions remain, because they are important for
/// subtyping, but they are anonymized and normalized as well).. /// subtyping, but they are anonymized and normalized as well)..
@ -32,12 +32,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
} }
struct RegionEraserVisitor<'a, 'gcx: 'tcx, 'tcx: 'a> { struct RegionEraserVisitor<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionEraserVisitor<'a, 'gcx, 'tcx> { impl TypeFolder<'gcx, 'tcx> for RegionEraserVisitor<'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -184,7 +184,7 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
} }
impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> Cow<'static, str> { pub fn sort_string(&self, tcx: TyCtxt<'lcx, 'gcx, 'lcx>) -> Cow<'static, str> {
match self.sty { match self.sty {
ty::Bool | ty::Char | ty::Int(_) | ty::Bool | ty::Char | ty::Int(_) |
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(), ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(),
@ -249,7 +249,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn note_and_explain_type_err(self, pub fn note_and_explain_type_err(self,
db: &mut DiagnosticBuilder<'_>, db: &mut DiagnosticBuilder<'_>,
err: &TypeError<'tcx>, err: &TypeError<'tcx>,

View file

@ -55,7 +55,7 @@ pub enum SimplifiedTypeGen<D>
/// then we can't say much about whether two types would unify. Put another way, /// 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 /// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they
/// are to be considered bound. /// are to be considered bound.
pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
ty: Ty<'_>, ty: Ty<'_>,
can_simplify_params: bool) can_simplify_params: bool)
-> Option<SimplifiedType> -> Option<SimplifiedType>

View file

@ -156,7 +156,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
/// identity fold, it should invoke `foo.fold_with(self)` to fold each /// identity fold, it should invoke `foo.fold_with(self)` to fold each
/// sub-item. /// sub-item.
pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized { pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx>; fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'gcx, 'tcx>;
fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T> fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T>
where T : TypeFoldable<'tcx> where T : TypeFoldable<'tcx>
@ -198,23 +198,23 @@ pub trait TypeVisitor<'tcx> : Sized {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Some sample folders // Some sample folders
pub struct BottomUpFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a, F, G, H> pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>, H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
{ {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>, pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
pub ty_op: F, pub ty_op: F,
pub lt_op: G, pub lt_op: G,
pub ct_op: H, pub ct_op: H,
} }
impl<'a, 'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx, 'tcx, F, G, H> impl<'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'gcx, 'tcx, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>, H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
{ {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.tcx }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
let t = ty.super_fold_with(self); let t = ty.super_fold_with(self);
@ -235,7 +235,7 @@ impl<'a, 'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Region folder // Region folder
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Collects the free and escaping regions in `value` into `region_set`. Returns /// Collects the free and escaping regions in `value` into `region_set`. Returns
/// whether any late-bound regions were skipped /// whether any late-bound regions were skipped
pub fn collect_regions<T>(self, pub fn collect_regions<T>(self,
@ -362,7 +362,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// visited by `fld_r`. /// visited by `fld_r`.
pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
skipped_regions: &'a mut bool, skipped_regions: &'a mut bool,
/// Stores the index of a binder *just outside* the stuff we have /// Stores the index of a binder *just outside* the stuff we have
@ -382,7 +382,7 @@ pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
#[inline] #[inline]
pub fn new( pub fn new(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
skipped_regions: &'a mut bool, skipped_regions: &'a mut bool,
fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>, fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
) -> RegionFolder<'a, 'gcx, 'tcx> { ) -> RegionFolder<'a, 'gcx, 'tcx> {
@ -396,7 +396,7 @@ impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.tcx }
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> { fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1); self.current_index.shift_in(1);
@ -427,7 +427,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> {
/// Replaces the escaping bound vars (late bound regions or bound types) in a type. /// Replaces the escaping bound vars (late bound regions or bound types) in a type.
struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
/// As with `RegionFolder`, represents the index of a binder *just outside* /// As with `RegionFolder`, represents the index of a binder *just outside*
/// the ones we have visited. /// the ones we have visited.
@ -440,7 +440,7 @@ struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
fn new<F, G, H>( fn new<F, G, H>(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
fld_r: &'a mut F, fld_r: &'a mut F,
fld_t: &'a mut G, fld_t: &'a mut G,
fld_c: &'a mut H, fld_c: &'a mut H,
@ -460,7 +460,7 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.tcx }
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> { fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1); self.current_index.shift_in(1);
@ -542,7 +542,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx>
} }
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Replaces all regions bound by the given `Binder` with the /// Replaces all regions bound by the given `Binder` with the
/// results returned by the closure; the closure is expected to /// results returned by the closure; the closure is expected to
/// return a free region (relative to this binder), and hence the /// return a free region (relative to this binder), and hence the
@ -722,15 +722,15 @@ enum Direction {
Out, Out,
} }
struct Shifter<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { struct Shifter<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
current_index: ty::DebruijnIndex, current_index: ty::DebruijnIndex,
amount: u32, amount: u32,
direction: Direction, direction: Direction,
} }
impl Shifter<'a, 'gcx, 'tcx> { impl Shifter<'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>, amount: u32, direction: Direction) -> Self { pub fn new(tcx: TyCtxt<'tcx, 'gcx, 'tcx>, amount: u32, direction: Direction) -> Self {
Shifter { Shifter {
tcx, tcx,
current_index: ty::INNERMOST, current_index: ty::INNERMOST,
@ -740,8 +740,8 @@ impl Shifter<'a, 'gcx, 'tcx> {
} }
} }
impl TypeFolder<'gcx, 'tcx> for Shifter<'a, 'gcx, 'tcx> { impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.tcx }
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> { fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1); self.current_index.shift_in(1);
@ -818,7 +818,7 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'a, 'gcx, 'tcx> {
} }
pub fn shift_region<'a, 'gcx, 'tcx>( pub fn shift_region<'a, 'gcx, 'tcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
region: ty::Region<'tcx>, region: ty::Region<'tcx>,
amount: u32 amount: u32
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
@ -833,7 +833,7 @@ pub fn shift_region<'a, 'gcx, 'tcx>(
} }
pub fn shift_vars<'a, 'gcx, 'tcx, T>( pub fn shift_vars<'a, 'gcx, 'tcx, T>(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
value: &T, value: &T,
amount: u32 amount: u32
) -> T where T: TypeFoldable<'tcx> { ) -> T where T: TypeFoldable<'tcx> {
@ -844,7 +844,7 @@ pub fn shift_vars<'a, 'gcx, 'tcx, T>(
} }
pub fn shift_out_vars<'a, 'gcx, 'tcx, T>( pub fn shift_out_vars<'a, 'gcx, 'tcx, T>(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
value: &T, value: &T,
amount: u32 amount: u32
) -> T where T: TypeFoldable<'tcx> { ) -> T where T: TypeFoldable<'tcx> {

View file

@ -32,7 +32,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
/// Creates a forest consisting of a single tree representing the entire /// Creates a forest consisting of a single tree representing the entire
/// crate. /// crate.
#[inline] #[inline]
pub fn full(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest { pub fn full(tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> DefIdForest {
let crate_id = tcx.hir().local_def_id(CRATE_NODE_ID); let crate_id = tcx.hir().local_def_id(CRATE_NODE_ID);
DefIdForest::from_id(crate_id) DefIdForest::from_id(crate_id)
} }
@ -53,14 +53,14 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
/// Tests whether the forest contains a given DefId. /// Tests whether the forest contains a given DefId.
pub fn contains(&self, pub fn contains(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
id: DefId) -> bool id: DefId) -> bool
{ {
self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id)) self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id))
} }
/// Calculate the intersection of a collection of forests. /// Calculate the intersection of a collection of forests.
pub fn intersection<I>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn intersection<I>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
iter: I) -> DefIdForest iter: I) -> DefIdForest
where I: IntoIterator<Item=DefIdForest> where I: IntoIterator<Item=DefIdForest>
{ {
@ -97,7 +97,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
} }
/// Calculate the union of a collection of forests. /// Calculate the union of a collection of forests.
pub fn union<I>(tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn union<I>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
iter: I) -> DefIdForest iter: I) -> DefIdForest
where I: IntoIterator<Item=DefIdForest> where I: IntoIterator<Item=DefIdForest>
{ {

View file

@ -51,7 +51,7 @@ mod def_id_forest;
// This code should only compile in modules where the uninhabitedness of Foo is // This code should only compile in modules where the uninhabitedness of Foo is
// visible. // visible.
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Checks whether a type is visibly uninhabited from a particular module. /// Checks whether a type is visibly uninhabited from a particular module.
/// # Example /// # Example
/// ```rust /// ```rust
@ -110,7 +110,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
/// Calculate the forest of DefIds from which this adt is visibly uninhabited. /// Calculate the forest of DefIds from which this adt is visibly uninhabited.
fn uninhabited_from( fn uninhabited_from(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
substs: SubstsRef<'tcx>) -> DefIdForest substs: SubstsRef<'tcx>) -> DefIdForest
{ {
// Non-exhaustive ADTs from other crates are always considered inhabited. // Non-exhaustive ADTs from other crates are always considered inhabited.
@ -128,7 +128,7 @@ impl<'a, 'gcx, 'tcx> VariantDef {
/// Calculate the forest of DefIds from which this variant is visibly uninhabited. /// Calculate the forest of DefIds from which this variant is visibly uninhabited.
pub fn uninhabited_from( pub fn uninhabited_from(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
adt_kind: AdtKind) -> DefIdForest adt_kind: AdtKind) -> DefIdForest
{ {
@ -154,7 +154,7 @@ impl<'a, 'gcx, 'tcx> FieldDef {
/// Calculate the forest of DefIds from which this field is visibly uninhabited. /// Calculate the forest of DefIds from which this field is visibly uninhabited.
fn uninhabited_from( fn uninhabited_from(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
is_enum: bool, is_enum: bool,
) -> DefIdForest { ) -> DefIdForest {
@ -182,7 +182,7 @@ impl<'a, 'gcx, 'tcx> FieldDef {
impl<'a, 'gcx, 'tcx> TyS<'tcx> { impl<'a, 'gcx, 'tcx> TyS<'tcx> {
/// Calculate the forest of DefIds from which this type is visibly uninhabited. /// Calculate the forest of DefIds from which this type is visibly uninhabited.
fn uninhabited_from(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest fn uninhabited_from(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> DefIdForest
{ {
match self.sty { match self.sty {
Adt(def, substs) => def.uninhabited_from(tcx, substs), Adt(def, substs) => def.uninhabited_from(tcx, substs),

View file

@ -44,7 +44,7 @@ pub enum InstanceDef<'tcx> {
impl<'a, 'tcx> Instance<'tcx> { impl<'a, 'tcx> Instance<'tcx> {
pub fn ty(&self, pub fn ty(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>) tcx: TyCtxt<'tcx, 'tcx, 'tcx>)
-> Ty<'tcx> -> Ty<'tcx>
{ {
let ty = tcx.type_of(self.def.def_id()); let ty = tcx.type_of(self.def.def_id());
@ -55,7 +55,7 @@ impl<'a, 'tcx> Instance<'tcx> {
) )
} }
fn fn_sig_noadjust(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> PolyFnSig<'tcx> { fn fn_sig_noadjust(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> PolyFnSig<'tcx> {
let ty = self.ty(tcx); let ty = self.ty(tcx);
match ty.sty { match ty.sty {
ty::FnDef(..) | ty::FnDef(..) |
@ -105,7 +105,7 @@ impl<'a, 'tcx> Instance<'tcx> {
} }
} }
pub fn fn_sig(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> { pub fn fn_sig(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
let mut fn_sig = self.fn_sig_noadjust(tcx); let mut fn_sig = self.fn_sig_noadjust(tcx);
if let InstanceDef::VtableShim(..) = self.def { if let InstanceDef::VtableShim(..) = self.def {
// Modify fn(self, ...) to fn(self: *mut Self, ...) // Modify fn(self, ...) to fn(self: *mut Self, ...)
@ -136,13 +136,13 @@ impl<'tcx> InstanceDef<'tcx> {
} }
#[inline] #[inline]
pub fn attrs<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::Attributes<'tcx> { pub fn attrs<'a>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> ty::Attributes<'tcx> {
tcx.get_attrs(self.def_id()) tcx.get_attrs(self.def_id())
} }
pub fn is_inline<'a>( pub fn is_inline<'a>(
&self, &self,
tcx: TyCtxt<'a, 'tcx, 'tcx> tcx: TyCtxt<'tcx, 'tcx, 'tcx>
) -> bool { ) -> bool {
use crate::hir::map::DefPathData; use crate::hir::map::DefPathData;
let def_id = match *self { let def_id = match *self {
@ -158,7 +158,7 @@ impl<'tcx> InstanceDef<'tcx> {
pub fn requires_local<'a>( pub fn requires_local<'a>(
&self, &self,
tcx: TyCtxt<'a, 'tcx, 'tcx> tcx: TyCtxt<'tcx, 'tcx, 'tcx>
) -> bool { ) -> bool {
if self.is_inline(tcx) { if self.is_inline(tcx) {
return true return true
@ -218,7 +218,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
Instance { def: InstanceDef::Item(def_id), substs: substs } Instance { def: InstanceDef::Item(def_id), substs: substs }
} }
pub fn mono(tcx: TyCtxt<'a, 'tcx, 'b>, def_id: DefId) -> Instance<'tcx> { pub fn mono(tcx: TyCtxt<'b, 'tcx, 'b>, def_id: DefId) -> Instance<'tcx> {
Instance::new(def_id, tcx.global_tcx().empty_substs_for_def_id(def_id)) Instance::new(def_id, tcx.global_tcx().empty_substs_for_def_id(def_id))
} }
@ -245,7 +245,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
/// Presuming that coherence and type-check have succeeded, if this method is invoked /// Presuming that coherence and type-check have succeeded, if this method is invoked
/// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return /// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return
/// `Some`. /// `Some`.
pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn resolve(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def_id: DefId, def_id: DefId,
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> { substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
@ -297,7 +297,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
result result
} }
pub fn resolve_for_vtable(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn resolve_for_vtable(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def_id: DefId, def_id: DefId,
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> { substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
@ -317,7 +317,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
} }
pub fn resolve_closure( pub fn resolve_closure(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
def_id: DefId, def_id: DefId,
substs: ty::ClosureSubsts<'tcx>, substs: ty::ClosureSubsts<'tcx>,
requested_kind: ty::ClosureKind) requested_kind: ty::ClosureKind)
@ -332,7 +332,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
} }
pub fn resolve_drop_in_place( pub fn resolve_drop_in_place(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
ty: Ty<'tcx>) ty: Ty<'tcx>)
-> ty::Instance<'tcx> -> ty::Instance<'tcx>
{ {
@ -342,7 +342,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
} }
pub fn fn_once_adapter_instance( pub fn fn_once_adapter_instance(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
closure_did: DefId, closure_did: DefId,
substs: ty::ClosureSubsts<'tcx>) substs: ty::ClosureSubsts<'tcx>)
-> Instance<'tcx> -> Instance<'tcx>
@ -377,7 +377,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
} }
fn resolve_associated_item<'a, 'tcx>( fn resolve_associated_item<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
trait_item: &ty::AssocItem, trait_item: &ty::AssocItem,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
trait_id: DefId, trait_id: DefId,

View file

@ -31,9 +31,9 @@ use rustc_target::abi::call::{
pub trait IntegerExt { pub trait IntegerExt {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx>; fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx>;
fn from_attr<C: HasDataLayout>(cx: &C, ity: attr::IntType) -> Integer; fn from_attr<C: HasDataLayout>(cx: &C, ity: attr::IntType) -> Integer;
fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
repr: &ReprOptions, repr: &ReprOptions,
min: i128, min: i128,
@ -42,7 +42,7 @@ pub trait IntegerExt {
} }
impl IntegerExt for Integer { impl IntegerExt for Integer {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx> { fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx> {
match (*self, signed) { match (*self, signed) {
(I8, false) => tcx.types.u8, (I8, false) => tcx.types.u8,
(I16, false) => tcx.types.u16, (I16, false) => tcx.types.u16,
@ -77,7 +77,7 @@ impl IntegerExt for Integer {
/// signed discriminant range and #[repr] attribute. /// signed discriminant range and #[repr] attribute.
/// N.B.: u128 values above i128::MAX will be treated as signed, but /// N.B.: u128 values above i128::MAX will be treated as signed, but
/// that shouldn't affect anything, other than maybe debuginfo. /// that shouldn't affect anything, other than maybe debuginfo.
fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
repr: &ReprOptions, repr: &ReprOptions,
min: i128, min: i128,
@ -126,11 +126,11 @@ impl IntegerExt for Integer {
} }
pub trait PrimitiveExt { pub trait PrimitiveExt {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx>; fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Ty<'tcx>;
} }
impl PrimitiveExt for Primitive { impl PrimitiveExt for Primitive {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> { fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Ty<'tcx> {
match *self { match *self {
Int(i, signed) => i.to_ty(tcx, signed), Int(i, signed) => i.to_ty(tcx, signed),
Float(FloatTy::F32) => tcx.types.f32, Float(FloatTy::F32) => tcx.types.f32,
@ -171,7 +171,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
} }
} }
fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> Result<&'tcx LayoutDetails, LayoutError<'tcx>> -> Result<&'tcx LayoutDetails, LayoutError<'tcx>>
{ {
@ -226,7 +226,7 @@ enum StructKind {
Prefixed(Size, Align), Prefixed(Size, Align),
} }
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx, 'tcx>> {
fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutDetails { fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutDetails {
let dl = self.data_layout(); let dl = self.data_layout();
let b_align = b.value.align(dl); let b_align = b.value.align(dl);
@ -1221,7 +1221,7 @@ enum SavedLocalEligibility {
// Also included in the layout are the upvars and the discriminant. // Also included in the layout are the upvars and the discriminant.
// These are included as fields on the "outer" layout; they are not part // These are included as fields on the "outer" layout; they are not part
// of any variant. // of any variant.
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx, 'tcx>> {
/// Compute the eligibility and assignment of each local. /// Compute the eligibility and assignment of each local.
fn generator_saved_local_eligibility(&self, info: &GeneratorLayout<'tcx>) fn generator_saved_local_eligibility(&self, info: &GeneratorLayout<'tcx>)
-> (BitSet<GeneratorSavedLocal>, IndexVec<GeneratorSavedLocal, SavedLocalEligibility>) { -> (BitSet<GeneratorSavedLocal>, IndexVec<GeneratorSavedLocal, SavedLocalEligibility>) {
@ -1442,9 +1442,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
debug!("generator layout ({:?}): {:#?}", ty, layout); debug!("generator layout ({:?}): {:#?}", ty, layout);
Ok(layout) Ok(layout)
} }
}
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
/// This is invoked by the `layout_raw` query to record the final /// This is invoked by the `layout_raw` query to record the final
/// layout of each type. /// layout of each type.
#[inline(always)] #[inline(always)]
@ -1607,7 +1605,7 @@ pub enum SizeSkeleton<'tcx> {
impl<'a, 'tcx> SizeSkeleton<'tcx> { impl<'a, 'tcx> SizeSkeleton<'tcx> {
pub fn compute(ty: Ty<'tcx>, pub fn compute(ty: Ty<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>) param_env: ty::ParamEnv<'tcx>)
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> { -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
debug_assert!(!ty.has_infer_types()); debug_assert!(!ty.has_infer_types());
@ -1729,21 +1727,21 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
} }
pub trait HasTyCtxt<'tcx>: HasDataLayout { pub trait HasTyCtxt<'tcx>: HasDataLayout {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>; fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx, 'tcx>;
} }
pub trait HasParamEnv<'tcx> { pub trait HasParamEnv<'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx>; fn param_env(&self) -> ty::ParamEnv<'tcx>;
} }
impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'tcx, 'gcx, 'tcx> {
fn data_layout(&self) -> &TargetDataLayout { fn data_layout(&self) -> &TargetDataLayout {
&self.data_layout &self.data_layout
} }
} }
impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'tcx, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> { fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'gcx, 'gcx> {
self.global_tcx() self.global_tcx()
} }
} }
@ -1761,7 +1759,7 @@ impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> {
} }
impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> { impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> { fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'gcx, 'gcx> {
self.tcx.tcx() self.tcx.tcx()
} }
} }
@ -1798,7 +1796,7 @@ impl<T, E> MaybeResult<T> for Result<T, E> {
pub type TyLayout<'tcx> = ::rustc_target::abi::TyLayout<'tcx, Ty<'tcx>>; pub type TyLayout<'tcx> = ::rustc_target::abi::TyLayout<'tcx, Ty<'tcx>>;
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx, 'tcx, 'tcx>> {
type Ty = Ty<'tcx>; type Ty = Ty<'tcx>;
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>; type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
@ -1825,7 +1823,7 @@ impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
} }
} }
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'a, 'tcx, 'tcx>> { impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx, 'tcx>> {
type Ty = Ty<'tcx>; type Ty = Ty<'tcx>;
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>; type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
@ -1857,7 +1855,7 @@ impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'a, 'tcx, 'tcx>>
} }
// Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users. // Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users.
impl TyCtxt<'a, 'tcx, '_> { impl TyCtxt<'_, 'tcx, '_> {
/// Computes the layout of a type. Note that this implicitly /// Computes the layout of a type. Note that this implicitly
/// executes in "reveal all" mode. /// executes in "reveal all" mode.
#[inline] #[inline]
@ -1871,7 +1869,7 @@ impl TyCtxt<'a, 'tcx, '_> {
} }
} }
impl ty::query::TyCtxtAt<'a, 'tcx, '_> { impl ty::query::TyCtxtAt<'tcx, '_> {
/// Computes the layout of a type. Note that this implicitly /// Computes the layout of a type. Note that this implicitly
/// executes in "reveal all" mode. /// executes in "reveal all" mode.
#[inline] #[inline]
@ -2191,7 +2189,7 @@ struct Niche {
impl Niche { impl Niche {
fn reserve<'a, 'tcx>( fn reserve<'a, 'tcx>(
&self, &self,
cx: &LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>>, cx: &LayoutCx<'tcx, TyCtxt<'tcx, 'tcx, 'tcx>>,
count: u128, count: u128,
) -> Option<(u128, Scalar)> { ) -> Option<(u128, Scalar)> {
if count > self.available { if count > self.available {
@ -2207,7 +2205,7 @@ impl Niche {
} }
} }
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx, 'tcx>> {
/// Find the offset of a niche leaf field, starting from /// Find the offset of a niche leaf field, starting from
/// the given type and recursing through aggregates. /// the given type and recursing through aggregates.
// FIXME(eddyb) traverse already optimized enums. // FIXME(eddyb) traverse already optimized enums.

View file

@ -213,7 +213,7 @@ impl AssocItem {
} }
} }
pub fn signature<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String { pub fn signature<'a, 'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> String {
match self.kind { match self.kind {
ty::AssocKind::Method => { ty::AssocKind::Method => {
// We skip the binder here because the binder would deanonymize all // We skip the binder here because the binder would deanonymize all
@ -259,7 +259,7 @@ pub trait DefIdTree: Copy {
} }
} }
impl<'a, 'gcx, 'tcx> DefIdTree for TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> DefIdTree for TyCtxt<'tcx, 'gcx, 'tcx> {
fn parent(self, id: DefId) -> Option<DefId> { fn parent(self, id: DefId) -> Option<DefId> {
self.def_key(id).parent.map(|index| DefId { index: index, ..id }) self.def_key(id).parent.map(|index| DefId { index: index, ..id })
} }
@ -934,7 +934,7 @@ impl<'a, 'gcx, 'tcx> Generics {
own_counts own_counts
} }
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool { pub fn requires_monomorphization(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> bool {
if self.own_requires_monomorphization() { if self.own_requires_monomorphization() {
return true; return true;
} }
@ -959,7 +959,7 @@ impl<'a, 'gcx, 'tcx> Generics {
pub fn region_param(&'tcx self, pub fn region_param(&'tcx self,
param: &EarlyBoundRegion, param: &EarlyBoundRegion,
tcx: TyCtxt<'a, 'gcx, 'tcx>) tcx: TyCtxt<'tcx, 'gcx, 'tcx>)
-> &'tcx GenericParamDef -> &'tcx GenericParamDef
{ {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) { if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
@ -977,7 +977,7 @@ impl<'a, 'gcx, 'tcx> Generics {
/// Returns the `GenericParamDef` associated with this `ParamTy`. /// Returns the `GenericParamDef` associated with this `ParamTy`.
pub fn type_param(&'tcx self, pub fn type_param(&'tcx self,
param: &ParamTy, param: &ParamTy,
tcx: TyCtxt<'a, 'gcx, 'tcx>) tcx: TyCtxt<'tcx, 'gcx, 'tcx>)
-> &'tcx GenericParamDef { -> &'tcx GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) { if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize]; let param = &self.params[index as usize];
@ -994,7 +994,7 @@ impl<'a, 'gcx, 'tcx> Generics {
/// Returns the `ConstParameterDef` associated with this `ParamConst`. /// Returns the `ConstParameterDef` associated with this `ParamConst`.
pub fn const_param(&'tcx self, pub fn const_param(&'tcx self,
param: &ParamConst, param: &ParamConst,
tcx: TyCtxt<'a, 'gcx, 'tcx>) tcx: TyCtxt<'tcx, 'gcx, 'tcx>)
-> &GenericParamDef { -> &GenericParamDef {
if let Some(index) = param.index.checked_sub(self.parent_count as u32) { if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize]; let param = &self.params[index as usize];
@ -1020,21 +1020,21 @@ impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {} impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> { impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> {
pub fn instantiate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: SubstsRef<'tcx>) pub fn instantiate(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>, substs: SubstsRef<'tcx>)
-> InstantiatedPredicates<'tcx> { -> InstantiatedPredicates<'tcx> {
let mut instantiated = InstantiatedPredicates::empty(); let mut instantiated = InstantiatedPredicates::empty();
self.instantiate_into(tcx, &mut instantiated, substs); self.instantiate_into(tcx, &mut instantiated, substs);
instantiated instantiated
} }
pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: SubstsRef<'tcx>) pub fn instantiate_own(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>, substs: SubstsRef<'tcx>)
-> InstantiatedPredicates<'tcx> { -> InstantiatedPredicates<'tcx> {
InstantiatedPredicates { InstantiatedPredicates {
predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(), predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
} }
} }
fn instantiate_into(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, fn instantiate_into(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
instantiated: &mut InstantiatedPredicates<'tcx>, instantiated: &mut InstantiatedPredicates<'tcx>,
substs: SubstsRef<'tcx>) { substs: SubstsRef<'tcx>) {
if let Some(def_id) = self.parent { if let Some(def_id) = self.parent {
@ -1045,14 +1045,14 @@ impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> {
); );
} }
pub fn instantiate_identity(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) pub fn instantiate_identity(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>)
-> InstantiatedPredicates<'tcx> { -> InstantiatedPredicates<'tcx> {
let mut instantiated = InstantiatedPredicates::empty(); let mut instantiated = InstantiatedPredicates::empty();
self.instantiate_identity_into(tcx, &mut instantiated); self.instantiate_identity_into(tcx, &mut instantiated);
instantiated instantiated
} }
fn instantiate_identity_into(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, fn instantiate_identity_into(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
instantiated: &mut InstantiatedPredicates<'tcx>) { instantiated: &mut InstantiatedPredicates<'tcx>) {
if let Some(def_id) = self.parent { if let Some(def_id) = self.parent {
tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated); tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated);
@ -1060,7 +1060,7 @@ impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> {
instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p)) instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p))
} }
pub fn instantiate_supertrait(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn instantiate_supertrait(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
poly_trait_ref: &ty::PolyTraitRef<'tcx>) poly_trait_ref: &ty::PolyTraitRef<'tcx>)
-> InstantiatedPredicates<'tcx> -> InstantiatedPredicates<'tcx>
{ {
@ -1134,7 +1134,7 @@ impl<'a, 'gcx, 'tcx> Predicate<'tcx> {
/// poly-trait-ref holds. This is slightly different from a normal /// poly-trait-ref holds. This is slightly different from a normal
/// substitution in terms of what happens with bound regions. See /// substitution in terms of what happens with bound regions. See
/// lengthy comment below for details. /// lengthy comment below for details.
pub fn subst_supertrait(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, pub fn subst_supertrait(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
trait_ref: &ty::PolyTraitRef<'tcx>) trait_ref: &ty::PolyTraitRef<'tcx>)
-> ty::Predicate<'tcx> -> ty::Predicate<'tcx>
{ {
@ -1856,7 +1856,7 @@ impl<'a, 'gcx, 'tcx> VariantDef {
/// If someone speeds up attribute loading to not be a performance concern, they can /// If someone speeds up attribute loading to not be a performance concern, they can
/// remove this hack and use the constructor `DefId` everywhere. /// remove this hack and use the constructor `DefId` everywhere.
pub fn new( pub fn new(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
ident: Ident, ident: Ident,
variant_did: Option<DefId>, variant_did: Option<DefId>,
ctor_def_id: Option<DefId>, ctor_def_id: Option<DefId>,
@ -2143,7 +2143,7 @@ impl ReprOptions {
} }
impl<'a, 'gcx, 'tcx> AdtDef { impl<'gcx, 'tcx> AdtDef {
/// Creates a new `AdtDef`. /// Creates a new `AdtDef`.
fn new( fn new(
tcx: TyCtxt<'_, '_, '_>, tcx: TyCtxt<'_, '_, '_>,
@ -2286,7 +2286,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
} }
/// Returns `true` if this type has a destructor. /// Returns `true` if this type has a destructor.
pub fn has_dtor(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool { pub fn has_dtor(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> bool {
self.destructor(tcx).is_some() self.destructor(tcx).is_some()
} }
@ -2297,7 +2297,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
} }
#[inline] #[inline]
pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> &'tcx GenericPredicates<'gcx> { pub fn predicates(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> &'tcx GenericPredicates<'gcx> {
tcx.predicates_of(self.did) tcx.predicates_of(self.did)
} }
@ -2351,7 +2351,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
#[inline] #[inline]
pub fn eval_explicit_discr( pub fn eval_explicit_discr(
&self, &self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
expr_did: DefId, expr_did: DefId,
) -> Option<Discr<'tcx>> { ) -> Option<Discr<'tcx>> {
let param_env = ParamEnv::empty(); let param_env = ParamEnv::empty();
@ -2397,9 +2397,9 @@ impl<'a, 'gcx, 'tcx> AdtDef {
#[inline] #[inline]
pub fn discriminants( pub fn discriminants(
&'a self, &'tcx self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'gcx> + 'a { ) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'gcx> {
let repr_type = self.repr.discr_type(); let repr_type = self.repr.discr_type();
let initial = repr_type.initial_discriminant(tcx.global_tcx()); let initial = repr_type.initial_discriminant(tcx.global_tcx());
let mut prev_discr = None::<Discr<'tcx>>; let mut prev_discr = None::<Discr<'tcx>>;
@ -2428,7 +2428,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
/// assuming there are no constant-evaluation errors there. /// assuming there are no constant-evaluation errors there.
#[inline] #[inline]
pub fn discriminant_for_variant(&self, pub fn discriminant_for_variant(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
variant_index: VariantIdx) variant_index: VariantIdx)
-> Discr<'tcx> { -> Discr<'tcx> {
let (val, offset) = self.discriminant_def_for_variant(variant_index); let (val, offset) = self.discriminant_def_for_variant(variant_index);
@ -2465,7 +2465,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
(expr_did, variant_index.as_u32() - explicit_index) (expr_did, variant_index.as_u32() - explicit_index)
} }
pub fn destructor(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Destructor> { pub fn destructor(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Option<Destructor> {
tcx.adt_destructor(self.did) tcx.adt_destructor(self.did)
} }
@ -2479,12 +2479,12 @@ impl<'a, 'gcx, 'tcx> AdtDef {
/// ///
/// Due to normalization being eager, this applies even if /// Due to normalization being eager, this applies even if
/// the associated type is behind a pointer (e.g., issue #31299). /// the associated type is behind a pointer (e.g., issue #31299).
pub fn sized_constraint(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> &'tcx [Ty<'tcx>] { pub fn sized_constraint(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> &'tcx [Ty<'tcx>] {
tcx.adt_sized_constraint(self.did).0 tcx.adt_sized_constraint(self.did).0
} }
fn sized_constraint_for_ty(&self, fn sized_constraint_for_ty(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
ty: Ty<'tcx>) ty: Ty<'tcx>)
-> Vec<Ty<'tcx>> { -> Vec<Ty<'tcx>> {
let result = match ty.sty { let result = match ty.sty {
@ -2564,7 +2564,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
} }
impl<'a, 'gcx, 'tcx> FieldDef { impl<'a, 'gcx, 'tcx> FieldDef {
pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> { pub fn ty(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> {
tcx.type_of(self.did).subst(tcx, subst) tcx.type_of(self.did).subst(tcx, subst)
} }
} }
@ -2590,7 +2590,7 @@ impl<'a, 'tcx> ClosureKind {
// This is the initial value used when doing upvar inference. // This is the initial value used when doing upvar inference.
pub const LATTICE_BOTTOM: ClosureKind = ClosureKind::Fn; pub const LATTICE_BOTTOM: ClosureKind = ClosureKind::Fn;
pub fn trait_did(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> DefId { pub fn trait_did(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> DefId {
match *self { match *self {
ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem), ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem),
ClosureKind::FnMut => { ClosureKind::FnMut => {
@ -2618,7 +2618,7 @@ impl<'a, 'tcx> ClosureKind {
/// Returns the representative scalar type for this closure kind. /// Returns the representative scalar type for this closure kind.
/// See `TyS::to_opt_closure_kind` for more details. /// 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, '_, 'tcx>) -> Ty<'tcx> {
match self { match self {
ty::ClosureKind::Fn => tcx.types.i8, ty::ClosureKind::Fn => tcx.types.i8,
ty::ClosureKind::FnMut => tcx.types.i16, ty::ClosureKind::FnMut => tcx.types.i16,
@ -2755,7 +2755,7 @@ pub enum ImplOverlapKind {
Issue33140 Issue33140
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> { pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> {
self.typeck_tables_of(self.hir().body_owner_def_id(body)) self.typeck_tables_of(self.hir().body_owner_def_id(body))
} }
@ -2765,7 +2765,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// themselves, you can do `self.hir().krate().body_ids.iter()`. /// themselves, you can do `self.hir().krate().body_ids.iter()`.
pub fn body_owners( pub fn body_owners(
self, self,
) -> impl Iterator<Item = DefId> + Captures<'tcx> + Captures<'gcx> + 'a { ) -> impl Iterator<Item = DefId> + Captures<'gcx> + 'tcx {
self.hir().krate() self.hir().krate()
.body_ids .body_ids
.iter() .iter()
@ -2892,7 +2892,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn associated_items( pub fn associated_items(
self, self,
def_id: DefId, def_id: DefId,
) -> AssocItemsIterator<'a, 'gcx, 'tcx> { ) -> AssocItemsIterator<'gcx, 'tcx> {
// Ideally, we would use `-> impl Iterator` here, but it falls // Ideally, we would use `-> impl Iterator` here, but it falls
// afoul of the conservative "capture [restrictions]" we put // afoul of the conservative "capture [restrictions]" we put
// in place, so we use a hand-written iterator. // in place, so we use a hand-written iterator.
@ -3115,13 +3115,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
} }
pub struct AssocItemsIterator<'a, 'gcx: 'tcx, 'tcx: 'a> { pub struct AssocItemsIterator<'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
def_ids: &'gcx [DefId], def_ids: &'gcx [DefId],
next_index: usize, next_index: usize,
} }
impl Iterator for AssocItemsIterator<'_, '_, '_> { impl Iterator for AssocItemsIterator<'_, '_> {
type Item = AssocItem; type Item = AssocItem;
fn next(&mut self) -> Option<AssocItem> { fn next(&mut self) -> Option<AssocItem> {
@ -3131,7 +3131,7 @@ impl Iterator for AssocItemsIterator<'_, '_, '_> {
} }
} }
fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssocItem { fn associated_item<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId) -> AssocItem {
let id = tcx.hir().as_local_hir_id(def_id).unwrap(); let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let parent_id = tcx.hir().get_parent_item(id); let parent_id = tcx.hir().get_parent_item(id);
let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id); let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id);
@ -3176,7 +3176,7 @@ pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]);
/// such. /// such.
/// - a Error, if a type contained itself. The representability /// - a Error, if a type contained itself. The representability
/// check should catch this case. /// check should catch this case.
fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
def_id: DefId) def_id: DefId)
-> AdtSizedConstraint<'tcx> { -> AdtSizedConstraint<'tcx> {
let def = tcx.adt_def(def_id); let def = tcx.adt_def(def_id);
@ -3192,7 +3192,7 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
AdtSizedConstraint(result) AdtSizedConstraint(result)
} }
fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
def_id: DefId) def_id: DefId)
-> &'tcx [DefId] { -> &'tcx [DefId] {
let id = tcx.hir().as_local_hir_id(def_id).unwrap(); let id = tcx.hir().as_local_hir_id(def_id).unwrap();
@ -3217,14 +3217,14 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
} }
fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { fn def_span<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId) -> Span {
tcx.hir().span_if_local(def_id).unwrap() tcx.hir().span_if_local(def_id).unwrap()
} }
/// If the given `DefId` describes an item belonging to a trait, /// If the given `DefId` describes an item belonging to a trait,
/// returns the `DefId` of the trait that the trait item belongs to; /// returns the `DefId` of the trait that the trait item belongs to;
/// otherwise, returns `None`. /// otherwise, returns `None`.
fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> { fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> {
tcx.opt_associated_item(def_id) tcx.opt_associated_item(def_id)
.and_then(|associated_item| { .and_then(|associated_item| {
match associated_item.container { match associated_item.container {
@ -3247,7 +3247,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<DefI
} }
/// See `ParamEnv` struct definition for details. /// See `ParamEnv` struct definition for details.
fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn param_env<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
def_id: DefId) def_id: DefId)
-> ParamEnv<'tcx> -> ParamEnv<'tcx>
{ {
@ -3285,26 +3285,26 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause) traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
} }
fn crate_disambiguator<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn crate_disambiguator<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
crate_num: CrateNum) -> CrateDisambiguator { crate_num: CrateNum) -> CrateDisambiguator {
assert_eq!(crate_num, LOCAL_CRATE); assert_eq!(crate_num, LOCAL_CRATE);
tcx.sess.local_crate_disambiguator() tcx.sess.local_crate_disambiguator()
} }
fn original_crate_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn original_crate_name<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
crate_num: CrateNum) -> Symbol { crate_num: CrateNum) -> Symbol {
assert_eq!(crate_num, LOCAL_CRATE); assert_eq!(crate_num, LOCAL_CRATE);
tcx.crate_name.clone() tcx.crate_name.clone()
} }
fn crate_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn crate_hash<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
crate_num: CrateNum) crate_num: CrateNum)
-> Svh { -> Svh {
assert_eq!(crate_num, LOCAL_CRATE); assert_eq!(crate_num, LOCAL_CRATE);
tcx.hir().crate_hash tcx.hir().crate_hash
} }
fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
instance_def: InstanceDef<'tcx>) instance_def: InstanceDef<'tcx>)
-> usize { -> usize {
match instance_def { match instance_def {
@ -3321,7 +3321,7 @@ fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`. /// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
/// ///
/// See [`ImplOverlapKind::Issue33140`] for more details. /// See [`ImplOverlapKind::Issue33140`] for more details.
fn issue33140_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn issue33140_self_ty<'a, 'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
def_id: DefId) def_id: DefId)
-> Option<Ty<'tcx>> -> Option<Ty<'tcx>>
{ {

View file

@ -45,7 +45,7 @@ pub enum Component<'tcx> {
EscapingProjection(Vec<Component<'tcx>>), EscapingProjection(Vec<Component<'tcx>>),
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'tcx, 'gcx, 'tcx> {
/// Push onto `out` all the things that must outlive `'a` for the condition /// 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**. /// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
pub fn push_outlives_components(&self, ty0: Ty<'tcx>, pub fn push_outlives_components(&self, ty0: Ty<'tcx>,

View file

@ -37,7 +37,7 @@ pub trait Printer<'gcx: 'tcx, 'tcx>: Sized {
type DynExistential; type DynExistential;
type Const; type Const;
fn tcx(&'a self) -> TyCtxt<'a, 'gcx, 'tcx>; fn tcx(&'a self) -> TyCtxt<'tcx, 'gcx, 'tcx>;
fn print_def_path( fn print_def_path(
self, self,

Some files were not shown because too many files have changed in this diff Show more