1
Fork 0

rustc: put ty_trait behind some indirection.

This reduces ty::sty from 160 bytes to just 112, and some measurements
eddyb made suggest that the ty_trait variant occurs very
rarely (e.g. ~1% of all sty instances) hence this will result in a large
memory saving, and the cost of the indirection is unlikely to be an
issue.
This commit is contained in:
Huon Wilson 2014-03-19 22:01:30 +11:00
parent a39c294155
commit 405b5fc1ee
18 changed files with 94 additions and 61 deletions

View file

@ -280,11 +280,11 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
enc_substs(w, cx, substs); enc_substs(w, cx, substs);
mywrite!(w, "]"); mywrite!(w, "]");
} }
ty::ty_trait(def, ref substs, store, mt, bounds) => { ty::ty_trait(~ty::TyTrait { def_id, ref substs, store, mutability, bounds }) => {
mywrite!(w, "x[{}|", (cx.ds)(def)); mywrite!(w, "x[{}|", (cx.ds)(def_id));
enc_substs(w, cx, substs); enc_substs(w, cx, substs);
enc_trait_store(w, cx, store); enc_trait_store(w, cx, store);
enc_mutability(w, mt); enc_mutability(w, mutability);
let bounds = ty::ParamBounds {builtin_bounds: bounds, let bounds = ty::ParamBounds {builtin_bounds: bounds,
trait_bounds: Vec::new()}; trait_bounds: Vec::new()};
enc_bounds(w, cx, &bounds); enc_bounds(w, cx, &bounds);

View file

@ -358,7 +358,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span: Span) { fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span: Span) {
check_cast_for_escaping_regions(cx, source_ty, target_ty, span); check_cast_for_escaping_regions(cx, source_ty, target_ty, span);
match ty::get(target_ty).sty { match ty::get(target_ty).sty {
ty::ty_trait(_, _, _, _, bounds) => { ty::ty_trait(~ty::TyTrait { bounds, .. }) => {
check_trait_cast_bounds(cx, span, source_ty, bounds); check_trait_cast_bounds(cx, span, source_ty, bounds);
} }
_ => {} _ => {}

View file

@ -911,7 +911,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
} }
ty::ty_uniq(_) | ty::ty_str(ty::vstore_uniq) | ty::ty_uniq(_) | ty::ty_str(ty::vstore_uniq) |
ty::ty_vec(_, ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) |
ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => { ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) => {
n_uniq += 1; n_uniq += 1;
} }
ty::ty_closure(ref c) if c.sigil == ast::OwnedSigil => { ty::ty_closure(ref c) if c.sigil == ast::OwnedSigil => {

View file

@ -170,7 +170,7 @@ pub enum deref_kind {
pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> { pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
match ty::get(t).sty { match ty::get(t).sty {
ty::ty_uniq(_) | ty::ty_uniq(_) |
ty::ty_trait(_, _, ty::UniqTraitStore, _, _) | ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) |
ty::ty_vec(_, ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) |
ty::ty_str(ty::vstore_uniq) | ty::ty_str(ty::vstore_uniq) |
ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => { ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
@ -183,7 +183,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
Some(deref_ptr(BorrowedPtr(kind, r))) Some(deref_ptr(BorrowedPtr(kind, r)))
} }
ty::ty_trait(_, _, ty::RegionTraitStore(r), m, _) => { ty::ty_trait(~ty::TyTrait { store: ty::RegionTraitStore(r), mutability: m, .. }) => {
let kind = ty::BorrowKind::from_mutbl(m); let kind = ty::BorrowKind::from_mutbl(m);
Some(deref_ptr(BorrowedPtr(kind, r))) Some(deref_ptr(BorrowedPtr(kind, r)))
} }

View file

@ -2126,7 +2126,9 @@ fn type_metadata(cx: &CrateContext,
ty::ty_closure(ref closurety) => { ty::ty_closure(ref closurety) => {
subroutine_type_metadata(cx, &closurety.sig, usage_site_span) subroutine_type_metadata(cx, &closurety.sig, usage_site_span)
}, },
ty::ty_trait(def_id, ref substs, trait_store, mutability, ref bounds) => { ty::ty_trait(~ty::TyTrait { def_id, ref substs,
store: trait_store, mutability,
ref bounds }) => {
trait_metadata(cx, def_id, t, substs, trait_store, mutability, bounds) trait_metadata(cx, def_id, t, substs, trait_store, mutability, bounds)
}, },
ty::ty_struct(def_id, ref substs) => { ty::ty_struct(def_id, ref substs) => {

View file

@ -310,7 +310,7 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
} }
} }
} }
ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => { ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) => {
let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]); let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]);
// Only drop the value when it is non-null // Only drop the value when it is non-null
with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| { with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| {

View file

@ -351,7 +351,7 @@ impl<'a> Reflector<'a> {
}) })
} }
ty::ty_trait(_, _, _, _, _) => { ty::ty_trait(..) => {
let extra = [ let extra = [
self.c_slice(token::intern_and_get_ident(ty_to_str(tcx, t))) self.c_slice(token::intern_and_get_ident(ty_to_str(tcx, t)))
]; ];

View file

@ -747,7 +747,7 @@ pub enum sty {
ty_rptr(Region, mt), ty_rptr(Region, mt),
ty_bare_fn(BareFnTy), ty_bare_fn(BareFnTy),
ty_closure(ClosureTy), ty_closure(ClosureTy),
ty_trait(DefId, substs, TraitStore, ast::Mutability, BuiltinBounds), ty_trait(~TyTrait),
ty_struct(DefId, substs), ty_struct(DefId, substs),
ty_tup(Vec<t>), ty_tup(Vec<t>),
@ -764,6 +764,15 @@ pub enum sty {
ty_unboxed_vec(mt), ty_unboxed_vec(mt),
} }
#[deriving(Clone, Eq, Hash)]
pub struct TyTrait {
def_id: DefId,
substs: substs,
store: TraitStore,
mutability: ast::Mutability,
bounds: BuiltinBounds
}
#[deriving(Eq, Hash)] #[deriving(Eq, Hash)]
pub struct TraitRef { pub struct TraitRef {
def_id: DefId, def_id: DefId,
@ -1205,10 +1214,10 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
&ty_infer(_) => flags |= needs_infer as uint, &ty_infer(_) => flags |= needs_infer as uint,
&ty_self(_) => flags |= has_self as uint, &ty_self(_) => flags |= has_self as uint,
&ty_enum(_, ref substs) | &ty_struct(_, ref substs) | &ty_enum(_, ref substs) | &ty_struct(_, ref substs) |
&ty_trait(_, ref substs, _, _, _) => { &ty_trait(~ty::TyTrait { ref substs, .. }) => {
flags |= sflags(substs); flags |= sflags(substs);
match st { match st {
ty_trait(_, _, RegionTraitStore(r), _, _) => { ty_trait(~ty::TyTrait { store: RegionTraitStore(r), .. }) => {
flags |= rflags(r); flags |= rflags(r);
} }
_ => {} _ => {}
@ -1432,7 +1441,14 @@ pub fn mk_trait(cx: &ctxt,
bounds: BuiltinBounds) bounds: BuiltinBounds)
-> t { -> t {
// take a copy of substs so that we own the vectors inside // take a copy of substs so that we own the vectors inside
mk_t(cx, ty_trait(did, substs, store, mutability, bounds)) let inner = ~TyTrait {
def_id: did,
substs: substs,
store: store,
mutability: mutability,
bounds: bounds
};
mk_t(cx, ty_trait(inner))
} }
pub fn mk_struct(cx: &ctxt, struct_id: ast::DefId, substs: substs) -> t { pub fn mk_struct(cx: &ctxt, struct_id: ast::DefId, substs: substs) -> t {
@ -1472,7 +1488,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
maybe_walk_ty(tm.ty, f); maybe_walk_ty(tm.ty, f);
} }
ty_enum(_, ref substs) | ty_struct(_, ref substs) | ty_enum(_, ref substs) | ty_struct(_, ref substs) |
ty_trait(_, ref substs, _, _, _) => { ty_trait(~TyTrait { ref substs, .. }) => {
for subty in (*substs).tps.iter() { maybe_walk_ty(*subty, |x| f(x)); } for subty in (*substs).tps.iter() { maybe_walk_ty(*subty, |x| f(x)); }
} }
ty_tup(ref ts) => { for tt in ts.iter() { maybe_walk_ty(*tt, |x| f(x)); } } ty_tup(ref ts) => { for tt in ts.iter() { maybe_walk_ty(*tt, |x| f(x)); } }
@ -2144,8 +2160,8 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
tc_ty(cx, typ, cache).owned_pointer() tc_ty(cx, typ, cache).owned_pointer()
} }
ty_trait(_, _, store, mutbl, bounds) => { ty_trait(~ty::TyTrait { store, mutability, bounds, .. }) => {
object_contents(cx, store, mutbl, bounds) object_contents(cx, store, mutability, bounds)
} }
ty_ptr(ref mt) => { ty_ptr(ref mt) => {
@ -2437,7 +2453,7 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool {
false // unsafe ptrs can always be NULL false // unsafe ptrs can always be NULL
} }
ty_trait(_, _, _, _, _) => { ty_trait(..) => {
false false
} }
@ -3140,9 +3156,9 @@ pub fn adjust_ty(cx: &ctxt,
fn borrow_obj(cx: &ctxt, span: Span, r: Region, fn borrow_obj(cx: &ctxt, span: Span, r: Region,
m: ast::Mutability, ty: ty::t) -> ty::t { m: ast::Mutability, ty: ty::t) -> ty::t {
match get(ty).sty { match get(ty).sty {
ty_trait(trt_did, ref trt_substs, _, _, b) => { ty_trait(~ty::TyTrait {def_id, ref substs, bounds, .. }) => {
ty::mk_trait(cx, trt_did, trt_substs.clone(), ty::mk_trait(cx, def_id, substs.clone(),
RegionTraitStore(r), m, b) RegionTraitStore(r), m, bounds)
} }
ref s => { ref s => {
cx.sess.span_bug( cx.sess.span_bug(
@ -3479,7 +3495,7 @@ pub fn ty_sort_str(cx: &ctxt, t: t) -> ~str {
ty_rptr(_, _) => ~"&-ptr", ty_rptr(_, _) => ~"&-ptr",
ty_bare_fn(_) => ~"extern fn", ty_bare_fn(_) => ~"extern fn",
ty_closure(_) => ~"fn", ty_closure(_) => ~"fn",
ty_trait(id, _, _, _, _) => format!("trait {}", item_path_str(cx, id)), ty_trait(ref inner) => format!("trait {}", item_path_str(cx, inner.def_id)),
ty_struct(id, _) => format!("struct {}", item_path_str(cx, id)), ty_struct(id, _) => format!("struct {}", item_path_str(cx, id)),
ty_tup(_) => ~"tuple", ty_tup(_) => ~"tuple",
ty_infer(TyVar(_)) => ~"inferred type", ty_infer(TyVar(_)) => ~"inferred type",
@ -3865,7 +3881,7 @@ pub fn try_add_builtin_trait(tcx: &ctxt,
pub fn ty_to_def_id(ty: t) -> Option<ast::DefId> { pub fn ty_to_def_id(ty: t) -> Option<ast::DefId> {
match get(ty).sty { match get(ty).sty {
ty_trait(id, _, _, _, _) | ty_struct(id, _) | ty_enum(id, _) => Some(id), ty_trait(~TyTrait { def_id: id, .. }) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
_ => None _ => None
} }
} }
@ -4951,7 +4967,7 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
hash!(c.bounds); hash!(c.bounds);
region(&mut state, c.region); region(&mut state, c.region);
} }
ty_trait(d, _, store, m, bounds) => { ty_trait(~ty::TyTrait { def_id: d, store, mutability: m, bounds, .. }) => {
byte!(17); byte!(17);
did(&mut state, d); did(&mut state, d);
match store { match store {

View file

@ -159,12 +159,14 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T,
ty::ty_enum(tid, ref substs) => { ty::ty_enum(tid, ref substs) => {
ty::ty_enum(tid, this.fold_substs(substs)) ty::ty_enum(tid, this.fold_substs(substs))
} }
ty::ty_trait(did, ref substs, st, mutbl, bounds) => { ty::ty_trait(~ty::TyTrait { def_id, ref substs, store, mutability, bounds }) => {
ty::ty_trait(did, ty::ty_trait(~ty::TyTrait{
this.fold_substs(substs), def_id: def_id,
this.fold_trait_store(st), substs: this.fold_substs(substs),
mutbl, store: this.fold_trait_store(store),
bounds) mutability: mutability,
bounds: bounds
})
} }
ty::ty_tup(ref ts) => { ty::ty_tup(ref ts) => {
ty::ty_tup(fold_ty_vec(this, ts.as_slice())) ty::ty_tup(fold_ty_vec(this, ts.as_slice()))

View file

@ -417,9 +417,9 @@ impl<'a> LookupContext<'a> {
let span = self.self_expr.map_or(self.span, |e| e.span); let span = self.self_expr.map_or(self.span, |e| e.span);
check::autoderef(self.fcx, span, self_ty, None, PreferMutLvalue, |self_ty, _| { check::autoderef(self.fcx, span, self_ty, None, PreferMutLvalue, |self_ty, _| {
match get(self_ty).sty { match get(self_ty).sty {
ty_trait(did, ref substs, _, _, _) => { ty_trait(~TyTrait { def_id, ref substs, .. }) => {
self.push_inherent_candidates_from_object(did, substs); self.push_inherent_candidates_from_object(def_id, substs);
self.push_inherent_impl_candidates_for_type(did); self.push_inherent_impl_candidates_for_type(def_id);
} }
ty_enum(did, _) | ty_struct(did, _) => { ty_enum(did, _) | ty_struct(did, _) => {
if self.check_traits == CheckTraitsAndInherentMethods { if self.check_traits == CheckTraitsAndInherentMethods {
@ -775,10 +775,12 @@ impl<'a> LookupContext<'a> {
autoderefs: autoderefs, autoderefs: autoderefs,
autoref: Some(ty::AutoBorrowVec(region, self_mt.mutbl))}) autoref: Some(ty::AutoBorrowVec(region, self_mt.mutbl))})
} }
ty::ty_trait(did, ref substs, ty::RegionTraitStore(_), mutbl, bounds) => { ty::ty_trait(~ty::TyTrait {
def_id, ref substs, store: ty::RegionTraitStore(_), mutability: mutbl, bounds
}) => {
let region = let region =
self.infcx().next_region_var(infer::Autoref(self.span)); self.infcx().next_region_var(infer::Autoref(self.span));
(ty::mk_trait(tcx, did, substs.clone(), (ty::mk_trait(tcx, def_id, substs.clone(),
ty::RegionTraitStore(region), ty::RegionTraitStore(region),
mutbl, bounds), mutbl, bounds),
ty::AutoDerefRef { ty::AutoDerefRef {
@ -860,7 +862,7 @@ impl<'a> LookupContext<'a> {
}) })
} }
ty_trait(trt_did, trt_substs, _, _, b) => { ty_trait(~ty::TyTrait { def_id: trt_did, substs: trt_substs, bounds: b, .. }) => {
// Coerce ~/@/&Trait instances to &Trait. // Coerce ~/@/&Trait instances to &Trait.
self.search_for_some_kind_of_autorefd_method( self.search_for_some_kind_of_autorefd_method(
@ -1301,7 +1303,9 @@ impl<'a> LookupContext<'a> {
rcvr_matches_ty(self.fcx, mt.ty, candidate) rcvr_matches_ty(self.fcx, mt.ty, candidate)
} }
ty::ty_trait(self_did, _, RegionTraitStore(_), self_m, _) => { ty::ty_trait(~ty::TyTrait {
def_id: self_did, store: RegionTraitStore(_), mutability: self_m, ..
}) => {
mutability_matches(self_m, m) && mutability_matches(self_m, m) &&
rcvr_matches_object(self_did, candidate) rcvr_matches_object(self_did, candidate)
} }
@ -1317,7 +1321,9 @@ impl<'a> LookupContext<'a> {
rcvr_matches_ty(self.fcx, typ, candidate) rcvr_matches_ty(self.fcx, typ, candidate)
} }
ty::ty_trait(self_did, _, UniqTraitStore, _, _) => { ty::ty_trait(~ty::TyTrait {
def_id: self_did, store: UniqTraitStore, ..
}) => {
rcvr_matches_object(self_did, candidate) rcvr_matches_object(self_did, candidate)
} }

View file

@ -542,7 +542,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
// explaining how it goes about doing that. // explaining how it goes about doing that.
let target_ty = rcx.resolve_node_type(expr.id); let target_ty = rcx.resolve_node_type(expr.id);
match ty::get(target_ty).sty { match ty::get(target_ty).sty {
ty::ty_trait(_, _, ty::RegionTraitStore(trait_region), _, _) => { ty::ty_trait(~ty::TyTrait { store: ty::RegionTraitStore(trait_region), .. }) => {
let source_ty = rcx.resolve_expr_type_adjusted(source); let source_ty = rcx.resolve_expr_type_adjusted(source);
constrain_regions_in_type( constrain_regions_in_type(
rcx, rcx,

View file

@ -478,7 +478,7 @@ fn fixup_substs(vcx: &VtableContext,
ty::EmptyBuiltinBounds()); ty::EmptyBuiltinBounds());
fixup_ty(vcx, span, t, is_early).map(|t_f| { fixup_ty(vcx, span, t, is_early).map(|t_f| {
match ty::get(t_f).sty { match ty::get(t_f).sty {
ty::ty_trait(_, ref substs_f, _, _, _) => (*substs_f).clone(), ty::ty_trait(ref inner) => inner.substs.clone(),
_ => fail!("t_f should be a trait") _ => fail!("t_f should be a trait")
} }
}) })
@ -536,8 +536,10 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) {
let resolve_object_cast = |src: &ast::Expr, target_ty: ty::t| { let resolve_object_cast = |src: &ast::Expr, target_ty: ty::t| {
match ty::get(target_ty).sty { match ty::get(target_ty).sty {
// Bounds of type's contents are not checked here, but in kind.rs. // Bounds of type's contents are not checked here, but in kind.rs.
ty::ty_trait(target_def_id, ref target_substs, store, ty::ty_trait(~ty::TyTrait {
target_mutbl, _bounds) => { def_id: target_def_id, substs: ref target_substs, store: store,
mutability: target_mutbl, bounds: _bounds
}) => {
fn mutability_allowed(a_mutbl: ast::Mutability, fn mutability_allowed(a_mutbl: ast::Mutability,
b_mutbl: ast::Mutability) -> bool { b_mutbl: ast::Mutability) -> bool {
a_mutbl == b_mutbl || a_mutbl == b_mutbl ||

View file

@ -106,7 +106,7 @@ fn type_is_defined_in_local_crate(original_type: t) -> bool {
ty::walk_ty(original_type, |t| { ty::walk_ty(original_type, |t| {
match get(t).sty { match get(t).sty {
ty_enum(def_id, _) | ty_enum(def_id, _) |
ty_trait(def_id, _, _, _, _) | ty_trait(~ty::TyTrait { def_id, .. }) |
ty_struct(def_id, _) => { ty_struct(def_id, _) => {
if def_id.krate == ast::LOCAL_CRATE { if def_id.krate == ast::LOCAL_CRATE {
found_nominal = true; found_nominal = true;
@ -132,7 +132,7 @@ fn get_base_type_def_id(inference_context: &InferCtxt,
match get(base_type).sty { match get(base_type).sty {
ty_enum(def_id, _) | ty_enum(def_id, _) |
ty_struct(def_id, _) | ty_struct(def_id, _) |
ty_trait(def_id, _, _, _, _) => { ty_trait(~ty::TyTrait { def_id, .. }) => {
return Some(def_id); return Some(def_id);
} }
_ => { _ => {

View file

@ -131,7 +131,9 @@ impl<'f> Coerce<'f> {
}); });
} }
ty::ty_trait(def_id, ref substs, ty::UniqTraitStore, m, bounds) => { ty::ty_trait(~ty::TyTrait {
def_id, ref substs, store: ty::UniqTraitStore, mutability: m, bounds
}) => {
let result = self.unpack_actual_value(a, |sty_a| { let result = self.unpack_actual_value(a, |sty_a| {
match *sty_a { match *sty_a {
ty::ty_uniq(..) => { ty::ty_uniq(..) => {
@ -148,7 +150,9 @@ impl<'f> Coerce<'f> {
} }
} }
ty::ty_trait(def_id, ref substs, ty::RegionTraitStore(region), m, bounds) => { ty::ty_trait(~ty::TyTrait {
def_id, ref substs, store: ty::RegionTraitStore(region), mutability: m, bounds
}) => {
let result = self.unpack_actual_value(a, |sty_a| { let result = self.unpack_actual_value(a, |sty_a| {
match *sty_a { match *sty_a {
ty::ty_rptr(..) => { ty::ty_rptr(..) => {
@ -313,9 +317,9 @@ impl<'f> Coerce<'f> {
let r_a = self.get_ref().infcx.next_region_var(Coercion(self.get_ref().trace)); let r_a = self.get_ref().infcx.next_region_var(Coercion(self.get_ref().trace));
let a_borrowed = match *sty_a { let a_borrowed = match *sty_a {
ty::ty_trait(did, ref substs, _, _, b) => { ty::ty_trait(~ty::TyTrait { def_id, ref substs, bounds, .. }) => {
ty::mk_trait(tcx, did, substs.clone(), ty::mk_trait(tcx, def_id, substs.clone(),
ty::RegionTraitStore(r_a), b_mutbl, b) ty::RegionTraitStore(r_a), b_mutbl, bounds)
} }
_ => { _ => {
return self.subtype(a, b); return self.subtype(a, b);

View file

@ -500,18 +500,18 @@ pub fn super_tys<C:Combine>(this: &C, a: ty::t, b: ty::t) -> cres<ty::t> {
Ok(ty::mk_enum(tcx, a_id, substs)) Ok(ty::mk_enum(tcx, a_id, substs))
} }
(&ty::ty_trait(a_id, ref a_substs, a_store, a_mutbl, a_bounds), (&ty::ty_trait(ref a_),
&ty::ty_trait(b_id, ref b_substs, b_store, b_mutbl, b_bounds)) &ty::ty_trait(ref b_))
if a_id == b_id && a_mutbl == b_mutbl => { if a_.def_id == b_.def_id && a_.mutability == b_.mutability => {
debug!("Trying to match traits {:?} and {:?}", a, b); debug!("Trying to match traits {:?} and {:?}", a, b);
let substs = if_ok!(this.substs(a_id, a_substs, b_substs)); let substs = if_ok!(this.substs(a_.def_id, &a_.substs, &b_.substs));
let s = if_ok!(this.trait_stores(ty::terr_trait, a_store, b_store)); let s = if_ok!(this.trait_stores(ty::terr_trait, a_.store, b_.store));
let bounds = if_ok!(this.bounds(a_bounds, b_bounds)); let bounds = if_ok!(this.bounds(a_.bounds, b_.bounds));
Ok(ty::mk_trait(tcx, Ok(ty::mk_trait(tcx,
a_id, a_.def_id,
substs.clone(), substs.clone(),
s, s,
a_mutbl, a_.mutability,
bounds)) bounds))
} }

View file

@ -719,7 +719,7 @@ impl<'a> InferCtxt<'a> {
ty::EmptyBuiltinBounds()); ty::EmptyBuiltinBounds());
let dummy1 = self.resolve_type_vars_if_possible(dummy0); let dummy1 = self.resolve_type_vars_if_possible(dummy0);
match ty::get(dummy1).sty { match ty::get(dummy1).sty {
ty::ty_trait(ref def_id, ref substs, _, _, _) => { ty::ty_trait(~ty::TyTrait { ref def_id, ref substs, .. }) => {
ty::TraitRef { ty::TraitRef {
def_id: *def_id, def_id: *def_id,
substs: (*substs).clone(), substs: (*substs).clone(),
@ -976,4 +976,3 @@ impl Repr for RegionVariableOrigin {
} }
} }
} }

View file

@ -675,7 +675,7 @@ impl<'a> ConstraintContext<'a> {
substs, variance); substs, variance);
} }
ty::ty_trait(def_id, ref substs, _, _, _) => { ty::ty_trait(~ty::TyTrait { def_id, ref substs, .. }) => {
let trait_def = ty::lookup_trait_def(self.tcx(), def_id); let trait_def = ty::lookup_trait_def(self.tcx(), def_id);
self.add_constraints_from_substs(def_id, &trait_def.generics, self.add_constraints_from_substs(def_id, &trait_def.generics,
substs, variance); substs, variance);

View file

@ -484,7 +484,9 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
did, did,
false) false)
} }
ty_trait(did, ref substs, s, mutbl, ref bounds) => { ty_trait(~ty::TyTrait {
def_id: did, ref substs, store: s, mutability: mutbl, ref bounds
}) => {
let base = ty::item_path_str(cx, did); let base = ty::item_path_str(cx, did);
let ty = parameterized(cx, base, &substs.regions, let ty = parameterized(cx, base, &substs.regions,
substs.tps.as_slice(), did, true); substs.tps.as_slice(), did, true);