De-@ ty::ctxt usage.
This commit is contained in:
parent
4fae06824c
commit
9b1fee898f
68 changed files with 741 additions and 756 deletions
|
@ -534,7 +534,7 @@ fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
|
|||
|
||||
|
||||
// This calculates STH for a symbol, as defined above
|
||||
fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &mut Sha256,
|
||||
fn symbol_hash(tcx: &ty::ctxt, symbol_hasher: &mut Sha256,
|
||||
t: ty::t, link_meta: &LinkMeta) -> ~str {
|
||||
// NB: do *not* use abbrevs here as we want the symbol names
|
||||
// to be independent of one another in the crate.
|
||||
|
|
|
@ -327,60 +327,60 @@ pub fn phase_3_run_analysis_passes(sess: Session,
|
|||
freevars, region_map, lang_items);
|
||||
|
||||
// passes are timed inside typeck
|
||||
let (method_map, vtable_map) = typeck::check_crate(ty_cx, trait_map, krate);
|
||||
let (method_map, vtable_map) = typeck::check_crate(&ty_cx, trait_map, krate);
|
||||
|
||||
time(time_passes, "check static items", (), |_|
|
||||
middle::check_static::check_crate(ty_cx, krate));
|
||||
middle::check_static::check_crate(&ty_cx, krate));
|
||||
|
||||
// These next two const passes can probably be merged
|
||||
time(time_passes, "const marking", (), |_|
|
||||
middle::const_eval::process_crate(krate, ty_cx));
|
||||
middle::const_eval::process_crate(krate, &ty_cx));
|
||||
|
||||
time(time_passes, "const checking", (), |_|
|
||||
middle::check_const::check_crate(krate, def_map, method_map, ty_cx));
|
||||
middle::check_const::check_crate(krate, def_map, method_map, &ty_cx));
|
||||
|
||||
let maps = (external_exports, last_private_map);
|
||||
let (exported_items, public_items) =
|
||||
time(time_passes, "privacy checking", maps, |(a, b)|
|
||||
middle::privacy::check_crate(ty_cx, &method_map, &exp_map2,
|
||||
middle::privacy::check_crate(&ty_cx, &method_map, &exp_map2,
|
||||
a, b, krate));
|
||||
|
||||
time(time_passes, "effect checking", (), |_|
|
||||
middle::effect::check_crate(ty_cx, method_map, krate));
|
||||
middle::effect::check_crate(&ty_cx, method_map, krate));
|
||||
|
||||
time(time_passes, "loop checking", (), |_|
|
||||
middle::check_loop::check_crate(ty_cx, krate));
|
||||
middle::check_loop::check_crate(&ty_cx, krate));
|
||||
|
||||
let middle::moves::MoveMaps {moves_map, moved_variables_set,
|
||||
capture_map} =
|
||||
time(time_passes, "compute moves", (), |_|
|
||||
middle::moves::compute_moves(ty_cx, method_map, krate));
|
||||
middle::moves::compute_moves(&ty_cx, method_map, krate));
|
||||
|
||||
time(time_passes, "match checking", (), |_|
|
||||
middle::check_match::check_crate(ty_cx, method_map,
|
||||
middle::check_match::check_crate(&ty_cx, method_map,
|
||||
moves_map, krate));
|
||||
|
||||
time(time_passes, "liveness checking", (), |_|
|
||||
middle::liveness::check_crate(ty_cx, method_map,
|
||||
middle::liveness::check_crate(&ty_cx, method_map,
|
||||
capture_map, krate));
|
||||
|
||||
let root_map =
|
||||
time(time_passes, "borrow checking", (), |_|
|
||||
middle::borrowck::check_crate(ty_cx, method_map,
|
||||
middle::borrowck::check_crate(&ty_cx, method_map,
|
||||
moves_map, moved_variables_set,
|
||||
capture_map, krate));
|
||||
|
||||
time(time_passes, "kind checking", (), |_|
|
||||
kind::check_crate(ty_cx, method_map, krate));
|
||||
kind::check_crate(&ty_cx, method_map, krate));
|
||||
|
||||
let reachable_map =
|
||||
time(time_passes, "reachability checking", (), |_|
|
||||
reachable::find_reachable(ty_cx, method_map, &exported_items));
|
||||
reachable::find_reachable(&ty_cx, method_map, &exported_items));
|
||||
|
||||
{
|
||||
let reachable_map = reachable_map.borrow();
|
||||
time(time_passes, "death checking", (), |_| {
|
||||
middle::dead::check_crate(ty_cx,
|
||||
middle::dead::check_crate(&ty_cx,
|
||||
method_map,
|
||||
&exported_items,
|
||||
reachable_map.get(),
|
||||
|
@ -389,7 +389,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
|
|||
}
|
||||
|
||||
time(time_passes, "lint checking", (), |_|
|
||||
lint::check_crate(ty_cx, method_map, &exported_items, krate));
|
||||
lint::check_crate(&ty_cx, method_map, &exported_items, krate));
|
||||
|
||||
CrateAnalysis {
|
||||
exp_map2: exp_map2,
|
||||
|
@ -640,7 +640,7 @@ impl pprust::PpAnn for TypedAnnotation {
|
|||
}
|
||||
}
|
||||
fn post(&self, node: pprust::AnnNode) -> io::IoResult<()> {
|
||||
let tcx = self.analysis.ty_cx;
|
||||
let tcx = &self.analysis.ty_cx;
|
||||
match node {
|
||||
pprust::NodeExpr(s, expr) => {
|
||||
try!(pp::space(&mut s.s));
|
||||
|
|
|
@ -87,7 +87,7 @@ pub fn each_top_level_item_of_crate(cstore: @cstore::CStore,
|
|||
callback)
|
||||
}
|
||||
|
||||
pub fn get_item_path(tcx: ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem> {
|
||||
pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem> {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
let path = decoder::get_item_path(cdata, def.node);
|
||||
|
@ -107,7 +107,7 @@ pub enum found_ast {
|
|||
// Finds the AST for this item in the crate metadata, if any. If the item was
|
||||
// not marked for inlining, then the AST will not be present and hence none
|
||||
// will be returned.
|
||||
pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::DefId,
|
||||
pub fn maybe_get_item_ast(tcx: &ty::ctxt, def: ast::DefId,
|
||||
decode_inlined_item: decoder::DecodeInlinedItem)
|
||||
-> found_ast {
|
||||
let cstore = tcx.cstore;
|
||||
|
@ -115,7 +115,7 @@ pub fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::DefId,
|
|||
decoder::maybe_get_item_ast(cdata, tcx, def.node, decode_inlined_item)
|
||||
}
|
||||
|
||||
pub fn get_enum_variants(tcx: ty::ctxt, def: ast::DefId)
|
||||
pub fn get_enum_variants(tcx: &ty::ctxt, def: ast::DefId)
|
||||
-> Vec<@ty::VariantInfo> {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
|
@ -123,13 +123,13 @@ pub fn get_enum_variants(tcx: ty::ctxt, def: ast::DefId)
|
|||
}
|
||||
|
||||
/// Returns information about the given implementation.
|
||||
pub fn get_impl(tcx: ty::ctxt, impl_def_id: ast::DefId)
|
||||
pub fn get_impl(tcx: &ty::ctxt, impl_def_id: ast::DefId)
|
||||
-> ty::Impl {
|
||||
let cdata = tcx.cstore.get_crate_data(impl_def_id.krate);
|
||||
decoder::get_impl(tcx.cstore.intr, cdata, impl_def_id.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_method(tcx: ty::ctxt, def: ast::DefId) -> ty::Method {
|
||||
pub fn get_method(tcx: &ty::ctxt, def: ast::DefId) -> ty::Method {
|
||||
let cdata = tcx.cstore.get_crate_data(def.krate);
|
||||
decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ pub fn get_item_variances(cstore: @cstore::CStore,
|
|||
decoder::get_item_variances(cdata, def.node)
|
||||
}
|
||||
|
||||
pub fn get_provided_trait_methods(tcx: ty::ctxt,
|
||||
pub fn get_provided_trait_methods(tcx: &ty::ctxt,
|
||||
def: ast::DefId)
|
||||
-> Vec<@ty::Method> {
|
||||
let cstore = tcx.cstore;
|
||||
|
@ -162,7 +162,7 @@ pub fn get_provided_trait_methods(tcx: ty::ctxt,
|
|||
decoder::get_provided_trait_methods(cstore.intr, cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_supertraits(tcx: ty::ctxt, def: ast::DefId) -> Vec<@ty::TraitRef> {
|
||||
pub fn get_supertraits(tcx: &ty::ctxt, def: ast::DefId) -> Vec<@ty::TraitRef> {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
decoder::get_supertraits(cdata, def.node, tcx)
|
||||
|
@ -195,7 +195,7 @@ pub fn get_struct_fields(cstore: @cstore::CStore,
|
|||
decoder::get_struct_fields(cstore.intr, cdata, def.node)
|
||||
}
|
||||
|
||||
pub fn get_type(tcx: ty::ctxt,
|
||||
pub fn get_type(tcx: &ty::ctxt,
|
||||
def: ast::DefId)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
let cstore = tcx.cstore;
|
||||
|
@ -203,13 +203,13 @@ pub fn get_type(tcx: ty::ctxt,
|
|||
decoder::get_type(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_trait_def(tcx: ty::ctxt, def: ast::DefId) -> ty::TraitDef {
|
||||
pub fn get_trait_def(tcx: &ty::ctxt, def: ast::DefId) -> ty::TraitDef {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
decoder::get_trait_def(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_field_type(tcx: ty::ctxt, class_id: ast::DefId,
|
||||
pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
|
||||
def: ast::DefId) -> ty::ty_param_bounds_and_ty {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(class_id.krate);
|
||||
|
@ -232,7 +232,7 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::DefId,
|
|||
|
||||
// Given a def_id for an impl, return the trait it implements,
|
||||
// if there is one.
|
||||
pub fn get_impl_trait(tcx: ty::ctxt,
|
||||
pub fn get_impl_trait(tcx: &ty::ctxt,
|
||||
def: ast::DefId) -> Option<@ty::TraitRef> {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
|
@ -240,7 +240,7 @@ pub fn get_impl_trait(tcx: ty::ctxt,
|
|||
}
|
||||
|
||||
// Given a def_id for an impl, return information about its vtables
|
||||
pub fn get_impl_vtables(tcx: ty::ctxt,
|
||||
pub fn get_impl_vtables(tcx: &ty::ctxt,
|
||||
def: ast::DefId) -> typeck::impl_res {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
|
@ -295,7 +295,7 @@ pub fn each_implementation_for_trait(cstore: @cstore::CStore,
|
|||
/// the trait that the method belongs to. Otherwise, returns `None`.
|
||||
pub fn get_trait_of_method(cstore: @cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
tcx: ty::ctxt)
|
||||
tcx: &ty::ctxt)
|
||||
-> Option<ast::DefId> {
|
||||
let cdata = cstore.get_crate_data(def_id.krate);
|
||||
decoder::get_trait_of_method(cdata, def_id.node, tcx)
|
||||
|
|
|
@ -219,35 +219,35 @@ fn variant_disr_val(d: ebml::Doc) -> Option<ty::Disr> {
|
|||
})
|
||||
}
|
||||
|
||||
fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::t {
|
||||
fn doc_type(doc: ebml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::t {
|
||||
let tp = reader::get_doc(doc, tag_items_data_item_type);
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
|
||||
fn doc_method_fty(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::BareFnTy {
|
||||
fn doc_method_fty(doc: ebml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::BareFnTy {
|
||||
let tp = reader::get_doc(doc, tag_item_method_fty);
|
||||
parse_bare_fn_ty_data(tp.data, cdata.cnum, tp.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
|
||||
pub fn item_type(_item_id: ast::DefId, item: ebml::Doc,
|
||||
tcx: ty::ctxt, cdata: Cmd) -> ty::t {
|
||||
tcx: &ty::ctxt, cdata: Cmd) -> ty::t {
|
||||
doc_type(item, tcx, cdata)
|
||||
}
|
||||
|
||||
fn doc_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::TraitRef {
|
||||
fn doc_trait_ref(doc: ebml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::TraitRef {
|
||||
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
|
||||
|_, did| translate_def_id(cdata, did))
|
||||
}
|
||||
|
||||
fn item_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: Cmd) -> ty::TraitRef {
|
||||
fn item_trait_ref(doc: ebml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::TraitRef {
|
||||
let tp = reader::get_doc(doc, tag_item_trait_ref);
|
||||
doc_trait_ref(tp, tcx, cdata)
|
||||
}
|
||||
|
||||
fn item_ty_param_defs(item: ebml::Doc,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
cdata: Cmd,
|
||||
tag: uint)
|
||||
-> Rc<Vec<ty::TypeParameterDef> > {
|
||||
|
@ -378,7 +378,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
|
|||
|
||||
pub fn get_trait_def(cdata: Cmd,
|
||||
item_id: ast::NodeId,
|
||||
tcx: ty::ctxt) -> ty::TraitDef
|
||||
tcx: &ty::ctxt) -> ty::TraitDef
|
||||
{
|
||||
let item_doc = lookup_item(item_id, cdata.data());
|
||||
let tp_defs = item_ty_param_defs(item_doc, tcx, cdata,
|
||||
|
@ -403,7 +403,7 @@ pub fn get_trait_def(cdata: Cmd,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
|
||||
pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
|
||||
let item = lookup_item(id, cdata.data());
|
||||
|
@ -427,7 +427,7 @@ pub fn get_type_param_count(data: &[u8], id: ast::NodeId) -> uint {
|
|||
|
||||
pub fn get_impl_trait(cdata: Cmd,
|
||||
id: ast::NodeId,
|
||||
tcx: ty::ctxt) -> Option<@ty::TraitRef>
|
||||
tcx: &ty::ctxt) -> Option<@ty::TraitRef>
|
||||
{
|
||||
let item_doc = lookup_item(id, cdata.data());
|
||||
reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| {
|
||||
|
@ -437,7 +437,7 @@ pub fn get_impl_trait(cdata: Cmd,
|
|||
|
||||
pub fn get_impl_vtables(cdata: Cmd,
|
||||
id: ast::NodeId,
|
||||
tcx: ty::ctxt) -> typeck::impl_res
|
||||
tcx: &ty::ctxt) -> typeck::impl_res
|
||||
{
|
||||
let item_doc = lookup_item(id, cdata.data());
|
||||
let vtables_doc = reader::get_doc(item_doc, tag_item_impl_vtables);
|
||||
|
@ -672,12 +672,12 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> Vec<ast_map::PathElem> {
|
|||
}
|
||||
|
||||
pub type DecodeInlinedItem<'a> = 'a |cdata: @cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
path: Vec<ast_map::PathElem>,
|
||||
par_doc: ebml::Doc|
|
||||
-> Result<ast::InlinedItem, Vec<ast_map::PathElem> >;
|
||||
|
||||
pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, id: ast::NodeId,
|
||||
pub fn maybe_get_item_ast(cdata: Cmd, tcx: &ty::ctxt, id: ast::NodeId,
|
||||
decode_inlined_item: DecodeInlinedItem)
|
||||
-> csearch::found_ast {
|
||||
debug!("Looking up item: {}", id);
|
||||
|
@ -702,7 +702,7 @@ pub fn maybe_get_item_ast(cdata: Cmd, tcx: ty::ctxt, id: ast::NodeId,
|
|||
}
|
||||
|
||||
pub fn get_enum_variants(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId,
|
||||
tcx: ty::ctxt) -> Vec<@ty::VariantInfo> {
|
||||
tcx: &ty::ctxt) -> Vec<@ty::VariantInfo> {
|
||||
let data = cdata.data();
|
||||
let items = reader::get_doc(reader::Doc(data), tag_items);
|
||||
let item = find_item(id, items);
|
||||
|
@ -761,7 +761,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::ExplicitSelf_ {
|
|||
}
|
||||
|
||||
fn item_impl_methods(intr: @IdentInterner, cdata: Cmd, item: ebml::Doc,
|
||||
tcx: ty::ctxt) -> Vec<@ty::Method> {
|
||||
tcx: &ty::ctxt) -> Vec<@ty::Method> {
|
||||
let mut rslt = Vec::new();
|
||||
reader::tagged_docs(item, tag_item_impl_method, |doc| {
|
||||
let m_did = reader::with_doc_data(doc, parse_def_id);
|
||||
|
@ -774,7 +774,7 @@ fn item_impl_methods(intr: @IdentInterner, cdata: Cmd, item: ebml::Doc,
|
|||
|
||||
/// Returns information about the given implementation.
|
||||
pub fn get_impl(intr: @IdentInterner, cdata: Cmd, impl_id: ast::NodeId,
|
||||
tcx: ty::ctxt)
|
||||
tcx: &ty::ctxt)
|
||||
-> ty::Impl {
|
||||
let data = cdata.data();
|
||||
let impl_item = lookup_item(impl_id, data);
|
||||
|
@ -800,7 +800,7 @@ pub fn get_method_name_and_explicit_self(
|
|||
}
|
||||
|
||||
pub fn get_method(intr: @IdentInterner, cdata: Cmd, id: ast::NodeId,
|
||||
tcx: ty::ctxt) -> ty::Method
|
||||
tcx: &ty::ctxt) -> ty::Method
|
||||
{
|
||||
let method_doc = lookup_item(id, cdata.data());
|
||||
let def_id = item_def_id(method_doc, cdata);
|
||||
|
@ -858,7 +858,7 @@ pub fn get_item_variances(cdata: Cmd, id: ast::NodeId) -> ty::ItemVariances {
|
|||
}
|
||||
|
||||
pub fn get_provided_trait_methods(intr: @IdentInterner, cdata: Cmd,
|
||||
id: ast::NodeId, tcx: ty::ctxt) ->
|
||||
id: ast::NodeId, tcx: &ty::ctxt) ->
|
||||
Vec<@ty::Method> {
|
||||
let data = cdata.data();
|
||||
let item = lookup_item(id, data);
|
||||
|
@ -878,7 +878,7 @@ pub fn get_provided_trait_methods(intr: @IdentInterner, cdata: Cmd,
|
|||
}
|
||||
|
||||
/// Returns the supertraits of the given trait.
|
||||
pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
|
||||
pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
|
||||
-> Vec<@ty::TraitRef> {
|
||||
let mut results = Vec::new();
|
||||
let item_doc = lookup_item(id, cdata.data());
|
||||
|
@ -1235,7 +1235,7 @@ pub fn each_implementation_for_trait(cdata: Cmd,
|
|||
});
|
||||
}
|
||||
|
||||
pub fn get_trait_of_method(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
|
||||
pub fn get_trait_of_method(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
|
||||
-> Option<ast::DefId> {
|
||||
let item_doc = lookup_item(id, cdata.data());
|
||||
let parent_item_id = match item_parent_item(item_doc) {
|
||||
|
|
|
@ -69,7 +69,7 @@ pub type EncodeInlinedItem<'a> = 'a |ecx: &EncodeContext,
|
|||
|
||||
pub struct EncodeParams<'a> {
|
||||
diag: @SpanHandler,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
reexports2: middle::resolve::ExportMap2,
|
||||
item_symbols: &'a RefCell<NodeMap<~str>>,
|
||||
non_inlineable_statics: &'a RefCell<NodeSet>,
|
||||
|
@ -96,7 +96,7 @@ pub struct Stats {
|
|||
|
||||
pub struct EncodeContext<'a> {
|
||||
diag: @SpanHandler,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
stats: @Stats,
|
||||
reexports2: middle::resolve::ExportMap2,
|
||||
item_symbols: &'a RefCell<NodeMap<~str>>,
|
||||
|
@ -1899,7 +1899,7 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
|
|||
}
|
||||
|
||||
// Get the encoded string for a type
|
||||
pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str {
|
||||
pub fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> ~str {
|
||||
let cx = @tyencode::ctxt {
|
||||
diag: tcx.diag,
|
||||
ds: def_to_str,
|
||||
|
|
|
@ -62,7 +62,7 @@ pub struct PState<'a> {
|
|||
data: &'a [u8],
|
||||
krate: ast::CrateNum,
|
||||
pos: uint,
|
||||
tcx: ty::ctxt
|
||||
tcx: &'a ty::ctxt
|
||||
}
|
||||
|
||||
fn peek(st: &PState) -> char {
|
||||
|
@ -105,7 +105,7 @@ fn parse_ident_(st: &mut PState, is_last: |char| -> bool) -> ast::Ident {
|
|||
}
|
||||
|
||||
pub fn parse_state_from_data<'a>(data: &'a [u8], crate_num: ast::CrateNum,
|
||||
pos: uint, tcx: ty::ctxt) -> PState<'a> {
|
||||
pos: uint, tcx: &'a ty::ctxt) -> PState<'a> {
|
||||
PState {
|
||||
data: data,
|
||||
krate: crate_num,
|
||||
|
@ -114,25 +114,25 @@ pub fn parse_state_from_data<'a>(data: &'a [u8], crate_num: ast::CrateNum,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
|
||||
conv: conv_did) -> ty::t {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_ty(&mut st, conv)
|
||||
}
|
||||
|
||||
pub fn parse_bare_fn_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_bare_fn_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
|
||||
conv: conv_did) -> ty::BareFnTy {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_bare_fn_ty(&mut st, conv)
|
||||
}
|
||||
|
||||
pub fn parse_trait_ref_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_trait_ref_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
|
||||
conv: conv_did) -> ty::TraitRef {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_trait_ref(&mut st, conv)
|
||||
}
|
||||
|
||||
pub fn parse_substs_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
|
||||
pub fn parse_substs_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: &ty::ctxt,
|
||||
conv: conv_did) -> ty::substs {
|
||||
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
|
||||
parse_substs(&mut st, conv)
|
||||
|
@ -565,7 +565,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
|
|||
}
|
||||
|
||||
pub fn parse_type_param_def_data(data: &[u8], start: uint,
|
||||
crate_num: ast::CrateNum, tcx: ty::ctxt,
|
||||
crate_num: ast::CrateNum, tcx: &ty::ctxt,
|
||||
conv: conv_did) -> ty::TypeParameterDef
|
||||
{
|
||||
let mut st = parse_state_from_data(data, crate_num, start, tcx);
|
||||
|
|
|
@ -35,12 +35,12 @@ macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
|
|||
format_args!(|a| { mywrite($wr, a) }, $($arg)*)
|
||||
) )
|
||||
|
||||
pub struct ctxt {
|
||||
pub struct ctxt<'a> {
|
||||
diag: @SpanHandler,
|
||||
// Def -> str Callback:
|
||||
ds: extern "Rust" fn(DefId) -> ~str,
|
||||
// The type context.
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
abbrevs: abbrev_ctxt
|
||||
}
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ pub struct Maps {
|
|||
capture_map: middle::moves::CaptureMap,
|
||||
}
|
||||
|
||||
struct DecodeContext {
|
||||
struct DecodeContext<'a> {
|
||||
cdata: @cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
maps: Maps
|
||||
}
|
||||
|
||||
struct ExtendedDecodeContext {
|
||||
dcx: @DecodeContext,
|
||||
struct ExtendedDecodeContext<'a> {
|
||||
dcx: @DecodeContext<'a>,
|
||||
from_id_range: ast_util::IdRange,
|
||||
to_id_range: ast_util::IdRange
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ pub fn encode_exported_macro(ebml_w: &mut writer::Encoder, i: &ast::Item) {
|
|||
}
|
||||
|
||||
pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
maps: Maps,
|
||||
path: Vec<ast_map::PathElem> ,
|
||||
par_doc: ebml::Doc)
|
||||
|
@ -188,7 +188,7 @@ fn reserve_id_range(sess: &Session,
|
|||
ast_util::IdRange { min: to_id_min, max: to_id_max }
|
||||
}
|
||||
|
||||
impl ExtendedDecodeContext {
|
||||
impl<'a> ExtendedDecodeContext<'a> {
|
||||
pub fn tr_id(&self, id: ast::NodeId) -> ast::NodeId {
|
||||
/*!
|
||||
* Translates an internal id, meaning a node id that is known
|
||||
|
@ -375,11 +375,11 @@ fn decode_ast(par_doc: ebml::Doc) -> ast::InlinedItem {
|
|||
Decodable::decode(&mut d)
|
||||
}
|
||||
|
||||
struct AstRenumberer {
|
||||
xcx: @ExtendedDecodeContext,
|
||||
struct AstRenumberer<'a> {
|
||||
xcx: @ExtendedDecodeContext<'a>,
|
||||
}
|
||||
|
||||
impl ast_map::FoldOps for AstRenumberer {
|
||||
impl<'a> ast_map::FoldOps for AstRenumberer<'a> {
|
||||
fn new_id(&self, id: ast::NodeId) -> ast::NodeId {
|
||||
if id == ast::DUMMY_NODE_ID {
|
||||
// Used by ast_map to map the NodeInlinedParent.
|
||||
|
@ -702,19 +702,19 @@ pub fn encode_vtable_origin(ecx: &e::EncodeContext,
|
|||
|
||||
pub trait vtable_decoder_helpers {
|
||||
fn read_vtable_res(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
-> typeck::vtable_res;
|
||||
fn read_vtable_param_res(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
-> typeck::vtable_param_res;
|
||||
fn read_vtable_origin(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
-> typeck::vtable_origin;
|
||||
}
|
||||
|
||||
impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
|
||||
fn read_vtable_res(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
-> typeck::vtable_res {
|
||||
@self.read_to_vec(|this|
|
||||
this.read_vtable_param_res(tcx, cdata))
|
||||
|
@ -723,7 +723,7 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
|
|||
}
|
||||
|
||||
fn read_vtable_param_res(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
-> typeck::vtable_param_res {
|
||||
@self.read_to_vec(|this|
|
||||
this.read_vtable_origin(tcx, cdata))
|
||||
|
@ -732,7 +732,7 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
|
|||
}
|
||||
|
||||
fn read_vtable_origin(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata)
|
||||
-> typeck::vtable_origin {
|
||||
self.read_enum("vtable_origin", |this| {
|
||||
this.read_enum_variant(["vtable_static",
|
||||
|
@ -775,11 +775,11 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
|
|||
// Encoding and decoding the side tables
|
||||
|
||||
trait get_ty_str_ctxt {
|
||||
fn ty_str_ctxt(&self) -> @tyencode::ctxt;
|
||||
fn ty_str_ctxt<'a>(&'a self) -> @tyencode::ctxt<'a>;
|
||||
}
|
||||
|
||||
impl<'a> get_ty_str_ctxt for e::EncodeContext<'a> {
|
||||
fn ty_str_ctxt(&self) -> @tyencode::ctxt {
|
||||
fn ty_str_ctxt<'a>(&'a self) -> @tyencode::ctxt<'a> {
|
||||
@tyencode::ctxt {
|
||||
diag: self.tcx.sess.diagnostic(),
|
||||
ds: e::def_to_str,
|
||||
|
@ -1122,15 +1122,15 @@ trait ebml_decoder_decoder_helpers {
|
|||
// Versions of the type reading functions that don't need the full
|
||||
// ExtendedDecodeContext.
|
||||
fn read_ty_noxcx(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata) -> ty::t;
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata) -> ty::t;
|
||||
fn read_tys_noxcx(&mut self,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
cdata: @cstore::crate_metadata) -> Vec<ty::t>;
|
||||
}
|
||||
|
||||
impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
|
||||
fn read_ty_noxcx(&mut self,
|
||||
tcx: ty::ctxt, cdata: @cstore::crate_metadata) -> ty::t {
|
||||
tcx: &ty::ctxt, cdata: @cstore::crate_metadata) -> ty::t {
|
||||
self.read_opaque(|_, doc| {
|
||||
tydecode::parse_ty_data(
|
||||
doc.data,
|
||||
|
@ -1142,7 +1142,7 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
|
|||
}
|
||||
|
||||
fn read_tys_noxcx(&mut self,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
cdata: @cstore::crate_metadata) -> Vec<ty::t> {
|
||||
self.read_to_vec(|this| this.read_ty_noxcx(tcx, cdata) )
|
||||
.move_iter()
|
||||
|
|
|
@ -32,9 +32,9 @@ use syntax::visit;
|
|||
use util::ppaux::Repr;
|
||||
|
||||
struct CheckLoanCtxt<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
dfcx_loans: &'a LoanDataFlow,
|
||||
move_data: move_data::FlowedMoveData,
|
||||
bccx: &'a BorrowckCtxt<'a>,
|
||||
dfcx_loans: &'a LoanDataFlow<'a>,
|
||||
move_data: move_data::FlowedMoveData<'a>,
|
||||
all_loans: &'a [Loan],
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ enum MoveError {
|
|||
}
|
||||
|
||||
impl<'a> CheckLoanCtxt<'a> {
|
||||
pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
||||
pub fn tcx(&self) -> &'a ty::ctxt { self.bccx.tcx }
|
||||
|
||||
pub fn each_issued_loan(&self, scope_id: ast::NodeId, op: |&Loan| -> bool)
|
||||
-> bool {
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
|
|||
// Private
|
||||
|
||||
struct GuaranteeLifetimeContext<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
bccx: &'a BorrowckCtxt<'a>,
|
||||
|
||||
// the node id of the function body for the enclosing item
|
||||
item_scope_id: ast::NodeId,
|
||||
|
@ -65,7 +65,7 @@ struct GuaranteeLifetimeContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> GuaranteeLifetimeContext<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
fn tcx(&self) -> &'a ty::ctxt {
|
||||
self.bccx.tcx
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ mod gather_moves;
|
|||
/// body of the while loop and we will refuse to root the pointer `&*x`
|
||||
/// because it would have to be rooted for a region greater than `root_ub`.
|
||||
struct GatherLoanCtxt<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
bccx: &'a BorrowckCtxt<'a>,
|
||||
id_range: IdRange,
|
||||
move_data: move_data::MoveData,
|
||||
all_loans: @RefCell<Vec<Loan> >,
|
||||
|
@ -315,7 +315,7 @@ fn with_assignee_loan_path(bccx: &BorrowckCtxt, expr: &ast::Expr, op: |@LoanPath
|
|||
}
|
||||
|
||||
impl<'a> GatherLoanCtxt<'a> {
|
||||
pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
||||
pub fn tcx(&self) -> &'a ty::ctxt { self.bccx.tcx }
|
||||
|
||||
pub fn push_repeating_id(&mut self, id: ast::NodeId) {
|
||||
self.repeating_ids.push(id);
|
||||
|
|
|
@ -46,7 +46,7 @@ pub fn compute_restrictions(bccx: &BorrowckCtxt,
|
|||
// Private
|
||||
|
||||
struct RestrictionsContext<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
bccx: &'a BorrowckCtxt<'a>,
|
||||
span: Span,
|
||||
cmt_original: mc::cmt,
|
||||
loan_region: ty::Region,
|
||||
|
|
|
@ -61,16 +61,16 @@ impl Clone for LoanDataFlowOperator {
|
|||
}
|
||||
}
|
||||
|
||||
pub type LoanDataFlow = DataFlowContext<LoanDataFlowOperator>;
|
||||
pub type LoanDataFlow<'a> = DataFlowContext<'a, LoanDataFlowOperator>;
|
||||
|
||||
impl Visitor<()> for BorrowckCtxt {
|
||||
impl<'a> Visitor<()> for BorrowckCtxt<'a> {
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl,
|
||||
b: &Block, s: Span, n: NodeId, _: ()) {
|
||||
borrowck_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
moves_map: moves::MovesMap,
|
||||
moved_variables_set: moves::MovedVariablesSet,
|
||||
|
@ -155,8 +155,8 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
|
|||
// ----------------------------------------------------------------------
|
||||
// Type definitions
|
||||
|
||||
pub struct BorrowckCtxt {
|
||||
tcx: ty::ctxt,
|
||||
pub struct BorrowckCtxt<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
moves_map: moves::MovesMap,
|
||||
moved_variables_set: moves::MovedVariablesSet,
|
||||
|
@ -335,7 +335,7 @@ impl BitAnd<RestrictionSet,RestrictionSet> for RestrictionSet {
|
|||
}
|
||||
|
||||
impl Repr for RestrictionSet {
|
||||
fn repr(&self, _tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ty::ctxt) -> ~str {
|
||||
format!("RestrictionSet(0x{:x})", self.bits as uint)
|
||||
}
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ pub enum MovedValueUseKind {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Misc
|
||||
|
||||
impl BorrowckCtxt {
|
||||
impl<'a> BorrowckCtxt<'a> {
|
||||
pub fn is_subregion_of(&self, r_sub: ty::Region, r_sup: ty::Region)
|
||||
-> bool {
|
||||
self.tcx.region_maps.is_subregion_of(r_sub, r_sup)
|
||||
|
@ -421,7 +421,7 @@ impl BorrowckCtxt {
|
|||
moves_map.get().contains(&id)
|
||||
}
|
||||
|
||||
pub fn mc(&self) -> mc::MemCategorizationContext<TcxTyper> {
|
||||
pub fn mc(&self) -> mc::MemCategorizationContext<TcxTyper<'a>> {
|
||||
mc::MemCategorizationContext {
|
||||
typer: TcxTyper {
|
||||
tcx: self.tcx,
|
||||
|
@ -601,7 +601,7 @@ impl BorrowckCtxt {
|
|||
}
|
||||
}
|
||||
|
||||
fn move_suggestion(tcx: ty::ctxt, ty: ty::t, default_msg: &'static str)
|
||||
fn move_suggestion(tcx: &ty::ctxt, ty: ty::t, default_msg: &'static str)
|
||||
-> &'static str {
|
||||
match ty::get(ty).sty {
|
||||
ty::ty_closure(ref cty) if cty.sigil == ast::BorrowedSigil =>
|
||||
|
@ -871,7 +871,7 @@ impl DataFlowOperator for LoanDataFlowOperator {
|
|||
}
|
||||
|
||||
impl Repr for Loan {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
|
||||
self.index,
|
||||
self.loan_path.repr(tcx),
|
||||
|
@ -883,7 +883,7 @@ impl Repr for Loan {
|
|||
}
|
||||
|
||||
impl Repr for Restriction {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
format!("Restriction({}, {:x})",
|
||||
self.loan_path.repr(tcx),
|
||||
self.set.bits as uint)
|
||||
|
@ -891,7 +891,7 @@ impl Repr for Restriction {
|
|||
}
|
||||
|
||||
impl Repr for LoanPath {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match self {
|
||||
&LpVar(id) => {
|
||||
format!("$({})", tcx.map.node_to_str(id))
|
||||
|
@ -910,13 +910,13 @@ impl Repr for LoanPath {
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct TcxTyper {
|
||||
tcx: ty::ctxt,
|
||||
pub struct TcxTyper<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
}
|
||||
|
||||
impl mc::Typer for TcxTyper {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
impl<'a> mc::Typer for TcxTyper<'a> {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ impl mc::Typer for TcxTyper {
|
|||
Ok(ty::node_id_to_type(self.tcx, id))
|
||||
}
|
||||
|
||||
fn node_method_ty(&mut self, method_call: typeck::MethodCall) -> Option<ty::t> {
|
||||
fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<ty::t> {
|
||||
self.method_map.borrow().get().find(&method_call).map(|method| method.ty)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,15 +55,15 @@ pub struct MoveData {
|
|||
assignee_ids: RefCell<HashSet<ast::NodeId>>,
|
||||
}
|
||||
|
||||
pub struct FlowedMoveData {
|
||||
pub struct FlowedMoveData<'a> {
|
||||
move_data: MoveData,
|
||||
|
||||
dfcx_moves: MoveDataFlow,
|
||||
dfcx_moves: MoveDataFlow<'a>,
|
||||
|
||||
// We could (and maybe should, for efficiency) combine both move
|
||||
// and assign data flow into one, but this way it's easier to
|
||||
// distinguish the bits that correspond to moves and assignments.
|
||||
dfcx_assign: AssignDataFlow
|
||||
dfcx_assign: AssignDataFlow<'a>
|
||||
}
|
||||
|
||||
/// Index into `MoveData.paths`, used like a pointer
|
||||
|
@ -159,7 +159,7 @@ impl Clone for MoveDataFlowOperator {
|
|||
}
|
||||
}
|
||||
|
||||
pub type MoveDataFlow = DataFlowContext<MoveDataFlowOperator>;
|
||||
pub type MoveDataFlow<'a> = DataFlowContext<'a, MoveDataFlowOperator>;
|
||||
|
||||
pub struct AssignDataFlowOperator;
|
||||
|
||||
|
@ -171,7 +171,7 @@ impl Clone for AssignDataFlowOperator {
|
|||
}
|
||||
}
|
||||
|
||||
pub type AssignDataFlow = DataFlowContext<AssignDataFlowOperator>;
|
||||
pub type AssignDataFlow<'a> = DataFlowContext<'a, AssignDataFlowOperator>;
|
||||
|
||||
impl MoveData {
|
||||
pub fn new() -> MoveData {
|
||||
|
@ -236,7 +236,7 @@ impl MoveData {
|
|||
}
|
||||
|
||||
pub fn move_path(&self,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
lp: @LoanPath) -> MovePathIndex {
|
||||
/*!
|
||||
* Returns the existing move path index for `lp`, if any,
|
||||
|
@ -355,7 +355,7 @@ impl MoveData {
|
|||
}
|
||||
|
||||
pub fn add_move(&self,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
lp: @LoanPath,
|
||||
id: ast::NodeId,
|
||||
kind: MoveKind) {
|
||||
|
@ -390,7 +390,7 @@ impl MoveData {
|
|||
}
|
||||
|
||||
pub fn add_assignment(&self,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
lp: @LoanPath,
|
||||
assign_id: ast::NodeId,
|
||||
span: Span,
|
||||
|
@ -435,7 +435,7 @@ impl MoveData {
|
|||
}
|
||||
|
||||
fn add_gen_kills(&self,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
dfcx_moves: &mut MoveDataFlow,
|
||||
dfcx_assign: &mut AssignDataFlow) {
|
||||
/*!
|
||||
|
@ -566,13 +566,13 @@ impl MoveData {
|
|||
}
|
||||
}
|
||||
|
||||
impl FlowedMoveData {
|
||||
impl<'a> FlowedMoveData<'a> {
|
||||
pub fn new(move_data: MoveData,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
id_range: ast_util::IdRange,
|
||||
body: &ast::Block)
|
||||
-> FlowedMoveData {
|
||||
-> FlowedMoveData<'a> {
|
||||
let mut dfcx_moves = {
|
||||
let moves = move_data.moves.borrow();
|
||||
DataFlowContext::new(tcx,
|
||||
|
|
|
@ -18,8 +18,8 @@ use syntax::ast_util;
|
|||
use syntax::opt_vec;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
struct CFGBuilder {
|
||||
tcx: ty::ctxt,
|
||||
struct CFGBuilder<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
exit_map: NodeMap<CFGIndex>,
|
||||
graph: CFGGraph,
|
||||
|
@ -32,7 +32,7 @@ struct LoopScope {
|
|||
break_index: CFGIndex, // where to go on a `break
|
||||
}
|
||||
|
||||
pub fn construct(tcx: ty::ctxt,
|
||||
pub fn construct(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
blk: &ast::Block) -> CFG {
|
||||
let mut cfg_builder = CFGBuilder {
|
||||
|
@ -51,7 +51,7 @@ pub fn construct(tcx: ty::ctxt,
|
|||
exit: exit}
|
||||
}
|
||||
|
||||
impl CFGBuilder {
|
||||
impl<'a> CFGBuilder<'a> {
|
||||
fn block(&mut self, blk: &ast::Block, pred: CFGIndex) -> CFGIndex {
|
||||
let mut stmts_exit = pred;
|
||||
for &stmt in blk.stmts.iter() {
|
||||
|
|
|
@ -53,7 +53,7 @@ pub struct CFGIndices {
|
|||
}
|
||||
|
||||
impl CFG {
|
||||
pub fn new(tcx: ty::ctxt,
|
||||
pub fn new(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
blk: &ast::Block) -> CFG {
|
||||
construct::construct(tcx, method_map, blk)
|
||||
|
|
|
@ -21,13 +21,13 @@ use syntax::{ast_util, ast_map};
|
|||
use syntax::visit::Visitor;
|
||||
use syntax::visit;
|
||||
|
||||
pub struct CheckCrateVisitor {
|
||||
pub struct CheckCrateVisitor<'a> {
|
||||
def_map: resolve::DefMap,
|
||||
method_map: typeck::MethodMap,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
}
|
||||
|
||||
impl Visitor<bool> for CheckCrateVisitor {
|
||||
impl<'a> Visitor<bool> for CheckCrateVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &Item, env: bool) {
|
||||
check_item(self, i, env);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ impl Visitor<bool> for CheckCrateVisitor {
|
|||
pub fn check_crate(krate: &Crate,
|
||||
def_map: resolve::DefMap,
|
||||
method_map: typeck::MethodMap,
|
||||
tcx: ty::ctxt) {
|
||||
tcx: &ty::ctxt) {
|
||||
let mut v = CheckCrateVisitor {
|
||||
def_map: def_map,
|
||||
method_map: method_map,
|
||||
|
|
|
@ -20,15 +20,15 @@ enum Context {
|
|||
Normal, Loop, Closure
|
||||
}
|
||||
|
||||
struct CheckLoopVisitor {
|
||||
tcx: ty::ctxt,
|
||||
struct CheckLoopVisitor<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt, krate: &ast::Crate) {
|
||||
pub fn check_crate(tcx: &ty::ctxt, krate: &ast::Crate) {
|
||||
visit::walk_crate(&mut CheckLoopVisitor { tcx: tcx }, krate, Normal)
|
||||
}
|
||||
|
||||
impl Visitor<Context> for CheckLoopVisitor {
|
||||
impl<'a> Visitor<Context> for CheckLoopVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &ast::Item, _cx: Context) {
|
||||
visit::walk_item(self, i, Normal);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl Visitor<Context> for CheckLoopVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl CheckLoopVisitor {
|
||||
impl<'a> CheckLoopVisitor<'a> {
|
||||
fn require_loop(&self, name: &str, cx: Context, span: Span) {
|
||||
match cx {
|
||||
Loop => {}
|
||||
|
|
|
@ -30,47 +30,41 @@ use syntax::parse::token;
|
|||
use syntax::visit;
|
||||
use syntax::visit::{Visitor, FnKind};
|
||||
|
||||
struct MatchCheckCtxt {
|
||||
tcx: ty::ctxt,
|
||||
struct MatchCheckCtxt<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: MethodMap,
|
||||
moves_map: moves::MovesMap
|
||||
}
|
||||
|
||||
struct CheckMatchVisitor {
|
||||
cx: @MatchCheckCtxt
|
||||
}
|
||||
|
||||
impl Visitor<()> for CheckMatchVisitor {
|
||||
impl<'a> Visitor<()> for MatchCheckCtxt<'a> {
|
||||
fn visit_expr(&mut self, ex: &Expr, _: ()) {
|
||||
check_expr(self, self.cx, ex, ());
|
||||
check_expr(self, ex);
|
||||
}
|
||||
fn visit_local(&mut self, l: &Local, _: ()) {
|
||||
check_local(self, self.cx, l, ());
|
||||
check_local(self, l);
|
||||
}
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) {
|
||||
check_fn(self, self.cx, fk, fd, b, s, n, ());
|
||||
check_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: MethodMap,
|
||||
moves_map: moves::MovesMap,
|
||||
krate: &Crate) {
|
||||
let cx = @MatchCheckCtxt {tcx: tcx,
|
||||
let mut cx = MatchCheckCtxt {
|
||||
tcx: tcx,
|
||||
method_map: method_map,
|
||||
moves_map: moves_map};
|
||||
let mut v = CheckMatchVisitor { cx: cx };
|
||||
moves_map: moves_map
|
||||
};
|
||||
|
||||
visit::walk_crate(&mut v, krate, ());
|
||||
visit::walk_crate(&mut cx, krate, ());
|
||||
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
fn check_expr(v: &mut CheckMatchVisitor,
|
||||
cx: @MatchCheckCtxt,
|
||||
ex: &Expr,
|
||||
s: ()) {
|
||||
visit::walk_expr(v, ex, s);
|
||||
fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) {
|
||||
visit::walk_expr(cx, ex, ());
|
||||
match ex.node {
|
||||
ExprMatch(scrut, ref arms) => {
|
||||
// First, check legality of move bindings.
|
||||
|
@ -871,11 +865,8 @@ fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<Vec<@Pat> > {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_local(v: &mut CheckMatchVisitor,
|
||||
cx: &MatchCheckCtxt,
|
||||
loc: &Local,
|
||||
s: ()) {
|
||||
visit::walk_local(v, loc, s);
|
||||
fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) {
|
||||
visit::walk_local(cx, loc, ());
|
||||
if is_refutable(cx, loc.pat) {
|
||||
cx.tcx.sess.span_err(loc.pat.span,
|
||||
"refutable pattern in local binding");
|
||||
|
@ -885,15 +876,13 @@ fn check_local(v: &mut CheckMatchVisitor,
|
|||
check_legality_of_move_bindings(cx, false, [ loc.pat ]);
|
||||
}
|
||||
|
||||
fn check_fn(v: &mut CheckMatchVisitor,
|
||||
cx: &MatchCheckCtxt,
|
||||
fn check_fn(cx: &mut MatchCheckCtxt,
|
||||
kind: &FnKind,
|
||||
decl: &FnDecl,
|
||||
body: &Block,
|
||||
sp: Span,
|
||||
id: NodeId,
|
||||
s: ()) {
|
||||
visit::walk_fn(v, kind, decl, body, sp, id, s);
|
||||
id: NodeId) {
|
||||
visit::walk_fn(cx, kind, decl, body, sp, id, ());
|
||||
for input in decl.inputs.iter() {
|
||||
if is_refutable(cx, input.pat) {
|
||||
cx.tcx.sess.span_err(input.pat.span,
|
||||
|
|
|
@ -30,7 +30,7 @@ use syntax::visit;
|
|||
use syntax::print::pprust;
|
||||
|
||||
|
||||
fn safe_type_for_static_mut(cx: ty::ctxt, e: &ast::Expr) -> Option<~str> {
|
||||
fn safe_type_for_static_mut(cx: &ty::ctxt, e: &ast::Expr) -> Option<~str> {
|
||||
let node_ty = ty::node_id_to_type(cx, e.id);
|
||||
let tcontents = ty::type_contents(cx, node_ty);
|
||||
debug!("safe_type_for_static_mut(dtor={}, managed={}, owned={})",
|
||||
|
@ -49,16 +49,15 @@ fn safe_type_for_static_mut(cx: ty::ctxt, e: &ast::Expr) -> Option<~str> {
|
|||
Some(format!("mutable static items are not allowed to have {}", suffix))
|
||||
}
|
||||
|
||||
struct CheckStaticVisitor {
|
||||
tcx: ty::ctxt,
|
||||
struct CheckStaticVisitor<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt, krate: &ast::Crate) {
|
||||
pub fn check_crate(tcx: &ty::ctxt, krate: &ast::Crate) {
|
||||
visit::walk_crate(&mut CheckStaticVisitor { tcx: tcx }, krate, false)
|
||||
}
|
||||
|
||||
impl CheckStaticVisitor {
|
||||
|
||||
impl<'a> CheckStaticVisitor<'a> {
|
||||
fn report_error(&self, span: Span, result: Option<~str>) -> bool {
|
||||
match result {
|
||||
None => { false }
|
||||
|
@ -70,7 +69,7 @@ impl CheckStaticVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<bool> for CheckStaticVisitor {
|
||||
impl<'a> Visitor<bool> for CheckStaticVisitor<'a> {
|
||||
|
||||
fn visit_item(&mut self, i: &ast::Item, _is_const: bool) {
|
||||
debug!("visit_item(item={})", pprust::item_to_str(i));
|
||||
|
|
|
@ -84,7 +84,7 @@ pub fn join_all<It: Iterator<constness>>(mut cs: It) -> constness {
|
|||
cs.fold(integral_const, |a, b| join(a, b))
|
||||
}
|
||||
|
||||
pub fn lookup_const(tcx: ty::ctxt, e: &Expr) -> Option<@Expr> {
|
||||
pub fn lookup_const(tcx: &ty::ctxt, e: &Expr) -> Option<@Expr> {
|
||||
let opt_def = {
|
||||
let def_map = tcx.def_map.borrow();
|
||||
def_map.get().find_copy(&e.id)
|
||||
|
@ -100,7 +100,7 @@ pub fn lookup_const(tcx: ty::ctxt, e: &Expr) -> Option<@Expr> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn lookup_variant_by_id(tcx: ty::ctxt,
|
||||
pub fn lookup_variant_by_id(tcx: &ty::ctxt,
|
||||
enum_def: ast::DefId,
|
||||
variant_def: ast::DefId)
|
||||
-> Option<@Expr> {
|
||||
|
@ -161,7 +161,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn lookup_const_by_id(tcx: ty::ctxt, def_id: ast::DefId)
|
||||
pub fn lookup_const_by_id(tcx: &ty::ctxt, def_id: ast::DefId)
|
||||
-> Option<@Expr> {
|
||||
if ast_util::is_local(def_id) {
|
||||
{
|
||||
|
@ -207,12 +207,12 @@ pub fn lookup_const_by_id(tcx: ty::ctxt, def_id: ast::DefId)
|
|||
}
|
||||
}
|
||||
|
||||
struct ConstEvalVisitor {
|
||||
tcx: ty::ctxt,
|
||||
struct ConstEvalVisitor<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
ccache: constness_cache,
|
||||
}
|
||||
|
||||
impl ConstEvalVisitor {
|
||||
impl<'a> ConstEvalVisitor<'a> {
|
||||
fn classify(&mut self, e: &Expr) -> constness {
|
||||
let did = ast_util::local_def(e.id);
|
||||
match self.ccache.find(&did) {
|
||||
|
@ -297,14 +297,14 @@ impl ConstEvalVisitor {
|
|||
|
||||
}
|
||||
|
||||
impl Visitor<()> for ConstEvalVisitor {
|
||||
impl<'a> Visitor<()> for ConstEvalVisitor<'a> {
|
||||
fn visit_expr_post(&mut self, e: &Expr, _: ()) {
|
||||
self.classify(e);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process_crate(krate: &ast::Crate,
|
||||
tcx: ty::ctxt) {
|
||||
tcx: &ty::ctxt) {
|
||||
let mut v = ConstEvalVisitor {
|
||||
tcx: tcx,
|
||||
ccache: DefIdMap::new(),
|
||||
|
@ -326,8 +326,8 @@ pub enum const_val {
|
|||
const_bool(bool)
|
||||
}
|
||||
|
||||
pub fn eval_const_expr(tcx: middle::ty::ctxt, e: &Expr) -> const_val {
|
||||
match eval_const_expr_partial(&tcx, e) {
|
||||
pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
|
||||
match eval_const_expr_partial(tcx, e) {
|
||||
Ok(r) => r,
|
||||
Err(s) => tcx.sess.span_fatal(e.span, s)
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
|
|||
}
|
||||
ExprPath(_) => {
|
||||
match lookup_const(tcx.ty_ctxt(), e) {
|
||||
Some(actual_e) => eval_const_expr_partial(&tcx.ty_ctxt(), actual_e),
|
||||
Some(actual_e) => eval_const_expr_partial(tcx.ty_ctxt(), actual_e),
|
||||
None => Err(~"non-constant path in constant expr")
|
||||
}
|
||||
}
|
||||
|
@ -540,11 +540,11 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option<int> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn compare_lit_exprs(tcx: middle::ty::ctxt, a: &Expr, b: &Expr) -> Option<int> {
|
||||
pub fn compare_lit_exprs(tcx: &ty::ctxt, a: &Expr, b: &Expr) -> Option<int> {
|
||||
compare_const_vals(&eval_const_expr(tcx, a), &eval_const_expr(tcx, b))
|
||||
}
|
||||
|
||||
pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: &Expr, b: &Expr) -> Option<bool> {
|
||||
pub fn lit_expr_eq(tcx: &ty::ctxt, a: &Expr, b: &Expr) -> Option<bool> {
|
||||
compare_lit_exprs(tcx, a, b).map(|val| val == 0)
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ use util::ppaux::Repr;
|
|||
use util::nodemap::NodeMap;
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct DataFlowContext<O> {
|
||||
priv tcx: ty::ctxt,
|
||||
pub struct DataFlowContext<'a, O> {
|
||||
priv tcx: &'a ty::ctxt,
|
||||
priv method_map: typeck::MethodMap,
|
||||
|
||||
/// the data flow operator
|
||||
|
@ -73,8 +73,8 @@ pub trait DataFlowOperator {
|
|||
fn join(&self, succ: uint, pred: uint) -> uint;
|
||||
}
|
||||
|
||||
struct PropagationContext<'a, O> {
|
||||
dfcx: &'a mut DataFlowContext<O>,
|
||||
struct PropagationContext<'a, 'b, O> {
|
||||
dfcx: &'a mut DataFlowContext<'b, O>,
|
||||
changed: bool
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ struct LoopScope<'a> {
|
|||
break_bits: Vec<uint>
|
||||
}
|
||||
|
||||
impl<O:DataFlowOperator> pprust::PpAnn for DataFlowContext<O> {
|
||||
impl<'a, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, O> {
|
||||
fn pre(&self, node: pprust::AnnNode) -> io::IoResult<()> {
|
||||
let (ps, id) = match node {
|
||||
pprust::NodeExpr(ps, expr) => (ps, expr.id),
|
||||
|
@ -120,12 +120,12 @@ impl<O:DataFlowOperator> pprust::PpAnn for DataFlowContext<O> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<O:DataFlowOperator> DataFlowContext<O> {
|
||||
pub fn new(tcx: ty::ctxt,
|
||||
impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
|
||||
pub fn new(tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
oper: O,
|
||||
id_range: IdRange,
|
||||
bits_per_id: uint) -> DataFlowContext<O> {
|
||||
bits_per_id: uint) -> DataFlowContext<'a, O> {
|
||||
let words_per_id = (bits_per_id + uint::BITS - 1) / uint::BITS;
|
||||
|
||||
debug!("DataFlowContext::new(id_range={:?}, bits_per_id={:?}, words_per_id={:?})",
|
||||
|
@ -315,7 +315,7 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
||||
impl<'a, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, O> {
|
||||
// ^^^^^^^^^^^^^ only needed for pretty printing
|
||||
pub fn propagate(&mut self, blk: &ast::Block) {
|
||||
//! Performs the data flow analysis.
|
||||
|
@ -327,7 +327,7 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
|||
|
||||
{
|
||||
let mut propcx = PropagationContext {
|
||||
dfcx: self,
|
||||
dfcx: &mut *self,
|
||||
changed: true
|
||||
};
|
||||
|
||||
|
@ -359,8 +359,8 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
|
||||
fn tcx(&self) -> &'b ty::ctxt {
|
||||
self.dfcx.tcx
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ pub static DEAD_CODE_LINT_STR: &'static str = "dead_code";
|
|||
// 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: ty::ctxt, def_id: ast::DefId) -> bool {
|
||||
fn should_explore(tcx: &ty::ctxt, def_id: ast::DefId) -> bool {
|
||||
if !is_local(def_id) {
|
||||
return false;
|
||||
}
|
||||
|
@ -49,17 +49,17 @@ fn should_explore(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
struct MarkSymbolVisitor {
|
||||
struct MarkSymbolVisitor<'a> {
|
||||
worklist: Vec<ast::NodeId>,
|
||||
method_map: typeck::MethodMap,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
live_symbols: ~HashSet<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl MarkSymbolVisitor {
|
||||
fn new(tcx: ty::ctxt,
|
||||
impl<'a> MarkSymbolVisitor<'a> {
|
||||
fn new(tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
worklist: Vec<ast::NodeId> ) -> MarkSymbolVisitor {
|
||||
worklist: Vec<ast::NodeId>) -> MarkSymbolVisitor<'a> {
|
||||
MarkSymbolVisitor {
|
||||
worklist: worklist,
|
||||
method_map: method_map,
|
||||
|
@ -175,7 +175,7 @@ impl MarkSymbolVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<()> for MarkSymbolVisitor {
|
||||
impl<'a> Visitor<()> for MarkSymbolVisitor<'a> {
|
||||
|
||||
fn visit_expr(&mut self, expr: &ast::Expr, _: ()) {
|
||||
match expr.node {
|
||||
|
@ -253,7 +253,7 @@ impl Visitor<()> for LifeSeeder {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_and_seed_worklist(tcx: ty::ctxt,
|
||||
fn create_and_seed_worklist(tcx: &ty::ctxt,
|
||||
exported_items: &privacy::ExportedItems,
|
||||
reachable_symbols: &NodeSet,
|
||||
krate: &ast::Crate) -> Vec<ast::NodeId> {
|
||||
|
@ -286,7 +286,7 @@ fn create_and_seed_worklist(tcx: ty::ctxt,
|
|||
return life_seeder.worklist;
|
||||
}
|
||||
|
||||
fn find_live(tcx: ty::ctxt,
|
||||
fn find_live(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
exported_items: &privacy::ExportedItems,
|
||||
reachable_symbols: &NodeSet,
|
||||
|
@ -316,12 +316,12 @@ fn get_struct_ctor_id(item: &ast::Item) -> Option<ast::NodeId> {
|
|||
}
|
||||
}
|
||||
|
||||
struct DeadVisitor {
|
||||
tcx: ty::ctxt,
|
||||
struct DeadVisitor<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
live_symbols: ~HashSet<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl DeadVisitor {
|
||||
impl<'a> DeadVisitor<'a> {
|
||||
// id := node id of an item's definition.
|
||||
// ctor_id := `Some` if the item is a struct_ctor (tuple struct),
|
||||
// `None` otherwise.
|
||||
|
@ -368,7 +368,7 @@ impl DeadVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<()> for DeadVisitor {
|
||||
impl<'a> Visitor<()> for DeadVisitor<'a> {
|
||||
fn visit_item(&mut self, item: &ast::Item, _: ()) {
|
||||
let ctor_id = get_struct_ctor_id(item);
|
||||
if !self.symbol_is_live(item.id, ctor_id) && should_warn(item) {
|
||||
|
@ -409,7 +409,7 @@ impl Visitor<()> for DeadVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
exported_items: &privacy::ExportedItems,
|
||||
reachable_symbols: &NodeSet,
|
||||
|
|
|
@ -35,8 +35,8 @@ fn type_is_unsafe_function(ty: ty::t) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
struct EffectCheckVisitor {
|
||||
tcx: ty::ctxt,
|
||||
struct EffectCheckVisitor<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
|
||||
/// The method map.
|
||||
method_map: MethodMap,
|
||||
|
@ -44,7 +44,7 @@ struct EffectCheckVisitor {
|
|||
unsafe_context: UnsafeContext,
|
||||
}
|
||||
|
||||
impl EffectCheckVisitor {
|
||||
impl<'a> EffectCheckVisitor<'a> {
|
||||
fn require_unsafe(&mut self, span: Span, description: &str) {
|
||||
match self.unsafe_context {
|
||||
SafeContext => {
|
||||
|
@ -80,7 +80,7 @@ impl EffectCheckVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<()> for EffectCheckVisitor {
|
||||
impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
|
||||
fn visit_fn(&mut self, fn_kind: &visit::FnKind, fn_decl: &ast::FnDecl,
|
||||
block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) {
|
||||
|
||||
|
@ -191,7 +191,7 @@ impl Visitor<()> for EffectCheckVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt, method_map: MethodMap, krate: &ast::Crate) {
|
||||
pub fn check_crate(tcx: &ty::ctxt, method_map: MethodMap, krate: &ast::Crate) {
|
||||
let mut visitor = EffectCheckVisitor {
|
||||
tcx: tcx,
|
||||
method_map: method_map,
|
||||
|
|
|
@ -141,7 +141,7 @@ pub fn annotate_freevars(def_map: resolve::DefMap, krate: &ast::Crate) ->
|
|||
freevars
|
||||
}
|
||||
|
||||
pub fn get_freevars(tcx: ty::ctxt, fid: ast::NodeId) -> freevar_info {
|
||||
pub fn get_freevars(tcx: &ty::ctxt, fid: ast::NodeId) -> freevar_info {
|
||||
let freevars = tcx.freevars.borrow();
|
||||
match freevars.get().find(&fid) {
|
||||
None => fail!("get_freevars: {} has no freevars", fid),
|
||||
|
@ -149,6 +149,6 @@ pub fn get_freevars(tcx: ty::ctxt, fid: ast::NodeId) -> freevar_info {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn has_freevars(tcx: ty::ctxt, fid: ast::NodeId) -> bool {
|
||||
pub fn has_freevars(tcx: &ty::ctxt, fid: ast::NodeId) -> bool {
|
||||
!get_freevars(tcx, fid).is_empty()
|
||||
}
|
||||
|
|
|
@ -52,12 +52,12 @@ use syntax::visit::Visitor;
|
|||
// types.
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct Context {
|
||||
tcx: ty::ctxt,
|
||||
pub struct Context<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
}
|
||||
|
||||
impl Visitor<()> for Context {
|
||||
impl<'a> Visitor<()> for Context<'a> {
|
||||
|
||||
fn visit_expr(&mut self, ex: &Expr, _: ()) {
|
||||
check_expr(self, ex);
|
||||
|
@ -76,7 +76,7 @@ impl Visitor<()> for Context {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
krate: &Crate) {
|
||||
let mut ctx = Context {
|
||||
|
@ -324,7 +324,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
|
|||
check_trait_cast(cx, source_ty, target_ty, source.span);
|
||||
}
|
||||
ExprRepeat(element, count_expr, _) => {
|
||||
let count = ty::eval_repeat_count(&cx.tcx, count_expr);
|
||||
let count = ty::eval_repeat_count(cx.tcx, count_expr);
|
||||
if count > 1 {
|
||||
let element_ty = ty::expr_ty(cx.tcx, element);
|
||||
check_copy(cx, element_ty, element.span,
|
||||
|
@ -476,7 +476,7 @@ pub fn check_send(cx: &Context, ty: ty::t, sp: Span) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_static(tcx: ty::ctxt, ty: ty::t, sp: Span) -> bool {
|
||||
pub fn check_static(tcx: &ty::ctxt, ty: ty::t, sp: Span) -> bool {
|
||||
if !ty::type_is_static(tcx, ty) {
|
||||
match ty::get(ty).sty {
|
||||
ty::ty_param(..) => {
|
||||
|
|
|
@ -427,7 +427,7 @@ struct Context<'a> {
|
|||
// Current levels of each lint warning
|
||||
cur: SmallIntMap<(level, LintSource)>,
|
||||
// context we're checking in (used to access fields like sess)
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
// maps from an expression id that corresponds to a method call to the
|
||||
// details of the method to be invoked
|
||||
method_map: typeck::MethodMap,
|
||||
|
@ -670,7 +670,7 @@ fn check_while_true_expr(cx: &Context, e: &ast::Expr) {
|
|||
}
|
||||
}
|
||||
impl<'a> AstConv for Context<'a>{
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
|
||||
|
||||
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
|
||||
ty::lookup_item_type(self.tcx, id)
|
||||
|
@ -795,7 +795,7 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_limits(tcx: ty::ctxt, binop: ast::BinOp,
|
||||
fn check_limits(tcx: &ty::ctxt, binop: ast::BinOp,
|
||||
l: &ast::Expr, r: &ast::Expr) -> bool {
|
||||
let (lit, expr, swap) = match (&l.node, &r.node) {
|
||||
(&ast::ExprLit(_), _) => (l, r, true),
|
||||
|
@ -1749,7 +1749,7 @@ impl<'a> IdVisitingOperation for Context<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
exported_items: &privacy::ExportedItems,
|
||||
krate: &ast::Crate) {
|
||||
|
|
|
@ -152,7 +152,7 @@ pub enum LiveNodeKind {
|
|||
ExitNode
|
||||
}
|
||||
|
||||
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
|
||||
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: &ty::ctxt) -> ~str {
|
||||
let cm = cx.sess.codemap;
|
||||
match lnk {
|
||||
FreeVarNode(s) => format!("Free var node [{}]", cm.span_to_str(s)),
|
||||
|
@ -164,7 +164,7 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
|
|||
|
||||
struct LivenessVisitor;
|
||||
|
||||
impl Visitor<@IrMaps> for LivenessVisitor {
|
||||
impl<'a> Visitor<@IrMaps<'a>> for LivenessVisitor {
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, e: @IrMaps) {
|
||||
visit_fn(self, fk, fd, b, s, n, e);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ impl Visitor<@IrMaps> for LivenessVisitor {
|
|||
fn visit_arm(&mut self, a: &Arm, e: @IrMaps) { visit_arm(self, a, e); }
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
capture_map: moves::CaptureMap,
|
||||
krate: &Crate) {
|
||||
|
@ -251,8 +251,8 @@ pub enum VarKind {
|
|||
ImplicitRet
|
||||
}
|
||||
|
||||
pub struct IrMaps {
|
||||
tcx: ty::ctxt,
|
||||
pub struct IrMaps<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
capture_map: moves::CaptureMap,
|
||||
|
||||
|
@ -265,10 +265,10 @@ pub struct IrMaps {
|
|||
lnks: RefCell<Vec<LiveNodeKind> >,
|
||||
}
|
||||
|
||||
fn IrMaps(tcx: ty::ctxt,
|
||||
fn IrMaps<'a>(tcx: &'a ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
capture_map: moves::CaptureMap)
|
||||
-> IrMaps {
|
||||
-> IrMaps<'a> {
|
||||
IrMaps {
|
||||
tcx: tcx,
|
||||
method_map: method_map,
|
||||
|
@ -283,7 +283,7 @@ fn IrMaps(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
impl IrMaps {
|
||||
impl<'a> IrMaps<'a> {
|
||||
pub fn add_live_node(&self, lnk: LiveNodeKind) -> LiveNode {
|
||||
let num_live_nodes = self.num_live_nodes.get();
|
||||
let ln = LiveNode(num_live_nodes);
|
||||
|
@ -368,7 +368,7 @@ impl IrMaps {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<()> for Liveness {
|
||||
impl<'a> Visitor<()> for Liveness<'a> {
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) {
|
||||
check_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
|
@ -586,9 +586,9 @@ static ACC_USE: uint = 4u;
|
|||
|
||||
pub type LiveNodeMap = @RefCell<NodeMap<LiveNode>>;
|
||||
|
||||
pub struct Liveness {
|
||||
tcx: ty::ctxt,
|
||||
ir: @IrMaps,
|
||||
pub struct Liveness<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
ir: @IrMaps<'a>,
|
||||
s: Specials,
|
||||
successors: @RefCell<Vec<LiveNode> >,
|
||||
users: @RefCell<Vec<Users> >,
|
||||
|
@ -602,7 +602,7 @@ pub struct Liveness {
|
|||
cont_ln: LiveNodeMap
|
||||
}
|
||||
|
||||
fn Liveness(ir: @IrMaps, specials: Specials) -> Liveness {
|
||||
fn Liveness<'a>(ir: @IrMaps<'a>, specials: Specials) -> Liveness<'a> {
|
||||
Liveness {
|
||||
ir: ir,
|
||||
tcx: ir.tcx,
|
||||
|
@ -618,7 +618,7 @@ fn Liveness(ir: @IrMaps, specials: Specials) -> Liveness {
|
|||
}
|
||||
}
|
||||
|
||||
impl Liveness {
|
||||
impl<'a> Liveness<'a> {
|
||||
pub fn live_node(&self, node_id: NodeId, span: Span) -> LiveNode {
|
||||
let ir: &IrMaps = self.ir;
|
||||
let live_node_map = ir.live_node_map.borrow();
|
||||
|
@ -1549,7 +1549,7 @@ pub enum ReadKind {
|
|||
PartiallyMovedValue
|
||||
}
|
||||
|
||||
impl Liveness {
|
||||
impl<'a> Liveness<'a> {
|
||||
pub fn check_ret(&self,
|
||||
id: NodeId,
|
||||
sp: Span,
|
||||
|
|
|
@ -216,7 +216,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind {
|
||||
pub fn deref_kind(tcx: &ty::ctxt, t: ty::t) -> deref_kind {
|
||||
match opt_deref_kind(t) {
|
||||
Some(k) => k,
|
||||
None => {
|
||||
|
@ -267,9 +267,9 @@ pub type McResult<T> = Result<T, ()>;
|
|||
* can be sure that only `Ok` results will occur.
|
||||
*/
|
||||
pub trait Typer {
|
||||
fn tcx(&self) -> ty::ctxt;
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt;
|
||||
fn node_ty(&mut self, id: ast::NodeId) -> McResult<ty::t>;
|
||||
fn node_method_ty(&mut self, method_call: typeck::MethodCall) -> Option<ty::t>;
|
||||
fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<ty::t>;
|
||||
fn adjustment(&mut self, node_id: ast::NodeId) -> Option<@ty::AutoAdjustment>;
|
||||
fn is_method_call(&mut self, id: ast::NodeId) -> bool;
|
||||
fn temporary_scope(&mut self, rvalue_id: ast::NodeId) -> Option<ast::NodeId>;
|
||||
|
@ -351,7 +351,7 @@ macro_rules! if_ok(
|
|||
)
|
||||
|
||||
impl<TYPER:Typer> MemCategorizationContext<TYPER> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt {
|
||||
self.typer.tcx()
|
||||
}
|
||||
|
||||
|
@ -886,7 +886,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
|
|||
let cmt_slice = self.cat_index(slice_pat, vec_cmt, 0);
|
||||
return Ok((cmt_slice, slice_mutbl, slice_r));
|
||||
|
||||
fn vec_slice_info(tcx: ty::ctxt,
|
||||
fn vec_slice_info(tcx: &ty::ctxt,
|
||||
pat: @ast::Pat,
|
||||
slice_ty: ty::t)
|
||||
-> (ast::Mutability, ty::Region) {
|
||||
|
@ -996,10 +996,9 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
|
|||
// step out of sync again. So you'll see below that we always
|
||||
// get the type of the *subpattern* and use that.
|
||||
|
||||
let tcx = self.tcx();
|
||||
debug!("cat_pattern: id={} pat={} cmt={}",
|
||||
pat.id, pprust::pat_to_str(pat),
|
||||
cmt.repr(tcx));
|
||||
cmt.repr(self.tcx()));
|
||||
|
||||
op(self, cmt, pat);
|
||||
|
||||
|
@ -1187,7 +1186,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
|
|||
/// The node_id here is the node of the expression that references the field.
|
||||
/// This function looks it up in the def map in case the type happens to be
|
||||
/// an enum to determine which variant is in use.
|
||||
pub fn field_mutbl(tcx: ty::ctxt,
|
||||
pub fn field_mutbl(tcx: &ty::ctxt,
|
||||
base_ty: ty::t,
|
||||
// FIXME #6993: change type to Name
|
||||
f_name: ast::Ident,
|
||||
|
@ -1312,7 +1311,7 @@ impl cmt_ {
|
|||
}
|
||||
|
||||
impl Repr for cmt_ {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
format!("\\{{} id:{} m:{:?} ty:{}\\}",
|
||||
self.cat.repr(tcx),
|
||||
self.id,
|
||||
|
@ -1322,7 +1321,7 @@ impl Repr for cmt_ {
|
|||
}
|
||||
|
||||
impl Repr for categorization {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
cat_static_item |
|
||||
cat_rvalue(..) |
|
||||
|
@ -1365,7 +1364,7 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
|
|||
}
|
||||
|
||||
impl Repr for InteriorKind {
|
||||
fn repr(&self, _tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
InteriorField(NamedField(fld)) => {
|
||||
token::get_name(fld).get().to_str()
|
||||
|
|
|
@ -181,8 +181,8 @@ pub struct MoveMaps {
|
|||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
struct VisitContext {
|
||||
tcx: ty::ctxt,
|
||||
struct VisitContext<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
method_map: MethodMap,
|
||||
move_maps: MoveMaps
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ enum UseMode {
|
|||
Read // Read no matter what the type.
|
||||
}
|
||||
|
||||
impl visit::Visitor<()> for VisitContext {
|
||||
impl<'a> visit::Visitor<()> for VisitContext<'a> {
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &FnDecl,
|
||||
b: &Block, s: Span, n: NodeId, _: ()) {
|
||||
compute_modes_for_fn(self, fk, fd, b, s, n);
|
||||
|
@ -208,7 +208,7 @@ impl visit::Visitor<()> for VisitContext {
|
|||
fn visit_ty(&mut self, _t: &Ty, _: ()) {}
|
||||
}
|
||||
|
||||
pub fn compute_moves(tcx: ty::ctxt,
|
||||
pub fn compute_moves(tcx: &ty::ctxt,
|
||||
method_map: MethodMap,
|
||||
krate: &Crate) -> MoveMaps
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ fn compute_modes_for_expr(cx: &mut VisitContext,
|
|||
cx.consume_expr(expr);
|
||||
}
|
||||
|
||||
impl VisitContext {
|
||||
impl<'a> VisitContext<'a> {
|
||||
pub fn consume_exprs(&mut self, exprs: &[@Expr]) {
|
||||
for expr in exprs.iter() {
|
||||
self.consume_expr(*expr);
|
||||
|
@ -444,7 +444,7 @@ impl VisitContext {
|
|||
ty::type_moves_by_default(self.tcx, tf.mt.ty)
|
||||
});
|
||||
|
||||
fn has_dtor(tcx: ty::ctxt, ty: ty::t) -> bool {
|
||||
fn has_dtor(tcx: &ty::ctxt, ty: ty::t) -> bool {
|
||||
use middle::ty::{get,ty_struct,ty_enum};
|
||||
match get(ty).sty {
|
||||
ty_struct(did, _) | ty_enum(did, _) => ty::has_dtor(tcx, did),
|
||||
|
|
|
@ -142,7 +142,7 @@ impl Visitor<()> for ParentVisitor {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct EmbargoVisitor<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
exp_map2: &'a resolve::ExportMap2,
|
||||
|
||||
// This flag is an indicator of whether the previous item in the
|
||||
|
@ -345,7 +345,7 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct PrivacyVisitor<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
curitem: ast::NodeId,
|
||||
in_fn: bool,
|
||||
in_foreign: bool,
|
||||
|
@ -920,12 +920,12 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
|
|||
/// The privacy sanity check visitor, ensures unnecessary visibility isn't here
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SanePrivacyVisitor {
|
||||
tcx: ty::ctxt,
|
||||
struct SanePrivacyVisitor<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
in_fn: bool,
|
||||
}
|
||||
|
||||
impl Visitor<()> for SanePrivacyVisitor {
|
||||
impl<'a> Visitor<()> for SanePrivacyVisitor<'a> {
|
||||
fn visit_item(&mut self, item: &ast::Item, _: ()) {
|
||||
if self.in_fn {
|
||||
self.check_all_inherited(item);
|
||||
|
@ -976,7 +976,7 @@ impl Visitor<()> for SanePrivacyVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl SanePrivacyVisitor {
|
||||
impl<'a> SanePrivacyVisitor<'a> {
|
||||
/// Validates all of the visibility qualifers placed on the item given. This
|
||||
/// ensures that there are no extraneous qualifiers that don't actually do
|
||||
/// anything. In theory these qualifiers wouldn't parse, but that may happen
|
||||
|
@ -1159,7 +1159,7 @@ impl SanePrivacyVisitor {
|
|||
}
|
||||
|
||||
struct VisiblePrivateTypesVisitor<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
exported_items: &'a ExportedItems,
|
||||
public_items: &'a PublicItems,
|
||||
}
|
||||
|
@ -1403,7 +1403,7 @@ impl<'a> Visitor<()> for VisiblePrivateTypesVisitor<'a> {
|
|||
fn visit_expr(&mut self, _: &ast::Expr, _: ()) {}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
method_map: &MethodMap,
|
||||
exp_map2: &resolve::ExportMap2,
|
||||
external_exports: resolve::ExternalExports,
|
||||
|
|
|
@ -59,7 +59,7 @@ fn item_might_be_inlined(item: &ast::Item) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn method_might_be_inlined(tcx: ty::ctxt, method: &ast::Method,
|
||||
fn method_might_be_inlined(tcx: &ty::ctxt, method: &ast::Method,
|
||||
impl_src: ast::DefId) -> bool {
|
||||
if attributes_specify_inlining(method.attrs.as_slice()) ||
|
||||
generics_require_inlining(&method.generics) {
|
||||
|
@ -83,9 +83,9 @@ fn method_might_be_inlined(tcx: ty::ctxt, method: &ast::Method,
|
|||
}
|
||||
|
||||
// Information needed while computing reachability.
|
||||
struct ReachableContext {
|
||||
struct ReachableContext<'a> {
|
||||
// The type context.
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
// The method map, which links node IDs of method call expressions to the
|
||||
// methods they've been resolved to.
|
||||
method_map: typeck::MethodMap,
|
||||
|
@ -96,14 +96,14 @@ struct ReachableContext {
|
|||
worklist: @RefCell<Vec<ast::NodeId> >,
|
||||
}
|
||||
|
||||
struct MarkSymbolVisitor {
|
||||
struct MarkSymbolVisitor<'a> {
|
||||
worklist: @RefCell<Vec<ast::NodeId>>,
|
||||
method_map: typeck::MethodMap,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
reachable_symbols: @RefCell<NodeSet>,
|
||||
}
|
||||
|
||||
impl Visitor<()> for MarkSymbolVisitor {
|
||||
impl<'a> Visitor<()> for MarkSymbolVisitor<'a> {
|
||||
|
||||
fn visit_expr(&mut self, expr: &ast::Expr, _: ()) {
|
||||
|
||||
|
@ -177,9 +177,9 @@ impl Visitor<()> for MarkSymbolVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl ReachableContext {
|
||||
impl<'a> ReachableContext<'a> {
|
||||
// Creates a new reachability computation context.
|
||||
fn new(tcx: ty::ctxt, method_map: typeck::MethodMap) -> ReachableContext {
|
||||
fn new(tcx: &'a ty::ctxt, method_map: typeck::MethodMap) -> ReachableContext<'a> {
|
||||
ReachableContext {
|
||||
tcx: tcx,
|
||||
method_map: method_map,
|
||||
|
@ -190,7 +190,7 @@ impl ReachableContext {
|
|||
|
||||
// Returns true if the given def ID represents a local item that is
|
||||
// eligible for inlining and false otherwise.
|
||||
fn def_id_represents_local_inlined_item(tcx: ty::ctxt, def_id: ast::DefId)
|
||||
fn def_id_represents_local_inlined_item(tcx: &ty::ctxt, def_id: ast::DefId)
|
||||
-> bool {
|
||||
if def_id.krate != ast::LOCAL_CRATE {
|
||||
return false
|
||||
|
@ -233,7 +233,7 @@ impl ReachableContext {
|
|||
}
|
||||
|
||||
// Helper function to set up a visitor for `propagate()` below.
|
||||
fn init_visitor(&self) -> MarkSymbolVisitor {
|
||||
fn init_visitor(&self) -> MarkSymbolVisitor<'a> {
|
||||
let (worklist, method_map) = (self.worklist, self.method_map);
|
||||
let (tcx, reachable_symbols) = (self.tcx, self.reachable_symbols);
|
||||
|
||||
|
@ -387,7 +387,7 @@ impl ReachableContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find_reachable(tcx: ty::ctxt,
|
||||
pub fn find_reachable(tcx: &ty::ctxt,
|
||||
method_map: typeck::MethodMap,
|
||||
exported_items: &privacy::ExportedItems)
|
||||
-> @RefCell<NodeSet> {
|
||||
|
|
|
@ -29,10 +29,10 @@ use syntax::opt_vec::OptVec;
|
|||
// information available (for better errors).
|
||||
|
||||
pub trait Subst {
|
||||
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> Self {
|
||||
fn subst(&self, tcx: &ty::ctxt, substs: &ty::substs) -> Self {
|
||||
self.subst_spanned(tcx, substs, None)
|
||||
}
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> Self;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub trait Subst {
|
|||
// our current method/trait matching algorithm. - Niko
|
||||
|
||||
impl Subst for ty::t {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::t {
|
||||
if ty::substs_is_noop(substs) && !ty::type_has_params(*self) {
|
||||
|
@ -64,7 +64,7 @@ impl Subst for ty::t {
|
|||
}
|
||||
|
||||
struct SubstFolder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
substs: &'a ty::substs,
|
||||
|
||||
// The location for which the substitution is performed, if available.
|
||||
|
@ -75,7 +75,7 @@ struct SubstFolder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> TypeFolder for SubstFolder<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
|
||||
r.subst(self.tcx, self.substs)
|
||||
|
@ -132,14 +132,14 @@ impl<'a> TypeFolder for SubstFolder<'a> {
|
|||
// Other types
|
||||
|
||||
impl<T:Subst> Subst for Vec<T> {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> Vec<T> {
|
||||
self.map(|t| t.subst_spanned(tcx, substs, span))
|
||||
}
|
||||
}
|
||||
impl<T:Subst> Subst for Rc<T> {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> Rc<T> {
|
||||
Rc::new(self.deref().subst_spanned(tcx, substs, span))
|
||||
|
@ -147,7 +147,7 @@ impl<T:Subst> Subst for Rc<T> {
|
|||
}
|
||||
|
||||
impl<T:Subst> Subst for OptVec<T> {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> OptVec<T> {
|
||||
self.map(|t| t.subst_spanned(tcx, substs, span))
|
||||
|
@ -155,7 +155,7 @@ impl<T:Subst> Subst for OptVec<T> {
|
|||
}
|
||||
|
||||
impl<T:Subst + 'static> Subst for @T {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> @T {
|
||||
match self {
|
||||
|
@ -165,7 +165,7 @@ impl<T:Subst + 'static> Subst for @T {
|
|||
}
|
||||
|
||||
impl<T:Subst> Subst for Option<T> {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> Option<T> {
|
||||
self.as_ref().map(|t| t.subst_spanned(tcx, substs, span))
|
||||
|
@ -173,7 +173,7 @@ impl<T:Subst> Subst for Option<T> {
|
|||
}
|
||||
|
||||
impl Subst for ty::TraitRef {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::TraitRef {
|
||||
ty::TraitRef {
|
||||
|
@ -184,7 +184,7 @@ impl Subst for ty::TraitRef {
|
|||
}
|
||||
|
||||
impl Subst for ty::substs {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::substs {
|
||||
ty::substs {
|
||||
|
@ -196,7 +196,7 @@ impl Subst for ty::substs {
|
|||
}
|
||||
|
||||
impl Subst for ty::RegionSubsts {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::RegionSubsts {
|
||||
match *self {
|
||||
|
@ -211,7 +211,7 @@ impl Subst for ty::RegionSubsts {
|
|||
}
|
||||
|
||||
impl Subst for ty::BareFnTy {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::BareFnTy {
|
||||
let mut folder = SubstFolder {
|
||||
|
@ -225,7 +225,7 @@ impl Subst for ty::BareFnTy {
|
|||
}
|
||||
|
||||
impl Subst for ty::ParamBounds {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::ParamBounds {
|
||||
ty::ParamBounds {
|
||||
|
@ -236,7 +236,7 @@ impl Subst for ty::ParamBounds {
|
|||
}
|
||||
|
||||
impl Subst for ty::TypeParameterDef {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::TypeParameterDef {
|
||||
ty::TypeParameterDef {
|
||||
|
@ -249,7 +249,7 @@ impl Subst for ty::TypeParameterDef {
|
|||
}
|
||||
|
||||
impl Subst for ty::Generics {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::Generics {
|
||||
ty::Generics {
|
||||
|
@ -260,7 +260,7 @@ impl Subst for ty::Generics {
|
|||
}
|
||||
|
||||
impl Subst for ty::RegionParameterDef {
|
||||
fn subst_spanned(&self, _: ty::ctxt,
|
||||
fn subst_spanned(&self, _: &ty::ctxt,
|
||||
_: &ty::substs,
|
||||
_: Option<Span>) -> ty::RegionParameterDef {
|
||||
*self
|
||||
|
@ -268,7 +268,7 @@ impl Subst for ty::RegionParameterDef {
|
|||
}
|
||||
|
||||
impl Subst for ty::Region {
|
||||
fn subst_spanned(&self, _tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, _tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
_: Option<Span>) -> ty::Region {
|
||||
// Note: This routine only handles regions that are bound on
|
||||
|
@ -290,7 +290,7 @@ impl Subst for ty::Region {
|
|||
}
|
||||
|
||||
impl Subst for ty::ty_param_bounds_and_ty {
|
||||
fn subst_spanned(&self, tcx: ty::ctxt,
|
||||
fn subst_spanned(&self, tcx: &ty::ctxt,
|
||||
substs: &ty::substs,
|
||||
span: Option<Span>) -> ty::ty_param_bounds_and_ty {
|
||||
ty::ty_param_bounds_and_ty {
|
||||
|
|
|
@ -257,7 +257,7 @@ enum Opt {
|
|||
vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint))
|
||||
}
|
||||
|
||||
fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
|
||||
fn opt_eq(tcx: &ty::ctxt, a: &Opt, b: &Opt) -> bool {
|
||||
match (a, b) {
|
||||
(&lit(a), &lit(b)) => {
|
||||
match (a, b) {
|
||||
|
@ -427,7 +427,7 @@ struct Match<'a,'b> {
|
|||
bound_ptrs: Vec<(Ident, ValueRef)> }
|
||||
|
||||
impl<'a,'b> Repr for Match<'a,'b> {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
if tcx.sess.verbose() {
|
||||
// for many programs, this just take too long to serialize
|
||||
self.pats.repr(tcx)
|
||||
|
@ -931,7 +931,7 @@ fn enter_region<'r,
|
|||
// on a set of enum variants or a literal.
|
||||
fn get_options(bcx: &Block, m: &[Match], col: uint) -> Vec<Opt> {
|
||||
let ccx = bcx.ccx();
|
||||
fn add_to_set(tcx: ty::ctxt, set: &mut Vec<Opt> , val: Opt) {
|
||||
fn add_to_set(tcx: &ty::ctxt, set: &mut Vec<Opt>, val: Opt) {
|
||||
if set.iter().any(|l| opt_eq(tcx, l, &val)) {return;}
|
||||
set.push(val);
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr {
|
|||
|
||||
/// Determine, without doing translation, whether an ADT must be FFI-safe.
|
||||
/// For use in lint or similar, where being sound but slightly incomplete is acceptable.
|
||||
pub fn is_ffi_safe(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
|
||||
pub fn is_ffi_safe(tcx: &ty::ctxt, def_id: ast::DefId) -> bool {
|
||||
match ty::get(ty::lookup_item_type(tcx, def_id).ty).sty {
|
||||
ty::ty_enum(def_id, _) => {
|
||||
let variants = ty::enum_variants(tcx, def_id);
|
||||
|
@ -274,7 +274,7 @@ impl Case {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_cases(tcx: ty::ctxt, def_id: ast::DefId, substs: &ty::substs) -> Vec<Case> {
|
||||
fn get_cases(tcx: &ty::ctxt, def_id: ast::DefId, substs: &ty::substs) -> Vec<Case> {
|
||||
ty::enum_variants(tcx, def_id).map(|vi| {
|
||||
let arg_tys = vi.args.map(|&raw_ty| {
|
||||
ty::subst(tcx, substs, raw_ty)
|
||||
|
|
|
@ -135,15 +135,15 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
|
|||
_InsnCtxt { _x: () }
|
||||
}
|
||||
|
||||
pub struct StatRecorder {
|
||||
ccx: @CrateContext,
|
||||
pub struct StatRecorder<'a> {
|
||||
ccx: @CrateContext<'a>,
|
||||
name: Option<~str>,
|
||||
start: u64,
|
||||
istart: uint,
|
||||
}
|
||||
|
||||
impl StatRecorder {
|
||||
pub fn new(ccx: @CrateContext, name: ~str) -> StatRecorder {
|
||||
impl<'a> StatRecorder<'a> {
|
||||
pub fn new(ccx: @CrateContext<'a>, name: ~str) -> StatRecorder<'a> {
|
||||
let start = if ccx.sess().trans_stats() {
|
||||
time::precise_time_ns()
|
||||
} else {
|
||||
|
@ -160,7 +160,7 @@ impl StatRecorder {
|
|||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl Drop for StatRecorder {
|
||||
impl<'a> Drop for StatRecorder<'a> {
|
||||
fn drop(&mut self) {
|
||||
if self.ccx.sess().trans_stats() {
|
||||
let end = time::precise_time_ns();
|
||||
|
@ -1225,7 +1225,7 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
|
|||
//
|
||||
// Be warned! You must call `init_function` before doing anything with the
|
||||
// returned function context.
|
||||
pub fn new_fn_ctxt<'a>(ccx: @CrateContext,
|
||||
pub fn new_fn_ctxt<'a>(ccx: @CrateContext<'a>,
|
||||
llfndecl: ValueRef,
|
||||
id: ast::NodeId,
|
||||
has_env: bool,
|
||||
|
@ -1670,11 +1670,11 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::EnumDef,
|
|||
}
|
||||
}
|
||||
|
||||
pub struct TransItemVisitor {
|
||||
ccx: @CrateContext,
|
||||
pub struct TransItemVisitor<'a> {
|
||||
ccx: @CrateContext<'a>,
|
||||
}
|
||||
|
||||
impl Visitor<()> for TransItemVisitor {
|
||||
impl<'a> Visitor<()> for TransItemVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &ast::Item, _:()) {
|
||||
trans_item(self.ccx, i);
|
||||
}
|
||||
|
@ -2552,7 +2552,7 @@ pub fn trans_crate(krate: ast::Crate,
|
|||
let llmod_id = link_meta.crateid.name + ".rs";
|
||||
|
||||
let ccx = @CrateContext::new(llmod_id,
|
||||
analysis.ty_cx,
|
||||
&analysis.ty_cx,
|
||||
analysis.exp_map2,
|
||||
analysis.maps,
|
||||
Sha256::new(),
|
||||
|
|
|
@ -25,7 +25,7 @@ use syntax::codemap::Span;
|
|||
|
||||
pub struct Builder<'a> {
|
||||
llbuilder: BuilderRef,
|
||||
ccx: &'a CrateContext,
|
||||
ccx: &'a CrateContext<'a>,
|
||||
}
|
||||
|
||||
// This is a really awful way to get a zero-length c-string, but better (and a
|
||||
|
|
|
@ -846,7 +846,7 @@ impl Cleanup for FreeValue {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn temporary_scope(tcx: ty::ctxt,
|
||||
pub fn temporary_scope(tcx: &ty::ctxt,
|
||||
id: ast::NodeId)
|
||||
-> ScopeId {
|
||||
match tcx.region_maps.temporary_scope(id) {
|
||||
|
@ -861,7 +861,7 @@ pub fn temporary_scope(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn var_scope(tcx: ty::ctxt,
|
||||
pub fn var_scope(tcx: &ty::ctxt,
|
||||
id: ast::NodeId)
|
||||
-> ScopeId {
|
||||
let r = AstScope(tcx.region_maps.var_scope(id));
|
||||
|
|
|
@ -133,7 +133,7 @@ impl EnvValue {
|
|||
}
|
||||
|
||||
// Given a closure ty, emits a corresponding tuple ty
|
||||
pub fn mk_closure_tys(tcx: ty::ctxt,
|
||||
pub fn mk_closure_tys(tcx: &ty::ctxt,
|
||||
bound_values: &[EnvValue])
|
||||
-> ty::t {
|
||||
// determine the types of the values in the env. Note that this
|
||||
|
@ -151,7 +151,7 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
|
|||
return cdata_ty;
|
||||
}
|
||||
|
||||
fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
|
||||
fn tuplify_box_ty(tcx: &ty::ctxt, t: ty::t) -> ty::t {
|
||||
let ptr = ty::mk_imm_ptr(tcx, ty::mk_i8());
|
||||
ty::mk_tup(tcx, vec!(ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t))
|
||||
}
|
||||
|
|
|
@ -207,14 +207,14 @@ impl param_substs {
|
|||
}
|
||||
}
|
||||
|
||||
fn param_substs_to_str(this: ¶m_substs, tcx: ty::ctxt) -> ~str {
|
||||
fn param_substs_to_str(this: ¶m_substs, tcx: &ty::ctxt) -> ~str {
|
||||
format!("param_substs \\{tys:{}, vtables:{}\\}",
|
||||
this.tys.repr(tcx),
|
||||
this.vtables.repr(tcx))
|
||||
}
|
||||
|
||||
impl Repr for param_substs {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
param_substs_to_str(self, tcx)
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ pub struct FunctionContext<'a> {
|
|||
block_arena: &'a TypedArena<Block<'a>>,
|
||||
|
||||
// This function's enclosing crate context.
|
||||
ccx: @CrateContext,
|
||||
ccx: @CrateContext<'a>,
|
||||
|
||||
// Used and maintained by the debuginfo module.
|
||||
debug_context: debuginfo::FunctionDebugContext,
|
||||
|
@ -435,8 +435,8 @@ impl<'a> Block<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn ccx(&self) -> @CrateContext { self.fcx.ccx }
|
||||
pub fn tcx(&self) -> ty::ctxt {
|
||||
pub fn ccx(&self) -> @CrateContext<'a> { self.fcx.ccx }
|
||||
pub fn tcx(&self) -> &'a ty::ctxt {
|
||||
self.fcx.ccx.tcx
|
||||
}
|
||||
pub fn sess(&self) -> &'a Session { self.fcx.ccx.sess() }
|
||||
|
@ -858,7 +858,7 @@ pub fn resolve_vtables_in_fn_ctxt(fcx: &FunctionContext, vts: typeck::vtable_res
|
|||
vts)
|
||||
}
|
||||
|
||||
pub fn resolve_vtables_under_param_substs(tcx: ty::ctxt,
|
||||
pub fn resolve_vtables_under_param_substs(tcx: &ty::ctxt,
|
||||
param_substs: Option<@param_substs>,
|
||||
vts: typeck::vtable_res)
|
||||
-> typeck::vtable_res {
|
||||
|
@ -870,7 +870,7 @@ pub fn resolve_vtables_under_param_substs(tcx: ty::ctxt,
|
|||
}
|
||||
|
||||
pub fn resolve_param_vtables_under_param_substs(
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
param_substs: Option<@param_substs>,
|
||||
ds: typeck::vtable_param_res)
|
||||
-> typeck::vtable_param_res {
|
||||
|
@ -883,7 +883,7 @@ pub fn resolve_param_vtables_under_param_substs(
|
|||
|
||||
|
||||
|
||||
pub fn resolve_vtable_under_param_substs(tcx: ty::ctxt,
|
||||
pub fn resolve_vtable_under_param_substs(tcx: &ty::ctxt,
|
||||
param_substs: Option<@param_substs>,
|
||||
vt: &typeck::vtable_origin)
|
||||
-> typeck::vtable_origin {
|
||||
|
@ -919,7 +919,7 @@ pub fn resolve_vtable_under_param_substs(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find_vtable(tcx: ty::ctxt,
|
||||
pub fn find_vtable(tcx: &ty::ctxt,
|
||||
ps: ¶m_substs,
|
||||
n_param: typeck::param_index,
|
||||
n_bound: uint)
|
||||
|
|
|
@ -38,7 +38,7 @@ use collections::{HashMap, HashSet};
|
|||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
|
||||
pub struct CrateContext {
|
||||
pub struct CrateContext<'a> {
|
||||
llmod: ModuleRef,
|
||||
llcx: ContextRef,
|
||||
metadata_llmod: ModuleRef,
|
||||
|
@ -100,7 +100,7 @@ pub struct CrateContext {
|
|||
symbol_hasher: RefCell<Sha256>,
|
||||
type_hashcodes: RefCell<HashMap<ty::t, ~str>>,
|
||||
all_llvm_symbols: RefCell<HashSet<~str>>,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
maps: astencode::Maps,
|
||||
stats: @Stats,
|
||||
tydesc_type: Type,
|
||||
|
@ -116,15 +116,15 @@ pub struct CrateContext {
|
|||
dbg_cx: Option<debuginfo::CrateDebugContext>,
|
||||
}
|
||||
|
||||
impl CrateContext {
|
||||
impl<'a> CrateContext<'a> {
|
||||
pub fn new(name: &str,
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
emap2: resolve::ExportMap2,
|
||||
maps: astencode::Maps,
|
||||
symbol_hasher: Sha256,
|
||||
link_meta: LinkMeta,
|
||||
reachable: @RefCell<NodeSet>)
|
||||
-> CrateContext {
|
||||
-> CrateContext<'a> {
|
||||
unsafe {
|
||||
let llcx = llvm::LLVMContextCreate();
|
||||
set_task_llcx(llcx);
|
||||
|
@ -275,7 +275,7 @@ impl CrateContext {
|
|||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl Drop for CrateContext {
|
||||
impl<'a> Drop for CrateContext<'a> {
|
||||
fn drop(&mut self) {
|
||||
unset_task_llcx();
|
||||
}
|
||||
|
|
|
@ -709,11 +709,11 @@ impl<'a> DatumBlock<'a, Expr> {
|
|||
self.datum.shallow_copy(self.bcx, dst)
|
||||
}
|
||||
|
||||
pub fn ccx(&self) -> @CrateContext {
|
||||
pub fn ccx(&self) -> @CrateContext<'a> {
|
||||
self.bcx.ccx()
|
||||
}
|
||||
|
||||
pub fn tcx(&self) -> ty::ctxt {
|
||||
pub fn tcx(&self) -> &'a ty::ctxt {
|
||||
self.bcx.tcx()
|
||||
}
|
||||
|
||||
|
|
|
@ -940,7 +940,7 @@ pub fn trans_local_var<'a>(bcx: &'a Block<'a>,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn with_field_tys<R>(tcx: ty::ctxt,
|
||||
pub fn with_field_tys<R>(tcx: &ty::ctxt,
|
||||
ty: ty::t,
|
||||
node_id_opt: Option<ast::NodeId>,
|
||||
op: |ty::Disr, (&[ty::field])| -> R)
|
||||
|
|
|
@ -38,7 +38,7 @@ use syntax::parse::token::InternedString;
|
|||
// containing an unboxed vector. This expands a boxed vector type into such an
|
||||
// expanded type. It doesn't respect mutability, but that doesn't matter at
|
||||
// this point.
|
||||
pub fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
|
||||
pub fn expand_boxed_vec_ty(tcx: &ty::ctxt, t: ty::t) -> ty::t {
|
||||
let unit_ty = ty::sequence_element_type(tcx, t);
|
||||
let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty);
|
||||
match ty::get(t).sty {
|
||||
|
@ -441,7 +441,7 @@ pub fn write_content<'a>(
|
|||
return expr::trans_into(bcx, element, Ignore);
|
||||
}
|
||||
SaveIn(lldest) => {
|
||||
let count = ty::eval_repeat_count(&bcx.tcx(), count_expr);
|
||||
let count = ty::eval_repeat_count(bcx.tcx(), count_expr);
|
||||
if count == 0 {
|
||||
return bcx;
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint {
|
|||
},
|
||||
ast::ExprVec(ref es, _) => es.len(),
|
||||
ast::ExprRepeat(_, count_expr, _) => {
|
||||
ty::eval_repeat_count(&bcx.tcx(), count_expr)
|
||||
ty::eval_repeat_count(bcx.tcx(), count_expr)
|
||||
}
|
||||
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected vec content")
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@ use util::ppaux::Repr;
|
|||
use std::vec_ng::Vec;
|
||||
|
||||
pub trait TypeFolder {
|
||||
fn tcx(&self) -> ty::ctxt;
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt;
|
||||
|
||||
fn fold_ty(&mut self, t: ty::t) -> ty::t {
|
||||
super_fold_ty(self, t)
|
||||
|
@ -93,7 +93,8 @@ pub fn fold_ty_vec<T:TypeFolder>(this: &mut T, tys: &[ty::t]) -> Vec<ty::t> {
|
|||
pub fn super_fold_ty<T:TypeFolder>(this: &mut T,
|
||||
t: ty::t)
|
||||
-> ty::t {
|
||||
ty::mk_t(this.tcx(), this.fold_sty(&ty::get(t).sty))
|
||||
let sty = this.fold_sty(&ty::get(t).sty);
|
||||
ty::mk_t(this.tcx(), sty)
|
||||
}
|
||||
|
||||
pub fn super_fold_substs<T:TypeFolder>(this: &mut T,
|
||||
|
@ -218,12 +219,12 @@ pub fn super_fold_trait_store<T:TypeFolder>(this: &mut T,
|
|||
// Some sample folders
|
||||
|
||||
pub struct BottomUpFolder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
fldop: 'a |ty::t| -> ty::t,
|
||||
}
|
||||
|
||||
impl<'a> TypeFolder for BottomUpFolder<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: ty::t) -> ty::t {
|
||||
let t1 = super_fold_ty(self, ty);
|
||||
|
@ -235,13 +236,13 @@ impl<'a> TypeFolder for BottomUpFolder<'a> {
|
|||
// Region folder
|
||||
|
||||
pub struct RegionFolder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
fld_t: 'a |ty::t| -> ty::t,
|
||||
fld_r: 'a |ty::Region| -> ty::Region,
|
||||
}
|
||||
|
||||
impl<'a> RegionFolder<'a> {
|
||||
pub fn general(tcx: ty::ctxt,
|
||||
pub fn general(tcx: &'a ty::ctxt,
|
||||
fld_r: 'a |ty::Region| -> ty::Region,
|
||||
fld_t: 'a |ty::t| -> ty::t)
|
||||
-> RegionFolder<'a> {
|
||||
|
@ -252,7 +253,7 @@ impl<'a> RegionFolder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn regions(tcx: ty::ctxt, fld_r: 'a |ty::Region| -> ty::Region)
|
||||
pub fn regions(tcx: &'a ty::ctxt, fld_r: 'a |ty::Region| -> ty::Region)
|
||||
-> RegionFolder<'a> {
|
||||
fn noop(t: ty::t) -> ty::t { t }
|
||||
|
||||
|
@ -265,7 +266,7 @@ impl<'a> RegionFolder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> TypeFolder for RegionFolder<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: ty::t) -> ty::t {
|
||||
debug!("RegionFolder.fold_ty({})", ty.repr(self.tcx()));
|
||||
|
|
|
@ -69,7 +69,7 @@ use syntax::opt_vec;
|
|||
use syntax::print::pprust::{lifetime_to_str, path_to_str};
|
||||
|
||||
pub trait AstConv {
|
||||
fn tcx(&self) -> ty::ctxt;
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt;
|
||||
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty;
|
||||
fn get_trait_def(&self, id: ast::DefId) -> @ty::TraitDef;
|
||||
|
||||
|
@ -77,7 +77,7 @@ pub trait AstConv {
|
|||
fn ty_infer(&self, span: Span) -> ty::t;
|
||||
}
|
||||
|
||||
pub fn ast_region_to_region(tcx: ty::ctxt, lifetime: &ast::Lifetime)
|
||||
pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime)
|
||||
-> ty::Region {
|
||||
let named_region_map = tcx.named_region_map.borrow();
|
||||
let r = match named_region_map.get().find(&lifetime.id) {
|
||||
|
@ -304,7 +304,7 @@ pub fn ast_path_to_ty<AC:AstConv,RS:RegionScope>(
|
|||
pub static NO_REGIONS: uint = 1;
|
||||
pub static NO_TPS: uint = 2;
|
||||
|
||||
fn check_path_args(tcx: ty::ctxt,
|
||||
fn check_path_args(tcx: &ty::ctxt,
|
||||
path: &ast::Path,
|
||||
flags: uint) {
|
||||
if (flags & NO_TPS) != 0u {
|
||||
|
@ -324,7 +324,7 @@ fn check_path_args(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ast_ty_to_prim_ty(tcx: ty::ctxt, ast_ty: &ast::Ty) -> Option<ty::t> {
|
||||
pub fn ast_ty_to_prim_ty(tcx: &ty::ctxt, ast_ty: &ast::Ty) -> Option<ty::t> {
|
||||
match ast_ty.node {
|
||||
ast::TyPath(ref path, _, id) => {
|
||||
let def_map = tcx.def_map.borrow();
|
||||
|
@ -393,7 +393,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
|||
VStore(ty::vstore)
|
||||
}
|
||||
impl PointerTy {
|
||||
fn expect_vstore(&self, tcx: ty::ctxt, span: Span, ty: &str) -> ty::vstore {
|
||||
fn expect_vstore(&self, tcx: &ty::ctxt, span: Span, ty: &str) -> ty::vstore {
|
||||
match *self {
|
||||
Box => {
|
||||
tcx.sess.span_err(span, format!("managed {} are not supported", ty));
|
||||
|
@ -614,7 +614,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
|||
}
|
||||
}
|
||||
ast::TyFixedLengthVec(ty, e) => {
|
||||
match const_eval::eval_const_expr_partial(&tcx, e) {
|
||||
match const_eval::eval_const_expr_partial(tcx, e) {
|
||||
Ok(ref r) => {
|
||||
match *r {
|
||||
const_eval::const_int(i) =>
|
||||
|
@ -818,7 +818,7 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>(
|
|||
}
|
||||
}
|
||||
|
||||
fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option<OptVec<ast::TyParamBound>>,
|
||||
fn conv_builtin_bounds(tcx: &ty::ctxt, ast_bounds: &Option<OptVec<ast::TyParamBound>>,
|
||||
store: ty::TraitStore)
|
||||
-> ty::BuiltinBounds {
|
||||
//! Converts a list of bounds from the AST into a `BuiltinBounds`
|
||||
|
|
|
@ -103,8 +103,8 @@ pub fn check_match(fcx: @FnCtxt,
|
|||
fcx.write_ty(expr.id, result_ty);
|
||||
}
|
||||
|
||||
pub struct pat_ctxt {
|
||||
fcx: @FnCtxt,
|
||||
pub struct pat_ctxt<'a> {
|
||||
fcx: @FnCtxt<'a>,
|
||||
map: PatIdMap,
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ pub fn lookup_in_trait<'a>(
|
|||
}
|
||||
|
||||
struct LookupContext<'a> {
|
||||
fcx: @FnCtxt,
|
||||
fcx: @FnCtxt<'a>,
|
||||
span: Span,
|
||||
|
||||
// The receiver to the method call. Only `None` in the case of
|
||||
|
@ -1422,11 +1422,11 @@ impl<'a> LookupContext<'a> {
|
|||
ty::item_path_str(self.tcx(), did)));
|
||||
}
|
||||
|
||||
fn infcx(&'a self) -> &'a infer::InferCtxt {
|
||||
fn infcx(&'a self) -> &'a infer::InferCtxt<'a> {
|
||||
&self.fcx.inh.infcx
|
||||
}
|
||||
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
fn tcx(&'a self) -> &'a ty::ctxt {
|
||||
self.fcx.tcx()
|
||||
}
|
||||
|
||||
|
@ -1445,7 +1445,7 @@ impl<'a> LookupContext<'a> {
|
|||
}
|
||||
|
||||
impl Repr for Candidate {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
format!("Candidate(rcvr_ty={}, rcvr_substs={}, origin={:?})",
|
||||
self.rcvr_match_condition.repr(tcx),
|
||||
self.rcvr_substs.repr(tcx),
|
||||
|
@ -1454,7 +1454,7 @@ impl Repr for Candidate {
|
|||
}
|
||||
|
||||
impl Repr for RcvrMatchCondition {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
RcvrMatchesIfObject(d) => {
|
||||
format!("RcvrMatchesIfObject({})", d.repr(tcx))
|
||||
|
|
|
@ -155,8 +155,8 @@ pub mod method;
|
|||
/// Here, the function `foo()` and the closure passed to
|
||||
/// `bar()` will each have their own `FnCtxt`, but they will
|
||||
/// share the inherited fields.
|
||||
pub struct Inherited {
|
||||
infcx: infer::InferCtxt,
|
||||
pub struct Inherited<'a> {
|
||||
infcx: infer::InferCtxt<'a>,
|
||||
locals: @RefCell<NodeMap<ty::t>>,
|
||||
param_env: ty::ParameterEnvironment,
|
||||
|
||||
|
@ -221,7 +221,7 @@ enum IsBinopAssignment{
|
|||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct FnCtxt {
|
||||
pub struct FnCtxt<'a> {
|
||||
// Number of errors that had been reported when we started
|
||||
// checking this function. On exit, if we find that *more* errors
|
||||
// have been reported, we will skip regionck and other work that
|
||||
|
@ -251,15 +251,15 @@ pub struct FnCtxt {
|
|||
// function return type.
|
||||
fn_kind: FnKind,
|
||||
|
||||
inh: @Inherited,
|
||||
inh: @Inherited<'a>,
|
||||
|
||||
ccx: @CrateCtxt,
|
||||
ccx: @CrateCtxt<'a>,
|
||||
}
|
||||
|
||||
impl Inherited {
|
||||
fn new(tcx: ty::ctxt,
|
||||
impl<'a> Inherited<'a> {
|
||||
fn new(tcx: &'a ty::ctxt,
|
||||
param_env: ty::ParameterEnvironment)
|
||||
-> Inherited {
|
||||
-> Inherited<'a> {
|
||||
Inherited {
|
||||
infcx: infer::new_infer_ctxt(tcx),
|
||||
locals: @RefCell::new(NodeMap::new()),
|
||||
|
@ -275,10 +275,10 @@ impl Inherited {
|
|||
}
|
||||
|
||||
// Used by check_const and check_enum_variants
|
||||
pub fn blank_fn_ctxt(ccx: @CrateCtxt,
|
||||
pub fn blank_fn_ctxt<'a>(ccx: @CrateCtxt<'a>,
|
||||
rty: ty::t,
|
||||
region_bnd: ast::NodeId)
|
||||
-> @FnCtxt {
|
||||
-> @FnCtxt<'a> {
|
||||
// It's kind of a kludge to manufacture a fake function context
|
||||
// and statement context, but we might as well do write the code only once
|
||||
let param_env = ty::ParameterEnvironment { free_substs: substs::empty(),
|
||||
|
@ -295,19 +295,19 @@ pub fn blank_fn_ctxt(ccx: @CrateCtxt,
|
|||
}
|
||||
}
|
||||
|
||||
impl ExprTyProvider for FnCtxt {
|
||||
impl<'a> ExprTyProvider for FnCtxt<'a> {
|
||||
fn expr_ty(&self, ex: &ast::Expr) -> ty::t {
|
||||
self.expr_ty(ex)
|
||||
}
|
||||
|
||||
fn ty_ctxt(&self) -> ty::ctxt {
|
||||
fn ty_ctxt<'a>(&'a self) -> &'a ty::ctxt {
|
||||
self.ccx.tcx
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckItemTypesVisitor { ccx: @CrateCtxt }
|
||||
struct CheckItemTypesVisitor<'a> { ccx: @CrateCtxt<'a> }
|
||||
|
||||
impl Visitor<()> for CheckItemTypesVisitor {
|
||||
impl<'a> Visitor<()> for CheckItemTypesVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &ast::Item, _: ()) {
|
||||
check_item(self.ccx, i);
|
||||
visit::walk_item(self, i, ());
|
||||
|
@ -340,12 +340,11 @@ fn check_bare_fn(ccx: @CrateCtxt,
|
|||
}
|
||||
}
|
||||
|
||||
struct GatherLocalsVisitor {
|
||||
fcx: @FnCtxt,
|
||||
tcx: ty::ctxt,
|
||||
struct GatherLocalsVisitor<'a> {
|
||||
fcx: @FnCtxt<'a>
|
||||
}
|
||||
|
||||
impl GatherLocalsVisitor {
|
||||
impl<'a> GatherLocalsVisitor<'a> {
|
||||
fn assign(&mut self, nid: ast::NodeId, ty_opt: Option<ty::t>) {
|
||||
match ty_opt {
|
||||
None => {
|
||||
|
@ -364,7 +363,7 @@ impl GatherLocalsVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor<()> for GatherLocalsVisitor {
|
||||
impl<'a> Visitor<()> for GatherLocalsVisitor<'a> {
|
||||
// Add explicitly-declared locals.
|
||||
fn visit_local(&mut self, local: &ast::Local, _: ()) {
|
||||
let o_ty = match local.ty.node {
|
||||
|
@ -416,14 +415,14 @@ impl Visitor<()> for GatherLocalsVisitor {
|
|||
|
||||
}
|
||||
|
||||
fn check_fn(ccx: @CrateCtxt,
|
||||
fn check_fn<'a>(ccx: @CrateCtxt<'a>,
|
||||
purity: ast::Purity,
|
||||
fn_sig: &ty::FnSig,
|
||||
decl: &ast::FnDecl,
|
||||
id: ast::NodeId,
|
||||
body: &ast::Block,
|
||||
fn_kind: FnKind,
|
||||
inherited: @Inherited) -> @FnCtxt
|
||||
inherited: @Inherited<'a>) -> @FnCtxt<'a>
|
||||
{
|
||||
/*!
|
||||
* Helper used by check_bare_fn and check_expr_fn. Does the
|
||||
|
@ -467,7 +466,7 @@ fn check_fn(ccx: @CrateCtxt,
|
|||
|
||||
{
|
||||
|
||||
let mut visit = GatherLocalsVisitor { fcx: fcx, tcx: tcx, };
|
||||
let mut visit = GatherLocalsVisitor { fcx: fcx, };
|
||||
// Add formal parameters.
|
||||
for (arg_ty, input) in arg_tys.iter().zip(decl.inputs.iter()) {
|
||||
// Create type variables for each argument.
|
||||
|
@ -512,7 +511,7 @@ fn check_fn(ccx: @CrateCtxt,
|
|||
fcx
|
||||
}
|
||||
|
||||
pub fn check_no_duplicate_fields(tcx: ty::ctxt,
|
||||
pub fn check_no_duplicate_fields(tcx: &ty::ctxt,
|
||||
fields: Vec<(ast::Ident, Span)>) {
|
||||
let mut field_names = HashMap::new();
|
||||
|
||||
|
@ -769,7 +768,7 @@ fn check_impl_methods_against_trait(ccx: @CrateCtxt,
|
|||
* - trait_m: the method in the trait
|
||||
* - trait_substs: the substitutions used on the type of the trait
|
||||
*/
|
||||
fn compare_impl_method(tcx: ty::ctxt,
|
||||
fn compare_impl_method(tcx: &ty::ctxt,
|
||||
impl_generics: &ty::Generics,
|
||||
impl_m: @ty::Method,
|
||||
impl_m_span: Span,
|
||||
|
@ -956,8 +955,8 @@ fn compare_impl_method(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
impl AstConv for FnCtxt {
|
||||
fn tcx(&self) -> ty::ctxt { self.ccx.tcx }
|
||||
impl<'a> AstConv for FnCtxt<'a> {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.ccx.tcx }
|
||||
|
||||
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
|
||||
ty::lookup_item_type(self.tcx(), id)
|
||||
|
@ -972,8 +971,8 @@ impl AstConv for FnCtxt {
|
|||
}
|
||||
}
|
||||
|
||||
impl FnCtxt {
|
||||
pub fn infcx<'a>(&'a self) -> &'a infer::InferCtxt {
|
||||
impl<'a> FnCtxt<'a> {
|
||||
pub fn infcx<'b>(&'b self) -> &'b infer::InferCtxt<'a> {
|
||||
&self.inh.infcx
|
||||
}
|
||||
|
||||
|
@ -989,7 +988,7 @@ impl FnCtxt {
|
|||
}
|
||||
}
|
||||
|
||||
impl RegionScope for infer::InferCtxt {
|
||||
impl<'a> RegionScope for infer::InferCtxt<'a> {
|
||||
fn anon_regions(&self, span: Span, count: uint)
|
||||
-> Result<Vec<ty::Region> , ()> {
|
||||
Ok(Vec::from_fn(count, |_| {
|
||||
|
@ -998,7 +997,7 @@ impl RegionScope for infer::InferCtxt {
|
|||
}
|
||||
}
|
||||
|
||||
impl FnCtxt {
|
||||
impl<'a> FnCtxt<'a> {
|
||||
pub fn tag(&self) -> ~str {
|
||||
format!("{}", self as *FnCtxt)
|
||||
}
|
||||
|
@ -1444,7 +1443,7 @@ pub fn impl_self_ty(vcx: &VtableContext,
|
|||
|
||||
// Only for fields! Returns <none> for methods>
|
||||
// Indifferent to privacy flags
|
||||
pub fn lookup_field_ty(tcx: ty::ctxt,
|
||||
pub fn lookup_field_ty(tcx: &ty::ctxt,
|
||||
class_id: ast::DefId,
|
||||
items: &[ty::field_ty],
|
||||
fieldname: ast::Name,
|
||||
|
@ -1463,7 +1462,7 @@ pub enum DerefArgs {
|
|||
|
||||
// Given the provenance of a static method, returns the generics of the static
|
||||
// method's container.
|
||||
fn generics_of_static_method_container(type_context: ty::ctxt,
|
||||
fn generics_of_static_method_container(type_context: &ty::ctxt,
|
||||
provenance: ast::MethodProvenance)
|
||||
-> ty::Generics {
|
||||
match provenance {
|
||||
|
@ -3413,7 +3412,7 @@ pub fn check_const_with_ty(fcx: @FnCtxt,
|
|||
/// pointer, which would mean their size is unbounded. This is different from
|
||||
/// the question of whether a type can be instantiated. See the definition of
|
||||
/// `check_instantiable`.
|
||||
pub fn check_representable(tcx: ty::ctxt,
|
||||
pub fn check_representable(tcx: &ty::ctxt,
|
||||
sp: Span,
|
||||
item_id: ast::NodeId,
|
||||
designation: &str) {
|
||||
|
@ -3446,7 +3445,7 @@ pub fn check_representable(tcx: ty::ctxt,
|
|||
/// enum foo { Some(@foo) }
|
||||
///
|
||||
/// is representable, but not instantiable.
|
||||
pub fn check_instantiable(tcx: ty::ctxt,
|
||||
pub fn check_instantiable(tcx: &ty::ctxt,
|
||||
sp: Span,
|
||||
item_id: ast::NodeId) {
|
||||
let item_ty = ty::node_id_to_type(tcx, item_id);
|
||||
|
@ -3458,7 +3457,7 @@ pub fn check_instantiable(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_simd(tcx: ty::ctxt, sp: Span, id: ast::NodeId) {
|
||||
pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
|
||||
let t = ty::node_id_to_type(tcx, id);
|
||||
if ty::type_needs_subst(t) {
|
||||
tcx.sess.span_err(sp, "SIMD vector cannot be generic");
|
||||
|
@ -3550,7 +3549,7 @@ pub fn check_enum_variants(ccx: @CrateCtxt,
|
|||
// that the expression is in an form that eval_const_expr can
|
||||
// handle, so we may still get an internal compiler error
|
||||
|
||||
match const_eval::eval_const_expr_partial(&ccx.tcx, e) {
|
||||
match const_eval::eval_const_expr_partial(ccx.tcx, e) {
|
||||
Ok(const_eval::const_int(val)) => current_disr_val = val as Disr,
|
||||
Ok(const_eval::const_uint(val)) => current_disr_val = val as Disr,
|
||||
Ok(_) => {
|
||||
|
@ -3939,7 +3938,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: @FnCtxt,
|
|||
}
|
||||
|
||||
// Returns true if b contains a break that can exit from b
|
||||
pub fn may_break(cx: ty::ctxt, id: ast::NodeId, b: ast::P<ast::Block>) -> bool {
|
||||
pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: ast::P<ast::Block>) -> bool {
|
||||
// First: is there an unlabeled break immediately
|
||||
// inside the loop?
|
||||
(loop_query(b, |e| {
|
||||
|
|
|
@ -154,15 +154,15 @@ macro_rules! ignore_err(
|
|||
)
|
||||
)
|
||||
|
||||
pub struct Rcx {
|
||||
fcx: @FnCtxt,
|
||||
pub struct Rcx<'a> {
|
||||
fcx: &'a FnCtxt<'a>,
|
||||
errors_reported: uint,
|
||||
|
||||
// id of innermost fn or loop
|
||||
repeating_scope: ast::NodeId,
|
||||
}
|
||||
|
||||
fn region_of_def(fcx: @FnCtxt, def: ast::Def) -> ty::Region {
|
||||
fn region_of_def(fcx: &FnCtxt, def: ast::Def) -> ty::Region {
|
||||
/*!
|
||||
* Returns the validity region of `def` -- that is, how long
|
||||
* is `def` valid?
|
||||
|
@ -187,8 +187,8 @@ fn region_of_def(fcx: @FnCtxt, def: ast::Def) -> ty::Region {
|
|||
}
|
||||
}
|
||||
|
||||
impl Rcx {
|
||||
pub fn tcx(&self) -> ty::ctxt {
|
||||
impl<'a> Rcx<'a> {
|
||||
pub fn tcx(&self) -> &'a ty::ctxt {
|
||||
self.fcx.ccx.tcx
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ impl Rcx {
|
|||
old_scope
|
||||
}
|
||||
|
||||
pub fn resolve_type(&mut self, unresolved_ty: ty::t) -> ty::t {
|
||||
pub fn resolve_type(&self, unresolved_ty: ty::t) -> ty::t {
|
||||
/*!
|
||||
* Try to resolve the type for the given node, returning
|
||||
* t_err if an error results. Note that we never care
|
||||
|
@ -240,7 +240,7 @@ impl Rcx {
|
|||
self.resolve_type(t)
|
||||
}
|
||||
|
||||
fn resolve_method_type(&mut self, method_call: MethodCall) -> Option<ty::t> {
|
||||
fn resolve_method_type(&self, method_call: MethodCall) -> Option<ty::t> {
|
||||
let method_ty = self.fcx.inh.method_map.borrow().get()
|
||||
.find(&method_call).map(|method| method.ty);
|
||||
method_ty.map(|method_ty| self.resolve_type(method_ty))
|
||||
|
@ -260,8 +260,8 @@ impl Rcx {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> mc::Typer for &'a mut Rcx {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
impl<'a, 'b> mc::Typer for &'a mut Rcx<'b> {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt {
|
||||
self.fcx.tcx()
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ impl<'a> mc::Typer for &'a mut Rcx {
|
|||
if ty::type_is_error(t) {Err(())} else {Ok(t)}
|
||||
}
|
||||
|
||||
fn node_method_ty(&mut self, method_call: MethodCall) -> Option<ty::t> {
|
||||
fn node_method_ty(&self, method_call: MethodCall) -> Option<ty::t> {
|
||||
self.resolve_method_type(method_call)
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ pub fn regionck_fn(fcx: @FnCtxt, blk: &ast::Block) {
|
|||
fcx.infcx().resolve_regions();
|
||||
}
|
||||
|
||||
impl Visitor<()> for Rcx {
|
||||
impl<'a> Visitor<()> for Rcx<'a> {
|
||||
// (..) FIXME(#3238) should use visit_pat, not visit_arm/visit_local,
|
||||
// However, right now we run into an issue whereby some free
|
||||
// regions are not properly related if they appear within the
|
||||
|
|
|
@ -22,7 +22,7 @@ use util::ppaux;
|
|||
// Helper functions related to manipulating region types.
|
||||
|
||||
pub fn replace_late_bound_regions_in_fn_sig(
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
fn_sig: &ty::FnSig,
|
||||
mapf: |ty::BoundRegion| -> ty::Region)
|
||||
-> (HashMap<ty::BoundRegion,ty::Region>, ty::FnSig) {
|
||||
|
@ -45,7 +45,7 @@ pub fn replace_late_bound_regions_in_fn_sig(
|
|||
(map, fn_sig)
|
||||
}
|
||||
|
||||
pub fn relate_nested_regions(tcx: ty::ctxt,
|
||||
pub fn relate_nested_regions(tcx: &ty::ctxt,
|
||||
opt_region: Option<ty::Region>,
|
||||
ty: ty::t,
|
||||
relate_op: |ty::Region, ty::Region|) {
|
||||
|
@ -85,7 +85,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
|
|||
rr.fold_ty(ty);
|
||||
|
||||
struct RegionRelator<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
stack: Vec<ty::Region>,
|
||||
relate_op: 'a |ty::Region, ty::Region|,
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
|
|||
// well.
|
||||
|
||||
impl<'a> TypeFolder for RegionRelator<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn relate_free_regions(tcx: ty::ctxt, fn_sig: &ty::FnSig) {
|
||||
pub fn relate_free_regions(tcx: &ty::ctxt, fn_sig: &ty::FnSig) {
|
||||
/*!
|
||||
* This function populates the region map's `free_region_map`.
|
||||
* It walks over the transformed self type and argument types
|
||||
|
|
|
@ -66,12 +66,12 @@ use syntax::visit::Visitor;
|
|||
/// A vtable context includes an inference context, a crate context, and a
|
||||
/// callback function to call in case of type error.
|
||||
pub struct VtableContext<'a> {
|
||||
infcx: &'a infer::InferCtxt,
|
||||
infcx: &'a infer::InferCtxt<'a>,
|
||||
param_env: &'a ty::ParameterEnvironment,
|
||||
}
|
||||
|
||||
impl<'a> VtableContext<'a> {
|
||||
pub fn tcx(&self) -> ty::ctxt { self.infcx.tcx }
|
||||
pub fn tcx(&self) -> &'a ty::ctxt { self.infcx.tcx }
|
||||
}
|
||||
|
||||
fn has_trait_bounds(type_param_defs: &[ty::TypeParameterDef]) -> bool {
|
||||
|
@ -726,7 +726,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn resolve_impl(tcx: ty::ctxt,
|
||||
pub fn resolve_impl(tcx: &ty::ctxt,
|
||||
impl_item: &ast::Item,
|
||||
impl_generics: &ty::Generics,
|
||||
impl_trait_ref: &ty::TraitRef) {
|
||||
|
@ -783,7 +783,7 @@ pub fn resolve_impl(tcx: ty::ctxt,
|
|||
|
||||
/// Resolve vtables for a method call after typeck has finished.
|
||||
/// Used by trans to monomorphize artificial method callees (e.g. drop).
|
||||
pub fn trans_resolve_method(tcx: ty::ctxt, id: ast::NodeId,
|
||||
pub fn trans_resolve_method(tcx: &ty::ctxt, id: ast::NodeId,
|
||||
substs: &ty::substs) -> Option<vtable_res> {
|
||||
let generics = ty::lookup_item_type(tcx, ast_util::local_def(id)).generics;
|
||||
let type_param_defs = generics.type_param_defs.deref();
|
||||
|
@ -803,7 +803,7 @@ pub fn trans_resolve_method(tcx: ty::ctxt, id: ast::NodeId,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> visit::Visitor<()> for &'a FnCtxt {
|
||||
impl<'a, 'b> visit::Visitor<()> for &'a FnCtxt<'b> {
|
||||
fn visit_expr(&mut self, ex: &ast::Expr, _: ()) {
|
||||
early_resolve_expr(ex, *self, false);
|
||||
visit::walk_expr(self, ex, ());
|
||||
|
|
|
@ -254,8 +254,8 @@ fn resolve_type_vars_for_node(wbcx: &mut WbCtxt, sp: Span, id: ast::NodeId)
|
|||
}
|
||||
}
|
||||
|
||||
struct WbCtxt {
|
||||
fcx: @FnCtxt,
|
||||
struct WbCtxt<'a> {
|
||||
fcx: @FnCtxt<'a>,
|
||||
|
||||
// As soon as we hit an error we have to stop resolving
|
||||
// the entire function.
|
||||
|
@ -338,7 +338,7 @@ fn visit_item(_item: &ast::Item, _wbcx: &mut WbCtxt) {
|
|||
// Ignore items
|
||||
}
|
||||
|
||||
impl Visitor<()> for WbCtxt {
|
||||
impl<'a> Visitor<()> for WbCtxt<'a> {
|
||||
fn visit_item(&mut self, i: &ast::Item, _: ()) { visit_item(i, self); }
|
||||
fn visit_stmt(&mut self, s: &ast::Stmt, _: ()) { visit_stmt(s, self); }
|
||||
fn visit_expr(&mut self, ex:&ast::Expr, _: ()) { visit_expr(ex, self); }
|
||||
|
|
|
@ -144,13 +144,13 @@ fn get_base_type_def_id(inference_context: &InferCtxt,
|
|||
}
|
||||
}
|
||||
|
||||
struct CoherenceChecker {
|
||||
crate_context: @CrateCtxt,
|
||||
inference_context: InferCtxt,
|
||||
struct CoherenceChecker<'a> {
|
||||
crate_context: @CrateCtxt<'a>,
|
||||
inference_context: InferCtxt<'a>,
|
||||
}
|
||||
|
||||
struct CoherenceCheckVisitor<'a> {
|
||||
cc: &'a CoherenceChecker
|
||||
cc: &'a CoherenceChecker<'a>
|
||||
}
|
||||
|
||||
impl<'a> visit::Visitor<()> for CoherenceCheckVisitor<'a> {
|
||||
|
@ -176,7 +176,7 @@ impl<'a> visit::Visitor<()> for CoherenceCheckVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
struct PrivilegedScopeVisitor<'a> { cc: &'a CoherenceChecker }
|
||||
struct PrivilegedScopeVisitor<'a> { cc: &'a CoherenceChecker<'a> }
|
||||
|
||||
impl<'a> visit::Visitor<()> for PrivilegedScopeVisitor<'a> {
|
||||
fn visit_item(&mut self, item: &Item, _: ()) {
|
||||
|
@ -226,8 +226,8 @@ impl<'a> visit::Visitor<()> for PrivilegedScopeVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl CoherenceChecker {
|
||||
fn new(crate_context: @CrateCtxt) -> CoherenceChecker {
|
||||
impl<'a> CoherenceChecker<'a> {
|
||||
fn new(crate_context: @CrateCtxt<'a>) -> CoherenceChecker<'a> {
|
||||
CoherenceChecker {
|
||||
crate_context: crate_context,
|
||||
inference_context: new_infer_ctxt(crate_context.tcx),
|
||||
|
@ -762,7 +762,7 @@ impl CoherenceChecker {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn make_substs_for_receiver_types(tcx: ty::ctxt,
|
||||
pub fn make_substs_for_receiver_types(tcx: &ty::ctxt,
|
||||
impl_id: ast::DefId,
|
||||
trait_ref: &ty::TraitRef,
|
||||
method: &ty::Method)
|
||||
|
@ -810,7 +810,7 @@ pub fn make_substs_for_receiver_types(tcx: ty::ctxt,
|
|||
};
|
||||
}
|
||||
|
||||
fn subst_receiver_types_in_method_ty(tcx: ty::ctxt,
|
||||
fn subst_receiver_types_in_method_ty(tcx: &ty::ctxt,
|
||||
impl_id: ast::DefId,
|
||||
trait_ref: &ty::TraitRef,
|
||||
new_def_id: ast::DefId,
|
||||
|
|
|
@ -61,11 +61,11 @@ use syntax::print::pprust::{path_to_str};
|
|||
use syntax::visit;
|
||||
use syntax::opt_vec::OptVec;
|
||||
|
||||
struct CollectItemTypesVisitor {
|
||||
ccx: @CrateCtxt
|
||||
struct CollectItemTypesVisitor<'a> {
|
||||
ccx: @CrateCtxt<'a>
|
||||
}
|
||||
|
||||
impl visit::Visitor<()> for CollectItemTypesVisitor {
|
||||
impl<'a> visit::Visitor<()> for CollectItemTypesVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &ast::Item, _: ()) {
|
||||
convert(self.ccx, i);
|
||||
visit::walk_item(self, i, ());
|
||||
|
@ -100,14 +100,14 @@ pub trait ToTy {
|
|||
fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> ty::t;
|
||||
}
|
||||
|
||||
impl ToTy for CrateCtxt {
|
||||
impl<'a> ToTy for CrateCtxt<'a> {
|
||||
fn to_ty<RS:RegionScope>(&self, rs: &RS, ast_ty: &ast::Ty) -> ty::t {
|
||||
ast_ty_to_ty(self, rs, ast_ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl AstConv for CrateCtxt {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
impl<'a> AstConv for CrateCtxt<'a> {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
|
||||
|
||||
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
|
||||
if id.krate != ast::LOCAL_CRATE {
|
||||
|
|
|
@ -70,7 +70,7 @@ use syntax::opt_vec;
|
|||
use syntax::abi::AbiSet;
|
||||
|
||||
pub trait Combine {
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt;
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a>;
|
||||
fn tag(&self) -> ~str;
|
||||
fn a_is_expected(&self) -> bool;
|
||||
fn trace(&self) -> TypeTrace;
|
||||
|
@ -331,7 +331,7 @@ pub trait Combine {
|
|||
}
|
||||
|
||||
pub struct CombineFields<'a> {
|
||||
infcx: &'a InferCtxt,
|
||||
infcx: &'a InferCtxt<'a>,
|
||||
a_is_expected: bool,
|
||||
trace: TypeTrace,
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ trait ErrorReportingHelpers {
|
|||
generics: ast::Generics);
|
||||
}
|
||||
|
||||
impl ErrorReporting for InferCtxt {
|
||||
impl<'a> ErrorReporting for InferCtxt<'a> {
|
||||
fn report_region_errors(&self,
|
||||
errors: &OptVec<RegionResolutionError>) {
|
||||
let p_errors = self.process_errors(errors);
|
||||
|
@ -255,7 +255,7 @@ impl ErrorReporting for InferCtxt {
|
|||
scope_id: ast::NodeId
|
||||
}
|
||||
|
||||
fn free_regions_from_same_fn(tcx: ty::ctxt,
|
||||
fn free_regions_from_same_fn(tcx: &ty::ctxt,
|
||||
sub: Region,
|
||||
sup: Region)
|
||||
-> Option<FreeRegionsFromSameFn> {
|
||||
|
@ -672,7 +672,7 @@ impl ErrorReporting for InferCtxt {
|
|||
}
|
||||
|
||||
struct Rebuilder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
fn_decl: ast::P<ast::FnDecl>,
|
||||
generics: &'a ast::Generics,
|
||||
same_regions: &'a [SameRegions],
|
||||
|
@ -682,7 +682,7 @@ struct Rebuilder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Rebuilder<'a> {
|
||||
fn new(tcx: ty::ctxt,
|
||||
fn new(tcx: &'a ty::ctxt,
|
||||
fn_decl: ast::P<ast::FnDecl>,
|
||||
generics: &'a ast::Generics,
|
||||
same_regions: &'a [SameRegions])
|
||||
|
@ -1006,7 +1006,7 @@ impl<'a> Rebuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ErrorReportingHelpers for InferCtxt {
|
||||
impl<'a> ErrorReportingHelpers for InferCtxt<'a> {
|
||||
fn give_expl_lifetime_param(&self,
|
||||
inputs: Vec<ast::Arg>,
|
||||
output: ast::P<ast::Ty>,
|
||||
|
|
|
@ -35,7 +35,7 @@ impl<'f> Glb<'f> {
|
|||
}
|
||||
|
||||
impl<'f> Combine for Glb<'f> {
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt { self.get_ref().infcx }
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a> { self.get_ref().infcx }
|
||||
fn tag(&self) -> ~str { ~"glb" }
|
||||
fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected }
|
||||
fn trace(&self) -> TypeTrace { self.get_ref().trace }
|
||||
|
|
|
@ -38,7 +38,7 @@ impl<'f> Lub<'f> {
|
|||
}
|
||||
|
||||
impl<'f> Combine for Lub<'f> {
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt { self.get_ref().infcx }
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a> { self.get_ref().infcx }
|
||||
fn tag(&self) -> ~str { ~"lub" }
|
||||
fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected }
|
||||
fn trace(&self) -> TypeTrace { self.get_ref().trace }
|
||||
|
|
|
@ -75,8 +75,8 @@ pub type ures = cres<()>; // "unify result"
|
|||
pub type fres<T> = Result<T, fixup_err>; // "fixup result"
|
||||
pub type CoerceResult = cres<Option<@ty::AutoAdjustment>>;
|
||||
|
||||
pub struct InferCtxt {
|
||||
tcx: ty::ctxt,
|
||||
pub struct InferCtxt<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
|
||||
// We instantiate ValsAndBindings with bounds<ty::t> because the
|
||||
// types that might instantiate a general type variable have an
|
||||
|
@ -95,7 +95,7 @@ pub struct InferCtxt {
|
|||
float_var_counter: Cell<uint>,
|
||||
|
||||
// For region variables.
|
||||
region_vars: RegionVarBindings,
|
||||
region_vars: RegionVarBindings<'a>,
|
||||
}
|
||||
|
||||
/// Why did we require that the two types be related?
|
||||
|
@ -267,7 +267,7 @@ fn new_ValsAndBindings<V:Clone,T:Clone>() -> ValsAndBindings<V, T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_infer_ctxt(tcx: ty::ctxt) -> InferCtxt {
|
||||
pub fn new_infer_ctxt<'a>(tcx: &'a ty::ctxt) -> InferCtxt<'a> {
|
||||
InferCtxt {
|
||||
tcx: tcx,
|
||||
|
||||
|
@ -510,7 +510,7 @@ pub struct Snapshot {
|
|||
region_vars_snapshot: uint,
|
||||
}
|
||||
|
||||
impl InferCtxt {
|
||||
impl<'a> InferCtxt<'a> {
|
||||
pub fn combine_fields<'a>(&'a self, a_is_expected: bool, trace: TypeTrace)
|
||||
-> CombineFields<'a> {
|
||||
CombineFields {infcx: self,
|
||||
|
@ -609,7 +609,7 @@ fn next_simple_var<V:Clone,T:Clone>(counter: &mut uint,
|
|||
return id;
|
||||
}
|
||||
|
||||
impl InferCtxt {
|
||||
impl<'a> InferCtxt<'a> {
|
||||
pub fn next_ty_var_id(&self) -> TyVid {
|
||||
let id = self.ty_var_counter.get();
|
||||
self.ty_var_counter.set(id + 1);
|
||||
|
@ -840,7 +840,7 @@ impl InferCtxt {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fold_regions_in_sig(tcx: ty::ctxt,
|
||||
pub fn fold_regions_in_sig(tcx: &ty::ctxt,
|
||||
fn_sig: &ty::FnSig,
|
||||
fldr: |r: ty::Region| -> ty::Region)
|
||||
-> ty::FnSig {
|
||||
|
@ -854,7 +854,7 @@ impl TypeTrace {
|
|||
}
|
||||
|
||||
impl Repr for TypeTrace {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
format!("TypeTrace({})", self.origin.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ impl TypeOrigin {
|
|||
}
|
||||
|
||||
impl Repr for TypeOrigin {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
MethodCompatCheck(a) => format!("MethodCompatCheck({})", a.repr(tcx)),
|
||||
ExprAssignable(a) => format!("ExprAssignable({})", a.repr(tcx)),
|
||||
|
@ -911,7 +911,7 @@ impl SubregionOrigin {
|
|||
}
|
||||
|
||||
impl Repr for SubregionOrigin {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
Subtype(a) => format!("Subtype({})", a.repr(tcx)),
|
||||
InfStackClosure(a) => format!("InfStackClosure({})", a.repr(tcx)),
|
||||
|
@ -954,7 +954,7 @@ impl RegionVariableOrigin {
|
|||
}
|
||||
|
||||
impl Repr for RegionVariableOrigin {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
MiscVariable(a) => format!("MiscVariable({})", a.repr(tcx)),
|
||||
PatternRegion(a) => format!("PatternRegion({})", a.repr(tcx)),
|
||||
|
|
|
@ -123,8 +123,8 @@ impl SameRegions {
|
|||
|
||||
pub type CombineMap = HashMap<TwoRegions, RegionVid>;
|
||||
|
||||
pub struct RegionVarBindings {
|
||||
tcx: ty::ctxt,
|
||||
pub struct RegionVarBindings<'a> {
|
||||
tcx: &'a ty::ctxt,
|
||||
var_origins: RefCell<Vec<RegionVariableOrigin>>,
|
||||
constraints: RefCell<HashMap<Constraint, SubregionOrigin>>,
|
||||
lubs: RefCell<CombineMap>,
|
||||
|
@ -147,7 +147,7 @@ pub struct RegionVarBindings {
|
|||
values: RefCell<Option<Vec<VarValue> >>,
|
||||
}
|
||||
|
||||
pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
|
||||
pub fn RegionVarBindings<'a>(tcx: &'a ty::ctxt) -> RegionVarBindings<'a> {
|
||||
RegionVarBindings {
|
||||
tcx: tcx,
|
||||
var_origins: RefCell::new(Vec::new()),
|
||||
|
@ -161,7 +161,7 @@ pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
|
|||
}
|
||||
}
|
||||
|
||||
impl RegionVarBindings {
|
||||
impl<'a> RegionVarBindings<'a> {
|
||||
pub fn in_snapshot(&self) -> bool {
|
||||
let undo_log = self.undo_log.borrow();
|
||||
undo_log.get().len() > 0
|
||||
|
@ -572,7 +572,7 @@ impl RegionVarBindings {
|
|||
}
|
||||
}
|
||||
|
||||
impl RegionVarBindings {
|
||||
impl<'a> RegionVarBindings<'a> {
|
||||
fn is_subregion_of(&self, sub: Region, sup: Region) -> bool {
|
||||
self.tcx.region_maps.is_subregion_of(sub, sup)
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ struct RegionAndOrigin {
|
|||
|
||||
type RegionGraph = graph::Graph<(), Constraint>;
|
||||
|
||||
impl RegionVarBindings {
|
||||
impl<'a> RegionVarBindings<'a> {
|
||||
fn infer_variable_values(&self,
|
||||
errors: &mut OptVec<RegionResolutionError>)
|
||||
-> Vec<VarValue> {
|
||||
|
@ -1359,7 +1359,7 @@ impl RegionVarBindings {
|
|||
}
|
||||
|
||||
impl Repr for Constraint {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
ConstrainVarSubVar(a, b) => format!("ConstrainVarSubVar({}, {})",
|
||||
a.repr(tcx), b.repr(tcx)),
|
||||
|
|
|
@ -81,7 +81,7 @@ pub static resolve_and_force_all_but_regions: uint =
|
|||
(resolve_all | force_all) & not_regions;
|
||||
|
||||
pub struct ResolveState<'a> {
|
||||
infcx: &'a InferCtxt,
|
||||
infcx: &'a InferCtxt<'a>,
|
||||
modes: uint,
|
||||
err: Option<fixup_err>,
|
||||
v_seen: Vec<TyVid> ,
|
||||
|
@ -99,7 +99,7 @@ pub fn resolver<'a>(infcx: &'a InferCtxt, modes: uint) -> ResolveState<'a> {
|
|||
}
|
||||
|
||||
impl<'a> ty_fold::TypeFolder for ResolveState<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ impl<'f> Sub<'f> {
|
|||
}
|
||||
|
||||
impl<'f> Combine for Sub<'f> {
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt { self.get_ref().infcx }
|
||||
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a> { self.get_ref().infcx }
|
||||
fn tag(&self) -> ~str { ~"sub" }
|
||||
fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected }
|
||||
fn trace(&self) -> TypeTrace { self.get_ref().trace }
|
||||
|
|
|
@ -61,7 +61,7 @@ pub trait UnifyInferCtxtMethods {
|
|||
-> (V, uint);
|
||||
}
|
||||
|
||||
impl UnifyInferCtxtMethods for InferCtxt {
|
||||
impl<'a> UnifyInferCtxtMethods for InferCtxt<'a> {
|
||||
fn get<T:Clone,
|
||||
V:Clone + Eq + Vid + UnifyVid<T>>(
|
||||
&self,
|
||||
|
@ -80,7 +80,7 @@ impl UnifyInferCtxtMethods for InferCtxt {
|
|||
return helper(tcx, vb.get(), vid);
|
||||
|
||||
fn helper<T:Clone, V:Clone+Eq+Vid>(
|
||||
tcx: ty::ctxt,
|
||||
tcx: &ty::ctxt,
|
||||
vb: &mut ValsAndBindings<V,T>,
|
||||
vid: V) -> Node<V, T>
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ pub trait InferCtxtMethods {
|
|||
-> ures;
|
||||
}
|
||||
|
||||
impl InferCtxtMethods for InferCtxt {
|
||||
impl<'a> InferCtxtMethods for InferCtxt<'a> {
|
||||
fn simple_vars<T:Clone + Eq + InferStr + SimplyUnifiable,
|
||||
V:Clone + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
|
||||
&self,
|
||||
|
|
|
@ -200,7 +200,7 @@ pub enum vtable_origin {
|
|||
}
|
||||
|
||||
impl Repr for vtable_origin {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
match *self {
|
||||
vtable_static(def_id, ref tys, ref vtable_res) => {
|
||||
format!("vtable_static({:?}:{}, {}, {})",
|
||||
|
@ -232,7 +232,7 @@ pub struct impl_res {
|
|||
}
|
||||
|
||||
impl Repr for impl_res {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> ~str {
|
||||
format!("impl_res \\{trait_vtables={}, self_vtables={}\\}",
|
||||
self.trait_vtables.repr(tcx),
|
||||
self.self_vtables.repr(tcx))
|
||||
|
@ -241,22 +241,22 @@ impl Repr for impl_res {
|
|||
|
||||
pub type impl_vtable_map = RefCell<DefIdMap<impl_res>>;
|
||||
|
||||
pub struct CrateCtxt {
|
||||
pub struct CrateCtxt<'a> {
|
||||
// A mapping from method call sites to traits that have that method.
|
||||
trait_map: resolve::TraitMap,
|
||||
method_map: MethodMap,
|
||||
vtable_map: vtable_map,
|
||||
tcx: ty::ctxt
|
||||
tcx: &'a ty::ctxt
|
||||
}
|
||||
|
||||
// Functions that write types into the node type table
|
||||
pub fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::NodeId, ty: ty::t) {
|
||||
pub fn write_ty_to_tcx(tcx: &ty::ctxt, node_id: ast::NodeId, ty: ty::t) {
|
||||
debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_str(tcx, ty));
|
||||
assert!(!ty::type_needs_infer(ty));
|
||||
let mut node_types = tcx.node_types.borrow_mut();
|
||||
node_types.get().insert(node_id as uint, ty);
|
||||
}
|
||||
pub fn write_substs_to_tcx(tcx: ty::ctxt,
|
||||
pub fn write_substs_to_tcx(tcx: &ty::ctxt,
|
||||
node_id: ast::NodeId,
|
||||
substs: Vec<ty::t> ) {
|
||||
if substs.len() > 0u {
|
||||
|
@ -268,7 +268,7 @@ pub fn write_substs_to_tcx(tcx: ty::ctxt,
|
|||
node_type_substs.get().insert(node_id, substs);
|
||||
}
|
||||
}
|
||||
pub fn write_tpt_to_tcx(tcx: ty::ctxt,
|
||||
pub fn write_tpt_to_tcx(tcx: &ty::ctxt,
|
||||
node_id: ast::NodeId,
|
||||
tpt: &ty::ty_param_substs_and_ty) {
|
||||
write_ty_to_tcx(tcx, node_id, tpt.ty);
|
||||
|
@ -277,7 +277,7 @@ pub fn write_tpt_to_tcx(tcx: ty::ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn lookup_def_tcx(tcx: ty::ctxt, sp: Span, id: ast::NodeId) -> ast::Def {
|
||||
pub fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> ast::Def {
|
||||
let def_map = tcx.def_map.borrow();
|
||||
match def_map.get().find(&id) {
|
||||
Some(&x) => x,
|
||||
|
@ -300,7 +300,7 @@ pub fn no_params(t: ty::t) -> ty::ty_param_bounds_and_ty {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn require_same_types(tcx: ty::ctxt,
|
||||
pub fn require_same_types(tcx: &ty::ctxt,
|
||||
maybe_infcx: Option<&infer::InferCtxt>,
|
||||
t1_is_expected: bool,
|
||||
span: Span,
|
||||
|
@ -457,7 +457,7 @@ fn check_for_entry_fn(ccx: &CrateCtxt) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
trait_map: resolve::TraitMap,
|
||||
krate: &ast::Crate)
|
||||
-> (MethodMap, vtable_map) {
|
||||
|
|
|
@ -205,7 +205,7 @@ use syntax::visit;
|
|||
use syntax::visit::Visitor;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
pub fn infer_variance(tcx: ty::ctxt,
|
||||
pub fn infer_variance(tcx: &ty::ctxt,
|
||||
krate: &ast::Crate) {
|
||||
let mut arena = arena::Arena::new();
|
||||
let terms_cx = determine_parameters_to_be_inferred(tcx, &mut arena, krate);
|
||||
|
@ -251,7 +251,7 @@ impl<'a> fmt::Show for VarianceTerm<'a> {
|
|||
*/
|
||||
|
||||
struct TermsContext<'a> {
|
||||
tcx: ty::ctxt,
|
||||
tcx: &'a ty::ctxt,
|
||||
arena: &'a Arena,
|
||||
|
||||
empty_variances: @ty::ItemVariances,
|
||||
|
@ -274,7 +274,7 @@ struct InferredInfo<'a> {
|
|||
term: VarianceTermPtr<'a>,
|
||||
}
|
||||
|
||||
fn determine_parameters_to_be_inferred<'a>(tcx: ty::ctxt,
|
||||
fn determine_parameters_to_be_inferred<'a>(tcx: &'a ty::ctxt,
|
||||
arena: &'a mut Arena,
|
||||
krate: &ast::Crate)
|
||||
-> TermsContext<'a> {
|
||||
|
@ -522,7 +522,7 @@ impl<'a> Visitor<()> for ConstraintContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> ConstraintContext<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
fn tcx(&self) -> &'a ty::ctxt {
|
||||
self.terms_cx.tcx
|
||||
}
|
||||
|
||||
|
|
|
@ -35,15 +35,15 @@ use syntax::opt_vec::OptVec;
|
|||
|
||||
/// Produces a string suitable for debugging output.
|
||||
pub trait Repr {
|
||||
fn repr(&self, tcx: ctxt) -> ~str;
|
||||
fn repr(&self, tcx: &ctxt) -> ~str;
|
||||
}
|
||||
|
||||
/// Produces a string suitable for showing to the user.
|
||||
pub trait UserString {
|
||||
fn user_string(&self, tcx: ctxt) -> ~str;
|
||||
fn user_string(&self, tcx: &ctxt) -> ~str;
|
||||
}
|
||||
|
||||
pub fn note_and_explain_region(cx: ctxt,
|
||||
pub fn note_and_explain_region(cx: &ctxt,
|
||||
prefix: &str,
|
||||
region: ty::Region,
|
||||
suffix: &str) {
|
||||
|
@ -62,13 +62,13 @@ pub fn note_and_explain_region(cx: ctxt,
|
|||
|
||||
/// Returns a string like "the block at 27:31" that attempts to explain a
|
||||
/// lifetime in a way it might plausibly be understood.
|
||||
pub fn explain_region(cx: ctxt, region: ty::Region) -> ~str {
|
||||
pub fn explain_region(cx: &ctxt, region: ty::Region) -> ~str {
|
||||
let (res, _) = explain_region_and_span(cx, region);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
|
||||
pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
|
||||
-> (~str, Option<Span>) {
|
||||
return match region {
|
||||
ReScope(node_id) => {
|
||||
|
@ -138,7 +138,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
|
|||
}
|
||||
};
|
||||
|
||||
fn explain_span(cx: ctxt, heading: &str, span: Span)
|
||||
fn explain_span(cx: &ctxt, heading: &str, span: Span)
|
||||
-> (~str, Option<Span>)
|
||||
{
|
||||
let lo = cx.sess.codemap.lookup_char_pos_adj(span.lo);
|
||||
|
@ -147,11 +147,11 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
|
|||
}
|
||||
}
|
||||
|
||||
pub fn bound_region_ptr_to_str(cx: ctxt, br: BoundRegion) -> ~str {
|
||||
pub fn bound_region_ptr_to_str(cx: &ctxt, br: BoundRegion) -> ~str {
|
||||
bound_region_to_str(cx, "&", true, br)
|
||||
}
|
||||
|
||||
pub fn bound_region_to_str(cx: ctxt,
|
||||
pub fn bound_region_to_str(cx: &ctxt,
|
||||
prefix: &str, space: bool,
|
||||
br: BoundRegion) -> ~str {
|
||||
let space_str = if space { " " } else { "" };
|
||||
|
@ -168,7 +168,7 @@ pub fn bound_region_to_str(cx: ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ReScope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str {
|
||||
pub fn ReScope_id_to_str(cx: &ctxt, node_id: ast::NodeId) -> ~str {
|
||||
match cx.map.find(node_id) {
|
||||
Some(ast_map::NodeBlock(ref blk)) => {
|
||||
format!("<block at {}>",
|
||||
|
@ -207,11 +207,11 @@ pub fn ReScope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str {
|
|||
// In general, if you are giving a region error message,
|
||||
// you should use `explain_region()` or, better yet,
|
||||
// `note_and_explain_region()`
|
||||
pub fn region_ptr_to_str(cx: ctxt, region: Region) -> ~str {
|
||||
pub fn region_ptr_to_str(cx: &ctxt, region: Region) -> ~str {
|
||||
region_to_str(cx, "&", true, region)
|
||||
}
|
||||
|
||||
pub fn region_to_str(cx: ctxt, prefix: &str, space: bool, region: Region) -> ~str {
|
||||
pub fn region_to_str(cx: &ctxt, prefix: &str, space: bool, region: Region) -> ~str {
|
||||
let space_str = if space { " " } else { "" };
|
||||
|
||||
if cx.sess.verbose() {
|
||||
|
@ -243,16 +243,16 @@ pub fn mutability_to_str(m: ast::Mutability) -> ~str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mt_to_str(cx: ctxt, m: &mt) -> ~str {
|
||||
pub fn mt_to_str(cx: &ctxt, m: &mt) -> ~str {
|
||||
mt_to_str_wrapped(cx, "", m, "")
|
||||
}
|
||||
|
||||
pub fn mt_to_str_wrapped(cx: ctxt, before: &str, m: &mt, after: &str) -> ~str {
|
||||
pub fn mt_to_str_wrapped(cx: &ctxt, before: &str, m: &mt, after: &str) -> ~str {
|
||||
let mstr = mutability_to_str(m.mutbl);
|
||||
return format!("{}{}{}{}", mstr, before, ty_to_str(cx, m.ty), after);
|
||||
}
|
||||
|
||||
pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
|
||||
pub fn vstore_to_str(cx: &ctxt, vs: ty::vstore) -> ~str {
|
||||
match vs {
|
||||
ty::vstore_fixed(n) => format!("{}", n),
|
||||
ty::vstore_uniq => ~"~",
|
||||
|
@ -260,14 +260,14 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str {
|
||||
pub fn trait_store_to_str(cx: &ctxt, s: ty::TraitStore) -> ~str {
|
||||
match s {
|
||||
ty::UniqTraitStore => ~"~",
|
||||
ty::RegionTraitStore(r) => region_ptr_to_str(cx, r)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vstore_ty_to_str(cx: ctxt, mt: &mt, vs: ty::vstore) -> ~str {
|
||||
pub fn vstore_ty_to_str(cx: &ctxt, mt: &mt, vs: ty::vstore) -> ~str {
|
||||
match vs {
|
||||
ty::vstore_fixed(_) => {
|
||||
format!("[{}, .. {}]", mt_to_str(cx, mt), vstore_to_str(cx, vs))
|
||||
|
@ -283,26 +283,26 @@ pub fn vec_map_to_str<T>(ts: &[T], f: |t: &T| -> ~str) -> ~str {
|
|||
format!("[{}]", tstrs.connect(", "))
|
||||
}
|
||||
|
||||
pub fn tys_to_str(cx: ctxt, ts: &[t]) -> ~str {
|
||||
pub fn tys_to_str(cx: &ctxt, ts: &[t]) -> ~str {
|
||||
vec_map_to_str(ts, |t| ty_to_str(cx, *t))
|
||||
}
|
||||
|
||||
pub fn fn_sig_to_str(cx: ctxt, typ: &ty::FnSig) -> ~str {
|
||||
pub fn fn_sig_to_str(cx: &ctxt, typ: &ty::FnSig) -> ~str {
|
||||
format!("fn{}{} -> {}",
|
||||
typ.binder_id,
|
||||
typ.inputs.repr(cx),
|
||||
typ.output.repr(cx))
|
||||
}
|
||||
|
||||
pub fn trait_ref_to_str(cx: ctxt, trait_ref: &ty::TraitRef) -> ~str {
|
||||
pub fn trait_ref_to_str(cx: &ctxt, trait_ref: &ty::TraitRef) -> ~str {
|
||||
trait_ref.user_string(cx)
|
||||
}
|
||||
|
||||
pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
||||
fn fn_input_to_str(cx: ctxt, input: ty::t) -> ~str {
|
||||
pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
|
||||
fn fn_input_to_str(cx: &ctxt, input: ty::t) -> ~str {
|
||||
ty_to_str(cx, input)
|
||||
}
|
||||
fn bare_fn_to_str(cx: ctxt,
|
||||
fn bare_fn_to_str(cx: &ctxt,
|
||||
purity: ast::Purity,
|
||||
abis: AbiSet,
|
||||
ident: Option<ast::Ident>,
|
||||
|
@ -336,7 +336,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
|||
|
||||
return s;
|
||||
}
|
||||
fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str {
|
||||
fn closure_to_str(cx: &ctxt, cty: &ty::ClosureTy) -> ~str {
|
||||
let is_proc =
|
||||
(cty.sigil, cty.onceness) == (ast::OwnedSigil, ast::Once);
|
||||
let is_borrowed_closure = cty.sigil == ast::BorrowedSigil;
|
||||
|
@ -402,7 +402,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
|||
|
||||
return s;
|
||||
}
|
||||
fn push_sig_to_str(cx: ctxt,
|
||||
fn push_sig_to_str(cx: &ctxt,
|
||||
s: &mut ~str,
|
||||
bra: char,
|
||||
ket: char,
|
||||
|
@ -501,7 +501,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parameterized(cx: ctxt,
|
||||
pub fn parameterized(cx: &ctxt,
|
||||
base: &str,
|
||||
regions: &ty::RegionSubsts,
|
||||
tps: &[ty::t],
|
||||
|
@ -554,14 +554,14 @@ pub fn parameterized(cx: ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ty_to_short_str(cx: ctxt, typ: t) -> ~str {
|
||||
pub fn ty_to_short_str(cx: &ctxt, typ: t) -> ~str {
|
||||
let mut s = encoder::encoded_ty(cx, typ);
|
||||
if s.len() >= 32u { s = s.slice(0u, 32u).to_owned(); }
|
||||
return s;
|
||||
}
|
||||
|
||||
impl<T:Repr> Repr for Option<T> {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match self {
|
||||
&None => ~"None",
|
||||
&Some(ref t) => t.repr(tcx),
|
||||
|
@ -570,7 +570,7 @@ impl<T:Repr> Repr for Option<T> {
|
|||
}
|
||||
|
||||
impl<T:Repr,U:Repr> Repr for Result<T,U> {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match self {
|
||||
&Ok(ref t) => t.repr(tcx),
|
||||
&Err(ref u) => format!("Err({})", u.repr(tcx))
|
||||
|
@ -579,35 +579,35 @@ impl<T:Repr,U:Repr> Repr for Result<T,U> {
|
|||
}
|
||||
|
||||
impl Repr for () {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
~"()"
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Repr> Repr for @T {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
(&**self).repr(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Repr> Repr for ~T {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
(&**self).repr(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
fn repr_vec<T:Repr>(tcx: ctxt, v: &[T]) -> ~str {
|
||||
fn repr_vec<T:Repr>(tcx: &ctxt, v: &[T]) -> ~str {
|
||||
vec_map_to_str(v, |t| t.repr(tcx))
|
||||
}
|
||||
|
||||
impl<'a, T:Repr> Repr for &'a [T] {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
repr_vec(tcx, *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Repr> Repr for OptVec<T> {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match *self {
|
||||
opt_vec::Empty => ~"[]",
|
||||
opt_vec::Vec(ref v) => repr_vec(tcx, v.as_slice())
|
||||
|
@ -618,13 +618,13 @@ impl<T:Repr> Repr for OptVec<T> {
|
|||
// This is necessary to handle types like Option<~[T]>, for which
|
||||
// autoderef cannot convert the &[T] handler
|
||||
impl<T:Repr> Repr for Vec<T> {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
repr_vec(tcx, self.as_slice())
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::TypeParameterDef {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("TypeParameterDef({:?}, {})",
|
||||
self.def_id,
|
||||
self.bounds.repr(tcx))
|
||||
|
@ -632,7 +632,7 @@ impl Repr for ty::TypeParameterDef {
|
|||
}
|
||||
|
||||
impl Repr for ty::RegionParameterDef {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("RegionParameterDef({}, {:?})",
|
||||
token::get_name(self.name),
|
||||
self.def_id)
|
||||
|
@ -640,13 +640,13 @@ impl Repr for ty::RegionParameterDef {
|
|||
}
|
||||
|
||||
impl Repr for ty::t {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
ty_to_str(tcx, *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::substs {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("substs(regions={}, self_ty={}, tps={})",
|
||||
self.regions.repr(tcx),
|
||||
self.self_ty.repr(tcx),
|
||||
|
@ -655,7 +655,7 @@ impl Repr for ty::substs {
|
|||
}
|
||||
|
||||
impl Repr for ty::RegionSubsts {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match *self {
|
||||
ty::ErasedRegions => ~"erased",
|
||||
ty::NonerasedRegions(ref regions) => regions.repr(tcx)
|
||||
|
@ -664,7 +664,7 @@ impl Repr for ty::RegionSubsts {
|
|||
}
|
||||
|
||||
impl Repr for ty::ParamBounds {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
let mut res = Vec::new();
|
||||
for b in self.builtin_bounds.iter() {
|
||||
res.push(match b {
|
||||
|
@ -683,25 +683,25 @@ impl Repr for ty::ParamBounds {
|
|||
}
|
||||
|
||||
impl Repr for ty::TraitRef {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
trait_ref_to_str(tcx, self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Expr {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("expr({}: {})", self.id, pprust::expr_to_str(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Item {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("item({})", tcx.map.node_to_str(self.id))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Stmt {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("stmt({}: {})",
|
||||
ast_util::stmt_id(self),
|
||||
pprust::stmt_to_str(self))
|
||||
|
@ -709,7 +709,7 @@ impl Repr for ast::Stmt {
|
|||
}
|
||||
|
||||
impl Repr for ast::Pat {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("pat({}: {})",
|
||||
self.id,
|
||||
pprust::pat_to_str(self))
|
||||
|
@ -717,7 +717,7 @@ impl Repr for ast::Pat {
|
|||
}
|
||||
|
||||
impl Repr for ty::BoundRegion {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match *self {
|
||||
ty::BrAnon(id) => format!("BrAnon({})", id),
|
||||
ty::BrNamed(id, name) => format!("BrNamed({}, {})",
|
||||
|
@ -729,7 +729,7 @@ impl Repr for ty::BoundRegion {
|
|||
}
|
||||
|
||||
impl Repr for ty::Region {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match *self {
|
||||
ty::ReEarlyBound(id, index, name) => {
|
||||
format!("ReEarlyBound({}, {}, {})",
|
||||
|
@ -772,7 +772,7 @@ impl Repr for ty::Region {
|
|||
}
|
||||
|
||||
impl Repr for ast::DefId {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
// Unfortunately, there seems to be no way to attempt to print
|
||||
// a path for a def-id, so I'll just make a best effort for now
|
||||
// and otherwise fallback to just printing the crate/node pair
|
||||
|
@ -798,7 +798,7 @@ impl Repr for ast::DefId {
|
|||
}
|
||||
|
||||
impl Repr for ty::ty_param_bounds_and_ty {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("ty_param_bounds_and_ty \\{generics: {}, ty: {}\\}",
|
||||
self.generics.repr(tcx),
|
||||
self.ty.repr(tcx))
|
||||
|
@ -806,7 +806,7 @@ impl Repr for ty::ty_param_bounds_and_ty {
|
|||
}
|
||||
|
||||
impl Repr for ty::Generics {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("Generics(type_param_defs: {}, region_param_defs: {})",
|
||||
self.type_param_defs().repr(tcx),
|
||||
self.region_param_defs().repr(tcx))
|
||||
|
@ -814,7 +814,7 @@ impl Repr for ty::Generics {
|
|||
}
|
||||
|
||||
impl Repr for ty::ItemVariances {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("IterVariances(self_param={}, type_params={}, region_params={})",
|
||||
self.self_param.repr(tcx),
|
||||
self.type_params.repr(tcx),
|
||||
|
@ -823,13 +823,13 @@ impl Repr for ty::ItemVariances {
|
|||
}
|
||||
|
||||
impl Repr for ty::Variance {
|
||||
fn repr(&self, _: ctxt) -> ~str {
|
||||
fn repr(&self, _: &ctxt) -> ~str {
|
||||
self.to_str().to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::Method {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("method(ident: {}, generics: {}, fty: {}, \
|
||||
explicit_self: {}, vis: {}, def_id: {})",
|
||||
self.ident.repr(tcx),
|
||||
|
@ -842,31 +842,31 @@ impl Repr for ty::Method {
|
|||
}
|
||||
|
||||
impl Repr for ast::Name {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
token::get_name(*self).get().to_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Ident {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
token::get_ident(*self).get().to_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::ExplicitSelf_ {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Visibility {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::BareFnTy {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("BareFnTy \\{purity: {:?}, abis: {}, sig: {}\\}",
|
||||
self.purity,
|
||||
self.abis.to_str(),
|
||||
|
@ -875,13 +875,13 @@ impl Repr for ty::BareFnTy {
|
|||
}
|
||||
|
||||
impl Repr for ty::FnSig {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
fn_sig_to_str(tcx, self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for typeck::MethodCallee {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("MethodCallee \\{origin: {}, ty: {}, {}\\}",
|
||||
self.origin.repr(tcx),
|
||||
self.ty.repr(tcx),
|
||||
|
@ -890,7 +890,7 @@ impl Repr for typeck::MethodCallee {
|
|||
}
|
||||
|
||||
impl Repr for typeck::MethodOrigin {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match self {
|
||||
&typeck::MethodStatic(def_id) => {
|
||||
format!("MethodStatic({})", def_id.repr(tcx))
|
||||
|
@ -906,7 +906,7 @@ impl Repr for typeck::MethodOrigin {
|
|||
}
|
||||
|
||||
impl Repr for typeck::MethodParam {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("MethodParam({},{:?},{:?},{:?})",
|
||||
self.trait_id.repr(tcx),
|
||||
self.method_num,
|
||||
|
@ -916,7 +916,7 @@ impl Repr for typeck::MethodParam {
|
|||
}
|
||||
|
||||
impl Repr for typeck::MethodObject {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("MethodObject({},{:?},{:?})",
|
||||
self.trait_id.repr(tcx),
|
||||
self.method_num,
|
||||
|
@ -926,13 +926,13 @@ impl Repr for typeck::MethodObject {
|
|||
|
||||
|
||||
impl Repr for ty::RegionVid {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::TraitStore {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
match self {
|
||||
&ty::UniqTraitStore => ~"~Trait",
|
||||
&ty::RegionTraitStore(r) => format!("&{} Trait", r.repr(tcx))
|
||||
|
@ -941,19 +941,19 @@ impl Repr for ty::TraitStore {
|
|||
}
|
||||
|
||||
impl Repr for ty::vstore {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
vstore_to_str(tcx, *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::BuiltinBound {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl UserString for ty::BuiltinBound {
|
||||
fn user_string(&self, _tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, _tcx: &ctxt) -> ~str {
|
||||
match *self {
|
||||
ty::BoundStatic => ~"'static",
|
||||
ty::BoundSend => ~"Send",
|
||||
|
@ -965,26 +965,26 @@ impl UserString for ty::BuiltinBound {
|
|||
}
|
||||
|
||||
impl Repr for ty::BuiltinBounds {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
self.user_string(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for Span {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
tcx.sess.codemap.span_to_str(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:UserString> UserString for @A {
|
||||
fn user_string(&self, tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, tcx: &ctxt) -> ~str {
|
||||
let this: &A = &**self;
|
||||
this.user_string(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl UserString for ty::BuiltinBounds {
|
||||
fn user_string(&self, tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, tcx: &ctxt) -> ~str {
|
||||
if self.is_empty() { ~"<no-bounds>" } else {
|
||||
let mut result = Vec::new();
|
||||
for bb in self.iter() {
|
||||
|
@ -996,7 +996,7 @@ impl UserString for ty::BuiltinBounds {
|
|||
}
|
||||
|
||||
impl UserString for ty::TraitRef {
|
||||
fn user_string(&self, tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, tcx: &ctxt) -> ~str {
|
||||
let base = ty::item_path_str(tcx, self.def_id);
|
||||
if tcx.sess.verbose() && self.substs.self_ty.is_some() {
|
||||
let mut all_tps = self.substs.tps.clone();
|
||||
|
@ -1011,31 +1011,31 @@ impl UserString for ty::TraitRef {
|
|||
}
|
||||
|
||||
impl UserString for ty::t {
|
||||
fn user_string(&self, tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, tcx: &ctxt) -> ~str {
|
||||
ty_to_str(tcx, *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl UserString for ast::Ident {
|
||||
fn user_string(&self, _tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, _tcx: &ctxt) -> ~str {
|
||||
token::get_name(self.name).get().to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for AbiSet {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
self.to_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserString for AbiSet {
|
||||
fn user_string(&self, _tcx: ctxt) -> ~str {
|
||||
fn user_string(&self, _tcx: &ctxt) -> ~str {
|
||||
self.to_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::UpvarId {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("UpvarId({};`{}`;{})",
|
||||
self.var_id,
|
||||
ty::local_var_name_str(tcx, self.var_id),
|
||||
|
@ -1044,19 +1044,19 @@ impl Repr for ty::UpvarId {
|
|||
}
|
||||
|
||||
impl Repr for ast::Mutability {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::BorrowKind {
|
||||
fn repr(&self, _tcx: ctxt) -> ~str {
|
||||
fn repr(&self, _tcx: &ctxt) -> ~str {
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::UpvarBorrow {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
fn repr(&self, tcx: &ctxt) -> ~str {
|
||||
format!("UpvarBorrow({}, {})",
|
||||
self.kind.repr(tcx),
|
||||
self.region.repr(tcx))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue