macro_rules! mywrite( ($($arg:tt)*) => ({ write!($($arg)*); }) )
-pub struct ctxt<'a> {
+pub struct ctxt<'a, 'tcx: 'a> {
pub diag: &'a SpanHandler,
// Def -> str Callback:
pub ds: fn(DefId) -> String,
// The type context.
- pub tcx: &'a ty::ctxt,
+ pub tcx: &'a ty::ctxt<'tcx>,
pub abbrevs: &'a abbrev_map
}
}
}
-fn enc_region(w: &mut SeekableMemWriter, cx: &ctxt, r: ty::Region) {
+pub fn enc_region(w: &mut SeekableMemWriter, cx: &ctxt, r: ty::Region) {
match r {
ty::ReLateBound(id, br) => {
mywrite!(w, "b[{}|", id);
ty::ty_trait(box ty::TyTrait {
def_id,
ref substs,
- bounds
+ ref bounds
}) => {
mywrite!(w, "x[{}|", (cx.ds)(def_id));
enc_substs(w, cx, substs);
- let bounds = ty::ParamBounds {builtin_bounds: bounds,
- trait_bounds: Vec::new()};
- enc_bounds(w, cx, &bounds);
+ enc_existential_bounds(w, cx, bounds);
mywrite!(w, "]");
}
ty::ty_tup(ref ts) => {
enc_region(w, cx, r);
enc_mt(w, cx, mt);
}
- ty::ty_vec(mt, sz) => {
+ ty::ty_vec(t, sz) => {
mywrite!(w, "V");
- enc_mt(w, cx, mt);
+ enc_ty(w, cx, t);
mywrite!(w, "/");
match sz {
Some(n) => mywrite!(w, "{}|", n),
ty::ty_err => {
mywrite!(w, "e");
}
+ ty::ty_open(_) => {
+ cx.diag.handler().bug("unexpected type in enc_sty (ty_open)");
+ }
}
}
enc_fn_style(w, ft.fn_style);
enc_onceness(w, ft.onceness);
enc_trait_store(w, cx, ft.store);
- let bounds = ty::ParamBounds {builtin_bounds: ft.bounds,
- trait_bounds: Vec::new()};
- enc_bounds(w, cx, &bounds);
+ enc_existential_bounds(w, cx, &ft.bounds);
enc_fn_sig(w, cx, &ft.sig);
enc_abi(w, ft.abi);
}
enc_ty(w, cx, fsig.output);
}
-fn enc_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
- for bound in bs.builtin_bounds.iter() {
+pub fn enc_builtin_bounds(w: &mut SeekableMemWriter, _cx: &ctxt, bs: &ty::BuiltinBounds) {
+ for bound in bs.iter() {
match bound {
ty::BoundSend => mywrite!(w, "S"),
- ty::BoundStatic => mywrite!(w, "O"),
ty::BoundSized => mywrite!(w, "Z"),
ty::BoundCopy => mywrite!(w, "P"),
ty::BoundSync => mywrite!(w, "T"),
}
}
+ mywrite!(w, ".");
+}
+
+pub fn enc_existential_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ExistentialBounds) {
+ enc_region(w, cx, bs.region_bound);
+ enc_builtin_bounds(w, cx, &bs.builtin_bounds);
+}
+
+pub fn enc_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
+ enc_builtin_bounds(w, cx, &bs.builtin_bounds);
+
+ for &r in bs.region_bounds.iter() {
+ mywrite!(w, "R");
+ enc_region(w, cx, r);
+ }
+
for tp in bs.trait_bounds.iter() {
mywrite!(w, "I");
enc_trait_ref(w, cx, &**tp);
mywrite!(w, "{}:{}|{}|{}|",
token::get_ident(v.ident), (cx.ds)(v.def_id),
v.space.to_uint(), v.index);
- enc_bounds(w, cx, &*v.bounds);
+ enc_opt(w, v.associated_with, |w, did| mywrite!(w, "{}", (cx.ds)(did)));
+ mywrite!(w, "|");
+ enc_bounds(w, cx, &v.bounds);
enc_opt(w, v.default, |w, t| enc_ty(w, cx, t));
}