rustc: Split 'tcx into 'gcx and 'tcx for InferCtxt and its users.
This commit is contained in:
parent
166dbc3273
commit
76affa5d6f
160 changed files with 1296 additions and 1189 deletions
|
|
@ -19,7 +19,7 @@ use syntax::ptr::P;
|
|||
use hir::{self, PatKind};
|
||||
|
||||
struct CFGBuilder<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
graph: CFGGraph,
|
||||
fn_exit: CFGIndex,
|
||||
loop_scopes: Vec<LoopScope>,
|
||||
|
|
@ -32,8 +32,8 @@ struct LoopScope {
|
|||
break_index: CFGIndex, // where to go on a `break
|
||||
}
|
||||
|
||||
pub fn construct(tcx: TyCtxt,
|
||||
blk: &hir::Block) -> CFG {
|
||||
pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
blk: &hir::Block) -> CFG {
|
||||
let mut graph = graph::Graph::new();
|
||||
let entry = graph.add_node(CFGNodeData::Entry);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ pub type CFGNode = graph::Node<CFGNodeData>;
|
|||
pub type CFGEdge = graph::Edge<CFGEdgeData>;
|
||||
|
||||
impl CFG {
|
||||
pub fn new(tcx: TyCtxt,
|
||||
blk: &hir::Block) -> CFG {
|
||||
pub fn new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
blk: &hir::Block) -> CFG {
|
||||
construct::construct(tcx, blk)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ use super::dep_node::DepNode;
|
|||
/// read edge from the corresponding AST node. This is used in
|
||||
/// compiler passes to automatically record the item that they are
|
||||
/// working on.
|
||||
pub fn visit_all_items_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn visit_all_items_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mut dep_node_fn: F,
|
||||
visitor: &mut V)
|
||||
where F: FnMut(DefId) -> DepNode<DefId>, V: Visitor<'tcx>
|
||||
{
|
||||
struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> {
|
||||
tcx: TyCtxt<'visit, 'tcx>,
|
||||
tcx: TyCtxt<'visit, 'tcx, 'tcx>,
|
||||
dep_node_fn: &'visit mut F,
|
||||
visitor: &'visit mut V
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn def_to_path(tcx: TyCtxt, id: DefId) -> hir::Path {
|
||||
pub fn def_to_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> hir::Path {
|
||||
let name = tcx.item_name(id);
|
||||
hir::Path::from_ident(DUMMY_SP, hir::Ident::from_name(name))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,20 +32,20 @@ use ty::{self, Ty, TyCtxt};
|
|||
use ty::TyVar;
|
||||
use ty::relate::{Relate, RelateResult, TypeRelation};
|
||||
|
||||
pub struct Bivariate<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>
|
||||
pub struct Bivariate<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'gcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Bivariate<'a, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx>) -> Bivariate<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Bivariate<'a, 'tcx, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx, 'tcx>) -> Bivariate<'a, 'tcx, 'tcx> {
|
||||
Bivariate { fields: fields }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx, 'tcx> {
|
||||
fn tag(&self) -> &'static str { "Bivariate" }
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.fields.tcx() }
|
||||
|
||||
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
|
||||
|
||||
|
|
|
|||
|
|
@ -52,15 +52,15 @@ use syntax::ast;
|
|||
use syntax::codemap::Span;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CombineFields<'a, 'tcx: 'a> {
|
||||
pub infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
pub struct CombineFields<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
pub a_is_expected: bool,
|
||||
pub trace: TypeTrace<'tcx>,
|
||||
pub cause: Option<ty::relate::Cause>,
|
||||
pub obligations: PredicateObligations<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn super_combine_tys<R>(&self,
|
||||
relation: &mut R,
|
||||
a: Ty<'tcx>,
|
||||
|
|
@ -150,35 +150,35 @@ fn unify_float_variable(&self,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> CombineFields<'a, 'tcx, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
pub fn switch_expected(&self) -> CombineFields<'a, 'tcx> {
|
||||
pub fn switch_expected(&self) -> CombineFields<'a, 'tcx, 'tcx> {
|
||||
CombineFields {
|
||||
a_is_expected: !self.a_is_expected,
|
||||
..(*self).clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn equate(&self) -> Equate<'a, 'tcx> {
|
||||
pub fn equate(&self) -> Equate<'a, 'tcx, 'tcx> {
|
||||
Equate::new(self.clone())
|
||||
}
|
||||
|
||||
pub fn bivariate(&self) -> Bivariate<'a, 'tcx> {
|
||||
pub fn bivariate(&self) -> Bivariate<'a, 'tcx, 'tcx> {
|
||||
Bivariate::new(self.clone())
|
||||
}
|
||||
|
||||
pub fn sub(&self) -> Sub<'a, 'tcx> {
|
||||
pub fn sub(&self) -> Sub<'a, 'tcx, 'tcx> {
|
||||
Sub::new(self.clone())
|
||||
}
|
||||
|
||||
pub fn lub(&self) -> Lub<'a, 'tcx> {
|
||||
pub fn lub(&self) -> Lub<'a, 'tcx, 'tcx> {
|
||||
Lub::new(self.clone())
|
||||
}
|
||||
|
||||
pub fn glb(&self) -> Glb<'a, 'tcx> {
|
||||
pub fn glb(&self) -> Glb<'a, 'tcx, 'tcx> {
|
||||
Glb::new(self.clone())
|
||||
}
|
||||
|
||||
|
|
@ -291,16 +291,16 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
struct Generalizer<'cx, 'tcx:'cx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
struct Generalizer<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
span: Span,
|
||||
for_vid: ty::TyVid,
|
||||
make_region_vars: bool,
|
||||
cycle_detected: bool,
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx> {
|
||||
impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx, 'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ use ty::relate::{Relate, RelateResult, TypeRelation};
|
|||
use traits::PredicateObligations;
|
||||
|
||||
/// Ensures `a` is made equal to `b`. Returns `a` on success.
|
||||
pub struct Equate<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>
|
||||
pub struct Equate<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'gcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Equate<'a, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx>) -> Equate<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Equate<'a, 'tcx, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx, 'tcx>) -> Equate<'a, 'tcx, 'tcx> {
|
||||
Equate { fields: fields }
|
||||
}
|
||||
|
||||
|
|
@ -33,10 +33,10 @@ impl<'a, 'tcx> Equate<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx, 'tcx> {
|
||||
fn tag(&self) -> &'static str { "Equate" }
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.fields.tcx() }
|
||||
|
||||
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ use syntax::codemap::{self, Pos, Span};
|
|||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn note_and_explain_region(self,
|
||||
err: &mut DiagnosticBuilder,
|
||||
prefix: &str,
|
||||
|
|
@ -112,8 +112,9 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn explain_span(tcx: TyCtxt, heading: &str, span: Span)
|
||||
-> (String, Option<Span>) {
|
||||
fn explain_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
heading: &str, span: Span)
|
||||
-> (String, Option<Span>) {
|
||||
let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
|
||||
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
|
||||
Some(span))
|
||||
|
|
@ -301,7 +302,7 @@ trait ErrorReportingHelpers<'tcx> {
|
|||
span: Span);
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx, 'tcx> {
|
||||
fn report_region_errors(&self,
|
||||
errors: &Vec<RegionResolutionError<'tcx>>) {
|
||||
debug!("report_region_errors(): {} errors to start", errors.len());
|
||||
|
|
@ -474,10 +475,10 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn free_regions_from_same_fn(tcx: TyCtxt,
|
||||
sub: Region,
|
||||
sup: Region)
|
||||
-> Option<FreeRegionsFromSameFn> {
|
||||
fn free_regions_from_same_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sub: Region,
|
||||
sup: Region)
|
||||
-> Option<FreeRegionsFromSameFn> {
|
||||
debug!("free_regions_from_same_fn(sub={:?}, sup={:?})", sub, sup);
|
||||
let (scope_id, fr1, fr2) = match (sub, sup) {
|
||||
(ReFree(fr1), ReFree(fr2)) => {
|
||||
|
|
@ -1109,7 +1110,7 @@ struct RebuildPathInfo<'a> {
|
|||
}
|
||||
|
||||
struct Rebuilder<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
fn_decl: &'a hir::FnDecl,
|
||||
expl_self_opt: Option<&'a hir::ExplicitSelf_>,
|
||||
generics: &'a hir::Generics,
|
||||
|
|
@ -1125,7 +1126,7 @@ enum FreshOrKept {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
fn_decl: &'a hir::FnDecl,
|
||||
expl_self_opt: Option<&'a hir::ExplicitSelf_>,
|
||||
generics: &'a hir::Generics,
|
||||
|
|
@ -1641,7 +1642,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx, 'tcx> {
|
||||
fn give_expl_lifetime_param(&self,
|
||||
err: &mut DiagnosticBuilder,
|
||||
decl: &hir::FnDecl,
|
||||
|
|
@ -1904,17 +1905,17 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub trait Resolvable<'tcx> {
|
||||
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>) -> Self;
|
||||
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx, 'tcx>) -> Self;
|
||||
}
|
||||
|
||||
impl<'tcx> Resolvable<'tcx> for Ty<'tcx> {
|
||||
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
infcx.resolve_type_vars_if_possible(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Resolvable<'tcx> for ty::TraitRef<'tcx> {
|
||||
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx>)
|
||||
fn resolve<'a>(&self, infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::TraitRef<'tcx> {
|
||||
infcx.resolve_type_vars_if_possible(self)
|
||||
}
|
||||
|
|
@ -1922,16 +1923,16 @@ impl<'tcx> Resolvable<'tcx> for ty::TraitRef<'tcx> {
|
|||
|
||||
impl<'tcx> Resolvable<'tcx> for ty::PolyTraitRef<'tcx> {
|
||||
fn resolve<'a>(&self,
|
||||
infcx: &InferCtxt<'a, 'tcx>)
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::PolyTraitRef<'tcx>
|
||||
{
|
||||
infcx.resolve_type_vars_if_possible(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn lifetimes_in_scope(tcx: TyCtxt,
|
||||
scope_id: ast::NodeId)
|
||||
-> Vec<hir::LifetimeDef> {
|
||||
fn lifetimes_in_scope<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
scope_id: ast::NodeId)
|
||||
-> Vec<hir::LifetimeDef> {
|
||||
let mut taken = Vec::new();
|
||||
let parent = tcx.map.get_parent(scope_id);
|
||||
let method_id_opt = match tcx.map.find(parent) {
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ use std::collections::hash_map::{self, Entry};
|
|||
use super::InferCtxt;
|
||||
use super::unify_key::ToType;
|
||||
|
||||
pub struct TypeFreshener<'a, 'tcx:'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
pub struct TypeFreshener<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
freshen_count: u32,
|
||||
freshen_map: hash_map::HashMap<ty::InferTy, Ty<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> TypeFreshener<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeFreshener<'a, 'tcx, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx, 'tcx>) -> TypeFreshener<'a, 'tcx, 'tcx> {
|
||||
TypeFreshener {
|
||||
infcx: infcx,
|
||||
freshen_count: 0,
|
||||
|
|
@ -77,8 +77,8 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ use ty::relate::{Relate, RelateResult, TypeRelation};
|
|||
use traits::PredicateObligations;
|
||||
|
||||
/// "Greatest lower bound" (common subtype)
|
||||
pub struct Glb<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>
|
||||
pub struct Glb<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'gcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Glb<'a, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx>) -> Glb<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Glb<'a, 'tcx, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx, 'tcx>) -> Glb<'a, 'tcx, 'tcx> {
|
||||
Glb { fields: fields }
|
||||
}
|
||||
|
||||
|
|
@ -33,10 +33,10 @@ impl<'a, 'tcx> Glb<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx, 'tcx> {
|
||||
fn tag(&self) -> &'static str { "Glb" }
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.fields.tcx() }
|
||||
|
||||
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
|
||||
|
||||
|
|
@ -76,8 +76,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> LatticeDir<'a,'tcx> for Glb<'a, 'tcx> {
|
||||
fn infcx(&self) -> &'a InferCtxt<'a,'tcx> {
|
||||
impl<'a, 'tcx> LatticeDir<'a,'tcx> for Glb<'a, 'tcx, 'tcx> {
|
||||
fn infcx(&self) -> &'a InferCtxt<'a, 'tcx, 'tcx> {
|
||||
self.fields.infcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub trait HigherRankedRelations<'a,'tcx> {
|
|||
where T: Relate<'a,'tcx>;
|
||||
}
|
||||
|
||||
impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
||||
impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a, 'tcx, 'tcx> {
|
||||
fn higher_ranked_sub<T>(&self, a: &Binder<T>, b: &Binder<T>)
|
||||
-> RelateResult<'tcx, Binder<T>>
|
||||
where T: Relate<'a,'tcx>
|
||||
|
|
@ -119,14 +119,14 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
Ok(ty::Binder(result1))
|
||||
});
|
||||
|
||||
fn generalize_region(infcx: &InferCtxt,
|
||||
span: Span,
|
||||
snapshot: &CombinedSnapshot,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
new_vars: &[ty::RegionVid],
|
||||
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
||||
r0: ty::Region)
|
||||
-> ty::Region {
|
||||
fn generalize_region<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
span: Span,
|
||||
snapshot: &CombinedSnapshot,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
new_vars: &[ty::RegionVid],
|
||||
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
||||
r0: ty::Region)
|
||||
-> ty::Region {
|
||||
// Regions that pre-dated the LUB computation stay as they are.
|
||||
if !is_var_in_set(new_vars, r0) {
|
||||
assert!(!r0.is_bound());
|
||||
|
|
@ -214,15 +214,15 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
Ok(ty::Binder(result1))
|
||||
});
|
||||
|
||||
fn generalize_region(infcx: &InferCtxt,
|
||||
span: Span,
|
||||
snapshot: &CombinedSnapshot,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
new_vars: &[ty::RegionVid],
|
||||
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
||||
a_vars: &[ty::RegionVid],
|
||||
b_vars: &[ty::RegionVid],
|
||||
r0: ty::Region) -> ty::Region {
|
||||
fn generalize_region<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
span: Span,
|
||||
snapshot: &CombinedSnapshot,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
new_vars: &[ty::RegionVid],
|
||||
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
||||
a_vars: &[ty::RegionVid],
|
||||
b_vars: &[ty::RegionVid],
|
||||
r0: ty::Region) -> ty::Region {
|
||||
if !is_var_in_set(new_vars, r0) {
|
||||
assert!(!r0.is_bound());
|
||||
return r0;
|
||||
|
|
@ -306,7 +306,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn var_ids<'a, 'tcx>(fields: &CombineFields<'a, 'tcx>,
|
||||
fn var_ids<'a, 'tcx>(fields: &CombineFields<'a, 'tcx, 'tcx>,
|
||||
map: &FnvHashMap<ty::BoundRegion, ty::Region>)
|
||||
-> Vec<ty::RegionVid> {
|
||||
map.iter()
|
||||
|
|
@ -329,7 +329,7 @@ fn is_var_in_set(new_vars: &[ty::RegionVid], r: ty::Region) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_regions_in<'a, 'tcx, T, F>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn fold_regions_in<'a, 'tcx, T, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
unbound_value: &T,
|
||||
mut fldr: F)
|
||||
-> T
|
||||
|
|
@ -349,7 +349,7 @@ fn fold_regions_in<'a, 'tcx, T, F>(tcx: TyCtxt<'a, 'tcx>,
|
|||
})
|
||||
}
|
||||
|
||||
impl<'a,'tcx> InferCtxt<'a,'tcx> {
|
||||
impl<'a,'tcx> InferCtxt<'a,'tcx, 'tcx> {
|
||||
fn tainted_regions(&self, snapshot: &CombinedSnapshot, r: ty::Region) -> Vec<ty::Region> {
|
||||
self.region_vars.tainted(&snapshot.region_vars_snapshot, r)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use ty::{self, Ty};
|
|||
use ty::relate::{RelateResult, TypeRelation};
|
||||
|
||||
pub trait LatticeDir<'f,'tcx> : TypeRelation<'f,'tcx> {
|
||||
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
|
||||
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx, 'tcx>;
|
||||
|
||||
// Relates the type `v` to `a` and `b` such that `v` represents
|
||||
// the LUB/GLB of `a` and `b` as appropriate.
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ use ty::relate::{Relate, RelateResult, TypeRelation};
|
|||
use traits::PredicateObligations;
|
||||
|
||||
/// "Least upper bound" (common supertype)
|
||||
pub struct Lub<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>
|
||||
pub struct Lub<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'gcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lub<'a, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx>) -> Lub<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Lub<'a, 'tcx, 'tcx> {
|
||||
pub fn new(fields: CombineFields<'a, 'tcx, 'tcx>) -> Lub<'a, 'tcx, 'tcx> {
|
||||
Lub { fields: fields }
|
||||
}
|
||||
|
||||
|
|
@ -33,10 +33,10 @@ impl<'a, 'tcx> Lub<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx, 'tcx> {
|
||||
fn tag(&self) -> &'static str { "Lub" }
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.tcx() }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.fields.tcx() }
|
||||
|
||||
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
|
||||
|
||||
|
|
@ -76,8 +76,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> LatticeDir<'a,'tcx> for Lub<'a, 'tcx> {
|
||||
fn infcx(&self) -> &'a InferCtxt<'a,'tcx> {
|
||||
impl<'a, 'tcx> LatticeDir<'a,'tcx> for Lub<'a, 'tcx, 'tcx> {
|
||||
fn infcx(&self) -> &'a InferCtxt<'a, 'tcx, 'tcx> {
|
||||
self.fields.infcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ pub type Bound<T> = Option<T>;
|
|||
pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result"
|
||||
pub type FixupResult<T> = Result<T, FixupError>; // "fixup result"
|
||||
|
||||
pub struct InferCtxt<'a, 'tcx: 'a> {
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
|
||||
pub tables: &'a RefCell<ty::Tables<'tcx>>,
|
||||
|
||||
|
|
@ -384,8 +384,8 @@ impl fmt::Display for FixupError {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
tables: &'a RefCell<ty::Tables<'tcx>>,
|
||||
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
|
||||
projection_mode: ProjectionMode)
|
||||
|
|
@ -406,7 +406,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn normalizing(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn normalizing(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
tables: &'a RefCell<ty::Tables<'tcx>>,
|
||||
projection_mode: ProjectionMode)
|
||||
-> Self {
|
||||
|
|
@ -441,7 +441,7 @@ pub struct CombinedSnapshot {
|
|||
}
|
||||
|
||||
// NOTE: Callable from trans only!
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn normalize_associated_type<T>(self, value: &T) -> T
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
|
|
@ -473,7 +473,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn drain_fulfillment_cx_or_panic<T>(&self,
|
||||
span: Span,
|
||||
fulfill_cx: &mut traits::FulfillmentContext<'tcx>,
|
||||
|
|
@ -532,7 +532,7 @@ pub fn drain_fulfillment_cx<T>(&self,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx> {
|
||||
pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx, 'tcx> {
|
||||
freshen::TypeFreshener::new(self)
|
||||
}
|
||||
|
||||
|
|
@ -603,8 +603,7 @@ pub fn drain_fulfillment_cx<T>(&self,
|
|||
}
|
||||
|
||||
fn combine_fields(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>)
|
||||
-> CombineFields<'a, 'tcx>
|
||||
{
|
||||
-> CombineFields<'a, 'tcx, 'tcx> {
|
||||
CombineFields {
|
||||
infcx: self,
|
||||
a_is_expected: a_is_expected,
|
||||
|
|
@ -1539,7 +1538,7 @@ impl<'a, 'tcx> TypeTrace<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn dummy(tcx: TyCtxt<'a, 'tcx>) -> TypeTrace<'tcx> {
|
||||
pub fn dummy(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
origin: TypeOrigin::Misc(codemap::DUMMY_SP),
|
||||
values: Types(ExpectedFound {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
|
|||
}
|
||||
|
||||
struct ConstraintGraph<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
graph_name: String,
|
||||
map: &'a FnvHashMap<Constraint, SubregionOrigin<'tcx>>,
|
||||
node_ids: FnvHashMap<Node, usize>,
|
||||
|
|
@ -139,7 +139,7 @@ enum Edge {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
name: String,
|
||||
map: &'a ConstraintMap<'tcx>)
|
||||
-> ConstraintGraph<'a, 'tcx> {
|
||||
|
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'tcx> {
|
|||
|
||||
pub type ConstraintMap<'tcx> = FnvHashMap<Constraint, SubregionOrigin<'tcx>>;
|
||||
|
||||
fn dump_region_constraints_to<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn dump_region_constraints_to<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
map: &ConstraintMap<'tcx>,
|
||||
path: &str)
|
||||
-> io::Result<()> {
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ impl SameRegions {
|
|||
pub type CombineMap = FnvHashMap<TwoRegions, RegionVid>;
|
||||
|
||||
pub struct RegionVarBindings<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
var_origins: RefCell<Vec<RegionVariableOrigin>>,
|
||||
|
||||
// Constraints of the form `A <= B` introduced by the region
|
||||
|
|
@ -254,7 +254,7 @@ pub struct RegionSnapshot {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx>) -> RegionVarBindings<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> RegionVarBindings<'a, 'tcx> {
|
||||
RegionVarBindings {
|
||||
tcx: tcx,
|
||||
var_origins: RefCell::new(Vec::new()),
|
||||
|
|
@ -1363,7 +1363,7 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> GenericKind<'tcx> {
|
||||
pub fn to_ty(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn to_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
GenericKind::Param(ref p) => p.to_ty(tcx),
|
||||
GenericKind::Projection(ref p) => tcx.mk_projection(p.trait_ref.clone(), p.item_name),
|
||||
|
|
@ -1371,7 +1371,7 @@ impl<'a, 'tcx> GenericKind<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl VerifyBound {
|
||||
impl<'a, 'tcx> VerifyBound {
|
||||
fn for_each_region(&self, f: &mut FnMut(ty::Region)) {
|
||||
match self {
|
||||
&VerifyBound::AnyRegion(ref rs) |
|
||||
|
|
@ -1424,7 +1424,7 @@ impl VerifyBound {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_met(&self, tcx: TyCtxt,
|
||||
fn is_met(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
free_regions: &FreeRegionMap,
|
||||
var_values: &Vec<VarValue>,
|
||||
min: ty::Region)
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@ use ty::{self, Ty, TyCtxt, TypeFoldable};
|
|||
/// been unified with (similar to `shallow_resolve`, but deep). This is
|
||||
/// useful for printing messages etc but also required at various
|
||||
/// points for correctness.
|
||||
pub struct OpportunisticTypeResolver<'a, 'tcx:'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> OpportunisticTypeResolver<'a, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> OpportunisticTypeResolver<'a, 'tcx> {
|
||||
impl<'a, 'tcx> OpportunisticTypeResolver<'a, 'tcx, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx, 'tcx>) -> OpportunisticTypeResolver<'a, 'tcx, 'tcx> {
|
||||
OpportunisticTypeResolver { infcx: infcx }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
|
||||
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
@ -47,18 +47,18 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx
|
|||
/// The opportunistic type and region resolver is similar to the
|
||||
/// opportunistic type resolver, but also opportunistly resolves
|
||||
/// regions. It is useful for canonicalization.
|
||||
pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx:'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
pub struct OpportunisticTypeAndRegionResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
|
||||
impl<'a, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'tcx, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx, 'tcx>) -> Self {
|
||||
OpportunisticTypeAndRegionResolver { infcx: infcx }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
|
||||
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,8 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver
|
|||
/// Full type resolution replaces all type and region variables with
|
||||
/// their concrete results. If any variable cannot be replaced (never unified, etc)
|
||||
/// then an `Err` result is returned.
|
||||
pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a,'tcx>, value: &T) -> FixupResult<T>
|
||||
pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
value: &T) -> FixupResult<T>
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
let mut full_resolver = FullTypeResolver { infcx: infcx, err: None };
|
||||
|
|
@ -98,13 +99,13 @@ pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a,'tcx>, value: &T) -> Fixu
|
|||
|
||||
// N.B. This type is not public because the protocol around checking the
|
||||
// `err` field is not enforcable otherwise.
|
||||
struct FullTypeResolver<'a, 'tcx:'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
struct FullTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
err: Option<FixupError>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> {
|
||||
impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ use traits::PredicateObligations;
|
|||
use std::mem;
|
||||
|
||||
/// Ensures `a` is made a subtype of `b`. Returns `a` on success.
|
||||
pub struct Sub<'a, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'tcx>,
|
||||
pub struct Sub<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
fields: CombineFields<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Sub<'a, 'tcx> {
|
||||
pub fn new(f: CombineFields<'a, 'tcx>) -> Sub<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Sub<'a, 'tcx, 'tcx> {
|
||||
pub fn new(f: CombineFields<'a, 'tcx, 'tcx>) -> Sub<'a, 'tcx, 'tcx> {
|
||||
Sub { fields: f }
|
||||
}
|
||||
|
||||
|
|
@ -34,9 +34,9 @@ impl<'a, 'tcx> Sub<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx, 'tcx> {
|
||||
fn tag(&self) -> &'static str { "Sub" }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.fields.infcx.tcx }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.fields.infcx.tcx }
|
||||
fn a_is_expected(&self) -> bool { self.fields.a_is_expected }
|
||||
|
||||
fn with_cause<F,R>(&mut self, cause: Cause, f: F) -> R
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use ty::{self, IntVarValue, Ty, TyCtxt};
|
|||
use rustc_data_structures::unify::{Combine, UnifyKey};
|
||||
|
||||
pub trait ToType<'tcx> {
|
||||
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx>;
|
||||
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx>;
|
||||
}
|
||||
|
||||
impl UnifyKey for ty::IntVid {
|
||||
|
|
@ -51,7 +51,7 @@ impl UnifyKey for ty::RegionVid {
|
|||
}
|
||||
|
||||
impl<'tcx> ToType<'tcx> for IntVarValue {
|
||||
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
ty::IntType(i) => tcx.mk_mach_int(i),
|
||||
ty::UintType(i) => tcx.mk_mach_uint(i),
|
||||
|
|
@ -69,7 +69,7 @@ impl UnifyKey for ty::FloatVid {
|
|||
}
|
||||
|
||||
impl<'tcx> ToType<'tcx> for ast::FloatTy {
|
||||
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
fn to_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
tcx.mk_mach_float(*self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ impl LintStore {
|
|||
/// Context for lint checking after type checking.
|
||||
pub struct LateContext<'a, 'tcx: 'a> {
|
||||
/// Type context we're checking in.
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
/// The crate being checked.
|
||||
pub krate: &'a hir::Crate,
|
||||
|
|
@ -652,7 +652,7 @@ impl<'a> EarlyContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> LateContext<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
krate: &'a hir::Crate,
|
||||
access_levels: &'a AccessLevels) -> LateContext<'a, 'tcx> {
|
||||
// We want to own the lint store, so move it out of the session.
|
||||
|
|
@ -1220,7 +1220,8 @@ fn check_lint_name_cmdline(sess: &Session, lint_cx: &LintStore,
|
|||
/// Perform lint checking on a crate.
|
||||
///
|
||||
/// Consumes the `lint_store` field of the `Session`.
|
||||
pub fn check_crate(tcx: TyCtxt, access_levels: &AccessLevels) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &AccessLevels) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck);
|
||||
|
||||
let krate = tcx.map.krate();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use ty::{Ty, TyCtxt};
|
|||
use syntax::codemap::Span;
|
||||
use hir as ast;
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn prohibit_type_params(self, segments: &[ast::PathSegment]) {
|
||||
for segment in segments {
|
||||
for typ in segment.parameters.types() {
|
||||
|
|
|
|||
|
|
@ -161,47 +161,47 @@ pub trait CrateStore<'tcx> : Any {
|
|||
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>;
|
||||
fn visibility(&self, def: DefId) -> ty::Visibility;
|
||||
fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind;
|
||||
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def_id: DefId)
|
||||
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> ty::ClosureTy<'tcx>;
|
||||
fn item_variances(&self, def: DefId) -> ty::ItemVariances;
|
||||
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr>;
|
||||
fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::TypeScheme<'tcx>;
|
||||
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>>;
|
||||
fn item_name(&self, def: DefId) -> ast::Name;
|
||||
fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx>;
|
||||
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx>;
|
||||
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
|
||||
fn item_symbol(&self, def: DefId) -> String;
|
||||
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
|
||||
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
|
||||
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
|
||||
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
|
||||
fn method_arg_names(&self, did: DefId) -> Vec<String>;
|
||||
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>;
|
||||
|
||||
// trait info
|
||||
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId>;
|
||||
fn provided_trait_methods<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn provided_trait_methods<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::Method<'tcx>>>;
|
||||
fn trait_item_def_ids(&self, def: DefId)
|
||||
-> Vec<ty::ImplOrTraitItemId>;
|
||||
|
||||
// impl info
|
||||
fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>;
|
||||
fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::TraitRef<'tcx>>;
|
||||
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity>;
|
||||
fn custom_coerce_unsized_kind(&self, def: DefId)
|
||||
-> Option<ty::adjustment::CustomCoerceUnsized>;
|
||||
fn associated_consts<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn associated_consts<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>>;
|
||||
fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;
|
||||
|
||||
// trait/impl-item info
|
||||
fn trait_of_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def_id: DefId)
|
||||
fn trait_of_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> Option<DefId>;
|
||||
fn impl_or_trait_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn impl_or_trait_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>>;
|
||||
|
||||
// flags
|
||||
|
|
@ -209,7 +209,7 @@ pub trait CrateStore<'tcx> : Any {
|
|||
fn is_defaulted_trait(&self, did: DefId) -> bool;
|
||||
fn is_impl(&self, did: DefId) -> bool;
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool;
|
||||
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, did: DefId) -> bool;
|
||||
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, did: DefId) -> bool;
|
||||
fn is_static_method(&self, did: DefId) -> bool;
|
||||
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool;
|
||||
fn is_typedef(&self, did: DefId) -> bool;
|
||||
|
|
@ -250,9 +250,9 @@ pub trait CrateStore<'tcx> : Any {
|
|||
fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>;
|
||||
|
||||
// misc. metadata
|
||||
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> FoundAst<'tcx>;
|
||||
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<Mir<'tcx>>;
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool;
|
||||
|
||||
|
|
@ -266,14 +266,14 @@ pub trait CrateStore<'tcx> : Any {
|
|||
fn metadata_filename(&self) -> &str;
|
||||
fn metadata_section_name(&self, target: &Target) -> &str;
|
||||
fn encode_type<'a>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx>, DefId) -> String)
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String)
|
||||
-> Vec<u8>;
|
||||
fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>;
|
||||
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource;
|
||||
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>;
|
||||
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
reexports: &def::ExportMap,
|
||||
item_symbols: &RefCell<NodeMap<String>>,
|
||||
link_meta: &LinkMeta,
|
||||
|
|
@ -338,32 +338,32 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
|
||||
fn visibility(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
|
||||
fn closure_kind(&self, def_id: DefId) -> ty::ClosureKind { bug!("closure_kind") }
|
||||
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def_id: DefId)
|
||||
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> ty::ClosureTy<'tcx> { bug!("closure_ty") }
|
||||
fn item_variances(&self, def: DefId) -> ty::ItemVariances { bug!("item_variances") }
|
||||
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { bug!("repr_attrs") }
|
||||
fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::TypeScheme<'tcx> { bug!("item_type") }
|
||||
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
|
||||
bug!("visible_parent_map")
|
||||
}
|
||||
fn item_name(&self, def: DefId) -> ast::Name { bug!("item_name") }
|
||||
fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
|
||||
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
|
||||
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
|
||||
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
|
||||
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
|
||||
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
|
||||
{ bug!("trait_def") }
|
||||
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
||||
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
||||
{ bug!("adt_def") }
|
||||
fn method_arg_names(&self, did: DefId) -> Vec<String> { bug!("method_arg_names") }
|
||||
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
||||
|
||||
// trait info
|
||||
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
||||
fn provided_trait_methods<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn provided_trait_methods<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::Method<'tcx>>> { bug!("provided_trait_methods") }
|
||||
fn trait_item_def_ids(&self, def: DefId)
|
||||
-> Vec<ty::ImplOrTraitItemId> { bug!("trait_item_def_ids") }
|
||||
|
|
@ -371,20 +371,20 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
// impl info
|
||||
fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>
|
||||
{ bug!("impl_items") }
|
||||
fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
|
||||
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { bug!("impl_polarity") }
|
||||
fn custom_coerce_unsized_kind(&self, def: DefId)
|
||||
-> Option<ty::adjustment::CustomCoerceUnsized>
|
||||
{ bug!("custom_coerce_unsized_kind") }
|
||||
fn associated_consts<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn associated_consts<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { bug!("associated_consts") }
|
||||
fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
|
||||
|
||||
// trait/impl-item info
|
||||
fn trait_of_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def_id: DefId)
|
||||
fn trait_of_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> Option<DefId> { bug!("trait_of_item") }
|
||||
fn impl_or_trait_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn impl_or_trait_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>> { bug!("impl_or_trait_item") }
|
||||
|
||||
// flags
|
||||
|
|
@ -392,7 +392,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
|
||||
fn is_impl(&self, did: DefId) -> bool { bug!("is_impl") }
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
|
||||
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, did: DefId) -> bool
|
||||
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, did: DefId) -> bool
|
||||
{ bug!("is_extern_item") }
|
||||
fn is_static_method(&self, did: DefId) -> bool { bug!("is_static_method") }
|
||||
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool { false }
|
||||
|
|
@ -446,9 +446,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
{ bug!("crate_top_level_items") }
|
||||
|
||||
// misc. metadata
|
||||
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> FoundAst<'tcx> { bug!("maybe_get_item_ast") }
|
||||
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<Mir<'tcx>> { bug!("maybe_get_item_mir") }
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool {
|
||||
bug!("is_item_mir_available")
|
||||
|
|
@ -464,9 +464,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
|
||||
fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
|
||||
fn encode_type<'a>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx>, DefId) -> String)
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String)
|
||||
-> Vec<u8> {
|
||||
bug!("encode_type")
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
{ vec![] }
|
||||
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { bug!("used_crate_source") }
|
||||
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
|
||||
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
reexports: &def::ExportMap,
|
||||
item_symbols: &RefCell<NodeMap<String>>,
|
||||
link_meta: &LinkMeta,
|
||||
|
|
@ -507,7 +507,7 @@ pub mod tls {
|
|||
use hir::def_id::DefId;
|
||||
|
||||
pub trait EncodingContext<'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx>;
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
||||
fn encode_ty(&self, encoder: &mut OpaqueEncoder, t: Ty<'tcx>);
|
||||
fn encode_substs(&self, encoder: &mut OpaqueEncoder, substs: &Substs<'tcx>);
|
||||
}
|
||||
|
|
@ -574,7 +574,7 @@ pub mod tls {
|
|||
}
|
||||
|
||||
pub trait DecodingContext<'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx>;
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
||||
fn decode_ty(&self, decoder: &mut OpaqueDecoder) -> ty::Ty<'tcx>;
|
||||
fn decode_substs(&self, decoder: &mut OpaqueDecoder) -> Substs<'tcx>;
|
||||
fn translate_def_id(&self, def_id: DefId) -> DefId;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub enum EntryOrExit {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct DataFlowContext<'a, 'tcx: 'a, O> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
/// a name for the analysis using this dataflow instance
|
||||
analysis_name: &'static str,
|
||||
|
|
@ -222,7 +222,7 @@ pub enum KillFrom {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
analysis_name: &'static str,
|
||||
decl: Option<&hir::FnDecl>,
|
||||
cfg: &cfg::CFG,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ use syntax::attr;
|
|||
// explored. For example, if it's a live NodeItem that is a
|
||||
// function, then we should explore its block to check for codes that
|
||||
// may need to be marked as live.
|
||||
fn should_explore(tcx: TyCtxt, node_id: ast::NodeId) -> bool {
|
||||
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
node_id: ast::NodeId) -> bool {
|
||||
match tcx.map.find(node_id) {
|
||||
Some(ast_map::NodeItem(..)) |
|
||||
Some(ast_map::NodeImplItem(..)) |
|
||||
|
|
@ -45,7 +46,7 @@ fn should_explore(tcx: TyCtxt, node_id: ast::NodeId) -> bool {
|
|||
|
||||
struct MarkSymbolVisitor<'a, 'tcx: 'a> {
|
||||
worklist: Vec<ast::NodeId>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
live_symbols: Box<HashSet<ast::NodeId>>,
|
||||
struct_has_extern_repr: bool,
|
||||
ignore_non_const_paths: bool,
|
||||
|
|
@ -54,7 +55,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
worklist: Vec<ast::NodeId>) -> MarkSymbolVisitor<'a, 'tcx> {
|
||||
MarkSymbolVisitor {
|
||||
worklist: worklist,
|
||||
|
|
@ -362,9 +363,10 @@ impl<'v> Visitor<'v> for LifeSeeder {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_and_seed_worklist(tcx: TyCtxt,
|
||||
access_levels: &privacy::AccessLevels,
|
||||
krate: &hir::Crate) -> Vec<ast::NodeId> {
|
||||
fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels,
|
||||
krate: &hir::Crate)
|
||||
-> Vec<ast::NodeId> {
|
||||
let mut worklist = Vec::new();
|
||||
for (id, _) in &access_levels.map {
|
||||
worklist.push(*id);
|
||||
|
|
@ -385,10 +387,10 @@ fn create_and_seed_worklist(tcx: TyCtxt,
|
|||
return life_seeder.worklist;
|
||||
}
|
||||
|
||||
fn find_live(tcx: TyCtxt,
|
||||
access_levels: &privacy::AccessLevels,
|
||||
krate: &hir::Crate)
|
||||
-> Box<HashSet<ast::NodeId>> {
|
||||
fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels,
|
||||
krate: &hir::Crate)
|
||||
-> Box<HashSet<ast::NodeId>> {
|
||||
let worklist = create_and_seed_worklist(tcx, access_levels, krate);
|
||||
let mut symbol_visitor = MarkSymbolVisitor::new(tcx, worklist);
|
||||
symbol_visitor.mark_live_symbols();
|
||||
|
|
@ -405,7 +407,7 @@ fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> {
|
|||
}
|
||||
|
||||
struct DeadVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
live_symbols: Box<HashSet<ast::NodeId>>,
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +585,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt, access_levels: &privacy::AccessLevels) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::DeadCheck);
|
||||
let krate = tcx.map.krate();
|
||||
let live_symbols = find_live(tcx, access_levels, krate);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ fn type_is_unsafe_function(ty: Ty) -> bool {
|
|||
}
|
||||
|
||||
struct EffectCheckVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
/// Whether we're in an unsafe context.
|
||||
unsafe_context: UnsafeContext,
|
||||
|
|
@ -183,7 +183,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::EffectCheck);
|
||||
|
||||
let mut visitor = EffectCheckVisitor {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use self::OverloadedCallType::*;
|
|||
use hir::pat_util;
|
||||
use hir::def::Def;
|
||||
use hir::def_id::{DefId};
|
||||
use infer;
|
||||
use infer::InferCtxt;
|
||||
use middle::mem_categorization as mc;
|
||||
use ty::{self, TyCtxt, adjustment};
|
||||
|
||||
|
|
@ -209,8 +209,8 @@ enum OverloadedCallType {
|
|||
}
|
||||
|
||||
impl OverloadedCallType {
|
||||
fn from_trait_id(tcx: TyCtxt, trait_id: DefId)
|
||||
-> OverloadedCallType {
|
||||
fn from_trait_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_id: DefId)
|
||||
-> OverloadedCallType {
|
||||
for &(maybe_function_trait, overloaded_call_type) in &[
|
||||
(tcx.lang_items.fn_once_trait(), FnOnceOverloadedCall),
|
||||
(tcx.lang_items.fn_mut_trait(), FnMutOverloadedCall),
|
||||
|
|
@ -227,8 +227,8 @@ impl OverloadedCallType {
|
|||
bug!("overloaded call didn't map to known function trait")
|
||||
}
|
||||
|
||||
fn from_method_id(tcx: TyCtxt, method_id: DefId)
|
||||
-> OverloadedCallType {
|
||||
fn from_method_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, method_id: DefId)
|
||||
-> OverloadedCallType {
|
||||
let method = tcx.impl_or_trait_item(method_id);
|
||||
OverloadedCallType::from_trait_id(tcx, method.container().id())
|
||||
}
|
||||
|
|
@ -241,9 +241,8 @@ impl OverloadedCallType {
|
|||
// mem_categorization, it requires a TYPER, which is a type that
|
||||
// supplies types from the tree. After type checking is complete, you
|
||||
// can just use the tcx as the typer.
|
||||
pub struct ExprUseVisitor<'d, 't, 'a: 't, 'tcx:'a+'d> {
|
||||
typer: &'t infer::InferCtxt<'a, 'tcx>,
|
||||
mc: mc::MemCategorizationContext<'t, 'a, 'tcx>,
|
||||
pub struct ExprUseVisitor<'d, 'a, 'gcx: 'a+'tcx, 'tcx:'a+'d> {
|
||||
mc: mc::MemCategorizationContext<'a, 'gcx, 'tcx>,
|
||||
delegate: &'d mut Delegate<'tcx>,
|
||||
}
|
||||
|
||||
|
|
@ -272,14 +271,14 @@ enum PassArgs {
|
|||
ByRef,
|
||||
}
|
||||
|
||||
impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||
impl<'d, 'a, 'tcx> ExprUseVisitor<'d, 'a, 'tcx, 'tcx> {
|
||||
pub fn new(delegate: &'d mut (Delegate<'tcx>+'d),
|
||||
typer: &'t infer::InferCtxt<'a, 'tcx>)
|
||||
-> ExprUseVisitor<'d,'t,'a,'tcx> where 'tcx:'a+'d
|
||||
infcx: &'a InferCtxt<'a, 'tcx, 'tcx>) -> Self
|
||||
{
|
||||
let mc: mc::MemCategorizationContext<'t, 'a, 'tcx> =
|
||||
mc::MemCategorizationContext::new(typer);
|
||||
ExprUseVisitor { typer: typer, mc: mc, delegate: delegate }
|
||||
ExprUseVisitor {
|
||||
mc: mc::MemCategorizationContext::new(infcx),
|
||||
delegate: delegate
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn(&mut self,
|
||||
|
|
@ -293,7 +292,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
decl: &hir::FnDecl,
|
||||
body: &hir::Block) {
|
||||
for arg in &decl.inputs {
|
||||
let arg_ty = return_if_err!(self.typer.node_ty(arg.pat.id));
|
||||
let arg_ty = return_if_err!(self.mc.infcx.node_ty(arg.pat.id));
|
||||
|
||||
let fn_body_scope = self.tcx().region_maps.node_extent(body.id);
|
||||
let arg_cmt = self.mc.cat_rvalue(
|
||||
|
|
@ -306,8 +305,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'t, 'tcx> {
|
||||
self.typer.tcx
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
self.mc.infcx.tcx
|
||||
}
|
||||
|
||||
fn delegate_consume(&mut self,
|
||||
|
|
@ -317,7 +316,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
debug!("delegate_consume(consume_id={}, cmt={:?})",
|
||||
consume_id, cmt);
|
||||
|
||||
let mode = copy_or_move(self.typer, &cmt, DirectRefMove);
|
||||
let mode = copy_or_move(self.mc.infcx, &cmt, DirectRefMove);
|
||||
self.delegate.consume(consume_id, consume_span, cmt, mode);
|
||||
}
|
||||
|
||||
|
|
@ -442,7 +441,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
hir::ExprAddrOf(m, ref base) => { // &base
|
||||
// make sure that the thing we are pointing out stays valid
|
||||
// for the lifetime `scope_r` of the resulting ptr:
|
||||
let expr_ty = return_if_err!(self.typer.node_ty(expr.id));
|
||||
let expr_ty = return_if_err!(self.mc.infcx.node_ty(expr.id));
|
||||
if let ty::TyRef(&r, _) = expr_ty.sty {
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.borrow_expr(&base, r, bk, AddrOf);
|
||||
|
|
@ -548,7 +547,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
}
|
||||
|
||||
fn walk_callee(&mut self, call: &hir::Expr, callee: &hir::Expr) {
|
||||
let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee));
|
||||
let callee_ty = return_if_err!(self.mc.infcx.expr_ty_adjusted(callee));
|
||||
debug!("walk_callee: callee={:?} callee_ty={:?}",
|
||||
callee, callee_ty);
|
||||
let call_scope = self.tcx().region_maps.node_extent(call.id);
|
||||
|
|
@ -559,7 +558,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
ty::TyError => { }
|
||||
_ => {
|
||||
let overloaded_call_type =
|
||||
match self.typer.node_method_id(ty::MethodCall::expr(call.id)) {
|
||||
match self.mc.infcx.node_method_id(ty::MethodCall::expr(call.id)) {
|
||||
Some(method_id) => {
|
||||
OverloadedCallType::from_method_id(self.tcx(), method_id)
|
||||
}
|
||||
|
|
@ -615,7 +614,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
match local.init {
|
||||
None => {
|
||||
let delegate = &mut self.delegate;
|
||||
pat_util::pat_bindings(&self.typer.tcx.def_map, &local.pat,
|
||||
pat_util::pat_bindings(&self.mc.infcx.tcx.def_map, &local.pat,
|
||||
|_, id, span, _| {
|
||||
delegate.decl_without_init(id, span);
|
||||
})
|
||||
|
|
@ -707,9 +706,9 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
// consumed or borrowed as part of the automatic adjustment
|
||||
// process.
|
||||
fn walk_adjustment(&mut self, expr: &hir::Expr) {
|
||||
let typer = self.typer;
|
||||
let infcx = self.mc.infcx;
|
||||
//NOTE(@jroesch): mixed RefCell borrow causes crash
|
||||
let adj = typer.adjustments().get(&expr.id).map(|x| x.clone());
|
||||
let adj = infcx.adjustments().get(&expr.id).map(|x| x.clone());
|
||||
if let Some(adjustment) = adj {
|
||||
match adjustment {
|
||||
adjustment::AdjustReifyFnPointer |
|
||||
|
|
@ -739,7 +738,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
|
||||
for i in 0..autoderefs {
|
||||
let deref_id = ty::MethodCall::autoderef(expr.id, i as u32);
|
||||
match self.typer.node_method_ty(deref_id) {
|
||||
match self.mc.infcx.node_method_ty(deref_id) {
|
||||
None => {}
|
||||
Some(method_ty) => {
|
||||
let cmt = return_if_err!(self.mc.cat_expr_autoderefd(expr, i));
|
||||
|
|
@ -865,7 +864,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
pass_args: PassArgs)
|
||||
-> bool
|
||||
{
|
||||
if !self.typer.is_method_call(expr.id) {
|
||||
if !self.mc.infcx.is_method_call(expr.id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -941,7 +940,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
PatKind::Ident(hir::BindByRef(_), _, _) =>
|
||||
mode.lub(BorrowingMatch),
|
||||
PatKind::Ident(hir::BindByValue(_), _, _) => {
|
||||
match copy_or_move(self.typer, &cmt_pat, PatBindingMove) {
|
||||
match copy_or_move(self.mc.infcx, &cmt_pat, PatBindingMove) {
|
||||
Copy => mode.lub(CopyingMatch),
|
||||
Move(_) => mode.lub(MovingMatch),
|
||||
}
|
||||
|
|
@ -967,7 +966,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
pat);
|
||||
|
||||
let mc = &self.mc;
|
||||
let typer = self.typer;
|
||||
let infcx = self.mc.infcx;
|
||||
let def_map = &self.tcx().def_map;
|
||||
let delegate = &mut self.delegate;
|
||||
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
|
||||
|
|
@ -978,7 +977,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
match_mode);
|
||||
|
||||
// pat_ty: the type of the binding being produced.
|
||||
let pat_ty = return_if_err!(typer.node_ty(pat.id));
|
||||
let pat_ty = return_if_err!(infcx.node_ty(pat.id));
|
||||
|
||||
// Each match binding is effectively an assignment to the
|
||||
// binding being produced.
|
||||
|
|
@ -1000,7 +999,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
}
|
||||
}
|
||||
PatKind::Ident(hir::BindByValue(_), _, _) => {
|
||||
let mode = copy_or_move(typer, &cmt_pat, PatBindingMove);
|
||||
let mode = copy_or_move(infcx, &cmt_pat, PatBindingMove);
|
||||
debug!("walk_pat binding consuming pat");
|
||||
delegate.consume_pat(pat, cmt_pat, mode);
|
||||
}
|
||||
|
|
@ -1057,7 +1056,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
// the leaves of the pattern tree structure.
|
||||
return_if_err!(mc.cat_pattern(cmt_discr, pat, |mc, cmt_pat, pat| {
|
||||
let def_map = def_map.borrow();
|
||||
let tcx = typer.tcx;
|
||||
let tcx = infcx.tcx;
|
||||
|
||||
match pat.node {
|
||||
PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::QPath(..) |
|
||||
|
|
@ -1150,13 +1149,13 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
let id_var = freevar.def.var_id();
|
||||
let upvar_id = ty::UpvarId { var_id: id_var,
|
||||
closure_expr_id: closure_expr.id };
|
||||
let upvar_capture = self.typer.upvar_capture(upvar_id).unwrap();
|
||||
let upvar_capture = self.mc.infcx.upvar_capture(upvar_id).unwrap();
|
||||
let cmt_var = return_if_err!(self.cat_captured_var(closure_expr.id,
|
||||
fn_decl_span,
|
||||
freevar.def));
|
||||
match upvar_capture {
|
||||
ty::UpvarCapture::ByValue => {
|
||||
let mode = copy_or_move(self.typer, &cmt_var, CaptureMove);
|
||||
let mode = copy_or_move(self.mc.infcx, &cmt_var, CaptureMove);
|
||||
self.delegate.consume(closure_expr.id, freevar.span, cmt_var, mode);
|
||||
}
|
||||
ty::UpvarCapture::ByRef(upvar_borrow) => {
|
||||
|
|
@ -1180,17 +1179,17 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
// Create the cmt for the variable being borrowed, from the
|
||||
// caller's perspective
|
||||
let var_id = upvar_def.var_id();
|
||||
let var_ty = self.typer.node_ty(var_id)?;
|
||||
let var_ty = self.mc.infcx.node_ty(var_id)?;
|
||||
self.mc.cat_def(closure_id, closure_span, var_ty, upvar_def)
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_or_move<'a, 'tcx>(typer: &infer::InferCtxt<'a, 'tcx>,
|
||||
cmt: &mc::cmt<'tcx>,
|
||||
move_reason: MoveReason)
|
||||
-> ConsumeMode
|
||||
fn copy_or_move<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
cmt: &mc::cmt<'tcx>,
|
||||
move_reason: MoveReason)
|
||||
-> ConsumeMode
|
||||
{
|
||||
if typer.type_moves_by_default(cmt.ty, cmt.span) {
|
||||
if infcx.type_moves_by_default(cmt.ty, cmt.span) {
|
||||
Move(move_reason)
|
||||
} else {
|
||||
Copy
|
||||
|
|
|
|||
|
|
@ -120,11 +120,11 @@ impl FreeRegionMap {
|
|||
|
||||
/// Determines whether one region is a subregion of another. This is intended to run *after
|
||||
/// inference* and sadly the logic is somewhat duplicated with the code in infer.rs.
|
||||
pub fn is_subregion_of(&self,
|
||||
tcx: TyCtxt,
|
||||
sub_region: ty::Region,
|
||||
super_region: ty::Region)
|
||||
-> bool {
|
||||
pub fn is_subregion_of<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sub_region: ty::Region,
|
||||
super_region: ty::Region)
|
||||
-> bool {
|
||||
let result = sub_region == super_region || {
|
||||
match (sub_region, super_region) {
|
||||
(ty::ReEmpty, _) |
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use syntax::codemap::Span;
|
|||
use hir::intravisit::{self, Visitor, FnKind};
|
||||
use hir;
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let mut visitor = ItemVisitor {
|
||||
tcx: tcx
|
||||
};
|
||||
|
|
@ -30,7 +30,7 @@ pub fn check_crate(tcx: TyCtxt) {
|
|||
}
|
||||
|
||||
struct ItemVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ItemVisitor<'a, 'tcx> {
|
||||
|
|
@ -46,11 +46,11 @@ impl<'a, 'tcx> ItemVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
struct ExprVisitor<'a, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>
|
||||
struct ExprVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx> ExprVisitor<'a, 'tcx, 'tcx> {
|
||||
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
|
||||
let intrinsic = match self.infcx.tcx.lookup_item_type(def_id).ty.sty {
|
||||
ty::TyFnDef(_, _, ref bfty) => bfty.abi == RustIntrinsic,
|
||||
|
|
@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ItemVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for ExprVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for ExprVisitor<'a, 'tcx, 'tcx> {
|
||||
fn visit_expr(&mut self, expr: &hir::Expr) {
|
||||
if let hir::ExprPath(..) = expr.node {
|
||||
match self.infcx.tcx.resolve_expr(expr) {
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IrMaps<'a, 'tcx> {
|
|||
fn visit_arm(&mut self, a: &hir::Arm) { visit_arm(self, a); }
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::Liveness);
|
||||
tcx.map.krate().visit_all_items(&mut IrMaps::new(tcx));
|
||||
tcx.sess.abort_if_errors();
|
||||
|
|
@ -263,7 +263,7 @@ enum VarKind {
|
|||
}
|
||||
|
||||
struct IrMaps<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
num_live_nodes: usize,
|
||||
num_vars: usize,
|
||||
|
|
@ -275,7 +275,7 @@ struct IrMaps<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>) -> IrMaps<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> IrMaps<'a, 'tcx> {
|
||||
IrMaps {
|
||||
tcx: tcx,
|
||||
num_live_nodes: 0,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ use self::Aliasability::*;
|
|||
|
||||
use hir::def_id::DefId;
|
||||
use hir::map as ast_map;
|
||||
use infer;
|
||||
use infer::InferCtxt;
|
||||
use middle::const_qualif::ConstQualif;
|
||||
use hir::def::Def;
|
||||
use ty::adjustment;
|
||||
|
|
@ -256,8 +256,8 @@ impl ast_node for hir::Pat {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct MemCategorizationContext<'t, 'a: 't, 'tcx : 'a> {
|
||||
pub typer: &'t infer::InferCtxt<'a, 'tcx>,
|
||||
pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
pub type McResult<T> = Result<T, ()>;
|
||||
|
|
@ -302,7 +302,9 @@ impl MutabilityCategory {
|
|||
ret
|
||||
}
|
||||
|
||||
fn from_local(tcx: TyCtxt, id: ast::NodeId) -> MutabilityCategory {
|
||||
fn from_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: ast::NodeId)
|
||||
-> MutabilityCategory {
|
||||
let ret = match tcx.map.get(id) {
|
||||
ast_map::NodeLocal(p) => match p.node {
|
||||
PatKind::Ident(bind_mode, _, _) => {
|
||||
|
|
@ -358,17 +360,18 @@ impl MutabilityCategory {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||
pub fn new(typer: &'t infer::InferCtxt<'a, 'tcx>) -> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||
MemCategorizationContext { typer: typer }
|
||||
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> MemCategorizationContext<'a, 'tcx, 'tcx> {
|
||||
MemCategorizationContext { infcx: infcx }
|
||||
}
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> {
|
||||
self.typer.tcx
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn expr_ty(&self, expr: &hir::Expr) -> McResult<Ty<'tcx>> {
|
||||
match self.typer.node_ty(expr.id) {
|
||||
match self.infcx.node_ty(expr.id) {
|
||||
Ok(t) => Ok(t),
|
||||
Err(()) => {
|
||||
debug!("expr_ty({:?}) yielded Err", expr);
|
||||
|
|
@ -381,16 +384,16 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
let unadjusted_ty = self.expr_ty(expr)?;
|
||||
Ok(unadjusted_ty.adjust(
|
||||
self.tcx(), expr.span, expr.id,
|
||||
self.typer.adjustments().get(&expr.id),
|
||||
|method_call| self.typer.node_method_ty(method_call)))
|
||||
self.infcx.adjustments().get(&expr.id),
|
||||
|method_call| self.infcx.node_method_ty(method_call)))
|
||||
}
|
||||
|
||||
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>> {
|
||||
self.typer.node_ty(id)
|
||||
self.infcx.node_ty(id)
|
||||
}
|
||||
|
||||
fn pat_ty(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
|
||||
let base_ty = self.typer.node_ty(pat.id)?;
|
||||
let base_ty = self.infcx.node_ty(pat.id)?;
|
||||
// FIXME (Issue #18207): This code detects whether we are
|
||||
// looking at a `ref x`, and if so, figures out what the type
|
||||
// *being borrowed* is. But ideally we would put in a more
|
||||
|
|
@ -413,7 +416,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn cat_expr(&self, expr: &hir::Expr) -> McResult<cmt<'tcx>> {
|
||||
match self.typer.adjustments().get(&expr.id) {
|
||||
match self.infcx.adjustments().get(&expr.id) {
|
||||
None => {
|
||||
// No adjustments.
|
||||
self.cat_expr_unadjusted(expr)
|
||||
|
|
@ -485,7 +488,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
hir::ExprIndex(ref base, _) => {
|
||||
let method_call = ty::MethodCall::expr(expr.id());
|
||||
let context = InteriorOffsetKind::Index;
|
||||
match self.typer.node_method_ty(method_call) {
|
||||
match self.infcx.node_method_ty(method_call) {
|
||||
Some(method_ty) => {
|
||||
// If this is an index implemented by a method call, then it
|
||||
// will include an implicit deref of the result.
|
||||
|
|
@ -578,7 +581,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
let ty = self.node_ty(fn_node_id)?;
|
||||
match ty.sty {
|
||||
ty::TyClosure(closure_id, _) => {
|
||||
match self.typer.closure_kind(closure_id) {
|
||||
match self.infcx.closure_kind(closure_id) {
|
||||
Some(kind) => {
|
||||
self.cat_upvar(id, span, var_id, fn_node_id, kind)
|
||||
}
|
||||
|
|
@ -687,7 +690,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
// for that.
|
||||
let upvar_id = ty::UpvarId { var_id: var_id,
|
||||
closure_expr_id: fn_node_id };
|
||||
let upvar_capture = self.typer.upvar_capture(upvar_id).unwrap();
|
||||
let upvar_capture = self.infcx.upvar_capture(upvar_id).unwrap();
|
||||
let cmt_result = match upvar_capture {
|
||||
ty::UpvarCapture::ByValue => {
|
||||
cmt_result
|
||||
|
|
@ -785,7 +788,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
/// Returns the lifetime of a temporary created by expr with id `id`.
|
||||
/// This could be `'static` if `id` is part of a constant expression.
|
||||
pub fn temporary_scope(&self, id: ast::NodeId) -> ty::Region {
|
||||
match self.typer.temporary_scope(id) {
|
||||
match self.infcx.temporary_scope(id) {
|
||||
Some(scope) => ty::ReScope(scope),
|
||||
None => ty::ReStatic
|
||||
}
|
||||
|
|
@ -882,7 +885,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
expr_id: node.id(),
|
||||
autoderef: deref_cnt as u32
|
||||
};
|
||||
let method_ty = self.typer.node_method_ty(method_call);
|
||||
let method_ty = self.infcx.node_method_ty(method_call);
|
||||
|
||||
debug!("cat_deref: method_call={:?} method_ty={:?}",
|
||||
method_call, method_ty.map(|ty| ty));
|
||||
|
|
@ -977,7 +980,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
//! - `base_cmt`: the cmt of `elt`
|
||||
|
||||
let method_call = ty::MethodCall::expr(elt.id());
|
||||
let method_ty = self.typer.node_method_ty(method_call);
|
||||
let method_ty = self.infcx.node_method_ty(method_call);
|
||||
|
||||
let element_ty = match method_ty {
|
||||
Some(method_ty) => {
|
||||
|
|
@ -1082,10 +1085,10 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
/// In a pattern like [a, b, ..c], normally `c` has slice type, but if you have [a, b,
|
||||
/// ..ref c], then the type of `ref c` will be `&&[]`, so to extract the slice details we
|
||||
/// have to recurse through rptrs.
|
||||
fn vec_slice_info(tcx: TyCtxt,
|
||||
pat: &hir::Pat,
|
||||
slice_ty: Ty)
|
||||
-> (hir::Mutability, ty::Region) {
|
||||
fn vec_slice_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pat: &hir::Pat,
|
||||
slice_ty: Ty)
|
||||
-> (hir::Mutability, ty::Region) {
|
||||
match slice_ty.sty {
|
||||
ty::TyRef(r, ref mt) => match mt.ty.sty {
|
||||
ty::TySlice(_) => (mt.mutbl, *r),
|
||||
|
|
@ -1137,7 +1140,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn cat_pattern<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, mut op: F) -> McResult<()>
|
||||
where F: FnMut(&MemCategorizationContext<'t, 'a, 'tcx>, cmt<'tcx>, &hir::Pat),
|
||||
where F: FnMut(&MemCategorizationContext<'a, 'tcx, 'tcx>, cmt<'tcx>, &hir::Pat),
|
||||
{
|
||||
self.cat_pattern_(cmt, pat, &mut op)
|
||||
}
|
||||
|
|
@ -1145,7 +1148,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
// FIXME(#19596) This is a workaround, but there should be a better way to do this
|
||||
fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F)
|
||||
-> McResult<()>
|
||||
where F : FnMut(&MemCategorizationContext<'t, 'a, 'tcx>, cmt<'tcx>, &hir::Pat),
|
||||
where F : FnMut(&MemCategorizationContext<'a, 'tcx, 'tcx>, cmt<'tcx>, &hir::Pat),
|
||||
{
|
||||
// Here, `cmt` is the categorization for the value being
|
||||
// matched and pat is the pattern it is being matched against.
|
||||
|
|
@ -1463,7 +1466,7 @@ impl<'tcx> cmt_<'tcx> {
|
|||
}
|
||||
|
||||
|
||||
pub fn descriptive_string(&self, tcx: TyCtxt) -> String {
|
||||
pub fn descriptive_string<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String {
|
||||
match self.cat {
|
||||
Categorization::StaticItem => {
|
||||
"static item".to_string()
|
||||
|
|
|
|||
|
|
@ -55,9 +55,10 @@ fn item_might_be_inlined(item: &hir::Item) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn method_might_be_inlined(tcx: TyCtxt, sig: &hir::MethodSig,
|
||||
impl_item: &hir::ImplItem,
|
||||
impl_src: DefId) -> bool {
|
||||
fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sig: &hir::MethodSig,
|
||||
impl_item: &hir::ImplItem,
|
||||
impl_src: DefId) -> bool {
|
||||
if attr::requests_inline(&impl_item.attrs) ||
|
||||
generics_require_inlining(&sig.generics) {
|
||||
return true
|
||||
|
|
@ -77,7 +78,7 @@ fn method_might_be_inlined(tcx: TyCtxt, sig: &hir::MethodSig,
|
|||
// Information needed while computing reachability.
|
||||
struct ReachableContext<'a, 'tcx: 'a> {
|
||||
// The type context.
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// The set of items which must be exported in the linkage sense.
|
||||
reachable_symbols: NodeSet,
|
||||
// A worklist of item IDs. Each item ID in this worklist will be inlined
|
||||
|
|
@ -142,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
// Creates a new reachability computation context.
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>) -> ReachableContext<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ReachableContext<'a, 'tcx> {
|
||||
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
|
||||
*ty != config::CrateTypeExecutable
|
||||
});
|
||||
|
|
@ -344,9 +345,9 @@ impl<'a, 'v> Visitor<'v> for CollectPrivateImplItemsVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find_reachable(tcx: TyCtxt,
|
||||
access_levels: &privacy::AccessLevels)
|
||||
-> NodeSet {
|
||||
pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels)
|
||||
-> NodeSet {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::Reachability);
|
||||
|
||||
let mut reachable_context = ReachableContext::new(tcx);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ pub struct Index<'tcx> {
|
|||
|
||||
// A private tree-walker for producing an Index.
|
||||
struct Annotator<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
index: &'a mut Index<'tcx>,
|
||||
parent_stab: Option<&'tcx Stability>,
|
||||
parent_depr: Option<Deprecation>,
|
||||
|
|
@ -280,7 +280,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> Index<'tcx> {
|
||||
/// Construct the stability index for a crate being compiled.
|
||||
pub fn build(&mut self, tcx: TyCtxt<'a, 'tcx>, access_levels: &AccessLevels) {
|
||||
pub fn build(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &AccessLevels) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
|
||||
let krate = tcx.map.krate();
|
||||
let mut annotator = Annotator {
|
||||
|
|
@ -320,8 +320,8 @@ impl<'a, 'tcx> Index<'tcx> {
|
|||
/// Cross-references the feature names of unstable APIs with enabled
|
||||
/// features and possibly prints errors. Returns a list of all
|
||||
/// features used.
|
||||
pub fn check_unstable_api_usage(tcx: TyCtxt)
|
||||
-> FnvHashMap<InternedString, StabilityLevel> {
|
||||
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> FnvHashMap<InternedString, StabilityLevel> {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck);
|
||||
let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ pub fn check_unstable_api_usage(tcx: TyCtxt)
|
|||
}
|
||||
|
||||
struct Checker<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
active_features: FnvHashSet<InternedString>,
|
||||
used_features: FnvHashMap<InternedString, StabilityLevel>,
|
||||
// Within a block where feature gate checking can be skipped.
|
||||
|
|
@ -468,8 +468,12 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> {
|
|||
}
|
||||
|
||||
/// Helper for discovering nodes to check for stability
|
||||
pub fn check_item(tcx: TyCtxt, item: &hir::Item, warn_about_defns: bool,
|
||||
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
|
||||
pub fn check_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item: &hir::Item,
|
||||
warn_about_defns: bool,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>,
|
||||
&Option<Deprecation>)) {
|
||||
match item.node {
|
||||
hir::ItemExternCrate(_) => {
|
||||
// compiler-generated `extern crate` items have a dummy span.
|
||||
|
|
@ -505,8 +509,10 @@ pub fn check_item(tcx: TyCtxt, item: &hir::Item, warn_about_defns: bool,
|
|||
}
|
||||
|
||||
/// Helper for discovering nodes to check for stability
|
||||
pub fn check_expr(tcx: TyCtxt, e: &hir::Expr,
|
||||
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
|
||||
pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>,
|
||||
&Option<Deprecation>)) {
|
||||
let span;
|
||||
let id = match e.node {
|
||||
hir::ExprMethodCall(i, _, _) => {
|
||||
|
|
@ -566,8 +572,11 @@ pub fn check_expr(tcx: TyCtxt, e: &hir::Expr,
|
|||
maybe_do_stability_check(tcx, id, span, cb);
|
||||
}
|
||||
|
||||
pub fn check_path(tcx: TyCtxt, path: &hir::Path, id: ast::NodeId,
|
||||
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
|
||||
pub fn check_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
path: &hir::Path, id: ast::NodeId,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>,
|
||||
&Option<Deprecation>)) {
|
||||
match tcx.def_map.borrow().get(&id).map(|d| d.full_def()) {
|
||||
Some(Def::PrimTy(..)) => {}
|
||||
Some(Def::SelfTy(..)) => {}
|
||||
|
|
@ -578,8 +587,11 @@ pub fn check_path(tcx: TyCtxt, path: &hir::Path, id: ast::NodeId,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_path_list_item(tcx: TyCtxt, item: &hir::PathListItem,
|
||||
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
|
||||
pub fn check_path_list_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item: &hir::PathListItem,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>,
|
||||
&Option<Deprecation>)) {
|
||||
match tcx.def_map.borrow().get(&item.node.id()).map(|d| d.full_def()) {
|
||||
Some(Def::PrimTy(..)) => {}
|
||||
Some(def) => {
|
||||
|
|
@ -589,8 +601,10 @@ pub fn check_path_list_item(tcx: TyCtxt, item: &hir::PathListItem,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_pat(tcx: TyCtxt, pat: &hir::Pat,
|
||||
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
|
||||
pub fn check_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &hir::Pat,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>,
|
||||
&Option<Deprecation>)) {
|
||||
debug!("check_pat(pat = {:?})", pat);
|
||||
if is_internal(tcx, pat.span) { return; }
|
||||
|
||||
|
|
@ -618,9 +632,11 @@ pub fn check_pat(tcx: TyCtxt, pat: &hir::Pat,
|
|||
}
|
||||
}
|
||||
|
||||
fn maybe_do_stability_check(tcx: TyCtxt, id: DefId, span: Span,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>, &Option<Deprecation>)) {
|
||||
fn maybe_do_stability_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: DefId, span: Span,
|
||||
cb: &mut FnMut(DefId, Span,
|
||||
&Option<&Stability>,
|
||||
&Option<Deprecation>)) {
|
||||
if is_internal(tcx, span) {
|
||||
debug!("maybe_do_stability_check: \
|
||||
skipping span={:?} since it is internal", span);
|
||||
|
|
@ -636,11 +652,11 @@ fn maybe_do_stability_check(tcx: TyCtxt, id: DefId, span: Span,
|
|||
cb(id, span, &stability, &deprecation);
|
||||
}
|
||||
|
||||
fn is_internal(tcx: TyCtxt, span: Span) -> bool {
|
||||
fn is_internal<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span) -> bool {
|
||||
tcx.sess.codemap().span_allows_unstable(span)
|
||||
}
|
||||
|
||||
fn is_staged_api(tcx: TyCtxt, id: DefId) -> bool {
|
||||
fn is_staged_api<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> bool {
|
||||
match tcx.trait_item_of_item(id) {
|
||||
Some(ty::MethodTraitItemId(trait_method_id))
|
||||
if trait_method_id != id => {
|
||||
|
|
@ -653,7 +669,7 @@ fn is_staged_api(tcx: TyCtxt, id: DefId) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
/// Lookup the stability for a node, loading external crate
|
||||
/// metadata as necessary.
|
||||
pub fn lookup_stability(self, id: DefId) -> Option<&'tcx Stability> {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ impl<'a, 'tcx> LvalueTy<'tcx> {
|
|||
LvalueTy::Ty { ty: ty }
|
||||
}
|
||||
|
||||
pub fn to_ty(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn to_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
LvalueTy::Ty { ty } =>
|
||||
ty,
|
||||
|
|
@ -44,7 +44,7 @@ impl<'a, 'tcx> LvalueTy<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn projection_ty(self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn projection_ty(self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
elem: &LvalueElem<'tcx>)
|
||||
-> LvalueTy<'tcx>
|
||||
{
|
||||
|
|
@ -101,7 +101,7 @@ impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Mir<'tcx> {
|
||||
pub fn operand_ty(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn operand_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
operand: &Operand<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
|
|
@ -111,7 +111,7 @@ impl<'a, 'tcx> Mir<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn binop_ty(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn binop_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
op: BinOp,
|
||||
lhs_ty: Ty<'tcx>,
|
||||
rhs_ty: Ty<'tcx>)
|
||||
|
|
@ -135,7 +135,7 @@ impl<'a, 'tcx> Mir<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn lvalue_ty(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn lvalue_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
lvalue: &Lvalue<'tcx>)
|
||||
-> LvalueTy<'tcx>
|
||||
{
|
||||
|
|
@ -155,7 +155,7 @@ impl<'a, 'tcx> Mir<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rvalue_ty(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn rvalue_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
rvalue: &Rvalue<'tcx>)
|
||||
-> Option<Ty<'tcx>>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ pub enum MirSource {
|
|||
Promoted(NodeId, usize)
|
||||
}
|
||||
|
||||
impl MirSource {
|
||||
pub fn from_node(tcx: TyCtxt, id: NodeId) -> MirSource {
|
||||
impl<'a, 'tcx> MirSource {
|
||||
pub fn from_node(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> MirSource {
|
||||
use hir::*;
|
||||
|
||||
// Handle constants in enum discriminants, types, and repeat expressions.
|
||||
|
|
@ -79,21 +79,22 @@ pub trait Pass {
|
|||
|
||||
/// A pass which inspects the whole MirMap.
|
||||
pub trait MirMapPass<'tcx>: Pass {
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>, map: &mut MirMap<'tcx>);
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, map: &mut MirMap<'tcx>);
|
||||
}
|
||||
|
||||
/// A pass which inspects Mir of functions in isolation.
|
||||
pub trait MirPass<'tcx>: Pass {
|
||||
fn run_pass_on_promoted<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn run_pass_on_promoted<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item_id: NodeId, index: usize,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
self.run_pass(tcx, MirSource::Promoted(item_id, index), mir);
|
||||
}
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>, src: MirSource, mir: &mut Mir<'tcx>);
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
src: MirSource, mir: &mut Mir<'tcx>);
|
||||
}
|
||||
|
||||
impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T {
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>, map: &mut MirMap<'tcx>) {
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, map: &mut MirMap<'tcx>) {
|
||||
for (&id, mir) in &mut map.map {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let _task = tcx.dep_graph.in_task(self.dep_node(def_id));
|
||||
|
|
@ -123,7 +124,7 @@ impl<'a, 'tcx> Passes {
|
|||
passes
|
||||
}
|
||||
|
||||
pub fn run_passes(&mut self, tcx: TyCtxt<'a, 'tcx>, map: &mut MirMap<'tcx>) {
|
||||
pub fn run_passes(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, map: &mut MirMap<'tcx>) {
|
||||
for pass in &mut self.plugin_passes {
|
||||
pass.run_pass(tcx, map);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct InferIsLocal(bool);
|
|||
|
||||
/// If there are types that satisfy both impls, returns a suitably-freshened
|
||||
/// `ImplHeader` with those types substituted
|
||||
pub fn overlapping_impls<'cx, 'tcx>(infcx: &InferCtxt<'cx, 'tcx>,
|
||||
pub fn overlapping_impls<'cx, 'tcx>(infcx: &InferCtxt<'cx, 'tcx, 'tcx>,
|
||||
impl1_def_id: DefId,
|
||||
impl2_def_id: DefId)
|
||||
-> Option<ty::ImplHeader<'tcx>>
|
||||
|
|
@ -41,7 +41,7 @@ pub fn overlapping_impls<'cx, 'tcx>(infcx: &InferCtxt<'cx, 'tcx>,
|
|||
|
||||
/// Can both impl `a` and impl `b` be satisfied by a common type (including
|
||||
/// `where` clauses)? If so, returns an `ImplHeader` that unifies the two impls.
|
||||
fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
|
||||
fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx, 'tcx>,
|
||||
a_def_id: DefId,
|
||||
b_def_id: DefId)
|
||||
-> Option<ty::ImplHeader<'tcx>>
|
||||
|
|
@ -86,7 +86,7 @@ fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
|
|||
Some(selcx.infcx().resolve_type_vars_if_possible(&a_impl_header))
|
||||
}
|
||||
|
||||
pub fn trait_ref_is_knowable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn trait_ref_is_knowable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
trait_ref: &ty::TraitRef<'tcx>) -> bool
|
||||
{
|
||||
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
|
||||
|
|
@ -129,7 +129,7 @@ pub enum OrphanCheckErr<'tcx> {
|
|||
///
|
||||
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
|
||||
/// 2. Some local type must appear in `Self`.
|
||||
pub fn orphan_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn orphan_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId)
|
||||
-> Result<(), OrphanCheckErr<'tcx>>
|
||||
{
|
||||
|
|
@ -150,7 +150,7 @@ pub fn orphan_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
orphan_check_trait_ref(tcx, &trait_ref, InferIsLocal(false))
|
||||
}
|
||||
|
||||
fn orphan_check_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn orphan_check_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
trait_ref: &ty::TraitRef<'tcx>,
|
||||
infer_is_local: InferIsLocal)
|
||||
-> Result<(), OrphanCheckErr<'tcx>>
|
||||
|
|
@ -198,7 +198,7 @@ fn orphan_check_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
return Err(OrphanCheckErr::NoLocalInputType);
|
||||
}
|
||||
|
||||
fn uncovered_tys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn uncovered_tys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
infer_is_local: InferIsLocal)
|
||||
-> Vec<Ty<'tcx>>
|
||||
|
|
@ -222,13 +222,15 @@ fn is_type_parameter<'tcx>(ty: Ty<'tcx>) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn ty_is_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, ty: Ty<'tcx>, infer_is_local: InferIsLocal) -> bool
|
||||
fn ty_is_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
infer_is_local: InferIsLocal) -> bool
|
||||
{
|
||||
ty_is_local_constructor(tcx, ty, infer_is_local) ||
|
||||
fundamental_ty(tcx, ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, infer_is_local))
|
||||
}
|
||||
|
||||
fn fundamental_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> bool
|
||||
fn fundamental_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool
|
||||
{
|
||||
match ty.sty {
|
||||
ty::TyBox(..) | ty::TyRef(..) =>
|
||||
|
|
@ -242,7 +244,7 @@ fn fundamental_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> bool
|
|||
}
|
||||
}
|
||||
|
||||
fn ty_is_local_constructor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn ty_is_local_constructor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
infer_is_local: InferIsLocal)
|
||||
-> bool
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ pub struct TraitErrorKey<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> TraitErrorKey<'tcx> {
|
||||
fn from_error<'a>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
fn from_error<'a>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
e: &FulfillmentError<'tcx>,
|
||||
warning_node_id: Option<ast::NodeId>) -> Self {
|
||||
let predicate =
|
||||
|
|
@ -60,7 +60,7 @@ impl<'tcx> TraitErrorKey<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn report_fulfillment_errors(&self, errors: &Vec<FulfillmentError<'tcx>>) {
|
||||
for error in errors {
|
||||
self.report_fulfillment_error(error, None);
|
||||
|
|
@ -558,7 +558,7 @@ pub fn report_selection_error(&self,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn recursive_type_with_infinite_size_error(self,
|
||||
type_def_id: DefId)
|
||||
-> DiagnosticBuilder<'tcx>
|
||||
|
|
@ -646,7 +646,7 @@ pub fn report_object_safety_error(self,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
|
||||
fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>) {
|
||||
// Unable to successfully determine, probably means
|
||||
// insufficient type information, but could mean
|
||||
|
|
@ -738,13 +738,13 @@ fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>) {
|
|||
/// to the type parameters.
|
||||
fn predicate_can_apply(&self, pred: ty::PolyTraitRef<'tcx>) -> bool {
|
||||
struct ParamToVarFolder<'a, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'a, 'tcx, 'tcx>,
|
||||
var_map: FnvHashMap<Ty<'tcx>, Ty<'tcx>>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx>
|
||||
{
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> { self.infcx.tcx }
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.infcx.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::TyParam(..) = ty.sty {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
/// something concrete. If this fails, we'll unify `$0` with
|
||||
/// `projection_ty` again.
|
||||
pub fn normalize_projection_type(&mut self,
|
||||
infcx: &InferCtxt<'a,'tcx>,
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
projection_ty: ty::ProjectionTy<'tcx>,
|
||||
cause: ObligationCause<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
|
|
@ -155,7 +155,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn register_builtin_bound(&mut self,
|
||||
infcx: &InferCtxt<'a, 'tcx>,
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
builtin_bound: ty::BuiltinBound,
|
||||
cause: ObligationCause<'tcx>)
|
||||
|
|
@ -177,7 +177,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn register_predicate_obligation(&mut self,
|
||||
infcx: &InferCtxt<'a, 'tcx>,
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
obligation: PredicateObligation<'tcx>)
|
||||
{
|
||||
// this helps to reduce duplicate errors, as well as making
|
||||
|
|
@ -200,7 +200,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn register_rfc1592_obligation(&mut self,
|
||||
_infcx: &InferCtxt<'a,'tcx>,
|
||||
_infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
obligation: PredicateObligation<'tcx>)
|
||||
{
|
||||
self.rfc1592_obligations.push(obligation);
|
||||
|
|
@ -217,7 +217,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn select_rfc1592_obligations(&mut self,
|
||||
infcx: &InferCtxt<'a,'tcx>)
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Result<(),Vec<FulfillmentError<'tcx>>>
|
||||
{
|
||||
while !self.rfc1592_obligations.is_empty() {
|
||||
|
|
@ -232,7 +232,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn select_all_or_error(&mut self,
|
||||
infcx: &InferCtxt<'a,'tcx>)
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Result<(),Vec<FulfillmentError<'tcx>>>
|
||||
{
|
||||
self.select_where_possible(infcx)?;
|
||||
|
|
@ -250,7 +250,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn select_where_possible(&mut self,
|
||||
infcx: &InferCtxt<'a, 'tcx>)
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Result<(),Vec<FulfillmentError<'tcx>>>
|
||||
{
|
||||
let mut selcx = SelectionContext::new(infcx);
|
||||
|
|
@ -261,7 +261,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
self.predicates.pending_obligations()
|
||||
}
|
||||
|
||||
fn is_duplicate_or_add(&mut self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn is_duplicate_or_add(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
predicate: &ty::Predicate<'tcx>)
|
||||
-> bool {
|
||||
// For "global" predicates -- that is, predicates that don't
|
||||
|
|
@ -289,7 +289,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
|
||||
/// Attempts to select obligations using `selcx`. If `only_new_obligations` is true, then it
|
||||
/// only attempts to select obligations that haven't been seen before.
|
||||
fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx>)
|
||||
fn select(&mut self, selcx: &mut SelectionContext<'a, 'tcx, 'tcx>)
|
||||
-> Result<(),Vec<FulfillmentError<'tcx>>> {
|
||||
debug!("select(obligation-forest-size={})", self.predicates.len());
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
|||
}
|
||||
|
||||
/// Like `process_predicate1`, but wrap result into a pending predicate.
|
||||
fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
||||
fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx, 'tcx>,
|
||||
tree_cache: &mut LocalFulfilledPredicates<'tcx>,
|
||||
pending_obligation: &mut PendingPredicateObligation<'tcx>,
|
||||
backtrace: Backtrace<PendingPredicateObligation<'tcx>>,
|
||||
|
|
@ -362,8 +362,8 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
fn process_child_obligations<'a,'tcx>(
|
||||
selcx: &mut SelectionContext<'a,'tcx>,
|
||||
fn process_child_obligations<'a, 'tcx>(
|
||||
selcx: &mut SelectionContext<'a, 'tcx, 'tcx>,
|
||||
tree_cache: &mut LocalFulfilledPredicates<'tcx>,
|
||||
pending_obligation: &PredicateObligation<'tcx>,
|
||||
backtrace: Backtrace<PendingPredicateObligation<'tcx>>,
|
||||
|
|
@ -478,7 +478,7 @@ impl<'a, 'b, 'tcx> AncestorSet<'b, 'tcx> {
|
|||
/// type-resolved). Returns `None` if not; otherwise, returns
|
||||
/// `Some` with the index within the backtrace.
|
||||
fn has(&mut self,
|
||||
infcx: &InferCtxt<'a, 'tcx>,
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
predicate: &ty::Predicate<'tcx>)
|
||||
-> Option<usize> {
|
||||
// the first time, we have to populate the cache
|
||||
|
|
@ -514,7 +514,7 @@ impl<'a, 'b, 'tcx> AncestorSet<'b, 'tcx> {
|
|||
}
|
||||
|
||||
/// Return the set of type variables contained in a trait ref
|
||||
fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
|
||||
fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx, 'tcx>,
|
||||
t: ty::PolyTraitRef<'tcx>) -> Vec<Ty<'tcx>>
|
||||
{
|
||||
t.skip_binder() // ok b/c this check doesn't care about regions
|
||||
|
|
@ -531,7 +531,7 @@ fn trait_ref_type_vars<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx>,
|
|||
/// - `Ok(Some(v))` if the predicate is true, presuming that `v` are also true
|
||||
/// - `Ok(None)` if we don't have enough info to be sure
|
||||
/// - `Err` if the predicate does not hold
|
||||
fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
||||
fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx, 'tcx>,
|
||||
pending_obligation: &mut PendingPredicateObligation<'tcx>,
|
||||
region_obligations: &mut NodeMap<Vec<RegionObligation<'tcx>>>,
|
||||
rfc1592_obligations: &mut Vec<PredicateObligation<'tcx>>)
|
||||
|
|
@ -722,9 +722,9 @@ fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
/// - it also appears in the backtrace at some position `X`; and,
|
||||
/// - all the predicates at positions `X..` between `X` an the top are
|
||||
/// also defaulted traits.
|
||||
fn coinductive_match<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
||||
cycle: &[PredicateObligation<'tcx>])
|
||||
-> bool
|
||||
fn coinductive_match<'a, 'tcx>(selcx: &mut SelectionContext<'a, 'tcx, 'tcx>,
|
||||
cycle: &[PredicateObligation<'tcx>])
|
||||
-> bool
|
||||
{
|
||||
let len = cycle.len();
|
||||
|
||||
|
|
@ -740,7 +740,7 @@ fn coinductive_match<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
})
|
||||
}
|
||||
|
||||
fn coinductive_obligation<'a, 'tcx>(selcx: &SelectionContext<'a, 'tcx>,
|
||||
fn coinductive_obligation<'a, 'tcx>(selcx: &SelectionContext<'a, 'tcx, 'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>)
|
||||
-> bool {
|
||||
match obligation.predicate {
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>,
|
|||
/// `bound` or is not known to meet bound (note that this is
|
||||
/// conservative towards *no impl*, which is the opposite of the
|
||||
/// `evaluate` methods).
|
||||
pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
||||
pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
bound: ty::BuiltinBound,
|
||||
span: Span)
|
||||
|
|
@ -460,7 +460,7 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
|
|||
infcx.parameter_environment.with_caller_bounds(predicates)
|
||||
}
|
||||
|
||||
pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
||||
pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx, 'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
value: &T)
|
||||
-> Result<T, Vec<FulfillmentError<'tcx>>>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub enum MethodViolationCode {
|
|||
Generic,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn is_object_safe(self, trait_def_id: DefId) -> bool {
|
||||
// Because we query yes/no results frequently, we keep a cache:
|
||||
let def = self.lookup_trait_def(trait_def_id);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ struct ProjectionTyCandidateSet<'tcx> {
|
|||
///
|
||||
/// If successful, this may result in additional obligations.
|
||||
pub fn poly_project_and_unify_type<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &PolyProjectionObligation<'tcx>)
|
||||
-> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>>
|
||||
{
|
||||
|
|
@ -205,7 +205,7 @@ pub fn poly_project_and_unify_type<'cx,'tcx>(
|
|||
///
|
||||
/// If successful, this may result in additional obligations.
|
||||
fn project_and_unify_type<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionObligation<'tcx>)
|
||||
-> Result<Option<Vec<PredicateObligation<'tcx>>>, MismatchedProjectionTypes<'tcx>>
|
||||
{
|
||||
|
|
@ -240,7 +240,7 @@ fn project_and_unify_type<'cx,'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionObligation<'tcx>) {
|
||||
debug!("consider_unification_despite_ambiguity(obligation={:?})",
|
||||
obligation);
|
||||
|
|
@ -295,7 +295,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext
|
|||
/// them with a fully resolved type where possible. The return value
|
||||
/// combines the normalized result and any additional obligations that
|
||||
/// were incurred as result.
|
||||
pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>,
|
||||
pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx, 'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
value: &T)
|
||||
-> Normalized<'tcx, T>
|
||||
|
|
@ -305,7 +305,7 @@ pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>,
|
|||
}
|
||||
|
||||
/// As `normalize`, but with a custom depth.
|
||||
pub fn normalize_with_depth<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>,
|
||||
pub fn normalize_with_depth<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx, 'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
depth: usize,
|
||||
value: &T)
|
||||
|
|
@ -322,14 +322,14 @@ pub fn normalize_with_depth<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tc
|
|||
}
|
||||
|
||||
struct AssociatedTypeNormalizer<'a,'b:'a,'tcx:'b> {
|
||||
selcx: &'a mut SelectionContext<'b,'tcx>,
|
||||
selcx: &'a mut SelectionContext<'b,'tcx, 'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
obligations: Vec<PredicateObligation<'tcx>>,
|
||||
depth: usize,
|
||||
}
|
||||
|
||||
impl<'a,'b,'tcx> AssociatedTypeNormalizer<'a,'b,'tcx> {
|
||||
fn new(selcx: &'a mut SelectionContext<'b,'tcx>,
|
||||
fn new(selcx: &'a mut SelectionContext<'b,'tcx, 'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
depth: usize)
|
||||
-> AssociatedTypeNormalizer<'a,'b,'tcx>
|
||||
|
|
@ -354,7 +354,7 @@ impl<'a,'b,'tcx> AssociatedTypeNormalizer<'a,'b,'tcx> {
|
|||
}
|
||||
|
||||
impl<'a,'b,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'b,'tcx> {
|
||||
fn tcx<'c>(&'c self) -> TyCtxt<'c, 'tcx> {
|
||||
fn tcx<'c>(&'c self) -> TyCtxt<'c, 'tcx, 'tcx> {
|
||||
self.selcx.tcx()
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ impl<'tcx,T> Normalized<'tcx,T> {
|
|||
/// substitute a fresh type variable `$X` and generate a new
|
||||
/// obligation `<T as Trait>::Item == $X` for later.
|
||||
pub fn normalize_projection_type<'a,'b,'tcx>(
|
||||
selcx: &'a mut SelectionContext<'b,'tcx>,
|
||||
selcx: &'a mut SelectionContext<'b,'tcx, 'tcx>,
|
||||
projection_ty: ty::ProjectionTy<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
depth: usize)
|
||||
|
|
@ -454,7 +454,7 @@ pub fn normalize_projection_type<'a,'b,'tcx>(
|
|||
/// additional obligations). Returns `None` in the case of ambiguity,
|
||||
/// which indicates that there are unbound type variables.
|
||||
fn opt_normalize_projection_type<'a,'b,'tcx>(
|
||||
selcx: &'a mut SelectionContext<'b,'tcx>,
|
||||
selcx: &'a mut SelectionContext<'b,'tcx, 'tcx>,
|
||||
projection_ty: ty::ProjectionTy<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
depth: usize)
|
||||
|
|
@ -542,7 +542,7 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
|
|||
/// an error for this obligation, but we legitimately should not,
|
||||
/// because it contains `[type error]`. Yuck! (See issue #29857 for
|
||||
/// one case where this arose.)
|
||||
fn normalize_to_error<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
||||
fn normalize_to_error<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx, 'tcx>,
|
||||
projection_ty: ty::ProjectionTy<'tcx>,
|
||||
cause: ObligationCause<'tcx>,
|
||||
depth: usize)
|
||||
|
|
@ -566,7 +566,7 @@ enum ProjectedTy<'tcx> {
|
|||
|
||||
/// Compute the result of a projection type (if we can).
|
||||
fn project_type<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>)
|
||||
-> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>>
|
||||
{
|
||||
|
|
@ -749,7 +749,7 @@ fn project_type<'cx,'tcx>(
|
|||
/// environment to see whether there are any projection predicates
|
||||
/// there that can answer this question.
|
||||
fn assemble_candidates_from_param_env<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
obligation_trait_ref: &ty::TraitRef<'tcx>,
|
||||
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
|
||||
|
|
@ -775,7 +775,7 @@ fn assemble_candidates_from_param_env<'cx,'tcx>(
|
|||
///
|
||||
/// Here, for example, we could conclude that the result is `i32`.
|
||||
fn assemble_candidates_from_trait_def<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
obligation_trait_ref: &ty::TraitRef<'tcx>,
|
||||
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
|
||||
|
|
@ -807,7 +807,7 @@ fn assemble_candidates_from_trait_def<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn assemble_candidates_from_predicates<'cx,'tcx,I>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
obligation_trait_ref: &ty::TraitRef<'tcx>,
|
||||
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
|
||||
|
|
@ -854,7 +854,7 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>(
|
|||
}
|
||||
|
||||
fn assemble_candidates_from_object_type<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
obligation_trait_ref: &ty::TraitRef<'tcx>,
|
||||
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
|
||||
|
|
@ -886,7 +886,7 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn assemble_candidates_from_impls<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
obligation_trait_ref: &ty::TraitRef<'tcx>,
|
||||
candidate_set: &mut ProjectionTyCandidateSet<'tcx>)
|
||||
|
|
@ -970,7 +970,7 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn confirm_candidate<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
candidate: ProjectionTyCandidate<'tcx>)
|
||||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
|
|
@ -1000,7 +1000,7 @@ fn confirm_candidate<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn confirm_fn_pointer_candidate<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
fn_type: Ty<'tcx>)
|
||||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
|
|
@ -1011,7 +1011,7 @@ fn confirm_fn_pointer_candidate<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn confirm_closure_candidate<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>)
|
||||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
|
|
@ -1034,7 +1034,7 @@ fn confirm_closure_candidate<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn confirm_callable_candidate<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
fn_sig: &ty::PolyFnSig<'tcx>,
|
||||
flag: util::TupleArgumentsFlag)
|
||||
|
|
@ -1068,7 +1068,7 @@ fn confirm_callable_candidate<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn confirm_param_env_candidate<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
poly_projection: ty::PolyProjectionPredicate<'tcx>)
|
||||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
|
|
@ -1107,7 +1107,7 @@ fn confirm_param_env_candidate<'cx,'tcx>(
|
|||
}
|
||||
|
||||
fn confirm_impl_candidate<'cx,'tcx>(
|
||||
selcx: &mut SelectionContext<'cx,'tcx>,
|
||||
selcx: &mut SelectionContext<'cx,'tcx, 'tcx>,
|
||||
obligation: &ProjectionTyObligation<'tcx>,
|
||||
impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>)
|
||||
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
|
||||
|
|
@ -1146,7 +1146,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
|
|||
///
|
||||
/// Based on the "projection mode", this lookup may in fact only examine the
|
||||
/// topmost impl. See the comments for `ProjectionMode` for more details.
|
||||
fn assoc_ty_def<'cx, 'tcx>(selcx: &SelectionContext<'cx, 'tcx>,
|
||||
fn assoc_ty_def<'cx, 'tcx>(selcx: &SelectionContext<'cx, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId,
|
||||
assoc_ty_name: ast::Name)
|
||||
-> Option<specialization_graph::NodeItem<Rc<ty::AssociatedType<'tcx>>>>
|
||||
|
|
|
|||
|
|
@ -49,15 +49,15 @@ use syntax::abi::Abi;
|
|||
use hir;
|
||||
use util::nodemap::FnvHashMap;
|
||||
|
||||
pub struct SelectionContext<'cx, 'tcx:'cx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
|
||||
/// Freshener used specifically for skolemizing entries on the
|
||||
/// obligation stack. This ensures that all entries on the stack
|
||||
/// at one time will have the same set of skolemized entries,
|
||||
/// which is important for checking for trait bounds that
|
||||
/// recursively require themselves.
|
||||
freshener: TypeFreshener<'cx, 'tcx>,
|
||||
freshener: TypeFreshener<'cx, 'tcx, 'tcx>,
|
||||
|
||||
/// If true, indicates that the evaluation should be conservative
|
||||
/// and consider the possibility of types outside this crate.
|
||||
|
|
@ -262,8 +262,8 @@ pub struct EvaluationCache<'tcx> {
|
|||
hashmap: RefCell<FnvHashMap<ty::PolyTraitRef<'tcx>, EvaluationResult>>
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx, 'tcx> {
|
||||
pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx, 'tcx>) -> SelectionContext<'cx, 'tcx, 'tcx> {
|
||||
SelectionContext {
|
||||
infcx: infcx,
|
||||
freshener: infcx.freshener(),
|
||||
|
|
@ -271,7 +271,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> {
|
||||
pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx, 'tcx>) -> SelectionContext<'cx, 'tcx, 'tcx> {
|
||||
SelectionContext {
|
||||
infcx: infcx,
|
||||
freshener: infcx.freshener(),
|
||||
|
|
@ -279,11 +279,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'tcx> {
|
||||
pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'tcx, 'tcx> {
|
||||
self.infcx
|
||||
}
|
||||
|
||||
pub fn tcx(&self) -> TyCtxt<'cx, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'cx, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.infcx.param_env()
|
||||
}
|
||||
|
||||
pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'tcx> {
|
||||
pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'tcx, 'tcx> {
|
||||
self.infcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ use syntax::codemap::DUMMY_SP;
|
|||
pub mod specialization_graph;
|
||||
|
||||
/// Information pertinent to an overlapping impl error.
|
||||
pub struct Overlap<'a, 'tcx: 'a> {
|
||||
pub in_context: InferCtxt<'a, 'tcx>,
|
||||
pub struct Overlap<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
pub in_context: InferCtxt<'a, 'gcx, 'tcx>,
|
||||
pub with_impl: DefId,
|
||||
pub on_trait_ref: ty::TraitRef<'tcx>,
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ pub struct Overlap<'a, 'tcx: 'a> {
|
|||
/// through associated type projection. We deal with such cases by using
|
||||
/// *fulfillment* to relate the two impls, requiring that all projections are
|
||||
/// resolved.
|
||||
pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
source_impl: DefId,
|
||||
source_substs: &'tcx Substs<'tcx>,
|
||||
target_node: specialization_graph::Node)
|
||||
|
|
@ -108,7 +108,9 @@ pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
/// Specialization is determined by the sets of types to which the impls apply;
|
||||
/// impl1 specializes impl2 if it applies to a subset of the types impl2 applies
|
||||
/// to.
|
||||
pub fn specializes(tcx: TyCtxt, impl1_def_id: DefId, impl2_def_id: DefId) -> bool {
|
||||
pub fn specializes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl1_def_id: DefId,
|
||||
impl2_def_id: DefId) -> bool {
|
||||
// The feature gate should prevent introducing new specializations, but not
|
||||
// taking advantage of upstream ones.
|
||||
if !tcx.sess.features.borrow().specialization &&
|
||||
|
|
@ -165,7 +167,7 @@ pub fn specializes(tcx: TyCtxt, impl1_def_id: DefId, impl2_def_id: DefId) -> boo
|
|||
/// generics of `target_impl`, including both those needed to unify with
|
||||
/// `source_trait_ref` and those whose identity is determined via a where
|
||||
/// clause in the impl.
|
||||
fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
source_trait_ref: ty::TraitRef<'tcx>,
|
||||
target_impl: DefId)
|
||||
-> Result<Substs<'tcx>, ()> {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ enum InsertResult<'a, 'tcx: 'a> {
|
|||
|
||||
/// The impl has an unresolvable overlap with an existing child (neither
|
||||
/// specializes the other).
|
||||
Overlapped(Overlap<'a, 'tcx>),
|
||||
Overlapped(Overlap<'a, 'tcx, 'tcx>),
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Children {
|
||||
|
|
@ -90,7 +90,9 @@ impl<'a, 'tcx> Children {
|
|||
}
|
||||
|
||||
/// Insert an impl into this set of children without comparing to any existing impls
|
||||
fn insert_blindly(&mut self, tcx: TyCtxt, impl_def_id: DefId) {
|
||||
fn insert_blindly(&mut self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId) {
|
||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||
self.nonblanket_impls.entry(sty).or_insert(vec![]).push(impl_def_id)
|
||||
|
|
@ -102,7 +104,7 @@ impl<'a, 'tcx> Children {
|
|||
/// Attempt to insert an impl into this set of children, while comparing for
|
||||
/// specialiation relationships.
|
||||
fn insert(&mut self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId,
|
||||
simplified_self: Option<SimplifiedType>)
|
||||
-> InsertResult<'a, 'tcx>
|
||||
|
|
@ -174,9 +176,9 @@ impl<'a, 'tcx> Graph {
|
|||
/// conflicts with it (has overlap, but neither specializes the other),
|
||||
/// information about the area of overlap is returned in the `Err`.
|
||||
pub fn insert(&mut self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId)
|
||||
-> Result<(), Overlap<'a, 'tcx>> {
|
||||
-> Result<(), Overlap<'a, 'tcx, 'tcx>> {
|
||||
assert!(impl_def_id.is_local());
|
||||
|
||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
|
|
@ -235,7 +237,10 @@ impl<'a, 'tcx> Graph {
|
|||
}
|
||||
|
||||
/// Insert cached metadata mapping from a child impl back to its parent.
|
||||
pub fn record_impl_from_cstore(&mut self, tcx: TyCtxt, parent: DefId, child: DefId) {
|
||||
pub fn record_impl_from_cstore(&mut self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
parent: DefId,
|
||||
child: DefId) {
|
||||
if self.parent.insert(child, parent).is_some() {
|
||||
bug!("When recording an impl from the crate store, information about its parent \
|
||||
was already present.");
|
||||
|
|
@ -269,7 +274,7 @@ impl<'a, 'tcx> Node {
|
|||
}
|
||||
|
||||
/// Iterate over the items defined directly by the given (impl or trait) node.
|
||||
pub fn items(&self, tcx: TyCtxt<'a, 'tcx>) -> NodeItems<'a, 'tcx> {
|
||||
pub fn items(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> NodeItems<'a, 'tcx> {
|
||||
match *self {
|
||||
Node::Impl(impl_def_id) => {
|
||||
NodeItems::Impl {
|
||||
|
|
@ -299,7 +304,7 @@ impl<'a, 'tcx> Node {
|
|||
/// An iterator over the items defined within a trait or impl.
|
||||
pub enum NodeItems<'a, 'tcx: 'a> {
|
||||
Impl {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
items: cell::Ref<'a, Vec<ty::ImplOrTraitItemId>>,
|
||||
idx: usize,
|
||||
},
|
||||
|
|
@ -411,7 +416,7 @@ impl<'a, 'tcx> Iterator for ConstDefs<'a, 'tcx> {
|
|||
impl<'a, 'tcx> Ancestors<'a, 'tcx> {
|
||||
/// Search the items from the given ancestors, returning each type definition
|
||||
/// with the given name.
|
||||
pub fn type_defs(self, tcx: TyCtxt<'a, 'tcx>, name: Name) -> TypeDefs<'a, 'tcx> {
|
||||
pub fn type_defs(self, tcx: TyCtxt<'a, 'tcx, 'tcx>, name: Name) -> TypeDefs<'a, 'tcx> {
|
||||
let iter = self.flat_map(move |node| {
|
||||
node.items(tcx)
|
||||
.filter_map(move |item| {
|
||||
|
|
@ -432,7 +437,7 @@ impl<'a, 'tcx> Ancestors<'a, 'tcx> {
|
|||
|
||||
/// Search the items from the given ancestors, returning each fn definition
|
||||
/// with the given name.
|
||||
pub fn fn_defs(self, tcx: TyCtxt<'a, 'tcx>, name: Name) -> FnDefs<'a, 'tcx> {
|
||||
pub fn fn_defs(self, tcx: TyCtxt<'a, 'tcx, 'tcx>, name: Name) -> FnDefs<'a, 'tcx> {
|
||||
let iter = self.flat_map(move |node| {
|
||||
node.items(tcx)
|
||||
.filter_map(move |item| {
|
||||
|
|
@ -453,7 +458,7 @@ impl<'a, 'tcx> Ancestors<'a, 'tcx> {
|
|||
|
||||
/// Search the items from the given ancestors, returning each const
|
||||
/// definition with the given name.
|
||||
pub fn const_defs(self, tcx: TyCtxt<'a, 'tcx>, name: Name) -> ConstDefs<'a, 'tcx> {
|
||||
pub fn const_defs(self, tcx: TyCtxt<'a, 'tcx, 'tcx>, name: Name) -> ConstDefs<'a, 'tcx> {
|
||||
let iter = self.flat_map(move |node| {
|
||||
node.items(tcx)
|
||||
.filter_map(move |item| {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use util::nodemap::FnvHashSet;
|
|||
|
||||
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
|
||||
|
||||
fn anonymize_predicate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, pred: &ty::Predicate<'tcx>)
|
||||
fn anonymize_predicate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pred: &ty::Predicate<'tcx>)
|
||||
-> ty::Predicate<'tcx> {
|
||||
match *pred {
|
||||
ty::Predicate::Trait(ref data) =>
|
||||
|
|
@ -52,12 +52,12 @@ fn anonymize_predicate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, pred: &ty::Predicate<'tc
|
|||
|
||||
|
||||
struct PredicateSet<'a,'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
set: FnvHashSet<ty::Predicate<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'a,'tcx> PredicateSet<'a,'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>) -> PredicateSet<'a,'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> PredicateSet<'a,'tcx> {
|
||||
PredicateSet { tcx: tcx, set: FnvHashSet() }
|
||||
}
|
||||
|
||||
|
|
@ -88,13 +88,13 @@ impl<'a,'tcx> PredicateSet<'a,'tcx> {
|
|||
/// Foo : 'static`, and we know that `T : Foo`, then we know that `T :
|
||||
/// 'static`.
|
||||
pub struct Elaborator<'cx, 'tcx:'cx> {
|
||||
tcx: TyCtxt<'cx, 'tcx>,
|
||||
tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
stack: Vec<ty::Predicate<'tcx>>,
|
||||
visited: PredicateSet<'cx,'tcx>,
|
||||
}
|
||||
|
||||
pub fn elaborate_trait_ref<'cx, 'tcx>(
|
||||
tcx: TyCtxt<'cx, 'tcx>,
|
||||
tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>)
|
||||
-> Elaborator<'cx, 'tcx>
|
||||
{
|
||||
|
|
@ -102,7 +102,7 @@ pub fn elaborate_trait_ref<'cx, 'tcx>(
|
|||
}
|
||||
|
||||
pub fn elaborate_trait_refs<'cx, 'tcx>(
|
||||
tcx: TyCtxt<'cx, 'tcx>,
|
||||
tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
trait_refs: &[ty::PolyTraitRef<'tcx>])
|
||||
-> Elaborator<'cx, 'tcx>
|
||||
{
|
||||
|
|
@ -113,7 +113,7 @@ pub fn elaborate_trait_refs<'cx, 'tcx>(
|
|||
}
|
||||
|
||||
pub fn elaborate_predicates<'cx, 'tcx>(
|
||||
tcx: TyCtxt<'cx, 'tcx>,
|
||||
tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
mut predicates: Vec<ty::Predicate<'tcx>>)
|
||||
-> Elaborator<'cx, 'tcx>
|
||||
{
|
||||
|
|
@ -222,14 +222,14 @@ impl<'cx, 'tcx> Iterator for Elaborator<'cx, 'tcx> {
|
|||
|
||||
pub type Supertraits<'cx, 'tcx> = FilterToTraits<Elaborator<'cx, 'tcx>>;
|
||||
|
||||
pub fn supertraits<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx>,
|
||||
pub fn supertraits<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>)
|
||||
-> Supertraits<'cx, 'tcx>
|
||||
{
|
||||
elaborate_trait_ref(tcx, trait_ref).filter_to_traits()
|
||||
}
|
||||
|
||||
pub fn transitive_bounds<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx>,
|
||||
pub fn transitive_bounds<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
bounds: &[ty::PolyTraitRef<'tcx>])
|
||||
-> Supertraits<'cx, 'tcx>
|
||||
{
|
||||
|
|
@ -240,12 +240,12 @@ pub fn transitive_bounds<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx>,
|
|||
// Iterator over def-ids of supertraits
|
||||
|
||||
pub struct SupertraitDefIds<'cx, 'tcx:'cx> {
|
||||
tcx: TyCtxt<'cx, 'tcx>,
|
||||
tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
stack: Vec<DefId>,
|
||||
visited: FnvHashSet<DefId>,
|
||||
}
|
||||
|
||||
pub fn supertrait_def_ids<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx>,
|
||||
pub fn supertrait_def_ids<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx, 'tcx>,
|
||||
trait_def_id: DefId)
|
||||
-> SupertraitDefIds<'cx, 'tcx>
|
||||
{
|
||||
|
|
@ -319,7 +319,7 @@ impl<'tcx,I:Iterator<Item=ty::Predicate<'tcx>>> Iterator for FilterToTraits<I> {
|
|||
/// Instantiate all bound parameters of the impl with the given substs,
|
||||
/// returning the resulting trait ref and all obligations that arise.
|
||||
/// The obligations are closed under normalization.
|
||||
pub fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
||||
pub fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx, 'tcx>,
|
||||
impl_def_id: DefId,
|
||||
impl_substs: &Substs<'tcx>)
|
||||
-> (ty::TraitRef<'tcx>,
|
||||
|
|
@ -352,7 +352,7 @@ pub fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
|
|||
// declared on the impl declaration e.g., `impl<A,B> for Box<[(A,B)]>`
|
||||
// would return ($0, $1) where $0 and $1 are freshly instantiated type
|
||||
// variables.
|
||||
pub fn fresh_type_vars_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
pub fn fresh_type_vars_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
span: Span,
|
||||
impl_def_id: DefId)
|
||||
-> Substs<'tcx>
|
||||
|
|
@ -391,7 +391,7 @@ pub fn predicate_for_trait_ref<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn trait_ref_for_builtin_bound(self,
|
||||
builtin_bound: ty::BuiltinBound,
|
||||
param_ty: Ty<'tcx>)
|
||||
|
|
|
|||
|
|
@ -29,18 +29,18 @@ use ty::relate::{self, Relate, TypeRelation, RelateResult};
|
|||
/// important thing about the result is Ok/Err. Also, matching never
|
||||
/// affects any type variables or unification state.
|
||||
pub struct Match<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Match<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx>) -> Match<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Match<'a, 'tcx> {
|
||||
Match { tcx: tcx }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> {
|
||||
fn tag(&self) -> &'static str { "Match" }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.tcx }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.tcx }
|
||||
fn a_is_expected(&self) -> bool { true } // irrelevant
|
||||
|
||||
fn relate_with_variance<T:Relate<'a,'tcx>>(&mut self,
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ pub enum CustomCoerceUnsized {
|
|||
impl<'a, 'tcx> ty::TyS<'tcx> {
|
||||
/// See `expr_ty_adjusted`
|
||||
pub fn adjust<F>(&'tcx self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
span: Span,
|
||||
expr_id: ast::NodeId,
|
||||
adjustment: Option<&AutoAdjustment<'tcx>>,
|
||||
|
|
@ -216,7 +216,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
|
||||
pub fn adjust_for_autoderef<F>(&'tcx self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
expr_id: ast::NodeId,
|
||||
expr_span: Span,
|
||||
autoderef: u32, // how many autoderefs so far?
|
||||
|
|
@ -244,7 +244,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn adjust_for_autoref(&'tcx self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn adjust_for_autoref(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
autoref: Option<AutoRef<'tcx>>)
|
||||
-> Ty<'tcx> {
|
||||
match autoref {
|
||||
|
|
|
|||
|
|
@ -140,10 +140,10 @@ impl fmt::Debug for TypeContents {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> ty::TyS<'tcx> {
|
||||
pub fn type_contents(&'tcx self, tcx: TyCtxt<'a, 'tcx>) -> TypeContents {
|
||||
pub fn type_contents(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> TypeContents {
|
||||
return tcx.tc_cache.memoize(self, || tc_ty(tcx, self, &mut FnvHashMap()));
|
||||
|
||||
fn tc_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn tc_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
cache: &mut FnvHashMap<Ty<'tcx>, TypeContents>) -> TypeContents
|
||||
{
|
||||
|
|
@ -255,8 +255,9 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
result
|
||||
}
|
||||
|
||||
fn apply_lang_items(tcx: TyCtxt, did: DefId, tc: TypeContents)
|
||||
-> TypeContents {
|
||||
fn apply_lang_items<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
did: DefId, tc: TypeContents)
|
||||
-> TypeContents {
|
||||
if Some(did) == tcx.lang_items.unsafe_cell_type() {
|
||||
tc | TC::InteriorUnsafe
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ impl<'a, 'tcx> Tables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn closure_kind(this: &RefCell<Self>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
-> ty::ClosureKind {
|
||||
// If this is a local def-id, it should be inserted into the
|
||||
|
|
@ -226,7 +226,7 @@ impl<'a, 'tcx> Tables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn closure_type(this: &RefCell<Self>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
substs: &ClosureSubsts<'tcx>)
|
||||
-> ty::ClosureTy<'tcx>
|
||||
|
|
@ -271,14 +271,14 @@ impl<'tcx> CommonTypes<'tcx> {
|
|||
/// generates so that so that it can be reused and doesn't have to be redone
|
||||
/// later on.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct TyCtxt<'a, 'tcx: 'a> {
|
||||
gcx: &'a GlobalCtxt<'tcx>,
|
||||
pub struct TyCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
gcx: &'a GlobalCtxt<'gcx>,
|
||||
interners: &'a CtxtInterners<'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Deref for TyCtxt<'a, 'tcx> {
|
||||
type Target = &'a GlobalCtxt<'tcx>;
|
||||
fn deref(&self) -> &&'a GlobalCtxt<'tcx> {
|
||||
impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> {
|
||||
type Target = &'a GlobalCtxt<'gcx>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.gcx
|
||||
}
|
||||
}
|
||||
|
|
@ -486,7 +486,7 @@ pub struct GlobalCtxt<'tcx> {
|
|||
|
||||
impl<'tcx> GlobalCtxt<'tcx> {
|
||||
/// Get the global TyCtxt.
|
||||
pub fn global_tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx> {
|
||||
pub fn global_tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
TyCtxt {
|
||||
gcx: self,
|
||||
interners: &self.global_interners
|
||||
|
|
@ -494,7 +494,7 @@ impl<'tcx> GlobalCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn crate_name(self, cnum: ast::CrateNum) -> token::InternedString {
|
||||
if cnum == LOCAL_CRATE {
|
||||
self.crate_name.clone()
|
||||
|
|
@ -617,7 +617,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
stability: stability::Index<'tcx>,
|
||||
crate_name: &str,
|
||||
f: F) -> R
|
||||
where F: for<'b> FnOnce(TyCtxt<'b, 'tcx>) -> R
|
||||
where F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'tcx>) -> R
|
||||
{
|
||||
let data_layout = TargetDataLayout::parse(s);
|
||||
let interners = CtxtInterners::new(arenas);
|
||||
|
|
@ -693,12 +693,12 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
/// e.g. `()` or `u8`, was interned in a different context.
|
||||
pub trait Lift<'tcx> {
|
||||
type Lifted;
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Option<Self::Lifted>;
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted>;
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lift<'tcx> for Ty<'a> {
|
||||
type Lifted = Ty<'tcx>;
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx>) -> Option<Ty<'tcx>> {
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<Ty<'tcx>> {
|
||||
if let Some(&InternedTy { ty }) = tcx.interners.type_.borrow().get(&self.sty) {
|
||||
if *self as *const _ == ty as *const _ {
|
||||
return Some(ty);
|
||||
|
|
@ -710,7 +710,7 @@ impl<'a, 'tcx> Lift<'tcx> for Ty<'a> {
|
|||
|
||||
impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> {
|
||||
type Lifted = &'tcx Substs<'tcx>;
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx>) -> Option<&'tcx Substs<'tcx>> {
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> {
|
||||
if let Some(&InternedSubsts { substs }) = tcx.interners.substs.borrow().get(*self) {
|
||||
if *self as *const _ == substs as *const _ {
|
||||
return Some(substs);
|
||||
|
|
@ -744,7 +744,7 @@ pub mod tls {
|
|||
}
|
||||
|
||||
pub fn enter<'tcx, F, R>(gcx: GlobalCtxt<'tcx>, f: F) -> R
|
||||
where F: for<'a> FnOnce(TyCtxt<'a, 'tcx>) -> R
|
||||
where F: for<'a> FnOnce(TyCtxt<'a, 'tcx, 'tcx>) -> R
|
||||
{
|
||||
codemap::SPAN_DEBUG.with(|span_dbg| {
|
||||
let original_span_debug = span_dbg.get();
|
||||
|
|
@ -762,7 +762,9 @@ pub mod tls {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn with<F: FnOnce(TyCtxt) -> R, R>(f: F) -> R {
|
||||
pub fn with<F, R>(f: F) -> R
|
||||
where F: for<'a, 'tcx> FnOnce(TyCtxt<'a, 'tcx, 'tcx>) -> R
|
||||
{
|
||||
TLS_TCX.with(|gcx| {
|
||||
let gcx = gcx.get().unwrap();
|
||||
let gcx = unsafe { &*(gcx as *const GlobalCtxt) };
|
||||
|
|
@ -773,7 +775,9 @@ pub mod tls {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn with_opt<F: FnOnce(Option<TyCtxt>) -> R, R>(f: F) -> R {
|
||||
pub fn with_opt<F, R>(f: F) -> R
|
||||
where F: for<'a, 'tcx> FnOnce(Option<TyCtxt<'a, 'tcx, 'tcx>>) -> R
|
||||
{
|
||||
if TLS_TCX.with(|gcx| gcx.get().is_some()) {
|
||||
with(|v| f(Some(v)))
|
||||
} else {
|
||||
|
|
@ -846,7 +850,7 @@ macro_rules! sty_debug_print {
|
|||
}}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn print_debug_stats(self) {
|
||||
sty_debug_print!(
|
||||
self,
|
||||
|
|
@ -906,7 +910,7 @@ fn bound_list_is_sorted(bounds: &[ty::PolyProjectionPredicate]) -> bool {
|
|||
|(index, bound)| bounds[index].sort_key() <= bound.sort_key())
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
// Type constructors
|
||||
pub fn mk_substs(self, substs: Substs<'tcx>) -> &'tcx Substs<'tcx> {
|
||||
if let Some(interned) = self.interners.substs.borrow().get(&substs) {
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::TyS<'tcx> {
|
||||
fn sort_string(&self, tcx: TyCtxt) -> String {
|
||||
impl<'a, 'tcx, 'lcx> ty::TyS<'tcx> {
|
||||
fn sort_string(&self, tcx: TyCtxt<'a, 'lcx, 'lcx>) -> String {
|
||||
match self.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr => self.to_string(),
|
||||
|
|
@ -252,7 +252,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn note_and_explain_type_err(self,
|
||||
db: &mut DiagnosticBuilder,
|
||||
err: &TypeError<'tcx>,
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ pub enum SimplifiedType {
|
|||
/// then we can't say much about whether two types would unify. Put another way,
|
||||
/// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they
|
||||
/// are to be considered bound.
|
||||
pub fn simplify_type(tcx: TyCtxt,
|
||||
ty: Ty,
|
||||
can_simplify_params: bool)
|
||||
-> Option<SimplifiedType>
|
||||
pub fn simplify_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty,
|
||||
can_simplify_params: bool)
|
||||
-> Option<SimplifiedType>
|
||||
{
|
||||
match ty.sty {
|
||||
ty::TyBool => Some(BoolSimplifiedType),
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
|
|||
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
|
||||
/// sub-item.
|
||||
pub trait TypeFolder<'tcx> : Sized {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx>;
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
||||
|
||||
fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T>
|
||||
where T : TypeFoldable<'tcx>
|
||||
|
|
@ -202,14 +202,14 @@ pub trait TypeVisitor<'tcx> : Sized {
|
|||
// Some sample folders
|
||||
|
||||
pub struct BottomUpFolder<'a, 'tcx: 'a, F> where F: FnMut(Ty<'tcx>) -> Ty<'tcx> {
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub fldop: F,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
|
||||
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
||||
{
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> { self.tcx }
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let t1 = ty.super_fold_with(self);
|
||||
|
|
@ -220,7 +220,7 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Region folder
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
/// Collects the free and escaping regions in `value` into `region_set`. Returns
|
||||
/// whether any late-bound regions were skipped
|
||||
pub fn collect_regions<T>(self,
|
||||
|
|
@ -260,14 +260,14 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
/// visited by `fld_r`.
|
||||
|
||||
pub struct RegionFolder<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
skipped_regions: &'a mut bool,
|
||||
current_depth: u32,
|
||||
fld_r: &'a mut (FnMut(ty::Region, u32) -> ty::Region + 'a),
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
|
||||
pub fn new<F>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn new<F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
skipped_regions: &'a mut bool,
|
||||
fld_r: &'a mut F) -> RegionFolder<'a, 'tcx>
|
||||
where F : FnMut(ty::Region, u32) -> ty::Region
|
||||
|
|
@ -283,7 +283,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx>
|
||||
{
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> { self.tcx }
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx }
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
||||
self.current_depth += 1;
|
||||
|
|
@ -315,13 +315,13 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx>
|
|||
// Replaces the escaping regions in a type.
|
||||
|
||||
struct RegionReplacer<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
current_depth: u32,
|
||||
fld_r: &'a mut (FnMut(ty::BoundRegion) -> ty::Region + 'a),
|
||||
map: FnvHashMap<ty::BoundRegion, ty::Region>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn replace_late_bound_regions<T,F>(self,
|
||||
value: &Binder<T>,
|
||||
mut f: F)
|
||||
|
|
@ -409,7 +409,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> RegionReplacer<'a, 'tcx> {
|
||||
fn new<F>(tcx: TyCtxt<'a, 'tcx>, fld_r: &'a mut F) -> RegionReplacer<'a, 'tcx>
|
||||
fn new<F>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fld_r: &'a mut F) -> RegionReplacer<'a, 'tcx>
|
||||
where F : FnMut(ty::BoundRegion) -> ty::Region
|
||||
{
|
||||
RegionReplacer {
|
||||
|
|
@ -423,7 +423,7 @@ impl<'a, 'tcx> RegionReplacer<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
|
||||
{
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> { self.tcx }
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx }
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
||||
self.current_depth += 1;
|
||||
|
|
@ -463,7 +463,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Region eraser
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
/// Returns an equivalent value with all free regions removed (note
|
||||
/// that late-bound regions remain, because they are important for
|
||||
/// subtyping, but they are anonymized and normalized as well)..
|
||||
|
|
@ -475,10 +475,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
value, value1);
|
||||
return value1;
|
||||
|
||||
struct RegionEraser<'a, 'tcx: 'a>(TyCtxt<'a, 'tcx>);
|
||||
struct RegionEraser<'a, 'tcx: 'a>(TyCtxt<'a, 'tcx, 'tcx>);
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for RegionEraser<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> { self.0 }
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.0 }
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match self.tcx().normalized_cache.borrow().get(&ty).cloned() {
|
||||
|
|
@ -543,7 +543,7 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shift_regions<'a, 'tcx, T:TypeFoldable<'tcx>>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn shift_regions<'a, 'tcx, T:TypeFoldable<'tcx>>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
amount: u32, value: &T) -> T {
|
||||
debug!("shift_regions(value={:?}, amount={})",
|
||||
value, amount);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use hir::def_id::{DefId, CRATE_DEF_INDEX};
|
|||
use ty::{self, Ty, TyCtxt};
|
||||
use syntax::ast;
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
/// Returns a string identifying this def-id. This string is
|
||||
/// suitable for user output. It is relative to the current crate
|
||||
/// root.
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ pub struct Struct {
|
|||
pub offset_after_field: Vec<Size>
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
impl<'a, 'tcx> Struct {
|
||||
pub fn new(dl: &TargetDataLayout, packed: bool) -> Struct {
|
||||
Struct {
|
||||
align: if packed { dl.i8_align } else { dl.aggregate_align },
|
||||
|
|
@ -477,10 +477,10 @@ impl Struct {
|
|||
}
|
||||
|
||||
/// Extend the Struct with more fields.
|
||||
pub fn extend<'a, 'tcx, I>(&mut self, dl: &TargetDataLayout,
|
||||
fields: I,
|
||||
scapegoat: Ty<'tcx>)
|
||||
-> Result<(), LayoutError<'tcx>>
|
||||
pub fn extend<I>(&mut self, dl: &TargetDataLayout,
|
||||
fields: I,
|
||||
scapegoat: Ty<'tcx>)
|
||||
-> Result<(), LayoutError<'tcx>>
|
||||
where I: Iterator<Item=Result<&'a Layout, LayoutError<'tcx>>> {
|
||||
self.offset_after_field.reserve(fields.size_hint().0);
|
||||
|
||||
|
|
@ -527,8 +527,8 @@ impl Struct {
|
|||
}
|
||||
|
||||
/// Determine whether a structure would be zero-sized, given its fields.
|
||||
pub fn would_be_zero_sized<'a, 'tcx, I>(dl: &TargetDataLayout, fields: I)
|
||||
-> Result<bool, LayoutError<'tcx>>
|
||||
pub fn would_be_zero_sized<I>(dl: &TargetDataLayout, fields: I)
|
||||
-> Result<bool, LayoutError<'tcx>>
|
||||
where I: Iterator<Item=Result<&'a Layout, LayoutError<'tcx>>> {
|
||||
for field in fields {
|
||||
let field = field?;
|
||||
|
|
@ -542,9 +542,9 @@ impl Struct {
|
|||
/// Find the path leading to a non-zero leaf field, starting from
|
||||
/// the given type and recursing through aggregates.
|
||||
// FIXME(eddyb) track value ranges and traverse already optimized enums.
|
||||
pub fn non_zero_field_in_type<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
ty: Ty<'tcx>)
|
||||
-> Result<Option<FieldPath>, LayoutError<'tcx>> {
|
||||
pub fn non_zero_field_in_type(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>)
|
||||
-> Result<Option<FieldPath>, LayoutError<'tcx>> {
|
||||
let tcx = infcx.tcx;
|
||||
match (ty.layout(infcx)?, &ty.sty) {
|
||||
(&Scalar { non_zero: true, .. }, _) => Ok(Some(vec![])),
|
||||
|
|
@ -600,9 +600,9 @@ impl Struct {
|
|||
|
||||
/// Find the path leading to a non-zero leaf field, starting from
|
||||
/// the given set of fields and recursing through aggregates.
|
||||
pub fn non_zero_field_path<'a, 'tcx, I>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
fields: I)
|
||||
-> Result<Option<FieldPath>, LayoutError<'tcx>>
|
||||
pub fn non_zero_field_path<I>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
fields: I)
|
||||
-> Result<Option<FieldPath>, LayoutError<'tcx>>
|
||||
where I: Iterator<Item=Ty<'tcx>> {
|
||||
for (i, ty) in fields.enumerate() {
|
||||
if let Some(mut path) = Struct::non_zero_field_in_type(infcx, ty)? {
|
||||
|
|
@ -736,7 +736,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
|||
}
|
||||
|
||||
/// Helper function for normalizing associated types in an inference context.
|
||||
fn normalize_associated_type<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
fn normalize_associated_type<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
if !ty.has_projection_types() {
|
||||
|
|
@ -757,10 +757,10 @@ fn normalize_associated_type<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
infcx.drain_fulfillment_cx_or_panic(DUMMY_SP, &mut fulfill_cx, &result)
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
pub fn compute_uncached<'a, 'tcx>(ty: Ty<'tcx>,
|
||||
infcx: &InferCtxt<'a, 'tcx>)
|
||||
-> Result<Layout, LayoutError<'tcx>> {
|
||||
impl<'a, 'tcx> Layout {
|
||||
pub fn compute_uncached(ty: Ty<'tcx>,
|
||||
infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Result<Layout, LayoutError<'tcx>> {
|
||||
let tcx = infcx.tcx;
|
||||
let dl = &tcx.data_layout;
|
||||
assert!(!ty.has_infer_types());
|
||||
|
|
@ -1220,9 +1220,9 @@ pub enum SizeSkeleton<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SizeSkeleton<'tcx> {
|
||||
pub fn compute<'a>(ty: Ty<'tcx>, infcx: &InferCtxt<'a, 'tcx>)
|
||||
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
|
||||
impl<'a, 'tcx> SizeSkeleton<'tcx> {
|
||||
pub fn compute(ty: Ty<'tcx>, infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
|
||||
let tcx = infcx.tcx;
|
||||
assert!(!ty.has_infer_types());
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ pub struct ImplHeader<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> ImplHeader<'tcx> {
|
||||
pub fn with_fresh_ty_vars(selcx: &mut traits::SelectionContext<'a, 'tcx>,
|
||||
pub fn with_fresh_ty_vars(selcx: &mut traits::SelectionContext<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId)
|
||||
-> ImplHeader<'tcx>
|
||||
{
|
||||
|
|
@ -780,14 +780,14 @@ impl<'a, 'tcx> GenericPredicates<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn instantiate(&self, tcx: TyCtxt<'a, 'tcx>, substs: &Substs<'tcx>)
|
||||
pub fn instantiate(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, substs: &Substs<'tcx>)
|
||||
-> InstantiatedPredicates<'tcx> {
|
||||
InstantiatedPredicates {
|
||||
predicates: self.predicates.subst(tcx, substs),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn instantiate_supertrait(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn instantiate_supertrait(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
poly_trait_ref: &ty::PolyTraitRef<'tcx>)
|
||||
-> InstantiatedPredicates<'tcx>
|
||||
{
|
||||
|
|
@ -838,7 +838,7 @@ impl<'a, 'tcx> Predicate<'tcx> {
|
|||
/// poly-trait-ref holds. This is slightly different from a normal
|
||||
/// substitution in terms of what happens with bound regions. See
|
||||
/// lengthy comment below for details.
|
||||
pub fn subst_supertrait(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn subst_supertrait(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
trait_ref: &ty::PolyTraitRef<'tcx>)
|
||||
-> ty::Predicate<'tcx>
|
||||
{
|
||||
|
|
@ -1210,7 +1210,7 @@ impl<'tcx> TraitRef<'tcx> {
|
|||
/// more distinctions clearer.
|
||||
#[derive(Clone)]
|
||||
pub struct ParameterEnvironment<'a, 'tcx:'a> {
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
/// See `construct_free_substs` for details.
|
||||
pub free_substs: Substs<'tcx>,
|
||||
|
|
@ -1260,7 +1260,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
}
|
||||
|
||||
/// Construct a parameter environment given an item, impl item, or trait item
|
||||
pub fn for_item(tcx: TyCtxt<'a, 'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> {
|
||||
pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx> {
|
||||
match tcx.map.find(id) {
|
||||
Some(ast_map::NodeImplItem(ref impl_item)) => {
|
||||
match impl_item.node {
|
||||
|
|
@ -1569,7 +1569,7 @@ impl VariantKind {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx, 'container> AdtDefData<'tcx, 'container> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
did: DefId,
|
||||
kind: AdtKind,
|
||||
variants: Vec<VariantDefData<'tcx, 'container>>) -> Self {
|
||||
|
|
@ -1599,7 +1599,7 @@ impl<'a, 'tcx, 'container> AdtDefData<'tcx, 'container> {
|
|||
}
|
||||
}
|
||||
|
||||
fn calculate_dtorck(&'tcx self, tcx: TyCtxt<'a, 'tcx>) {
|
||||
fn calculate_dtorck(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
if tcx.is_adt_dtorck(self) {
|
||||
self.flags.set(self.flags.get() | AdtFlags::IS_DTORCK);
|
||||
}
|
||||
|
|
@ -1620,7 +1620,7 @@ impl<'a, 'tcx, 'container> AdtDefData<'tcx, 'container> {
|
|||
/// true, this type being safe for destruction requires it to be
|
||||
/// alive; Otherwise, only the contents are required to be.
|
||||
#[inline]
|
||||
pub fn is_dtorck(&'tcx self, tcx: TyCtxt<'a, 'tcx>) -> bool {
|
||||
pub fn is_dtorck(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
|
||||
if !self.flags.get().intersects(AdtFlags::IS_DTORCK_VALID) {
|
||||
self.calculate_dtorck(tcx)
|
||||
}
|
||||
|
|
@ -1661,12 +1661,12 @@ impl<'a, 'tcx, 'container> AdtDefData<'tcx, 'container> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_scheme(&self, tcx: TyCtxt<'a, 'tcx>) -> TypeScheme<'tcx> {
|
||||
pub fn type_scheme(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> TypeScheme<'tcx> {
|
||||
tcx.lookup_item_type(self.did)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn predicates(&self, tcx: TyCtxt<'a, 'tcx>) -> GenericPredicates<'tcx> {
|
||||
pub fn predicates(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> GenericPredicates<'tcx> {
|
||||
tcx.lookup_predicates(self.did)
|
||||
}
|
||||
|
||||
|
|
@ -1754,7 +1754,7 @@ impl<'a, 'tcx, 'container> AdtDefData<'tcx, 'container> {
|
|||
///
|
||||
/// Due to normalization being eager, this applies even if
|
||||
/// the associated type is behind a pointer, e.g. issue #31299.
|
||||
pub fn sized_constraint(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn sized_constraint(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
let dep_node = DepNode::SizedConstraint(self.did);
|
||||
match self.sized_constraint.get(dep_node) {
|
||||
None => {
|
||||
|
|
@ -1783,7 +1783,7 @@ impl<'a, 'tcx> AdtDefData<'tcx, 'tcx> {
|
|||
/// such.
|
||||
/// - a TyError, if a type contained itself. The representability
|
||||
/// check should catch this case.
|
||||
fn calculate_sized_constraint_inner(&'tcx self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn calculate_sized_constraint_inner(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
stack: &mut Vec<AdtDefMaster<'tcx>>)
|
||||
{
|
||||
|
||||
|
|
@ -1836,7 +1836,7 @@ impl<'a, 'tcx> AdtDefData<'tcx, 'tcx> {
|
|||
|
||||
fn sized_constraint_for_ty(
|
||||
&'tcx self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
stack: &mut Vec<AdtDefMaster<'tcx>>,
|
||||
ty: Ty<'tcx>
|
||||
) -> Vec<Ty<'tcx>> {
|
||||
|
|
@ -1963,7 +1963,7 @@ impl<'a, 'tcx, 'container> FieldDefData<'tcx, 'container> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ty(&self, tcx: TyCtxt<'a, 'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> {
|
||||
pub fn ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> {
|
||||
self.unsubst_ty().subst(tcx, subst)
|
||||
}
|
||||
|
||||
|
|
@ -1993,8 +1993,8 @@ pub enum ClosureKind {
|
|||
FnOnce,
|
||||
}
|
||||
|
||||
impl ClosureKind {
|
||||
pub fn trait_did(&self, tcx: TyCtxt) -> DefId {
|
||||
impl<'a, 'tcx> ClosureKind {
|
||||
pub fn trait_did(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> DefId {
|
||||
let result = match *self {
|
||||
ClosureKind::Fn => tcx.lang_items.require(FnTraitLangItem),
|
||||
ClosureKind::FnMut => {
|
||||
|
|
@ -2144,7 +2144,7 @@ impl BorrowKind {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn node_id_to_type(self, id: NodeId) -> Ty<'tcx> {
|
||||
match self.node_id_to_type_opt(id) {
|
||||
Some(ty) => ty,
|
||||
|
|
@ -2941,7 +2941,7 @@ pub enum ExplicitSelfCategory {
|
|||
ByBox,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn with_freevars<T, F>(self, fid: NodeId, f: F) -> T where
|
||||
F: FnOnce(&[hir::Freevar]) -> T,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub enum Component<'tcx> {
|
|||
EscapingProjection(Vec<Component<'tcx>>),
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx, 'tcx> {
|
||||
/// Returns all the things that must outlive `'a` for the condition
|
||||
/// `ty0: 'a` to hold.
|
||||
pub fn outlives_components(&self, ty0: Ty<'tcx>)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub enum Cause {
|
|||
}
|
||||
|
||||
pub trait TypeRelation<'a,'tcx> : Sized {
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx>;
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
||||
|
||||
/// Returns a static string we can use for printouts.
|
||||
fn tag(&self) -> &'static str;
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@ use hir;
|
|||
|
||||
impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
|
||||
type Lifted = (A::Lifted, B::Lifted);
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Option<Self::Lifted> {
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
||||
tcx.lift(&self.0).and_then(|a| tcx.lift(&self.1).map(|b| (a, b)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] {
|
||||
type Lifted = Vec<T::Lifted>;
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Option<Self::Lifted> {
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
||||
// type annotation needed to inform `projection_must_outlive`
|
||||
let mut result : Vec<<T as Lift<'tcx>>::Lifted>
|
||||
= Vec::with_capacity(self.len());
|
||||
|
|
@ -55,7 +55,7 @@ impl<'tcx> Lift<'tcx> for ty::Region {
|
|||
|
||||
impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> {
|
||||
type Lifted = TraitRef<'tcx>;
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx>) -> Option<TraitRef<'tcx>> {
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<TraitRef<'tcx>> {
|
||||
tcx.lift(&self.substs).map(|substs| TraitRef {
|
||||
def_id: self.def_id,
|
||||
substs: substs
|
||||
|
|
@ -65,7 +65,7 @@ impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> {
|
|||
|
||||
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
||||
type Lifted = ty::TraitPredicate<'tcx>;
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
|
||||
tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate {
|
||||
trait_ref: trait_ref
|
||||
})
|
||||
|
|
@ -74,21 +74,22 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
|||
|
||||
impl<'a, 'tcx> Lift<'tcx> for ty::EquatePredicate<'a> {
|
||||
type Lifted = ty::EquatePredicate<'tcx>;
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx>) -> Option<ty::EquatePredicate<'tcx>> {
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<ty::EquatePredicate<'tcx>> {
|
||||
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::EquatePredicate(a, b))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
|
||||
type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Option<Self::Lifted> {
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
||||
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
|
||||
type Lifted = ty::ProjectionPredicate<'tcx>;
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> {
|
||||
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>)
|
||||
-> Option<ty::ProjectionPredicate<'tcx>> {
|
||||
tcx.lift(&(self.projection_ty.trait_ref, self.ty)).map(|(trait_ref, ty)| {
|
||||
ty::ProjectionPredicate {
|
||||
projection_ty: ty::ProjectionTy {
|
||||
|
|
@ -103,7 +104,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
|
|||
|
||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
|
||||
type Lifted = ty::Binder<T::Lifted>;
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx>) -> Option<Self::Lifted> {
|
||||
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
||||
tcx.lift(&self.0).map(|x| ty::Binder(x))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ impl<'a, 'tcx> TraitTy<'tcx> {
|
|||
/// we convert the principal trait-ref into a normal trait-ref,
|
||||
/// you must give *some* self-type. A common choice is `mk_err()`
|
||||
/// or some skolemized type.
|
||||
pub fn principal_trait_ref_with_self_ty(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn principal_trait_ref_with_self_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
self_ty: Ty<'tcx>)
|
||||
-> ty::PolyTraitRef<'tcx>
|
||||
{
|
||||
|
|
@ -292,7 +292,7 @@ impl<'a, 'tcx> TraitTy<'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn projection_bounds_with_self_ty(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn projection_bounds_with_self_ty(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
self_ty: Ty<'tcx>)
|
||||
-> Vec<ty::PolyProjectionPredicate<'tcx>>
|
||||
{
|
||||
|
|
@ -537,7 +537,7 @@ impl<'a, 'tcx> ParamTy {
|
|||
ParamTy::new(def.space, def.index, def.name)
|
||||
}
|
||||
|
||||
pub fn to_ty(self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn to_ty(self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
tcx.mk_param(self.space, self.idx, self.name)
|
||||
}
|
||||
|
||||
|
|
@ -771,7 +771,7 @@ impl<'a, 'tcx> BuiltinBounds {
|
|||
self.into_iter()
|
||||
}
|
||||
|
||||
pub fn to_predicates(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn to_predicates(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
self_ty: Ty<'tcx>)
|
||||
-> Vec<ty::Predicate<'tcx>> {
|
||||
self.iter().filter_map(|builtin_bound|
|
||||
|
|
@ -819,7 +819,7 @@ impl CLike for BuiltinBound {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn try_add_builtin_trait(self,
|
||||
trait_def_id: DefId,
|
||||
builtin_bounds: &mut EnumSet<BuiltinBound>)
|
||||
|
|
@ -971,7 +971,7 @@ impl<'a, 'tcx> TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn sequence_element_type(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
TyStr => tcx.mk_mach_uint(ast::UintTy::U8),
|
||||
|
|
@ -979,7 +979,7 @@ impl<'a, 'tcx> TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn simd_type(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn simd_type(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyStruct(def, substs) => {
|
||||
def.struct_variant().fields[0].ty(tcx, substs)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ impl<'a, 'tcx> Substs<'tcx> {
|
|||
}
|
||||
|
||||
/// Creates a trait-ref out of this substs, ignoring the FnSpace substs
|
||||
pub fn to_trait_ref(&self, tcx: TyCtxt<'a, 'tcx>, trait_id: DefId)
|
||||
pub fn to_trait_ref(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_id: DefId)
|
||||
-> ty::TraitRef<'tcx> {
|
||||
let Substs { mut types, mut regions } = self.clone();
|
||||
types.truncate(FnSpace, 0);
|
||||
|
|
@ -532,18 +532,18 @@ impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
|
|||
// there is more information available (for better errors).
|
||||
|
||||
pub trait Subst<'tcx> : Sized {
|
||||
fn subst<'a>(&self, tcx: TyCtxt<'a, 'tcx>, substs: &Substs<'tcx>) -> Self {
|
||||
fn subst<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, substs: &Substs<'tcx>) -> Self {
|
||||
self.subst_spanned(tcx, substs, None)
|
||||
}
|
||||
|
||||
fn subst_spanned<'a>(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn subst_spanned<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
substs: &Substs<'tcx>,
|
||||
span: Option<Span>)
|
||||
-> Self;
|
||||
}
|
||||
|
||||
impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
|
||||
fn subst_spanned<'a>(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn subst_spanned<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
substs: &Substs<'tcx>,
|
||||
span: Option<Span>)
|
||||
-> T
|
||||
|
|
@ -562,7 +562,7 @@ impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
|
|||
// The actual substitution engine itself is a type folder.
|
||||
|
||||
struct SubstFolder<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
substs: &'a Substs<'tcx>,
|
||||
|
||||
// The location for which the substitution is performed, if available.
|
||||
|
|
@ -579,7 +579,7 @@ struct SubstFolder<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx> { self.tcx }
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx }
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
||||
self.region_binders_passed += 1;
|
||||
|
|
|
|||
|
|
@ -117,18 +117,18 @@ impl<'a, 'tcx> TraitDef<'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
fn write_trait_impls(&self, tcx: TyCtxt<'a, 'tcx>) {
|
||||
fn write_trait_impls(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
tcx.dep_graph.write(DepNode::TraitImpls(self.trait_ref.def_id));
|
||||
}
|
||||
|
||||
fn read_trait_impls(&self, tcx: TyCtxt<'a, 'tcx>) {
|
||||
fn read_trait_impls(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
tcx.dep_graph.read(DepNode::TraitImpls(self.trait_ref.def_id));
|
||||
}
|
||||
|
||||
/// Records a basic trait-to-implementation mapping.
|
||||
///
|
||||
/// Returns `true` iff the impl has not previously been recorded.
|
||||
fn record_impl(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn record_impl(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId,
|
||||
impl_trait_ref: TraitRef<'tcx>)
|
||||
-> bool {
|
||||
|
|
@ -163,7 +163,7 @@ impl<'a, 'tcx> TraitDef<'tcx> {
|
|||
}
|
||||
|
||||
/// Records a trait-to-implementation mapping for a crate-local impl.
|
||||
pub fn record_local_impl(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn record_local_impl(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId,
|
||||
impl_trait_ref: TraitRef<'tcx>) {
|
||||
assert!(impl_def_id.is_local());
|
||||
|
|
@ -176,7 +176,7 @@ impl<'a, 'tcx> TraitDef<'tcx> {
|
|||
/// The `parent_impl` is the immediately-less-specialized impl, or the
|
||||
/// trait's def ID if the impl is not a specialization -- information that
|
||||
/// should be pulled from the metadata.
|
||||
pub fn record_remote_impl(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn record_remote_impl(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId,
|
||||
impl_trait_ref: TraitRef<'tcx>,
|
||||
parent_impl: DefId) {
|
||||
|
|
@ -194,9 +194,10 @@ impl<'a, 'tcx> TraitDef<'tcx> {
|
|||
/// Adds a local impl into the specialization graph, returning an error with
|
||||
/// overlap information if the impl overlaps but does not specialize an
|
||||
/// existing impl.
|
||||
pub fn add_impl_for_specialization(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn add_impl_for_specialization(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_def_id: DefId)
|
||||
-> Result<(), traits::Overlap<'a, 'tcx>> {
|
||||
-> Result<(), traits::Overlap<'a, 'tcx, 'tcx>> {
|
||||
assert!(impl_def_id.is_local());
|
||||
|
||||
self.specialization_graph.borrow_mut()
|
||||
|
|
@ -207,7 +208,7 @@ impl<'a, 'tcx> TraitDef<'tcx> {
|
|||
specialization_graph::ancestors(self, of_impl)
|
||||
}
|
||||
|
||||
pub fn for_each_impl<F: FnMut(DefId)>(&self, tcx: TyCtxt<'a, 'tcx>, mut f: F) {
|
||||
pub fn for_each_impl<F: FnMut(DefId)>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, mut f: F) {
|
||||
self.read_trait_impls(tcx);
|
||||
tcx.populate_implementations_for_trait_if_necessary(self.trait_ref.def_id);
|
||||
|
||||
|
|
@ -225,7 +226,7 @@ impl<'a, 'tcx> TraitDef<'tcx> {
|
|||
/// Iterate over every impl that could possibly match the
|
||||
/// self-type `self_ty`.
|
||||
pub fn for_each_relevant_impl<F: FnMut(DefId)>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
self_ty: Ty<'tcx>,
|
||||
mut f: F)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,14 +32,15 @@ use syntax::codemap::Span;
|
|||
use hir;
|
||||
|
||||
pub trait IntTypeExt {
|
||||
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx>;
|
||||
fn disr_incr(&self, tcx: TyCtxt, val: Option<Disr>) -> Option<Disr>;
|
||||
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx>;
|
||||
fn disr_incr<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, val: Option<Disr>)
|
||||
-> Option<Disr>;
|
||||
fn assert_ty_matches(&self, val: Disr);
|
||||
fn initial_discriminant(&self, tcx: TyCtxt) -> Disr;
|
||||
fn initial_discriminant<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Disr;
|
||||
}
|
||||
|
||||
impl IntTypeExt for attr::IntType {
|
||||
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx>) -> Ty<'tcx> {
|
||||
fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
SignedInt(ast::IntTy::I8) => tcx.types.i8,
|
||||
SignedInt(ast::IntTy::I16) => tcx.types.i16,
|
||||
|
|
@ -54,7 +55,7 @@ impl IntTypeExt for attr::IntType {
|
|||
}
|
||||
}
|
||||
|
||||
fn initial_discriminant(&self, tcx: TyCtxt) -> Disr {
|
||||
fn initial_discriminant<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Disr {
|
||||
match *self {
|
||||
SignedInt(ast::IntTy::I8) => ConstInt::I8(0),
|
||||
SignedInt(ast::IntTy::I16) => ConstInt::I16(0),
|
||||
|
|
@ -93,7 +94,8 @@ impl IntTypeExt for attr::IntType {
|
|||
}
|
||||
}
|
||||
|
||||
fn disr_incr(&self, tcx: TyCtxt, val: Option<Disr>) -> Option<Disr> {
|
||||
fn disr_incr<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, val: Option<Disr>)
|
||||
-> Option<Disr> {
|
||||
if let Some(val) = val {
|
||||
self.assert_ty_matches(val);
|
||||
(val + ConstInt::Infer(1)).ok()
|
||||
|
|
@ -170,7 +172,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
pub fn pat_contains_ref_binding(self, pat: &hir::Pat) -> Option<hir::Mutability> {
|
||||
pat_util::pat_contains_ref_binding(&self.def_map, pat)
|
||||
}
|
||||
|
|
@ -337,7 +339,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx> {
|
|||
helper(self, ty, svh, &mut state);
|
||||
return state.finish();
|
||||
|
||||
fn helper<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, ty: Ty<'tcx>, svh: &Svh,
|
||||
fn helper<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, svh: &Svh,
|
||||
state: &mut SipHasher) {
|
||||
macro_rules! byte { ($b:expr) => { ($b as u8).hash(state) } }
|
||||
macro_rules! hash { ($e:expr) => { $e.hash(state) } }
|
||||
|
|
@ -600,7 +602,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn layout(&'tcx self, infcx: &InferCtxt<'a, 'tcx>)
|
||||
pub fn layout(&'tcx self, infcx: &InferCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Result<&'tcx Layout, LayoutError<'tcx>> {
|
||||
let can_cache = !self.has_param_types() && !self.has_self_ty();
|
||||
if can_cache {
|
||||
|
|
@ -620,10 +622,11 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
|
||||
/// Check whether a type is representable. This means it cannot contain unboxed
|
||||
/// structural recursion. This check is needed for structs and enums.
|
||||
pub fn is_representable(&'tcx self, tcx: TyCtxt<'a, 'tcx>, sp: Span) -> Representability {
|
||||
pub fn is_representable(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span)
|
||||
-> Representability {
|
||||
|
||||
// Iterate until something non-representable is found
|
||||
fn find_nonrepresentable<'a, 'tcx, It>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn find_nonrepresentable<'a, 'tcx, It>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sp: Span,
|
||||
seen: &mut Vec<Ty<'tcx>>,
|
||||
iter: It)
|
||||
|
|
@ -633,7 +636,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
|r, ty| cmp::max(r, is_type_structurally_recursive(tcx, sp, seen, ty)))
|
||||
}
|
||||
|
||||
fn are_inner_types_recursive<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, sp: Span,
|
||||
fn are_inner_types_recursive<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span,
|
||||
seen: &mut Vec<Ty<'tcx>>, ty: Ty<'tcx>)
|
||||
-> Representability {
|
||||
match ty.sty {
|
||||
|
|
@ -692,7 +695,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
|
||||
// Does the type `ty` directly (without indirection through a pointer)
|
||||
// contain any types on stack `seen`?
|
||||
fn is_type_structurally_recursive<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn is_type_structurally_recursive<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sp: Span,
|
||||
seen: &mut Vec<Ty<'tcx>>,
|
||||
ty: Ty<'tcx>) -> Representability {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use util::common::ErrorReported;
|
|||
/// inference variable, returns `None`, because we are not able to
|
||||
/// make any progress at all. This is to prevent "livelock" where we
|
||||
/// say "$0 is WF if $0 is WF".
|
||||
pub fn obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
pub fn obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
body_id: ast::NodeId,
|
||||
ty: Ty<'tcx>,
|
||||
span: Span)
|
||||
|
|
@ -49,7 +49,7 @@ pub fn obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
/// well-formed. For example, if there is a trait `Set` defined like
|
||||
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF
|
||||
/// if `Bar: Eq`.
|
||||
pub fn trait_obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
pub fn trait_obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
body_id: ast::NodeId,
|
||||
trait_ref: &ty::TraitRef<'tcx>,
|
||||
span: Span)
|
||||
|
|
@ -60,7 +60,7 @@ pub fn trait_obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
wf.normalize()
|
||||
}
|
||||
|
||||
pub fn predicate_obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
pub fn predicate_obligations<'a,'tcx>(infcx: &InferCtxt<'a, 'tcx, 'tcx>,
|
||||
body_id: ast::NodeId,
|
||||
predicate: &ty::Predicate<'tcx>,
|
||||
span: Span)
|
||||
|
|
@ -123,8 +123,8 @@ pub enum ImpliedBound<'tcx> {
|
|||
/// Compute the implied bounds that a callee/impl can assume based on
|
||||
/// the fact that caller/projector has ensured that `ty` is WF. See
|
||||
/// the `ImpliedBound` type for more details.
|
||||
pub fn implied_bounds<'a,'tcx>(
|
||||
infcx: &'a InferCtxt<'a,'tcx>,
|
||||
pub fn implied_bounds<'a, 'tcx>(
|
||||
infcx: &'a InferCtxt<'a, 'tcx, 'tcx>,
|
||||
body_id: ast::NodeId,
|
||||
ty: Ty<'tcx>,
|
||||
span: Span)
|
||||
|
|
@ -228,7 +228,7 @@ fn implied_bounds_from_components<'tcx>(sub_region: ty::Region,
|
|||
}
|
||||
|
||||
struct WfPredicates<'a,'tcx:'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'a, 'tcx, 'tcx>,
|
||||
body_id: ast::NodeId,
|
||||
span: Span,
|
||||
out: Vec<traits::PredicateObligation<'tcx>>,
|
||||
|
|
@ -526,7 +526,7 @@ impl<'a,'tcx> WfPredicates<'a,'tcx> {
|
|||
/// `'static` would appear in the list. The hard work is done by
|
||||
/// `ty::required_region_bounds`, see that for more information.
|
||||
pub fn object_region_bounds<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
principal: &ty::PolyTraitRef<'tcx>,
|
||||
others: ty::BuiltinBounds)
|
||||
-> Vec<ty::Region>
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ pub enum Ns {
|
|||
Value
|
||||
}
|
||||
|
||||
fn number_of_supplied_defaults<'a, 'tcx, GG>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn number_of_supplied_defaults<'a, 'tcx, GG>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
substs: &subst::Substs,
|
||||
space: subst::ParamSpace,
|
||||
get_generics: GG)
|
||||
-> usize
|
||||
where GG: FnOnce(TyCtxt<'a, 'tcx>) -> ty::Generics<'tcx>
|
||||
where GG: FnOnce(TyCtxt<'a, 'tcx, 'tcx>) -> ty::Generics<'tcx>
|
||||
{
|
||||
let generics = get_generics(tcx);
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
|
|||
projections: &[ty::ProjectionPredicate],
|
||||
get_generics: GG)
|
||||
-> fmt::Result
|
||||
where GG: for<'a, 'tcx> FnOnce(TyCtxt<'a, 'tcx>) -> ty::Generics<'tcx>
|
||||
where GG: for<'a, 'tcx> FnOnce(TyCtxt<'a, 'tcx, 'tcx>) -> ty::Generics<'tcx>
|
||||
{
|
||||
if let (Ns::Value, Some(self_ty)) = (ns, substs.self_ty()) {
|
||||
write!(f, "<{} as ", self_ty)?;
|
||||
|
|
@ -231,7 +231,7 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
|
|||
}
|
||||
|
||||
fn in_binder<'a, 'tcx, T, U>(f: &mut fmt::Formatter,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
original: &ty::Binder<T>,
|
||||
lifted: Option<ty::Binder<U>>) -> fmt::Result
|
||||
where T: fmt::Display, U: fmt::Display + TypeFoldable<'tcx>
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ fn compatible_borrow_kinds(borrow_kind1: ty::BorrowKind,
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.bccx.tcx }
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.bccx.tcx }
|
||||
|
||||
pub fn each_issued_loan<F>(&self, node: ast::NodeId, mut op: F) -> bool where
|
||||
F: FnMut(&Loan<'tcx>) -> bool,
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ impl FragmentSets {
|
|||
}
|
||||
|
||||
pub fn instrument_move_fragments<'a, 'tcx>(this: &MoveData<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sp: Span,
|
||||
id: ast::NodeId) {
|
||||
let span_err = tcx.map.attrs(id).iter()
|
||||
|
|
@ -245,7 +245,7 @@ pub fn instrument_move_fragments<'a, 'tcx>(this: &MoveData<'tcx>,
|
|||
///
|
||||
/// Note: "left-over fragments" means paths that were not directly referenced in moves nor
|
||||
/// assignments, but must nonetheless be tracked as potential drop obligations.
|
||||
pub fn fixup_fragment_sets<'a, 'tcx>(this: &MoveData<'tcx>, tcx: TyCtxt<'a, 'tcx>) {
|
||||
pub fn fixup_fragment_sets<'a, 'tcx>(this: &MoveData<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
|
||||
let mut fragments = this.fragments.borrow_mut();
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ pub fn fixup_fragment_sets<'a, 'tcx>(this: &MoveData<'tcx>, tcx: TyCtxt<'a, 'tcx
|
|||
/// example, if `lp` represents `s.x.j`, then adds moves paths for `s.x.i` and `s.x.k`, the
|
||||
/// siblings of `s.x.j`.
|
||||
fn add_fragment_siblings<'a, 'tcx>(this: &MoveData<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
gathered_fragments: &mut Vec<Fragment>,
|
||||
lp: Rc<LoanPath<'tcx>>,
|
||||
origin_id: Option<ast::NodeId>) {
|
||||
|
|
@ -406,7 +406,7 @@ fn add_fragment_siblings<'a, 'tcx>(this: &MoveData<'tcx>,
|
|||
/// We have determined that `origin_lp` destructures to LpExtend(parent, original_field_name).
|
||||
/// Based on this, add move paths for all of the siblings of `origin_lp`.
|
||||
fn add_fragment_siblings_for_extension<'a, 'tcx>(this: &MoveData<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
gathered_fragments: &mut Vec<Fragment>,
|
||||
parent_lp: &Rc<LoanPath<'tcx>>,
|
||||
mc: mc::MutabilityCategory,
|
||||
|
|
@ -505,7 +505,7 @@ fn add_fragment_siblings_for_extension<'a, 'tcx>(this: &MoveData<'tcx>,
|
|||
/// Adds the single sibling `LpExtend(parent, new_field_name)` of `origin_lp` (the original
|
||||
/// loan-path).
|
||||
fn add_fragment_sibling_core<'a, 'tcx>(this: &MoveData<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
gathered_fragments: &mut Vec<Fragment>,
|
||||
parent: Rc<LoanPath<'tcx>>,
|
||||
mc: mc::MutabilityCategory,
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ fn check_mutability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx> { self.bccx.tcx }
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.bccx.tcx }
|
||||
|
||||
/// Guarantees that `cmt` is assignable, or reports an error.
|
||||
fn guarantee_assignment_valid(&mut self,
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ impl<D: BitDenotation> DataflowState<D> {
|
|||
|
||||
|
||||
impl<'a, 'tcx> DataflowState<MoveData<'tcx>> {
|
||||
pub fn new_move_analysis(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx>) -> Self {
|
||||
pub fn new_move_analysis(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
|
||||
let move_data = MoveData::gather_moves(mir, tcx);
|
||||
DataflowState::new(mir, move_data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ impl<'a, 'tcx> MovePathDataBuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> MoveData<'tcx> {
|
||||
pub fn gather_moves(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx>) -> Self {
|
||||
pub fn gather_moves(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self {
|
||||
gather_moves(mir, tcx)
|
||||
}
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ enum StmtKind {
|
|||
Aggregate, Drop, CallFn, CallArg, Return,
|
||||
}
|
||||
|
||||
fn gather_moves<'a, 'tcx>(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx>) -> MoveData<'tcx> {
|
||||
fn gather_moves<'a, 'tcx>(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> MoveData<'tcx> {
|
||||
use self::StmtKind as SK;
|
||||
|
||||
let bbs = mir.all_basic_blocks();
|
||||
|
|
@ -667,7 +667,7 @@ fn gather_moves<'a, 'tcx>(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx>) -> MoveData<'t
|
|||
}
|
||||
|
||||
struct BlockContext<'b, 'a: 'b, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'b, 'tcx>,
|
||||
tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
moves: &'b mut Vec<MoveOut>,
|
||||
builder: MovePathDataBuilder<'a, 'tcx>,
|
||||
path_map: &'b mut Vec<Vec<MoveOutIndex>>,
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, mir_map: &MirMap<'tcx>) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir_map: &MirMap<'tcx>) {
|
||||
let mut bccx = BorrowckCtxt {
|
||||
tcx: tcx,
|
||||
mir_map: Some(mir_map),
|
||||
|
|
@ -244,7 +244,7 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
|||
/// Accessor for introspective clients inspecting `AnalysisData` and
|
||||
/// the `BorrowckCtxt` itself , e.g. the flowgraph visualizer.
|
||||
pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir_map: Option<&'a MirMap<'tcx>>,
|
||||
fn_parts: FnParts<'a>,
|
||||
cfg: &cfg::CFG)
|
||||
|
|
@ -278,7 +278,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
|
|||
// Type definitions
|
||||
|
||||
pub struct BorrowckCtxt<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
// Hacky. As we visit various fns, we have to load up the
|
||||
// free-region map for each one. This map is computed by during
|
||||
|
|
@ -427,7 +427,7 @@ pub fn closure_to_block(closure_id: ast::NodeId,
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> LoanPath<'tcx> {
|
||||
pub fn kill_scope(&self, tcx: TyCtxt<'a, 'tcx>) -> region::CodeExtent {
|
||||
pub fn kill_scope(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> region::CodeExtent {
|
||||
match self.kind {
|
||||
LpVar(local_id) => tcx.region_maps.var_scope(local_id),
|
||||
LpUpvar(upvar_id) => {
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
|
||||
/// Returns the existing move path index for `lp`, if any, and otherwise adds a new index for
|
||||
/// `lp` and any of its base paths that do not yet have an index.
|
||||
pub fn move_path(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn move_path(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
lp: Rc<LoanPath<'tcx>>) -> MovePathIndex {
|
||||
match self.path_map.borrow().get(&lp) {
|
||||
Some(&index) => {
|
||||
|
|
@ -363,7 +363,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
}
|
||||
|
||||
/// Adds a new move entry for a move of `lp` that occurs at location `id` with kind `kind`.
|
||||
pub fn add_move(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn add_move(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
lp: Rc<LoanPath<'tcx>>,
|
||||
id: ast::NodeId,
|
||||
kind: MoveKind) {
|
||||
|
|
@ -390,7 +390,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
|
||||
/// Adds a new record for an assignment to `lp` that occurs at location `id` with the given
|
||||
/// `span`.
|
||||
pub fn add_assignment(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn add_assignment(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
lp: Rc<LoanPath<'tcx>>,
|
||||
assign_id: ast::NodeId,
|
||||
span: Span,
|
||||
|
|
@ -434,7 +434,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
/// variant `lp`, that occurs at location `pattern_id`. (One
|
||||
/// should be able to recover the span info from the
|
||||
/// `pattern_id` and the ast_map, I think.)
|
||||
pub fn add_variant_match(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn add_variant_match(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
lp: Rc<LoanPath<'tcx>>,
|
||||
pattern_id: ast::NodeId,
|
||||
base_lp: Rc<LoanPath<'tcx>>,
|
||||
|
|
@ -457,7 +457,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
self.variant_matches.borrow_mut().push(variant_match);
|
||||
}
|
||||
|
||||
fn fixup_fragment_sets(&self, tcx: TyCtxt<'a, 'tcx>) {
|
||||
fn fixup_fragment_sets(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
fragments::fixup_fragment_sets(self, tcx)
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
/// Moves are generated by moves and killed by assignments and
|
||||
/// scoping. Assignments are generated by assignment to variables and
|
||||
/// killed by scoping. See `README.md` for more details.
|
||||
fn add_gen_kills(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn add_gen_kills(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
dfcx_moves: &mut MoveDataFlow,
|
||||
dfcx_assign: &mut AssignDataFlow) {
|
||||
for (i, the_move) in self.moves.borrow().iter().enumerate() {
|
||||
|
|
@ -595,7 +595,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
|
||||
impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
|
||||
pub fn new(move_data: MoveData<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cfg: &cfg::CFG,
|
||||
id_range: IdRange,
|
||||
decl: &hir::FnDecl,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ impl<'a> FromIterator<Vec<&'a Pat>> for Matrix<'a> {
|
|||
|
||||
//NOTE: appears to be the only place other then InferCtxt to contain a ParamEnv
|
||||
pub struct MatchCheckCtxt<'a, 'tcx: 'a> {
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub param_env: ParameterEnvironment<'a, 'tcx>,
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt) {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
tcx.visit_all_items_in_krate(DepNode::MatchCheck, &mut MatchCheckCtxt {
|
||||
tcx: tcx,
|
||||
param_env: tcx.empty_parameter_environment(),
|
||||
|
|
@ -455,13 +455,13 @@ fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> {
|
|||
}
|
||||
|
||||
pub struct StaticInliner<'a, 'tcx: 'a> {
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub failed: bool,
|
||||
pub renaming_map: Option<&'a mut FnvHashMap<(NodeId, Span), NodeId>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> StaticInliner<'a, 'tcx> {
|
||||
pub fn new<'b>(tcx: TyCtxt<'b, 'tcx>,
|
||||
pub fn new<'b>(tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
renaming_map: Option<&'b mut FnvHashMap<(NodeId, Span), NodeId>>)
|
||||
-> StaticInliner<'b, 'tcx> {
|
||||
StaticInliner {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ macro_rules! math {
|
|||
}
|
||||
}
|
||||
|
||||
fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
enum_def: DefId,
|
||||
variant_def: DefId)
|
||||
-> Option<&'tcx Expr> {
|
||||
|
|
@ -90,7 +90,7 @@ fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
///
|
||||
/// `substs` is optional and is used for associated constants.
|
||||
/// This generally happens in late/trans const evaluation.
|
||||
pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
substs: Option<subst::Substs<'tcx>>)
|
||||
-> Option<(&'tcx Expr, Option<ty::Ty<'tcx>>)> {
|
||||
|
|
@ -182,8 +182,9 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
fn inline_const_fn_from_external_crate(tcx: TyCtxt, def_id: DefId)
|
||||
-> Option<ast::NodeId> {
|
||||
fn inline_const_fn_from_external_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
-> Option<ast::NodeId> {
|
||||
match tcx.extern_const_fns.borrow().get(&def_id) {
|
||||
Some(&ast::DUMMY_NODE_ID) => return None,
|
||||
Some(&fn_id) => return Some(fn_id),
|
||||
|
|
@ -205,7 +206,7 @@ fn inline_const_fn_from_external_crate(tcx: TyCtxt, def_id: DefId)
|
|||
fn_id
|
||||
}
|
||||
|
||||
pub fn lookup_const_fn_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, def_id: DefId)
|
||||
pub fn lookup_const_fn_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> Option<FnLikeNode<'tcx>>
|
||||
{
|
||||
let fn_id = if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
||||
|
|
@ -238,8 +239,11 @@ pub fn lookup_const_fn_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, def_id: DefId)
|
|||
}
|
||||
}
|
||||
|
||||
pub fn const_expr_to_pat(tcx: TyCtxt, expr: &Expr, pat_id: ast::NodeId, span: Span)
|
||||
-> Result<P<hir::Pat>, DefId> {
|
||||
pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
expr: &Expr,
|
||||
pat_id: ast::NodeId,
|
||||
span: Span)
|
||||
-> Result<P<hir::Pat>, DefId> {
|
||||
let pat_ty = tcx.expr_ty(expr);
|
||||
debug!("expr={:?} pat_ty={:?} pat_id={}", expr, pat_ty, pat_id);
|
||||
match pat_ty.sty {
|
||||
|
|
@ -339,7 +343,8 @@ pub fn const_expr_to_pat(tcx: TyCtxt, expr: &Expr, pat_id: ast::NodeId, span: Sp
|
|||
Ok(P(hir::Pat { id: expr.id, node: pat, span: span }))
|
||||
}
|
||||
|
||||
pub fn eval_const_expr(tcx: TyCtxt, e: &Expr) -> ConstVal {
|
||||
pub fn eval_const_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
e: &Expr) -> ConstVal {
|
||||
match eval_const_expr_partial(tcx, e, ExprTypeChecked, None) {
|
||||
Ok(r) => r,
|
||||
// non-const path still needs to be a fatal error, because enums are funky
|
||||
|
|
@ -526,7 +531,7 @@ macro_rules! signal {
|
|||
/// guaranteed to be evaluatable. `ty_hint` is usually ExprTypeChecked,
|
||||
/// but a few places need to evaluate constants during type-checking, like
|
||||
/// computing the length of an array. (See also the FIXME above EvalHint.)
|
||||
pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
e: &Expr,
|
||||
ty_hint: EvalHint<'tcx>,
|
||||
fn_args: FnArgMap) -> EvalResult {
|
||||
|
|
@ -932,7 +937,7 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
fn infer<'a, 'tcx>(i: ConstInt,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty_hint: &ty::TypeVariants<'tcx>)
|
||||
-> Result<ConstInt, ErrKind> {
|
||||
use syntax::ast::*;
|
||||
|
|
@ -996,7 +1001,7 @@ fn infer<'a, 'tcx>(i: ConstInt,
|
|||
}
|
||||
}
|
||||
|
||||
fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ti: &'tcx hir::TraitItem,
|
||||
trait_id: DefId,
|
||||
rcvr_substs: subst::Substs<'tcx>)
|
||||
|
|
@ -1053,7 +1058,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, val: ConstInt, ty: ty::Ty) -> CastResult {
|
||||
fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstInt, ty: ty::Ty) -> CastResult {
|
||||
let v = val.to_u64_unchecked();
|
||||
match ty.sty {
|
||||
ty::TyBool if v == 0 => Ok(Bool(false)),
|
||||
|
|
@ -1098,7 +1103,7 @@ fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, val: ConstInt, ty: ty::Ty) ->
|
|||
}
|
||||
}
|
||||
|
||||
fn cast_const_float<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, f: f64, ty: ty::Ty) -> CastResult {
|
||||
fn cast_const_float<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: f64, ty: ty::Ty) -> CastResult {
|
||||
match ty.sty {
|
||||
ty::TyInt(_) if f >= 0.0 => cast_const_int(tcx, Infer(f as u64), ty),
|
||||
ty::TyInt(_) => cast_const_int(tcx, InferSigned(f as i64), ty),
|
||||
|
|
@ -1109,7 +1114,7 @@ fn cast_const_float<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, f: f64, ty: ty::Ty) -> Cast
|
|||
}
|
||||
}
|
||||
|
||||
fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, val: ConstVal, ty: ty::Ty) -> CastResult {
|
||||
fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstVal, ty: ty::Ty) -> CastResult {
|
||||
match val {
|
||||
Integral(i) => cast_const_int(tcx, i, ty),
|
||||
Bool(b) => cast_const_int(tcx, Infer(b as u64), ty),
|
||||
|
|
@ -1127,7 +1132,7 @@ fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>, val: ConstVal, ty: ty::Ty) -> Cas
|
|||
}
|
||||
|
||||
fn lit_to_const<'a, 'tcx>(lit: &ast::LitKind,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty_hint: Option<Ty<'tcx>>,
|
||||
span: Span)
|
||||
-> Result<ConstVal, ErrKind> {
|
||||
|
|
@ -1197,7 +1202,7 @@ pub fn compare_const_vals(a: &ConstVal, b: &ConstVal) -> Option<Ordering> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn compare_lit_exprs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn compare_lit_exprs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
a: &Expr,
|
||||
b: &Expr) -> Option<Ordering> {
|
||||
let a = match eval_const_expr_partial(tcx, a, ExprTypeChecked, None) {
|
||||
|
|
@ -1219,7 +1224,8 @@ pub fn compare_lit_exprs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
|
||||
|
||||
/// Returns the repeat count for a repeating vector expression.
|
||||
pub fn eval_repeat_count(tcx: TyCtxt, count_expr: &hir::Expr) -> usize {
|
||||
pub fn eval_repeat_count<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
count_expr: &hir::Expr) -> usize {
|
||||
let hint = UncheckedExprHint(tcx.types.usize);
|
||||
match eval_const_expr_partial(tcx, count_expr, hint, None) {
|
||||
Ok(Integral(Usize(count))) => {
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ pub struct CompileState<'a, 'b, 'ast: 'a, 'tcx: 'b> where 'ast: 'tcx {
|
|||
pub resolutions: Option<&'a Resolutions>,
|
||||
pub mir_map: Option<&'b MirMap<'tcx>>,
|
||||
pub analysis: Option<&'a ty::CrateAnalysis<'a>>,
|
||||
pub tcx: Option<TyCtxt<'b, 'tcx>>,
|
||||
pub tcx: Option<TyCtxt<'b, 'tcx, 'tcx>>,
|
||||
pub trans: Option<&'a trans::CrateTranslation>,
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
|
|||
hir_crate: &'a hir::Crate,
|
||||
analysis: &'a ty::CrateAnalysis<'a>,
|
||||
mir_map: Option<&'b MirMap<'tcx>>,
|
||||
tcx: TyCtxt<'b, 'tcx>,
|
||||
tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
crate_name: &'a str)
|
||||
-> CompileState<'a, 'b, 'ast, 'tcx> {
|
||||
CompileState {
|
||||
|
|
@ -817,7 +817,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
|||
name: &str,
|
||||
f: F)
|
||||
-> Result<R, usize>
|
||||
where F: for<'a> FnOnce(TyCtxt<'a, 'tcx>,
|
||||
where F: for<'a> FnOnce(TyCtxt<'a, 'tcx, 'tcx>,
|
||||
Option<MirMap<'tcx>>,
|
||||
ty::CrateAnalysis,
|
||||
CompileResult) -> R
|
||||
|
|
@ -992,7 +992,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
|||
}
|
||||
|
||||
/// Run the translation phase to LLVM, after which the AST and analysis can
|
||||
pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mut mir_map: MirMap<'tcx>,
|
||||
analysis: ty::CrateAnalysis)
|
||||
-> trans::CrateTranslation {
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> {
|
|||
|
||||
|
||||
struct TypedAnnotation<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
|
||||
|
|
@ -690,7 +690,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
|
|||
}
|
||||
|
||||
fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir_map: Option<&MirMap<'tcx>>,
|
||||
code: blocks::Code,
|
||||
mode: PpFlowGraphMode,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ use syntax::feature_gate::UnstableFeatures;
|
|||
use rustc::hir;
|
||||
|
||||
struct Env<'a, 'tcx: 'a> {
|
||||
infcx: &'a infer::InferCtxt<'a, 'tcx>,
|
||||
infcx: &'a infer::InferCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
struct RH<'a> {
|
||||
|
|
@ -160,7 +160,7 @@ fn test_env<F>(source_string: &str,
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Env<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
@ -354,25 +354,25 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
infer::TypeTrace::dummy(self.tcx())
|
||||
}
|
||||
|
||||
pub fn sub(&self, t1: &Ty<'tcx>, t2: &Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
pub fn sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
let trace = self.dummy_type_trace();
|
||||
self.infcx.sub(true, trace, t1, t2)
|
||||
self.infcx.sub(true, trace, &t1, &t2)
|
||||
}
|
||||
|
||||
pub fn lub(&self, t1: &Ty<'tcx>, t2: &Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
pub fn lub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
let trace = self.dummy_type_trace();
|
||||
self.infcx.lub(true, trace, t1, t2)
|
||||
self.infcx.lub(true, trace, &t1, &t2)
|
||||
}
|
||||
|
||||
pub fn glb(&self, t1: &Ty<'tcx>, t2: &Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
pub fn glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
|
||||
let trace = self.dummy_type_trace();
|
||||
self.infcx.glb(true, trace, t1, t2)
|
||||
self.infcx.glb(true, trace, &t1, &t2)
|
||||
}
|
||||
|
||||
/// Checks that `t1 <: t2` is true (this may register additional
|
||||
/// region checks).
|
||||
pub fn check_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) {
|
||||
match self.sub(&t1, &t2) {
|
||||
match self.sub(t1, t2) {
|
||||
Ok(InferOk { obligations, .. }) => {
|
||||
// FIXME(#32730) once obligations are being propagated, assert the right thing.
|
||||
assert!(obligations.is_empty());
|
||||
|
|
@ -386,7 +386,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
/// Checks that `t1 <: t2` is false (this may register additional
|
||||
/// region checks).
|
||||
pub fn check_not_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) {
|
||||
match self.sub(&t1, &t2) {
|
||||
match self.sub(t1, t2) {
|
||||
Err(_) => {}
|
||||
Ok(_) => {
|
||||
panic!("unexpected success computing sub({:?},{:?})", t1, t2);
|
||||
|
|
@ -396,7 +396,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
|
||||
/// Checks that `LUB(t1,t2) == t_lub`
|
||||
pub fn check_lub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_lub: Ty<'tcx>) {
|
||||
match self.lub(&t1, &t2) {
|
||||
match self.lub(t1, t2) {
|
||||
Ok(InferOk { obligations, value: t }) => {
|
||||
// FIXME(#32730) once obligations are being propagated, assert the right thing.
|
||||
assert!(obligations.is_empty());
|
||||
|
|
@ -412,7 +412,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
/// Checks that `GLB(t1,t2) == t_glb`
|
||||
pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) {
|
||||
debug!("check_glb(t1={}, t2={}, t_glb={})", t1, t2, t_glb);
|
||||
match self.glb(&t1, &t2) {
|
||||
match self.glb(t1, t2) {
|
||||
Err(e) => {
|
||||
panic!("unexpected error computing LUB: {:?}", e)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ const IF_THIS_CHANGED: &'static str = "rustc_if_this_changed";
|
|||
const THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need";
|
||||
const ID: &'static str = "id";
|
||||
|
||||
pub fn assert_dep_graph(tcx: TyCtxt) {
|
||||
pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
|
||||
if tcx.sess.opts.debugging_opts.dump_dep_graph {
|
||||
|
|
@ -98,7 +98,7 @@ type TargetHashMap =
|
|||
FnvHashSet<(Span, InternedString, ast::NodeId, DepNode<DefId>)>>;
|
||||
|
||||
struct IfThisChanged<'a, 'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
if_this_changed: SourceHashMap,
|
||||
then_this_would_need: TargetHashMap,
|
||||
}
|
||||
|
|
@ -172,9 +172,9 @@ impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_paths(tcx: TyCtxt,
|
||||
if_this_changed: &SourceHashMap,
|
||||
then_this_would_need: &TargetHashMap)
|
||||
fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
if_this_changed: &SourceHashMap,
|
||||
then_this_would_need: &TargetHashMap)
|
||||
{
|
||||
// Return early here so as not to construct the query, which is not cheap.
|
||||
if if_this_changed.is_empty() {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub trait SvhCalculate {
|
|||
fn calculate_item_hash(self, def_id: DefId) -> u64;
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> SvhCalculate for TyCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx> SvhCalculate for TyCtxt<'a, 'tcx, 'tcx> {
|
||||
fn calculate_krate_hash(self) -> Svh {
|
||||
// FIXME (#14132): This is better than it used to be, but it still not
|
||||
// ideal. We now attempt to hash only the relevant portions of the
|
||||
|
|
@ -118,13 +118,13 @@ mod svh_visitor {
|
|||
use std::hash::{Hash, SipHasher};
|
||||
|
||||
pub struct StrictVersionHashVisitor<'a, 'tcx: 'a> {
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub st: &'a mut SipHasher,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> StrictVersionHashVisitor<'a, 'tcx> {
|
||||
pub fn new(st: &'a mut SipHasher,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Self {
|
||||
StrictVersionHashVisitor { st: st, tcx: tcx }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,13 +63,13 @@ impl RetracedDefIdDirectory {
|
|||
}
|
||||
|
||||
pub struct DefIdDirectoryBuilder<'a,'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
hash: DefIdMap<Option<DefPathIndex>>,
|
||||
directory: DefIdDirectory,
|
||||
}
|
||||
|
||||
impl<'a,'tcx> DefIdDirectoryBuilder<'a,'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx>) -> DefIdDirectoryBuilder<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> DefIdDirectoryBuilder<'a, 'tcx> {
|
||||
DefIdDirectoryBuilder {
|
||||
tcx: tcx,
|
||||
hash: DefIdMap(),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const CLEAN: &'static str = "rustc_clean";
|
|||
const LABEL: &'static str = "label";
|
||||
const CFG: &'static str = "cfg";
|
||||
|
||||
pub fn check_dirty_clean_annotations(tcx: TyCtxt) {
|
||||
pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
let query = tcx.dep_graph.query();
|
||||
let krate = tcx.map.krate();
|
||||
|
|
@ -49,7 +49,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt) {
|
|||
}
|
||||
|
||||
pub struct DirtyCleanVisitor<'a, 'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
query: &'a DepGraphQuery<DefId>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type CleanEdges = Vec<(DepNode<DefId>, DepNode<DefId>)>;
|
|||
/// early in compilation, before we've really done any work, but
|
||||
/// actually it doesn't matter all that much.) See `README.md` for
|
||||
/// more general overview.
|
||||
pub fn load_dep_graph(tcx: TyCtxt) {
|
||||
pub fn load_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
|
||||
if let Some(dep_graph) = dep_graph_path(tcx) {
|
||||
|
|
@ -47,7 +47,7 @@ pub fn load_dep_graph(tcx: TyCtxt) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load_dep_graph_if_exists(tcx: TyCtxt, path: &Path) {
|
||||
pub fn load_dep_graph_if_exists<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, path: &Path) {
|
||||
if !path.exists() {
|
||||
return;
|
||||
}
|
||||
|
|
@ -74,7 +74,9 @@ pub fn load_dep_graph_if_exists(tcx: TyCtxt, path: &Path) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn decode_dep_graph(tcx: TyCtxt, data: &[u8]) -> Result<(), Error>
|
||||
pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
data: &[u8])
|
||||
-> Result<(), Error>
|
||||
{
|
||||
// Deserialize the directory and dep-graph.
|
||||
let mut decoder = Decoder::new(data, 0);
|
||||
|
|
@ -128,10 +130,10 @@ pub fn decode_dep_graph(tcx: TyCtxt, data: &[u8]) -> Result<(), Error>
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn initial_dirty_nodes(tcx: TyCtxt,
|
||||
hashed_items: &[SerializedHash],
|
||||
retraced: &RetracedDefIdDirectory)
|
||||
-> DirtyNodes {
|
||||
fn initial_dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
hashed_items: &[SerializedHash],
|
||||
retraced: &RetracedDefIdDirectory)
|
||||
-> DirtyNodes {
|
||||
let mut items_removed = false;
|
||||
let mut dirty_nodes = FnvHashSet();
|
||||
for hashed_item in hashed_items {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use super::data::*;
|
|||
use super::directory::*;
|
||||
use super::util::*;
|
||||
|
||||
pub fn save_dep_graph(tcx: TyCtxt) {
|
||||
pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
|
||||
if let Some(dep_graph) = dep_graph_path(tcx) {
|
||||
|
|
@ -68,7 +68,9 @@ pub fn save_dep_graph(tcx: TyCtxt) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn encode_dep_graph(tcx: TyCtxt, encoder: &mut Encoder) -> io::Result<()> {
|
||||
pub fn encode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
encoder: &mut Encoder)
|
||||
-> io::Result<()> {
|
||||
// Here we take advantage of how RBML allows us to skip around
|
||||
// and encode the depgraph as a two-part structure:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -792,9 +792,9 @@ impl LateLintPass for UnconditionalRecursion {
|
|||
}
|
||||
|
||||
// Check if the expression `id` performs a call to `method`.
|
||||
fn expr_refers_to_this_method(tcx: TyCtxt,
|
||||
method: &ty::Method,
|
||||
id: ast::NodeId) -> bool {
|
||||
fn expr_refers_to_this_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
method: &ty::Method,
|
||||
id: ast::NodeId) -> bool {
|
||||
// Check for method calls and overloaded operators.
|
||||
let opt_m = tcx.tables.borrow().method_map.get(&ty::MethodCall::expr(id)).cloned();
|
||||
if let Some(m) = opt_m {
|
||||
|
|
@ -840,7 +840,7 @@ impl LateLintPass for UnconditionalRecursion {
|
|||
|
||||
// Check if the method call to the method with the ID `callee_id`
|
||||
// and instantiated with `callee_substs` refers to method `method`.
|
||||
fn method_call_refers_to_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn method_call_refers_to_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
method: &ty::Method,
|
||||
callee_id: DefId,
|
||||
callee_substs: &Substs<'tcx>,
|
||||
|
|
|
|||
|
|
@ -294,8 +294,10 @@ impl LateLintPass for TypeLimits {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_limits(tcx: TyCtxt, binop: hir::BinOp,
|
||||
l: &hir::Expr, r: &hir::Expr) -> bool {
|
||||
fn check_limits<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
binop: hir::BinOp,
|
||||
l: &hir::Expr,
|
||||
r: &hir::Expr) -> bool {
|
||||
let (lit, expr, swap) = match (&l.node, &r.node) {
|
||||
(&hir::ExprLit(_), _) => (l, r, true),
|
||||
(_, &hir::ExprLit(_)) => (r, l, false),
|
||||
|
|
@ -375,7 +377,7 @@ enum FfiResult {
|
|||
/// to function pointers and references, but could be
|
||||
/// expanded to cover NonZero raw pointers and newtypes.
|
||||
/// FIXME: This duplicates code in trans.
|
||||
fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def: ty::AdtDef<'tcx>,
|
||||
substs: &Substs<'tcx>)
|
||||
-> bool {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ use rustc_serialize::{Encodable, EncoderHelpers};
|
|||
#[cfg(test)] use rustc::hir::lowering::{lower_item, LoweringContext, DummyResolver};
|
||||
|
||||
struct DecodeContext<'a, 'b, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cdata: &'b cstore::crate_metadata,
|
||||
from_id_range: IdRange,
|
||||
to_id_range: IdRange,
|
||||
|
|
@ -123,7 +123,7 @@ impl<'a, 'b, 'c, 'tcx> ast_map::FoldOps for &'a DecodeContext<'b, 'c, 'tcx> {
|
|||
/// Decodes an item from its AST in the cdata's metadata and adds it to the
|
||||
/// ast-map.
|
||||
pub fn decode_inlined_item<'a, 'tcx>(cdata: &cstore::crate_metadata,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
parent_def_path: ast_map::DefPath,
|
||||
parent_did: DefId,
|
||||
ast_doc: rbml::Doc,
|
||||
|
|
@ -861,17 +861,17 @@ trait rbml_decoder_decoder_helpers<'tcx> {
|
|||
|
||||
// Versions of the type reading functions that don't need the full
|
||||
// DecodeContext.
|
||||
fn read_ty_nodcx<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn read_ty_nodcx<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cdata: &cstore::crate_metadata) -> Ty<'tcx>;
|
||||
fn read_tys_nodcx<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn read_tys_nodcx<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cdata: &cstore::crate_metadata) -> Vec<Ty<'tcx>>;
|
||||
fn read_substs_nodcx<'a>(&mut self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn read_substs_nodcx<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cdata: &cstore::crate_metadata)
|
||||
-> subst::Substs<'tcx>;
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
||||
fn read_ty_nodcx<'b>(&mut self, tcx: TyCtxt<'b, 'tcx>,
|
||||
fn read_ty_nodcx<'b>(&mut self, tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
cdata: &cstore::crate_metadata)
|
||||
-> Ty<'tcx> {
|
||||
self.read_opaque(|_, doc| {
|
||||
|
|
@ -882,7 +882,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
|||
}).unwrap()
|
||||
}
|
||||
|
||||
fn read_tys_nodcx<'b>(&mut self, tcx: TyCtxt<'b, 'tcx>,
|
||||
fn read_tys_nodcx<'b>(&mut self, tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
cdata: &cstore::crate_metadata) -> Vec<Ty<'tcx>> {
|
||||
self.read_to_vec(|this| Ok(this.read_ty_nodcx(tcx, cdata)) )
|
||||
.unwrap()
|
||||
|
|
@ -890,7 +890,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn read_substs_nodcx<'b>(&mut self, tcx: TyCtxt<'b, 'tcx>,
|
||||
fn read_substs_nodcx<'b>(&mut self, tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
cdata: &cstore::crate_metadata)
|
||||
-> subst::Substs<'tcx>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
decoder::closure_kind(&cdata, def_id.index)
|
||||
}
|
||||
|
||||
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx>
|
||||
fn closure_ty<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx>
|
||||
{
|
||||
assert!(!def_id.is_local());
|
||||
let cdata = self.get_crate_data(def_id.krate);
|
||||
|
|
@ -78,21 +78,21 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
decoder::get_repr_attrs(&cdata, def.index)
|
||||
}
|
||||
|
||||
fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_type<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::TypeScheme<'tcx>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_type(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_predicates(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
|
|
@ -111,13 +111,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
decoder::get_symbol(&cdata, def.index)
|
||||
}
|
||||
|
||||
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId) -> ty::TraitDef<'tcx>
|
||||
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::TraitDef<'tcx>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_trait_def(&cdata, def.index, tcx)
|
||||
}
|
||||
|
||||
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
||||
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_adt_def(&self.intr, &cdata, def.index, tcx)
|
||||
|
|
@ -155,7 +155,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
result
|
||||
}
|
||||
|
||||
fn provided_trait_methods<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn provided_trait_methods<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::Method<'tcx>>>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
|
|
@ -181,7 +181,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
decoder::get_impl_polarity(&cdata, def.index)
|
||||
}
|
||||
|
||||
fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn impl_trait_ref<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::TraitRef<'tcx>>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
|
|
@ -196,7 +196,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
}
|
||||
|
||||
// FIXME: killme
|
||||
fn associated_consts<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn associated_consts<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> {
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::get_associated_consts(self.intr.clone(), &cdata, def.index, tcx)
|
||||
|
|
@ -207,13 +207,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
decoder::get_parent_impl(&*cdata, impl_def.index)
|
||||
}
|
||||
|
||||
fn trait_of_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def_id: DefId) -> Option<DefId>
|
||||
fn trait_of_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId>
|
||||
{
|
||||
let cdata = self.get_crate_data(def_id.krate);
|
||||
decoder::get_trait_of_item(&cdata, def_id.index, tcx)
|
||||
}
|
||||
|
||||
fn impl_or_trait_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn impl_or_trait_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
|
|
@ -247,7 +247,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
decoder::is_default_impl(&cdata, impl_did.index)
|
||||
}
|
||||
|
||||
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx>, did: DefId) -> bool {
|
||||
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, did: DefId) -> bool {
|
||||
let cdata = self.get_crate_data(did.krate);
|
||||
decoder::is_extern_item(&cdata, did.index, tcx)
|
||||
}
|
||||
|
|
@ -442,14 +442,14 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
result
|
||||
}
|
||||
|
||||
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn maybe_get_item_ast<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> FoundAst<'tcx>
|
||||
{
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::maybe_get_item_ast(&cdata, tcx, def.index)
|
||||
}
|
||||
|
||||
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx>, def: DefId)
|
||||
fn maybe_get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<Mir<'tcx>> {
|
||||
let cdata = self.get_crate_data(def.krate);
|
||||
decoder::maybe_get_item_mir(&cdata, tcx, def.index)
|
||||
|
|
@ -487,9 +487,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
loader::meta_section_name(target)
|
||||
}
|
||||
fn encode_type<'a>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx>, DefId) -> String)
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String)
|
||||
-> Vec<u8>
|
||||
{
|
||||
encoder::encoded_ty(tcx, ty, def_id_to_string)
|
||||
|
|
@ -510,7 +510,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
self.do_extern_mod_stmt_cnum(emod_id)
|
||||
}
|
||||
|
||||
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx>,
|
||||
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
reexports: &def::ExportMap,
|
||||
item_symbols: &RefCell<NodeMap<String>>,
|
||||
link_meta: &LinkMeta,
|
||||
|
|
|
|||
|
|
@ -223,14 +223,15 @@ fn variant_disr_val(d: rbml::Doc) -> Option<u64> {
|
|||
})
|
||||
}
|
||||
|
||||
fn doc_type<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx>, cdata: Cmd) -> Ty<'tcx> {
|
||||
fn doc_type<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx, 'tcx>, cdata: Cmd) -> Ty<'tcx> {
|
||||
let tp = reader::get_doc(doc, tag_items_data_item_type);
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, tp,
|
||||
&mut |did| translate_def_id(cdata, did))
|
||||
.parse_ty()
|
||||
}
|
||||
|
||||
fn maybe_doc_type<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx>, cdata: Cmd) -> Option<Ty<'tcx>> {
|
||||
fn maybe_doc_type<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx, 'tcx>, cdata: Cmd)
|
||||
-> Option<Ty<'tcx>> {
|
||||
reader::maybe_get_doc(doc, tag_items_data_item_type).map(|tp| {
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, tp,
|
||||
&mut |did| translate_def_id(cdata, did))
|
||||
|
|
@ -239,18 +240,18 @@ fn maybe_doc_type<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx>, cdata: Cmd) -
|
|||
}
|
||||
|
||||
pub fn item_type<'a, 'tcx>(_item_id: DefId, item: rbml::Doc,
|
||||
tcx: TyCtxt<'a, 'tcx>, cdata: Cmd) -> Ty<'tcx> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>, cdata: Cmd) -> Ty<'tcx> {
|
||||
doc_type(item, tcx, cdata)
|
||||
}
|
||||
|
||||
fn doc_trait_ref<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx>, cdata: Cmd)
|
||||
fn doc_trait_ref<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx, 'tcx>, cdata: Cmd)
|
||||
-> ty::TraitRef<'tcx> {
|
||||
TyDecoder::with_doc(tcx, cdata.cnum, doc,
|
||||
&mut |did| translate_def_id(cdata, did))
|
||||
.parse_trait_ref()
|
||||
}
|
||||
|
||||
fn item_trait_ref<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx>, cdata: Cmd)
|
||||
fn item_trait_ref<'a, 'tcx>(doc: rbml::Doc, tcx: TyCtxt<'a, 'tcx, 'tcx>, cdata: Cmd)
|
||||
-> ty::TraitRef<'tcx> {
|
||||
let tp = reader::get_doc(doc, tag_item_trait_ref);
|
||||
doc_trait_ref(tp, tcx, cdata)
|
||||
|
|
@ -352,7 +353,7 @@ fn parse_associated_type_names(item_doc: rbml::Doc) -> Vec<ast::Name> {
|
|||
|
||||
pub fn get_trait_def<'a, 'tcx>(cdata: Cmd,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>) -> ty::TraitDef<'tcx>
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::TraitDef<'tcx>
|
||||
{
|
||||
let item_doc = cdata.lookup_item(item_id);
|
||||
let generics = doc_generics(item_doc, tcx, cdata, tag_item_generics);
|
||||
|
|
@ -370,7 +371,7 @@ pub fn get_trait_def<'a, 'tcx>(cdata: Cmd,
|
|||
pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::AdtDefMaster<'tcx>
|
||||
{
|
||||
fn expect_variant_kind(family: Family) -> ty::VariantKind {
|
||||
|
|
@ -498,7 +499,7 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
|
||||
pub fn get_predicates<'a, 'tcx>(cdata: Cmd,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::GenericPredicates<'tcx>
|
||||
{
|
||||
let item_doc = cdata.lookup_item(item_id);
|
||||
|
|
@ -507,14 +508,14 @@ pub fn get_predicates<'a, 'tcx>(cdata: Cmd,
|
|||
|
||||
pub fn get_super_predicates<'a, 'tcx>(cdata: Cmd,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::GenericPredicates<'tcx>
|
||||
{
|
||||
let item_doc = cdata.lookup_item(item_id);
|
||||
doc_predicates(item_doc, tcx, cdata, tag_item_super_predicates)
|
||||
}
|
||||
|
||||
pub fn get_type<'a, 'tcx>(cdata: Cmd, id: DefIndex, tcx: TyCtxt<'a, 'tcx>)
|
||||
pub fn get_type<'a, 'tcx>(cdata: Cmd, id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::TypeScheme<'tcx>
|
||||
{
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
|
|
@ -593,7 +594,7 @@ pub fn get_custom_coerce_unsized_kind<'tcx>(
|
|||
|
||||
pub fn get_impl_trait<'a, 'tcx>(cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Option<ty::TraitRef<'tcx>>
|
||||
{
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
|
|
@ -776,7 +777,7 @@ pub fn get_item_name(intr: &IdentInterner, cdata: Cmd, id: DefIndex) -> ast::Nam
|
|||
item_name(intr, cdata.lookup_item(id))
|
||||
}
|
||||
|
||||
pub fn maybe_get_item_ast<'a, 'tcx>(cdata: Cmd, tcx: TyCtxt<'a, 'tcx>, id: DefIndex)
|
||||
pub fn maybe_get_item_ast<'a, 'tcx>(cdata: Cmd, tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefIndex)
|
||||
-> FoundAst<'tcx> {
|
||||
debug!("Looking up item: {:?}", id);
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
|
|
@ -829,7 +830,7 @@ pub fn is_item_mir_available<'tcx>(cdata: Cmd, id: DefIndex) -> bool {
|
|||
}
|
||||
|
||||
pub fn maybe_get_item_mir<'a, 'tcx>(cdata: Cmd,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: DefIndex)
|
||||
-> Option<mir::repr::Mir<'tcx>> {
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
|
|
@ -947,7 +948,7 @@ pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool {
|
|||
pub fn get_impl_or_trait_item<'a, 'tcx>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>> {
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
|
||||
|
|
@ -1042,7 +1043,7 @@ pub fn get_item_variances(cdata: Cmd, id: DefIndex) -> ty::ItemVariances {
|
|||
pub fn get_provided_trait_methods<'a, 'tcx>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Vec<Rc<ty::Method<'tcx>>> {
|
||||
let item = cdata.lookup_item(id);
|
||||
|
||||
|
|
@ -1069,7 +1070,7 @@ pub fn get_provided_trait_methods<'a, 'tcx>(intr: Rc<IdentInterner>,
|
|||
pub fn get_associated_consts<'a, 'tcx>(intr: Rc<IdentInterner>,
|
||||
cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> {
|
||||
let item = cdata.lookup_item(id);
|
||||
|
||||
|
|
@ -1443,8 +1444,10 @@ pub fn each_implementation_for_trait<F>(cdata: Cmd,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_trait_of_item(cdata: Cmd, id: DefIndex, tcx: TyCtxt)
|
||||
-> Option<DefId> {
|
||||
pub fn get_trait_of_item<'a, 'tcx>(cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> Option<DefId> {
|
||||
let item_doc = cdata.lookup_item(id);
|
||||
let parent_item_id = match item_parent_item(cdata, item_doc) {
|
||||
None => return None,
|
||||
|
|
@ -1578,7 +1581,10 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: TyCtxt) -> bool {
|
||||
pub fn is_extern_item<'a, 'tcx>(cdata: Cmd,
|
||||
id: DefIndex,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> bool {
|
||||
let item_doc = match cdata.get_item(id) {
|
||||
Some(doc) => doc,
|
||||
None => return false,
|
||||
|
|
@ -1614,7 +1620,7 @@ pub fn is_impl(cdata: Cmd, id: DefIndex) -> bool {
|
|||
}
|
||||
|
||||
fn doc_generics<'a, 'tcx>(base_doc: rbml::Doc,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cdata: Cmd,
|
||||
tag: usize)
|
||||
-> ty::Generics<'tcx>
|
||||
|
|
@ -1663,7 +1669,7 @@ fn doc_generics<'a, 'tcx>(base_doc: rbml::Doc,
|
|||
|
||||
fn doc_predicate<'a, 'tcx>(cdata: Cmd,
|
||||
doc: rbml::Doc,
|
||||
tcx: TyCtxt<'a, 'tcx>)
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::Predicate<'tcx>
|
||||
{
|
||||
let predicate_pos = cdata.xref_index.lookup(
|
||||
|
|
@ -1675,7 +1681,7 @@ fn doc_predicate<'a, 'tcx>(cdata: Cmd,
|
|||
}
|
||||
|
||||
fn doc_predicates<'a, 'tcx>(base_doc: rbml::Doc,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cdata: Cmd,
|
||||
tag: usize)
|
||||
-> ty::GenericPredicates<'tcx>
|
||||
|
|
@ -1730,7 +1736,7 @@ pub fn closure_kind(cdata: Cmd, closure_id: DefIndex) -> ty::ClosureKind {
|
|||
ty::ClosureKind::decode(&mut decoder).unwrap()
|
||||
}
|
||||
|
||||
pub fn closure_ty<'a, 'tcx>(cdata: Cmd, closure_id: DefIndex, tcx: TyCtxt<'a, 'tcx>)
|
||||
pub fn closure_ty<'a, 'tcx>(cdata: Cmd, closure_id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> ty::ClosureTy<'tcx> {
|
||||
let closure_doc = cdata.lookup_item(closure_id);
|
||||
let closure_ty_doc = reader::get_doc(closure_doc, tag_items_closure_ty);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ use rustc::hir::map::DefKey;
|
|||
|
||||
pub struct EncodeContext<'a, 'tcx: 'a> {
|
||||
pub diag: &'a Handler,
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub reexports: &'a def::ExportMap,
|
||||
pub item_symbols: &'a RefCell<NodeMap<String>>,
|
||||
pub link_meta: &'a LinkMeta,
|
||||
|
|
@ -1697,7 +1697,7 @@ fn encode_struct_field_attrs(ecx: &EncodeContext,
|
|||
|
||||
|
||||
struct ImplVisitor<'a, 'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impls: FnvHashMap<DefId, Vec<DefId>>
|
||||
}
|
||||
|
||||
|
|
@ -2016,9 +2016,9 @@ fn encode_metadata_inner(rbml_w: &mut Encoder,
|
|||
}
|
||||
|
||||
// Get the encoded string for a type
|
||||
pub fn encoded_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn encoded_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
t: Ty<'tcx>,
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx>, DefId) -> String)
|
||||
def_id_to_string: for<'b> fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String)
|
||||
-> Vec<u8> {
|
||||
let mut wr = Cursor::new(Vec::new());
|
||||
tyencode::enc_ty(&mut wr, &tyencode::ctxt {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use tyencode;
|
|||
|
||||
impl<'a, 'tcx: 'a> tls::EncodingContext<'tcx> for encoder::EncodeContext<'a, 'tcx> {
|
||||
|
||||
fn tcx<'s>(&'s self) -> TyCtxt<'s, 'tcx> {
|
||||
fn tcx<'s>(&'s self) -> TyCtxt<'s, 'tcx, 'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
|
@ -40,12 +40,12 @@ impl<'a, 'tcx: 'a> tls::EncodingContext<'tcx> for encoder::EncodeContext<'a, 'tc
|
|||
|
||||
pub struct DecodingContext<'a, 'tcx: 'a> {
|
||||
pub crate_metadata: Cmd<'a>,
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a> tls::DecodingContext<'tcx> for DecodingContext<'a, 'tcx> {
|
||||
|
||||
fn tcx<'s>(&'s self) -> TyCtxt<'s, 'tcx> {
|
||||
fn tcx<'s>(&'s self) -> TyCtxt<'s, 'tcx, 'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ pub struct TyDecoder<'a, 'tcx: 'a> {
|
|||
data: &'a [u8],
|
||||
krate: ast::CrateNum,
|
||||
pos: usize,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
conv_def_id: DefIdConvert<'a>,
|
||||
}
|
||||
|
||||
impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||
pub fn with_doc(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn with_doc(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
crate_num: ast::CrateNum,
|
||||
doc: rbml::Doc<'a>,
|
||||
conv: DefIdConvert<'a>)
|
||||
|
|
@ -57,7 +57,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
pub fn new(data: &'a [u8],
|
||||
crate_num: ast::CrateNum,
|
||||
pos: usize,
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
conv: DefIdConvert<'a>)
|
||||
-> TyDecoder<'a, 'tcx> {
|
||||
TyDecoder {
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ use encoder;
|
|||
pub struct ctxt<'a, 'tcx: 'a> {
|
||||
pub diag: &'a Handler,
|
||||
// Def -> str Callback:
|
||||
pub ds: for<'b> fn(TyCtxt<'b, 'tcx>, DefId) -> String,
|
||||
pub ds: for<'b> fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String,
|
||||
// The type context.
|
||||
pub tcx: TyCtxt<'a, 'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub abbrevs: &'a abbrev_map<'tcx>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use syntax::codemap::Span;
|
|||
use syntax::parse::token::keywords;
|
||||
|
||||
pub struct Builder<'a, 'tcx: 'a> {
|
||||
hir: Cx<'a, 'tcx>,
|
||||
hir: Cx<'a, 'tcx, 'tcx>,
|
||||
cfg: CFG<'tcx>,
|
||||
|
||||
fn_span: Span,
|
||||
|
|
@ -160,7 +160,7 @@ macro_rules! unpack {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
/// the main entry point for building MIR for a function
|
||||
|
||||
pub fn construct_fn<'a, 'tcx, A>(hir: Cx<'a,'tcx>,
|
||||
pub fn construct_fn<'a, 'tcx, A>(hir: Cx<'a, 'tcx, 'tcx>,
|
||||
fn_id: ast::NodeId,
|
||||
arguments: A,
|
||||
return_ty: ty::FnOutput<'tcx>,
|
||||
|
|
@ -232,7 +232,7 @@ pub fn construct_fn<'a, 'tcx, A>(hir: Cx<'a,'tcx>,
|
|||
builder.finish(upvar_decls, arg_decls, return_ty)
|
||||
}
|
||||
|
||||
pub fn construct_const<'a, 'tcx>(hir: Cx<'a,'tcx>,
|
||||
pub fn construct_const<'a, 'tcx>(hir: Cx<'a, 'tcx, 'tcx>,
|
||||
item_id: ast::NodeId,
|
||||
ast_expr: &'tcx hir::Expr)
|
||||
-> (Mir<'tcx>, ScopeAuxiliaryVec) {
|
||||
|
|
@ -260,7 +260,7 @@ pub fn construct_const<'a, 'tcx>(hir: Cx<'a,'tcx>,
|
|||
}
|
||||
|
||||
impl<'a,'tcx> Builder<'a,'tcx> {
|
||||
fn new(hir: Cx<'a, 'tcx>, span: Span) -> Builder<'a, 'tcx> {
|
||||
fn new(hir: Cx<'a, 'tcx, 'tcx>, span: Span) -> Builder<'a, 'tcx> {
|
||||
let mut builder = Builder {
|
||||
hir: hir,
|
||||
cfg: CFG { basic_blocks: vec![] },
|
||||
|
|
|
|||
|
|
@ -662,7 +662,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
|
|||
block.unit()
|
||||
}
|
||||
|
||||
fn build_diverge_scope<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn build_diverge_scope<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cfg: &mut CFG<'tcx>,
|
||||
unit_temp: &Lvalue<'tcx>,
|
||||
scope: &mut Scope<'tcx>,
|
||||
|
|
@ -721,7 +721,7 @@ fn build_diverge_scope<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
target
|
||||
}
|
||||
|
||||
fn build_free<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn build_free<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
unit_temp: &Lvalue<'tcx>,
|
||||
data: &FreeData<'tcx>,
|
||||
target: BasicBlock)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use std::io::{self, Write};
|
|||
use syntax::ast::NodeId;
|
||||
|
||||
/// Write a graphviz DOT graph of a list of MIRs.
|
||||
pub fn write_mir_graphviz<'a, 'b, 'tcx, W, I>(tcx: TyCtxt<'b, 'tcx>,
|
||||
pub fn write_mir_graphviz<'a, 'b, 'tcx, W, I>(tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
iter: I, w: &mut W)
|
||||
-> io::Result<()>
|
||||
where W: Write, I: Iterator<Item=(&'a NodeId, &'a Mir<'a>)> {
|
||||
|
|
@ -118,8 +118,11 @@ fn write_edges<W: Write>(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result
|
|||
/// Write the graphviz DOT label for the overall graph. This is essentially a block of text that
|
||||
/// will appear below the graph, showing the type of the `fn` this MIR represents and the types of
|
||||
/// all the variables and temporaries.
|
||||
fn write_graph_label<W: Write>(tcx: TyCtxt, nid: NodeId, mir: &Mir, w: &mut W)
|
||||
-> io::Result<()> {
|
||||
fn write_graph_label<'a, 'tcx, W: Write>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
nid: NodeId,
|
||||
mir: &Mir,
|
||||
w: &mut W)
|
||||
-> io::Result<()> {
|
||||
write!(w, " label=<fn {}(", dot::escape_html(&tcx.node_path_str(nid)))?;
|
||||
|
||||
// fn argument types.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use syntax::ast;
|
|||
impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
|
||||
type Output = Block<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx>) -> Block<'tcx> {
|
||||
fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx, 'tcx>) -> Block<'tcx> {
|
||||
// We have to eagerly translate the "spine" of the statements
|
||||
// in order to get the lexical scoping correctly.
|
||||
let stmts = mirror_stmts(cx, self.id, &*self.stmts);
|
||||
|
|
@ -31,10 +31,10 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
|
|||
}
|
||||
}
|
||||
|
||||
fn mirror_stmts<'a,'tcx:'a>(cx: &mut Cx<'a,'tcx>,
|
||||
block_id: ast::NodeId,
|
||||
stmts: &'tcx [hir::Stmt])
|
||||
-> Vec<StmtRef<'tcx>>
|
||||
fn mirror_stmts<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
block_id: ast::NodeId,
|
||||
stmts: &'tcx [hir::Stmt])
|
||||
-> Vec<StmtRef<'tcx>>
|
||||
{
|
||||
let mut result = vec![];
|
||||
for (index, stmt) in stmts.iter().enumerate() {
|
||||
|
|
@ -74,7 +74,9 @@ fn mirror_stmts<'a,'tcx:'a>(cx: &mut Cx<'a,'tcx>,
|
|||
return result;
|
||||
}
|
||||
|
||||
pub fn to_expr_ref<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, block: &'tcx hir::Block) -> ExprRef<'tcx> {
|
||||
pub fn to_expr_ref<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
block: &'tcx hir::Block)
|
||||
-> ExprRef<'tcx> {
|
||||
let block_ty = cx.tcx.node_id_to_type(block.id);
|
||||
let temp_lifetime = cx.tcx.region_maps.temporary_scope(block.id);
|
||||
let expr = Expr {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use syntax::ptr::P;
|
|||
impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||
type Output = Expr<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx>) -> Expr<'tcx> {
|
||||
fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx, 'tcx>) -> Expr<'tcx> {
|
||||
let temp_lifetime = cx.tcx.region_maps.temporary_scope(self.id);
|
||||
let expr_extent = cx.tcx.region_maps.node_extent(self.id);
|
||||
|
||||
|
|
@ -202,7 +202,9 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
}
|
||||
}
|
||||
|
||||
fn make_mirror_unadjusted<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr) -> Expr<'tcx> {
|
||||
fn make_mirror_unadjusted<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &'tcx hir::Expr)
|
||||
-> Expr<'tcx> {
|
||||
let expr_ty = cx.tcx.expr_ty(expr);
|
||||
let temp_lifetime = cx.tcx.region_maps.temporary_scope(expr.id);
|
||||
|
||||
|
|
@ -620,10 +622,10 @@ fn make_mirror_unadjusted<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr
|
|||
}
|
||||
}
|
||||
|
||||
fn method_callee<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
||||
expr: &hir::Expr,
|
||||
method_call: ty::MethodCall)
|
||||
-> Expr<'tcx> {
|
||||
fn method_callee<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &hir::Expr,
|
||||
method_call: ty::MethodCall)
|
||||
-> Expr<'tcx> {
|
||||
let tables = cx.tcx.tables.borrow();
|
||||
let callee = &tables.method_map[&method_call];
|
||||
let temp_lifetime = cx.tcx.region_maps.temporary_scope(expr.id);
|
||||
|
|
@ -647,7 +649,8 @@ fn to_borrow_kind(m: hir::Mutability) -> BorrowKind {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_arm<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> {
|
||||
fn convert_arm<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
arm: &'tcx hir::Arm) -> Arm<'tcx> {
|
||||
let mut map;
|
||||
let opt_map = if arm.pats.len() == 1 {
|
||||
None
|
||||
|
|
@ -666,7 +669,9 @@ fn convert_arm<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, arm: &'tcx hir::Arm) -> Arm<
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_path_expr<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr) -> ExprKind<'tcx> {
|
||||
fn convert_path_expr<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &'tcx hir::Expr)
|
||||
-> ExprKind<'tcx> {
|
||||
let substs = cx.tcx.mk_substs(cx.tcx.node_id_item_substs(expr.id).substs);
|
||||
// Otherwise there may be def_map borrow conflicts
|
||||
let def = cx.tcx.def_map.borrow()[&expr.id].full_def();
|
||||
|
|
@ -738,10 +743,10 @@ fn convert_path_expr<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr)
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
||||
expr: &'tcx hir::Expr,
|
||||
def: Def)
|
||||
-> ExprKind<'tcx> {
|
||||
fn convert_var<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &'tcx hir::Expr,
|
||||
def: Def)
|
||||
-> ExprKind<'tcx> {
|
||||
let temp_lifetime = cx.tcx.region_maps.temporary_scope(expr.id);
|
||||
|
||||
match def {
|
||||
|
|
@ -903,13 +908,13 @@ enum PassArgs {
|
|||
ByRef,
|
||||
}
|
||||
|
||||
fn overloaded_operator<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
||||
expr: &'tcx hir::Expr,
|
||||
method_call: ty::MethodCall,
|
||||
pass_args: PassArgs,
|
||||
receiver: ExprRef<'tcx>,
|
||||
args: Vec<&'tcx P<hir::Expr>>)
|
||||
-> ExprKind<'tcx> {
|
||||
fn overloaded_operator<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &'tcx hir::Expr,
|
||||
method_call: ty::MethodCall,
|
||||
pass_args: PassArgs,
|
||||
receiver: ExprRef<'tcx>,
|
||||
args: Vec<&'tcx P<hir::Expr>>)
|
||||
-> ExprKind<'tcx> {
|
||||
// the receiver has all the adjustments that are needed, so we can
|
||||
// just push a reference to it
|
||||
let mut argrefs = vec![receiver];
|
||||
|
|
@ -954,13 +959,13 @@ fn overloaded_operator<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
fn overloaded_lvalue<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
||||
expr: &'tcx hir::Expr,
|
||||
method_call: ty::MethodCall,
|
||||
pass_args: PassArgs,
|
||||
receiver: ExprRef<'tcx>,
|
||||
args: Vec<&'tcx P<hir::Expr>>)
|
||||
-> ExprKind<'tcx> {
|
||||
fn overloaded_lvalue<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &'tcx hir::Expr,
|
||||
method_call: ty::MethodCall,
|
||||
pass_args: PassArgs,
|
||||
receiver: ExprRef<'tcx>,
|
||||
args: Vec<&'tcx P<hir::Expr>>)
|
||||
-> ExprKind<'tcx> {
|
||||
// For an overloaded *x or x[y] expression of type T, the method
|
||||
// call returns an &T and we must add the deref so that the types
|
||||
// line up (this is because `*x` and `x[y]` represent lvalues):
|
||||
|
|
@ -989,11 +994,11 @@ fn overloaded_lvalue<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
|||
ExprKind::Deref { arg: ref_expr.to_ref() }
|
||||
}
|
||||
|
||||
fn capture_freevar<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
||||
closure_expr: &'tcx hir::Expr,
|
||||
freevar: &hir::Freevar,
|
||||
freevar_ty: Ty<'tcx>)
|
||||
-> ExprRef<'tcx> {
|
||||
fn capture_freevar<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
closure_expr: &'tcx hir::Expr,
|
||||
freevar: &hir::Freevar,
|
||||
freevar_ty: Ty<'tcx>)
|
||||
-> ExprRef<'tcx> {
|
||||
let id_var = freevar.def.var_id();
|
||||
let upvar_id = ty::UpvarId {
|
||||
var_id: id_var,
|
||||
|
|
@ -1030,7 +1035,8 @@ fn capture_freevar<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
fn loop_label<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr) -> CodeExtent {
|
||||
fn loop_label<'a, 'tcx>(cx: &mut Cx<'a, 'tcx, 'tcx>,
|
||||
expr: &'tcx hir::Expr) -> CodeExtent {
|
||||
match cx.tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def()) {
|
||||
Some(Def::Label(loop_id)) => cx.tcx.region_maps.node_extent(loop_id),
|
||||
d => {
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ use rustc::hir;
|
|||
use rustc_const_math::{ConstInt, ConstUsize};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Cx<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
pub struct Cx<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
constness: hir::Constness
|
||||
}
|
||||
|
||||
impl<'a,'tcx> Cx<'a,'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
impl<'a, 'tcx> Cx<'a, 'tcx, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'tcx, 'tcx>,
|
||||
constness: hir::Constness)
|
||||
-> Cx<'a, 'tcx> {
|
||||
-> Cx<'a, 'tcx, 'tcx> {
|
||||
Cx {
|
||||
tcx: infcx.tcx,
|
||||
infcx: infcx,
|
||||
|
|
@ -47,7 +47,7 @@ impl<'a,'tcx> Cx<'a,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a,'tcx:'a> Cx<'a, 'tcx> {
|
||||
impl<'a, 'tcx: 'a> Cx<'a, 'tcx, 'tcx> {
|
||||
/// Normalizes `ast` into the appropriate `mirror` type.
|
||||
pub fn mirror<M: Mirror<'tcx>>(&mut self, ast: M) -> M::Output {
|
||||
ast.make_mirror(self)
|
||||
|
|
@ -144,7 +144,7 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> {
|
|||
self.tcx.type_needs_drop_given_env(ty, &self.infcx.parameter_environment)
|
||||
}
|
||||
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ use syntax::ptr::P;
|
|||
/// }
|
||||
/// ```
|
||||
struct PatCx<'patcx, 'cx: 'patcx, 'tcx: 'cx> {
|
||||
cx: &'patcx mut Cx<'cx, 'tcx>,
|
||||
cx: &'patcx mut Cx<'cx, 'tcx, 'tcx>,
|
||||
binding_map: Option<&'patcx FnvHashMap<ast::Name, ast::NodeId>>,
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> Cx<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx> Cx<'cx, 'tcx, 'tcx> {
|
||||
pub fn irrefutable_pat(&mut self, pat: &hir::Pat) -> Pattern<'tcx> {
|
||||
PatCx::new(self, None).to_pattern(pat)
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ impl<'cx, 'tcx> Cx<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
||||
fn new(cx: &'patcx mut Cx<'cx, 'tcx>,
|
||||
fn new(cx: &'patcx mut Cx<'cx, 'tcx, 'tcx>,
|
||||
binding_map: Option<&'patcx FnvHashMap<ast::Name, ast::NodeId>>)
|
||||
-> PatCx<'patcx, 'cx, 'tcx> {
|
||||
PatCx {
|
||||
|
|
|
|||
|
|
@ -358,13 +358,13 @@ pub struct FieldPattern<'tcx> {
|
|||
pub trait Mirror<'tcx> {
|
||||
type Output;
|
||||
|
||||
fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx>) -> Self::Output;
|
||||
fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx, 'tcx>) -> Self::Output;
|
||||
}
|
||||
|
||||
impl<'tcx> Mirror<'tcx> for Expr<'tcx> {
|
||||
type Output = Expr<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx>) -> Expr<'tcx> {
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx, 'tcx>) -> Expr<'tcx> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ impl<'tcx> Mirror<'tcx> for Expr<'tcx> {
|
|||
impl<'tcx> Mirror<'tcx> for ExprRef<'tcx> {
|
||||
type Output = Expr<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, hir: &mut Cx<'a, 'tcx>) -> Expr<'tcx> {
|
||||
fn make_mirror<'a>(self, hir: &mut Cx<'a, 'tcx, 'tcx>) -> Expr<'tcx> {
|
||||
match self {
|
||||
ExprRef::Hair(h) => h.make_mirror(hir),
|
||||
ExprRef::Mirror(m) => *m,
|
||||
|
|
@ -383,7 +383,7 @@ impl<'tcx> Mirror<'tcx> for ExprRef<'tcx> {
|
|||
impl<'tcx> Mirror<'tcx> for Stmt<'tcx> {
|
||||
type Output = Stmt<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx>) -> Stmt<'tcx> {
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx, 'tcx>) -> Stmt<'tcx> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
@ -391,7 +391,7 @@ impl<'tcx> Mirror<'tcx> for Stmt<'tcx> {
|
|||
impl<'tcx> Mirror<'tcx> for StmtRef<'tcx> {
|
||||
type Output = Stmt<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a,'tcx>) -> Stmt<'tcx> {
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx, 'tcx>) -> Stmt<'tcx> {
|
||||
match self {
|
||||
StmtRef::Mirror(m) => *m,
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ impl<'tcx> Mirror<'tcx> for StmtRef<'tcx> {
|
|||
impl<'tcx> Mirror<'tcx> for Block<'tcx> {
|
||||
type Output = Block<'tcx>;
|
||||
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx>) -> Block<'tcx> {
|
||||
fn make_mirror<'a>(self, _: &mut Cx<'a, 'tcx, 'tcx>) -> Block<'tcx> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use rustc::hir::map::blocks::FnLikeNode;
|
|||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
||||
pub fn build_mir_for_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>) -> MirMap<'tcx> {
|
||||
pub fn build_mir_for_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> MirMap<'tcx> {
|
||||
let mut map = MirMap {
|
||||
map: NodeMap(),
|
||||
};
|
||||
|
|
@ -52,13 +52,13 @@ pub fn build_mir_for_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>) -> MirMap<'tcx> {
|
|||
// BuildMir -- walks a crate, looking for fn items and methods to build MIR from
|
||||
|
||||
struct BuildMir<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
map: &'a mut MirMap<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> BuildMir<'a, 'tcx> {
|
||||
fn build<F>(&mut self, src: MirSource, f: F)
|
||||
where F: for<'b> FnOnce(Cx<'b, 'tcx>) -> (Mir<'tcx>, build::ScopeAuxiliaryVec)
|
||||
where F: for<'b> FnOnce(Cx<'b, 'tcx, 'tcx>) -> (Mir<'tcx>, build::ScopeAuxiliaryVec)
|
||||
{
|
||||
let constness = match src {
|
||||
MirSource::Const(_) |
|
||||
|
|
@ -202,7 +202,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
closure_expr_id: ast::NodeId,
|
||||
body_id: ast::NodeId)
|
||||
-> Ty<'tcx> {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const INDENT: &'static str = " ";
|
|||
/// - `substring1&substring2,...` -- `&`-separated list of substrings
|
||||
/// that can appear in the pass-name or the `item_path_str` for the given
|
||||
/// node-id. If any one of the substrings match, the data is dumped out.
|
||||
pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pass_name: &str,
|
||||
disambiguator: &Display,
|
||||
src: MirSource,
|
||||
|
|
@ -73,7 +73,7 @@ pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
/// Write out a human-readable textual representation for the given MIR.
|
||||
pub fn write_mir_pretty<'a, 'b, 'tcx, I>(tcx: TyCtxt<'b, 'tcx>,
|
||||
pub fn write_mir_pretty<'a, 'b, 'tcx, I>(tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
iter: I,
|
||||
w: &mut Write)
|
||||
-> io::Result<()>
|
||||
|
|
@ -95,7 +95,7 @@ enum Annotation {
|
|||
ExitScope(ScopeId),
|
||||
}
|
||||
|
||||
pub fn write_mir_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx>,
|
||||
pub fn write_mir_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
src: MirSource,
|
||||
mir: &Mir<'tcx>,
|
||||
w: &mut Write,
|
||||
|
|
@ -219,8 +219,11 @@ fn write_scope_tree(tcx: TyCtxt,
|
|||
|
||||
/// Write out a human-readable textual representation of the MIR's `fn` type and the types of its
|
||||
/// local variables (both user-defined bindings and compiler temporaries).
|
||||
fn write_mir_intro(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut Write)
|
||||
-> io::Result<()> {
|
||||
fn write_mir_intro<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
src: MirSource,
|
||||
mir: &Mir,
|
||||
w: &mut Write)
|
||||
-> io::Result<()> {
|
||||
match src {
|
||||
MirSource::Fn(_) => write!(w, "fn")?,
|
||||
MirSource::Const(_) => write!(w, "const")?,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue