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