1
Fork 0

Unify all uses of 'gcx and 'tcx.

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-14 00:48:52 +03:00
parent 0e4a56b4b0
commit f3f9d6dfd9
341 changed files with 3109 additions and 3327 deletions

View file

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

View file

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

View file

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

View file

@ -204,10 +204,10 @@ macro_rules! define_dep_nodes {
impl DepNode { impl DepNode {
#[allow(unreachable_code, non_snake_case)] #[allow(unreachable_code, non_snake_case)]
#[inline(always)] #[inline(always)]
pub fn new<'a, 'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, pub fn new<'a, 'tcx>(tcx: TyCtxt<'tcx>,
dep: DepConstructor<'gcx>) dep: DepConstructor<'tcx>)
-> DepNode -> DepNode
where 'gcx: 'a + 'tcx, where 'tcx: 'a,
'tcx: 'a 'tcx: 'a
{ {
match dep { match dep {
@ -307,7 +307,7 @@ macro_rules! define_dep_nodes {
/// refers to something from the previous compilation session that /// refers to something from the previous compilation session that
/// has been removed. /// has been removed.
#[inline] #[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() { if self.kind.can_reconstruct_query_key() {
let def_path_hash = DefPathHash(self.hash); let def_path_hash = DefPathHash(self.hash);
tcx.def_path_hash_to_def_id.as_ref()? tcx.def_path_hash_to_def_id.as_ref()?
@ -400,7 +400,7 @@ impl DefPathHash {
impl DefId { impl DefId {
#[inline(always)] #[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)) DepNode::from_def_path_hash(kind, tcx.def_path_hash(self))
} }
} }
@ -442,50 +442,50 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
]); ]);
pub trait RecoverKey<'tcx>: Sized { pub trait RecoverKey<'tcx>: Sized {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self>; fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>;
} }
impl RecoverKey<'tcx> for CrateNum { impl RecoverKey<'tcx> for CrateNum {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> { fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.krate) dep_node.extract_def_id(tcx).map(|id| id.krate)
} }
} }
impl RecoverKey<'tcx> for DefId { impl RecoverKey<'tcx> for DefId {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> { fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx) dep_node.extract_def_id(tcx)
} }
} }
impl RecoverKey<'tcx> for DefIndex { impl RecoverKey<'tcx> for DefIndex {
fn recover(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> Option<Self> { fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
dep_node.extract_def_id(tcx).map(|id| id.index) dep_node.extract_def_id(tcx).map(|id| id.index)
} }
} }
trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug { trait DepNodeParams<'tcx>: fmt::Debug {
const CAN_RECONSTRUCT_QUERY_KEY: bool; const CAN_RECONSTRUCT_QUERY_KEY: bool;
/// This method turns the parameters of a DepNodeConstructor into an opaque /// This method turns the parameters of a DepNodeConstructor into an opaque
/// Fingerprint to be used in DepNode. /// Fingerprint to be used in DepNode.
/// Not all DepNodeParams support being turned into a Fingerprint (they /// Not all DepNodeParams support being turned into a Fingerprint (they
/// don't need to if the corresponding DepNode is anonymous). /// don't need to if the corresponding DepNode is anonymous).
fn to_fingerprint(&self, _: TyCtxt<'gcx, 'tcx>) -> Fingerprint { fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint {
panic!("Not implemented. Accidentally called on anonymous node?") panic!("Not implemented. Accidentally called on anonymous node?")
} }
fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String { fn to_debug_str(&self, _: TyCtxt<'tcx>) -> String {
format!("{:?}", self) format!("{:?}", self)
} }
} }
impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T impl<'tcx, T> DepNodeParams<'tcx> for T
where where
T: HashStable<StableHashingContext<'tcx>> + fmt::Debug, T: HashStable<StableHashingContext<'tcx>> + fmt::Debug,
{ {
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false; default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
default fn to_fingerprint(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Fingerprint { default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
let mut hcx = tcx.create_stable_hashing_context(); let mut hcx = tcx.create_stable_hashing_context();
let mut hasher = StableHasher::new(); let mut hasher = StableHasher::new();
@ -494,39 +494,39 @@ where
hasher.finish() hasher.finish()
} }
default fn to_debug_str(&self, _: TyCtxt<'gcx, 'tcx>) -> String { default fn to_debug_str(&self, _: TyCtxt<'tcx>) -> String {
format!("{:?}", *self) format!("{:?}", *self)
} }
} }
impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefId { impl<'tcx> DepNodeParams<'tcx> for DefId {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint {
tcx.def_path_hash(*self).0 tcx.def_path_hash(*self).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.def_path_str(*self) tcx.def_path_str(*self)
} }
} }
impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for DefIndex { impl<'tcx> DepNodeParams<'tcx> for DefIndex {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint {
tcx.hir().definitions().def_path_hash(*self).0 tcx.hir().definitions().def_path_hash(*self).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.def_path_str(DefId::local(*self)) tcx.def_path_str(DefId::local(*self))
} }
} }
impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for CrateNum { impl<'tcx> DepNodeParams<'tcx> for CrateNum {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; 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 { let def_id = DefId {
krate: *self, krate: *self,
index: CRATE_DEF_INDEX, index: CRATE_DEF_INDEX,
@ -534,18 +534,18 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for CrateNum {
tcx.def_path_hash(def_id).0 tcx.def_path_hash(def_id).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
tcx.crate_name(*self).as_str().to_string() tcx.crate_name(*self).as_str().to_string()
} }
} }
impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) { impl<'tcx> DepNodeParams<'tcx> for (DefId, DefId) {
const CAN_RECONSTRUCT_QUERY_KEY: bool = false; const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
// We actually would not need to specialize the implementation of this // We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full // method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state. // 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_id_0, def_id_1) = *self;
let def_path_hash_0 = tcx.def_path_hash(def_id_0); let def_path_hash_0 = tcx.def_path_hash(def_id_0);
@ -554,7 +554,7 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) {
def_path_hash_0.0.combine(def_path_hash_1.0) def_path_hash_0.0.combine(def_path_hash_1.0)
} }
fn to_debug_str(&self, tcx: TyCtxt<'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
let (def_id_0, def_id_1) = *self; let (def_id_0, def_id_1) = *self;
format!("({}, {})", format!("({}, {})",
@ -563,13 +563,13 @@ impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for (DefId, DefId) {
} }
} }
impl<'gcx: 'tcx, 'tcx> DepNodeParams<'gcx, 'tcx> for HirId { impl<'tcx> DepNodeParams<'tcx> for HirId {
const CAN_RECONSTRUCT_QUERY_KEY: bool = false; const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
// We actually would not need to specialize the implementation of this // We actually would not need to specialize the implementation of this
// method but it's faster to combine the hashes than to instantiate a full // method but it's faster to combine the hashes than to instantiate a full
// hashing context and stable-hashing state. // hashing context and stable-hashing state.
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_>) -> Fingerprint { fn to_fingerprint(&self, tcx: TyCtxt<'_>) -> Fingerprint {
let HirId { let HirId {
owner, owner,
local_id, local_id,

View file

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

View file

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

View file

@ -88,7 +88,7 @@ impl Target {
} }
struct CheckAttrVisitor<'tcx> { struct CheckAttrVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
} }
impl CheckAttrVisitor<'tcx> { impl CheckAttrVisitor<'tcx> {
@ -347,7 +347,7 @@ fn is_c_like_enum(item: &hir::Item) -> bool {
} }
} }
fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module( tcx.hir().visit_item_likes_in_module(
module_def_id, module_def_id,
&mut CheckAttrVisitor { tcx }.as_deep_visitor() &mut CheckAttrVisitor { tcx }.as_deep_visitor()

View file

@ -177,7 +177,7 @@ impl DefId {
LocalDefId::from_def_id(self) 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 { if self.is_local() && self.index == CRATE_DEF_INDEX {
format!("top-level module") format!("top-level module")
} else { } else {

View file

@ -413,8 +413,8 @@ impl<'a> LoweringContext<'a> {
/// needed from arbitrary locations in the crate, /// needed from arbitrary locations in the crate,
/// e.g., the number of lifetime generic parameters /// e.g., the number of lifetime generic parameters
/// declared for every type and trait definition. /// declared for every type and trait definition.
struct MiscCollector<'lcx, 'interner: 'lcx> { struct MiscCollector<'tcx, 'interner: 'tcx> {
lctx: &'lcx mut LoweringContext<'interner>, lctx: &'tcx mut LoweringContext<'interner>,
hir_id_owner: Option<NodeId>, hir_id_owner: Option<NodeId>,
} }
@ -458,8 +458,8 @@ impl<'a> LoweringContext<'a> {
} }
} }
impl<'lcx, 'interner> Visitor<'lcx> for MiscCollector<'lcx, 'interner> { impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> {
fn visit_pat(&mut self, p: &'lcx Pat) { fn visit_pat(&mut self, p: &'tcx Pat) {
match p.node { match p.node {
// Doesn't generate a HIR node // Doesn't generate a HIR node
PatKind::Paren(..) => {}, PatKind::Paren(..) => {},
@ -473,7 +473,7 @@ impl<'a> LoweringContext<'a> {
visit::walk_pat(self, p) visit::walk_pat(self, p)
} }
fn visit_item(&mut self, item: &'lcx Item) { fn visit_item(&mut self, item: &'tcx Item) {
let hir_id = self.lctx.allocate_hir_id_counter(item.id); let hir_id = self.lctx.allocate_hir_id_counter(item.id);
match item.node { match item.node {
@ -505,7 +505,7 @@ impl<'a> LoweringContext<'a> {
}); });
} }
fn visit_trait_item(&mut self, item: &'lcx TraitItem) { fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
self.lctx.allocate_hir_id_counter(item.id); self.lctx.allocate_hir_id_counter(item.id);
match item.node { match item.node {
@ -521,21 +521,21 @@ impl<'a> LoweringContext<'a> {
} }
} }
fn visit_impl_item(&mut self, item: &'lcx ImplItem) { fn visit_impl_item(&mut self, item: &'tcx ImplItem) {
self.lctx.allocate_hir_id_counter(item.id); self.lctx.allocate_hir_id_counter(item.id);
self.with_hir_id_owner(Some(item.id), |this| { self.with_hir_id_owner(Some(item.id), |this| {
visit::walk_impl_item(this, item); visit::walk_impl_item(this, item);
}); });
} }
fn visit_foreign_item(&mut self, i: &'lcx ForeignItem) { fn visit_foreign_item(&mut self, i: &'tcx ForeignItem) {
// Ignore patterns in foreign items // Ignore patterns in foreign items
self.with_hir_id_owner(None, |this| { self.with_hir_id_owner(None, |this| {
visit::walk_foreign_item(this, i) visit::walk_foreign_item(this, i)
}); });
} }
fn visit_ty(&mut self, t: &'lcx Ty) { fn visit_ty(&mut self, t: &'tcx Ty) {
match t.node { match t.node {
// Mirrors the case in visit::walk_ty // Mirrors the case in visit::walk_ty
TyKind::BareFn(ref f) => { TyKind::BareFn(ref f) => {
@ -559,11 +559,11 @@ impl<'a> LoweringContext<'a> {
} }
} }
struct ItemLowerer<'lcx, 'interner: 'lcx> { struct ItemLowerer<'tcx, 'interner: 'tcx> {
lctx: &'lcx mut LoweringContext<'interner>, lctx: &'tcx mut LoweringContext<'interner>,
} }
impl<'lcx, 'interner> ItemLowerer<'lcx, 'interner> { impl<'tcx, 'interner> ItemLowerer<'tcx, 'interner> {
fn with_trait_impl_ref<F>(&mut self, trait_impl_ref: &Option<TraitRef>, f: F) fn with_trait_impl_ref<F>(&mut self, trait_impl_ref: &Option<TraitRef>, f: F)
where where
F: FnOnce(&mut Self), F: FnOnce(&mut Self),
@ -579,8 +579,8 @@ impl<'a> LoweringContext<'a> {
} }
} }
impl<'lcx, 'interner> Visitor<'lcx> for ItemLowerer<'lcx, 'interner> { impl<'tcx, 'interner> Visitor<'tcx> for ItemLowerer<'tcx, 'interner> {
fn visit_mod(&mut self, m: &'lcx Mod, _s: Span, _attrs: &[Attribute], n: NodeId) { fn visit_mod(&mut self, m: &'tcx Mod, _s: Span, _attrs: &[Attribute], n: NodeId) {
self.lctx.modules.insert(n, hir::ModuleItems { self.lctx.modules.insert(n, hir::ModuleItems {
items: BTreeSet::new(), items: BTreeSet::new(),
trait_items: BTreeSet::new(), trait_items: BTreeSet::new(),
@ -593,7 +593,7 @@ impl<'a> LoweringContext<'a> {
self.lctx.current_module = old; self.lctx.current_module = old;
} }
fn visit_item(&mut self, item: &'lcx Item) { fn visit_item(&mut self, item: &'tcx Item) {
let mut item_hir_id = None; let mut item_hir_id = None;
self.lctx.with_hir_id_owner(item.id, |lctx| { self.lctx.with_hir_id_owner(item.id, |lctx| {
if let Some(hir_item) = lctx.lower_item(item) { if let Some(hir_item) = lctx.lower_item(item) {
@ -624,7 +624,7 @@ impl<'a> LoweringContext<'a> {
} }
} }
fn visit_trait_item(&mut self, item: &'lcx TraitItem) { fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
self.lctx.with_hir_id_owner(item.id, |lctx| { self.lctx.with_hir_id_owner(item.id, |lctx| {
let hir_item = lctx.lower_trait_item(item); let hir_item = lctx.lower_trait_item(item);
let id = hir::TraitItemId { hir_id: hir_item.hir_id }; let id = hir::TraitItemId { hir_id: hir_item.hir_id };
@ -635,7 +635,7 @@ impl<'a> LoweringContext<'a> {
visit::walk_trait_item(self, item); visit::walk_trait_item(self, item);
} }
fn visit_impl_item(&mut self, item: &'lcx ImplItem) { fn visit_impl_item(&mut self, item: &'tcx ImplItem) {
self.lctx.with_hir_id_owner(item.id, |lctx| { self.lctx.with_hir_id_owner(item.id, |lctx| {
let hir_item = lctx.lower_impl_item(item); let hir_item = lctx.lower_impl_item(item);
let id = hir::ImplItemId { hir_id: hir_item.hir_id }; let id = hir::ImplItemId { hir_id: hir_item.hir_id };

View file

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

View file

@ -61,12 +61,12 @@ pub enum NodeIdHashingMode {
/// We could also just store a plain reference to the hir::Crate but we want /// We could also just store a plain reference to the hir::Crate but we want
/// to avoid that the crate is used to get untracked access to all of the HIR. /// to avoid that the crate is used to get untracked access to all of the HIR.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
struct BodyResolver<'gcx>(&'gcx hir::Crate); struct BodyResolver<'tcx>(&'tcx hir::Crate);
impl<'gcx> BodyResolver<'gcx> { impl<'tcx> BodyResolver<'tcx> {
// Return a reference to the hir::Body with the given BodyId. // Return a reference to the hir::Body with the given BodyId.
// DOES NOT DO ANY TRACKING, use carefully. // DOES NOT DO ANY TRACKING, use carefully.
fn body(self, id: hir::BodyId) -> &'gcx hir::Body { fn body(self, id: hir::BodyId) -> &'tcx hir::Body {
self.0.body(id) self.0.body(id)
} }
} }
@ -205,8 +205,8 @@ for &'b mut T {
} }
} }
impl StableHashingContextProvider<'lcx> for TyCtxt<'gcx, 'lcx> { impl StableHashingContextProvider<'tcx> for TyCtxt<'tcx> {
fn get_stable_hashing_context(&self) -> StableHashingContext<'lcx> { fn get_stable_hashing_context(&self) -> StableHashingContext<'tcx> {
(*self).create_stable_hashing_context() (*self).create_stable_hashing_context()
} }
} }

View file

@ -508,9 +508,9 @@ fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar,
impl<'gcx> HashStable<StableHashingContext<'gcx>> for feature_gate::Features { impl<'tcx> HashStable<StableHashingContext<'tcx>> for feature_gate::Features {
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>, hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) { hasher: &mut StableHasher<W>) {
// Unfortunately we cannot exhaustively list fields here, since the // Unfortunately we cannot exhaustively list fields here, since the
// struct is macro generated. // struct is macro generated.

View file

@ -11,8 +11,8 @@ use crate::middle::region;
use crate::ty; use crate::ty;
use crate::mir; use crate::mir;
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>>
for &'gcx ty::List<T> for &'tcx ty::List<T>
where T: HashStable<StableHashingContext<'a>> { where T: HashStable<StableHashingContext<'a>> {
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>, hcx: &mut StableHashingContext<'a>,
@ -40,7 +40,7 @@ for &'gcx ty::List<T>
} }
} }
impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::List<T> impl<'a, 'tcx, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx ty::List<T>
where T: HashStable<StableHashingContext<'a>> where T: HashStable<StableHashingContext<'a>>
{ {
type KeyType = Fingerprint; type KeyType = Fingerprint;
@ -54,7 +54,7 @@ impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::List<T
} }
} }
impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::subst::Kind<'gcx> { impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::Kind<'tcx> {
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>, hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) { hasher: &mut StableHasher<W>) {
@ -117,19 +117,19 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
} }
} }
impl<'gcx, 'tcx> HashStable<StableHashingContext<'gcx>> for ty::ConstVid<'tcx> { impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::ConstVid<'tcx> {
#[inline] #[inline]
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>, hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) { hasher: &mut StableHasher<W>) {
self.index.hash_stable(hcx, hasher); self.index.hash_stable(hcx, hasher);
} }
} }
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar { impl<'tcx> HashStable<StableHashingContext<'tcx>> for ty::BoundVar {
#[inline] #[inline]
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>, hcx: &mut StableHashingContext<'tcx>,
hasher: &mut StableHasher<W>) { hasher: &mut StableHasher<W>) {
self.index().hash_stable(hcx, hasher); self.index().hash_stable(hcx, hasher);
} }

View file

@ -30,24 +30,24 @@ use super::*;
use crate::ty::Const; use crate::ty::Const;
use crate::ty::relate::{Relate, TypeRelation}; use crate::ty::relate::{Relate, TypeRelation};
pub struct At<'a, 'gcx: 'tcx, 'tcx: 'a> { pub struct At<'a, 'tcx: 'a> {
pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, pub infcx: &'a InferCtxt<'a, 'tcx>,
pub cause: &'a ObligationCause<'tcx>, pub cause: &'a ObligationCause<'tcx>,
pub param_env: ty::ParamEnv<'tcx>, pub param_env: ty::ParamEnv<'tcx>,
} }
pub struct Trace<'a, 'gcx: 'tcx, 'tcx: 'a> { pub struct Trace<'a, 'tcx: 'a> {
at: At<'a, 'gcx, 'tcx>, at: At<'a, 'tcx>,
a_is_expected: bool, a_is_expected: bool,
trace: TypeTrace<'tcx>, trace: TypeTrace<'tcx>,
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
#[inline] #[inline]
pub fn at(&'a self, pub fn at(&'a self,
cause: &'a ObligationCause<'tcx>, cause: &'a ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>) param_env: ty::ParamEnv<'tcx>)
-> At<'a, 'gcx, 'tcx> -> At<'a, 'tcx>
{ {
At { infcx: self, cause, param_env } At { infcx: self, cause, param_env }
} }
@ -61,7 +61,7 @@ pub trait ToTrace<'tcx>: Relate<'tcx> + Copy {
-> TypeTrace<'tcx>; -> TypeTrace<'tcx>;
} }
impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { impl<'a, 'tcx> At<'a, 'tcx> {
/// Hacky routine for equating two impl headers in coherence. /// Hacky routine for equating two impl headers in coherence.
pub fn eq_impl_headers(self, pub fn eq_impl_headers(self,
expected: &ty::ImplHeader<'tcx>, expected: &ty::ImplHeader<'tcx>,
@ -189,7 +189,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> {
pub fn trace<T>(self, pub fn trace<T>(self,
expected: T, expected: T,
actual: T) actual: T)
-> Trace<'a, 'gcx, 'tcx> -> Trace<'a, 'tcx>
where T: ToTrace<'tcx> where T: ToTrace<'tcx>
{ {
self.trace_exp(true, expected, actual) self.trace_exp(true, expected, actual)
@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> {
a_is_expected: bool, a_is_expected: bool,
a: T, a: T,
b: T) b: T)
-> Trace<'a, 'gcx, 'tcx> -> Trace<'a, 'tcx>
where T: ToTrace<'tcx> where T: ToTrace<'tcx>
{ {
let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b); let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b);
@ -210,7 +210,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> Trace<'a, 'gcx, 'tcx> { impl<'a, 'tcx> Trace<'a, 'tcx> {
/// Makes `a <: b` where `a` may or may not be expected (if /// Makes `a <: b` where `a` may or may not be expected (if
/// `a_is_expected` is true, then `a` is expected). /// `a_is_expected` is true, then `a` is expected).
/// Makes `expected <: actual`. /// Makes `expected <: actual`.

View file

@ -21,7 +21,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::indexed_vec::Idx;
use smallvec::SmallVec; use smallvec::SmallVec;
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// Canonicalizes a query value `V`. When we canonicalize a query, /// Canonicalizes a query value `V`. When we canonicalize a query,
/// we not only canonicalize unbound inference variables, but we /// we not only canonicalize unbound inference variables, but we
/// *also* replace all free regions whatsoever. So for example a /// *also* replace all free regions whatsoever. So for example a
@ -41,9 +41,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
&self, &self,
value: &V, value: &V,
query_state: &mut OriginalQueryValues<'tcx>, query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonicalized<'gcx, V> ) -> Canonicalized<'tcx, V>
where where
V: TypeFoldable<'tcx> + Lift<'gcx>, V: TypeFoldable<'tcx> + Lift<'tcx>,
{ {
self.tcx self.tcx
.sess .sess
@ -85,9 +85,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
/// out the [chapter in the rustc guide][c]. /// out the [chapter in the rustc guide][c].
/// ///
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query-result /// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query-result
pub fn canonicalize_response<V>(&self, value: &V) -> Canonicalized<'gcx, V> pub fn canonicalize_response<V>(&self, value: &V) -> Canonicalized<'tcx, V>
where where
V: TypeFoldable<'tcx> + Lift<'gcx>, V: TypeFoldable<'tcx> + Lift<'tcx>,
{ {
let mut query_state = OriginalQueryValues::default(); let mut query_state = OriginalQueryValues::default();
Canonicalizer::canonicalize( Canonicalizer::canonicalize(
@ -99,9 +99,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
) )
} }
pub fn canonicalize_user_type_annotation<V>(&self, value: &V) -> Canonicalized<'gcx, V> pub fn canonicalize_user_type_annotation<V>(&self, value: &V) -> Canonicalized<'tcx, V>
where where
V: TypeFoldable<'tcx> + Lift<'gcx>, V: TypeFoldable<'tcx> + Lift<'tcx>,
{ {
let mut query_state = OriginalQueryValues::default(); let mut query_state = OriginalQueryValues::default();
Canonicalizer::canonicalize( Canonicalizer::canonicalize(
@ -130,9 +130,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
&self, &self,
value: &V, value: &V,
query_state: &mut OriginalQueryValues<'tcx>, query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonicalized<'gcx, V> ) -> Canonicalized<'tcx, V>
where where
V: TypeFoldable<'tcx> + Lift<'gcx>, V: TypeFoldable<'tcx> + Lift<'tcx>,
{ {
self.tcx self.tcx
.sess .sess
@ -160,7 +160,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
trait CanonicalizeRegionMode { trait CanonicalizeRegionMode {
fn canonicalize_free_region( fn canonicalize_free_region(
&self, &self,
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, canonicalizer: &mut Canonicalizer<'_, 'tcx>,
r: ty::Region<'tcx>, r: ty::Region<'tcx>,
) -> ty::Region<'tcx>; ) -> ty::Region<'tcx>;
@ -172,7 +172,7 @@ struct CanonicalizeQueryResponse;
impl CanonicalizeRegionMode for CanonicalizeQueryResponse { impl CanonicalizeRegionMode for CanonicalizeQueryResponse {
fn canonicalize_free_region( fn canonicalize_free_region(
&self, &self,
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, canonicalizer: &mut Canonicalizer<'_, 'tcx>,
r: ty::Region<'tcx>, r: ty::Region<'tcx>,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
match r { match r {
@ -221,7 +221,7 @@ struct CanonicalizeUserTypeAnnotation;
impl CanonicalizeRegionMode for CanonicalizeUserTypeAnnotation { impl CanonicalizeRegionMode for CanonicalizeUserTypeAnnotation {
fn canonicalize_free_region( fn canonicalize_free_region(
&self, &self,
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, canonicalizer: &mut Canonicalizer<'_, 'tcx>,
r: ty::Region<'tcx>, r: ty::Region<'tcx>,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
match r { match r {
@ -244,7 +244,7 @@ struct CanonicalizeAllFreeRegions;
impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions { impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions {
fn canonicalize_free_region( fn canonicalize_free_region(
&self, &self,
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, canonicalizer: &mut Canonicalizer<'_, 'tcx>,
r: ty::Region<'tcx>, r: ty::Region<'tcx>,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
canonicalizer.canonical_var_for_region_in_root_universe(r) canonicalizer.canonical_var_for_region_in_root_universe(r)
@ -260,7 +260,7 @@ struct CanonicalizeFreeRegionsOtherThanStatic;
impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic { impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
fn canonicalize_free_region( fn canonicalize_free_region(
&self, &self,
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, canonicalizer: &mut Canonicalizer<'_, 'tcx>,
r: ty::Region<'tcx>, r: ty::Region<'tcx>,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
if let ty::ReStatic = r { if let ty::ReStatic = r {
@ -275,9 +275,9 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
} }
} }
struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { struct Canonicalizer<'cx, 'tcx: 'cx> {
infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>, infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
variables: SmallVec<[CanonicalVarInfo; 8]>, variables: SmallVec<[CanonicalVarInfo; 8]>,
query_state: &'cx mut OriginalQueryValues<'tcx>, query_state: &'cx mut OriginalQueryValues<'tcx>,
// Note that indices is only used once `var_values` is big enough to be // Note that indices is only used once `var_values` is big enough to be
@ -289,8 +289,8 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
binder_index: ty::DebruijnIndex, binder_index: ty::DebruijnIndex,
} }
impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -495,18 +495,18 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
} }
} }
impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
/// The main `canonicalize` method, shared impl of /// The main `canonicalize` method, shared impl of
/// `canonicalize_query` and `canonicalize_response`. /// `canonicalize_query` and `canonicalize_response`.
fn canonicalize<V>( fn canonicalize<V>(
value: &V, value: &V,
infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>, infcx: Option<&InferCtxt<'_, 'tcx>>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalize_region_mode: &dyn CanonicalizeRegionMode, canonicalize_region_mode: &dyn CanonicalizeRegionMode,
query_state: &mut OriginalQueryValues<'tcx>, query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonicalized<'gcx, V> ) -> Canonicalized<'tcx, V>
where where
V: TypeFoldable<'tcx> + Lift<'gcx>, V: TypeFoldable<'tcx> + Lift<'tcx>,
{ {
let needs_canonical_flags = if canonicalize_region_mode.any() { let needs_canonical_flags = if canonicalize_region_mode.any() {
TypeFlags::KEEP_IN_LOCAL_TCX | TypeFlags::KEEP_IN_LOCAL_TCX |

View file

@ -44,15 +44,15 @@ mod substitute;
/// variables have been rewritten to "canonical vars". These are /// variables have been rewritten to "canonical vars". These are
/// numbered starting from 0 in order of first appearance. /// numbered starting from 0 in order of first appearance.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable, HashStable)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable, HashStable)]
pub struct Canonical<'gcx, V> { pub struct Canonical<'tcx, V> {
pub max_universe: ty::UniverseIndex, pub max_universe: ty::UniverseIndex,
pub variables: CanonicalVarInfos<'gcx>, pub variables: CanonicalVarInfos<'tcx>,
pub value: V, pub value: V,
} }
pub type CanonicalVarInfos<'gcx> = &'gcx List<CanonicalVarInfo>; pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo>;
impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {} impl<'tcx> UseSpecializedDecodable for CanonicalVarInfos<'tcx> {}
/// A set of values corresponding to the canonical variables from some /// A set of values corresponding to the canonical variables from some
/// `Canonical`. You can give these values to /// `Canonical`. You can give these values to
@ -194,10 +194,10 @@ pub struct QueryResponse<'tcx, R> {
pub value: R, pub value: R,
} }
pub type Canonicalized<'gcx, V> = Canonical<'gcx, <V as Lift<'gcx>>::Lifted>; pub type Canonicalized<'tcx, V> = Canonical<'tcx, <V as Lift<'tcx>>::Lifted>;
pub type CanonicalizedQueryResponse<'gcx, T> = pub type CanonicalizedQueryResponse<'tcx, T> =
&'gcx Canonical<'gcx, QueryResponse<'gcx, <T as Lift<'gcx>>::Lifted>>; &'tcx Canonical<'tcx, QueryResponse<'tcx, <T as Lift<'tcx>>::Lifted>>;
/// Indicates whether or not we were able to prove the query to be /// Indicates whether or not we were able to prove the query to be
/// true. /// true.
@ -254,7 +254,7 @@ impl<'tcx, R> Canonical<'tcx, QueryResponse<'tcx, R>> {
} }
} }
impl<'gcx, V> Canonical<'gcx, V> { impl<'tcx, V> Canonical<'tcx, V> {
/// Allows you to map the `value` of a canonical while keeping the /// Allows you to map the `value` of a canonical while keeping the
/// same set of bound variables. /// same set of bound variables.
/// ///
@ -278,7 +278,7 @@ impl<'gcx, V> Canonical<'gcx, V> {
/// let ty: Ty<'tcx> = ...; /// let ty: Ty<'tcx> = ...;
/// let b: Canonical<'tcx, (T, Ty<'tcx>)> = a.unchecked_map(|v| (v, ty)); /// let b: Canonical<'tcx, (T, Ty<'tcx>)> = a.unchecked_map(|v| (v, ty));
/// ``` /// ```
pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'gcx, W> { pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, W> {
let Canonical { let Canonical {
max_universe, max_universe,
variables, variables,
@ -294,7 +294,7 @@ impl<'gcx, V> Canonical<'gcx, V> {
pub type QueryRegionConstraint<'tcx> = ty::Binder<ty::OutlivesPredicate<Kind<'tcx>, Region<'tcx>>>; pub type QueryRegionConstraint<'tcx> = ty::Binder<ty::OutlivesPredicate<Kind<'tcx>, Region<'tcx>>>;
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// Creates a substitution S for the canonical value with fresh /// Creates a substitution S for the canonical value with fresh
/// inference variables and applies it to the canonical value. /// inference variables and applies it to the canonical value.
/// Returns both the instantiated result *and* the substitution S. /// Returns both the instantiated result *and* the substitution S.
@ -478,7 +478,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
/// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]` /// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]`
/// we'll return a substitution `subst` with: /// we'll return a substitution `subst` with:
/// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`. /// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`.
pub fn make_identity(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Self { pub fn make_identity(&self, tcx: TyCtxt<'tcx>) -> Self {
use crate::ty::subst::UnpackedKind; use crate::ty::subst::UnpackedKind;
CanonicalVarValues { CanonicalVarValues {

View file

@ -29,7 +29,7 @@ use crate::ty::subst::{Kind, UnpackedKind};
use crate::ty::{self, BoundVar, InferConst, Lift, Ty, TyCtxt}; use crate::ty::{self, BoundVar, InferConst, Lift, Ty, TyCtxt};
use crate::util::captures::Captures; use crate::util::captures::Captures;
impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { impl<'tcx> InferCtxtBuilder<'tcx> {
/// The "main method" for a canonicalized trait query. Given the /// The "main method" for a canonicalized trait query. Given the
/// canonical key `canonical_key`, this method will create a new /// canonical key `canonical_key`, this method will create a new
/// inference context, instantiate the key, and run your operation /// inference context, instantiate the key, and run your operation
@ -42,20 +42,20 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
/// ///
/// (It might be mildly nicer to implement this on `TyCtxt`, and /// (It might be mildly nicer to implement this on `TyCtxt`, and
/// not `InferCtxtBuilder`, but that is a bit tricky right now. /// not `InferCtxtBuilder`, but that is a bit tricky right now.
/// In part because we would need a `for<'gcx: 'tcx>` sort of /// In part because we would need a `for<'tcx>` sort of
/// bound for the closure and in part because it is convenient to /// bound for the closure and in part because it is convenient to
/// have `'tcx` be free on this function so that we can talk about /// have `'tcx` be free on this function so that we can talk about
/// `K: TypeFoldable<'tcx>`.) /// `K: TypeFoldable<'tcx>`.)
pub fn enter_canonical_trait_query<K, R>( pub fn enter_canonical_trait_query<K, R>(
&'tcx mut self, &mut self,
canonical_key: &Canonical<'tcx, K>, canonical_key: &Canonical<'tcx, K>,
operation: impl FnOnce(&InferCtxt<'_, 'gcx, 'tcx>, &mut dyn TraitEngine<'tcx>, K) operation: impl FnOnce(&InferCtxt<'_, 'tcx>, &mut dyn TraitEngine<'tcx>, K)
-> Fallible<R>, -> Fallible<R>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, R>> ) -> Fallible<CanonicalizedQueryResponse<'tcx, R>>
where where
K: TypeFoldable<'tcx>, K: TypeFoldable<'tcx>,
R: Debug + Lift<'gcx> + TypeFoldable<'tcx>, R: Debug + Lift<'tcx> + TypeFoldable<'tcx>,
Canonical<'gcx, <QueryResponse<'gcx, R> as Lift<'gcx>>::Lifted>: ArenaAllocatable, Canonical<'tcx, <QueryResponse<'tcx, R> as Lift<'tcx>>::Lifted>: ArenaAllocatable,
{ {
self.enter_with_canonical( self.enter_with_canonical(
DUMMY_SP, DUMMY_SP,
@ -73,7 +73,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
} }
} }
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// This method is meant to be invoked as the final step of a canonical query /// This method is meant to be invoked as the final step of a canonical query
/// implementation. It is given: /// implementation. It is given:
/// ///
@ -98,10 +98,10 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
inference_vars: CanonicalVarValues<'tcx>, inference_vars: CanonicalVarValues<'tcx>,
answer: T, answer: T,
fulfill_cx: &mut dyn TraitEngine<'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, T>> ) -> Fallible<CanonicalizedQueryResponse<'tcx, T>>
where where
T: Debug + Lift<'gcx> + TypeFoldable<'tcx>, T: Debug + Lift<'tcx> + TypeFoldable<'tcx>,
Canonical<'gcx, <QueryResponse<'gcx, T> as Lift<'gcx>>::Lifted>: ArenaAllocatable, Canonical<'tcx, <QueryResponse<'tcx, T> as Lift<'tcx>>::Lifted>: ArenaAllocatable,
{ {
let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?; let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?;
let canonical_result = self.canonicalize_response(&query_response); let canonical_result = self.canonicalize_response(&query_response);
@ -127,9 +127,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
&self, &self,
inference_vars: CanonicalVarValues<'tcx>, inference_vars: CanonicalVarValues<'tcx>,
answer: T answer: T
) -> Canonical<'gcx, QueryResponse<'gcx, <T as Lift<'gcx>>::Lifted>> ) -> Canonical<'tcx, QueryResponse<'tcx, <T as Lift<'tcx>>::Lifted>>
where where
T: Debug + Lift<'gcx> + TypeFoldable<'tcx>, T: Debug + Lift<'tcx> + TypeFoldable<'tcx>,
{ {
self.canonicalize_response(&QueryResponse { self.canonicalize_response(&QueryResponse {
var_values: inference_vars, var_values: inference_vars,
@ -148,7 +148,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
fulfill_cx: &mut dyn TraitEngine<'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx>,
) -> Result<QueryResponse<'tcx, T>, NoSolution> ) -> Result<QueryResponse<'tcx, T>, NoSolution>
where where
T: Debug + TypeFoldable<'tcx> + Lift<'gcx>, T: Debug + TypeFoldable<'tcx> + Lift<'tcx>,
{ {
let tcx = self.tcx; let tcx = self.tcx;
@ -567,7 +567,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
unsubstituted_region_constraints: &'a [QueryRegionConstraint<'tcx>], unsubstituted_region_constraints: &'a [QueryRegionConstraint<'tcx>],
result_subst: &'a CanonicalVarValues<'tcx>, result_subst: &'a CanonicalVarValues<'tcx>,
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'gcx> { ) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
unsubstituted_region_constraints unsubstituted_region_constraints
.iter() .iter()
.map(move |constraint| { .map(move |constraint| {
@ -647,7 +647,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
/// Given the region obligations and constraints scraped from the infcx, /// Given the region obligations and constraints scraped from the infcx,
/// creates query region constraints. /// creates query region constraints.
pub fn make_query_outlives<'tcx>( pub fn make_query_outlives<'tcx>(
tcx: TyCtxt<'_, 'tcx>, tcx: TyCtxt<'tcx>,
outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>)>, outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>)>,
region_constraints: &RegionConstraintData<'tcx>, region_constraints: &RegionConstraintData<'tcx>,
) -> Vec<QueryRegionConstraint<'tcx>> { ) -> Vec<QueryRegionConstraint<'tcx>> {

View file

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

View file

@ -44,8 +44,8 @@ use syntax::ast;
use syntax_pos::{Span, DUMMY_SP}; use syntax_pos::{Span, DUMMY_SP};
#[derive(Clone)] #[derive(Clone)]
pub struct CombineFields<'infcx, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { pub struct CombineFields<'infcx, 'tcx: 'infcx> {
pub infcx: &'infcx InferCtxt<'infcx, 'gcx, 'tcx>, pub infcx: &'infcx InferCtxt<'infcx, 'tcx>,
pub trace: TypeTrace<'tcx>, pub trace: TypeTrace<'tcx>,
pub cause: Option<ty::relate::Cause>, pub cause: Option<ty::relate::Cause>,
pub param_env: ty::ParamEnv<'tcx>, pub param_env: ty::ParamEnv<'tcx>,
@ -57,7 +57,7 @@ pub enum RelationDir {
SubtypeOf, SupertypeOf, EqTo SubtypeOf, SupertypeOf, EqTo
} }
impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> { impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
pub fn super_combine_tys<R>( pub fn super_combine_tys<R>(
&self, &self,
relation: &mut R, relation: &mut R,
@ -65,7 +65,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
b: Ty<'tcx>, b: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>> ) -> RelateResult<'tcx, Ty<'tcx>>
where where
R: TypeRelation<'gcx, 'tcx>, R: TypeRelation<'tcx>,
{ {
let a_is_expected = relation.a_is_expected(); let a_is_expected = relation.a_is_expected();
@ -125,7 +125,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
b: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>,
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
where where
R: TypeRelation<'gcx, 'tcx>, R: TypeRelation<'tcx>,
{ {
let a_is_expected = relation.a_is_expected(); let a_is_expected = relation.a_is_expected();
@ -208,24 +208,24 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
} }
} }
impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> { impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { pub fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'gcx, 'tcx> { pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'tcx> {
Equate::new(self, a_is_expected) Equate::new(self, a_is_expected)
} }
pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'gcx, 'tcx> { pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'tcx> {
Sub::new(self, a_is_expected) Sub::new(self, a_is_expected)
} }
pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'gcx, 'tcx> { pub fn lub<'a>(&'a mut self, a_is_expected: bool) -> Lub<'a, 'infcx, 'tcx> {
Lub::new(self, a_is_expected) Lub::new(self, a_is_expected)
} }
pub fn glb<'a>(&'a mut self, a_is_expected: bool) -> Glb<'a, 'infcx, 'gcx, 'tcx> { pub fn glb<'a>(&'a mut self, a_is_expected: bool) -> Glb<'a, 'infcx, 'tcx> {
Glb::new(self, a_is_expected) Glb::new(self, a_is_expected)
} }
@ -355,8 +355,8 @@ impl<'infcx, 'gcx, 'tcx> CombineFields<'infcx, 'gcx, 'tcx> {
} }
} }
struct Generalizer<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> { struct Generalizer<'cx, 'tcx: 'cx> {
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
/// The span, used when creating new type variables and things. /// The span, used when creating new type variables and things.
span: Span, span: Span,
@ -415,8 +415,8 @@ struct Generalization<'tcx> {
needs_wf: bool, needs_wf: bool,
} }
impl TypeRelation<'gcx, 'tcx> for Generalizer<'_, 'gcx, 'tcx> { impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -11,23 +11,23 @@ use crate::mir::interpret::ConstValue;
use crate::infer::unify_key::replace_if_possible; use crate::infer::unify_key::replace_if_possible;
/// Ensures `a` is made equal to `b`. Returns `a` on success. /// Ensures `a` is made equal to `b`. Returns `a` on success.
pub struct Equate<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool, a_is_expected: bool,
} }
impl<'combine, 'infcx, 'gcx, 'tcx> Equate<'combine, 'infcx, 'gcx, 'tcx> { impl<'combine, 'infcx, 'tcx> Equate<'combine, 'infcx, 'tcx> {
pub fn new(fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Equate<'combine, 'infcx, 'gcx, 'tcx> -> Equate<'combine, 'infcx, 'tcx>
{ {
Equate { fields: fields, a_is_expected: a_is_expected } Equate { fields: fields, a_is_expected: a_is_expected }
} }
} }
impl TypeRelation<'gcx, 'tcx> for Equate<'combine, 'infcx, 'gcx, 'tcx> { impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
fn tag(&self) -> &'static str { "Equate" } fn tag(&self) -> &'static str { "Equate" }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() } fn tcx(&self) -> TyCtxt<'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }

View file

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

View file

@ -9,16 +9,16 @@ use syntax::source_map::CompilerDesugaringKind;
use syntax_pos::Span; use syntax_pos::Span;
use errors::DiagnosticBuilder; use errors::DiagnosticBuilder;
struct FindLocalByTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { struct FindLocalByTypeVisitor<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
target_ty: Ty<'tcx>, target_ty: Ty<'tcx>,
hir_map: &'a hir::map::Map<'gcx>, hir_map: &'a hir::map::Map<'tcx>,
found_local_pattern: Option<&'gcx Pat>, found_local_pattern: Option<&'tcx Pat>,
found_arg_pattern: Option<&'gcx Pat>, found_arg_pattern: Option<&'tcx Pat>,
found_ty: Option<Ty<'tcx>>, found_ty: Option<Ty<'tcx>>,
} }
impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> {
fn node_matches_type(&mut self, hir_id: HirId) -> Option<Ty<'tcx>> { fn node_matches_type(&mut self, hir_id: HirId) -> Option<Ty<'tcx>> {
let ty_opt = self.infcx.in_progress_tables.and_then(|tables| { let ty_opt = self.infcx.in_progress_tables.and_then(|tables| {
tables.borrow().node_type_opt(hir_id) tables.borrow().node_type_opt(hir_id)
@ -47,12 +47,12 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.hir_map) NestedVisitorMap::OnlyBodies(&self.hir_map)
} }
fn visit_local(&mut self, local: &'gcx Local) { fn visit_local(&mut self, local: &'tcx Local) {
if let (None, Some(ty)) = (self.found_local_pattern, self.node_matches_type(local.hir_id)) { if let (None, Some(ty)) = (self.found_local_pattern, self.node_matches_type(local.hir_id)) {
self.found_local_pattern = Some(&*local.pat); self.found_local_pattern = Some(&*local.pat);
self.found_ty = Some(ty); self.found_ty = Some(ty);
@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
intravisit::walk_local(self, local); intravisit::walk_local(self, local);
} }
fn visit_body(&mut self, body: &'gcx Body) { fn visit_body(&mut self, body: &'tcx Body) {
for argument in &body.arguments { for argument in &body.arguments {
if let (None, Some(ty)) = ( if let (None, Some(ty)) = (
self.found_arg_pattern, self.found_arg_pattern,
@ -75,7 +75,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn extract_type_name( pub fn extract_type_name(
&self, &self,
ty: Ty<'tcx>, ty: Ty<'tcx>,
@ -103,7 +103,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
body_id: Option<hir::BodyId>, body_id: Option<hir::BodyId>,
span: Span, span: Span,
ty: Ty<'tcx> ty: Ty<'tcx>
) -> DiagnosticBuilder<'gcx> { ) -> DiagnosticBuilder<'tcx> {
let ty = self.resolve_vars_if_possible(&ty); let ty = self.resolve_vars_if_possible(&ty);
let name = self.extract_type_name(&ty, None); let name = self.extract_type_name(&ty, None);
@ -230,7 +230,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
&self, &self,
span: Span, span: Span,
ty: Ty<'tcx> ty: Ty<'tcx>
) -> DiagnosticBuilder<'gcx> { ) -> DiagnosticBuilder<'tcx> {
let ty = self.resolve_vars_if_possible(&ty); let ty = self.resolve_vars_if_possible(&ty);
let name = self.extract_type_name(&ty, None); let name = self.extract_type_name(&ty, None);

View file

@ -5,7 +5,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::error_reporting::nice_region_error::util::AnonymousArgInfo; use crate::infer::error_reporting::nice_region_error::util::AnonymousArgInfo;
use crate::util::common::ErrorReported; use crate::util::common::ErrorReported;
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when both the concerned regions are anonymous. /// Print the error message for lifetime errors when both the concerned regions are anonymous.
/// ///
/// Consider a case where we have /// Consider a case where we have

View file

@ -5,7 +5,7 @@ use crate::middle::resolve_lifetime as rl;
use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::error_reporting::nice_region_error::NiceRegionError;
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// This function calls the `visit_ty` method for the parameters /// This function calls the `visit_ty` method for the parameters
/// corresponding to the anonymous regions. The `nested_visitor.found_type` /// corresponding to the anonymous regions. The `nested_visitor.found_type`
/// contains the anonymous type. /// contains the anonymous type.
@ -60,9 +60,9 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
// to the anonymous region. // to the anonymous region.
fn find_component_for_bound_region( fn find_component_for_bound_region(
&self, &self,
arg: &'gcx hir::Ty, arg: &'tcx hir::Ty,
br: &ty::BoundRegion, br: &ty::BoundRegion,
) -> Option<(&'gcx hir::Ty)> { ) -> Option<(&'tcx hir::Ty)> {
let mut nested_visitor = FindNestedTypeVisitor { let mut nested_visitor = FindNestedTypeVisitor {
tcx: self.tcx(), tcx: self.tcx(),
bound_region: *br, bound_region: *br,
@ -81,23 +81,23 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
// walk the types like &mut Vec<&u8> and &u8 looking for the HIR // walk the types like &mut Vec<&u8> and &u8 looking for the HIR
// where that lifetime appears. This allows us to highlight the // where that lifetime appears. This allows us to highlight the
// specific part of the type in the error message. // specific part of the type in the error message.
struct FindNestedTypeVisitor<'gcx, 'tcx> { struct FindNestedTypeVisitor<'tcx> {
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
// The bound_region corresponding to the Refree(freeregion) // The bound_region corresponding to the Refree(freeregion)
// associated with the anonymous region we are looking for. // associated with the anonymous region we are looking for.
bound_region: ty::BoundRegion, bound_region: ty::BoundRegion,
// The type where the anonymous lifetime appears // The type where the anonymous lifetime appears
// for e.g., Vec<`&u8`> and <`&u8`> // for e.g., Vec<`&u8`> and <`&u8`>
found_type: Option<&'gcx hir::Ty>, found_type: Option<&'tcx hir::Ty>,
current_index: ty::DebruijnIndex, current_index: ty::DebruijnIndex,
} }
impl Visitor<'gcx> for FindNestedTypeVisitor<'gcx, 'tcx> { impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_ty(&mut self, arg: &'gcx hir::Ty) { fn visit_ty(&mut self, arg: &'tcx hir::Ty) {
match arg.node { match arg.node {
hir::TyKind::BareFn(_) => { hir::TyKind::BareFn(_) => {
self.current_index.shift_in(1); self.current_index.shift_in(1);
@ -208,15 +208,15 @@ impl Visitor<'gcx> for FindNestedTypeVisitor<'gcx, 'tcx> {
// and would walk the types like Vec<Ref> in the above example and Ref looking for the HIR // and would walk the types like Vec<Ref> in the above example and Ref looking for the HIR
// where that lifetime appears. This allows us to highlight the // where that lifetime appears. This allows us to highlight the
// specific part of the type in the error message. // specific part of the type in the error message.
struct TyPathVisitor<'gcx, 'tcx> { struct TyPathVisitor<'tcx> {
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
found_it: bool, found_it: bool,
bound_region: ty::BoundRegion, bound_region: ty::BoundRegion,
current_index: ty::DebruijnIndex, current_index: ty::DebruijnIndex,
} }
impl Visitor<'gcx> for TyPathVisitor<'gcx, 'tcx> { impl Visitor<'tcx> for TyPathVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
@ -267,7 +267,7 @@ impl Visitor<'gcx> for TyPathVisitor<'gcx, 'tcx> {
} }
} }
fn visit_ty(&mut self, arg: &'gcx hir::Ty) { fn visit_ty(&mut self, arg: &'tcx hir::Ty) {
// ignore nested types // ignore nested types
// //
// If you have a type like `Foo<'a, &Ty>` we // If you have a type like `Foo<'a, &Ty>` we

View file

@ -14,7 +14,7 @@ mod outlives_closure;
mod static_impl_trait; mod static_impl_trait;
mod util; mod util;
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
pub fn try_report_nice_region_error(&self, error: &RegionResolutionError<'tcx>) -> bool { pub fn try_report_nice_region_error(&self, error: &RegionResolutionError<'tcx>) -> bool {
match *error { match *error {
ConcreteFailure(..) | SubSupConflict(..) => {} ConcreteFailure(..) | SubSupConflict(..) => {}
@ -30,16 +30,16 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
} }
} }
pub struct NiceRegionError<'cx, 'gcx: 'tcx, 'tcx: 'cx> { pub struct NiceRegionError<'cx, 'tcx: 'cx> {
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
error: Option<RegionResolutionError<'tcx>>, error: Option<RegionResolutionError<'tcx>>,
regions: Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)>, regions: Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)>,
tables: Option<&'cx ty::TypeckTables<'tcx>>, tables: Option<&'cx ty::TypeckTables<'tcx>>,
} }
impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> {
pub fn new( pub fn new(
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
error: RegionResolutionError<'tcx>, error: RegionResolutionError<'tcx>,
tables: Option<&'cx ty::TypeckTables<'tcx>>, tables: Option<&'cx ty::TypeckTables<'tcx>>,
) -> Self { ) -> Self {
@ -47,7 +47,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {
} }
pub fn new_from_span( pub fn new_from_span(
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
span: Span, span: Span,
sub: ty::Region<'tcx>, sub: ty::Region<'tcx>,
sup: ty::Region<'tcx>, sup: ty::Region<'tcx>,
@ -56,7 +56,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {
Self { infcx, error: None, regions: Some((span, sub, sup)), tables } Self { infcx, error: None, regions: Some((span, sub, sup)), tables }
} }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -5,7 +5,7 @@ use crate::hir::{FunctionRetTy, TyKind};
use crate::ty; use crate::ty;
use errors::{Applicability, DiagnosticBuilder}; use errors::{Applicability, DiagnosticBuilder};
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// When given a `ConcreteFailure` for a function with arguments containing a named region and /// When given a `ConcreteFailure` for a function with arguments containing a named region and
/// an anonymous region, emit an descriptive diagnostic error. /// an anonymous region, emit an descriptive diagnostic error.
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'a>> { pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'a>> {

View file

@ -9,7 +9,7 @@ use crate::hir::Node;
use crate::util::common::ErrorReported; use crate::util::common::ErrorReported;
use crate::infer::lexical_region_resolve::RegionResolutionError::SubSupConflict; use crate::infer::lexical_region_resolve::RegionResolutionError::SubSupConflict;
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when binding escapes a closure. /// Print the error message for lifetime errors when binding escapes a closure.
/// ///
/// Consider a case where we have /// Consider a case where we have

View file

@ -13,7 +13,7 @@ use crate::ty::print::{Print, RegionHighlightMode, FmtPrinter};
use std::fmt::{self, Write}; use std::fmt::{self, Write};
impl NiceRegionError<'me, 'gcx, 'tcx> { impl NiceRegionError<'me, 'tcx> {
/// When given a `ConcreteFailure` for a function with arguments containing a named region and /// When given a `ConcreteFailure` for a function with arguments containing a named region and
/// an anonymous region, emit a descriptive diagnostic error. /// an anonymous region, emit a descriptive diagnostic error.
pub(super) fn try_report_placeholder_conflict(&self) -> Option<DiagnosticBuilder<'me>> { pub(super) fn try_report_placeholder_conflict(&self) -> Option<DiagnosticBuilder<'me>> {
@ -321,14 +321,14 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
) { ) {
// HACK(eddyb) maybe move this in a more central location. // HACK(eddyb) maybe move this in a more central location.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct Highlighted<'gcx, 'tcx, T> { struct Highlighted<'tcx, T> {
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
highlight: RegionHighlightMode, highlight: RegionHighlightMode,
value: T, value: T,
} }
impl<'gcx, 'tcx, T> Highlighted<'gcx, 'tcx, T> { impl<'tcx, T> Highlighted<'tcx, T> {
fn map<U>(self, f: impl FnOnce(T) -> U) -> Highlighted<'gcx, 'tcx, U> { fn map<U>(self, f: impl FnOnce(T) -> U) -> Highlighted<'tcx, U> {
Highlighted { Highlighted {
tcx: self.tcx, tcx: self.tcx,
highlight: self.highlight, highlight: self.highlight,
@ -337,12 +337,11 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
} }
} }
impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T> impl<'tcx, T> fmt::Display for Highlighted<'tcx, T>
where where
T: for<'a, 'b, 'c> Print< T: for<'a, 'b, 'c> Print<
'gcx,
'tcx, 'tcx,
FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>, FmtPrinter<'a, 'tcx, &'b mut fmt::Formatter<'c>>,
Error = fmt::Error, Error = fmt::Error,
>, >,
{ {

View file

@ -6,7 +6,7 @@ use crate::ty::{BoundRegion, FreeRegion, RegionKind};
use crate::util::common::ErrorReported; use crate::util::common::ErrorReported;
use errors::Applicability; use errors::Applicability;
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when the return type is a static impl Trait. /// Print the error message for lifetime errors when the return type is a static impl Trait.
pub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorReported> { pub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorReported> {
if let Some(ref error) = self.error { if let Some(ref error) = self.error {

View file

@ -24,7 +24,7 @@ pub(super) struct AnonymousArgInfo<'tcx> {
pub is_first: bool, pub is_first: bool,
} }
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
// This method walks the Type of the function body arguments using // This method walks the Type of the function body arguments using
// `fold_regions()` function and returns the // `fold_regions()` function and returns the
// &hir::Arg of the function argument corresponding to the anonymous // &hir::Arg of the function argument corresponding to the anonymous

View file

@ -4,7 +4,7 @@ use crate::ty::{self, Region};
use crate::ty::error::TypeError; use crate::ty::error::TypeError;
use errors::DiagnosticBuilder; use errors::DiagnosticBuilder;
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub(super) fn note_region_origin(&self, pub(super) fn note_region_origin(&self,
err: &mut DiagnosticBuilder<'_>, err: &mut DiagnosticBuilder<'_>,
origin: &SubregionOrigin<'tcx>) { origin: &SubregionOrigin<'tcx>) {

View file

@ -41,17 +41,17 @@ use std::collections::hash_map::Entry;
use super::InferCtxt; use super::InferCtxt;
use super::unify_key::ToType; use super::unify_key::ToType;
pub struct TypeFreshener<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct TypeFreshener<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
ty_freshen_count: u32, ty_freshen_count: u32,
const_freshen_count: u32, const_freshen_count: u32,
ty_freshen_map: FxHashMap<ty::InferTy, Ty<'tcx>>, ty_freshen_map: FxHashMap<ty::InferTy, Ty<'tcx>>,
const_freshen_map: FxHashMap<ty::InferConst<'tcx>, &'tcx ty::Const<'tcx>>, const_freshen_map: FxHashMap<ty::InferConst<'tcx>, &'tcx ty::Const<'tcx>>,
} }
impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) pub fn new(infcx: &'a InferCtxt<'a, 'tcx>)
-> TypeFreshener<'a, 'gcx, 'tcx> { -> TypeFreshener<'a, 'tcx> {
TypeFreshener { TypeFreshener {
infcx, infcx,
ty_freshen_count: 0, ty_freshen_count: 0,
@ -113,8 +113,8 @@ impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -22,7 +22,7 @@ fn const_vars_since_snapshot<'tcx>(
}).collect()) }).collect())
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// This rather funky routine is used while processing expected /// This rather funky routine is used while processing expected
/// types. What happens here is that we want to propagate a /// types. What happens here is that we want to propagate a
/// coercion through the return type of a fn to its /// coercion through the return type of a fn to its
@ -133,8 +133,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
} }
pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct InferenceFudger<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>), type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
int_vars: Range<IntVid>, int_vars: Range<IntVid>,
float_vars: Range<FloatVid>, float_vars: Range<FloatVid>,
@ -142,8 +142,8 @@ pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
const_vars: (Range<ConstVid<'tcx>>, Vec<ConstVariableOrigin>), const_vars: (Range<ConstVid<'tcx>>, Vec<ConstVariableOrigin>),
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -8,23 +8,23 @@ use crate::ty::{self, Ty, TyCtxt};
use crate::ty::relate::{Relate, RelateResult, TypeRelation}; use crate::ty::relate::{Relate, RelateResult, TypeRelation};
/// "Greatest lower bound" (common subtype) /// "Greatest lower bound" (common subtype)
pub struct Glb<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool, a_is_expected: bool,
} }
impl<'combine, 'infcx, 'gcx, 'tcx> Glb<'combine, 'infcx, 'gcx, 'tcx> { impl<'combine, 'infcx, 'tcx> Glb<'combine, 'infcx, 'tcx> {
pub fn new(fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Glb<'combine, 'infcx, 'gcx, 'tcx> -> Glb<'combine, 'infcx, 'tcx>
{ {
Glb { fields: fields, a_is_expected: a_is_expected } Glb { fields: fields, a_is_expected: a_is_expected }
} }
} }
impl TypeRelation<'gcx, 'tcx> for Glb<'combine, 'infcx, 'gcx, 'tcx> { impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
fn tag(&self) -> &'static str { "Glb" } fn tag(&self) -> &'static str { "Glb" }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() } fn tcx(&self) -> TyCtxt<'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }
@ -85,10 +85,10 @@ impl TypeRelation<'gcx, 'tcx> for Glb<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl<'combine, 'infcx, 'gcx, 'tcx> LatticeDir<'infcx, 'gcx, 'tcx> impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx>
for Glb<'combine, 'infcx, 'gcx, 'tcx> for Glb<'combine, 'infcx, 'tcx>
{ {
fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'gcx, 'tcx> { fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> {
self.fields.infcx self.fields.infcx
} }

View file

@ -9,7 +9,7 @@ use crate::ty::relate::{Relate, RelateResult, TypeRelation};
use crate::ty::{self, Binder, TypeFoldable}; use crate::ty::{self, Binder, TypeFoldable};
use crate::mir::interpret::ConstValue; use crate::mir::interpret::ConstValue;
impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { impl<'a, 'tcx> CombineFields<'a, 'tcx> {
pub fn higher_ranked_sub<T>( pub fn higher_ranked_sub<T>(
&mut self, &mut self,
a: &Binder<T>, a: &Binder<T>,
@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// Replaces all regions (resp. types) bound by `binder` with placeholder /// Replaces all regions (resp. types) bound by `binder` with placeholder
/// regions (resp. types) and return a map indicating which bound-region /// regions (resp. types) and return a map indicating which bound-region
/// placeholder region. This is the first step of checking subtyping /// placeholder region. This is the first step of checking subtyping

View file

@ -27,8 +27,8 @@ use crate::ty::TyVar;
use crate::ty::{self, Ty}; use crate::ty::{self, Ty};
use crate::ty::relate::{RelateResult, TypeRelation}; use crate::ty::relate::{RelateResult, TypeRelation};
pub trait LatticeDir<'f, 'gcx: 'f + 'tcx, 'tcx: 'f>: TypeRelation<'gcx, 'tcx> { pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> {
fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>; fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
fn cause(&self) -> &ObligationCause<'tcx>; fn cause(&self) -> &ObligationCause<'tcx>;
@ -41,11 +41,11 @@ pub trait LatticeDir<'f, 'gcx: 'f + 'tcx, 'tcx: 'f>: TypeRelation<'gcx, 'tcx> {
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
} }
pub fn super_lattice_tys<'a, 'gcx, 'tcx, L>(this: &mut L, pub fn super_lattice_tys<'a, 'tcx, L>(this: &mut L,
a: Ty<'tcx>, a: Ty<'tcx>,
b: Ty<'tcx>) b: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>> -> RelateResult<'tcx, Ty<'tcx>>
where L: LatticeDir<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a where L: LatticeDir<'a, 'tcx>, 'tcx: 'a
{ {
debug!("{}.lattice_tys({:?}, {:?})", debug!("{}.lattice_tys({:?}, {:?})",
this.tag(), this.tag(),

View file

@ -44,9 +44,9 @@ graphs will be printed. \n\
"); ");
} }
pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>( pub fn maybe_print_constraints_for<'a, 'tcx>(
region_data: &RegionConstraintData<'tcx>, region_data: &RegionConstraintData<'tcx>,
region_rels: &RegionRelations<'a, 'gcx, 'tcx>) region_rels: &RegionRelations<'a, 'tcx>)
{ {
let tcx = region_rels.tcx; let tcx = region_rels.tcx;
let context = region_rels.context; let context = region_rels.context;
@ -107,9 +107,9 @@ pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>(
} }
} }
struct ConstraintGraph<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { struct ConstraintGraph<'a, 'tcx: 'a> {
graph_name: String, graph_name: String,
region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>, region_rels: &'a RegionRelations<'a, 'tcx>,
map: &'a BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>, map: &'a BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
node_ids: FxHashMap<Node, usize>, node_ids: FxHashMap<Node, usize>,
} }
@ -126,11 +126,11 @@ enum Edge<'tcx> {
EnclScope(region::Scope, region::Scope), EnclScope(region::Scope, region::Scope),
} }
impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> { impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
fn new(name: String, fn new(name: String,
region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>, region_rels: &'a RegionRelations<'a, 'tcx>,
map: &'a ConstraintMap<'tcx>) map: &'a ConstraintMap<'tcx>)
-> ConstraintGraph<'a, 'gcx, 'tcx> { -> ConstraintGraph<'a, 'tcx> {
let mut i = 0; let mut i = 0;
let mut node_ids = FxHashMap::default(); let mut node_ids = FxHashMap::default();
{ {
@ -161,7 +161,7 @@ impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { impl<'a, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'tcx> {
type Node = Node; type Node = Node;
type Edge = Edge<'tcx>; type Edge = Edge<'tcx>;
fn graph_id(&self) -> dot::Id<'_> { fn graph_id(&self) -> dot::Id<'_> {
@ -215,7 +215,7 @@ fn edge_to_nodes(e: &Edge<'_>) -> (Node, Node) {
} }
} }
impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { impl<'a, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'tcx> {
type Node = Node; type Node = Node;
type Edge = Edge<'tcx>; type Edge = Edge<'tcx>;
fn nodes(&self) -> dot::Nodes<'_, Node> { fn nodes(&self) -> dot::Nodes<'_, Node> {
@ -246,7 +246,7 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
pub type ConstraintMap<'tcx> = BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>; pub type ConstraintMap<'tcx> = BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>;
fn dump_region_data_to<'a, 'gcx, 'tcx>(region_rels: &RegionRelations<'a, 'gcx, 'tcx>, fn dump_region_data_to<'a, 'tcx>(region_rels: &RegionRelations<'a, 'tcx>,
map: &ConstraintMap<'tcx>, map: &ConstraintMap<'tcx>,
path: &str) path: &str)
-> io::Result<()> { -> io::Result<()> {

View file

@ -30,7 +30,7 @@ mod graphviz;
/// assuming such values can be found. It returns the final values of /// assuming such values can be found. It returns the final values of
/// all the variables as well as a set of errors that must be reported. /// all the variables as well as a set of errors that must be reported.
pub fn resolve<'tcx>( pub fn resolve<'tcx>(
region_rels: &RegionRelations<'_, '_, 'tcx>, region_rels: &RegionRelations<'_, 'tcx>,
var_infos: VarInfos, var_infos: VarInfos,
data: RegionConstraintData<'tcx>, data: RegionConstraintData<'tcx>,
) -> ( ) -> (
@ -96,14 +96,14 @@ struct RegionAndOrigin<'tcx> {
type RegionGraph<'tcx> = Graph<(), Constraint<'tcx>>; type RegionGraph<'tcx> = Graph<(), Constraint<'tcx>>;
struct LexicalResolver<'cx, 'gcx: 'tcx, 'tcx: 'cx> { struct LexicalResolver<'cx, 'tcx: 'cx> {
region_rels: &'cx RegionRelations<'cx, 'gcx, 'tcx>, region_rels: &'cx RegionRelations<'cx, 'tcx>,
var_infos: VarInfos, var_infos: VarInfos,
data: RegionConstraintData<'tcx>, data: RegionConstraintData<'tcx>,
} }
impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.region_rels.tcx self.region_rels.tcx
} }
@ -136,14 +136,14 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
/// Initially, the value for all variables is set to `'empty`, the /// Initially, the value for all variables is set to `'empty`, the
/// empty region. The `expansion` phase will grow this larger. /// empty region. The `expansion` phase will grow this larger.
fn construct_var_data(&self, tcx: TyCtxt<'_, 'tcx>) -> LexicalRegionResolutions<'tcx> { fn construct_var_data(&self, tcx: TyCtxt<'tcx>) -> LexicalRegionResolutions<'tcx> {
LexicalRegionResolutions { LexicalRegionResolutions {
error_region: tcx.lifetimes.re_static, error_region: tcx.lifetimes.re_static,
values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars()) values: IndexVec::from_elem_n(VarValue::Value(tcx.lifetimes.re_empty), self.num_vars())
} }
} }
fn dump_constraints(&self, free_regions: &RegionRelations<'_, '_, 'tcx>) { fn dump_constraints(&self, free_regions: &RegionRelations<'_, 'tcx>) {
debug!( debug!(
"----() Start constraint listing (context={:?}) ()----", "----() Start constraint listing (context={:?}) ()----",
free_regions.context free_regions.context
@ -785,7 +785,7 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> {
} }
impl<'tcx> LexicalRegionResolutions<'tcx> { impl<'tcx> LexicalRegionResolutions<'tcx> {
fn normalize<T>(&self, tcx: TyCtxt<'_, 'tcx>, value: T) -> T fn normalize<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
where where
T: TypeFoldable<'tcx>, T: TypeFoldable<'tcx>,
{ {

View file

@ -8,23 +8,23 @@ use crate::ty::{self, Ty, TyCtxt};
use crate::ty::relate::{Relate, RelateResult, TypeRelation}; use crate::ty::relate::{Relate, RelateResult, TypeRelation};
/// "Least upper bound" (common supertype) /// "Least upper bound" (common supertype)
pub struct Lub<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool, a_is_expected: bool,
} }
impl<'combine, 'infcx, 'gcx, 'tcx> Lub<'combine, 'infcx, 'gcx, 'tcx> { impl<'combine, 'infcx, 'tcx> Lub<'combine, 'infcx, 'tcx> {
pub fn new(fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Lub<'combine, 'infcx, 'gcx, 'tcx> -> Lub<'combine, 'infcx, 'tcx>
{ {
Lub { fields: fields, a_is_expected: a_is_expected } Lub { fields: fields, a_is_expected: a_is_expected }
} }
} }
impl TypeRelation<'gcx, 'tcx> for Lub<'combine, 'infcx, 'gcx, 'tcx> { impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> {
fn tag(&self) -> &'static str { "Lub" } fn tag(&self) -> &'static str { "Lub" }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.tcx() } fn tcx(&self) -> TyCtxt<'tcx> { self.fields.tcx() }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }
@ -85,10 +85,10 @@ impl TypeRelation<'gcx, 'tcx> for Lub<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl<'combine, 'infcx, 'gcx, 'tcx> LatticeDir<'infcx, 'gcx, 'tcx> impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx>
for Lub<'combine, 'infcx, 'gcx, 'tcx> for Lub<'combine, 'infcx, 'tcx>
{ {
fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'gcx, 'tcx> { fn infcx(&self) -> &'infcx InferCtxt<'infcx, 'tcx> {
self.fields.infcx self.fields.infcx
} }

View file

@ -91,7 +91,7 @@ impl SuppressRegionErrors {
/// Indicates that the MIR borrowck will repeat these region /// Indicates that the MIR borrowck will repeat these region
/// checks, so we should ignore errors if NLL is (unconditionally) /// checks, so we should ignore errors if NLL is (unconditionally)
/// enabled. /// enabled.
pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_>) -> Self { pub fn when_nll_is_enabled(tcx: TyCtxt<'_>) -> Self {
match tcx.borrowck_mode() { match tcx.borrowck_mode() {
// If we're on Migrate mode, report AST region errors // If we're on Migrate mode, report AST region errors
BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false },
@ -102,8 +102,8 @@ impl SuppressRegionErrors {
} }
} }
pub struct InferCtxt<'a, 'gcx, 'tcx> { pub struct InferCtxt<'a, 'tcx> {
pub tcx: TyCtxt<'gcx, 'tcx>, pub tcx: TyCtxt<'tcx>,
/// During type-checking/inference of a body, `in_progress_tables` /// During type-checking/inference of a body, `in_progress_tables`
/// contains a reference to the tables being built up, which are /// contains a reference to the tables being built up, which are
@ -464,14 +464,14 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
/// Helper type of a temporary returned by `tcx.infer_ctxt()`. /// Helper type of a temporary returned by `tcx.infer_ctxt()`.
/// Necessary because we can't write the following bound: /// Necessary because we can't write the following bound:
/// `F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>)`. /// `F: for<'b, 'tcx> where 'tcx FnOnce(InferCtxt<'b, 'tcx>)`.
pub struct InferCtxtBuilder<'gcx: 'tcx, 'tcx> { pub struct InferCtxtBuilder<'tcx> {
global_tcx: TyCtxt<'gcx, 'gcx>, global_tcx: TyCtxt<'tcx>,
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>, fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
} }
impl TyCtxt<'gcx, 'gcx> { impl TyCtxt<'tcx> {
pub fn infer_ctxt<'tcx>(self) -> InferCtxtBuilder<'gcx, 'tcx> { pub fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
InferCtxtBuilder { InferCtxtBuilder {
global_tcx: self, global_tcx: self,
fresh_tables: None, fresh_tables: None,
@ -479,7 +479,7 @@ impl TyCtxt<'gcx, 'gcx> {
} }
} }
impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> { impl<'tcx> InferCtxtBuilder<'tcx> {
/// Used only by `rustc_typeck` during body type-checking/inference, /// Used only by `rustc_typeck` during body type-checking/inference,
/// will initialize `in_progress_tables` with fresh `TypeckTables`. /// will initialize `in_progress_tables` with fresh `TypeckTables`.
pub fn with_fresh_in_progress_tables(mut self, table_owner: DefId) -> Self { pub fn with_fresh_in_progress_tables(mut self, table_owner: DefId) -> Self {
@ -495,10 +495,10 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
/// the bound values in `C` to their instantiated values in `V` /// the bound values in `C` to their instantiated values in `V`
/// (in other words, `S(C) = V`). /// (in other words, `S(C) = V`).
pub fn enter_with_canonical<T, R>( pub fn enter_with_canonical<T, R>(
&'tcx mut self, &mut self,
span: Span, span: Span,
canonical: &Canonical<'tcx, T>, canonical: &Canonical<'tcx, T>,
f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>, T, CanonicalVarValues<'tcx>) -> R, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>, T, CanonicalVarValues<'tcx>) -> R,
) -> R ) -> R
where where
T: TypeFoldable<'tcx>, T: TypeFoldable<'tcx>,
@ -510,7 +510,7 @@ impl<'gcx, 'tcx> InferCtxtBuilder<'gcx, 'tcx> {
}) })
} }
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'gcx, 'tcx>) -> R) -> R { pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R {
let InferCtxtBuilder { let InferCtxtBuilder {
global_tcx, global_tcx,
ref fresh_tables, ref fresh_tables,
@ -567,7 +567,7 @@ impl<'tcx, T> InferOk<'tcx, T> {
/// Extracts `value`, registering any obligations into `fulfill_cx`. /// Extracts `value`, registering any obligations into `fulfill_cx`.
pub fn into_value_registering_obligations( pub fn into_value_registering_obligations(
self, self,
infcx: &InferCtxt<'_, '_, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
fulfill_cx: &mut dyn TraitEngine<'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx>,
) -> T { ) -> T {
let InferOk { value, obligations } = self; let InferOk { value, obligations } = self;
@ -598,7 +598,7 @@ pub struct CombinedSnapshot<'a, 'tcx: 'a> {
_in_progress_tables: Option<Ref<'a, ty::TypeckTables<'tcx>>>, _in_progress_tables: Option<Ref<'a, ty::TypeckTables<'tcx>>>,
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn is_in_snapshot(&self) -> bool { pub fn is_in_snapshot(&self) -> bool {
self.in_snapshot.get() self.in_snapshot.get()
} }
@ -614,7 +614,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
} }
pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'gcx, 'tcx> { pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx> {
freshen::TypeFreshener::new(self) freshen::TypeFreshener::new(self)
} }
@ -677,7 +677,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
&'a self, &'a self,
trace: TypeTrace<'tcx>, trace: TypeTrace<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
) -> CombineFields<'a, 'gcx, 'tcx> { ) -> CombineFields<'a, 'tcx> {
CombineFields { CombineFields {
infcx: self, infcx: self,
trace, trace,
@ -1548,13 +1548,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
} }
pub struct ShallowResolver<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct ShallowResolver<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
} }
impl<'a, 'gcx, 'tcx> ShallowResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
#[inline(always)] #[inline(always)]
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
ShallowResolver { infcx } ShallowResolver { infcx }
} }
@ -1599,8 +1599,8 @@ impl<'a, 'gcx, 'tcx> ShallowResolver<'a, 'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -1624,7 +1624,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ShallowResolver<'a, 'gcx, 'tcx>
} }
} }
impl<'gcx, 'tcx> TypeTrace<'tcx> { impl<'tcx> TypeTrace<'tcx> {
pub fn span(&self) -> Span { pub fn span(&self) -> Span {
self.cause.span self.cause.span
} }
@ -1641,7 +1641,7 @@ impl<'gcx, 'tcx> TypeTrace<'tcx> {
} }
} }
pub fn dummy(tcx: TyCtxt<'gcx, 'tcx>) -> TypeTrace<'tcx> { pub fn dummy(tcx: TyCtxt<'tcx>) -> TypeTrace<'tcx> {
TypeTrace { TypeTrace {
cause: ObligationCause::dummy(), cause: ObligationCause::dummy(),
values: Types(ExpectedFound { values: Types(ExpectedFound {

View file

@ -38,11 +38,11 @@ pub enum NormalizationStrategy {
Eager, Eager,
} }
pub struct TypeRelating<'me, 'gcx: 'tcx, 'tcx: 'me, D> pub struct TypeRelating<'me, 'tcx: 'me, D>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
{ {
infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, infcx: &'me InferCtxt<'me, 'tcx>,
/// Callback to use when we deduce an outlives relationship /// Callback to use when we deduce an outlives relationship
delegate: D, delegate: D,
@ -135,12 +135,12 @@ struct BoundRegionScope<'tcx> {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct UniversallyQuantified(bool); struct UniversallyQuantified(bool);
impl<'me, 'gcx, 'tcx, D> TypeRelating<'me, 'gcx, 'tcx, D> impl<'me, 'tcx, D> TypeRelating<'me, 'tcx, D>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
{ {
pub fn new( pub fn new(
infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, infcx: &'me InferCtxt<'me, 'tcx>,
delegate: D, delegate: D,
ambient_variance: ty::Variance, ambient_variance: ty::Variance,
) -> Self { ) -> Self {
@ -416,7 +416,7 @@ trait VidValuePair<'tcx>: Debug {
/// for more details on why we want them. /// for more details on why we want them.
fn vid_scopes<D: TypeRelatingDelegate<'tcx>>( fn vid_scopes<D: TypeRelatingDelegate<'tcx>>(
&self, &self,
relate: &'r mut TypeRelating<'_, '_, 'tcx, D>, relate: &'r mut TypeRelating<'_, 'tcx, D>,
) -> &'r mut Vec<BoundRegionScope<'tcx>>; ) -> &'r mut Vec<BoundRegionScope<'tcx>>;
/// Given a generalized type G that should replace the vid, relate /// Given a generalized type G that should replace the vid, relate
@ -424,7 +424,7 @@ trait VidValuePair<'tcx>: Debug {
/// appeared. /// appeared.
fn relate_generalized_ty<D>( fn relate_generalized_ty<D>(
&self, &self,
relate: &mut TypeRelating<'_, '_, 'tcx, D>, relate: &mut TypeRelating<'_, 'tcx, D>,
generalized_ty: Ty<'tcx>, generalized_ty: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>> ) -> RelateResult<'tcx, Ty<'tcx>>
where where
@ -442,7 +442,7 @@ impl VidValuePair<'tcx> for (ty::TyVid, Ty<'tcx>) {
fn vid_scopes<D>( fn vid_scopes<D>(
&self, &self,
relate: &'r mut TypeRelating<'_, '_, 'tcx, D>, relate: &'r mut TypeRelating<'_, 'tcx, D>,
) -> &'r mut Vec<BoundRegionScope<'tcx>> ) -> &'r mut Vec<BoundRegionScope<'tcx>>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
@ -452,7 +452,7 @@ impl VidValuePair<'tcx> for (ty::TyVid, Ty<'tcx>) {
fn relate_generalized_ty<D>( fn relate_generalized_ty<D>(
&self, &self,
relate: &mut TypeRelating<'_, '_, 'tcx, D>, relate: &mut TypeRelating<'_, 'tcx, D>,
generalized_ty: Ty<'tcx>, generalized_ty: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>> ) -> RelateResult<'tcx, Ty<'tcx>>
where where
@ -474,7 +474,7 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) {
fn vid_scopes<D>( fn vid_scopes<D>(
&self, &self,
relate: &'r mut TypeRelating<'_, '_, 'tcx, D>, relate: &'r mut TypeRelating<'_, 'tcx, D>,
) -> &'r mut Vec<BoundRegionScope<'tcx>> ) -> &'r mut Vec<BoundRegionScope<'tcx>>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
@ -484,7 +484,7 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) {
fn relate_generalized_ty<D>( fn relate_generalized_ty<D>(
&self, &self,
relate: &mut TypeRelating<'_, '_, 'tcx, D>, relate: &mut TypeRelating<'_, 'tcx, D>,
generalized_ty: Ty<'tcx>, generalized_ty: Ty<'tcx>,
) -> RelateResult<'tcx, Ty<'tcx>> ) -> RelateResult<'tcx, Ty<'tcx>>
where where
@ -494,11 +494,11 @@ impl VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) {
} }
} }
impl<D> TypeRelation<'gcx, 'tcx> for TypeRelating<'me, 'gcx, 'tcx, D> impl<D> TypeRelation<'tcx> for TypeRelating<'me, 'tcx, D>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
{ {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -798,11 +798,11 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
/// scopes. /// scopes.
/// ///
/// [blog post]: https://is.gd/0hKvIr /// [blog post]: https://is.gd/0hKvIr
struct TypeGeneralizer<'me, 'gcx: 'tcx, 'tcx: 'me, D> struct TypeGeneralizer<'me, 'tcx: 'me, D>
where where
D: TypeRelatingDelegate<'tcx> + 'me, D: TypeRelatingDelegate<'tcx> + 'me,
{ {
infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, infcx: &'me InferCtxt<'me, 'tcx>,
delegate: &'me mut D, delegate: &'me mut D,
@ -823,11 +823,11 @@ where
universe: ty::UniverseIndex, universe: ty::UniverseIndex,
} }
impl<D> TypeRelation<'gcx, 'tcx> for TypeGeneralizer<'me, 'gcx, 'tcx, D> impl<D> TypeRelation<'tcx> for TypeGeneralizer<'me, 'tcx, D>
where where
D: TypeRelatingDelegate<'tcx>, D: TypeRelatingDelegate<'tcx>,
{ {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -73,7 +73,7 @@ pub struct OpaqueTypeDecl<'tcx> {
pub origin: hir::ExistTyOrigin, pub origin: hir::ExistTyOrigin,
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// Replaces all opaque types in `value` with fresh inference variables /// Replaces all opaque types in `value` with fresh inference variables
/// and creates appropriate obligations. For example, given the input: /// and creates appropriate obligations. For example, given the input:
/// ///
@ -430,8 +430,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
&self, &self,
def_id: DefId, def_id: DefId,
opaque_defn: &OpaqueTypeDecl<'tcx>, opaque_defn: &OpaqueTypeDecl<'tcx>,
instantiated_ty: Ty<'gcx>, instantiated_ty: Ty<'tcx>,
) -> Ty<'gcx> { ) -> Ty<'tcx> {
debug!( debug!(
"infer_opaque_definition_from_instantiation(def_id={:?}, instantiated_ty={:?})", "infer_opaque_definition_from_instantiation(def_id={:?}, instantiated_ty={:?})",
def_id, instantiated_ty def_id, instantiated_ty
@ -446,7 +446,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// `impl Trait` return type, resulting in the parameters // `impl Trait` return type, resulting in the parameters
// shifting. // shifting.
let id_substs = InternalSubsts::identity_for_item(gcx, def_id); let id_substs = InternalSubsts::identity_for_item(gcx, def_id);
let map: FxHashMap<Kind<'tcx>, Kind<'gcx>> = opaque_defn let map: FxHashMap<Kind<'tcx>, Kind<'tcx>> = opaque_defn
.substs .substs
.iter() .iter()
.enumerate() .enumerate()
@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
); );
// We can unwrap here because our reverse mapper always // We can unwrap here because our reverse mapper always
// produces things with 'gcx lifetime, though the type folder // produces things with 'tcx lifetime, though the type folder
// obscures that. // obscures that.
let definition_ty = gcx.lift(&definition_ty).unwrap(); let definition_ty = gcx.lift(&definition_ty).unwrap();
@ -491,14 +491,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// //
// We ignore any type parameters because impl trait values are assumed to // We ignore any type parameters because impl trait values are assumed to
// capture all the in-scope type parameters. // capture all the in-scope type parameters.
struct OpaqueTypeOutlivesVisitor<'a, 'gcx, 'tcx> { struct OpaqueTypeOutlivesVisitor<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
least_region: ty::Region<'tcx>, least_region: ty::Region<'tcx>,
span: Span, span: Span,
} }
impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx> impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, 'tcx> {
{
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> bool { fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> bool {
t.skip_binder().visit_with(self); t.skip_binder().visit_with(self);
false // keep visiting false // keep visiting
@ -552,27 +551,27 @@ impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx>
} }
} }
struct ReverseMapper<'gcx, 'tcx> { struct ReverseMapper<'tcx> {
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
/// If errors have already been reported in this fn, we suppress /// If errors have already been reported in this fn, we suppress
/// our own errors because they are sometimes derivative. /// our own errors because they are sometimes derivative.
tainted_by_errors: bool, tainted_by_errors: bool,
opaque_type_def_id: DefId, opaque_type_def_id: DefId,
map: FxHashMap<Kind<'tcx>, Kind<'gcx>>, map: FxHashMap<Kind<'tcx>, Kind<'tcx>>,
map_missing_regions_to_empty: bool, map_missing_regions_to_empty: bool,
/// initially `Some`, set to `None` once error has been reported /// initially `Some`, set to `None` once error has been reported
hidden_ty: Option<Ty<'tcx>>, hidden_ty: Option<Ty<'tcx>>,
} }
impl ReverseMapper<'gcx, 'tcx> { impl ReverseMapper<'tcx> {
fn new( fn new(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
tainted_by_errors: bool, tainted_by_errors: bool,
opaque_type_def_id: DefId, opaque_type_def_id: DefId,
map: FxHashMap<Kind<'tcx>, Kind<'gcx>>, map: FxHashMap<Kind<'tcx>, Kind<'tcx>>,
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
) -> Self { ) -> Self {
Self { Self {
@ -599,8 +598,8 @@ impl ReverseMapper<'gcx, 'tcx> {
} }
} }
impl TypeFolder<'gcx, 'tcx> for ReverseMapper<'gcx, 'tcx> { impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }
@ -724,8 +723,8 @@ impl TypeFolder<'gcx, 'tcx> for ReverseMapper<'gcx, 'tcx> {
} }
} }
struct Instantiator<'a, 'gcx: 'tcx, 'tcx: 'a> { struct Instantiator<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
parent_def_id: DefId, parent_def_id: DefId,
body_id: hir::HirId, body_id: hir::HirId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
@ -733,7 +732,7 @@ struct Instantiator<'a, 'gcx: 'tcx, 'tcx: 'a> {
obligations: Vec<PredicateObligation<'tcx>>, obligations: Vec<PredicateObligation<'tcx>>,
} }
impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { impl<'a, 'tcx> Instantiator<'a, 'tcx> {
fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: &T) -> T { fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: &T) -> T {
debug!("instantiate_opaque_types_in_map(value={:?})", value); debug!("instantiate_opaque_types_in_map(value={:?})", value);
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
@ -944,7 +943,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
/// and `opaque_hir_id` is the `HirId` of the definition of the existential type `Baz`. /// 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`. /// For the above example, this function returns `true` for `f1` and `false` for `f2`.
pub fn may_define_existential_type( pub fn may_define_existential_type(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
def_id: DefId, def_id: DefId,
opaque_hir_id: hir::HirId, opaque_hir_id: hir::HirId,
) -> bool { ) -> bool {

View file

@ -67,7 +67,7 @@ pub struct OutlivesEnvironment<'tcx> {
/// because of implied bounds. /// because of implied bounds.
pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>; pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>;
impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> { impl<'a, 'tcx: 'a> OutlivesEnvironment<'tcx> {
pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self { pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self {
let mut env = OutlivesEnvironment { let mut env = OutlivesEnvironment {
param_env, param_env,
@ -160,7 +160,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> {
/// Tests: `src/test/compile-fail/regions-free-region-ordering-*.rs` /// Tests: `src/test/compile-fail/regions-free-region-ordering-*.rs`
pub fn add_implied_bounds( pub fn add_implied_bounds(
&mut self, &mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>, infcx: &InferCtxt<'a, 'tcx>,
fn_sig_tys: &[Ty<'tcx>], fn_sig_tys: &[Ty<'tcx>],
body_id: hir::HirId, body_id: hir::HirId,
span: Span, span: Span,
@ -192,7 +192,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> {
/// `RegionConstraintData`.) /// `RegionConstraintData`.)
fn add_outlives_bounds<I>( fn add_outlives_bounds<I>(
&mut self, &mut self,
infcx: Option<&InferCtxt<'a, 'gcx, 'tcx>>, infcx: Option<&InferCtxt<'a, 'tcx>>,
outlives_bounds: I, outlives_bounds: I,
) where ) where
I: IntoIterator<Item = OutlivesBound<'tcx>>, I: IntoIterator<Item = OutlivesBound<'tcx>>,

View file

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

View file

@ -69,7 +69,7 @@ use crate::ty::outlives::Component;
use crate::ty::{self, Region, Ty, TyCtxt, TypeFoldable}; use crate::ty::{self, Region, Ty, TyCtxt, TypeFoldable};
use crate::ty::subst::UnpackedKind; use crate::ty::subst::UnpackedKind;
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// Registers that the given region obligation must be resolved /// Registers that the given region obligation must be resolved
/// from within the scope of `body_id`. These regions are enqueued /// from within the scope of `body_id`. These regions are enqueued
/// and later processed by regionck, when full type information is /// and later processed by regionck, when full type information is
@ -226,15 +226,15 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
/// via a "delegate" of type `D` -- this is usually the `infcx`, which /// via a "delegate" of type `D` -- this is usually the `infcx`, which
/// accrues them into the `region_obligations` code, but for NLL we /// accrues them into the `region_obligations` code, but for NLL we
/// use something else. /// use something else.
pub struct TypeOutlives<'cx, 'gcx: 'tcx, 'tcx: 'cx, D> pub struct TypeOutlives<'cx, 'tcx: 'cx, D>
where where
D: TypeOutlivesDelegate<'tcx>, D: TypeOutlivesDelegate<'tcx>,
{ {
// See the comments on `process_registered_region_obligations` for the meaning // See the comments on `process_registered_region_obligations` for the meaning
// of these fields. // of these fields.
delegate: D, delegate: D,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
verify_bound: VerifyBoundCx<'cx, 'gcx, 'tcx>, verify_bound: VerifyBoundCx<'cx, 'tcx>,
} }
pub trait TypeOutlivesDelegate<'tcx> { pub trait TypeOutlivesDelegate<'tcx> {
@ -254,13 +254,13 @@ pub trait TypeOutlivesDelegate<'tcx> {
); );
} }
impl<'cx, 'gcx, 'tcx, D> TypeOutlives<'cx, 'gcx, 'tcx, D> impl<'cx, 'tcx, D> TypeOutlives<'cx, 'tcx, D>
where where
D: TypeOutlivesDelegate<'tcx>, D: TypeOutlivesDelegate<'tcx>,
{ {
pub fn new( pub fn new(
delegate: D, delegate: D,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
@ -487,7 +487,7 @@ where
} }
} }
impl<'cx, 'gcx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'tcx> {
fn push_sub_region_constraint( fn push_sub_region_constraint(
&mut self, &mut self,
origin: SubregionOrigin<'tcx>, origin: SubregionOrigin<'tcx>,

View file

@ -12,16 +12,16 @@ use crate::util::captures::Captures;
/// via a "delegate" of type `D` -- this is usually the `infcx`, which /// via a "delegate" of type `D` -- this is usually the `infcx`, which
/// accrues them into the `region_obligations` code, but for NLL we /// accrues them into the `region_obligations` code, but for NLL we
/// use something else. /// use something else.
pub struct VerifyBoundCx<'cx, 'gcx: 'tcx, 'tcx: 'cx> { pub struct VerifyBoundCx<'cx, 'tcx: 'cx> {
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
} }
impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
pub fn new( pub fn new(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
@ -102,7 +102,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
pub fn projection_declared_bounds_from_trait( pub fn projection_declared_bounds_from_trait(
&self, &self,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'gcx> { ) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'tcx> {
self.declared_projection_bounds_from_trait(projection_ty) self.declared_projection_bounds_from_trait(projection_ty)
} }
@ -244,7 +244,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
fn declared_projection_bounds_from_trait( fn declared_projection_bounds_from_trait(
&self, &self,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'gcx> { ) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'tcx> {
debug!("projection_bounds(projection_ty={:?})", projection_ty); debug!("projection_bounds(projection_ty={:?})", projection_ty);
let tcx = self.tcx; let tcx = self.tcx;
self.region_bounds_declared_on_associated_item(projection_ty.item_def_id) self.region_bounds_declared_on_associated_item(projection_ty.item_def_id)
@ -284,7 +284,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
fn region_bounds_declared_on_associated_item( fn region_bounds_declared_on_associated_item(
&self, &self,
assoc_item_def_id: DefId, assoc_item_def_id: DefId,
) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'gcx> { ) -> impl Iterator<Item = ty::Region<'tcx>> + 'cx + Captures<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let assoc_item = tcx.associated_item(assoc_item_def_id); let assoc_item = tcx.associated_item(assoc_item_def_id);
let trait_def_id = assoc_item.container.assert_trait(); let trait_def_id = assoc_item.container.assert_trait();

View file

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

View file

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

View file

@ -12,19 +12,19 @@ use crate::ty::fold::{TypeFolder, TypeVisitor};
/// been unified with (similar to `shallow_resolve`, but deep). This is /// been unified with (similar to `shallow_resolve`, but deep). This is
/// useful for printing messages etc but also required at various /// useful for printing messages etc but also required at various
/// points for correctness. /// points for correctness.
pub struct OpportunisticVarResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct OpportunisticVarResolver<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
} }
impl<'a, 'gcx, 'tcx> OpportunisticVarResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
#[inline] #[inline]
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
OpportunisticVarResolver { infcx } OpportunisticVarResolver { infcx }
} }
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -50,18 +50,18 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gc
/// The opportunistic type and region resolver is similar to the /// The opportunistic type and region resolver is similar to the
/// opportunistic type resolver, but also opportunistically resolves /// opportunistic type resolver, but also opportunistically resolves
/// regions. It is useful for canonicalization. /// regions. It is useful for canonicalization.
pub struct OpportunisticTypeAndRegionResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
} }
impl<'a, 'gcx, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
OpportunisticTypeAndRegionResolver { infcx } OpportunisticTypeAndRegionResolver { infcx }
} }
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
@ -101,20 +101,20 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeAndRegionResolv
/// type variables that don't yet have a value. The first unresolved type is stored. /// type variables that don't yet have a value. The first unresolved type is stored.
/// It does not construct the fully resolved type (which might /// It does not construct the fully resolved type (which might
/// involve some hashing and so forth). /// involve some hashing and so forth).
pub struct UnresolvedTypeFinder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct UnresolvedTypeFinder<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
/// Used to find the type parameter name and location for error reporting. /// Used to find the type parameter name and location for error reporting.
pub first_unresolved: Option<(Ty<'tcx>,Option<Span>)>, pub first_unresolved: Option<(Ty<'tcx>,Option<Span>)>,
} }
impl<'a, 'gcx, 'tcx> UnresolvedTypeFinder<'a, 'gcx, 'tcx> { impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self { pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
UnresolvedTypeFinder { infcx, first_unresolved: None } UnresolvedTypeFinder { infcx, first_unresolved: None }
} }
} }
impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
let t = self.infcx.shallow_resolve(t); let t = self.infcx.shallow_resolve(t);
if t.has_infer_types() { if t.has_infer_types() {
@ -157,7 +157,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx>
/// Full type resolution replaces all type and region variables with /// Full type resolution replaces all type and region variables with
/// their concrete results. If any variable cannot be replaced (never unified, etc) /// their concrete results. If any variable cannot be replaced (never unified, etc)
/// then an `Err` result is returned. /// then an `Err` result is returned.
pub fn fully_resolve<'a, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
value: &T) -> FixupResult<'tcx, T> value: &T) -> FixupResult<'tcx, T>
where T : TypeFoldable<'tcx> where T : TypeFoldable<'tcx>
{ {
@ -171,13 +171,13 @@ pub fn fully_resolve<'a, 'gcx, 'tcx, T>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
// N.B. This type is not public because the protocol around checking the // N.B. This type is not public because the protocol around checking the
// `err` field is not enforcable otherwise. // `err` field is not enforcable otherwise.
struct FullTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { struct FullTypeResolver<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
err: Option<FixupError<'tcx>>, err: Option<FixupError<'tcx>>,
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

@ -11,14 +11,14 @@ use crate::mir::interpret::ConstValue;
use std::mem; use std::mem;
/// Ensures `a` is made a subtype of `b`. Returns `a` on success. /// Ensures `a` is made a subtype of `b`. Returns `a` on success.
pub struct Sub<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> {
fields: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, fields: &'combine mut CombineFields<'infcx, 'tcx>,
a_is_expected: bool, a_is_expected: bool,
} }
impl<'combine, 'infcx, 'gcx, 'tcx> Sub<'combine, 'infcx, 'gcx, 'tcx> { impl<'combine, 'infcx, 'tcx> Sub<'combine, 'infcx, 'tcx> {
pub fn new(f: &'combine mut CombineFields<'infcx, 'gcx, 'tcx>, a_is_expected: bool) pub fn new(f: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool)
-> Sub<'combine, 'infcx, 'gcx, 'tcx> -> Sub<'combine, 'infcx, 'tcx>
{ {
Sub { fields: f, a_is_expected: a_is_expected } Sub { fields: f, a_is_expected: a_is_expected }
} }
@ -31,9 +31,9 @@ impl<'combine, 'infcx, 'gcx, 'tcx> Sub<'combine, 'infcx, 'gcx, 'tcx> {
} }
} }
impl TypeRelation<'gcx, 'tcx> for Sub<'combine, 'infcx, 'gcx, 'tcx> { impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
fn tag(&self) -> &'static str { "Sub" } fn tag(&self) -> &'static str { "Sub" }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { self.fields.infcx.tcx } fn tcx(&self) -> TyCtxt<'tcx> { self.fields.infcx.tcx }
fn a_is_expected(&self) -> bool { self.a_is_expected } fn a_is_expected(&self) -> bool { self.a_is_expected }
fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R

View file

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

View file

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

View file

@ -761,12 +761,12 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
return err 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); let attrs = tcx.hir().attrs_by_hir_id(id);
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
} }
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap { fn lint_levels<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap {
assert_eq!(cnum, LOCAL_CRATE); assert_eq!(cnum, LOCAL_CRATE);
let mut builder = LintLevelMapBuilder { let mut builder = LintLevelMapBuilder {
levels: LintLevelSets::builder(tcx.sess), levels: LintLevelSets::builder(tcx.sess),
@ -787,7 +787,7 @@ fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevel
struct LintLevelMapBuilder<'tcx> { struct LintLevelMapBuilder<'tcx> {
levels: levels::LintLevelsBuilder<'tcx>, levels: levels::LintLevelsBuilder<'tcx>,
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
} }
impl LintLevelMapBuilder<'tcx> { impl LintLevelMapBuilder<'tcx> {

View file

@ -195,7 +195,7 @@ macro_rules! CloneLiftImpls {
$( $(
impl<$tcx> $crate::ty::Lift<$tcx> for $ty { impl<$tcx> $crate::ty::Lift<$tcx> for $ty {
type Lifted = Self; type Lifted = Self;
fn lift_to_tcx<'gcx>(&self, _: $crate::ty::TyCtxt<'gcx, $tcx>) -> Option<Self> { fn lift_to_tcx(&self, _: $crate::ty::TyCtxt<$tcx>) -> Option<Self> {
Some(Clone::clone(self)) Some(Clone::clone(self))
} }
} }
@ -218,7 +218,7 @@ macro_rules! CloneTypeFoldableImpls {
(for <$tcx:lifetime> { $($ty:ty,)+ }) => { (for <$tcx:lifetime> { $($ty:ty,)+ }) => {
$( $(
impl<$tcx> $crate::ty::fold::TypeFoldable<$tcx> for $ty { impl<$tcx> $crate::ty::fold::TypeFoldable<$tcx> for $ty {
fn super_fold_with<'gcx: $tcx, F: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( fn super_fold_with<F: $crate::ty::fold::TypeFolder<$tcx>>(
&self, &self,
_: &mut F _: &mut F
) -> $ty { ) -> $ty {
@ -264,7 +264,7 @@ macro_rules! BraceStructLiftImpl {
{ {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<$lifted> { fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> {
$(let $field = tcx.lift(&self.$field)?;)* $(let $field = tcx.lift(&self.$field)?;)*
Some(Self::Lifted { $($field),* }) Some(Self::Lifted { $($field),* })
} }
@ -283,7 +283,7 @@ macro_rules! EnumLiftImpl {
{ {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<$lifted> { fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> {
EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output()) EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output())
} }
} }
@ -332,7 +332,7 @@ macro_rules! BraceStructTypeFoldableImpl {
impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s
$(where $($wc)*)* $(where $($wc)*)*
{ {
fn super_fold_with<'gcx: $tcx, V: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( fn super_fold_with<V: $crate::ty::fold::TypeFolder<$tcx>>(
&self, &self,
folder: &mut V, folder: &mut V,
) -> Self { ) -> Self {
@ -359,7 +359,7 @@ macro_rules! TupleStructTypeFoldableImpl {
impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s
$(where $($wc)*)* $(where $($wc)*)*
{ {
fn super_fold_with<'gcx: $tcx, V: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( fn super_fold_with<V: $crate::ty::fold::TypeFolder<$tcx>>(
&self, &self,
folder: &mut V, folder: &mut V,
) -> Self { ) -> Self {
@ -386,7 +386,7 @@ macro_rules! EnumTypeFoldableImpl {
impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s
$(where $($wc)*)* $(where $($wc)*)*
{ {
fn super_fold_with<'gcx: $tcx, V: $crate::ty::fold::TypeFolder<'gcx, $tcx>>( fn super_fold_with<V: $crate::ty::fold::TypeFolder<$tcx>>(
&self, &self,
folder: &mut V, folder: &mut V,
) -> Self { ) -> Self {

View file

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

View file

@ -26,7 +26,7 @@ use syntax_pos;
// explored. For example, if it's a live Node::Item that is a // explored. For example, if it's a live Node::Item that is a
// function, then we should explore its block to check for codes that // function, then we should explore its block to check for codes that
// may need to be marked as live. // may need to be marked as live.
fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool { fn should_explore<'tcx>(tcx: TyCtxt<'tcx>, hir_id: hir::HirId) -> bool {
match tcx.hir().find_by_hir_id(hir_id) { match tcx.hir().find_by_hir_id(hir_id) {
Some(Node::Item(..)) | Some(Node::Item(..)) |
Some(Node::ImplItem(..)) | Some(Node::ImplItem(..)) |
@ -40,7 +40,7 @@ fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool {
struct MarkSymbolVisitor<'a, 'tcx: 'a> { struct MarkSymbolVisitor<'a, 'tcx: 'a> {
worklist: Vec<hir::HirId>, worklist: Vec<hir::HirId>,
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
live_symbols: FxHashSet<hir::HirId>, live_symbols: FxHashSet<hir::HirId>,
repr_has_repr_c: bool, repr_has_repr_c: bool,
@ -302,7 +302,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
} }
fn has_allow_dead_code_or_lang_attr( fn has_allow_dead_code_or_lang_attr(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
id: hir::HirId, id: hir::HirId,
attrs: &[ast::Attribute], attrs: &[ast::Attribute],
) -> bool { ) -> bool {
@ -354,7 +354,7 @@ fn has_allow_dead_code_or_lang_attr(
struct LifeSeeder<'k, 'tcx: 'k> { struct LifeSeeder<'k, 'tcx: 'k> {
worklist: Vec<hir::HirId>, worklist: Vec<hir::HirId>,
krate: &'k hir::Crate, krate: &'k hir::Crate,
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
// see `MarkSymbolVisitor::struct_constructors` // see `MarkSymbolVisitor::struct_constructors`
struct_constructors: FxHashMap<hir::HirId, hir::HirId>, struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
} }
@ -425,7 +425,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
} }
fn create_and_seed_worklist<'tcx>( fn create_and_seed_worklist<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
access_levels: &privacy::AccessLevels, access_levels: &privacy::AccessLevels,
krate: &hir::Crate, krate: &hir::Crate,
) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) { ) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) {
@ -453,7 +453,7 @@ fn create_and_seed_worklist<'tcx>(
} }
fn find_live<'tcx>( fn find_live<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
access_levels: &privacy::AccessLevels, access_levels: &privacy::AccessLevels,
krate: &hir::Crate, krate: &hir::Crate,
) -> FxHashSet<hir::HirId> { ) -> FxHashSet<hir::HirId> {
@ -474,7 +474,7 @@ fn find_live<'tcx>(
} }
struct DeadVisitor<'tcx> { struct DeadVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
live_symbols: FxHashSet<hir::HirId>, live_symbols: FxHashSet<hir::HirId>,
} }
@ -662,7 +662,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
} }
} }
pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir().krate(); let krate = tcx.hir().krate();
let live_symbols = find_live(tcx, access_levels, krate); let live_symbols = find_live(tcx, access_levels, krate);

View file

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

View file

@ -38,7 +38,7 @@ pub enum ExportedSymbol<'tcx> {
} }
impl<'tcx> 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 { match *self {
ExportedSymbol::NonGeneric(def_id) => { ExportedSymbol::NonGeneric(def_id) => {
tcx.symbol_name(ty::Instance::mono(tcx, def_id)) tcx.symbol_name(ty::Instance::mono(tcx, def_id))
@ -54,7 +54,7 @@ impl<'tcx> ExportedSymbol<'tcx> {
pub fn compare_stable( pub fn compare_stable(
&self, &self,
tcx: TyCtxt<'tcx, '_>, tcx: TyCtxt<'tcx>,
other: &ExportedSymbol<'tcx>, other: &ExportedSymbol<'tcx>,
) -> cmp::Ordering { ) -> cmp::Ordering {
match *self { match *self {
@ -91,13 +91,13 @@ impl<'tcx> ExportedSymbol<'tcx> {
} }
} }
pub fn metadata_symbol_name(tcx: TyCtxt<'_, '_>) -> String { pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String {
format!("rust_metadata_{}_{}", format!("rust_metadata_{}_{}",
tcx.original_crate_name(LOCAL_CRATE), tcx.original_crate_name(LOCAL_CRATE),
tcx.crate_disambiguator(LOCAL_CRATE).to_fingerprint().to_hex()) tcx.crate_disambiguator(LOCAL_CRATE).to_fingerprint().to_hex())
} }
impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ExportedSymbol<'gcx> { impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ExportedSymbol<'tcx> {
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>, hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) { hasher: &mut StableHasher<W>) {

View file

@ -202,7 +202,7 @@ enum OverloadedCallType {
} }
impl 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 &[ for &(maybe_function_trait, overloaded_call_type) in &[
(tcx.lang_items().fn_once_trait(), FnOnceOverloadedCall), (tcx.lang_items().fn_once_trait(), FnOnceOverloadedCall),
(tcx.lang_items().fn_mut_trait(), FnMutOverloadedCall), (tcx.lang_items().fn_mut_trait(), FnMutOverloadedCall),
@ -219,7 +219,7 @@ impl OverloadedCallType {
bug!("overloaded call didn't map to known function trait") 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); let method = tcx.associated_item(method_id);
OverloadedCallType::from_trait_id(tcx, method.container.id()) OverloadedCallType::from_trait_id(tcx, method.container.id())
} }
@ -229,8 +229,8 @@ impl OverloadedCallType {
// The ExprUseVisitor type // The ExprUseVisitor type
// //
// This is the code that actually walks the tree. // This is the code that actually walks the tree.
pub struct ExprUseVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { pub struct ExprUseVisitor<'a, 'tcx: 'a> {
mc: mc::MemCategorizationContext<'a, 'gcx, 'tcx>, mc: mc::MemCategorizationContext<'a, 'tcx>,
delegate: &'a mut dyn Delegate<'tcx>, delegate: &'a mut dyn Delegate<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
} }
@ -254,7 +254,7 @@ macro_rules! return_if_err {
) )
} }
impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> { impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
/// Creates the ExprUseVisitor, configuring it with the various options provided: /// Creates the ExprUseVisitor, configuring it with the various options provided:
/// ///
/// - `delegate` -- who receives the callbacks /// - `delegate` -- who receives the callbacks
@ -268,7 +268,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
/// See also `with_infer`, which is used *during* typeck. /// See also `with_infer`, which is used *during* typeck.
pub fn new( pub fn new(
delegate: &'a mut (dyn Delegate<'tcx> + 'a), delegate: &'a mut (dyn Delegate<'tcx> + 'a),
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
body_owner: DefId, body_owner: DefId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
@ -287,9 +287,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a), pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a),
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
body_owner: DefId, body_owner: DefId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
@ -333,7 +333,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_expr(&body.value); self.consume_expr(&body.value);
} }
fn tcx(&self) -> TyCtxt<'gcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.mc.tcx self.mc.tcx
} }
@ -974,7 +974,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
} }
} }
fn copy_or_move<'a, 'gcx, 'tcx>(mc: &mc::MemCategorizationContext<'a, 'gcx, 'tcx>, fn copy_or_move<'a, 'tcx>(mc: &mc::MemCategorizationContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cmt: &mc::cmt_<'tcx>, cmt: &mc::cmt_<'tcx>,
move_reason: MoveReason) move_reason: MoveReason)

View file

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

View file

@ -10,7 +10,7 @@ use syntax_pos::{Span, sym};
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
use crate::hir; use crate::hir;
fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module( tcx.hir().visit_item_likes_in_module(
module_def_id, module_def_id,
&mut ItemVisitor { tcx }.as_deep_visitor() &mut ItemVisitor { tcx }.as_deep_visitor()
@ -25,18 +25,18 @@ pub fn provide(providers: &mut Providers<'_>) {
} }
struct ItemVisitor<'tcx> { struct ItemVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
} }
struct ExprVisitor<'tcx> { struct ExprVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
tables: &'tcx ty::TypeckTables<'tcx>, tables: &'tcx ty::TypeckTables<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
} }
/// If the type is `Option<T>`, it will return `T`, otherwise /// If the type is `Option<T>`, it will return `T`, otherwise
/// the type itself. Works on most `Option`-like types. /// the type itself. Works on most `Option`-like types.
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
let (def, substs) = match ty.sty { let (def, substs) = match ty.sty {
ty::Adt(def, substs) => (def, substs), ty::Adt(def, substs) => (def, substs),
_ => return ty _ => return ty

View file

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

View file

@ -38,12 +38,12 @@ impl LibFeatures {
} }
pub struct LibFeatureCollector<'tcx> { pub struct LibFeatureCollector<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
lib_features: LibFeatures, lib_features: LibFeatures,
} }
impl LibFeatureCollector<'tcx> { impl LibFeatureCollector<'tcx> {
fn new(tcx: TyCtxt<'tcx, 'tcx>) -> LibFeatureCollector<'tcx> { fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> {
LibFeatureCollector { LibFeatureCollector {
tcx, tcx,
lib_features: LibFeatures::new(), lib_features: LibFeatures::new(),
@ -142,7 +142,7 @@ impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
} }
} }
pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> LibFeatures { pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LibFeatures {
let mut collector = LibFeatureCollector::new(tcx); let mut collector = LibFeatureCollector::new(tcx);
intravisit::walk_crate(&mut collector, tcx.hir().krate()); intravisit::walk_crate(&mut collector, tcx.hir().krate());
collector.lib_features collector.lib_features

View file

@ -150,7 +150,7 @@ enum LiveNodeKind {
ExitNode 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(); let cm = tcx.sess.source_map();
match lnk { match lnk {
UpvarNode(s) => { UpvarNode(s) => {
@ -181,7 +181,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
fn visit_arm(&mut self, a: &'tcx hir::Arm) { visit_arm(self, a); } fn visit_arm(&mut self, a: &'tcx hir::Arm) { visit_arm(self, a); }
} }
fn check_mod_liveness<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { fn check_mod_liveness<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module( tcx.hir().visit_item_likes_in_module(
module_def_id, module_def_id,
&mut IrMaps::new(tcx, module_def_id).as_deep_visitor(), &mut IrMaps::new(tcx, module_def_id).as_deep_visitor(),
@ -257,7 +257,7 @@ enum VarKind {
} }
struct IrMaps<'tcx> { struct IrMaps<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
body_owner: DefId, body_owner: DefId,
num_live_nodes: usize, num_live_nodes: usize,
num_vars: usize, num_vars: usize,
@ -269,7 +269,7 @@ struct IrMaps<'tcx> {
} }
impl IrMaps<'tcx> { impl IrMaps<'tcx> {
fn new(tcx: TyCtxt<'tcx, 'tcx>, body_owner: DefId) -> IrMaps<'tcx> { fn new(tcx: TyCtxt<'tcx>, body_owner: DefId) -> IrMaps<'tcx> {
IrMaps { IrMaps {
tcx, tcx,
body_owner, body_owner,

View file

@ -287,14 +287,14 @@ impl HirNode for hir::Pat {
} }
#[derive(Clone)] #[derive(Clone)]
pub struct MemCategorizationContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct MemCategorizationContext<'a, 'tcx> {
pub tcx: TyCtxt<'gcx, 'tcx>, pub tcx: TyCtxt<'tcx>,
pub body_owner: DefId, pub body_owner: DefId,
pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>, pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
pub region_scope_tree: &'a region::ScopeTree, pub region_scope_tree: &'a region::ScopeTree,
pub tables: &'a ty::TypeckTables<'tcx>, pub tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>, rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
infcx: Option<&'a InferCtxt<'a, 'gcx, 'tcx>>, infcx: Option<&'a InferCtxt<'a, 'tcx>>,
} }
pub type McResult<T> = Result<T, ()>; pub type McResult<T> = Result<T, ()>;
@ -340,7 +340,7 @@ impl MutabilityCategory {
} }
fn from_local( fn from_local(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
tables: &ty::TypeckTables<'_>, tables: &ty::TypeckTables<'_>,
id: ast::NodeId, id: ast::NodeId,
) -> MutabilityCategory { ) -> MutabilityCategory {
@ -402,14 +402,14 @@ impl MutabilityCategory {
} }
} }
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> { impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
pub fn new( pub fn new(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
body_owner: DefId, body_owner: DefId,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
rvalue_promotable_map: Option<&'tcx ItemLocalSet>, rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
) -> MemCategorizationContext<'a, 'tcx, 'tcx> { ) -> MemCategorizationContext<'a, 'tcx> {
MemCategorizationContext { MemCategorizationContext {
tcx, tcx,
body_owner, body_owner,
@ -422,7 +422,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
/// Creates a `MemCategorizationContext` during type inference. /// Creates a `MemCategorizationContext` during type inference.
/// This is used during upvar analysis and a few other places. /// This is used during upvar analysis and a few other places.
/// Because the typeck tables are not yet complete, the results /// Because the typeck tables are not yet complete, the results
@ -432,11 +432,11 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
/// temporaries may be overly conservative; /// temporaries may be overly conservative;
/// - similarly, as the results of upvar analysis are not yet /// - similarly, as the results of upvar analysis are not yet
/// known, the results around upvar accesses may be incorrect. /// known, the results around upvar accesses may be incorrect.
pub fn with_infer(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, pub fn with_infer(infcx: &'a InferCtxt<'a, 'tcx>,
body_owner: DefId, body_owner: DefId,
region_scope_tree: &'a region::ScopeTree, region_scope_tree: &'a region::ScopeTree,
tables: &'a ty::TypeckTables<'tcx>) tables: &'a ty::TypeckTables<'tcx>)
-> MemCategorizationContext<'a, 'gcx, 'tcx> { -> MemCategorizationContext<'a, 'tcx> {
let tcx = infcx.tcx; let tcx = infcx.tcx;
// Subtle: we can't do rvalue promotion analysis until the // Subtle: we can't do rvalue promotion analysis until the
@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> { pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
// This recursion helper avoids going through *too many* // This recursion helper avoids going through *too many*
// adjustments, since *only* non-overloaded deref recurses. // adjustments, since *only* non-overloaded deref recurses.
fn helper<'a, 'gcx, 'tcx>(mc: &MemCategorizationContext<'a, 'gcx, 'tcx>, fn helper<'a, 'tcx>(mc: &MemCategorizationContext<'a, 'tcx>,
expr: &hir::Expr, expr: &hir::Expr,
adjustments: &[adjustment::Adjustment<'tcx>]) adjustments: &[adjustment::Adjustment<'tcx>])
-> McResult<cmt_<'tcx>> { -> McResult<cmt_<'tcx>> {
@ -1518,7 +1518,7 @@ impl<'tcx> cmt_<'tcx> {
} }
} }
pub fn descriptive_string(&self, tcx: TyCtxt<'_, '_>) -> Cow<'static, str> { pub fn descriptive_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
match self.cat { match self.cat {
Categorization::StaticItem => { Categorization::StaticItem => {
"static item".into() "static item".into()

View file

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

View file

@ -169,7 +169,7 @@ impl Scope {
self.id 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 { match scope_tree.root_body {
Some(hir_id) => { Some(hir_id) => {
tcx.hir().hir_to_node_id(hir::HirId { 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 /// Returns the span of this `Scope`. Note that in general the
/// returned span may not correspond to the span of any `NodeId` in /// returned span may not correspond to the span of any `NodeId` in
/// the AST. /// 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); let node_id = self.node_id(tcx, scope_tree);
if node_id == ast::DUMMY_NODE_ID { if node_id == ast::DUMMY_NODE_ID {
return DUMMY_SP; return DUMMY_SP;
@ -359,7 +359,7 @@ pub struct Context {
} }
struct RegionResolutionVisitor<'tcx> { struct RegionResolutionVisitor<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
// The number of expressions and patterns visited in the current body // The number of expressions and patterns visited in the current body
expr_and_pat_count: usize, expr_and_pat_count: usize,
@ -646,9 +646,9 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`, /// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives. /// returns the outermost `Scope` that the region outlives.
pub fn early_free_scope<'gcx>( pub fn early_free_scope(
&self, &self,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
br: &ty::EarlyBoundRegion, br: &ty::EarlyBoundRegion,
) -> Scope { ) -> Scope {
let param_owner = tcx.parent(br.def_id).unwrap(); let param_owner = tcx.parent(br.def_id).unwrap();
@ -679,7 +679,7 @@ impl<'tcx> ScopeTree {
/// Assuming that the provided region was defined within this `ScopeTree`, /// Assuming that the provided region was defined within this `ScopeTree`,
/// returns the outermost `Scope` that the region outlives. /// returns the outermost `Scope` that the region outlives.
pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion) -> Scope { pub fn free_scope(&self, tcx: TyCtxt<'tcx>, fr: &ty::FreeRegion) -> Scope {
let param_owner = match fr.bound_region { let param_owner = match fr.bound_region {
ty::BoundRegion::BrNamed(def_id, _) => { ty::BoundRegion::BrNamed(def_id, _) => {
tcx.parent(def_id).unwrap() tcx.parent(def_id).unwrap()
@ -1334,7 +1334,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
} }
} }
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ScopeTree { fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree {
let closure_base_def_id = tcx.closure_base_def_id(def_id); let closure_base_def_id = tcx.closure_base_def_id(def_id);
if closure_base_def_id != def_id { if closure_base_def_id != def_id {
return tcx.region_scope_tree(closure_base_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> { struct LifetimeContext<'a, 'tcx: 'a> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
map: &'a mut NamedRegionMap, map: &'a mut NamedRegionMap,
scope: ScopeRef<'a>, scope: ScopeRef<'a>,
@ -368,7 +368,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
/// entire crate. You should not read the result of this query /// entire crate. You should not read the result of this query
/// directly, but rather use `named_region_map`, `is_late_bound_map`, /// directly, but rather use `named_region_map`, `is_late_bound_map`,
/// etc. /// etc.
fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes { fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes {
assert_eq!(for_krate, LOCAL_CRATE); assert_eq!(for_krate, LOCAL_CRATE);
let named_region_map = krate(tcx); let named_region_map = krate(tcx);
@ -395,7 +395,7 @@ fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tc
tcx.arena.alloc(rl) tcx.arena.alloc(rl)
} }
fn krate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> NamedRegionMap { fn krate<'tcx>(tcx: TyCtxt<'tcx>) -> NamedRegionMap {
let krate = tcx.hir().krate(); let krate = tcx.hir().krate();
let mut map = NamedRegionMap { let mut map = NamedRegionMap {
defs: Default::default(), defs: Default::default(),
@ -1098,7 +1098,7 @@ impl ShadowKind {
} }
} }
fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_>, params: &P<[hir::GenericParam]>) { fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &P<[hir::GenericParam]>) {
let lifetime_params: Vec<_> = params let lifetime_params: Vec<_> = params
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
@ -1126,7 +1126,7 @@ fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_>, params: &P<[hir::G
} }
fn signal_shadowing_problem( fn signal_shadowing_problem(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
name: ast::Name, name: ast::Name,
orig: Original, orig: Original,
shadower: Shadower, shadower: Shadower,
@ -1166,7 +1166,7 @@ fn signal_shadowing_problem(
// if one of the label shadows a lifetime or another label. // if one of the label shadows a lifetime or another label.
fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
struct GatherLabels<'a, 'tcx: 'a> { struct GatherLabels<'a, 'tcx: 'a> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
scope: ScopeRef<'a>, scope: ScopeRef<'a>,
labels_in_fn: &'a mut Vec<ast::Ident>, labels_in_fn: &'a mut Vec<ast::Ident>,
} }
@ -1215,7 +1215,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
} }
fn check_if_label_shadows_lifetime( fn check_if_label_shadows_lifetime(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
mut scope: ScopeRef<'_>, mut scope: ScopeRef<'_>,
label: ast::Ident, label: ast::Ident,
) { ) {
@ -1253,7 +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(); let mut map = HirIdMap::default();
for item in tcx.hir().krate().items.values() { for item in tcx.hir().krate().items.values() {
match item.node { match item.node {
@ -1310,7 +1310,7 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_, '_>) -> HirIdMap<Vec<ObjectL
/// of the form `T:'a` so as to determine the `ObjectLifetimeDefault` /// of the form `T:'a` so as to determine the `ObjectLifetimeDefault`
/// for each type parameter. /// for each type parameter.
fn object_lifetime_defaults_for_item( fn object_lifetime_defaults_for_item(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
generics: &hir::Generics, generics: &hir::Generics,
) -> Vec<ObjectLifetimeDefault> { ) -> Vec<ObjectLifetimeDefault> {
fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound]) { 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. // A private tree-walker for producing an Index.
struct Annotator<'a, 'tcx: 'a> { struct Annotator<'a, 'tcx: 'a> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
index: &'a mut Index<'tcx>, index: &'a mut Index<'tcx>,
parent_stab: Option<&'tcx Stability>, parent_stab: Option<&'tcx Stability>,
parent_depr: Option<DeprecationEntry>, parent_depr: Option<DeprecationEntry>,
@ -317,7 +317,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
} }
struct MissingStabilityAnnotations<'a, 'tcx: 'a> { struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
access_levels: &'a AccessLevels, access_levels: &'a AccessLevels,
} }
@ -390,7 +390,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
} }
impl<'tcx> Index<'tcx> { impl<'tcx> Index<'tcx> {
pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Index<'tcx> { pub fn new(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
let is_staged_api = let is_staged_api =
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.sess.opts.debugging_opts.force_unstable_if_unmarked ||
tcx.features().staged_api; tcx.features().staged_api;
@ -466,7 +466,7 @@ impl<'tcx> Index<'tcx> {
/// Cross-references the feature names of unstable APIs with enabled /// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors. /// features and possibly prints errors.
fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, module_def_id: DefId) { fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor()); tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor());
} }
@ -502,7 +502,7 @@ pub fn deprecation_in_effect(since: &str) -> bool {
} }
struct Checker<'tcx> { struct Checker<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
} }
/// Result of `TyCtxt::eval_stability`. /// Result of `TyCtxt::eval_stability`.
@ -521,7 +521,7 @@ pub enum EvalResult {
Unmarked, Unmarked,
} }
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { impl<'tcx> TyCtxt<'tcx> {
// See issue #38412. // See issue #38412.
fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool { fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
// Check if `def_id` is a trait method. // Check if `def_id` is a trait method.
@ -827,7 +827,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
} }
} }
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { impl<'tcx> TyCtxt<'tcx> {
pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> { pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> {
self.lookup_deprecation_entry(id).map(|depr| depr.attr) self.lookup_deprecation_entry(id).map(|depr| depr.attr)
} }
@ -836,7 +836,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
/// Given the list of enabled features that were not language features (i.e., that /// Given the list of enabled features that were not language features (i.e., that
/// were expected to be library features), and the list of features used from /// were expected to be library features), and the list of features used from
/// libraries, identify activated features that don't exist and error about them. /// libraries, identify activated features that don't exist and error about them.
pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) { pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
if tcx.stability().staged_api[&LOCAL_CRATE] { if tcx.stability().staged_api[&LOCAL_CRATE] {
@ -921,7 +921,7 @@ pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) {
} }
fn unnecessary_stable_feature_lint<'tcx>( fn unnecessary_stable_feature_lint<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
span: Span, span: Span,
feature: Symbol, feature: Symbol,
since: Symbol, since: Symbol,

View file

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

View file

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

View file

@ -66,7 +66,7 @@ enum AllocDiscriminant {
pub fn specialized_encode_alloc_id<'tcx, E: Encoder>( pub fn specialized_encode_alloc_id<'tcx, E: Encoder>(
encoder: &mut E, encoder: &mut E,
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
alloc_id: AllocId, alloc_id: AllocId,
) -> Result<(), E::Error> { ) -> Result<(), E::Error> {
let alloc: GlobalAlloc<'tcx> = let alloc: GlobalAlloc<'tcx> =

View file

@ -1240,8 +1240,8 @@ impl<'tcx> Terminator<'tcx> {
} }
impl<'tcx> TerminatorKind<'tcx> { impl<'tcx> TerminatorKind<'tcx> {
pub fn if_<'gcx>( pub fn if_(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
cond: Operand<'tcx>, cond: Operand<'tcx>,
t: BasicBlock, t: BasicBlock,
f: BasicBlock, f: BasicBlock,
@ -2324,7 +2324,7 @@ impl<'tcx> Operand<'tcx> {
/// with given `DefId` and substs. Since this is used to synthesize /// with given `DefId` and substs. Since this is used to synthesize
/// MIR, assumes `user_ty` is None. /// MIR, assumes `user_ty` is None.
pub fn function_handle( pub fn function_handle(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
def_id: DefId, def_id: DefId,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
span: Span, span: Span,
@ -2795,7 +2795,7 @@ impl UserTypeProjection {
CloneTypeFoldableAndLiftImpls! { ProjectionKind, } CloneTypeFoldableAndLiftImpls! { ProjectionKind, }
impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection { impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
use crate::mir::ProjectionElem::*; use crate::mir::ProjectionElem::*;
let base = self.base.fold_with(folder); let base = self.base.fold_with(folder);
@ -3012,8 +3012,8 @@ pub struct GeneratorLayout<'tcx> {
} }
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct BorrowCheckResult<'gcx> { pub struct BorrowCheckResult<'tcx> {
pub closure_requirements: Option<ClosureRegionRequirements<'gcx>>, pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
pub used_mut_upvars: SmallVec<[Field; 8]>, pub used_mut_upvars: SmallVec<[Field; 8]>,
} }
@ -3068,7 +3068,7 @@ pub struct BorrowCheckResult<'gcx> {
/// TyCtxt, and hence we cannot use `ReVar` (which is what we use /// TyCtxt, and hence we cannot use `ReVar` (which is what we use
/// internally within the rest of the NLL code). /// internally within the rest of the NLL code).
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct ClosureRegionRequirements<'gcx> { pub struct ClosureRegionRequirements<'tcx> {
/// The number of external regions defined on the closure. In our /// The number of external regions defined on the closure. In our
/// example above, it would be 3 -- one for `'static`, then `'1` /// example above, it would be 3 -- one for `'static`, then `'1`
/// and `'2`. This is just used for a sanity check later on, to /// and `'2`. This is just used for a sanity check later on, to
@ -3078,7 +3078,7 @@ pub struct ClosureRegionRequirements<'gcx> {
/// Requirements between the various free regions defined in /// Requirements between the various free regions defined in
/// indices. /// indices.
pub outlives_requirements: Vec<ClosureOutlivesRequirement<'gcx>>, pub outlives_requirements: Vec<ClosureOutlivesRequirement<'tcx>>,
} }
/// Indicates an outlives constraint between a type or between two /// Indicates an outlives constraint between a type or between two
@ -3262,7 +3262,7 @@ EnumTypeFoldableImpl! {
} }
impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
use crate::mir::TerminatorKind::*; use crate::mir::TerminatorKind::*;
let kind = match self.kind { let kind = match self.kind {
@ -3430,7 +3430,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
} }
impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match self { match self {
&Place::Projection(ref p) => Place::Projection(p.fold_with(folder)), &Place::Projection(ref p) => Place::Projection(p.fold_with(folder)),
_ => self.clone(), _ => self.clone(),
@ -3447,7 +3447,7 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
} }
impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
use crate::mir::Rvalue::*; use crate::mir::Rvalue::*;
match *self { match *self {
Use(ref op) => Use(op.fold_with(folder)), Use(ref op) => Use(op.fold_with(folder)),
@ -3519,7 +3519,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
} }
impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match *self { match *self {
Operand::Copy(ref place) => Operand::Copy(place.fold_with(folder)), Operand::Copy(ref place) => Operand::Copy(place.fold_with(folder)),
Operand::Move(ref place) => Operand::Move(place.fold_with(folder)), Operand::Move(ref place) => Operand::Move(place.fold_with(folder)),
@ -3536,7 +3536,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
} }
impl<'tcx> TypeFoldable<'tcx> for Projection<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Projection<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
use crate::mir::ProjectionElem::*; use crate::mir::ProjectionElem::*;
let base = self.base.fold_with(folder); let base = self.base.fold_with(folder);
@ -3562,7 +3562,7 @@ impl<'tcx> TypeFoldable<'tcx> for Projection<'tcx> {
} }
impl<'tcx> TypeFoldable<'tcx> for Field { impl<'tcx> TypeFoldable<'tcx> for Field {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
*self *self
} }
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool { fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
@ -3571,7 +3571,7 @@ impl<'tcx> TypeFoldable<'tcx> for Field {
} }
impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal { impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
*self *self
} }
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool { fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
@ -3580,7 +3580,7 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
} }
impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> { impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, _: &mut F) -> Self {
self.clone() self.clone()
} }
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool { fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> bool {
@ -3589,7 +3589,7 @@ impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
} }
impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
Constant { Constant {
span: self.span.clone(), span: self.span.clone(),
ty: self.ty.fold_with(folder), ty: self.ty.fold_with(folder),

View file

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

View file

@ -21,7 +21,7 @@ pub struct PlaceTy<'tcx> {
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
static_assert_size!(PlaceTy<'_>, 16); static_assert_size!(PlaceTy<'_>, 16);
impl<'gcx, 'tcx> PlaceTy<'tcx> { impl<'tcx> PlaceTy<'tcx> {
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> { pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
PlaceTy { ty, variant_index: None } PlaceTy { ty, variant_index: None }
} }
@ -33,7 +33,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
/// not carry a `Ty` for `T`.) /// not carry a `Ty` for `T`.)
/// ///
/// Note that the resulting type has not been normalized. /// Note that the resulting type has not been normalized.
pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx> { pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> {
let answer = match self.ty.sty { let answer = match self.ty.sty {
ty::Adt(adt_def, substs) => { ty::Adt(adt_def, substs) => {
let variant_def = match self.variant_index { let variant_def = match self.variant_index {
@ -56,7 +56,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
/// Convenience wrapper around `projection_ty_core` for /// Convenience wrapper around `projection_ty_core` for
/// `PlaceElem`, where we can just use the `Ty` that is already /// `PlaceElem`, where we can just use the `Ty` that is already
/// stored inline on field projection elems. /// stored inline on field projection elems.
pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> { pub fn projection_ty(self, tcx: TyCtxt<'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> {
self.projection_ty_core(tcx, elem, |_, _, ty| ty) self.projection_ty_core(tcx, elem, |_, _, ty| ty)
} }
@ -67,7 +67,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
/// (which should be trivial when `T` = `Ty`). /// (which should be trivial when `T` = `Ty`).
pub fn projection_ty_core<V, T>( pub fn projection_ty_core<V, T>(
self, self,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
elem: &ProjectionElem<V, T>, elem: &ProjectionElem<V, T>,
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>, mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>,
) -> PlaceTy<'tcx> ) -> PlaceTy<'tcx>
@ -118,7 +118,7 @@ BraceStructTypeFoldableImpl! {
} }
impl<'tcx> Place<'tcx> { impl<'tcx> Place<'tcx> {
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> PlaceTy<'tcx> pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
where where
D: HasLocalDecls<'tcx>, D: HasLocalDecls<'tcx>,
{ {
@ -139,7 +139,7 @@ pub enum RvalueInitializationState {
} }
impl<'tcx> Rvalue<'tcx> { impl<'tcx> Rvalue<'tcx> {
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
where where
D: HasLocalDecls<'tcx>, D: HasLocalDecls<'tcx>,
{ {
@ -221,7 +221,7 @@ impl<'tcx> Rvalue<'tcx> {
} }
impl<'tcx> Operand<'tcx> { impl<'tcx> Operand<'tcx> {
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx> pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
where where
D: HasLocalDecls<'tcx>, D: HasLocalDecls<'tcx>,
{ {
@ -234,9 +234,9 @@ impl<'tcx> Operand<'tcx> {
} }
impl<'tcx> BinOp { impl<'tcx> BinOp {
pub fn ty<'gcx>( pub fn ty(
&self, &self,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
lhs_ty: Ty<'tcx>, lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {

View file

@ -48,11 +48,11 @@ pub struct AutoTraitInfo<'cx> {
} }
pub struct AutoTraitFinder<'tcx> { pub struct AutoTraitFinder<'tcx> {
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
} }
impl<'tcx> AutoTraitFinder<'tcx> { impl<'tcx> AutoTraitFinder<'tcx> {
pub fn new(tcx: TyCtxt<'tcx, 'tcx>) -> Self { pub fn new(tcx: TyCtxt<'tcx>) -> Self {
AutoTraitFinder { tcx } AutoTraitFinder { tcx }
} }
@ -79,7 +79,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
ty: Ty<'tcx>, ty: Ty<'tcx>,
orig_env: ty::ParamEnv<'tcx>, orig_env: ty::ParamEnv<'tcx>,
trait_did: DefId, trait_did: DefId,
auto_trait_callback: impl for<'i> Fn(&InferCtxt<'_, 'tcx, 'i>, AutoTraitInfo<'i>) -> A, auto_trait_callback: impl Fn(&InferCtxt<'_, 'tcx>, AutoTraitInfo<'tcx>) -> A,
) -> AutoTraitResult<A> { ) -> AutoTraitResult<A> {
let tcx = self.tcx; let tcx = self.tcx;
@ -270,16 +270,16 @@ impl AutoTraitFinder<'tcx> {
// the final synthesized generics: we don't want our generated docs page to contain something // the final synthesized generics: we don't want our generated docs page to contain something
// like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate // like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
// 'user_env', which only holds the predicates that will actually be displayed to the user. // 'user_env', which only holds the predicates that will actually be displayed to the user.
fn evaluate_predicates<'b, 'c>( fn evaluate_predicates(
&self, &self,
infcx: &InferCtxt<'b, 'tcx, 'c>, infcx: &InferCtxt<'_, 'tcx>,
trait_did: DefId, trait_did: DefId,
ty: Ty<'c>, ty: Ty<'tcx>,
param_env: ty::ParamEnv<'c>, param_env: ty::ParamEnv<'tcx>,
user_env: ty::ParamEnv<'c>, user_env: ty::ParamEnv<'tcx>,
fresh_preds: &mut FxHashSet<ty::Predicate<'c>>, fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
only_projections: bool, only_projections: bool,
) -> Option<(ty::ParamEnv<'c>, ty::ParamEnv<'c>)> { ) -> Option<(ty::ParamEnv<'tcx>, ty::ParamEnv<'tcx>)> {
let tcx = infcx.tcx; let tcx = infcx.tcx;
let mut select = SelectionContext::with_negative(&infcx, true); let mut select = SelectionContext::with_negative(&infcx, true);
@ -617,20 +617,14 @@ impl AutoTraitFinder<'tcx> {
} }
} }
fn evaluate_nested_obligations< fn evaluate_nested_obligations(
'b,
'c,
'd,
'cx,
T: Iterator<Item = Obligation<'cx, ty::Predicate<'cx>>>,
>(
&self, &self,
ty: Ty<'_>, ty: Ty<'_>,
nested: T, nested: impl Iterator<Item = Obligation<'tcx, ty::Predicate<'tcx>>>,
computed_preds: &'b mut FxHashSet<ty::Predicate<'cx>>, computed_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
fresh_preds: &'b mut FxHashSet<ty::Predicate<'cx>>, fresh_preds: &mut FxHashSet<ty::Predicate<'tcx>>,
predicates: &'b mut VecDeque<ty::PolyTraitPredicate<'cx>>, predicates: &mut VecDeque<ty::PolyTraitPredicate<'tcx>>,
select: &mut SelectionContext<'c, 'd, 'cx>, select: &mut SelectionContext<'_, 'tcx>,
only_projections: bool, only_projections: bool,
) -> bool { ) -> bool {
let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID); let dummy_cause = ObligationCause::misc(DUMMY_SP, hir::DUMMY_HIR_ID);
@ -822,23 +816,23 @@ impl AutoTraitFinder<'tcx> {
return true; return true;
} }
pub fn clean_pred<'c, 'd, 'cx>( pub fn clean_pred(
&self, &self,
infcx: &InferCtxt<'c, 'd, 'cx>, infcx: &InferCtxt<'_, 'tcx>,
p: ty::Predicate<'cx>, p: ty::Predicate<'tcx>,
) -> ty::Predicate<'cx> { ) -> ty::Predicate<'tcx> {
infcx.freshen(p) infcx.freshen(p)
} }
} }
// Replaces all ReVars in a type with ty::Region's, using the provided map // Replaces all ReVars in a type with ty::Region's, using the provided map
pub struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub struct RegionReplacer<'a, 'tcx> {
vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>, vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionReplacer<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.tcx self.tcx
} }

View file

@ -29,7 +29,7 @@ impl FulfillmentContext<'tcx> {
} }
fn in_environment( fn in_environment(
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx> obligation: PredicateObligation<'tcx>
) -> InEnvironment<'tcx, PredicateObligation<'tcx>> { ) -> InEnvironment<'tcx, PredicateObligation<'tcx>> {
assert!(!infcx.is_in_snapshot()); assert!(!infcx.is_in_snapshot());
@ -52,7 +52,7 @@ fn in_environment(
impl TraitEngine<'tcx> for FulfillmentContext<'tcx> { impl TraitEngine<'tcx> for FulfillmentContext<'tcx> {
fn normalize_projection_type( fn normalize_projection_type(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
_param_env: ty::ParamEnv<'tcx>, _param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
_cause: ObligationCause<'tcx>, _cause: ObligationCause<'tcx>,
@ -62,7 +62,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> {
fn register_predicate_obligation( fn register_predicate_obligation(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx>, obligation: PredicateObligation<'tcx>,
) { ) {
self.obligations.insert(in_environment(infcx, obligation)); self.obligations.insert(in_environment(infcx, obligation));
@ -70,7 +70,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> {
fn select_all_or_error( fn select_all_or_error(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>> { ) -> Result<(), Vec<FulfillmentError<'tcx>>> {
self.select_where_possible(infcx)?; self.select_where_possible(infcx)?;
@ -89,7 +89,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> {
fn select_where_possible( fn select_where_possible(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>> { ) -> Result<(), Vec<FulfillmentError<'tcx>>> {
let mut errors = Vec::new(); let mut errors = Vec::new();
let mut next_round = FxHashSet::default(); let mut next_round = FxHashSet::default();

View file

@ -19,7 +19,7 @@ use crate::ty::fold::TypeFoldable;
/// obligations *could be* resolved if we wanted to. /// obligations *could be* resolved if we wanted to.
/// Assumes that this is run after the entire crate has been successfully type-checked. /// Assumes that this is run after the entire crate has been successfully type-checked.
pub fn codegen_fulfill_obligation<'tcx>( pub fn codegen_fulfill_obligation<'tcx>(
ty: TyCtxt<'tcx, 'tcx>, ty: TyCtxt<'tcx>,
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>), (param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
) -> Vtable<'tcx, ()> { ) -> Vtable<'tcx, ()> {
// Remove any references to regions; this helps improve caching. // Remove any references to regions; this helps improve caching.
@ -73,7 +73,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
}) })
} }
impl<'tcx> TyCtxt<'tcx, 'tcx> { impl<'tcx> TyCtxt<'tcx> {
/// Monomorphizes a type from the AST by first applying the /// Monomorphizes a type from the AST by first applying the
/// in-scope substitutions and then normalizing any associated /// in-scope substitutions and then normalizing any associated
/// types. /// types.
@ -115,19 +115,19 @@ impl<'tcx> DepTrackingMapConfig for TraitSelectionCache<'tcx> {
// # Global Cache // # Global Cache
pub struct ProjectionCache<'gcx> { pub struct ProjectionCache<'tcx> {
data: PhantomData<&'gcx ()> data: PhantomData<&'tcx ()>
} }
impl<'gcx> DepTrackingMapConfig for ProjectionCache<'gcx> { impl<'tcx> DepTrackingMapConfig for ProjectionCache<'tcx> {
type Key = Ty<'gcx>; type Key = Ty<'tcx>;
type Value = Ty<'gcx>; type Value = Ty<'tcx>;
fn to_dep_kind() -> DepKind { fn to_dep_kind() -> DepKind {
DepKind::TraitSelect DepKind::TraitSelect
} }
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// Finishes processes any obligations that remain in the /// Finishes processes any obligations that remain in the
/// fulfillment context, and then returns the result with all type /// fulfillment context, and then returns the result with all type
/// variables removed and regions erased. Because this is intended /// variables removed and regions erased. Because this is intended
@ -141,7 +141,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fulfill_cx: &mut FulfillmentContext<'tcx>, fulfill_cx: &mut FulfillmentContext<'tcx>,
result: &T) result: &T)
-> T::Lifted -> T::Lifted
where T: TypeFoldable<'tcx> + ty::Lift<'gcx> where T: TypeFoldable<'tcx> + ty::Lift<'tcx>
{ {
debug!("drain_fulfillment_cx_or_panic()"); debug!("drain_fulfillment_cx_or_panic()");

View file

@ -48,8 +48,8 @@ pub fn add_placeholder_note(err: &mut errors::DiagnosticBuilder<'_>) {
/// If there are types that satisfy both impls, invokes `on_overlap` /// If there are types that satisfy both impls, invokes `on_overlap`
/// with a suitably-freshened `ImplHeader` with those types /// with a suitably-freshened `ImplHeader` with those types
/// substituted. Otherwise, invokes `no_overlap`. /// substituted. Otherwise, invokes `no_overlap`.
pub fn overlapping_impls<'gcx, F1, F2, R>( pub fn overlapping_impls<'tcx, F1, F2, R>(
tcx: TyCtxt<'gcx, 'gcx>, tcx: TyCtxt<'tcx>,
impl1_def_id: DefId, impl1_def_id: DefId,
impl2_def_id: DefId, impl2_def_id: DefId,
intercrate_mode: IntercrateMode, intercrate_mode: IntercrateMode,
@ -87,7 +87,7 @@ where
}) })
} }
fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, fn with_fresh_ty_vars<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId) impl_def_id: DefId)
-> ty::ImplHeader<'tcx> -> ty::ImplHeader<'tcx>
@ -111,8 +111,8 @@ fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, '
/// Can both impl `a` and impl `b` be satisfied by a common type (including /// Can both impl `a` and impl `b` be satisfied by a common type (including
/// where-clauses)? If so, returns an `ImplHeader` that unifies the two impls. /// where-clauses)? If so, returns an `ImplHeader` that unifies the two impls.
fn overlap<'cx, 'gcx, 'tcx>( fn overlap<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
a_def_id: DefId, a_def_id: DefId,
b_def_id: DefId, b_def_id: DefId,
) -> Option<OverlapResult<'tcx>> { ) -> Option<OverlapResult<'tcx>> {
@ -122,7 +122,7 @@ fn overlap<'cx, 'gcx, 'tcx>(
} }
fn overlap_within_probe( fn overlap_within_probe(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
a_def_id: DefId, a_def_id: DefId,
b_def_id: DefId, b_def_id: DefId,
snapshot: &CombinedSnapshot<'_, 'tcx>, snapshot: &CombinedSnapshot<'_, 'tcx>,
@ -183,8 +183,8 @@ fn overlap_within_probe(
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder }) Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
} }
pub fn trait_ref_is_knowable<'gcx, 'tcx>( pub fn trait_ref_is_knowable<'tcx>(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
trait_ref: ty::TraitRef<'tcx>, trait_ref: ty::TraitRef<'tcx>,
) -> Option<Conflict> { ) -> Option<Conflict> {
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref); debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
@ -229,8 +229,8 @@ pub fn trait_ref_is_knowable<'gcx, 'tcx>(
} }
} }
pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>( pub fn trait_ref_is_local_or_fundamental<'tcx>(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
trait_ref: ty::TraitRef<'tcx>, trait_ref: ty::TraitRef<'tcx>,
) -> bool { ) -> bool {
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental) trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
@ -247,8 +247,8 @@ pub enum OrphanCheckErr<'tcx> {
/// ///
/// 1. All type parameters in `Self` must be "covered" by some local type constructor. /// 1. All type parameters in `Self` must be "covered" by some local type constructor.
/// 2. Some local type must appear in `Self`. /// 2. Some local type must appear in `Self`.
pub fn orphan_check<'gcx, 'tcx>( pub fn orphan_check<'tcx>(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
impl_def_id: DefId, impl_def_id: DefId,
) -> Result<(), OrphanCheckErr<'tcx>> { ) -> Result<(), OrphanCheckErr<'tcx>> {
debug!("orphan_check({:?})", impl_def_id); debug!("orphan_check({:?})", impl_def_id);
@ -355,7 +355,7 @@ pub fn orphan_check<'gcx, 'tcx>(
/// Note that this function is never called for types that have both type /// Note that this function is never called for types that have both type
/// parameters and inference variables. /// parameters and inference variables.
fn orphan_check_trait_ref<'tcx>( fn orphan_check_trait_ref<'tcx>(
tcx: TyCtxt<'_, '_>, tcx: TyCtxt<'_>,
trait_ref: ty::TraitRef<'tcx>, trait_ref: ty::TraitRef<'tcx>,
in_crate: InCrate, in_crate: InCrate,
) -> Result<(), OrphanCheckErr<'tcx>> { ) -> Result<(), OrphanCheckErr<'tcx>> {
@ -431,7 +431,7 @@ fn orphan_check_trait_ref<'tcx>(
} }
} }
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<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) { if ty_is_local_constructor(ty, in_crate) {
vec![] vec![]
} else if fundamental_ty(ty) { } 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) || ty_is_local_constructor(ty, in_crate) ||
fundamental_ty(ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, in_crate)) fundamental_ty(ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, in_crate))
} }

View file

@ -9,7 +9,7 @@ use super::{ObligationCause, PredicateObligation};
pub trait TraitEngine<'tcx>: 'tcx { pub trait TraitEngine<'tcx>: 'tcx {
fn normalize_projection_type( fn normalize_projection_type(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -20,7 +20,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
/// parameters (except for `Self`). /// parameters (except for `Self`).
fn register_bound( fn register_bound(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
def_id: DefId, def_id: DefId,
@ -40,18 +40,18 @@ pub trait TraitEngine<'tcx>: 'tcx {
fn register_predicate_obligation( fn register_predicate_obligation(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx>, obligation: PredicateObligation<'tcx>,
); );
fn select_all_or_error( fn select_all_or_error(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>>; ) -> Result<(), Vec<FulfillmentError<'tcx>>>;
fn select_where_possible( fn select_where_possible(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>>; ) -> Result<(), Vec<FulfillmentError<'tcx>>>;
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>; fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>;
@ -60,7 +60,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
pub trait TraitEngineExt<'tcx> { pub trait TraitEngineExt<'tcx> {
fn register_predicate_obligations( fn register_predicate_obligations(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>, obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
); );
} }
@ -68,7 +68,7 @@ pub trait TraitEngineExt<'tcx> {
impl<T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T { impl<T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T {
fn register_predicate_obligations( fn register_predicate_obligations(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>, obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
) { ) {
for obligation in obligations { for obligation in obligations {
@ -78,7 +78,7 @@ impl<T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T {
} }
impl dyn TraitEngine<'tcx> { impl dyn TraitEngine<'tcx> {
pub fn new(tcx: TyCtxt<'_, 'tcx>) -> Box<Self> { pub fn new(tcx: TyCtxt<'tcx>) -> Box<Self> {
if tcx.sess.opts.debugging_opts.chalk { if tcx.sess.opts.debugging_opts.chalk {
Box::new(ChalkFulfillmentContext::new()) Box::new(ChalkFulfillmentContext::new())
} else { } else {

View file

@ -38,7 +38,7 @@ use syntax::ast;
use syntax::symbol::sym; use syntax::symbol::sym;
use syntax_pos::{DUMMY_SP, Span, ExpnInfo, ExpnFormat}; use syntax_pos::{DUMMY_SP, Span, ExpnInfo, ExpnFormat};
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn report_fulfillment_errors(&self, pub fn report_fulfillment_errors(&self,
errors: &[FulfillmentError<'tcx>], errors: &[FulfillmentError<'tcx>],
body_id: Option<hir::BodyId>, body_id: Option<hir::BodyId>,
@ -1249,8 +1249,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
expected_ref: ty::PolyTraitRef<'tcx>, expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>, found: ty::PolyTraitRef<'tcx>,
) -> DiagnosticBuilder<'tcx> { ) -> DiagnosticBuilder<'tcx> {
fn build_fn_sig_string<'gcx, 'tcx>( fn build_fn_sig_string<'tcx>(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
trait_ref: &ty::TraitRef<'tcx>, trait_ref: &ty::TraitRef<'tcx>,
) -> String { ) -> String {
let inputs = trait_ref.substs.type_at(1); let inputs = trait_ref.substs.type_at(1);
@ -1296,7 +1296,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
} }
impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> { impl<'tcx> TyCtxt<'tcx> {
pub fn recursive_type_with_infinite_size_error(self, pub fn recursive_type_with_infinite_size_error(self,
type_def_id: DefId) type_def_id: DefId)
-> DiagnosticBuilder<'tcx> -> DiagnosticBuilder<'tcx>
@ -1342,7 +1342,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
} }
} }
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>, fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>,
body_id: Option<hir::BodyId>) { body_id: Option<hir::BodyId>) {
// Unable to successfully determine, probably means // Unable to successfully determine, probably means
@ -1454,13 +1454,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
pred: ty::PolyTraitRef<'tcx>, pred: ty::PolyTraitRef<'tcx>,
) -> bool { ) -> bool {
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { struct ParamToVarFolder<'a, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>> var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>
} }
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ParamToVarFolder<'a, 'gcx, 'tcx> { impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.infcx.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.infcx.tcx }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Param(ty::ParamTy {name, .. }) = ty.sty { if let ty::Param(ty::ParamTy {name, .. }) = ty.sty {

View file

@ -68,7 +68,7 @@ pub struct PendingPredicateObligation<'tcx> {
pub stalled_on: Vec<Ty<'tcx>>, pub stalled_on: Vec<Ty<'tcx>>,
} }
impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> { impl<'a, 'tcx> FulfillmentContext<'tcx> {
/// Creates a new fulfillment context. /// Creates a new fulfillment context.
pub fn new() -> FulfillmentContext<'tcx> { pub fn new() -> FulfillmentContext<'tcx> {
FulfillmentContext { FulfillmentContext {
@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
} }
/// Attempts to select obligations using `selcx`. /// Attempts to select obligations using `selcx`.
fn select(&mut self, selcx: &mut SelectionContext<'a, 'gcx, 'tcx>) fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>)
-> Result<(), Vec<FulfillmentError<'tcx>>> { -> Result<(), Vec<FulfillmentError<'tcx>>> {
debug!("select(obligation-forest-size={})", self.predicates.len()); debug!("select(obligation-forest-size={})", self.predicates.len());
@ -143,8 +143,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
/// `SomeTrait` or a where-clause that lets us unify `$0` with /// `SomeTrait` or a where-clause that lets us unify `$0` with
/// something concrete. If this fails, we'll unify `$0` with /// something concrete. If this fails, we'll unify `$0` with
/// `projection_ty` again. /// `projection_ty` again.
fn normalize_projection_type<'a, 'gcx>(&mut self, fn normalize_projection_type(&mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>) cause: ObligationCause<'tcx>)
@ -172,8 +172,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
normalized_ty normalized_ty
} }
fn register_predicate_obligation<'a, 'gcx>(&mut self, fn register_predicate_obligation(&mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
obligation: PredicateObligation<'tcx>) obligation: PredicateObligation<'tcx>)
{ {
// this helps to reduce duplicate errors, as well as making // this helps to reduce duplicate errors, as well as making
@ -190,9 +190,9 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
}); });
} }
fn select_all_or_error<'a, 'gcx>( fn select_all_or_error(
&mut self, &mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx> infcx: &InferCtxt<'_, 'tcx>
) -> Result<(),Vec<FulfillmentError<'tcx>>> ) -> Result<(),Vec<FulfillmentError<'tcx>>>
{ {
self.select_where_possible(infcx)?; self.select_where_possible(infcx)?;
@ -209,8 +209,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
} }
} }
fn select_where_possible<'a, 'gcx>(&mut self, fn select_where_possible(&mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>) infcx: &InferCtxt<'_, 'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>> -> Result<(),Vec<FulfillmentError<'tcx>>>
{ {
let mut selcx = SelectionContext::new(infcx); let mut selcx = SelectionContext::new(infcx);
@ -222,8 +222,8 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
} }
} }
struct FulfillProcessor<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> { struct FulfillProcessor<'a, 'b: 'a, 'tcx: 'b> {
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, selcx: &'a mut SelectionContext<'b, 'tcx>,
register_region_obligations: bool register_region_obligations: bool
} }
@ -234,7 +234,7 @@ fn mk_pending(os: Vec<PredicateObligation<'tcx>>) -> Vec<PendingPredicateObligat
}).collect() }).collect()
} }
impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx, 'tcx> { impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
type Obligation = PendingPredicateObligation<'tcx>; type Obligation = PendingPredicateObligation<'tcx>;
type Error = FulfillmentErrorCode<'tcx>; type Error = FulfillmentErrorCode<'tcx>;
@ -514,7 +514,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
} }
/// Returns the set of type variables contained in a trait ref /// Returns the set of type variables contained in a trait ref
fn trait_ref_type_vars<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tcx>, fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
t: ty::PolyTraitRef<'tcx>) -> Vec<Ty<'tcx>> t: ty::PolyTraitRef<'tcx>) -> Vec<Ty<'tcx>>
{ {
t.skip_binder() // ok b/c this check doesn't care about regions t.skip_binder() // ok b/c this check doesn't care about regions

View file

@ -140,7 +140,7 @@ pub struct ObligationCause<'tcx> {
} }
impl<'tcx> ObligationCause<'tcx> { impl<'tcx> ObligationCause<'tcx> {
pub fn span<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Span { pub fn span(&self, tcx: TyCtxt<'tcx>) -> Span {
match self.code { match self.code {
ObligationCauseCode::CompareImplMethodObligation { .. } | ObligationCauseCode::CompareImplMethodObligation { .. } |
ObligationCauseCode::MainFunctionType | ObligationCauseCode::MainFunctionType |
@ -363,9 +363,9 @@ impl<'tcx> DomainGoal<'tcx> {
} }
impl<'tcx> GoalKind<'tcx> { impl<'tcx> GoalKind<'tcx> {
pub fn from_poly_domain_goal<'gcx>( pub fn from_poly_domain_goal(
domain_goal: PolyDomainGoal<'tcx>, domain_goal: PolyDomainGoal<'tcx>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
) -> GoalKind<'tcx> { ) -> GoalKind<'tcx> {
match domain_goal.no_bound_vars() { match domain_goal.no_bound_vars() {
Some(p) => p.into_goal(), Some(p) => p.into_goal(),
@ -643,8 +643,8 @@ pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>,
/// `bound` or is not known to meet bound (note that this is /// `bound` or is not known to meet bound (note that this is
/// conservative towards *no impl*, which is the opposite of the /// conservative towards *no impl*, which is the opposite of the
/// `evaluate` methods). /// `evaluate` methods).
pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>( pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
infcx: &InferCtxt<'a, 'gcx, 'tcx>, infcx: &InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
def_id: DefId, def_id: DefId,
@ -711,7 +711,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>(
} }
fn do_normalize_predicates<'tcx>( fn do_normalize_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
region_context: DefId, region_context: DefId,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>, elaborated_env: ty::ParamEnv<'tcx>,
@ -796,7 +796,7 @@ fn do_normalize_predicates<'tcx>(
// FIXME: this is gonna need to be removed ... // FIXME: this is gonna need to be removed ...
/// Normalizes the parameter environment, reporting errors if they occur. /// Normalizes the parameter environment, reporting errors if they occur.
pub fn normalize_param_env_or_error<'tcx>( pub fn normalize_param_env_or_error<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
region_context: DefId, region_context: DefId,
unnormalized_env: ty::ParamEnv<'tcx>, unnormalized_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -904,8 +904,8 @@ pub fn normalize_param_env_or_error<'tcx>(
) )
} }
pub fn fully_normalize<'a, 'gcx, 'tcx, T>( pub fn fully_normalize<'a, 'tcx, T>(
infcx: &InferCtxt<'a, 'gcx, 'tcx>, infcx: &InferCtxt<'a, 'tcx>,
mut fulfill_cx: FulfillmentContext<'tcx>, mut fulfill_cx: FulfillmentContext<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
@ -937,7 +937,7 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
/// encountered an error or one of the predicates did not hold. Used /// encountered an error or one of the predicates did not hold. Used
/// when creating vtables to check for unsatisfiable methods. /// when creating vtables to check for unsatisfiable methods.
fn normalize_and_test_predicates<'tcx>( fn normalize_and_test_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
predicates: Vec<ty::Predicate<'tcx>>, predicates: Vec<ty::Predicate<'tcx>>,
) -> bool { ) -> bool {
debug!("normalize_and_test_predicates(predicates={:?})", debug!("normalize_and_test_predicates(predicates={:?})",
@ -966,7 +966,7 @@ fn normalize_and_test_predicates<'tcx>(
} }
fn substitute_normalize_and_test_predicates<'tcx>( fn substitute_normalize_and_test_predicates<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
key: (DefId, SubstsRef<'tcx>), key: (DefId, SubstsRef<'tcx>),
) -> bool { ) -> bool {
debug!("substitute_normalize_and_test_predicates(key={:?})", debug!("substitute_normalize_and_test_predicates(key={:?})",
@ -984,7 +984,7 @@ fn substitute_normalize_and_test_predicates<'tcx>(
/// that come from `trait_ref`, including its supertraits. /// that come from `trait_ref`, including its supertraits.
#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`. #[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
fn vtable_methods<'tcx>( fn vtable_methods<'tcx>(
tcx: TyCtxt<'tcx, 'tcx>, tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>,
) -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] { ) -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
debug!("vtable_methods({:?})", trait_ref); debug!("vtable_methods({:?})", trait_ref);
@ -1185,7 +1185,7 @@ pub trait ExClauseFold<'tcx>
where where
Self: chalk_engine::context::Context + Clone, Self: chalk_engine::context::Context + Clone,
{ {
fn fold_ex_clause_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>( fn fold_ex_clause_with<F: TypeFolder<'tcx>>(
ex_clause: &chalk_engine::ExClause<Self>, ex_clause: &chalk_engine::ExClause<Self>,
folder: &mut F, folder: &mut F,
) -> chalk_engine::ExClause<Self>; ) -> chalk_engine::ExClause<Self>;
@ -1204,18 +1204,18 @@ where
type LiftedDelayedLiteral: Debug + 'tcx; type LiftedDelayedLiteral: Debug + 'tcx;
type LiftedLiteral: Debug + 'tcx; type LiftedLiteral: Debug + 'tcx;
fn lift_ex_clause_to_tcx<'gcx>( fn lift_ex_clause_to_tcx(
ex_clause: &chalk_engine::ExClause<Self>, ex_clause: &chalk_engine::ExClause<Self>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
) -> Option<Self::LiftedExClause>; ) -> Option<Self::LiftedExClause>;
fn lift_delayed_literal_to_tcx<'gcx>( fn lift_delayed_literal_to_tcx(
ex_clause: &chalk_engine::DelayedLiteral<Self>, ex_clause: &chalk_engine::DelayedLiteral<Self>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
) -> Option<Self::LiftedDelayedLiteral>; ) -> Option<Self::LiftedDelayedLiteral>;
fn lift_literal_to_tcx<'gcx>( fn lift_literal_to_tcx(
ex_clause: &chalk_engine::Literal<Self>, ex_clause: &chalk_engine::Literal<Self>,
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
) -> Option<Self::LiftedLiteral>; ) -> Option<Self::LiftedLiteral>;
} }

View file

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

View file

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

View file

@ -183,8 +183,8 @@ impl<'tcx> ProjectionTyCandidateSet<'tcx> {
/// ///
/// If successful, this may result in additional obligations. Also returns /// If successful, this may result in additional obligations. Also returns
/// the projection cache key used to track these additional obligations. /// the projection cache key used to track these additional obligations.
pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>( pub fn poly_project_and_unify_type<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &PolyProjectionObligation<'tcx>) obligation: &PolyProjectionObligation<'tcx>)
-> Result<Option<Vec<PredicateObligation<'tcx>>>, -> Result<Option<Vec<PredicateObligation<'tcx>>>,
MismatchedProjectionTypes<'tcx>> MismatchedProjectionTypes<'tcx>>
@ -210,8 +210,8 @@ pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>(
/// <T as Trait>::U == V /// <T as Trait>::U == V
/// ///
/// If successful, this may result in additional obligations. /// If successful, this may result in additional obligations.
fn project_and_unify_type<'cx, 'gcx, 'tcx>( fn project_and_unify_type<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionObligation<'tcx>) obligation: &ProjectionObligation<'tcx>)
-> Result<Option<Vec<PredicateObligation<'tcx>>>, -> Result<Option<Vec<PredicateObligation<'tcx>>>,
MismatchedProjectionTypes<'tcx>> MismatchedProjectionTypes<'tcx>>
@ -253,7 +253,7 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
/// them with a fully resolved type where possible. The return value /// them with a fully resolved type where possible. The return value
/// combines the normalized result and any additional obligations that /// combines the normalized result and any additional obligations that
/// were incurred as result. /// were incurred as result.
pub fn normalize<'a, 'b, 'gcx, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, pub fn normalize<'a, 'b, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
value: &T) value: &T)
@ -264,8 +264,8 @@ pub fn normalize<'a, 'b, 'gcx, 'tcx, T>(selcx: &'a mut SelectionContext<'b, 'gcx
} }
/// As `normalize`, but with a custom depth. /// As `normalize`, but with a custom depth.
pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>( pub fn normalize_with_depth<'a, 'b, 'tcx, T>(
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
depth: usize, depth: usize,
@ -287,20 +287,20 @@ pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>(
} }
} }
struct AssocTypeNormalizer<'a, 'b: 'a, 'gcx: 'b+'tcx, 'tcx: 'b> { struct AssocTypeNormalizer<'a, 'b: 'a, 'tcx: 'b> {
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
obligations: Vec<PredicateObligation<'tcx>>, obligations: Vec<PredicateObligation<'tcx>>,
depth: usize, depth: usize,
} }
impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> {
fn new(selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, fn new(selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
depth: usize) depth: usize)
-> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> -> AssocTypeNormalizer<'a, 'b, 'tcx>
{ {
AssocTypeNormalizer { AssocTypeNormalizer {
selcx, selcx,
@ -322,8 +322,8 @@ impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> {
} }
} }
impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
fn tcx<'c>(&'c self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'c>(&'c self) -> TyCtxt<'tcx> {
self.selcx.tcx() self.selcx.tcx()
} }
@ -456,8 +456,8 @@ impl<'tcx,T> Normalized<'tcx,T> {
/// there are unresolved type variables in the projection, we will /// there are unresolved type variables in the projection, we will
/// substitute a fresh type variable `$X` and generate a new /// substitute a fresh type variable `$X` and generate a new
/// obligation `<T as Trait>::Item == $X` for later. /// obligation `<T as Trait>::Item == $X` for later.
pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>( pub fn normalize_projection_type<'a, 'b, 'tcx>(
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -501,8 +501,8 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
/// often immediately appended to another obligations vector. So now this /// often immediately appended to another obligations vector. So now this
/// function takes an obligations vector and appends to it directly, which is /// function takes an obligations vector and appends to it directly, which is
/// slightly uglier but avoids the need for an extra short-lived allocation. /// slightly uglier but avoids the need for an extra short-lived allocation.
fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( fn opt_normalize_projection_type<'a, 'b, 'tcx>(
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -705,7 +705,7 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
/// If there are unresolved type variables, then we need to include /// If there are unresolved type variables, then we need to include
/// any subobligations that bind them, at least until those type /// any subobligations that bind them, at least until those type
/// variables are fully resolved. /// variables are fully resolved.
fn prune_cache_value_obligations<'a, 'gcx, 'tcx>(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, fn prune_cache_value_obligations<'a, 'tcx>(infcx: &'a InferCtxt<'a, 'tcx>,
result: &NormalizedTy<'tcx>) result: &NormalizedTy<'tcx>)
-> NormalizedTy<'tcx> { -> NormalizedTy<'tcx> {
if infcx.unresolved_type_vars(&result.value).is_none() { if infcx.unresolved_type_vars(&result.value).is_none() {
@ -763,8 +763,8 @@ fn prune_cache_value_obligations<'a, 'gcx, 'tcx>(infcx: &'a InferCtxt<'a, 'gcx,
/// that may yet turn out to be wrong. This *may* lead to some sort /// that may yet turn out to be wrong. This *may* lead to some sort
/// of trouble, though we don't have a concrete example of how that /// of trouble, though we don't have a concrete example of how that
/// can occur yet. But it seems risky at best. /// can occur yet. But it seems risky at best.
fn get_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>( fn get_paranoid_cache_value_obligation<'a, 'tcx>(
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -799,7 +799,7 @@ fn get_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>(
/// an error for this obligation, but we legitimately should not, /// an error for this obligation, but we legitimately should not,
/// because it contains `[type error]`. Yuck! (See issue #29857 for /// because it contains `[type error]`. Yuck! (See issue #29857 for
/// one case where this arose.) /// one case where this arose.)
fn normalize_to_error<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tcx>, fn normalize_to_error<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -836,7 +836,7 @@ struct Progress<'tcx> {
} }
impl<'tcx> Progress<'tcx> { impl<'tcx> Progress<'tcx> {
fn error<'gcx>(tcx: TyCtxt<'gcx, 'tcx>) -> Self { fn error(tcx: TyCtxt<'tcx>) -> Self {
Progress { Progress {
ty: tcx.types.err, ty: tcx.types.err,
obligations: vec![], obligations: vec![],
@ -861,8 +861,8 @@ impl<'tcx> Progress<'tcx> {
/// ///
/// IMPORTANT: /// IMPORTANT:
/// - `obligation` must be fully normalized /// - `obligation` must be fully normalized
fn project_type<'cx, 'gcx, 'tcx>( fn project_type<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>) obligation: &ProjectionTyObligation<'tcx>)
-> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>> -> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>>
{ {
@ -925,8 +925,8 @@ fn project_type<'cx, 'gcx, 'tcx>(
/// The first thing we have to do is scan through the parameter /// The first thing we have to do is scan through the parameter
/// environment to see whether there are any projection predicates /// environment to see whether there are any projection predicates
/// there that can answer this question. /// there that can answer this question.
fn assemble_candidates_from_param_env<'cx, 'gcx, 'tcx>( fn assemble_candidates_from_param_env<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>) candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
@ -950,8 +950,8 @@ fn assemble_candidates_from_param_env<'cx, 'gcx, 'tcx>(
/// ``` /// ```
/// ///
/// Here, for example, we could conclude that the result is `i32`. /// Here, for example, we could conclude that the result is `i32`.
fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>( fn assemble_candidates_from_trait_def<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>) candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
@ -986,8 +986,8 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>(
bounds) bounds)
} }
fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>( fn assemble_candidates_from_predicates<'cx, 'tcx, I>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>, candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
@ -1029,8 +1029,8 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>(
} }
} }
fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>( fn assemble_candidates_from_impls<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>) candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
@ -1177,8 +1177,8 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>(
}); });
} }
fn confirm_candidate<'cx, 'gcx, 'tcx>( fn confirm_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate: ProjectionTyCandidate<'tcx>) candidate: ProjectionTyCandidate<'tcx>)
@ -1200,8 +1200,8 @@ fn confirm_candidate<'cx, 'gcx, 'tcx>(
} }
} }
fn confirm_select_candidate<'cx, 'gcx, 'tcx>( fn confirm_select_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>, obligation_trait_ref: &ty::TraitRef<'tcx>,
vtable: Selection<'tcx>) vtable: Selection<'tcx>)
@ -1230,8 +1230,8 @@ fn confirm_select_candidate<'cx, 'gcx, 'tcx>(
} }
} }
fn confirm_object_candidate<'cx, 'gcx, 'tcx>( fn confirm_object_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>) obligation_trait_ref: &ty::TraitRef<'tcx>)
-> Progress<'tcx> -> Progress<'tcx>
@ -1295,8 +1295,8 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>(
confirm_param_env_candidate(selcx, obligation, env_predicate) confirm_param_env_candidate(selcx, obligation, env_predicate)
} }
fn confirm_generator_candidate<'cx, 'gcx, 'tcx>( fn confirm_generator_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>) vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx> -> Progress<'tcx>
@ -1348,8 +1348,8 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>(
.with_addl_obligations(obligations) .with_addl_obligations(obligations)
} }
fn confirm_fn_pointer_candidate<'cx, 'gcx, 'tcx>( fn confirm_fn_pointer_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>) fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx> -> Progress<'tcx>
@ -1370,8 +1370,8 @@ fn confirm_fn_pointer_candidate<'cx, 'gcx, 'tcx>(
.with_addl_obligations(obligations) .with_addl_obligations(obligations)
} }
fn confirm_closure_candidate<'cx, 'gcx, 'tcx>( fn confirm_closure_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>) vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx> -> Progress<'tcx>
@ -1402,8 +1402,8 @@ fn confirm_closure_candidate<'cx, 'gcx, 'tcx>(
.with_addl_obligations(obligations) .with_addl_obligations(obligations)
} }
fn confirm_callable_candidate<'cx, 'gcx, 'tcx>( fn confirm_callable_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
fn_sig: ty::PolyFnSig<'tcx>, fn_sig: ty::PolyFnSig<'tcx>,
flag: util::TupleArgumentsFlag) flag: util::TupleArgumentsFlag)
@ -1437,8 +1437,8 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
confirm_param_env_candidate(selcx, obligation, predicate) confirm_param_env_candidate(selcx, obligation, predicate)
} }
fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>( fn confirm_param_env_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
poly_cache_entry: ty::PolyProjectionPredicate<'tcx>, poly_cache_entry: ty::PolyProjectionPredicate<'tcx>,
) -> Progress<'tcx> { ) -> Progress<'tcx> {
@ -1478,8 +1478,8 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
} }
} }
fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( fn confirm_impl_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>) impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>)
-> Progress<'tcx> -> Progress<'tcx>
@ -1521,8 +1521,8 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
/// ///
/// Based on the "projection mode", this lookup may in fact only examine the /// Based on the "projection mode", this lookup may in fact only examine the
/// topmost impl. See the comments for `Reveal` for more details. /// topmost impl. See the comments for `Reveal` for more details.
fn assoc_ty_def<'cx, 'gcx, 'tcx>( fn assoc_ty_def<'cx, 'tcx>(
selcx: &SelectionContext<'cx, 'gcx, 'tcx>, selcx: &SelectionContext<'cx, 'tcx>,
impl_def_id: DefId, impl_def_id: DefId,
assoc_ty_def_id: DefId) assoc_ty_def_id: DefId)
-> specialization_graph::NodeItem<ty::AssocItem> -> specialization_graph::NodeItem<ty::AssocItem>
@ -1608,8 +1608,8 @@ pub struct ProjectionCacheKey<'tcx> {
ty: ty::ProjectionTy<'tcx> ty: ty::ProjectionTy<'tcx>
} }
impl<'cx, 'gcx, 'tcx> ProjectionCacheKey<'tcx> { impl<'cx, 'tcx> ProjectionCacheKey<'tcx> {
pub fn from_poly_projection_predicate(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, pub fn from_poly_projection_predicate(selcx: &mut SelectionContext<'cx, 'tcx>,
predicate: &ty::PolyProjectionPredicate<'tcx>) predicate: &ty::PolyProjectionPredicate<'tcx>)
-> Option<Self> -> Option<Self>
{ {

View file

@ -6,7 +6,7 @@ use syntax::source_map::Span;
use crate::ty::subst::Kind; use crate::ty::subst::Kind;
use crate::ty::{self, Ty, TyCtxt}; use crate::ty::{self, Ty, TyCtxt};
impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> At<'cx, 'tcx> {
/// Given a type `ty` of some value being dropped, computes a set /// Given a type `ty` of some value being dropped, computes a set
/// of "kinds" (types, regions) that must be outlive the execution /// of "kinds" (types, regions) that must be outlive the execution
/// of the destructor. These basically correspond to data that the /// of the destructor. These basically correspond to data that the
@ -85,7 +85,7 @@ pub struct DropckOutlivesResult<'tcx> {
} }
impl<'tcx> 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() { if let Some(overflow_ty) = self.overflows.iter().next() {
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
@ -101,7 +101,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn into_kinds_reporting_overflows( pub fn into_kinds_reporting_overflows(
self, self,
tcx: TyCtxt<'_, 'tcx>, tcx: TyCtxt<'tcx>,
span: Span, span: Span,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) -> Vec<Kind<'tcx>> { ) -> Vec<Kind<'tcx>> {
@ -185,7 +185,7 @@ impl_stable_hash_for!(struct DtorckConstraint<'tcx> {
/// ///
/// Note also that `needs_drop` requires a "global" type (i.e., one /// Note also that `needs_drop` requires a "global" type (i.e., one
/// with erased regions), but this function does not. /// with erased regions), but this function does not.
pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> bool { pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty { match ty.sty {
// None of these types have a destructor and hence they do not // None of these types have a destructor and hence they do not
// require anything in particular to outlive the dtor's // require anything in particular to outlive the dtor's

View file

@ -3,7 +3,7 @@ use crate::infer::canonical::OriginalQueryValues;
use crate::traits::{EvaluationResult, PredicateObligation, SelectionContext, use crate::traits::{EvaluationResult, PredicateObligation, SelectionContext,
TraitQueryMode, OverflowError}; TraitQueryMode, OverflowError};
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// Evaluates whether the predicate can be satisfied (by any means) /// Evaluates whether the predicate can be satisfied (by any means)
/// in the given `ParamEnv`. /// in the given `ParamEnv`.
pub fn predicate_may_hold( pub fn predicate_may_hold(

View file

@ -14,7 +14,7 @@ use crate::ty::{self, Ty, TyCtxt};
use super::NoSolution; use super::NoSolution;
impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> At<'cx, 'tcx> {
/// Normalize `value` in the context of the inference context, /// Normalize `value` in the context of the inference context,
/// yielding a resulting type, or an error if `value` cannot be /// yielding a resulting type, or an error if `value` cannot be
/// normalized. If you don't care about regions, you should prefer /// normalized. If you don't care about regions, you should prefer
@ -73,8 +73,8 @@ pub struct NormalizationResult<'tcx> {
pub normalized_ty: Ty<'tcx>, pub normalized_ty: Ty<'tcx>,
} }
struct QueryNormalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> { struct QueryNormalizer<'cx, 'tcx: 'cx> {
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
cause: &'cx ObligationCause<'tcx>, cause: &'cx ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
obligations: Vec<PredicateObligation<'tcx>>, obligations: Vec<PredicateObligation<'tcx>>,
@ -82,8 +82,8 @@ struct QueryNormalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
anon_depth: usize, anon_depth: usize,
} }
impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
fn tcx<'c>(&'c self) -> TyCtxt<'gcx, 'tcx> { fn tcx<'c>(&'c self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }

View file

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

View file

@ -64,7 +64,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OutlivesBound<'tcx> {
} }
} }
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// Implied bounds are region relationships that we deduce /// Implied bounds are region relationships that we deduce
/// automatically. The idea is that (e.g.) a caller must check that a /// automatically. The idea is that (e.g.) a caller must check that a
/// function's argument types are well-formed immediately before /// function's argument types are well-formed immediately before

View file

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

View file

@ -14,9 +14,9 @@ pub struct CustomTypeOp<F, G> {
} }
impl<F, G> CustomTypeOp<F, G> { impl<F, G> CustomTypeOp<F, G> {
pub fn new<'gcx, 'tcx, R>(closure: F, description: G) -> Self pub fn new<'tcx, R>(closure: F, description: G) -> Self
where where
F: FnOnce(&InferCtxt<'_, 'gcx, 'tcx>) -> Fallible<InferOk<'tcx, R>>, F: FnOnce(&InferCtxt<'_, 'tcx>) -> Fallible<InferOk<'tcx, R>>,
G: Fn() -> String, G: Fn() -> String,
{ {
CustomTypeOp { CustomTypeOp {
@ -26,9 +26,9 @@ impl<F, G> CustomTypeOp<F, G> {
} }
} }
impl<'gcx, 'tcx, F, R, G> super::TypeOp<'gcx, 'tcx> for CustomTypeOp<F, G> impl<'tcx, F, R, G> super::TypeOp<'tcx> for CustomTypeOp<F, G>
where where
F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'gcx, 'tcx>) -> Fallible<InferOk<'tcx, R>>, F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'tcx>) -> Fallible<InferOk<'tcx, R>>,
G: Fn() -> String, G: Fn() -> String,
{ {
type Output = R; type Output = R;
@ -38,7 +38,7 @@ where
/// (they will be given over to the NLL region solver). /// (they will be given over to the NLL region solver).
fn fully_perform( fn fully_perform(
self, self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> { ) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> {
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
info!("fully_perform({:?})", self); info!("fully_perform({:?})", self);
@ -59,8 +59,8 @@ where
/// Executes `op` and then scrapes out all the "old style" region /// Executes `op` and then scrapes out all the "old style" region
/// constraints that result, creating query-region-constraints. /// constraints that result, creating query-region-constraints.
fn scrape_region_constraints<'gcx, 'tcx, R>( fn scrape_region_constraints<'tcx, R>(
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>, op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
) -> Fallible<(R, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> { ) -> Fallible<(R, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> {
let mut fulfill_cx = TraitEngine::new(infcx.tcx); let mut fulfill_cx = TraitEngine::new(infcx.tcx);

View file

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

View file

@ -14,20 +14,20 @@ impl<'tcx> ImpliedOutlivesBounds<'tcx> {
} }
} }
impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds<'tcx> { impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
type QueryResponse = Vec<OutlivesBound<'tcx>>; type QueryResponse = Vec<OutlivesBound<'tcx>>;
fn try_fast_path( fn try_fast_path(
_tcx: TyCtxt<'gcx, 'tcx>, _tcx: TyCtxt<'tcx>,
_key: &ParamEnvAnd<'tcx, Self>, _key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
None None
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
// FIXME this `unchecked_map` is only necessary because the // FIXME this `unchecked_map` is only necessary because the
// query is defined as taking a `ParamEnvAnd<Ty>`; it should // query is defined as taking a `ParamEnvAnd<Ty>`; it should
// take a `ImpliedOutlivesBounds` instead // take a `ImpliedOutlivesBounds` instead
@ -40,7 +40,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds<
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, v: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> {
v v
} }

View file

@ -23,7 +23,7 @@ pub mod subtype;
/// "Type ops" are used in NLL to perform some particular action and /// "Type ops" are used in NLL to perform some particular action and
/// extract out the resulting region constraints (or an error if it /// extract out the resulting region constraints (or an error if it
/// cannot be completed). /// cannot be completed).
pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { pub trait TypeOp<'tcx>: Sized + fmt::Debug {
type Output; type Output;
/// Processes the operation and all resulting obligations, /// Processes the operation and all resulting obligations,
@ -31,7 +31,7 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
/// (they will be given over to the NLL region solver). /// (they will be given over to the NLL region solver).
fn fully_perform( fn fully_perform(
self, self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)>; ) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)>;
} }
@ -44,16 +44,16 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
/// which produces the resulting query region constraints. /// which produces the resulting query region constraints.
/// ///
/// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html /// [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: pub trait QueryTypeOp<'tcx>:
fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'gcx> fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'tcx>
{ {
type QueryResponse: TypeFoldable<'tcx> + Lift<'gcx>; type QueryResponse: TypeFoldable<'tcx> + Lift<'tcx>;
/// Give query the option for a simple fast path that never /// Give query the option for a simple fast path that never
/// actually hits the tcx cache lookup etc. Return `Some(r)` with /// actually hits the tcx cache lookup etc. Return `Some(r)` with
/// a final result or `None` to do the full path. /// a final result or `None` to do the full path.
fn try_fast_path( fn try_fast_path(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
key: &ParamEnvAnd<'tcx, Self>, key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse>; ) -> Option<Self::QueryResponse>;
@ -64,29 +64,29 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>:
/// bad, because it would create subregion relationships that are /// bad, because it would create subregion relationships that are
/// not captured in the return value. /// not captured in the return value.
fn perform_query( fn perform_query(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>>; ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>>;
/// Casts a lifted query result (which is in the gcx lifetime) /// Casts a lifted query result (which is in the gcx lifetime)
/// into the tcx lifetime. This is always just an identity cast, /// into the tcx lifetime. This is always just an identity cast,
/// but the generic code doesn't realize it -- put another way, in /// but the generic code doesn't realize it -- put another way, in
/// the generic code, we have a `Lifted<'gcx, Self::QueryResponse>` /// the generic code, we have a `Lifted<'tcx, Self::QueryResponse>`
/// and we want to convert that to a `Self::QueryResponse`. This is /// and we want to convert that to a `Self::QueryResponse`. This is
/// not a priori valid, so we can't do it -- but in practice, it /// not a priori valid, so we can't do it -- but in practice, it
/// is always a no-op (e.g., the lifted form of a type, /// is always a no-op (e.g., the lifted form of a type,
/// `Ty<'gcx>`, is a subtype of `Ty<'tcx>`). So we have to push /// `Ty<'tcx>`, is a subtype of `Ty<'tcx>`). So we have to push
/// the operation into the impls that know more specifically what /// the operation into the impls that know more specifically what
/// `QueryResponse` is. This operation would (maybe) be nicer with /// `QueryResponse` is. This operation would (maybe) be nicer with
/// something like HKTs or GATs, since then we could make /// something like HKTs or GATs, since then we could make
/// `QueryResponse` parametric and `'gcx` and `'tcx` etc. /// `QueryResponse` parametric and `'tcx` and `'tcx` etc.
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
lifted_query_result: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>; ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>;
fn fully_perform_into( fn fully_perform_into(
query_key: ParamEnvAnd<'tcx, Self>, query_key: ParamEnvAnd<'tcx, Self>,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
output_query_region_constraints: &mut Vec<QueryRegionConstraint<'tcx>>, output_query_region_constraints: &mut Vec<QueryRegionConstraint<'tcx>>,
) -> Fallible<Self::QueryResponse> { ) -> Fallible<Self::QueryResponse> {
if let Some(result) = QueryTypeOp::try_fast_path(infcx.tcx, &query_key) { if let Some(result) = QueryTypeOp::try_fast_path(infcx.tcx, &query_key) {
@ -133,15 +133,15 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>:
} }
} }
impl<'gcx: 'tcx, 'tcx, Q> TypeOp<'gcx, 'tcx> for ParamEnvAnd<'tcx, Q> impl<'tcx, Q> TypeOp<'tcx> for ParamEnvAnd<'tcx, Q>
where where
Q: QueryTypeOp<'gcx, 'tcx>, Q: QueryTypeOp<'tcx>,
{ {
type Output = Q::QueryResponse; type Output = Q::QueryResponse;
fn fully_perform( fn fully_perform(
self, self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> { ) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> {
let mut qrc = vec![]; let mut qrc = vec![];
let r = Q::fully_perform_into(self, infcx, &mut qrc)?; let r = Q::fully_perform_into(self, infcx, &mut qrc)?;

View file

@ -18,13 +18,13 @@ where
} }
} }
impl<'gcx: 'tcx, 'tcx, T> super::QueryTypeOp<'gcx, 'tcx> for Normalize<T> impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<T>
where where
T: Normalizable<'gcx, 'tcx>, T: Normalizable<'tcx>,
{ {
type QueryResponse = T; type QueryResponse = T;
fn try_fast_path(_tcx: TyCtxt<'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> { fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
if !key.value.value.has_projections() { if !key.value.value.has_projections() {
Some(key.value.value) Some(key.value.value)
} else { } else {
@ -33,99 +33,87 @@ where
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
T::type_op_method(tcx, canonicalized) T::type_op_method(tcx, canonicalized)
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, T>, v: &'a CanonicalizedQueryResponse<'tcx, T>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> {
T::shrink_to_tcx_lifetime(v) T::shrink_to_tcx_lifetime(v)
} }
} }
pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx> + Copy { pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>>; ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>>;
/// Converts from the `'gcx` (lifted) form of `Self` into the `tcx` /// Converts from the `'tcx` (lifted) form of `Self` into the `tcx`
/// form of `Self`. /// form of `Self`.
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, Self>, v: &'a CanonicalizedQueryResponse<'tcx, Self>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>; ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>;
} }
impl Normalizable<'gcx, 'tcx> for Ty<'tcx> impl Normalizable<'tcx> for Ty<'tcx> {
where
'gcx: 'tcx,
{
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
tcx.type_op_normalize_ty(canonicalized) tcx.type_op_normalize_ty(canonicalized)
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, Self>, v: &'a CanonicalizedQueryResponse<'tcx, Self>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
v v
} }
} }
impl Normalizable<'gcx, 'tcx> for ty::Predicate<'tcx> impl Normalizable<'tcx> for ty::Predicate<'tcx> {
where
'gcx: 'tcx,
{
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
tcx.type_op_normalize_predicate(canonicalized) tcx.type_op_normalize_predicate(canonicalized)
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, Self>, v: &'a CanonicalizedQueryResponse<'tcx, Self>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
v v
} }
} }
impl Normalizable<'gcx, 'tcx> for ty::PolyFnSig<'tcx> impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
where
'gcx: 'tcx,
{
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
tcx.type_op_normalize_poly_fn_sig(canonicalized) tcx.type_op_normalize_poly_fn_sig(canonicalized)
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, Self>, v: &'a CanonicalizedQueryResponse<'tcx, Self>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
v v
} }
} }
impl Normalizable<'gcx, 'tcx> for ty::FnSig<'tcx> impl Normalizable<'tcx> for ty::FnSig<'tcx> {
where
'gcx: 'tcx,
{
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
tcx.type_op_normalize_fn_sig(canonicalized) tcx.type_op_normalize_fn_sig(canonicalized)
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
v: &'a CanonicalizedQueryResponse<'gcx, Self>, v: &'a CanonicalizedQueryResponse<'tcx, Self>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
v v
} }

View file

@ -15,14 +15,11 @@ impl<'tcx> DropckOutlives<'tcx> {
} }
} }
impl super::QueryTypeOp<'gcx, 'tcx> for DropckOutlives<'tcx> impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
where
'gcx: 'tcx,
{
type QueryResponse = DropckOutlivesResult<'tcx>; type QueryResponse = DropckOutlivesResult<'tcx>;
fn try_fast_path( fn try_fast_path(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
key: &ParamEnvAnd<'tcx, Self>, key: &ParamEnvAnd<'tcx, Self>,
) -> Option<Self::QueryResponse> { ) -> Option<Self::QueryResponse> {
if trivial_dropck_outlives(tcx, key.value.dropped_ty) { if trivial_dropck_outlives(tcx, key.value.dropped_ty) {
@ -33,9 +30,9 @@ where
} }
fn perform_query( fn perform_query(
tcx: TyCtxt<'gcx, 'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResponse<'gcx, Self::QueryResponse>> { ) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
// Subtle: note that we are not invoking // Subtle: note that we are not invoking
// `infcx.at(...).dropck_outlives(...)` here, but rather the // `infcx.at(...).dropck_outlives(...)` here, but rather the
// underlying `dropck_outlives` query. This same underlying // underlying `dropck_outlives` query. This same underlying
@ -58,7 +55,7 @@ where
} }
fn shrink_to_tcx_lifetime( fn shrink_to_tcx_lifetime(
lifted_query_result: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> {
lifted_query_result lifted_query_result
} }

View file

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

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