Auto merge of #61722 - eddyb:vowel-exclusion-zone, r=oli-obk

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

This first lifetime parameter of `TyCtxt` has been phantom for a while, thanks to @Zoxc, but was never removed, and I'm doing this now in preparation for removing the `'gcx`/`'tcx` split.

I wasn't going to do this as a separate step, and instead start converting uses of `TyCtxt` to a single-lifetime alias of it (e.g. `type TyCx<'tcx> = TyCtxt<'tcx, 'tcx, 'tcx>;`) but it turns out (as @Zoxc rightly predicted) that there is far more fallout from not needing a lifetime for the first parameter of `TyCtxt`.

That is, going from `TyCtxt<'a, 'gcx, 'tcx>` to `TyCtxt<'tcx, 'gcx, 'tcx>` (the first commit in this PR) has the largest amount of fallout out of all the changes we might make (because it can require removing the `'a` parameter of `struct`s containing `tcx: TyCtxt<'a, ...>`), and is the hardest to automate (because `'a` is used everywhere, not just with `TyCtxt`, unlike, say `'gcx, 'tcx` -> `'tcx`).

So I'm submitting this now to get it out of the way and reduce further friction in the future.

**EDIT**: for the `rustfmt` commit, I used https://github.com/rust-lang/rustfmt/issues/1324#issuecomment-482109952, and manually filtered out some noise, like in #61735, but unlike that PR, there was also a weird bug to work around.
It should be reviewed separately, and dropped if unwanted.

cc @rust-lang/compiler r? @nikomatsakis
This commit is contained in:
bors 2019-06-12 13:41:43 +00:00
commit 24ddd16154
317 changed files with 3873 additions and 3828 deletions

View File

@ -8,7 +8,7 @@ use crate::hir::{self, PatKind};
use crate::hir::def_id::DefId;
struct CFGBuilder<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
owner_def_id: DefId,
tables: &'a ty::TypeckTables<'tcx>,
graph: CFGGraph,
@ -30,8 +30,7 @@ struct LoopScope {
break_index: CFGIndex, // where to go on a `break`
}
pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
body: &hir::Body) -> CFG {
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);

View File

@ -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<'a, '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

View File

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

View File

@ -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<'a, 'gcx, 'tcx>,
pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
dep: DepConstructor<'gcx>)
-> DepNode
where 'gcx: 'a + 'tcx,
@ -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()?
@ -400,7 +400,7 @@ impl DefPathHash {
impl DefId {
#[inline(always)]
pub fn to_dep_node(self, tcx: TyCtxt<'_, '_, '_>, kind: DepKind) -> DepNode {
pub fn to_dep_node(self, tcx: TyCtxt<'_, '_>, kind: DepKind) -> DepNode {
DepNode::from_def_path_hash(kind, tcx.def_path_hash(self))
}
}
@ -442,49 +442,50 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
]);
pub trait RecoverKey<'tcx>: Sized {
fn recover(tcx: TyCtxt<'_, 'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>;
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>;
}
impl RecoverKey<'tcx> for CrateNum {
fn recover(tcx: TyCtxt<'_, '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>, 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>, 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)
}
}
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug {
const CAN_RECONSTRUCT_QUERY_KEY: bool;
/// This method turns the parameters of a DepNodeConstructor into an opaque
/// Fingerprint to be used in DepNode.
/// Not all DepNodeParams support being turned into a Fingerprint (they
/// don't need to if the corresponding DepNode is anonymous).
fn to_fingerprint(&self, _: TyCtxt<'a, '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<'a, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String {
format!("{:?}", self)
}
}
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T
where T: HashStable<StableHashingContext<'a>> + fmt::Debug
impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
where
T: HashStable<StableHashingContext<'tcx>> + fmt::Debug,
{
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<'gcx, 'tcx>) -> Fingerprint {
let mut hcx = tcx.create_stable_hashing_context();
let mut hasher = StableHasher::new();
@ -493,39 +494,39 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T
hasher.finish()
}
default fn to_debug_str(&self, _: TyCtxt<'a, 'gcx, 'tcx>) -> String {
default fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String {
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;
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<'a, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
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;
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<'a, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
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;
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint {
let def_id = DefId {
krate: *self,
index: CRATE_DEF_INDEX,
@ -533,18 +534,18 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for CrateNum {
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<'gcx, 'tcx>) -> 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;
// 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);
@ -553,7 +554,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)
}
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String {
let (def_id_0, def_id_1) = *self;
format!("({}, {})",
@ -562,13 +563,13 @@ 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;
// 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,

View File

@ -90,7 +90,6 @@ where
}
impl DepGraph {
pub fn new(prev_graph: PreviousDepGraph,
prev_work_products: FxHashMap<WorkProductId, WorkProduct>) -> DepGraph {
let prev_graph_node_count = prev_graph.node_count();
@ -558,8 +557,8 @@ impl DepGraph {
/// a node index can be found for that node.
pub fn try_mark_green_and_read(
&self,
tcx: TyCtxt<'_, '_, '_>,
dep_node: &DepNode
tcx: TyCtxt<'_, '_>,
dep_node: &DepNode,
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
self.try_mark_green(tcx, dep_node).map(|(prev_index, dep_node_index)| {
debug_assert!(self.is_green(&dep_node));
@ -570,8 +569,8 @@ impl DepGraph {
pub fn try_mark_green(
&self,
tcx: TyCtxt<'_, '_, '_>,
dep_node: &DepNode
tcx: TyCtxt<'_, '_>,
dep_node: &DepNode,
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
debug_assert!(!dep_node.kind.is_eval_always());
@ -604,10 +603,10 @@ impl DepGraph {
/// Try to mark a dep-node which existed in the previous compilation session as green.
fn try_mark_previous_green<'tcx>(
&self,
tcx: TyCtxt<'_, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
data: &DepGraphData,
prev_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode
dep_node: &DepNode,
) -> Option<DepNodeIndex> {
debug!("try_mark_previous_green({:?}) - BEGIN", dep_node);
@ -791,7 +790,7 @@ impl DepGraph {
#[inline(never)]
fn emit_diagnostics<'tcx>(
&self,
tcx: TyCtxt<'_, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
data: &DepGraphData,
dep_node_index: DepNodeIndex,
did_allocation: bool,
@ -842,7 +841,7 @@ impl DepGraph {
//
// This method will only load queries that will end up in the disk cache.
// Other queries will not be executed.
pub fn exec_cache_promotions<'a, 'tcx>(&self, tcx: TyCtxt<'a, '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| {

View File

@ -33,8 +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<'a, 'gcx, 'tcx> DepGraphSafe for TyCtxt<'a, 'gcx, 'tcx> {
}
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {}
/// Tuples make it easy to build up state.
impl<A, B> DepGraphSafe for (A, B)

View File

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

View File

@ -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 {

View File

@ -55,7 +55,7 @@ impl Visitor<'tcx> for LocalCollector {
}
struct CaptureCollector<'a, 'tcx> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
locals: &'a FxHashSet<HirId>,
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> {
fn get_stable_hashing_context(&self) -> StableHashingContext<'a> {
impl StableHashingContextProvider<'lcx> for TyCtxt<'gcx, 'lcx> {
fn get_stable_hashing_context(&self) -> StableHashingContext<'lcx> {
(*self).create_stable_hashing_context()
}
}

View File

@ -277,7 +277,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>,
tcx: TyCtxt<'cx, '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
@ -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<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
@ -501,7 +501,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
fn canonicalize<V>(
value: &V,
infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>,
tcx: TyCtxt<'_, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
canonicalize_region_mode: &dyn CanonicalizeRegionMode,
query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonicalized<'gcx, V>

View File

@ -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<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
pub fn make_identity(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Self {
use crate::ty::subst::UnpackedKind;
CanonicalVarValues {

View File

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

View File

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

View File

@ -58,12 +58,14 @@ pub enum RelationDir {
}
impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
pub fn super_combine_tys<R>(&self,
relation: &mut R,
a: Ty<'tcx>,
b: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
where R: TypeRelation<'infcx, 'gcx, 'tcx>
pub fn super_combine_tys<R>(
&self,
relation: &mut R,
a: Ty<'tcx>,
b: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>>
where
R: TypeRelation<'gcx, 'tcx>,
{
let a_is_expected = relation.a_is_expected();
@ -123,7 +125,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
b: &'tcx ty::Const<'tcx>,
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
where
R: TypeRelation<'infcx, 'gcx, 'tcx>,
R: TypeRelation<'gcx, 'tcx>,
{
let a_is_expected = relation.a_is_expected();
@ -207,7 +209,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
}
impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}
@ -413,8 +415,8 @@ struct Generalization<'tcx> {
needs_wf: bool,
}
impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> {
impl TypeRelation<'gcx, 'tcx> for Generalizer<'_, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, '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>
for 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<'infcx, 'gcx, 'tcx> { self.fields.tcx() }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() }
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;
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
pub fn note_and_explain_region(
self,
region_scope_tree: &region::ScopeTree,
@ -445,13 +445,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
use ty::print::Printer;
use ty::subst::Kind;
struct AbsolutePathPrinter<'a, 'gcx, 'tcx> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
struct AbsolutePathPrinter<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
}
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 Path = Vec<String>;
@ -460,7 +460,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
type DynExistential = !;
type Const = !;
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'gcx, '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
// where that lifetime appears. This allows us to highlight the
// specific part of the type in the error message.
struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
struct FindNestedTypeVisitor<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
// The bound_region corresponding to the Refree(freeregion)
// associated with the anonymous region we are looking for.
bound_region: ty::BoundRegion,
@ -92,7 +92,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
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> {
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
// where that lifetime appears. This allows us to highlight the
// specific part of the type in the error message.
struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
struct TyPathVisitor<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
found_it: bool,
bound_region: ty::BoundRegion,
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> {
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 }
}
fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, '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.
#[derive(Copy, Clone)]
struct Highlighted<'a, 'gcx, 'tcx, T> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
struct Highlighted<'gcx, 'tcx, T> {
tcx: TyCtxt<'gcx, 'tcx>,
highlight: RegionHighlightMode,
value: T,
}
impl<'a, 'gcx, 'tcx, T> Highlighted<'a, 'gcx, 'tcx, T> {
fn map<U>(self, f: impl FnOnce(T) -> U) -> Highlighted<'a, 'gcx, 'tcx, U> {
impl<'gcx, 'tcx, T> Highlighted<'gcx, 'tcx, T> {
fn map<U>(self, f: impl FnOnce(T) -> U) -> Highlighted<'gcx, 'tcx, U> {
Highlighted {
tcx: self.tcx,
highlight: self.highlight,
@ -337,8 +337,11 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
}
}
impl<'a, 'gcx, 'tcx, T> fmt::Display for Highlighted<'a, 'gcx, 'tcx, T>
where T: for<'b, 'c> Print<'gcx, 'tcx,
impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T>
where
T: for<'a, 'b, 'c> Print<
'gcx,
'tcx,
FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>,
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> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, '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> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, '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>
for Glb<'combine, 'infcx, 'gcx, 'tcx>
{
impl TypeRelation<'gcx, 'tcx> for Glb<'combine, 'infcx, 'gcx, 'tcx> {
fn tag(&self) -> &'static str { "Glb" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() }
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::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 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> {
fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, '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
/// empty region. The `expansion` phase will grow this larger.
fn construct_var_data(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> LexicalRegionResolutions<'tcx> {
fn construct_var_data(&self, tcx: TyCtxt<'_, 'tcx>) -> LexicalRegionResolutions<'tcx> {
LexicalRegionResolutions {
error_region: tcx.lifetimes.re_static,
values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars())
@ -785,7 +785,7 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
}
impl<'tcx> LexicalRegionResolutions<'tcx> {
fn normalize<T>(&self, tcx: TyCtxt<'_, '_, 'tcx>, value: T) -> T
fn normalize<T>(&self, tcx: TyCtxt<'_, 'tcx>, value: T) -> T
where
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>
for Lub<'combine, 'infcx, 'gcx, 'tcx>
{
impl TypeRelation<'gcx, 'tcx> for Lub<'combine, 'infcx, 'gcx, 'tcx> {
fn tag(&self) -> &'static str { "Lub" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected }

View File

@ -91,7 +91,7 @@ impl SuppressRegionErrors {
/// Indicates that the MIR borrowck will repeat these region
/// checks, so we should ignore errors if NLL is (unconditionally)
/// enabled.
pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_, '_>) -> Self {
pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_>) -> Self {
match tcx.borrowck_mode() {
// If we're on Migrate mode, report AST region errors
BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false },
@ -102,8 +102,8 @@ impl SuppressRegionErrors {
}
}
pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub struct InferCtxt<'a, 'gcx, 'tcx> {
pub tcx: TyCtxt<'gcx, 'tcx>,
/// During type-checking/inference of a body, `in_progress_tables`
/// 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()`.
/// Necessary because we can't write the following bound:
/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`.
pub struct InferCtxtBuilder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
global_tcx: TyCtxt<'a, 'gcx, 'gcx>,
pub struct InferCtxtBuilder<'gcx, 'tcx> {
global_tcx: TyCtxt<'gcx, 'gcx>,
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> {
pub fn infer_ctxt(self) -> InferCtxtBuilder<'a, 'gcx, 'tcx> {
impl TyCtxt<'gcx, 'gcx> {
pub fn infer_ctxt<'tcx>(self) -> InferCtxtBuilder<'gcx, 'tcx> {
InferCtxtBuilder {
global_tcx: self,
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,
/// will initialize `in_progress_tables` with fresh `TypeckTables`.
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,
span: Span,
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
where
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 {
global_tcx,
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> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}
@ -1624,7 +1624,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx>
}
}
impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {
impl<'gcx, 'tcx> TypeTrace<'tcx> {
pub fn span(&self) -> Span {
self.cause.span
}
@ -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<'gcx, 'tcx>) -> TypeTrace<'tcx> {
TypeTrace {
cause: ObligationCause::dummy(),
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
D: TypeRelatingDelegate<'tcx>,
{
fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}
@ -823,11 +823,11 @@ where
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
D: TypeRelatingDelegate<'tcx>,
{
fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}

View File

@ -552,8 +552,8 @@ impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx>
}
}
struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
struct ReverseMapper<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
/// If errors have already been reported in this fn, we suppress
/// our own errors because they are sometimes derivative.
@ -567,9 +567,9 @@ struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
hidden_ty: Option<Ty<'tcx>>,
}
impl<'cx, 'gcx, 'tcx> ReverseMapper<'cx, 'gcx, 'tcx> {
impl ReverseMapper<'gcx, 'tcx> {
fn new(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
tainted_by_errors: bool,
opaque_type_def_id: DefId,
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> {
fn tcx(&self) -> TyCtxt<'_, 'gcx, 'tcx> {
impl TypeFolder<'gcx, 'tcx> for ReverseMapper<'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
@ -944,7 +944,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
/// and `opaque_hir_id` is the `HirId` of the definition of the existential type `Baz`.
/// For the above example, this function returns `true` for `f1` and `false` for `f2`.
pub fn may_define_existential_type(
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
def_id: DefId,
opaque_hir_id: hir::HirId,
) -> bool {

View File

@ -28,11 +28,12 @@ impl<'tcx> FreeRegionMap<'tcx> {
/// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See
/// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_free_regions<'a, 'gcx>(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
r_a: Region<'tcx>,
r_b: Region<'tcx>)
-> Region<'tcx> {
pub fn lub_free_regions<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
r_a: Region<'tcx>,
r_b: Region<'tcx>,
) -> Region<'tcx> {
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
assert!(is_free(r_a));
assert!(is_free(r_b));
@ -90,7 +91,7 @@ impl_stable_hash_for!(struct FreeRegionMap<'tcx> {
impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> {
type Lifted = FreeRegionMap<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<FreeRegionMap<'tcx>> {
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<FreeRegionMap<'tcx>> {
self.relation.maybe_map(|&fr| tcx.lift(&fr))
.map(|relation| FreeRegionMap { relation })
}

View File

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

View File

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

View File

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

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> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, '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> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, '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> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, '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>
for Sub<'combine, 'infcx, 'gcx, 'tcx>
{
impl TypeRelation<'gcx, 'tcx> for Sub<'combine, 'infcx, 'gcx, 'tcx> {
fn tag(&self) -> &'static str { "Sub" }
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.infcx.tcx }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.infcx.tcx }
fn a_is_expected(&self) -> bool { self.a_is_expected }
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;
pub trait ToType {
fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>;
fn to_type<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>;
}
impl UnifyKey for ty::IntVid {
@ -52,7 +52,7 @@ impl UnifyKey for ty::RegionVid {
}
impl ToType for IntVarValue {
fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
fn to_type<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> {
match *self {
ty::IntType(i) => tcx.mk_mach_int(i),
ty::UintType(i) => tcx.mk_mach_uint(i),
@ -72,7 +72,7 @@ impl UnifyKey for ty::FloatVid {
impl EqUnifyValue for FloatVarValue {}
impl ToType for FloatVarValue {
fn to_type<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
fn to_type<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> {
tcx.mk_mach_float(self.0)
}
}

View File

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

View File

@ -761,14 +761,12 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
return err
}
pub fn maybe_lint_level_root(tcx: TyCtxt<'_, '_, '_>, id: hir::HirId) -> bool {
pub fn maybe_lint_level_root(tcx: TyCtxt<'_, '_>, id: hir::HirId) -> bool {
let attrs = tcx.hir().attrs_by_hir_id(id);
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
}
fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
-> &'tcx LintLevelMap
{
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap {
assert_eq!(cnum, LOCAL_CRATE);
let mut builder = LintLevelMapBuilder {
levels: LintLevelSets::builder(tcx.sess),
@ -787,12 +785,12 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
tcx.arena.alloc(builder.levels.build_map())
}
struct LintLevelMapBuilder<'a, 'tcx: 'a> {
struct LintLevelMapBuilder<'tcx> {
levels: levels::LintLevelsBuilder<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
}
impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
impl LintLevelMapBuilder<'tcx> {
fn with_lint_attrs<F>(&mut self,
id: hir::HirId,
attrs: &[ast::Attribute],
@ -808,7 +806,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> {
intravisit::NestedVisitorMap::All(&self.tcx.hir())
}

View File

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

View File

@ -211,9 +211,7 @@ pub trait CrateStore {
fn crates_untracked(&self) -> Vec<CrateNum>;
// utility functions
fn encode_metadata<'a, 'tcx>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>)
-> EncodedMetadata;
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata;
fn metadata_encoding_version(&self) -> &[u8];
}
@ -228,9 +226,7 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
// In order to get this left-to-right dependency ordering, we perform a
// topological sort of all crates putting the leaves at the right-most
// positions.
pub fn used_crates(tcx: TyCtxt<'_, '_, '_>, prefer: LinkagePreference)
-> Vec<(CrateNum, LibSource)>
{
pub fn used_crates(tcx: TyCtxt<'_, '_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> {
let mut libs = tcx.crates()
.iter()
.cloned()

View File

@ -26,8 +26,7 @@ use syntax_pos;
// explored. For example, if it's a live Node::Item that is a
// function, then we should explore its block to check for codes that
// may need to be marked as live.
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hir_id: hir::HirId) -> bool {
fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool {
match tcx.hir().find_by_hir_id(hir_id) {
Some(Node::Item(..)) |
Some(Node::ImplItem(..)) |
@ -41,7 +40,7 @@ fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct MarkSymbolVisitor<'a, 'tcx: 'a> {
worklist: Vec<hir::HirId>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
live_symbols: FxHashSet<hir::HirId>,
repr_has_repr_c: bool,
@ -302,9 +301,11 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
}
}
fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
id: hir::HirId,
attrs: &[ast::Attribute]) -> bool {
fn has_allow_dead_code_or_lang_attr(
tcx: TyCtxt<'_, '_>,
id: hir::HirId,
attrs: &[ast::Attribute],
) -> bool {
if attr::contains_name(attrs, sym::lang) {
return true;
}
@ -353,7 +354,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
struct LifeSeeder<'k, 'tcx: 'k> {
worklist: Vec<hir::HirId>,
krate: &'k hir::Crate,
tcx: TyCtxt<'k, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
// see `MarkSymbolVisitor::struct_constructors`
struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
}
@ -423,8 +424,8 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
}
}
fn create_and_seed_worklist<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn create_and_seed_worklist<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
access_levels: &privacy::AccessLevels,
krate: &hir::Crate,
) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) {
@ -451,10 +452,11 @@ fn create_and_seed_worklist<'a, 'tcx>(
(life_seeder.worklist, life_seeder.struct_constructors)
}
fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
access_levels: &privacy::AccessLevels,
krate: &hir::Crate)
-> FxHashSet<hir::HirId> {
fn find_live<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
access_levels: &privacy::AccessLevels,
krate: &hir::Crate,
) -> FxHashSet<hir::HirId> {
let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate);
let mut symbol_visitor = MarkSymbolVisitor {
worklist,
@ -471,12 +473,12 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
symbol_visitor.live_symbols
}
struct DeadVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct DeadVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
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 {
let should_warn = match item.node {
hir::ItemKind::Static(..)
@ -554,7 +556,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
/// on inner functions when the outer function is already getting
/// an error. We could do this also by checking the parents, but
@ -660,7 +662,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<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir().krate();
let live_symbols = find_live(tcx, access_levels, krate);

View File

@ -81,7 +81,7 @@ pub enum Linkage {
Dynamic,
}
pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
pub fn calculate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) {
let sess = &tcx.sess;
let fmts = sess.crate_types.borrow().iter().map(|&ty| {
let linkage = calculate_type(tcx, ty);
@ -92,9 +92,7 @@ pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
sess.dependency_formats.set(fmts);
}
fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty: config::CrateType) -> DependencyList {
fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: config::CrateType) -> DependencyList {
let sess = &tcx.sess;
if !sess.opts.output_types.should_codegen() {
@ -242,10 +240,12 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ret
}
fn add_library(tcx: TyCtxt<'_, '_, '_>,
cnum: CrateNum,
link: LinkagePreference,
m: &mut FxHashMap<CrateNum, LinkagePreference>) {
fn add_library(
tcx: TyCtxt<'_, '_>,
cnum: CrateNum,
link: LinkagePreference,
m: &mut FxHashMap<CrateNum, LinkagePreference>,
) {
match m.get(&cnum) {
Some(&link2) => {
// If the linkages differ, then we'd have two copies of the library
@ -267,7 +267,7 @@ fn add_library(tcx: TyCtxt<'_, '_, '_>,
}
}
fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<DependencyList> {
fn attempt_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Option<DependencyList> {
let sess = &tcx.sess;
let crates = cstore::used_crates(tcx, RequireStatic);
if !crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) {
@ -324,7 +324,7 @@ fn activate_injected_dep(injected: Option<CrateNum>,
// After the linkage for a crate has been determined we need to verify that
// there's only going to be one allocator in the output.
fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) {
fn verify_ok<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, list: &[Linkage]) {
let sess = &tcx.sess;
if list.len() == 0 {
return

View File

@ -47,7 +47,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
}
}
fn entry_fn(tcx: TyCtxt<'_, '_, '_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> {
fn entry_fn(tcx: TyCtxt<'_, '_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> {
assert_eq!(cnum, LOCAL_CRATE);
let any_exe = tcx.sess.crate_types.borrow().iter().any(|ty| {
@ -141,7 +141,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
}
fn configure_main(
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
visitor: &EntryContext<'_, '_>,
) -> Option<(DefId, EntryFnType)> {
if let Some((hir_id, _)) = visitor.start_fn {
@ -179,7 +179,7 @@ fn configure_main(
}
}
pub fn find_entry_point(tcx: TyCtxt<'_, '_, '_>) -> Option<(DefId, EntryFnType)> {
pub fn find_entry_point(tcx: TyCtxt<'_, '_>) -> Option<(DefId, EntryFnType)> {
tcx.entry_fn(LOCAL_CRATE)
}

View File

@ -38,9 +38,7 @@ pub enum ExportedSymbol<'tcx> {
}
impl<'tcx> ExportedSymbol<'tcx> {
pub fn symbol_name(&self,
tcx: TyCtxt<'_, 'tcx, '_>)
-> ty::SymbolName {
pub fn symbol_name(&self, tcx: TyCtxt<'tcx, '_>) -> ty::SymbolName {
match *self {
ExportedSymbol::NonGeneric(def_id) => {
tcx.symbol_name(ty::Instance::mono(tcx, def_id))
@ -54,10 +52,11 @@ impl<'tcx> ExportedSymbol<'tcx> {
}
}
pub fn compare_stable(&self,
tcx: TyCtxt<'_, 'tcx, '_>,
other: &ExportedSymbol<'tcx>)
-> cmp::Ordering {
pub fn compare_stable(
&self,
tcx: TyCtxt<'tcx, '_>,
other: &ExportedSymbol<'tcx>,
) -> cmp::Ordering {
match *self {
ExportedSymbol::NonGeneric(self_def_id) => match *other {
ExportedSymbol::NonGeneric(other_def_id) => {
@ -92,7 +91,7 @@ impl<'tcx> ExportedSymbol<'tcx> {
}
}
pub fn metadata_symbol_name(tcx: TyCtxt<'_, '_, '_>) -> String {
pub fn metadata_symbol_name(tcx: TyCtxt<'_, '_>) -> String {
format!("rust_metadata_{}_{}",
tcx.original_crate_name(LOCAL_CRATE),
tcx.crate_disambiguator(LOCAL_CRATE).to_fingerprint().to_hex())

View File

@ -202,7 +202,7 @@ enum OverloadedCallType {
}
impl OverloadedCallType {
fn from_trait_id(tcx: TyCtxt<'_, '_, '_>, trait_id: DefId) -> OverloadedCallType {
fn from_trait_id(tcx: TyCtxt<'_, '_>, trait_id: DefId) -> OverloadedCallType {
for &(maybe_function_trait, overloaded_call_type) in &[
(tcx.lang_items().fn_once_trait(), FnOnceOverloadedCall),
(tcx.lang_items().fn_mut_trait(), FnMutOverloadedCall),
@ -219,7 +219,7 @@ impl OverloadedCallType {
bug!("overloaded call didn't map to known function trait")
}
fn from_method_id(tcx: TyCtxt<'_, '_, '_>, method_id: DefId) -> OverloadedCallType {
fn from_method_id(tcx: TyCtxt<'_, '_>, method_id: DefId) -> OverloadedCallType {
let method = tcx.associated_item(method_id);
OverloadedCallType::from_trait_id(tcx, method.container.id())
}
@ -266,15 +266,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
/// `None` means that rvalues will be given more conservative lifetimes.
///
/// See also `with_infer`, which is used *during* typeck.
pub fn new(delegate: &'a mut (dyn Delegate<'tcx>+'a),
tcx: TyCtxt<'a, 'tcx, 'tcx>,
body_owner: DefId,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
-> Self
{
pub fn new(
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
) -> Self {
ExprUseVisitor {
mc: mc::MemCategorizationContext::new(tcx,
body_owner,
@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_expr(&body.value);
}
fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, '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
/// transition to NLL, it'll all go away anyhow.
pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub tcx: TyCtxt<'gcx, 'tcx>,
/// The context used to fetch the region maps.
pub context: DefId,
@ -30,7 +30,7 @@ pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> {
pub fn new(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
context: DefId,
region_scope_tree: &'a region::ScopeTree,
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;
fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut ItemVisitor { tcx }.as_deep_visitor()
@ -24,21 +24,19 @@ pub fn provide(providers: &mut Providers<'_>) {
};
}
struct ItemVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>
struct ItemVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
}
struct ExprVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct ExprVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
tables: &'tcx ty::TypeckTables<'tcx>,
param_env: ty::ParamEnv<'tcx>,
}
/// If the type is `Option<T>`, it will return `T`, otherwise
/// the type itself. Works on most `Option`-like types.
fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty: Ty<'tcx>)
-> Ty<'tcx> {
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
let (def, substs) = match ty.sty {
ty::Adt(def, substs) => (def, substs),
_ => return ty
@ -66,7 +64,7 @@ fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty
}
impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
impl ExprVisitor<'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
self.tcx.fn_sig(def_id).abi() == RustIntrinsic &&
self.tcx.item_name(def_id) == sym::transmute
@ -131,7 +129,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> {
NestedVisitorMap::None
}
@ -146,7 +144,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> {
NestedVisitorMap::None
}

View File

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

View File

@ -37,13 +37,13 @@ impl LibFeatures {
}
}
pub struct LibFeatureCollector<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub struct LibFeatureCollector<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
lib_features: LibFeatures,
}
impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatureCollector<'a, 'tcx> {
impl LibFeatureCollector<'tcx> {
fn new(tcx: TyCtxt<'tcx, 'tcx>) -> LibFeatureCollector<'tcx> {
LibFeatureCollector {
tcx,
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> {
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<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> LibFeatures {
let mut collector = LibFeatureCollector::new(tcx);
intravisit::walk_crate(&mut collector, tcx.hir().krate());
collector.lib_features

View File

@ -150,7 +150,7 @@ enum LiveNodeKind {
ExitNode
}
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_, '_>) -> String {
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_>) -> String {
let cm = tcx.sess.source_map();
match lnk {
UpvarNode(s) => {
@ -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<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
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 check_mod_liveness<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
fn check_mod_liveness<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut IrMaps::new(tcx, module_def_id).as_deep_visitor(),
@ -256,8 +256,8 @@ enum VarKind {
CleanExit
}
struct IrMaps<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct IrMaps<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
num_live_nodes: usize,
num_vars: usize,
@ -268,8 +268,8 @@ struct IrMaps<'a, 'tcx: 'a> {
lnks: Vec<LiveNodeKind>,
}
impl<'a, 'tcx> IrMaps<'a, 'tcx> {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, body_owner: DefId) -> IrMaps<'a, 'tcx> {
impl IrMaps<'tcx> {
fn new(tcx: TyCtxt<'tcx, 'tcx>, body_owner: DefId) -> IrMaps<'tcx> {
IrMaps {
tcx,
body_owner,
@ -352,12 +352,14 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
}
}
fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
fk: FnKind<'tcx>,
decl: &'tcx hir::FnDecl,
body_id: hir::BodyId,
sp: Span,
id: hir::HirId) {
fn visit_fn<'a, 'tcx: 'a>(
ir: &mut IrMaps<'tcx>,
fk: FnKind<'tcx>,
decl: &'tcx hir::FnDecl,
body_id: hir::BodyId,
sp: Span,
id: hir::HirId,
) {
debug!("visit_fn");
// swap in a new set of IR maps for this function body:
@ -374,7 +376,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);
@ -411,7 +413,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
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<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
// For struct patterns, take note of which fields used shorthand
// (`x` rather than `x: x`).
let mut shorthand_field_ids = HirIdSet::default();
@ -457,19 +459,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<'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local) {
add_from_pat(ir, &local.pat);
intravisit::walk_local(ir, local);
}
fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) {
fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) {
for pat in &arm.pats {
add_from_pat(ir, pat);
}
intravisit::walk_arm(ir, arm);
}
fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) {
match expr.node {
// live nodes required for uses or definitions of variables:
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
@ -681,7 +683,7 @@ const ACC_WRITE: u32 = 2;
const ACC_USE: u32 = 4;
struct Liveness<'a, 'tcx: 'a> {
ir: &'a mut IrMaps<'a, 'tcx>,
ir: &'a mut IrMaps<'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
s: Specials,
successors: Vec<LiveNode>,
@ -695,7 +697,7 @@ struct Liveness<'a, 'tcx: 'a> {
}
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:
// - exit_ln represents the end of the fn, either by return or panic
// - implicit_ret_var is a pseudo-variable that represents

View File

@ -287,8 +287,8 @@ impl HirNode for hir::Pat {
}
#[derive(Clone)]
pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub struct MemCategorizationContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
pub tcx: TyCtxt<'gcx, 'tcx>,
pub body_owner: DefId,
pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
pub region_scope_tree: &'a region::ScopeTree,
@ -339,8 +339,11 @@ impl MutabilityCategory {
ret
}
fn from_local(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>,
id: ast::NodeId) -> MutabilityCategory {
fn from_local(
tcx: TyCtxt<'_, '_>,
tables: &ty::TypeckTables<'_>,
id: ast::NodeId,
) -> MutabilityCategory {
let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node {
PatKind::Binding(..) => {
@ -400,12 +403,13 @@ impl MutabilityCategory {
}
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
body_owner: DefId,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
-> MemCategorizationContext<'a, 'tcx, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx, 'tcx>,
body_owner: DefId,
region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
) -> MemCategorizationContext<'a, 'tcx, 'tcx> {
MemCategorizationContext {
tcx,
body_owner,
@ -1514,7 +1518,7 @@ impl<'tcx> cmt_<'tcx> {
}
}
pub fn descriptive_string(&self, tcx: TyCtxt<'_, '_, '_>) -> Cow<'static, str> {
pub fn descriptive_string(&self, tcx: TyCtxt<'_, '_>) -> Cow<'static, str> {
match self.cat {
Categorization::StaticItem => {
"static item".into()

View File

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

View File

@ -169,7 +169,7 @@ impl Scope {
self.id
}
pub fn node_id(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> ast::NodeId {
pub fn node_id(&self, tcx: TyCtxt<'_, '_>, scope_tree: &ScopeTree) -> ast::NodeId {
match scope_tree.root_body {
Some(hir_id) => {
tcx.hir().hir_to_node_id(hir::HirId {
@ -184,7 +184,7 @@ impl Scope {
/// Returns the span of this `Scope`. Note that in general the
/// returned span may not correspond to the span of any `NodeId` in
/// the AST.
pub fn span(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> Span {
pub fn span(&self, tcx: TyCtxt<'_, '_>, scope_tree: &ScopeTree) -> Span {
let node_id = self.node_id(tcx, scope_tree);
if node_id == ast::DUMMY_NODE_ID {
return DUMMY_SP;
@ -358,8 +358,8 @@ pub struct Context {
parent: Option<(Scope, ScopeDepth)>,
}
struct RegionResolutionVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct RegionResolutionVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
// The number of expressions and patterns visited in the current body
expr_and_pat_count: usize,
@ -646,9 +646,11 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives.
pub fn early_free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
br: &ty::EarlyBoundRegion)
-> Scope {
pub fn early_free_scope<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
br: &ty::EarlyBoundRegion,
) -> Scope {
let param_owner = tcx.parent(br.def_id).unwrap();
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();
@ -677,8 +679,7 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives.
pub fn free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, fr: &ty::FreeRegion)
-> Scope {
pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion) -> Scope {
let param_owner = match fr.bound_region {
ty::BoundRegion::BrNamed(def_id, _) => {
tcx.parent(def_id).unwrap()
@ -734,9 +735,11 @@ impl<'tcx> ScopeTree {
}
/// Records the lifetime of a local variable as `cx.var_parent`
fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_, '_>,
var_id: hir::ItemLocalId,
_sp: Span) {
fn record_var_lifetime(
visitor: &mut RegionResolutionVisitor<'_>,
var_id: hir::ItemLocalId,
_sp: Span,
) {
match visitor.cx.var_parent {
None => {
// this can happen in extern fn declarations like
@ -748,7 +751,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<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx hir::Block) {
debug!("resolve_block(blk.hir_id={:?})", blk.hir_id);
let prev_cx = visitor.cx;
@ -816,7 +819,7 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk:
visitor.cx = prev_cx;
}
fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, arm: &'tcx hir::Arm) {
fn resolve_arm<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, arm: &'tcx hir::Arm) {
let prev_cx = visitor.cx;
visitor.enter_scope(
@ -838,7 +841,7 @@ fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, arm: &
visitor.cx = prev_cx;
}
fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &'tcx hir::Pat) {
fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir::Pat) {
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.
@ -855,7 +858,7 @@ fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, 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<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, stmt: &'tcx hir::Stmt) {
let stmt_id = stmt.hir_id.local_id;
debug!("resolve_stmt(stmt.id={:?})", stmt_id);
@ -874,7 +877,7 @@ fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt:
visitor.cx.parent = prev_parent;
}
fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: &'tcx hir::Expr) {
fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx hir::Expr) {
debug!("resolve_expr - pre-increment {} expr = {:?}", visitor.expr_and_pat_count, expr);
let prev_cx = visitor.cx;
@ -977,9 +980,11 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
visitor.cx = prev_cx;
}
fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
pat: Option<&'tcx hir::Pat>,
init: Option<&'tcx hir::Expr>) {
fn resolve_local<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
pat: Option<&'tcx hir::Pat>,
init: Option<&'tcx hir::Expr>,
) {
debug!("resolve_local(pat={:?}, init={:?})", pat, init);
let blk_scope = visitor.cx.var_parent.map(|(p, _)| p);
@ -1127,11 +1132,11 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
/// | box E&
/// | E& as ...
/// | ( E& )
fn record_rvalue_scope_if_borrow_expr<'a, 'tcx>(
visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
fn record_rvalue_scope_if_borrow_expr<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr,
blk_id: Option<Scope>)
{
blk_id: Option<Scope>,
) {
match expr.node {
hir::ExprKind::AddrOf(_, ref subexpr) => {
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
@ -1178,9 +1183,11 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
/// | <rvalue>
///
/// Note: ET is intended to match "rvalues or places based on rvalues".
fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
expr: &hir::Expr,
blk_scope: Option<Scope>) {
fn record_rvalue_scope<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr,
blk_scope: Option<Scope>,
) {
let mut expr = expr;
loop {
// Note: give all the expressions matching `ET` with the
@ -1205,7 +1212,7 @@ fn resolve_local<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
}
}
impl<'a, 'tcx> RegionResolutionVisitor<'a, 'tcx> {
impl<'tcx> RegionResolutionVisitor<'tcx> {
/// Records the current parent (if any) as the parent of `child_scope`.
/// Returns the depth of `child_scope`.
fn record_child_scope(&mut self, child_scope: Scope) -> ScopeDepth {
@ -1235,7 +1242,7 @@ impl<'a, 'tcx> RegionResolutionVisitor<'a, 'tcx> {
}
}
impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::None
}
@ -1327,9 +1334,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
}
}
fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
-> &'tcx ScopeTree
{
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ScopeTree {
let closure_base_def_id = tcx.closure_base_def_id(def_id);
if closure_base_def_id != def_id {
return tcx.region_scope_tree(closure_base_def_id);

View File

@ -218,7 +218,7 @@ impl_stable_hash_for!(struct crate::middle::resolve_lifetime::ResolveLifetimes {
});
struct LifetimeContext<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
map: &'a mut NamedRegionMap,
scope: ScopeRef<'a>,
@ -368,10 +368,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
/// entire crate. You should not read the result of this query
/// directly, but rather use `named_region_map`, `is_late_bound_map`,
/// etc.
fn resolve_lifetimes<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
for_krate: CrateNum,
) -> &'tcx ResolveLifetimes {
fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes {
assert_eq!(for_krate, LOCAL_CRATE);
let named_region_map = krate(tcx);
@ -398,7 +395,7 @@ fn resolve_lifetimes<'tcx>(
tcx.arena.alloc(rl)
}
fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap {
fn krate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> NamedRegionMap {
let krate = tcx.hir().krate();
let mut map = NamedRegionMap {
defs: Default::default(),
@ -1101,7 +1098,7 @@ impl ShadowKind {
}
}
fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_, '_>, params: &P<[hir::GenericParam]>) {
fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_>, params: &P<[hir::GenericParam]>) {
let lifetime_params: Vec<_> = params
.iter()
.filter_map(|param| match param.kind {
@ -1129,7 +1126,7 @@ fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_, '_>, params: &P<[hi
}
fn signal_shadowing_problem(
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
name: ast::Name,
orig: Original,
shadower: Shadower,
@ -1169,7 +1166,7 @@ fn signal_shadowing_problem(
// if one of the label shadows a lifetime or another label.
fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
struct GatherLabels<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
scope: ScopeRef<'a>,
labels_in_fn: &'a mut Vec<ast::Ident>,
}
@ -1218,7 +1215,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
}
fn check_if_label_shadows_lifetime(
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
mut scope: ScopeRef<'_>,
label: ast::Ident,
) {
@ -1256,9 +1253,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
}
}
fn compute_object_lifetime_defaults(
tcx: TyCtxt<'_, '_, '_>,
) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
fn compute_object_lifetime_defaults(tcx: TyCtxt<'_, '_>) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
let mut map = HirIdMap::default();
for item in tcx.hir().krate().items.values() {
match item.node {
@ -1315,7 +1310,7 @@ fn compute_object_lifetime_defaults(
/// of the form `T:'a` so as to determine the `ObjectLifetimeDefault`
/// for each type parameter.
fn object_lifetime_defaults_for_item(
tcx: TyCtxt<'_, '_, '_>,
tcx: TyCtxt<'_, '_>,
generics: &hir::Generics,
) -> Vec<ObjectLifetimeDefault> {
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound]) {

View File

@ -106,7 +106,7 @@ impl_stable_hash_for!(struct self::Index<'tcx> {
// A private tree-walker for producing an Index.
struct Annotator<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
index: &'a mut Index<'tcx>,
parent_stab: Option<&'tcx Stability>,
parent_depr: Option<DeprecationEntry>,
@ -317,7 +317,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
}
struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
access_levels: &'a AccessLevels,
}
@ -389,8 +389,8 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
}
}
impl<'a, 'tcx> Index<'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Index<'tcx> {
impl<'tcx> Index<'tcx> {
pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Index<'tcx> {
let is_staged_api =
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked ||
tcx.features().staged_api;
@ -452,7 +452,7 @@ impl<'a, 'tcx> Index<'tcx> {
AnnotationKind::Required,
|v| intravisit::walk_crate(v, krate));
}
return index
return index;
}
pub fn local_stability(&self, id: HirId) -> Option<&'tcx Stability> {
@ -466,7 +466,7 @@ impl<'a, 'tcx> Index<'tcx> {
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors.
fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) {
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> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
struct Checker<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
}
/// Result of `TyCtxt::eval_stability`.
@ -521,7 +521,7 @@ pub enum EvalResult {
Unmarked,
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
// See issue #38412.
fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
// Check if `def_id` is a trait method.
@ -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
/// nested items in the context of the outer item, so enable
/// deep-walking.
@ -827,7 +827,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
}
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> {
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
/// were expected to be library features), and the list of features used from
/// libraries, identify activated features that don't exist and error about them.
pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
if tcx.stability().staged_api[&LOCAL_CRATE] {
@ -920,11 +920,11 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
// don't lint about unused features. We should reenable this one day!
}
fn unnecessary_stable_feature_lint<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn unnecessary_stable_feature_lint<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
span: Span,
feature: Symbol,
since: Symbol
since: Symbol,
) {
tcx.lint_hir(lint::builtin::STABLE_FEATURES,
hir::CRATE_HIR_ID,

View File

@ -18,13 +18,13 @@ macro_rules! weak_lang_items {
($($name:ident, $item:ident, $sym:ident;)*) => (
struct Context<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
items: &'a mut lang_items::LanguageItems,
}
/// Checks the crate for usage of weak lang items, returning a vector of all the
/// language items required by this crate, but not defined yet.
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
items: &mut lang_items::LanguageItems) {
// These are never called by user code, they're generated by the compiler.
// They will never implicitly be added to the `missing` array unless we do
@ -60,7 +60,7 @@ pub fn link_name(attrs: &[ast::Attribute]) -> Option<Symbol> {
/// Not all lang items are always required for each compilation, particularly in
/// the case of panic=abort. In these situations some lang items are injected by
/// crates and don't actually need to be defined in libstd.
pub fn whitelisted(tcx: TyCtxt<'_, '_, '_>, lang_item: lang_items::LangItem) -> bool {
pub fn whitelisted(tcx: TyCtxt<'_, '_>, lang_item: lang_items::LangItem) -> bool {
// If we're not compiling with unwinding, we won't actually need these
// symbols. Other panic runtimes ensure that the relevant symbols are
// available to link things together, but they're never exercised.
@ -72,7 +72,7 @@ pub fn whitelisted(tcx: TyCtxt<'_, '_, '_>, lang_item: lang_items::LangItem) ->
false
}
fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn verify<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
items: &lang_items::LanguageItems) {
// We only need to check for the presence of weak lang items if we're
// emitting something that's not an rlib.
@ -142,7 +142,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
}
}
impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> {
impl<'tcx, 'gcx> TyCtxt<'tcx, 'gcx> {
pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool {
let lang_items = self.lang_items();
let did = Some(item_def_id);

View File

@ -74,19 +74,16 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
}
}
impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
pub fn struct_error(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
message: &str)
-> Result<DiagnosticBuilder<'tcx>, ErrorHandled>
{
impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
pub fn struct_error(
&self,
tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
self.struct_generic(tcx, message, None)
}
pub fn report_as_error(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
message: &str
) -> ErrorHandled {
pub fn report_as_error(&self, tcx: TyCtxtAt<'gcx, 'tcx>, message: &str) -> ErrorHandled {
let err = self.struct_error(tcx, message);
match err {
Ok(mut err) => {
@ -97,8 +94,9 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
}
}
pub fn report_as_lint(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
pub fn report_as_lint(
&self,
tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str,
lint_root: hir::HirId,
span: Option<Span>,
@ -131,7 +129,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
fn struct_generic(
&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
tcx: TyCtxtAt<'gcx, 'tcx>,
message: &str,
lint_root: Option<hir::HirId>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
@ -172,10 +170,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
}
}
pub fn struct_error<'a, 'gcx, 'tcx>(
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
msg: &str,
) -> DiagnosticBuilder<'tcx> {
pub fn struct_error<'gcx, 'tcx>(tcx: TyCtxtAt<'gcx, 'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
}

View File

@ -64,12 +64,9 @@ enum AllocDiscriminant {
Static,
}
pub fn specialized_encode_alloc_id<
'a, 'tcx,
E: Encoder,
>(
pub fn specialized_encode_alloc_id<'tcx, E: Encoder>(
encoder: &mut E,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
alloc_id: AllocId,
) -> Result<(), E::Error> {
let alloc: GlobalAlloc<'tcx> =
@ -145,13 +142,10 @@ pub struct AllocDecodingSession<'s> {
}
impl<'s> AllocDecodingSession<'s> {
// Decodes an AllocId in a thread-safe way.
pub fn decode_alloc_id<'a, 'tcx, D>(&self,
decoder: &mut D)
-> Result<AllocId, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_alloc_id<D>(&self, decoder: &mut D) -> Result<AllocId, D::Error>
where
D: TyDecoder<'tcx>,
{
// Read the index of the allocation
let idx = decoder.read_u32()? as usize;

View File

@ -1240,8 +1240,8 @@ impl<'tcx> Terminator<'tcx> {
}
impl<'tcx> TerminatorKind<'tcx> {
pub fn if_<'a, 'gcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub fn if_<'gcx>(
tcx: TyCtxt<'gcx, 'tcx>,
cond: Operand<'tcx>,
t: BasicBlock,
f: BasicBlock,
@ -2323,8 +2323,8 @@ impl<'tcx> Operand<'tcx> {
/// Convenience helper to make a constant that refers to the fn
/// with given `DefId` and substs. Since this is used to synthesize
/// MIR, assumes `user_ty` is None.
pub fn function_handle<'a>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub fn function_handle(
tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>,
span: Span,
@ -3158,7 +3158,7 @@ pub enum ClosureOutlivesSubject<'tcx> {
/*
* TypeFoldable implementations for MIR types
*/
*/
CloneTypeFoldableAndLiftImpls! {
BlockTailInfo,

View File

@ -48,7 +48,7 @@ pub enum MonoItem<'tcx> {
}
impl<'tcx> MonoItem<'tcx> {
pub fn size_estimate<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> usize {
pub fn size_estimate(&self, tcx: TyCtxt<'tcx, 'tcx>) -> usize {
match *self {
MonoItem::Fn(instance) => {
// Estimate the size of a function based on how many statements
@ -72,7 +72,7 @@ impl<'tcx> MonoItem<'tcx> {
}
}
pub fn symbol_name(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> SymbolName {
pub fn symbol_name(&self, tcx: TyCtxt<'tcx, 'tcx>) -> SymbolName {
match *self {
MonoItem::Fn(instance) => tcx.symbol_name(instance),
MonoItem::Static(def_id) => {
@ -87,9 +87,7 @@ impl<'tcx> MonoItem<'tcx> {
}
}
pub fn instantiation_mode(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>)
-> InstantiationMode {
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx, 'tcx>) -> InstantiationMode {
let inline_in_all_cgus =
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| {
tcx.sess.opts.optimize != OptLevel::No
@ -133,7 +131,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>) -> Option<Linkage> {
let def_id = match *self {
MonoItem::Fn(ref instance) => instance.def_id(),
MonoItem::Static(def_id) => def_id,
@ -169,7 +167,7 @@ impl<'tcx> MonoItem<'tcx> {
/// Similarly, if a vtable method has such a signature, and therefore can't
/// be used, we can just not emit it and have a placeholder (a null pointer,
/// which will never be accessed) in its place.
pub fn is_instantiable(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
pub fn is_instantiable(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
debug!("is_instantiable({:?})", self);
let (def_id, substs) = match *self {
MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs),
@ -181,7 +179,7 @@ impl<'tcx> MonoItem<'tcx> {
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>, debug: bool) -> String {
return match *self {
MonoItem::Fn(instance) => {
to_string_internal(tcx, "fn ", instance, debug)
@ -195,11 +193,12 @@ impl<'tcx> MonoItem<'tcx> {
}
};
fn to_string_internal<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
prefix: &str,
instance: Instance<'tcx>,
debug: bool)
-> String {
fn to_string_internal<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
prefix: &str,
instance: Instance<'tcx>,
debug: bool,
) -> String {
let mut result = String::with_capacity(32);
result.push_str(prefix);
let printer = DefPathBasedNames::new(tcx, false, false);
@ -208,7 +207,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>) -> Option<Span> {
match *self {
MonoItem::Fn(Instance { def, .. }) => {
tcx.hir().as_local_hir_id(def.def_id())
@ -334,7 +333,7 @@ impl<'tcx> CodegenUnit<'tcx> {
base_n::encode(hash, base_n::CASE_INSENSITIVE)
}
pub fn estimate_size<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
pub fn estimate_size(&mut self, tcx: TyCtxt<'tcx, 'tcx>) {
// Estimate the size of a codegen unit as (approximately) the number of MIR
// statements it corresponds to.
self.size_estimate = Some(self.items.keys().map(|mi| mi.size_estimate(tcx)).sum());
@ -360,7 +359,7 @@ impl<'tcx> CodegenUnit<'tcx> {
WorkProductId::from_cgu_name(&self.name().as_str())
}
pub fn work_product(&self, tcx: TyCtxt<'_, '_, '_>) -> WorkProduct {
pub fn work_product(&self, tcx: TyCtxt<'_, '_>) -> WorkProduct {
let work_product_id = self.work_product_id();
tcx.dep_graph
.previous_work_product(&work_product_id)
@ -369,17 +368,16 @@ impl<'tcx> CodegenUnit<'tcx> {
})
}
pub fn items_in_deterministic_order<'a>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>)
-> Vec<(MonoItem<'tcx>,
(Linkage, Visibility))> {
pub fn items_in_deterministic_order(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
) -> Vec<(MonoItem<'tcx>, (Linkage, Visibility))> {
// The codegen tests rely on items being process in the same order as
// they appear in the file, so for local items, we sort by node_id first
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct ItemSortKey(Option<HirId>, SymbolName);
fn item_sort_key<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
item: MonoItem<'tcx>) -> ItemSortKey {
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: MonoItem<'tcx>) -> ItemSortKey {
ItemSortKey(match item {
MonoItem::Fn(ref instance) => {
match instance.def {
@ -415,7 +413,7 @@ impl<'tcx> CodegenUnit<'tcx> {
items
}
pub fn codegen_dep_node(&self, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> DepNode {
pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx, 'tcx>) -> DepNode {
DepNode::new(tcx, DepConstructor::CompileCodegenUnit(self.name().clone()))
}
}
@ -445,14 +443,13 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for CodegenUnit<'tcx> {
}
}
pub struct CodegenUnitNameBuilder<'a, 'gcx: 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub struct CodegenUnitNameBuilder<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
cache: FxHashMap<CrateNum, String>,
}
impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
impl CodegenUnitNameBuilder<'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>) -> Self {
CodegenUnitNameBuilder {
tcx,
cache: Default::default(),

View File

@ -21,7 +21,7 @@ pub struct PlaceTy<'tcx> {
#[cfg(target_arch = "x86_64")]
static_assert_size!(PlaceTy<'_>, 16);
impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
impl<'gcx, 'tcx> PlaceTy<'tcx> {
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
PlaceTy { ty, variant_index: None }
}
@ -33,8 +33,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
/// not carry a `Ty` for `T`.)
///
/// Note that the resulting type has not been normalized.
pub fn field_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, f: &Field) -> Ty<'tcx>
{
pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx> {
let answer = match self.ty.sty {
ty::Adt(adt_def, substs) => {
let variant_def = match self.variant_index {
@ -57,10 +56,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
/// Convenience wrapper around `projection_ty_core` for
/// `PlaceElem`, where we can just use the `Ty` that is already
/// stored inline on field projection elems.
pub fn projection_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
elem: &PlaceElem<'tcx>)
-> PlaceTy<'tcx>
{
pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> {
self.projection_ty_core(tcx, elem, |_, _, ty| ty)
}
@ -71,12 +67,13 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
/// (which should be trivial when `T` = `Ty`).
pub fn projection_ty_core<V, T>(
self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
elem: &ProjectionElem<V, T>,
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>)
-> PlaceTy<'tcx>
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>,
) -> PlaceTy<'tcx>
where
V: ::std::fmt::Debug, T: ::std::fmt::Debug
V: ::std::fmt::Debug,
T: ::std::fmt::Debug,
{
let answer = match *elem {
ProjectionElem::Deref => {
@ -121,8 +118,9 @@ BraceStructTypeFoldableImpl! {
}
impl<'tcx> Place<'tcx> {
pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PlaceTy<'tcx>
where D: HasLocalDecls<'tcx>
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> PlaceTy<'tcx>
where
D: HasLocalDecls<'tcx>,
{
match *self {
Place::Base(PlaceBase::Local(index)) =>
@ -141,8 +139,9 @@ pub enum RvalueInitializationState {
}
impl<'tcx> Rvalue<'tcx> {
pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>
where D: HasLocalDecls<'tcx>
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
where
D: HasLocalDecls<'tcx>,
{
match *self {
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
@ -222,8 +221,9 @@ impl<'tcx> Rvalue<'tcx> {
}
impl<'tcx> Operand<'tcx> {
pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>
where D: HasLocalDecls<'tcx>
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
where
D: HasLocalDecls<'tcx>,
{
match self {
&Operand::Copy(ref l) |
@ -234,10 +234,12 @@ impl<'tcx> Operand<'tcx> {
}
impl<'tcx> BinOp {
pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>)
-> Ty<'tcx> {
pub fn ty<'gcx>(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>,
) -> Ty<'tcx> {
// FIXME: handle SIMD correctly
match self {
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |

View File

@ -47,12 +47,12 @@ pub struct AutoTraitInfo<'cx> {
pub vid_to_region: FxHashMap<ty::RegionVid, ty::Region<'cx>>,
}
pub struct AutoTraitFinder<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub struct AutoTraitFinder<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
}
impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
impl<'tcx> AutoTraitFinder<'tcx> {
pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Self {
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.
//
// 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
pub struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'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<'gcx, 'tcx> {
self.tcx
}

View File

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

View File

@ -49,7 +49,7 @@ pub fn add_placeholder_note(err: &mut errors::DiagnosticBuilder<'_>) {
/// with a suitably-freshened `ImplHeader` with those types
/// substituted. Otherwise, invokes `no_overlap`.
pub fn overlapping_impls<'gcx, F1, F2, R>(
tcx: TyCtxt<'_, 'gcx, 'gcx>,
tcx: TyCtxt<'gcx, 'gcx>,
impl1_def_id: DefId,
impl2_def_id: DefId,
intercrate_mode: IntercrateMode,
@ -183,10 +183,10 @@ fn overlap_within_probe(
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
}
pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>)
-> Option<Conflict>
{
pub fn trait_ref_is_knowable<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
) -> Option<Conflict> {
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Remote).is_ok() {
// A downstream or cousin crate is allowed to implement some
@ -229,9 +229,10 @@ 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>,
trait_ref: ty::TraitRef<'tcx>)
-> bool {
pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
) -> bool {
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
}
@ -246,10 +247,10 @@ pub enum OrphanCheckErr<'tcx> {
///
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
/// 2. Some local type must appear in `Self`.
pub fn orphan_check<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
impl_def_id: DefId)
-> Result<(), OrphanCheckErr<'tcx>>
{
pub fn orphan_check<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
) -> Result<(), OrphanCheckErr<'tcx>> {
debug!("orphan_check({:?})", impl_def_id);
// We only except this routine to be invoked on implementations
@ -353,11 +354,11 @@ pub fn orphan_check<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
///
/// Note that this function is never called for types that have both type
/// parameters and inference variables.
fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>,
trait_ref: ty::TraitRef<'tcx>,
in_crate: InCrate)
-> Result<(), OrphanCheckErr<'tcx>>
{
fn orphan_check_trait_ref<'tcx>(
tcx: TyCtxt<'_, '_>,
trait_ref: ty::TraitRef<'tcx>,
in_crate: InCrate,
) -> Result<(), OrphanCheckErr<'tcx>> {
debug!("orphan_check_trait_ref(trait_ref={:?}, in_crate={:?})",
trait_ref, in_crate);
@ -430,8 +431,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>,
}
}
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>, in_crate: InCrate)
-> Vec<Ty<'tcx>> {
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<Ty<'tcx>> {
if ty_is_local_constructor(ty, in_crate) {
vec![]
} else if fundamental_ty(ty) {
@ -450,7 +450,7 @@ fn is_possibly_remote_type(ty: Ty<'_>, _in_crate: InCrate) -> bool {
}
}
fn ty_is_local(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'_>, in_crate: InCrate) -> bool {
fn ty_is_local(tcx: TyCtxt<'_, '_>, ty: Ty<'_>, in_crate: InCrate) -> bool {
ty_is_local_constructor(ty, in_crate) ||
fundamental_ty(ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, in_crate))
}

View File

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

View File

@ -1242,15 +1242,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err
}
fn report_closure_arg_mismatch(&self,
span: Span,
found_span: Option<Span>,
expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>)
-> DiagnosticBuilder<'tcx>
{
fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_ref: &ty::TraitRef<'tcx>) -> String {
fn report_closure_arg_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>,
) -> DiagnosticBuilder<'tcx> {
fn build_fn_sig_string<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: &ty::TraitRef<'tcx>,
) -> String {
let inputs = trait_ref.substs.type_at(1);
let sig = if let ty::Tuple(inputs) = inputs.sty {
tcx.mk_fn_sig(
@ -1294,7 +1296,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
pub fn recursive_type_with_infinite_size_error(self,
type_def_id: DefId)
-> DiagnosticBuilder<'tcx>
@ -1447,17 +1449,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// Returns `true` if the trait predicate may apply for *some* assignment
/// to the type parameters.
fn predicate_can_apply(&self,
param_env: ty::ParamEnv<'tcx>,
pred: ty::PolyTraitRef<'tcx>)
-> bool {
fn predicate_can_apply(
&self,
param_env: ty::ParamEnv<'tcx>,
pred: ty::PolyTraitRef<'tcx>,
) -> bool {
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
var_map: FxHashMap<Ty<'tcx>, Ty<'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<'gcx, 'tcx> { self.infcx.tcx }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Param(ty::ParamTy {name, .. }) = ty.sty {

View File

@ -140,7 +140,7 @@ pub struct ObligationCause<'tcx> {
}
impl<'tcx> ObligationCause<'tcx> {
pub fn span<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Span {
pub fn span<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Span {
match self.code {
ObligationCauseCode::CompareImplMethodObligation { .. } |
ObligationCauseCode::MainFunctionType |
@ -363,9 +363,9 @@ impl<'tcx> DomainGoal<'tcx> {
}
impl<'tcx> GoalKind<'tcx> {
pub fn from_poly_domain_goal<'a, 'gcx>(
pub fn from_poly_domain_goal<'gcx>(
domain_goal: PolyDomainGoal<'tcx>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
) -> GoalKind<'tcx> {
match domain_goal.no_bound_vars() {
Some(p) => p.into_goal(),
@ -710,13 +710,13 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>(
}
}
fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
region_context: DefId,
cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>,
predicates: Vec<ty::Predicate<'tcx>>)
-> Result<Vec<ty::Predicate<'tcx>>, ErrorReported>
{
fn do_normalize_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
region_context: DefId,
cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>,
predicates: Vec<ty::Predicate<'tcx>>,
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorReported> {
debug!(
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
predicates,
@ -795,12 +795,12 @@ fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// FIXME: this is gonna need to be removed ...
/// Normalizes the parameter environment, reporting errors if they occur.
pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
region_context: DefId,
unnormalized_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>)
-> ty::ParamEnv<'tcx>
{
pub fn normalize_param_env_or_error<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
region_context: DefId,
unnormalized_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
) -> ty::ParamEnv<'tcx> {
// I'm not wild about reporting errors here; I'd prefer to
// have the errors get reported at a defined place (e.g.,
// during typeck). Instead I have all parameter
@ -936,10 +936,10 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
/// environment. If this returns false, then either normalize
/// encountered an error or one of the predicates did not hold. Used
/// when creating vtables to check for unsatisfiable methods.
fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
predicates: Vec<ty::Predicate<'tcx>>)
-> bool
{
fn normalize_and_test_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
predicates: Vec<ty::Predicate<'tcx>>,
) -> bool {
debug!("normalize_and_test_predicates(predicates={:?})",
predicates);
@ -965,10 +965,10 @@ fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
result
}
fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
key: (DefId, SubstsRef<'tcx>))
-> bool
{
fn substitute_normalize_and_test_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
key: (DefId, SubstsRef<'tcx>),
) -> bool {
debug!("substitute_normalize_and_test_predicates(key={:?})",
key);
@ -983,11 +983,10 @@ fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
/// Given a trait `trait_ref`, iterates the vtable entries
/// that come from `trait_ref`, including its supertraits.
#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
fn vtable_methods<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
-> &'tcx [Option<(DefId, SubstsRef<'tcx>)>]
{
fn vtable_methods<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
debug!("vtable_methods({:?})", trait_ref);
tcx.arena.alloc_from_iter(
@ -1205,18 +1204,18 @@ where
type LiftedDelayedLiteral: Debug + 'tcx;
type LiftedLiteral: Debug + 'tcx;
fn lift_ex_clause_to_tcx<'a, 'gcx>(
fn lift_ex_clause_to_tcx<'gcx>(
ex_clause: &chalk_engine::ExClause<Self>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
) -> Option<Self::LiftedExClause>;
fn lift_delayed_literal_to_tcx<'a, 'gcx>(
fn lift_delayed_literal_to_tcx<'gcx>(
ex_clause: &chalk_engine::DelayedLiteral<Self>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
) -> Option<Self::LiftedDelayedLiteral>;
fn lift_literal_to_tcx<'a, 'gcx>(
fn lift_literal_to_tcx<'gcx>(
ex_clause: &chalk_engine::Literal<Self>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
) -> Option<Self::LiftedLiteral>;
}

View File

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

View File

@ -35,12 +35,13 @@ impl OnUnimplementedNote {
}
}
fn parse_error(tcx: TyCtxt<'_, '_, '_>, span: Span,
message: &str,
label: &str,
note: Option<&str>)
-> ErrorReported
{
fn parse_error(
tcx: TyCtxt<'_, '_>,
span: Span,
message: &str,
label: &str,
note: Option<&str>,
) -> ErrorReported {
let mut diag = struct_span_err!(
tcx.sess, span, E0232, "{}", message);
diag.span_label(span, label);
@ -51,14 +52,14 @@ fn parse_error(tcx: TyCtxt<'_, '_, '_>, span: Span,
ErrorReported
}
impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
fn parse(tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_def_id: DefId,
items: &[NestedMetaItem],
span: Span,
is_root: bool)
-> Result<Self, ErrorReported>
{
impl<'gcx, 'tcx> OnUnimplementedDirective {
fn parse(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
items: &[NestedMetaItem],
span: Span,
is_root: bool,
) -> Result<Self, ErrorReported> {
let mut errored = false;
let mut item_iter = items.iter();
@ -132,12 +133,11 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
}
}
pub fn of_item(tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_def_id: DefId,
impl_def_id: DefId)
-> Result<Option<Self>, ErrorReported>
{
pub fn of_item(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
impl_def_id: DefId,
) -> Result<Option<Self>, ErrorReported> {
let attrs = tcx.get_attrs(impl_def_id);
let attr = if let Some(item) = attr::find_by_name(&attrs, sym::rustc_on_unimplemented) {
@ -164,12 +164,12 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
result
}
pub fn evaluate(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
options: &[(Symbol, Option<String>)])
-> OnUnimplementedNote
{
pub fn evaluate(
&self,
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
options: &[(Symbol, Option<String>)],
) -> OnUnimplementedNote {
let mut message = None;
let mut label = None;
let mut note = None;
@ -214,13 +214,13 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective {
}
}
impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
fn try_parse(tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_def_id: DefId,
from: LocalInternedString,
err_sp: Span)
-> Result<Self, ErrorReported>
{
impl<'gcx, 'tcx> OnUnimplementedFormatString {
fn try_parse(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
from: LocalInternedString,
err_sp: Span,
) -> Result<Self, ErrorReported> {
let result = OnUnimplementedFormatString(from);
result.verify(tcx, trait_def_id, err_sp)?;
Ok(result)
@ -228,7 +228,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
fn verify(
&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
span: Span,
) -> Result<(), ErrorReported> {
@ -274,7 +274,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
pub fn format(
&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
options: &FxHashMap<Symbol, 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> {
fn tcx<'c>(&'c self) -> TyCtxt<'c, 'gcx, 'tcx> {
fn tcx<'c>(&'c self) -> TyCtxt<'gcx, 'tcx> {
self.selcx.tcx()
}
@ -836,7 +836,7 @@ struct Progress<'tcx> {
}
impl<'tcx> Progress<'tcx> {
fn error<'a,'gcx>(tcx: TyCtxt<'a,'gcx,'tcx>) -> Self {
fn error<'gcx>(tcx: TyCtxt<'gcx, 'tcx>) -> Self {
Progress {
ty: tcx.types.err,
obligations: vec![],

View File

@ -85,12 +85,7 @@ pub struct DropckOutlivesResult<'tcx> {
}
impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn report_overflows(
&self,
tcx: TyCtxt<'_, '_, 'tcx>,
span: Span,
ty: Ty<'tcx>,
) {
pub fn report_overflows(&self, tcx: TyCtxt<'_, 'tcx>, span: Span, ty: Ty<'tcx>) {
if let Some(overflow_ty) = self.overflows.iter().next() {
let mut err = struct_span_err!(
tcx.sess,
@ -106,7 +101,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn into_kinds_reporting_overflows(
self,
tcx: TyCtxt<'_, '_, 'tcx>,
tcx: TyCtxt<'_, 'tcx>,
span: Span,
ty: Ty<'tcx>,
) -> Vec<Kind<'tcx>> {
@ -190,7 +185,7 @@ impl_stable_hash_for!(struct DtorckConstraint<'tcx> {
///
/// Note also that `needs_drop` requires a "global" type (i.e., one
/// with erased regions), but this function does not.
pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty {
// None of these types have a destructor and hence they do not
// require anything in particular to outlive the dtor's

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> {
fn tcx<'c>(&'c self) -> TyCtxt<'c, 'gcx, 'tcx> {
fn tcx<'c>(&'c self) -> TyCtxt<'gcx, 'tcx> {
self.infcx.tcx
}

View File

@ -10,7 +10,7 @@
use crate::ty::{self, Ty, TyCtxt};
use crate::ty::fold::{TypeFoldable, TypeFolder};
impl<'cx, 'tcx> TyCtxt<'cx, 'tcx, 'tcx> {
impl<'tcx> TyCtxt<'tcx, 'tcx> {
/// Erase the regions in `value` and then fully normalize all the
/// 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> {
tcx: TyCtxt<'cx, 'tcx, 'tcx>,
struct NormalizeAfterErasingRegionsFolder<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
}
impl<'cx, 'tcx> TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'cx, 'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
impl TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}

View File

@ -25,14 +25,14 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for AscribeUserType<'tcx>
type QueryResponse = ();
fn try_fast_path(
_tcx: TyCtxt<'_, 'gcx, 'tcx>,
_tcx: TyCtxt<'gcx, 'tcx>,
_key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> {
None
}
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> {
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 = ();
fn try_fast_path(
_tcx: TyCtxt<'_, 'gcx, 'tcx>,
_tcx: TyCtxt<'gcx, 'tcx>,
key: &ParamEnvAnd<'tcx, Eq<'tcx>>,
) -> Option<Self::QueryResponse> {
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(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, ()>> {
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>>;
fn try_fast_path(
_tcx: TyCtxt<'_, 'gcx, 'tcx>,
_tcx: TyCtxt<'gcx, 'tcx>,
_key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> {
None
}
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> {
// 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
/// a final result or `None` to do the full path.
fn try_fast_path(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse>;
@ -64,7 +64,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>:
/// bad, because it would create subregion relationships that are
/// not captured in the return value.
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>>;

View File

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

View File

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

View File

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

View File

@ -109,8 +109,8 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
/// the kind `kind`, and trait method substitutions `substs`, in
/// that impl, a less specialized impl, or the trait default,
/// whichever applies.
pub fn find_associated_item<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub fn find_associated_item<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
item: &ty::AssocItem,
substs: SubstsRef<'tcx>,
@ -149,10 +149,10 @@ pub fn find_associated_item<'a, 'tcx>(
/// 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
/// to.
pub(super) fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
(impl1_def_id, impl2_def_id): (DefId, DefId))
-> bool
{
pub(super) fn specializes<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
(impl1_def_id, impl2_def_id): (DefId, DefId),
) -> bool {
debug!("specializes({:?}, {:?})", impl1_def_id, impl2_def_id);
// The feature gate should prevent introducing new specializations, but not
@ -285,8 +285,8 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
}
// Query provider for `specialization_graph_of`.
pub(super) fn specialization_graph_provider<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub(super) fn specialization_graph_provider<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
trait_id: DefId,
) -> &'tcx specialization_graph::Graph {
let mut sg = specialization_graph::Graph::new();
@ -390,7 +390,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
/// Recovers the "impl X for Y" signature from `impl_def_id` and returns it as a
/// string.
fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<String> {
fn to_pretty_impl_header(tcx: TyCtxt<'_, '_>, impl_def_id: DefId) -> Option<String> {
use std::fmt::Write;
let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) {

View File

@ -81,11 +81,9 @@ enum Inserted {
ShouldRecurseOn(DefId),
}
impl<'a, 'gcx, 'tcx> Children {
impl<'gcx, 'tcx> Children {
/// Insert an impl into this set of children without comparing to any existing impls.
fn insert_blindly(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
impl_def_id: DefId) {
fn insert_blindly(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
debug!("insert_blindly: impl_def_id={:?} sty={:?}", impl_def_id, sty);
@ -99,9 +97,7 @@ impl<'a, 'gcx, 'tcx> Children {
/// Removes an impl from this set of children. Used when replacing
/// an impl with a parent. The impl must be present in the list of
/// children already.
fn remove_existing(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
impl_def_id: DefId) {
fn remove_existing(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
let vec: &mut Vec<DefId>;
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
@ -118,12 +114,12 @@ impl<'a, 'gcx, 'tcx> Children {
/// Attempt to insert an impl into this set of children, while comparing for
/// specialization relationships.
fn insert(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
impl_def_id: DefId,
simplified_self: Option<SimplifiedType>)
-> Result<Inserted, OverlapError>
{
fn insert(
&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
simplified_self: Option<SimplifiedType>,
) -> Result<Inserted, OverlapError> {
let mut last_lint = None;
let mut replace_children = Vec::new();
@ -282,7 +278,7 @@ impl<I, J> Iterator for PotentialSiblings<I, J>
}
}
impl<'a, 'gcx, 'tcx> Graph {
impl<'gcx, 'tcx> Graph {
pub fn new() -> Graph {
Graph {
parent: Default::default(),
@ -293,10 +289,11 @@ impl<'a, 'gcx, 'tcx> Graph {
/// Insert a local impl into the specialization graph. If an existing impl
/// conflicts with it (has overlap, but neither specializes the other),
/// information about the area of overlap is returned in the `Err`.
pub fn insert(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
impl_def_id: DefId)
-> Result<Option<FutureCompatOverlapError>, OverlapError> {
pub fn insert(
&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
impl_def_id: DefId,
) -> Result<Option<FutureCompatOverlapError>, OverlapError> {
assert!(impl_def_id.is_local());
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
@ -386,10 +383,12 @@ impl<'a, 'gcx, 'tcx> Graph {
}
/// Insert cached metadata mapping from a child impl back to its parent.
pub fn record_impl_from_cstore(&mut self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
parent: DefId,
child: DefId) {
pub fn record_impl_from_cstore(
&mut self,
tcx: TyCtxt<'gcx, 'tcx>,
parent: DefId,
child: DefId,
) {
if self.parent.insert(child, parent).is_some() {
bug!("When recording an impl from the crate store, information about its parent \
was already present.");
@ -414,7 +413,7 @@ pub enum Node {
Trait(DefId),
}
impl<'a, 'gcx, 'tcx> Node {
impl<'gcx, 'tcx> Node {
pub fn is_from_trait(&self) -> bool {
match *self {
Node::Trait(..) => true,
@ -423,10 +422,7 @@ impl<'a, 'gcx, 'tcx> Node {
}
/// Iterate over the items defined directly by the given (impl or trait) node.
pub fn items(
&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
) -> ty::AssocItemsIterator<'a, 'gcx, 'tcx> {
pub fn items(&self, tcx: TyCtxt<'gcx, 'tcx>) -> ty::AssocItemsIterator<'gcx, 'tcx> {
tcx.associated_items(self.def_id())
}
@ -475,18 +471,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
/// with the given name and the given kind.
// FIXME(#35870): avoid closures being unexported due to `impl Trait`.
#[inline]
pub fn defs(
self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
trait_item_name: Ident,
trait_item_kind: ty::AssocKind,
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| {
use crate::ty::AssocKind::*;
node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) {
@ -508,10 +504,11 @@ impl<'a, 'gcx, 'tcx> Ancestors<'gcx> {
/// Walk up the specialization ancestors of a given impl, starting with that
/// impl itself.
pub fn ancestors(tcx: TyCtxt<'_, 'tcx, '_>,
trait_def_id: DefId,
start_from_impl: DefId)
-> Ancestors<'tcx> {
pub fn ancestors(
tcx: TyCtxt<'tcx, '_>,
trait_def_id: DefId,
start_from_impl: DefId,
) -> Ancestors<'tcx> {
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
Ancestors {
trait_def_id,

View File

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

View File

@ -12,9 +12,10 @@ use crate::util::nodemap::FxHashSet;
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
pred: &ty::Predicate<'tcx>)
-> ty::Predicate<'tcx> {
fn anonymize_predicate<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
pred: &ty::Predicate<'tcx>,
) -> ty::Predicate<'tcx> {
match *pred {
ty::Predicate::Trait(ref data) =>
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)),
@ -45,13 +46,13 @@ fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
}
}
struct PredicateSet<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
struct PredicateSet<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
set: FxHashSet<ty::Predicate<'tcx>>,
}
impl<'a, 'gcx, 'tcx> PredicateSet<'a, 'gcx, 'tcx> {
fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
impl PredicateSet<'gcx, 'tcx> {
fn new(tcx: TyCtxt<'gcx, 'tcx>) -> Self {
Self { tcx: tcx, set: Default::default() }
}
@ -70,7 +71,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) {
for pred in iter {
self.insert(pred.as_ref());
@ -88,39 +89,36 @@ 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`
/// holds as well. Similarly, if we have `trait Foo: 'static`, and we know that
/// `T: Foo`, then we know that `T: 'static`.
pub struct Elaborator<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
pub struct Elaborator<'gcx, 'tcx> {
stack: Vec<ty::Predicate<'tcx>>,
visited: PredicateSet<'a, 'gcx, 'tcx>,
visited: PredicateSet<'gcx, 'tcx>,
}
pub fn elaborate_trait_ref<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
-> Elaborator<'cx, 'gcx, 'tcx>
{
pub fn elaborate_trait_ref<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> Elaborator<'gcx, 'tcx> {
elaborate_predicates(tcx, vec![trait_ref.to_predicate()])
}
pub fn elaborate_trait_refs<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Elaborator<'cx, 'gcx, 'tcx>
{
pub fn elaborate_trait_refs<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> Elaborator<'gcx, 'tcx> {
let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect();
elaborate_predicates(tcx, predicates)
}
pub fn elaborate_predicates<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
mut predicates: Vec<ty::Predicate<'tcx>>)
-> Elaborator<'cx, 'gcx, 'tcx>
{
pub fn elaborate_predicates<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
mut predicates: Vec<ty::Predicate<'tcx>>,
) -> Elaborator<'gcx, 'tcx> {
let mut visited = PredicateSet::new(tcx);
predicates.retain(|pred| visited.insert(pred));
Elaborator { stack: predicates, visited }
}
impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
impl Elaborator<'gcx, 'tcx> {
pub fn filter_to_traits(self) -> FilterToTraits<Self> {
FilterToTraits::new(self)
}
@ -232,7 +230,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>;
fn size_hint(&self) -> (usize, Option<usize>) {
@ -254,17 +252,19 @@ impl<'cx, 'gcx, 'tcx> Iterator for Elaborator<'cx, 'gcx, 'tcx> {
// 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>,
trait_ref: ty::PolyTraitRef<'tcx>)
-> Supertraits<'cx, 'gcx, 'tcx> {
pub fn supertraits<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> Supertraits<'gcx, 'tcx> {
elaborate_trait_ref(tcx, trait_ref).filter_to_traits()
}
pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Supertraits<'cx, 'gcx, 'tcx> {
pub fn transitive_bounds<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> Supertraits<'gcx, 'tcx> {
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`.
/// Expansion is done via a DFS (depth-first search), and the `visited` field
/// is used to avoid cycles.
pub struct TraitAliasExpander<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub struct TraitAliasExpander<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
stack: Vec<TraitAliasExpansionInfo<'tcx>>,
}
@ -337,10 +337,10 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> {
}
}
pub fn expand_trait_aliases<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>
) -> TraitAliasExpander<'cx, 'gcx, 'tcx> {
pub fn expand_trait_aliases<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>,
) -> TraitAliasExpander<'gcx, 'tcx> {
let items: Vec<_> = trait_refs
.into_iter()
.map(|(trait_ref, span)| TraitAliasExpansionInfo::new(trait_ref, span))
@ -348,7 +348,7 @@ pub fn expand_trait_aliases<'cx, 'gcx, 'tcx>(
TraitAliasExpander { tcx, stack: items }
}
impl<'cx, 'gcx, 'tcx> TraitAliasExpander<'cx, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TraitAliasExpander<'gcx, 'tcx> {
/// If `item` is a trait alias and its predicate has not yet been visited, then expands `item`
/// to the definition, pushes the resulting expansion onto `self.stack`, and returns `false`.
/// Otherwise, immediately returns `true` if `item` is a regular trait, or `false` if it is a
@ -393,7 +393,7 @@ impl<'cx, 'gcx, 'tcx> TraitAliasExpander<'cx, 'gcx, 'tcx> {
}
}
impl<'cx, 'gcx, 'tcx> Iterator for TraitAliasExpander<'cx, 'gcx, 'tcx> {
impl<'gcx, 'tcx> Iterator for TraitAliasExpander<'gcx, 'tcx> {
type Item = TraitAliasExpansionInfo<'tcx>;
fn size_hint(&self) -> (usize, Option<usize>) {
@ -414,16 +414,16 @@ impl<'cx, 'gcx, 'tcx> Iterator for TraitAliasExpander<'cx, 'gcx, 'tcx> {
// Iterator over def-IDs of supertraits
///////////////////////////////////////////////////////////////////////////
pub struct SupertraitDefIds<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub struct SupertraitDefIds<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
stack: Vec<DefId>,
visited: FxHashSet<DefId>,
}
pub fn supertrait_def_ids<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
trait_def_id: DefId)
-> SupertraitDefIds<'cx, 'gcx, 'tcx>
{
pub fn supertrait_def_ids<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
trait_def_id: DefId,
) -> SupertraitDefIds<'gcx, 'tcx> {
SupertraitDefIds {
tcx,
stack: vec![trait_def_id],
@ -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;
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<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
pub fn predicate_for_trait_def(self,
param_env: ty::ParamEnv<'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
/// important thing about the result is Ok/Err. Also, matching never
/// affects any type variables or unification state.
pub struct Match<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>
pub struct Match<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
}
impl<'a, 'gcx, 'tcx> Match<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Match<'a, 'gcx, 'tcx> {
impl Match<'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>) -> Match<'gcx, '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 tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { self.tcx }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
fn a_is_expected(&self) -> bool { true } // irrelevant
fn relate_with_variance<T: Relate<'tcx>>(&mut self,

View File

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

View File

@ -107,9 +107,8 @@ pub fn encode_predicates<'tcx, E, C>(encoder: &mut E,
Ok(())
}
pub trait TyDecoder<'a, 'tcx: 'a>: Decoder {
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
pub trait TyDecoder<'tcx>: Decoder {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx>;
fn peek_byte(&self) -> u8;
@ -132,38 +131,38 @@ pub trait TyDecoder<'a, 'tcx: 'a>: Decoder {
}
#[inline]
pub fn decode_arena_allocable<'a, 'tcx, D, T: ArenaAllocatable + Decodable>(
decoder: &mut D
pub fn decode_arena_allocable<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D,
) -> Result<&'tcx T, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
}
#[inline]
pub fn decode_arena_allocable_slice<'a, 'tcx, D, T: ArenaAllocatable + Decodable>(
decoder: &mut D
pub fn decode_arena_allocable_slice<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D,
) -> Result<&'tcx [T], D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
}
#[inline]
pub fn decode_cnum<'a, 'tcx, D>(decoder: &mut D) -> Result<CrateNum, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
where
D: TyDecoder<'tcx>,
{
let cnum = CrateNum::from_u32(u32::decode(decoder)?);
Ok(decoder.map_encoded_cnum_to_current(cnum))
}
#[inline]
pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
// Handle shorthands first, if we have an usize > 0x80.
if decoder.positioned_at_shorthand() {
@ -181,10 +180,9 @@ pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
}
#[inline]
pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
-> Result<ty::GenericPredicates<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_predicates<D>(decoder: &mut D) -> Result<ty::GenericPredicates<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
Ok(ty::GenericPredicates {
parent: Decodable::decode(decoder)?,
@ -206,9 +204,9 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
}
#[inline]
pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
let tcx = decoder.tcx();
@ -216,38 +214,37 @@ pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D:
}
#[inline]
pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_region<D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
}
#[inline]
pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_ty_slice<D>(decoder: &mut D) -> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
}
#[inline]
pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::AdtDef, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_adt_def<D>(decoder: &mut D) -> Result<&'tcx ty::AdtDef, D::Error>
where
D: TyDecoder<'tcx>,
{
let def_id = DefId::decode(decoder)?;
Ok(decoder.tcx().adt_def(def_id))
}
#[inline]
pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_existential_predicate_slice<D>(
decoder: &mut D,
) -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
Ok(decoder.tcx()
@ -255,10 +252,9 @@ pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
}
#[inline]
pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
-> Result<CanonicalVarInfos<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_canonical_var_infos<D>(decoder: &mut D) -> Result<CanonicalVarInfos<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
let len = decoder.read_usize()?;
let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder))
@ -268,19 +264,17 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
}
#[inline]
pub fn decode_const<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::Const<'tcx>, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_const<D>(decoder: &mut D) -> Result<&'tcx ty::Const<'tcx>, D::Error>
where
D: TyDecoder<'tcx>,
{
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
}
#[inline]
pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx Allocation, D::Error>
where D: TyDecoder<'a, 'tcx>,
'tcx: 'a,
pub fn decode_allocation<D>(decoder: &mut D) -> Result<&'tcx Allocation, D::Error>
where
D: TyDecoder<'tcx>,
{
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 syntax::attr;
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
impl<'tcx> TyCtxt<'tcx, 'tcx> {
/// Whether the `def_id` counts as const fn in your current crate, considering all active
/// feature gates
pub fn is_const_fn(self, def_id: DefId) -> bool {
@ -69,7 +69,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
/// 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<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
let hir_id = tcx.hir().as_local_hir_id(def_id)
.expect("Non-local call to local provider is_const_fn");
@ -83,7 +83,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
}
}
fn is_promotable_const_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
fn is_promotable_const_fn<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
tcx.is_const_fn(def_id) && match tcx.lookup_stability(def_id) {
Some(stab) => {
if cfg!(debug_assertions) && stab.promotable {
@ -101,7 +101,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
}
}
fn const_fn_is_allowed_fn_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
fn const_fn_is_allowed_fn_ptr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
tcx.is_const_fn(def_id) &&
tcx.lookup_stability(def_id)
.map(|stab| stab.allow_const_fn_ptr).unwrap_or(false)

View File

@ -1016,13 +1016,13 @@ pub struct FreeRegionInfo {
///
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/ty.html
#[derive(Copy, Clone)]
pub struct TyCtxt<'a, 'gcx: 'tcx, 'tcx: 'a> {
pub struct TyCtxt<'gcx: 'tcx, 'tcx> {
gcx: &'gcx GlobalCtxt<'gcx>,
interners: &'gcx CtxtInterners<'gcx>,
dummy: PhantomData<(&'a (), &'tcx ())>,
dummy: PhantomData<&'tcx ()>,
}
impl<'gcx> Deref for TyCtxt<'_, 'gcx, '_> {
impl<'gcx> Deref for TyCtxt<'gcx, '_> {
type Target = &'gcx GlobalCtxt<'gcx>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
@ -1119,10 +1119,10 @@ pub struct GlobalCtxt<'tcx> {
output_filenames: Arc<OutputFilenames>,
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Gets the global `TyCtxt`.
#[inline]
pub fn global_tcx(self) -> TyCtxt<'gcx, 'gcx, 'gcx> {
pub fn global_tcx(self) -> TyCtxt<'gcx, 'gcx> {
TyCtxt {
gcx: self.gcx,
interners: &self.gcx.global_interners,
@ -1131,7 +1131,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
#[inline(always)]
pub fn hir(self) -> &'a hir_map::Map<'gcx> {
pub fn hir(self) -> &'tcx hir_map::Map<'gcx> {
&self.hir_map
}
@ -1469,7 +1469,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
#[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();
StableHashingContext::new(self.sess,
@ -1666,7 +1666,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
impl<'tcx> TyCtxt<'tcx, 'tcx> {
pub fn encode_metadata(self)
-> EncodedMetadata
{
@ -1678,12 +1678,9 @@ impl<'gcx> GlobalCtxt<'gcx> {
/// Call the closure with a local `TyCtxt` using the given arena.
/// `interners` is a slot passed so we can create a CtxtInterners
/// with the same lifetime as `arena`.
pub fn enter_local<'tcx, F, R>(
&'gcx self,
f: F
) -> R
pub fn enter_local<'tcx, F, R>(&'gcx self, f: F) -> R
where
F: FnOnce(TyCtxt<'tcx, 'gcx, 'tcx>) -> R,
F: FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
'gcx: 'tcx,
{
let tcx = TyCtxt {
@ -1725,48 +1722,48 @@ impl<'gcx> GlobalCtxt<'gcx> {
/// e.g., `()` or `u8`, was interned in a different context.
pub trait Lift<'tcx>: fmt::Debug {
type Lifted: fmt::Debug + 'tcx;
fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted>;
}
macro_rules! nop_lift {
($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for $ty {
type Lifted = $lifted;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
type Lifted = $lifted;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
};
}
macro_rules! nop_list_lift {
($ty:ty => $lifted:ty) => {
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
if self.is_empty() {
return Some(List::empty());
type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
if self.is_empty() {
return Some(List::empty());
}
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) });
}
// Also try in the global tcx if we're not that.
if !tcx.is_global() {
self.lift_to_tcx(tcx.global_tcx())
} else {
None
}
}
}
};
}
@ -1815,7 +1812,7 @@ pub mod tls {
pub struct ImplicitCtxt<'a, 'gcx: 'tcx, 'tcx> {
/// The current TyCtxt. Initially created by `enter_global` and updated
/// by `enter_local` with a new local interner
pub tcx: TyCtxt<'tcx, 'gcx, 'tcx>,
pub tcx: TyCtxt<'gcx, 'tcx>,
/// The current query job, if any. This is updated by JobOwner::start in
/// ty::query::plumbing when executing a query
@ -1941,7 +1938,8 @@ pub mod tls {
/// This happens once per rustc session and TyCtxts only exists
/// inside the `f` function.
pub fn enter_global<'gcx, F, R>(gcx: &'gcx GlobalCtxt<'gcx>, f: F) -> R
where F: FnOnce(TyCtxt<'gcx, 'gcx, 'gcx>) -> R
where
F: FnOnce(TyCtxt<'gcx, 'gcx>) -> R,
{
// Update GCX_PTR to indicate there's a GlobalCtxt available
GCX_PTR.with(|lock| {
@ -1978,7 +1976,8 @@ pub mod tls {
/// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local.
/// This is used in the deadlock handler.
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<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
{
let gcx = GCX_PTR.with(|lock| *lock.lock());
assert!(gcx != 0);
@ -2030,8 +2029,9 @@ pub mod tls {
/// This will panic if you pass it a TyCtxt which has a different global interner from
/// the current ImplicitCtxt's tcx field.
#[inline]
pub fn with_related_context<'a, 'gcx, 'tcx1, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx1>, f: F) -> R
where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R
pub fn with_related_context<'gcx, 'tcx1, F, R>(tcx: TyCtxt<'gcx, 'tcx1>, f: F) -> R
where
F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R,
{
with_context(|context| {
unsafe {
@ -2048,8 +2048,9 @@ pub mod tls {
/// This will panic if you pass it a TyCtxt which has a different global interner or
/// a different local interner from the current ImplicitCtxt's tcx field.
#[inline]
pub fn with_fully_related_context<'a, 'gcx, 'tcx, F, R>(tcx: TyCtxt<'a, 'gcx, 'tcx>, f: F) -> R
where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R
pub fn with_fully_related_context<'gcx, 'tcx, F, R>(tcx: TyCtxt<'gcx, 'tcx>, f: F) -> R
where
F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R,
{
with_context(|context| {
unsafe {
@ -2065,7 +2066,8 @@ pub mod tls {
/// Panics if there is no ImplicitCtxt available
#[inline]
pub fn with<F, R>(f: F) -> R
where F: for<'a, 'gcx, 'tcx> FnOnce(TyCtxt<'a, 'gcx, 'tcx>) -> R
where
F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
{
with_context(|context| f(context.tcx))
}
@ -2074,7 +2076,8 @@ pub mod tls {
/// The closure is passed None if there is no ImplicitCtxt available
#[inline]
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<'gcx, 'tcx> FnOnce(Option<TyCtxt<'gcx, 'tcx>>) -> R,
{
with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx)))
}
@ -2098,7 +2101,7 @@ macro_rules! sty_debug_print {
all_infer: usize,
}
pub fn go(tcx: TyCtxt<'_, '_, '_>) {
pub fn go(tcx: TyCtxt<'_, '_>) {
let mut total = DebugStat {
total: 0,
lt_infer: 0,
@ -2151,7 +2154,7 @@ macro_rules! sty_debug_print {
}}
}
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
impl<'tcx> TyCtxt<'tcx, 'tcx> {
pub fn print_debug_stats(self) {
sty_debug_print!(
self,
@ -2290,7 +2293,7 @@ macro_rules! intern_method {
$alloc_method:expr,
$alloc_to_key:expr,
$keep_in_local_tcx:expr) -> $ty:ty) => {
impl<'a, 'gcx, $lt_tcx> TyCtxt<'a, 'gcx, $lt_tcx> {
impl<'gcx, $lt_tcx> TyCtxt<'gcx, $lt_tcx> {
pub fn $method(self, v: $alloc) -> &$lt_tcx $ty {
let key = ($alloc_to_key)(&v);
@ -2400,7 +2403,7 @@ intern_method! {
) -> List<CanonicalVarInfo>
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Given a `fn` type, returns an equivalent `unsafe fn` type;
/// that is, a `fn` type that is equivalent in every way for being
/// unsafe.

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

View File

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

View File

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

View File

@ -155,8 +155,8 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
/// default implementation that does an "identity" fold. Within each
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
/// sub-item.
pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx>;
pub trait TypeFolder<'gcx: 'tcx, 'tcx>: Sized {
fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx>;
fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T>
where T : TypeFoldable<'tcx>
@ -198,23 +198,27 @@ pub trait TypeVisitor<'tcx> : Sized {
///////////////////////////////////////////////////////////////////////////
// Some sample folders
pub struct BottomUpFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
where
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
{
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub tcx: TyCtxt<'gcx, 'tcx>,
pub ty_op: F,
pub lt_op: G,
pub ct_op: H,
}
impl<'a, 'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx, 'tcx, F, G, H>
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
impl<'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'gcx, 'tcx, F, G, H>
where
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
{
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
let t = ty.super_fold_with(self);
@ -235,7 +239,7 @@ impl<'a, 'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx
///////////////////////////////////////////////////////////////////////////
// Region folder
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Collects the free and escaping regions in `value` into `region_set`. Returns
/// whether any late-bound regions were skipped
pub fn collect_regions<T>(self,
@ -361,8 +365,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// visited by this folder; only regions that occur free will be
/// visited by `fld_r`.
pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub struct RegionFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'gcx, 'tcx>,
skipped_regions: &'a mut bool,
/// Stores the index of a binder *just outside* the stuff we have
@ -373,16 +377,14 @@ pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
/// Callback invokes for each free region. The `DebruijnIndex`
/// points to the binder *just outside* the ones we have passed
/// through.
fold_region_fn: &'a mut (dyn FnMut(
ty::Region<'tcx>,
ty::DebruijnIndex,
) -> ty::Region<'tcx> + 'a),
fold_region_fn:
&'a mut (dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx> + 'a),
}
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
#[inline]
pub fn new(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
skipped_regions: &'a mut bool,
fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
) -> RegionFolder<'a, 'gcx, 'tcx> {
@ -396,7 +398,9 @@ impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
}
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1);
@ -427,7 +431,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.
struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
/// As with `RegionFolder`, represents the index of a binder *just outside*
/// the ones we have visited.
@ -440,14 +444,15 @@ struct BoundVarReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
fn new<F, G, H>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
fld_r: &'a mut F,
fld_t: &'a mut G,
fld_c: &'a mut H,
) -> Self
where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
G: FnMut(ty::BoundTy) -> Ty<'tcx>,
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
where
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
G: FnMut(ty::BoundTy) -> Ty<'tcx>,
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
{
BoundVarReplacer {
tcx,
@ -460,7 +465,9 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
}
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx }
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1);
@ -542,7 +549,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx>
}
}
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Replaces all regions bound by the given `Binder` with the
/// results returned by the closure; the closure is expected to
/// return a free region (relative to this binder), and hence the
@ -722,15 +729,15 @@ enum Direction {
Out,
}
struct Shifter<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
struct Shifter<'gcx, 'tcx> {
tcx: TyCtxt<'gcx, 'tcx>,
current_index: ty::DebruijnIndex,
amount: u32,
direction: Direction,
}
impl Shifter<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>, amount: u32, direction: Direction) -> Self {
impl Shifter<'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'gcx, 'tcx>, amount: u32, direction: Direction) -> Self {
Shifter {
tcx,
current_index: ty::INNERMOST,
@ -740,8 +747,10 @@ impl Shifter<'a, 'gcx, 'tcx> {
}
}
impl TypeFolder<'gcx, 'tcx> for Shifter<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx }
impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
self.tcx
}
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
self.current_index.shift_in(1);
@ -817,10 +826,10 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'a, 'gcx, 'tcx> {
}
}
pub fn shift_region<'a, 'gcx, 'tcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pub fn shift_region<'gcx, 'tcx>(
tcx: TyCtxt<'gcx, 'tcx>,
region: ty::Region<'tcx>,
amount: u32
amount: u32,
) -> ty::Region<'tcx> {
match region {
ty::ReLateBound(debruijn, br) if amount > 0 => {
@ -832,22 +841,20 @@ pub fn shift_region<'a, 'gcx, 'tcx>(
}
}
pub fn shift_vars<'a, 'gcx, 'tcx, T>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
value: &T,
amount: u32
) -> T where T: TypeFoldable<'tcx> {
pub fn shift_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T
where
T: TypeFoldable<'tcx>,
{
debug!("shift_vars(value={:?}, amount={})",
value, amount);
value.fold_with(&mut Shifter::new(tcx, amount, Direction::In))
}
pub fn shift_out_vars<'a, 'gcx, 'tcx, T>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
value: &T,
amount: u32
) -> T where T: TypeFoldable<'tcx> {
pub fn shift_out_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T
where
T: TypeFoldable<'tcx>,
{
debug!("shift_out_vars(value={:?}, amount={})",
value, amount);

View File

@ -21,7 +21,7 @@ pub struct DefIdForest {
root_ids: SmallVec<[DefId; 1]>,
}
impl<'a, 'gcx, 'tcx> DefIdForest {
impl<'gcx, 'tcx> DefIdForest {
/// Creates an empty forest.
pub fn empty() -> DefIdForest {
DefIdForest {
@ -32,7 +32,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
/// Creates a forest consisting of a single tree representing the entire
/// crate.
#[inline]
pub fn full(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest {
pub fn full(tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest {
let crate_id = tcx.hir().local_def_id(CRATE_NODE_ID);
DefIdForest::from_id(crate_id)
}
@ -52,17 +52,14 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
}
/// Tests whether the forest contains a given DefId.
pub fn contains(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
id: DefId) -> bool
{
pub fn contains(&self, tcx: TyCtxt<'gcx, 'tcx>, id: DefId) -> bool {
self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id))
}
/// Calculate the intersection of a collection of forests.
pub fn intersection<I>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
iter: I) -> DefIdForest
where I: IntoIterator<Item=DefIdForest>
pub fn intersection<I>(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest
where
I: IntoIterator<Item = DefIdForest>,
{
let mut iter = iter.into_iter();
let mut ret = if let Some(first) = iter.next() {
@ -97,9 +94,9 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
}
/// Calculate the union of a collection of forests.
pub fn union<I>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
iter: I) -> DefIdForest
where I: IntoIterator<Item=DefIdForest>
pub fn union<I>(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest
where
I: IntoIterator<Item = DefIdForest>,
{
let mut ret = DefIdForest::empty();
let mut next_ret = SmallVec::new();

View File

@ -51,7 +51,7 @@ mod def_id_forest;
// This code should only compile in modules where the uninhabitedness of Foo is
// visible.
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Checks whether a type is visibly uninhabited from a particular module.
/// # Example
/// ```rust
@ -106,13 +106,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
impl<'a, 'gcx, 'tcx> AdtDef {
impl<'gcx, 'tcx> AdtDef {
/// Calculate the forest of DefIds from which this adt is visibly uninhabited.
fn uninhabited_from(
&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
substs: SubstsRef<'tcx>) -> DefIdForest
{
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> DefIdForest {
// Non-exhaustive ADTs from other crates are always considered inhabited.
if self.is_variant_list_non_exhaustive() && !self.did.is_local() {
DefIdForest::empty()
@ -124,14 +120,14 @@ impl<'a, 'gcx, 'tcx> AdtDef {
}
}
impl<'a, 'gcx, 'tcx> VariantDef {
impl<'gcx, 'tcx> VariantDef {
/// Calculate the forest of DefIds from which this variant is visibly uninhabited.
pub fn uninhabited_from(
&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind) -> DefIdForest
{
adt_kind: AdtKind,
) -> DefIdForest {
let is_enum = match adt_kind {
// For now, `union`s are never considered uninhabited.
// The precise semantics of inhabitedness with respect to unions is currently undecided.
@ -150,11 +146,11 @@ impl<'a, 'gcx, 'tcx> VariantDef {
}
}
impl<'a, 'gcx, 'tcx> FieldDef {
impl<'gcx, 'tcx> FieldDef {
/// Calculate the forest of DefIds from which this field is visibly uninhabited.
fn uninhabited_from(
&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
tcx: TyCtxt<'gcx, 'tcx>,
substs: SubstsRef<'tcx>,
is_enum: bool,
) -> DefIdForest {
@ -180,10 +176,9 @@ impl<'a, 'gcx, 'tcx> FieldDef {
}
}
impl<'a, 'gcx, 'tcx> TyS<'tcx> {
impl<'gcx, 'tcx> TyS<'tcx> {
/// 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<'gcx, 'tcx>) -> DefIdForest {
match self.sty {
Adt(def, substs) => def.uninhabited_from(tcx, substs),

View File

@ -42,11 +42,8 @@ pub enum InstanceDef<'tcx> {
CloneShim(DefId, Ty<'tcx>),
}
impl<'a, 'tcx> Instance<'tcx> {
pub fn ty(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>)
-> Ty<'tcx>
{
impl<'tcx> Instance<'tcx> {
pub fn ty(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> {
let ty = tcx.type_of(self.def.def_id());
tcx.subst_and_normalize_erasing_regions(
self.substs,
@ -55,7 +52,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>) -> PolyFnSig<'tcx> {
let ty = self.ty(tcx);
match ty.sty {
ty::FnDef(..) |
@ -105,7 +102,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>) -> ty::PolyFnSig<'tcx> {
let mut fn_sig = self.fn_sig_noadjust(tcx);
if let InstanceDef::VtableShim(..) = self.def {
// Modify fn(self, ...) to fn(self: *mut Self, ...)
@ -136,14 +133,11 @@ impl<'tcx> InstanceDef<'tcx> {
}
#[inline]
pub fn attrs<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::Attributes<'tcx> {
pub fn attrs(&self, tcx: TyCtxt<'tcx, 'tcx>) -> ty::Attributes<'tcx> {
tcx.get_attrs(self.def_id())
}
pub fn is_inline<'a>(
&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>
) -> bool {
pub fn is_inline(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
use crate::hir::map::DefPathData;
let def_id = match *self {
ty::InstanceDef::Item(def_id) => def_id,
@ -156,10 +150,7 @@ impl<'tcx> InstanceDef<'tcx> {
}
}
pub fn requires_local<'a>(
&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>
) -> bool {
pub fn requires_local(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
if self.is_inline(tcx) {
return true
}
@ -209,7 +200,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
}
}
impl<'a, 'b, 'tcx> Instance<'tcx> {
impl<'b, 'tcx> Instance<'tcx> {
pub fn new(def_id: DefId, substs: SubstsRef<'tcx>)
-> Instance<'tcx> {
assert!(!substs.has_escaping_bound_vars(),
@ -218,7 +209,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
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<'tcx, 'b>, def_id: DefId) -> Instance<'tcx> {
Instance::new(def_id, tcx.global_tcx().empty_substs_for_def_id(def_id))
}
@ -245,10 +236,12 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
/// 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
/// `Some`.
pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
pub fn resolve(
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>,
) -> Option<Instance<'tcx>> {
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env);
@ -297,10 +290,12 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
result
}
pub fn resolve_for_vtable(tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
pub fn resolve_for_vtable(
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
substs: SubstsRef<'tcx>,
) -> Option<Instance<'tcx>> {
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
let fn_sig = tcx.fn_sig(def_id);
let is_vtable_shim =
@ -317,12 +312,11 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
}
pub fn resolve_closure(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
def_id: DefId,
substs: ty::ClosureSubsts<'tcx>,
requested_kind: ty::ClosureKind)
-> Instance<'tcx>
{
requested_kind: ty::ClosureKind,
) -> Instance<'tcx> {
let actual_kind = substs.closure_kind(def_id, tcx);
match needs_fn_once_adapter_shim(actual_kind, requested_kind) {
@ -331,22 +325,17 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
}
}
pub fn resolve_drop_in_place(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty: Ty<'tcx>)
-> ty::Instance<'tcx>
{
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
let substs = tcx.intern_substs(&[ty.into()]);
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
}
pub fn fn_once_adapter_instance(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
closure_did: DefId,
substs: ty::ClosureSubsts<'tcx>)
-> Instance<'tcx>
{
substs: ty::ClosureSubsts<'tcx>,
) -> Instance<'tcx> {
debug!("fn_once_adapter_shim({:?}, {:?})",
closure_did,
substs);
@ -376,8 +365,8 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
}
}
fn resolve_associated_item<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn resolve_associated_item<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
trait_item: &ty::AssocItem,
param_env: ty::ParamEnv<'tcx>,
trait_id: DefId,

View File

@ -28,21 +28,20 @@ use rustc_target::abi::call::{
ArgAttribute, ArgAttributes, ArgType, Conv, FnType, IgnoreMode, PassMode, Reg, RegKind
};
pub trait IntegerExt {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx>;
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx>;
fn from_attr<C: HasDataLayout>(cx: &C, ity: attr::IntType) -> Integer;
fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128)
-> (Integer, bool);
fn repr_discr<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128,
) -> (Integer, bool);
}
impl IntegerExt for Integer {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx> {
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx> {
match (*self, signed) {
(I8, false) => tcx.types.u8,
(I16, false) => tcx.types.u16,
@ -77,12 +76,13 @@ impl IntegerExt for Integer {
/// signed discriminant range and #[repr] attribute.
/// N.B.: u128 values above i128::MAX will be treated as signed, but
/// that shouldn't affect anything, other than maybe debuginfo.
fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128)
-> (Integer, bool) {
fn repr_discr<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
ty: Ty<'tcx>,
repr: &ReprOptions,
min: i128,
max: i128,
) -> (Integer, bool) {
// Theoretically, negative values could be larger in unsigned representation
// than the unsigned representation of the signed minimum. However, if there
// are any negative values, the only valid unsigned representation is u128
@ -126,11 +126,11 @@ impl IntegerExt for Integer {
}
pub trait PrimitiveExt {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx>;
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx>;
}
impl PrimitiveExt for Primitive {
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> {
match *self {
Int(i, signed) => i.to_ty(tcx, signed),
Float(FloatTy::F32) => tcx.types.f32,
@ -171,10 +171,10 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
}
}
fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-> Result<&'tcx LayoutDetails, LayoutError<'tcx>>
{
fn layout_raw<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
ty::tls::with_related_context(tcx, move |icx| {
let rec_limit = *tcx.sess.recursion_limit.get();
let (param_env, ty) = query.into_parts();
@ -226,7 +226,7 @@ enum StructKind {
Prefixed(Size, Align),
}
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> {
fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutDetails {
let dl = self.data_layout();
let b_align = b.value.align(dl);
@ -1221,7 +1221,7 @@ enum SavedLocalEligibility {
// Also included in the layout are the upvars and the discriminant.
// These are included as fields on the "outer" layout; they are not part
// of any variant.
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> {
/// Compute the eligibility and assignment of each local.
fn generator_saved_local_eligibility(&self, info: &GeneratorLayout<'tcx>)
-> (BitSet<GeneratorSavedLocal>, IndexVec<GeneratorSavedLocal, SavedLocalEligibility>) {
@ -1442,9 +1442,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
debug!("generator layout ({:?}): {:#?}", ty, layout);
Ok(layout)
}
}
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
/// This is invoked by the `layout_raw` query to record the final
/// layout of each type.
#[inline(always)]
@ -1605,11 +1603,12 @@ pub enum SizeSkeleton<'tcx> {
}
}
impl<'a, 'tcx> SizeSkeleton<'tcx> {
pub fn compute(ty: Ty<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>)
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
impl<'tcx> SizeSkeleton<'tcx> {
pub fn compute(
ty: Ty<'tcx>,
tcx: TyCtxt<'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
debug_assert!(!ty.has_infer_types());
// First try computing a static layout.
@ -1729,21 +1728,21 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
}
pub trait HasTyCtxt<'tcx>: HasDataLayout {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
fn tcx(&self) -> TyCtxt<'tcx, 'tcx>;
}
pub trait HasParamEnv<'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx>;
}
impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> {
impl<'gcx, 'tcx> HasDataLayout for TyCtxt<'gcx, 'tcx> {
fn data_layout(&self) -> &TargetDataLayout {
&self.data_layout
}
}
impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> {
impl<'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'gcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'gcx> {
self.global_tcx()
}
}
@ -1761,7 +1760,7 @@ impl<'tcx, T: HasDataLayout> HasDataLayout 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(&self) -> TyCtxt<'gcx, 'gcx> {
self.tcx.tcx()
}
}
@ -1798,7 +1797,7 @@ impl<T, E> MaybeResult<T> for Result<T, E> {
pub type TyLayout<'tcx> = ::rustc_target::abi::TyLayout<'tcx, Ty<'tcx>>;
impl<'a, 'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> {
type Ty = Ty<'tcx>;
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
@ -1825,7 +1824,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 TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
@ -1857,7 +1856,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.
impl TyCtxt<'a, 'tcx, '_> {
impl TyCtxt<'tcx, '_> {
/// Computes the layout of a type. Note that this implicitly
/// executes in "reveal all" mode.
#[inline]
@ -1871,7 +1870,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
/// executes in "reveal all" mode.
#[inline]
@ -2189,9 +2188,9 @@ struct Niche {
}
impl Niche {
fn reserve<'a, 'tcx>(
fn reserve<'tcx>(
&self,
cx: &LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>>,
cx: &LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>>,
count: u128,
) -> Option<(u128, Scalar)> {
if count > self.available {
@ -2207,7 +2206,7 @@ impl Niche {
}
}
impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx, 'tcx>> {
/// Find the offset of a niche leaf field, starting from
/// the given type and recursing through aggregates.
// FIXME(eddyb) traverse already optimized enums.

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