diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index e34fb37e1c5..1295970d667 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -10,10 +10,6 @@ // Searching for information from the cstore -#![allow(non_camel_case_types)] - -pub use self::found_ast::*; - use metadata::common::*; use metadata::cstore; use metadata::decoder; @@ -101,10 +97,10 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec r } -pub enum found_ast<'ast> { - found(&'ast ast::InlinedItem), - found_parent(ast::DefId, &'ast ast::InlinedItem), - not_found, +pub enum FoundAst<'ast> { + Found(&'ast ast::InlinedItem), + FoundParent(ast::DefId, &'ast ast::InlinedItem), + NotFound, } // Finds the AST for this item in the crate metadata, if any. If the item was @@ -112,7 +108,7 @@ pub enum found_ast<'ast> { // will be returned. pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId, decode_inlined_item: decoder::DecodeInlinedItem) - -> found_ast<'tcx> { + -> FoundAst<'tcx> { let cstore = &tcx.sess.cstore; let cdata = cstore.get_crate_data(def.krate); decoder::maybe_get_item_ast(&*cdata, tcx, def.node, decode_inlined_item) diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index e6f76dedca9..b573c54ef85 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -693,23 +693,23 @@ pub type DecodeInlinedItem<'a> = pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeId, mut decode_inlined_item: DecodeInlinedItem) - -> csearch::found_ast<'tcx> { + -> csearch::FoundAst<'tcx> { debug!("Looking up item: {}", id); let item_doc = lookup_item(id, cdata.data()); let path = item_path(item_doc).init().to_vec(); match decode_inlined_item(cdata, tcx, path, item_doc) { - Ok(ii) => csearch::found(ii), + Ok(ii) => csearch::FoundAst::Found(ii), Err(path) => { match item_parent_item(item_doc) { Some(did) => { let did = translate_def_id(cdata, did); let parent_item = lookup_item(did.node, cdata.data()); match decode_inlined_item(cdata, tcx, path, parent_item) { - Ok(ii) => csearch::found_parent(did, ii), - Err(_) => csearch::not_found + Ok(ii) => csearch::FoundAst::FoundParent(did, ii), + Err(_) => csearch::FoundAst::NotFound } } - None => csearch::not_found + None => csearch::FoundAst::NotFound } } } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index c2533c1a9c6..00141903c7c 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -133,7 +133,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt, } let expr_id = match csearch::maybe_get_item_ast(tcx, enum_def, box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { - csearch::found(&ast::IIItem(ref item)) => match item.node { + csearch::FoundAst::Found(&ast::IIItem(ref item)) => match item.node { ast::ItemEnum(ast::EnumDef { ref variants }, _) => { // NOTE this doesn't do the right thing, it compares inlined // NodeId's to the original variant_def's NodeId, but they @@ -173,7 +173,7 @@ pub fn lookup_const_by_id<'a>(tcx: &'a ty::ctxt, def_id: ast::DefId) } let expr_id = match csearch::maybe_get_item_ast(tcx, def_id, box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { - csearch::found(&ast::IIItem(ref item)) => match item.node { + csearch::FoundAst::Found(&ast::IIItem(ref item)) => match item.node { ast::ItemConst(_, ref const_expr) => Some(const_expr.id), _ => None }, diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index dd1cfc5ad6d..ea6d9b88e11 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -43,11 +43,11 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) box |a,b,c,d| astencode::decode_inlined_item(a, b, c, d)); let inline_def = match csearch_result { - csearch::not_found => { + csearch::FoundAst::NotFound => { ccx.external().borrow_mut().insert(fn_id, None); return None; } - csearch::found(&ast::IIItem(ref item)) => { + csearch::FoundAst::Found(&ast::IIItem(ref item)) => { ccx.external().borrow_mut().insert(fn_id, Some(item.id)); ccx.external_srcs().borrow_mut().insert(item.id, fn_id); @@ -90,12 +90,12 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) local_def(item.id) } - csearch::found(&ast::IIForeign(ref item)) => { + csearch::FoundAst::Found(&ast::IIForeign(ref item)) => { ccx.external().borrow_mut().insert(fn_id, Some(item.id)); ccx.external_srcs().borrow_mut().insert(item.id, fn_id); local_def(item.id) } - csearch::found_parent(parent_id, &ast::IIItem(ref item)) => { + csearch::FoundAst::FoundParent(parent_id, &ast::IIItem(ref item)) => { ccx.external().borrow_mut().insert(parent_id, Some(item.id)); ccx.external_srcs().borrow_mut().insert(item.id, parent_id); @@ -124,11 +124,11 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) trans_item(ccx, &**item); local_def(my_id) } - csearch::found_parent(_, _) => { - ccx.sess().bug("maybe_get_item_ast returned a found_parent \ + csearch::FoundAst::FoundParent(_, _) => { + ccx.sess().bug("maybe_get_item_ast returned a FoundParent \ with a non-item parent"); } - csearch::found(&ast::IITraitItem(_, ref trait_item)) => { + csearch::FoundAst::Found(&ast::IITraitItem(_, ref trait_item)) => { match *trait_item { ast::RequiredMethod(_) => ccx.sess().bug("found RequiredMethod IITraitItem"), ast::ProvidedMethod(ref mth) => { @@ -147,7 +147,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) } } } - csearch::found(&ast::IIImplItem(impl_did, ref impl_item)) => { + csearch::FoundAst::Found(&ast::IIImplItem(impl_did, ref impl_item)) => { match *impl_item { ast::MethodImplItem(ref mth) => { ccx.external().borrow_mut().insert(fn_id, Some(mth.id));