1
Fork 0

Fix fallout from libsyntax implementation

This commit is contained in:
Flavio Percoco 2015-01-22 22:15:02 +01:00
parent 6a2f16e136
commit 4148d5361a
9 changed files with 35 additions and 8 deletions

View file

@ -126,6 +126,7 @@ enum Family {
TupleVariant, // v TupleVariant, // v
StructVariant, // V StructVariant, // V
Impl, // i Impl, // i
DefTrait, // d
Trait, // I Trait, // I
Struct, // S Struct, // S
PublicField, // g PublicField, // g
@ -151,6 +152,7 @@ fn item_family(item: rbml::Doc) -> Family {
'v' => TupleVariant, 'v' => TupleVariant,
'V' => StructVariant, 'V' => StructVariant,
'i' => Impl, 'i' => Impl,
'd' => DefTrait,
'I' => Trait, 'I' => Trait,
'S' => Struct, 'S' => Struct,
'g' => PublicField, 'g' => PublicField,
@ -357,7 +359,7 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
} }
Trait => DlDef(def::DefTrait(did)), Trait => DlDef(def::DefTrait(did)),
Enum => DlDef(def::DefTy(did, true)), Enum => DlDef(def::DefTy(did, true)),
Impl => DlImpl(did), Impl | DefTrait => DlImpl(did),
PublicField | InheritedField => DlField, PublicField | InheritedField => DlField,
} }
} }
@ -480,7 +482,7 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
let item_doc = lookup_item(id, cdata.data()); let item_doc = lookup_item(id, cdata.data());
let fam = item_family(item_doc); let fam = item_family(item_doc);
match fam { match fam {
Family::Impl => { Family::Impl | Family::DefTrait => {
reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| { reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| {
doc_trait_ref(tp, tcx, cdata) doc_trait_ref(tp, tcx, cdata)
}) })
@ -1356,7 +1358,7 @@ pub fn get_trait_of_item(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
let parent_item_doc = lookup_item(parent_item_id.node, cdata.data()); let parent_item_doc = lookup_item(parent_item_id.node, cdata.data());
match item_family(parent_item_doc) { match item_family(parent_item_doc) {
Trait => Some(item_def_id(parent_item_doc, cdata)), Trait => Some(item_def_id(parent_item_doc, cdata)),
Impl => { Impl | DefTrait => {
reader::maybe_get_doc(parent_item_doc, tag_item_trait_ref) reader::maybe_get_doc(parent_item_doc, tag_item_trait_ref)
.map(|_| item_trait_ref(parent_item_doc, tcx, cdata).def_id) .map(|_| item_trait_ref(parent_item_doc, tcx, cdata).def_id)
} }

View file

@ -1201,6 +1201,18 @@ fn encode_info_for_item(ecx: &EncodeContext,
None => {} None => {}
} }
} }
ast::ItemDefTrait(unsafety, ref ast_trait_ref) => {
add_to_index(item, rbml_w, index);
rbml_w.start_tag(tag_items_data_item);
encode_def_id(rbml_w, def_id);
encode_family(rbml_w, 'd');
encode_name(rbml_w, item.ident.name);
encode_unsafety(rbml_w, unsafety);
let trait_ref = ty::node_id_to_trait_ref(tcx, ast_trait_ref.ref_id);
encode_trait_ref(rbml_w, ecx, &*trait_ref, tag_item_trait_ref);
rbml_w.end_tag();
}
ast::ItemImpl(unsafety, polarity, _, ref opt_trait, ref ty, ref ast_items) => { ast::ItemImpl(unsafety, polarity, _, ref opt_trait, ref ty, ref ast_items) => {
// We need to encode information about the default methods we // We need to encode information about the default methods we
// have inherited, so we drive this based on the impl structure. // have inherited, so we drive this based on the impl structure.

View file

@ -301,7 +301,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
ast::ItemTy(..) | ast::ItemStatic(_, _, _) | ast::ItemTy(..) | ast::ItemStatic(_, _, _) |
ast::ItemMod(..) | ast::ItemForeignMod(..) | ast::ItemMod(..) | ast::ItemForeignMod(..) |
ast::ItemImpl(..) | ast::ItemTrait(..) | ast::ItemImpl(..) | ast::ItemTrait(..) |
ast::ItemStruct(..) | ast::ItemEnum(..) => {} ast::ItemStruct(..) | ast::ItemEnum(..) |
ast::ItemDefTrait(..) => {}
_ => { _ => {
self.tcx.sess.span_bug(item.span, self.tcx.sess.span_bug(item.span,

View file

@ -115,6 +115,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
ast::ItemUse(_) | ast::ItemUse(_) |
ast::ItemMod(..) | ast::ItemMod(..) |
ast::ItemMac(..) | ast::ItemMac(..) |
ast::ItemDefTrait(..) |
ast::ItemForeignMod(..) | ast::ItemForeignMod(..) |
ast::ItemStatic(..) | ast::ItemStatic(..) |
ast::ItemConst(..) => { ast::ItemConst(..) => {

View file

@ -209,7 +209,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
match item.node { match item.node {
// impls/extern blocks do not break the "public chain" because they // impls/extern blocks do not break the "public chain" because they
// cannot have visibility qualifiers on them anyway // cannot have visibility qualifiers on them anyway
ast::ItemImpl(..) | ast::ItemForeignMod(..) => {} ast::ItemImpl(..) | ast::ItemDefTrait(..) | ast::ItemForeignMod(..) => {}
// Traits are a little special in that even if they themselves are // Traits are a little special in that even if they themselves are
// not public they may still be exported. // not public they may still be exported.
@ -1145,6 +1145,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
} }
} }
ast::ItemDefTrait(..) |
ast::ItemConst(..) | ast::ItemStatic(..) | ast::ItemStruct(..) | ast::ItemConst(..) | ast::ItemStatic(..) | ast::ItemStruct(..) |
ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) | ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) |
ast::ItemExternCrate(_) | ast::ItemUse(_) | ast::ItemMac(..) => {} ast::ItemExternCrate(_) | ast::ItemUse(_) | ast::ItemMac(..) => {}
@ -1204,7 +1205,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
} }
} }
ast::ItemExternCrate(_) | ast::ItemUse(_) | ast::ItemDefTrait(..) | ast::ItemExternCrate(_) | ast::ItemUse(_) |
ast::ItemStatic(..) | ast::ItemConst(..) | ast::ItemStatic(..) | ast::ItemConst(..) |
ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) | ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) |
ast::ItemMac(..) => {} ast::ItemMac(..) => {}

View file

@ -40,7 +40,7 @@ use syntax::ast::{Block, Crate};
use syntax::ast::{DeclItem, DefId}; use syntax::ast::{DeclItem, DefId};
use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic}; use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic};
use syntax::ast::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn}; use syntax::ast::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn};
use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic}; use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefTrait};
use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse}; use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse};
use syntax::ast::{MethodImplItem, Name, NamedField, NodeId}; use syntax::ast::{MethodImplItem, Name, NamedField, NodeId};
use syntax::ast::{PathListIdent, PathListMod}; use syntax::ast::{PathListIdent, PathListMod};
@ -656,6 +656,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
parent.clone() parent.clone()
} }
ItemDefTrait(_, _) |
ItemImpl(_, _, _, Some(_), _, _) => parent.clone(), ItemImpl(_, _, _, Some(_), _, _) => parent.clone(),
ItemTrait(_, _, _, ref items) => { ItemTrait(_, _, _, ref items) => {

View file

@ -70,7 +70,7 @@ use syntax::ast::{ExprClosure, ExprLoop, ExprWhile, ExprMethodCall};
use syntax::ast::{ExprPath, ExprQPath, ExprStruct, FnDecl}; use syntax::ast::{ExprPath, ExprQPath, ExprStruct, FnDecl};
use syntax::ast::{ForeignItemFn, ForeignItemStatic, Generics}; use syntax::ast::{ForeignItemFn, ForeignItemStatic, Generics};
use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate}; use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate};
use syntax::ast::{ItemFn, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic}; use syntax::ast::{ItemFn, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefTrait};
use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse}; use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse};
use syntax::ast::{Local, MethodImplItem, Mod, Name, NodeId}; use syntax::ast::{Local, MethodImplItem, Mod, Name, NodeId};
use syntax::ast::{Pat, PatEnum, PatIdent, PatLit}; use syntax::ast::{Pat, PatEnum, PatIdent, PatLit};
@ -2840,6 +2840,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}); });
} }
ItemDefTrait(_, ref trait_ref) => {
self.resolve_trait_reference(item.id, trait_ref, TraitImplementation);
}
ItemImpl(_, _, ItemImpl(_, _,
ref generics, ref generics,
ref implemented_traits, ref implemented_traits,

View file

@ -648,6 +648,9 @@ fn convert_item(ccx: &CollectCtxt, it: &ast::Item) {
predicates, predicates,
&enum_definition.variants); &enum_definition.variants);
}, },
ast::ItemDefTrait(_, ref ast_trait_ref) => {
}
ast::ItemImpl(_, _, ast::ItemImpl(_, _,
ref generics, ref generics,
ref opt_trait_ref, ref opt_trait_ref,
@ -1141,6 +1144,7 @@ fn compute_type_scheme_of_item<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
let t = ty::mk_struct(tcx, local_def(it.id), tcx.mk_substs(substs)); let t = ty::mk_struct(tcx, local_def(it.id), tcx.mk_substs(substs));
ty::TypeScheme { ty: t, generics: ty_generics } ty::TypeScheme { ty: t, generics: ty_generics }
} }
ast::ItemDefTrait(..) |
ast::ItemTrait(..) | ast::ItemTrait(..) |
ast::ItemImpl(..) | ast::ItemImpl(..) |
ast::ItemMod(..) | ast::ItemMod(..) |

View file

@ -476,6 +476,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> {
ast::ItemExternCrate(_) | ast::ItemExternCrate(_) |
ast::ItemUse(_) | ast::ItemUse(_) |
ast::ItemDefTrait(..) |
ast::ItemImpl(..) | ast::ItemImpl(..) |
ast::ItemStatic(..) | ast::ItemStatic(..) |
ast::ItemConst(..) | ast::ItemConst(..) |
@ -626,6 +627,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
ast::ItemForeignMod(..) | ast::ItemForeignMod(..) |
ast::ItemTy(..) | ast::ItemTy(..) |
ast::ItemImpl(..) | ast::ItemImpl(..) |
ast::ItemDefTrait(..) |
ast::ItemMac(..) => { ast::ItemMac(..) => {
} }
} }