eddyb's changes for DST coercions

+ lots of rebasing
This commit is contained in:
Nick Cameron 2015-04-15 11:57:29 +12:00
parent c2b30b86df
commit 843db01bd9
40 changed files with 1019 additions and 514 deletions

View file

@ -259,3 +259,5 @@ pub const tag_codemap_filemap: usize = 0xa2;
pub const tag_item_super_predicates: usize = 0xa3;
pub const tag_defaulted_trait: usize = 0xa4;
pub const tag_impl_coerce_unsized_kind: usize = 0xa5;

View file

@ -279,6 +279,14 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
decoder::get_impl_polarity(&*cdata, def.node)
}
pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
def: ast::DefId)
-> Option<ty::CustomCoerceUnsized> {
let cstore = &tcx.sess.cstore;
let cdata = cstore.get_crate_data(def.krate);
decoder::get_custom_coerce_unsized_kind(&*cdata, def.node)
}
// Given a def_id for an impl, return the trait it implements,
// if there is one.
pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,

View file

@ -489,6 +489,16 @@ pub fn get_impl_polarity<'tcx>(cdata: Cmd,
}
}
pub fn get_custom_coerce_unsized_kind<'tcx>(cdata: Cmd,
id: ast::NodeId)
-> Option<ty::CustomCoerceUnsized> {
let item_doc = lookup_item(id, cdata.data());
reader::maybe_get_doc(item_doc, tag_impl_coerce_unsized_kind).map(|kind_doc| {
let mut decoder = reader::Decoder::new(kind_doc);
Decodable::decode(&mut decoder).unwrap()
})
}
pub fn get_impl_trait<'tcx>(cdata: Cmd,
id: ast::NodeId,
tcx: &ty::ctxt<'tcx>)

View file

@ -1219,6 +1219,16 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_attributes(rbml_w, &item.attrs);
encode_unsafety(rbml_w, unsafety);
encode_polarity(rbml_w, polarity);
match tcx.custom_coerce_unsized_kinds.borrow().get(&local_def(item.id)) {
Some(&kind) => {
rbml_w.start_tag(tag_impl_coerce_unsized_kind);
kind.encode(rbml_w);
rbml_w.end_tag();
}
None => {}
}
match ty.node {
ast::TyPath(None, ref path) if path.segments.len() == 1 => {
let name = path.segments.last().unwrap().identifier.name;