Skip to content

Commit

Permalink
rustc: replace TyCtxt<'tcx, 'gcx, 'tcx> with TyCtxt<'gcx, 'tcx>.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 12, 2019
1 parent 2441253 commit 17cdd35
Show file tree
Hide file tree
Showing 295 changed files with 1,433 additions and 1,433 deletions.
4 changes: 2 additions & 2 deletions src/librustc/cfg/construct.rs
Expand Up @@ -8,7 +8,7 @@ use crate::hir::{self, PatKind};
use crate::hir::def_id::DefId;

struct CFGBuilder<'a, 'tcx: 'a> {
tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
owner_def_id: DefId,
tables: &'a ty::TypeckTables<'tcx>,
graph: CFGGraph,
Expand All @@ -30,7 +30,7 @@ struct LoopScope {
break_index: CFGIndex, // where to go on a `break`
}

pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
body: &hir::Body) -> CFG {
let mut graph = graph::Graph::new();
let entry = graph.add_node(CFGNodeData::Entry);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/cfg/graphviz.rs
Expand Up @@ -12,7 +12,7 @@ pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
pub type Edge<'a> = &'a cfg::CFGEdge;

pub struct LabelledCFG<'a, 'tcx: 'a> {
pub tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
pub tcx: TyCtxt<'tcx, 'tcx>,
pub cfg: &'a cfg::CFG,
pub name: String,
/// `labelled_edges` controls whether we emit labels on the edges
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/cfg/mod.rs
Expand Up @@ -49,7 +49,7 @@ pub type CFGNode = graph::Node<CFGNodeData>;
pub type CFGEdge = graph::Edge<CFGEdgeData>;

impl CFG {
pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
body: &hir::Body) -> CFG {
construct::construct(tcx, body)
}
Expand Down
40 changes: 20 additions & 20 deletions src/librustc/dep_graph/dep_node.rs
Expand Up @@ -204,7 +204,7 @@ macro_rules! define_dep_nodes {
impl DepNode {
#[allow(unreachable_code, non_snake_case)]
#[inline(always)]
pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
dep: DepConstructor<'gcx>)
-> DepNode
where 'gcx: 'a + 'tcx,
Expand Down Expand Up @@ -307,7 +307,7 @@ macro_rules! define_dep_nodes {
/// refers to something from the previous compilation session that
/// has been removed.
#[inline]
pub fn extract_def_id(&self, tcx: TyCtxt<'_, '_, '_>) -> Option<DefId> {
pub fn extract_def_id(&self, tcx: TyCtxt<'_, '_>) -> Option<DefId> {
if self.kind.can_reconstruct_query_key() {
let def_path_hash = DefPathHash(self.hash);
tcx.def_path_hash_to_def_id.as_ref()?
Expand Down Expand Up @@ -400,7 +400,7 @@ impl DefPathHash {

impl DefId {
#[inline(always)]
pub fn to_dep_node(self, tcx: TyCtxt<'_, '_, '_>, kind: DepKind) -> DepNode {
pub fn to_dep_node(self, tcx: TyCtxt<'_, '_>, kind: DepKind) -> DepNode {
DepNode::from_def_path_hash(kind, tcx.def_path_hash(self))
}
}
Expand Down Expand Up @@ -442,23 +442,23 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
]);

pub trait RecoverKey<'tcx>: Sized {
fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>;
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>;
}

impl RecoverKey<'tcx> for CrateNum {
fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.krate)
}
}

impl RecoverKey<'tcx> for DefId {
fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx)
}
}

impl RecoverKey<'tcx> for DefIndex {
fn recover(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.index)
}
}
Expand All @@ -470,11 +470,11 @@ trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug {
/// Fingerprint to be used in DepNode.
/// Not all DepNodeParams support being turned into a Fingerprint (they
/// don't need to if the corresponding DepNode is anonymous).
fn to_fingerprint(&self, _: TyCtxt<'tcx, 'gcx, 'tcx>) -> Fingerprint {
fn to_fingerprint(&self, _: TyCtxt<'gcx, 'tcx>) -> Fingerprint {
panic!("Not implemented. Accidentally called on anonymous node?")
}

fn to_debug_str(&self, _: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String {
format!("{:?}", self)
}
}
Expand All @@ -484,7 +484,7 @@ impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
{
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;

default fn to_fingerprint(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> Fingerprint {
default fn to_fingerprint(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Fingerprint {
let mut hcx = tcx.create_stable_hashing_context();
let mut hasher = StableHasher::new();

Expand All @@ -493,47 +493,47 @@ impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
hasher.finish()
}

default fn to_debug_str(&self, _: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
default fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String {
format!("{:?}", *self)
}
}

impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefId {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;

fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint {
tcx.def_path_hash(*self).0
}

fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
tcx.def_path_str(*self)
}
}

impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefIndex {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;

fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint {
tcx.hir().definitions().def_path_hash(*self).0
}

fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
tcx.def_path_str(DefId::local(*self))
}
}

impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for CrateNum {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;

fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint {
let def_id = DefId {
krate: *self,
index: CRATE_DEF_INDEX,
};
tcx.def_path_hash(def_id).0
}

fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
tcx.crate_name(*self).as_str().to_string()
}
}
Expand All @@ -544,7 +544,7 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) {
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint {
let (def_id_0, def_id_1) = *self;

let def_path_hash_0 = tcx.def_path_hash(def_id_0);
Expand All @@ -553,7 +553,7 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) {
def_path_hash_0.0.combine(def_path_hash_1.0)
}

fn to_debug_str(&self, tcx: TyCtxt<'tcx, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
let (def_id_0, def_id_1) = *self;

format!("({}, {})",
Expand All @@ -568,7 +568,7 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for HirId {
// We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state.
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint {
let HirId {
owner,
local_id,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/dep_graph/graph.rs
Expand Up @@ -558,7 +558,7 @@ impl DepGraph {
/// a node index can be found for that node.
pub fn try_mark_green_and_read(
&self,
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
dep_node: &DepNode
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
self.try_mark_green(tcx, dep_node).map(|(prev_index, dep_node_index)| {
Expand All @@ -570,7 +570,7 @@ impl DepGraph {

pub fn try_mark_green(
&self,
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
dep_node: &DepNode
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
debug_assert!(!dep_node.kind.is_eval_always());
Expand Down Expand Up @@ -604,7 +604,7 @@ impl DepGraph {
/// Try to mark a dep-node which existed in the previous compilation session as green.
fn try_mark_previous_green<'tcx>(
&self,
tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
data: &DepGraphData,
prev_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode
Expand Down Expand Up @@ -791,7 +791,7 @@ impl DepGraph {
#[inline(never)]
fn emit_diagnostics<'tcx>(
&self,
tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
data: &DepGraphData,
dep_node_index: DepNodeIndex,
did_allocation: bool,
Expand Down Expand Up @@ -842,7 +842,7 @@ impl DepGraph {
//
// This method will only load queries that will end up in the disk cache.
// Other queries will not be executed.
pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) {
pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) {
let green_nodes: Vec<DepNode> = {
let data = self.data.as_ref().unwrap();
data.colors.values.indices().filter_map(|prev_index| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/safe.rs
Expand Up @@ -33,7 +33,7 @@ impl DepGraphSafe for DefId {

/// The type context itself can be used to access all kinds of tracked
/// state, but those accesses should always generate read events.
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'tcx, 'gcx, 'tcx> {
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {
}

/// Tuples make it easy to build up state.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/check_attr.rs
Expand Up @@ -88,7 +88,7 @@ impl Target {
}

struct CheckAttrVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
}

impl CheckAttrVisitor<'tcx> {
Expand Down Expand Up @@ -347,7 +347,7 @@ fn is_c_like_enum(item: &hir::Item) -> bool {
}
}

fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx, 'tcx, 'tcx>, module_def_id: DefId) {
fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut CheckAttrVisitor { tcx }.as_deep_visitor()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/def_id.rs
Expand Up @@ -177,7 +177,7 @@ impl DefId {
LocalDefId::from_def_id(self)
}

pub fn describe_as_module(&self, tcx: TyCtxt<'_, '_, '_>) -> String {
pub fn describe_as_module(&self, tcx: TyCtxt<'_, '_>) -> String {
if self.is_local() && self.index == CRATE_DEF_INDEX {
format!("top-level module")
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/upvars.rs
Expand Up @@ -55,7 +55,7 @@ impl Visitor<'tcx> for LocalCollector {
}

struct CaptureCollector<'a, 'tcx> {
tcx: TyCtxt<'tcx, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
locals: &'a FxHashSet<HirId>,
upvars: FxIndexMap<HirId, hir::Upvar>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/hcx.rs
Expand Up @@ -205,7 +205,7 @@ for &'b mut T {
}
}

impl StableHashingContextProvider<'lcx> for TyCtxt<'lcx, 'gcx, 'lcx> {
impl StableHashingContextProvider<'lcx> for TyCtxt<'gcx, 'lcx> {
fn get_stable_hashing_context(&self) -> StableHashingContext<'lcx> {
(*self).create_stable_hashing_context()
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/canonical/canonicalizer.rs
Expand Up @@ -277,7 +277,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {

struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>,
tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
variables: SmallVec<[CanonicalVarInfo; 8]>,
query_state: &'cx mut OriginalQueryValues<'tcx>,
// Note that indices is only used once `var_values` is big enough to be
Expand All @@ -290,7 +290,7 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
}

impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}

Expand Down Expand Up @@ -501,7 +501,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
fn canonicalize<V>(
value: &V,
infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>,
tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
canonicalize_region_mode: &dyn CanonicalizeRegionMode,
query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonicalized<'gcx, V>
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/mod.rs
Expand Up @@ -478,7 +478,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
/// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]`
/// we'll return a substitution `subst` with:
/// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`.
pub fn make_identity(&self, tcx: TyCtxt<'tcx, 'tcx, 'tcx>) -> Self {
pub fn make_identity(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Self {
use crate::ty::subst::UnpackedKind;

CanonicalVarValues {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/query_response.rs
Expand Up @@ -647,7 +647,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
/// Given the region obligations and constraints scraped from the infcx,
/// creates query region constraints.
pub fn make_query_outlives<'tcx>(
tcx: TyCtxt<'tcx, '_, 'tcx>,
tcx: TyCtxt<'_, 'tcx>,
outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>)>,
region_constraints: &RegionConstraintData<'tcx>,
) -> Vec<QueryRegionConstraint<'tcx>> {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/canonical/substitute.rs
Expand Up @@ -16,7 +16,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
/// with the value given in `var_values`.
pub fn substitute(
&self,
tcx: TyCtxt<'tcx, '_, 'tcx>,
tcx: TyCtxt<'_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>,
) -> V
where
Expand All @@ -33,7 +33,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
/// V, replacing each of the canonical variables.
pub fn substitute_projected<T>(
&self,
tcx: TyCtxt<'tcx, '_, 'tcx>,
tcx: TyCtxt<'_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> &T,
) -> T
Expand All @@ -50,7 +50,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
/// must be values for the set of canonical variables that appear in
/// `value`.
pub(super) fn substitute_value<'a, 'tcx, T>(
tcx: TyCtxt<'tcx, '_, 'tcx>,
tcx: TyCtxt<'_, 'tcx>,
var_values: &CanonicalVarValues<'tcx>,
value: &'a T,
) -> T
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/combine.rs
Expand Up @@ -207,7 +207,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
}

impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}

Expand Down Expand Up @@ -414,7 +414,7 @@ struct Generalization<'tcx> {
}

impl TypeRelation<'gcx, 'tcx> for Generalizer<'_, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/equate.rs
Expand Up @@ -27,7 +27,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Equate<'combine, 'infcx, 'gcx, 'tcx> {
impl TypeRelation<'gcx, 'tcx> for Equate<'combine, 'infcx, 'gcx, 'tcx> {
fn tag(&self) -> &'static str { "Equate" }

fn tcx(&self) -> TyCtxt<'tcx, 'gcx, 'tcx> { self.fields.tcx() }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() }

fn a_is_expected(&self) -> bool { self.a_is_expected }

Expand Down

0 comments on commit 17cdd35

Please sign in to comment.