eddyb's changes for DST coercions
+ lots of rebasing
This commit is contained in:
parent
c2b30b86df
commit
843db01bd9
40 changed files with 1019 additions and 514 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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>)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue