Store Substs in an arena in the tcx.
This current inflates memory use more than 3 times.
This commit is contained in:
parent
7cd6bf67a2
commit
4f2b0f032a
34 changed files with 151 additions and 139 deletions
|
|
@ -262,8 +262,8 @@ fn parse_substs<'a, 'tcx>(st: &mut PState<'a, 'tcx>,
|
|||
let types =
|
||||
parse_vec_per_param_space(st, |st| parse_ty(st, |x,y| conv(x,y)));
|
||||
|
||||
return subst::Substs { types: types,
|
||||
regions: regions };
|
||||
subst::Substs { types: types,
|
||||
regions: regions }
|
||||
}
|
||||
|
||||
fn parse_region_substs(st: &mut PState, conv: conv_did) -> subst::RegionSubsts {
|
||||
|
|
@ -380,7 +380,7 @@ fn parse_trait_ref<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
|
|||
-> ty::TraitRef<'tcx> {
|
||||
let def = parse_def(st, NominalType, |x,y| conv(x,y));
|
||||
let substs = parse_substs(st, |x,y| conv(x,y));
|
||||
ty::TraitRef {def_id: def, substs: substs}
|
||||
ty::TraitRef {def_id: def, substs: st.tcx.mk_substs(substs)}
|
||||
}
|
||||
|
||||
fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
||||
|
|
@ -409,7 +409,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
let def = parse_def(st, NominalType, |x,y| conv(x,y));
|
||||
let substs = parse_substs(st, |x,y| conv(x,y));
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_enum(st.tcx, def, substs);
|
||||
return ty::mk_enum(st.tcx, def, st.tcx.mk_substs(substs));
|
||||
}
|
||||
'x' => {
|
||||
assert_eq!(next(st), '[');
|
||||
|
|
@ -490,7 +490,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
let did = parse_def(st, NominalType, |x,y| conv(x,y));
|
||||
let substs = parse_substs(st, |x,y| conv(x,y));
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_struct(st.tcx, did, substs);
|
||||
return ty::mk_struct(st.tcx, did, st.tcx.mk_substs(substs));
|
||||
}
|
||||
'k' => {
|
||||
assert_eq!(next(st), '[');
|
||||
|
|
@ -498,7 +498,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
let region = parse_region(st, |x,y| conv(x,y));
|
||||
let substs = parse_substs(st, |x,y| conv(x,y));
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_unboxed_closure(st.tcx, did, region, substs);
|
||||
return ty::mk_unboxed_closure(st.tcx, did, region, st.tcx.mk_substs(substs));
|
||||
}
|
||||
'e' => {
|
||||
return ty::mk_err();
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ fn enc_bound_region(w: &mut SeekableMemWriter, cx: &ctxt, br: ty::BoundRegion) {
|
|||
pub fn enc_trait_ref<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
|
||||
s: &ty::TraitRef<'tcx>) {
|
||||
mywrite!(w, "{}|", (cx.ds)(s.def_id));
|
||||
enc_substs(w, cx, &s.substs);
|
||||
enc_substs(w, cx, s.substs);
|
||||
}
|
||||
|
||||
pub fn enc_trait_store(w: &mut SeekableMemWriter, cx: &ctxt, s: ty::TraitStore) {
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
// Select just those fields of the `with`
|
||||
// expression that will actually be used
|
||||
let with_fields = match with_cmt.ty.sty {
|
||||
ty::ty_struct(did, ref substs) => {
|
||||
ty::ty_struct(did, substs) => {
|
||||
ty::struct_fields(self.tcx(), did, substs)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1271,4 +1271,3 @@ fn copy_or_move<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
Copy
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
bounds: bounds },
|
||||
ty_a)))
|
||||
}
|
||||
(&ty::ty_struct(did_a, ref substs_a), &ty::ty_struct(did_b, ref substs_b))
|
||||
(&ty::ty_struct(did_a, substs_a), &ty::ty_struct(did_b, substs_b))
|
||||
if did_a == did_b => {
|
||||
debug!("unsizing a struct");
|
||||
// Try unsizing each type param in turn to see if we end up with ty_b.
|
||||
|
|
@ -383,7 +383,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
// Check that the whole types match.
|
||||
let mut new_substs = substs_a.clone();
|
||||
new_substs.types.get_mut_slice(subst::TypeSpace)[i] = new_tp;
|
||||
let ty = ty::mk_struct(tcx, did_a, new_substs);
|
||||
let ty = ty::mk_struct(tcx, did_a, tcx.mk_substs(new_substs));
|
||||
if self.get_ref().infcx.try(|_| sub.tys(ty, ty_b)).is_err() {
|
||||
debug!("Unsized type parameter '{}', but still \
|
||||
could not match types {} and {}",
|
||||
|
|
|
|||
|
|
@ -470,13 +470,13 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
Ok(a)
|
||||
}
|
||||
|
||||
(&ty::ty_enum(a_id, ref a_substs),
|
||||
&ty::ty_enum(b_id, ref b_substs))
|
||||
(&ty::ty_enum(a_id, a_substs),
|
||||
&ty::ty_enum(b_id, b_substs))
|
||||
if a_id == b_id => {
|
||||
let substs = try!(this.substs(a_id,
|
||||
a_substs,
|
||||
b_substs));
|
||||
Ok(ty::mk_enum(tcx, a_id, substs))
|
||||
Ok(ty::mk_enum(tcx, a_id, tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::ty_trait(ref a_),
|
||||
|
|
@ -487,21 +487,21 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
Ok(ty::mk_trait(tcx, principal, bounds))
|
||||
}
|
||||
|
||||
(&ty::ty_struct(a_id, ref a_substs), &ty::ty_struct(b_id, ref b_substs))
|
||||
(&ty::ty_struct(a_id, a_substs), &ty::ty_struct(b_id, b_substs))
|
||||
if a_id == b_id => {
|
||||
let substs = try!(this.substs(a_id, a_substs, b_substs));
|
||||
Ok(ty::mk_struct(tcx, a_id, substs))
|
||||
Ok(ty::mk_struct(tcx, a_id, tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::ty_unboxed_closure(a_id, a_region, ref a_substs),
|
||||
&ty::ty_unboxed_closure(b_id, b_region, ref b_substs))
|
||||
(&ty::ty_unboxed_closure(a_id, a_region, a_substs),
|
||||
&ty::ty_unboxed_closure(b_id, b_region, b_substs))
|
||||
if a_id == b_id => {
|
||||
// All ty_unboxed_closure types with the same id represent
|
||||
// the (anonymous) type of the same closure expression. So
|
||||
// all of their regions should be equated.
|
||||
let region = try!(this.equate().regions(a_region, b_region));
|
||||
let substs = try!(this.substs_variances(None, a_substs, b_substs));
|
||||
Ok(ty::mk_unboxed_closure(tcx, a_id, region, substs))
|
||||
Ok(ty::mk_unboxed_closure(tcx, a_id, region, tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => {
|
||||
|
|
@ -813,5 +813,3 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
|||
self.infcx.next_region_var(MiscVariable(self.span))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn type_size_is_affected_by_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, typ: Ty<
|
|||
// No need to continue; we now know the result.
|
||||
false
|
||||
}
|
||||
ty::ty_enum(did, ref substs) => {
|
||||
ty::ty_enum(did, substs) => {
|
||||
for enum_variant in (*ty::enum_variants(tcx, did)).iter() {
|
||||
for argument_type in enum_variant.args.iter() {
|
||||
let argument_type = argument_type.subst(tcx, substs);
|
||||
|
|
@ -51,7 +51,7 @@ fn type_size_is_affected_by_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, typ: Ty<
|
|||
// Don't traverse substitutions.
|
||||
false
|
||||
}
|
||||
ty::ty_struct(did, ref substs) => {
|
||||
ty::ty_struct(did, substs) => {
|
||||
for field in ty::struct_fields(tcx, did, substs).iter() {
|
||||
result = result ||
|
||||
type_size_is_affected_by_type_parameters(tcx,
|
||||
|
|
|
|||
|
|
@ -1210,7 +1210,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
Ok(If(tys.clone()))
|
||||
}
|
||||
|
||||
ty::ty_unboxed_closure(def_id, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(def_id, _, substs) => {
|
||||
// FIXME -- This case is tricky. In the case of by-ref
|
||||
// closures particularly, we need the results of
|
||||
// inference to decide how to reflect the type of each
|
||||
|
|
@ -1248,7 +1248,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
let types: Vec<Ty> =
|
||||
ty::struct_fields(self.tcx(), def_id, substs)
|
||||
.iter()
|
||||
|
|
@ -1257,7 +1257,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
nominal(self, bound, def_id, types)
|
||||
}
|
||||
|
||||
ty::ty_enum(def_id, ref substs) => {
|
||||
ty::ty_enum(def_id, substs) => {
|
||||
let types: Vec<Ty> =
|
||||
ty::substd_enum_variants(self.tcx(), def_id, substs)
|
||||
.iter()
|
||||
|
|
@ -1574,7 +1574,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self_ty);
|
||||
let trait_ref = Rc::new(ty::Binder(ty::TraitRef {
|
||||
def_id: obligation.trait_ref.def_id(),
|
||||
substs: substs,
|
||||
substs: self.tcx().mk_substs(substs),
|
||||
}));
|
||||
|
||||
try!(self.confirm_poly_trait_refs(obligation.cause.clone(),
|
||||
|
|
@ -1615,7 +1615,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.self_ty());
|
||||
let trait_ref = Rc::new(ty::Binder(ty::TraitRef {
|
||||
def_id: obligation.trait_ref.def_id(),
|
||||
substs: substs,
|
||||
substs: self.tcx().mk_substs(substs),
|
||||
}));
|
||||
|
||||
debug!("confirm_unboxed_closure_candidate(closure_def_id={}, trait_ref={})",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
|
|
@ -276,7 +275,7 @@ pub fn poly_trait_ref_for_builtin_bound<'tcx>(
|
|||
Ok(def_id) => {
|
||||
Ok(Rc::new(ty::Binder(ty::TraitRef {
|
||||
def_id: def_id,
|
||||
substs: Substs::empty().with_self_ty(param_ty)
|
||||
substs: tcx.mk_substs(Substs::empty().with_self_ty(param_ty))
|
||||
})))
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -610,6 +610,7 @@ pub struct TransmuteRestriction<'tcx> {
|
|||
pub struct ctxt<'tcx> {
|
||||
/// The arena that types are allocated from.
|
||||
type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<Substs<'tcx>>,
|
||||
|
||||
/// Specifically use a speedy hash algorithm for this hash map, it's used
|
||||
/// quite often.
|
||||
|
|
@ -1312,7 +1313,7 @@ pub enum sty<'tcx> {
|
|||
/// from the tcx, use the `NodeId` from the `ast::Ty` and look it up in
|
||||
/// the `ast_ty_to_ty_cache`. This is probably true for `ty_struct` as
|
||||
/// well.`
|
||||
ty_enum(DefId, Substs<'tcx>),
|
||||
ty_enum(DefId, &'tcx Substs<'tcx>),
|
||||
ty_uniq(Ty<'tcx>),
|
||||
ty_str,
|
||||
ty_vec(Ty<'tcx>, Option<uint>), // Second field is length.
|
||||
|
|
@ -1325,9 +1326,9 @@ pub enum sty<'tcx> {
|
|||
|
||||
ty_closure(Box<ClosureTy<'tcx>>),
|
||||
ty_trait(Box<TyTrait<'tcx>>),
|
||||
ty_struct(DefId, Substs<'tcx>),
|
||||
ty_struct(DefId, &'tcx Substs<'tcx>),
|
||||
|
||||
ty_unboxed_closure(DefId, Region, Substs<'tcx>),
|
||||
ty_unboxed_closure(DefId, Region, &'tcx Substs<'tcx>),
|
||||
|
||||
ty_tup(Vec<Ty<'tcx>>),
|
||||
|
||||
|
|
@ -1384,7 +1385,7 @@ impl<'tcx> TyTrait<'tcx> {
|
|||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub struct TraitRef<'tcx> {
|
||||
pub def_id: DefId,
|
||||
pub substs: Substs<'tcx>,
|
||||
pub substs: &'tcx Substs<'tcx>,
|
||||
}
|
||||
|
||||
pub type PolyTraitRef<'tcx> = Binder<TraitRef<'tcx>>;
|
||||
|
|
@ -1820,7 +1821,7 @@ impl<'tcx> GenericBounds<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> TraitRef<'tcx> {
|
||||
pub fn new(def_id: ast::DefId, substs: Substs<'tcx>) -> TraitRef<'tcx> {
|
||||
pub fn new(def_id: ast::DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> {
|
||||
TraitRef { def_id: def_id, substs: substs }
|
||||
}
|
||||
|
||||
|
|
@ -2049,6 +2050,7 @@ impl UnboxedClosureKind {
|
|||
|
||||
pub fn mk_ctxt<'tcx>(s: Session,
|
||||
type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<Substs<'tcx>>,
|
||||
dm: DefMap,
|
||||
named_region_map: resolve_lifetime::NamedRegionMap,
|
||||
map: ast_map::Map<'tcx>,
|
||||
|
|
@ -2059,6 +2061,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||
stability: stability::Index) -> ctxt<'tcx> {
|
||||
ctxt {
|
||||
type_arena: type_arena,
|
||||
substs_arena: substs_arena,
|
||||
interner: RefCell::new(FnvHashMap::new()),
|
||||
named_region_map: named_region_map,
|
||||
item_variance_map: RefCell::new(DefIdMap::new()),
|
||||
|
|
@ -2119,6 +2122,12 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||
|
||||
// Type constructors
|
||||
|
||||
impl<'tcx> ctxt<'tcx> {
|
||||
pub fn mk_substs(&self, subst: Substs<'tcx>) -> &'tcx Substs<'tcx> {
|
||||
self.substs_arena.alloc(subst)
|
||||
}
|
||||
}
|
||||
|
||||
// Interns a type/name combination, stores the resulting box in cx.interner,
|
||||
// and returns the box as cast to an unsafe ptr (see comments for Ty above).
|
||||
pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
|
||||
|
|
@ -2222,7 +2231,7 @@ impl FlagComputation {
|
|||
}
|
||||
}
|
||||
|
||||
&ty_unboxed_closure(_, ref region, ref substs) => {
|
||||
&ty_unboxed_closure(_, ref region, substs) => {
|
||||
self.add_region(*region);
|
||||
self.add_substs(substs);
|
||||
}
|
||||
|
|
@ -2231,7 +2240,7 @@ impl FlagComputation {
|
|||
self.add_flags(HAS_TY_INFER)
|
||||
}
|
||||
|
||||
&ty_enum(_, ref substs) | &ty_struct(_, ref substs) => {
|
||||
&ty_enum(_, substs) | &ty_struct(_, substs) => {
|
||||
self.add_substs(substs);
|
||||
}
|
||||
|
||||
|
|
@ -2365,7 +2374,7 @@ pub fn mk_str_slice<'tcx>(cx: &ctxt<'tcx>, r: Region, m: ast::Mutability) -> Ty<
|
|||
})
|
||||
}
|
||||
|
||||
pub fn mk_enum<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId, substs: Substs<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_enum<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
mk_t(cx, ty_enum(did, substs))
|
||||
}
|
||||
|
|
@ -2459,13 +2468,13 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
|
|||
}
|
||||
|
||||
pub fn mk_struct<'tcx>(cx: &ctxt<'tcx>, struct_id: ast::DefId,
|
||||
substs: Substs<'tcx>) -> Ty<'tcx> {
|
||||
substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
mk_t(cx, ty_struct(struct_id, substs))
|
||||
}
|
||||
|
||||
pub fn mk_unboxed_closure<'tcx>(cx: &ctxt<'tcx>, closure_id: ast::DefId,
|
||||
region: Region, substs: Substs<'tcx>)
|
||||
region: Region, substs: &'tcx Substs<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
mk_t(cx, ty_unboxed_closure(closure_id, region, substs))
|
||||
}
|
||||
|
|
@ -2688,7 +2697,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
|||
|
||||
pub fn simd_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
ty_struct(did, ref substs) => {
|
||||
ty_struct(did, substs) => {
|
||||
let fields = lookup_struct_fields(cx, did);
|
||||
lookup_field_type(cx, did, fields[0].id, substs)
|
||||
}
|
||||
|
|
@ -2787,7 +2796,7 @@ pub fn type_needs_unwind_cleanup<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
ty_bool | ty_int(_) | ty_uint(_) |
|
||||
ty_float(_) | ty_tup(_) | ty_ptr(_) => false,
|
||||
|
||||
ty_enum(did, ref substs) =>
|
||||
ty_enum(did, substs) =>
|
||||
enum_variants(cx, did).iter().any(|v|
|
||||
v.args.iter().any(|aty| {
|
||||
let t = aty.subst(cx, substs);
|
||||
|
|
@ -3055,7 +3064,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
}
|
||||
ty_str => TC::Nonsized,
|
||||
|
||||
ty_struct(did, ref substs) => {
|
||||
ty_struct(did, substs) => {
|
||||
let flds = struct_fields(cx, did, substs);
|
||||
let mut res =
|
||||
TypeContents::union(flds[],
|
||||
|
|
@ -3071,7 +3080,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
apply_lang_items(cx, did, res)
|
||||
}
|
||||
|
||||
ty_unboxed_closure(did, r, ref substs) => {
|
||||
ty_unboxed_closure(did, r, substs) => {
|
||||
// FIXME(#14449): `borrowed_contents` below assumes `&mut`
|
||||
// unboxed closure.
|
||||
let upvars = unboxed_closure_upvars(cx, did, substs);
|
||||
|
|
@ -3085,7 +3094,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
|ty| tc_ty(cx, *ty, cache))
|
||||
}
|
||||
|
||||
ty_enum(did, ref substs) => {
|
||||
ty_enum(did, substs) => {
|
||||
let variants = substd_enum_variants(cx, did, substs);
|
||||
let mut res =
|
||||
TypeContents::union(variants[], |variant| {
|
||||
|
|
@ -3377,7 +3386,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
ty_struct(did, ref substs) => {
|
||||
ty_struct(did, substs) => {
|
||||
seen.push(did);
|
||||
let fields = struct_fields(cx, did, substs);
|
||||
let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty));
|
||||
|
|
@ -3385,7 +3394,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
|||
r
|
||||
}
|
||||
|
||||
ty_unboxed_closure(did, _, ref substs) => {
|
||||
ty_unboxed_closure(did, _, substs) => {
|
||||
let upvars = unboxed_closure_upvars(cx, did, substs);
|
||||
upvars.iter().any(|f| type_requires(cx, seen, r_ty, f.ty))
|
||||
}
|
||||
|
|
@ -3398,7 +3407,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
ty_enum(did, ref substs) => {
|
||||
ty_enum(did, substs) => {
|
||||
seen.push(did);
|
||||
let vs = enum_variants(cx, did);
|
||||
let r = !vs.is_empty() && vs.iter().all(|variant| {
|
||||
|
|
@ -3465,11 +3474,11 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
ty_vec(ty, Some(_)) => {
|
||||
is_type_structurally_recursive(cx, sp, seen, ty)
|
||||
}
|
||||
ty_struct(did, ref substs) => {
|
||||
ty_struct(did, substs) => {
|
||||
let fields = struct_fields(cx, did, substs);
|
||||
find_nonrepresentable(cx, sp, seen, fields.iter().map(|f| f.mt.ty))
|
||||
}
|
||||
ty_enum(did, ref substs) => {
|
||||
ty_enum(did, substs) => {
|
||||
let vs = enum_variants(cx, did);
|
||||
let iter = vs.iter()
|
||||
.flat_map(|variant| { variant.args.iter() })
|
||||
|
|
@ -3477,7 +3486,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
|
||||
find_nonrepresentable(cx, sp, seen, iter)
|
||||
}
|
||||
ty_unboxed_closure(did, _, ref substs) => {
|
||||
ty_unboxed_closure(did, _, substs) => {
|
||||
let upvars = unboxed_closure_upvars(cx, did, substs);
|
||||
find_nonrepresentable(cx, sp, seen, upvars.iter().map(|f| f.ty))
|
||||
}
|
||||
|
|
@ -3697,7 +3706,7 @@ pub fn lltype_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
ty_str | ty_trait(..) | ty_vec(..) => ty,
|
||||
ty_struct(def_id, ref substs) => {
|
||||
ty_struct(def_id, substs) => {
|
||||
let unsized_fields: Vec<_> = struct_fields(cx, def_id, substs).iter()
|
||||
.map(|f| f.mt.ty).filter(|ty| !type_is_sized(cx, *ty)).collect();
|
||||
// Exactly one of the fields must be unsized.
|
||||
|
|
@ -3801,16 +3810,16 @@ pub fn positional_element_ty<'tcx>(cx: &ctxt<'tcx>,
|
|||
(&ty_tup(ref v), None) => v.get(i).map(|&t| t),
|
||||
|
||||
|
||||
(&ty_struct(def_id, ref substs), None) => lookup_struct_fields(cx, def_id)
|
||||
(&ty_struct(def_id, substs), None) => lookup_struct_fields(cx, def_id)
|
||||
.get(i)
|
||||
.map(|&t|lookup_item_type(cx, t.id).ty.subst(cx, substs)),
|
||||
|
||||
(&ty_enum(def_id, ref substs), Some(variant_def_id)) => {
|
||||
(&ty_enum(def_id, substs), Some(variant_def_id)) => {
|
||||
let variant_info = enum_variant_with_id(cx, def_id, variant_def_id);
|
||||
variant_info.args.get(i).map(|t|t.subst(cx, substs))
|
||||
}
|
||||
|
||||
(&ty_enum(def_id, ref substs), None) => {
|
||||
(&ty_enum(def_id, substs), None) => {
|
||||
assert!(enum_is_univariant(cx, def_id));
|
||||
let enum_variants = enum_variants(cx, def_id);
|
||||
let variant_info = &(*enum_variants)[0];
|
||||
|
|
@ -3829,12 +3838,12 @@ pub fn named_element_ty<'tcx>(cx: &ctxt<'tcx>,
|
|||
variant: Option<ast::DefId>) -> Option<Ty<'tcx>> {
|
||||
|
||||
match (&ty.sty, variant) {
|
||||
(&ty_struct(def_id, ref substs), None) => {
|
||||
(&ty_struct(def_id, substs), None) => {
|
||||
let r = lookup_struct_fields(cx, def_id);
|
||||
r.iter().find(|f| f.name == n)
|
||||
.map(|&f| lookup_field_type(cx, def_id, f.id, substs))
|
||||
}
|
||||
(&ty_enum(def_id, ref substs), Some(variant_def_id)) => {
|
||||
(&ty_enum(def_id, substs), Some(variant_def_id)) => {
|
||||
let variant_info = enum_variant_with_id(cx, def_id, variant_def_id);
|
||||
variant_info.arg_names.as_ref()
|
||||
.expect("must have struct enum variant if accessing a named fields")
|
||||
|
|
@ -4197,12 +4206,12 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
|
|||
ty_to_string(cx, ty))[])
|
||||
},
|
||||
&UnsizeStruct(box ref k, tp_index) => match ty.sty {
|
||||
ty_struct(did, ref substs) => {
|
||||
ty_struct(did, substs) => {
|
||||
let ty_substs = substs.types.get_slice(subst::TypeSpace);
|
||||
let new_ty = unsize_ty(cx, ty_substs[tp_index], k, span);
|
||||
let mut unsized_substs = substs.clone();
|
||||
unsized_substs.types.get_mut_slice(subst::TypeSpace)[tp_index] = new_ty;
|
||||
mk_struct(cx, did, unsized_substs)
|
||||
mk_struct(cx, did, cx.mk_substs(unsized_substs))
|
||||
}
|
||||
_ => cx.sess.span_bug(span,
|
||||
format!("UnsizeStruct with bad sty: {}",
|
||||
|
|
@ -5227,9 +5236,10 @@ pub fn predicates_for_trait_ref<'tcx>(tcx: &ctxt<'tcx>,
|
|||
trait_def.bounds.trait_bounds
|
||||
.iter()
|
||||
.map(|bound_trait_ref| {
|
||||
let substs = tcx.mk_substs(bound_trait_ref.substs().subst(tcx, trait_ref.substs()));
|
||||
ty::Binder(
|
||||
ty::TraitRef::new(bound_trait_ref.def_id(),
|
||||
bound_trait_ref.substs().subst(tcx, trait_ref.substs())))
|
||||
substs))
|
||||
})
|
||||
.map(|bound_trait_ref| Rc::new(bound_trait_ref))
|
||||
.collect();
|
||||
|
|
@ -6305,8 +6315,8 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
|||
ty_trait(ref t) => {
|
||||
accumulator.push_all(t.principal.substs().regions().as_slice());
|
||||
}
|
||||
ty_enum(_, ref substs) |
|
||||
ty_struct(_, ref substs) => {
|
||||
ty_enum(_, substs) |
|
||||
ty_struct(_, substs) => {
|
||||
accum_substs(accumulator, substs);
|
||||
}
|
||||
ty_closure(ref closure_ty) => {
|
||||
|
|
@ -6315,7 +6325,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
|||
UniqTraitStore => {}
|
||||
}
|
||||
}
|
||||
ty_unboxed_closure(_, ref region, ref substs) => {
|
||||
ty_unboxed_closure(_, ref region, substs) => {
|
||||
accumulator.push(*region);
|
||||
accum_substs(accumulator, substs);
|
||||
}
|
||||
|
|
@ -6702,4 +6712,3 @@ impl<T:RegionEscape,U:RegionEscape> RegionEscape for OutlivesPredicate<T,U> {
|
|||
self.0.has_regions_escaping_depth(depth) || self.1.has_regions_escaping_depth(depth)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
|||
{
|
||||
ty::TraitRef {
|
||||
def_id: t.def_id,
|
||||
substs: t.substs.fold_with(this),
|
||||
substs: this.tcx().mk_substs(substs),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -833,4 +833,3 @@ pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>
|
|||
shift_region(region, amount)
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
param_ty.user_string(cx)
|
||||
}
|
||||
}
|
||||
ty_enum(did, ref substs) | ty_struct(did, ref substs) => {
|
||||
ty_enum(did, substs) | ty_struct(did, substs) => {
|
||||
let base = ty::item_path_str(cx, did);
|
||||
let generics = ty::lookup_item_type(cx, did).generics;
|
||||
parameterized(cx, base.as_slice(), substs, &generics, did)
|
||||
|
|
@ -449,7 +449,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
bound_str)
|
||||
}
|
||||
ty_str => "str".to_string(),
|
||||
ty_unboxed_closure(ref did, _, ref substs) => {
|
||||
ty_unboxed_closure(ref did, _, substs) => {
|
||||
let unboxed_closures = cx.unboxed_closures.borrow();
|
||||
unboxed_closures.get(did).map(|cl| {
|
||||
closure_to_string(cx, &cl.closure_type.subst(cx, substs))
|
||||
|
|
@ -1209,8 +1209,10 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
|
|||
fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
let path_str = ty::item_path_str(tcx, self.def_id);
|
||||
let trait_def = ty::lookup_trait_def(tcx, self.def_id);
|
||||
parameterized(tcx, path_str.as_slice(), &self.substs,
|
||||
parameterized(tcx, path_str.as_slice(), self.substs,
|
||||
&trait_def.generics, self.def_id)
|
||||
let did = trait_def.trait_ref.def_id;
|
||||
parameterized(tcx, base.as_slice(), trait_ref.substs, &trait_def.generics, did)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
(&ty::ty_enum(enum_def_id, ref substs), ref enum_variant_info) => {
|
||||
(&ty::ty_enum(enum_def_id, substs), ref enum_variant_info) => {
|
||||
let variant_info = {
|
||||
let mut variants = ty::substd_enum_variants(tcx, enum_def_id, substs);
|
||||
match *enum_variant_info {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use rustc::session::Session;
|
|||
use rustc::session::config::{mod, Input, OutputFilenames};
|
||||
use rustc::lint;
|
||||
use rustc::metadata::creader;
|
||||
use rustc::middle::{stability, ty, reachable};
|
||||
use rustc::middle::{stability, ty, reachable, subst};
|
||||
use rustc::middle::dependency_format;
|
||||
use rustc::middle;
|
||||
use rustc::plugin::load::Plugins;
|
||||
|
|
@ -80,7 +80,8 @@ pub fn compile_input(sess: Session,
|
|||
if stop_after_phase_2(&sess) { return; }
|
||||
|
||||
let type_arena = TypedArena::new();
|
||||
let analysis = phase_3_run_analysis_passes(sess, ast_map, &type_arena, id);
|
||||
let substs_arena = TypedArena::new();
|
||||
let analysis = phase_3_run_analysis_passes(sess, ast_map, &type_arena, &substs_arena, id);
|
||||
phase_save_analysis(&analysis.ty_cx.sess, analysis.ty_cx.map.krate(), &analysis, outdir);
|
||||
|
||||
if log_enabled!(::log::INFO) {
|
||||
|
|
@ -343,6 +344,7 @@ pub fn assign_node_ids_and_map<'ast>(sess: &Session,
|
|||
pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
||||
ast_map: ast_map::Map<'tcx>,
|
||||
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<subst::Substs<'tcx>>,
|
||||
name: String) -> ty::CrateAnalysis<'tcx> {
|
||||
let time_passes = sess.time_passes();
|
||||
let krate = ast_map.krate();
|
||||
|
|
@ -403,6 +405,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
|||
|
||||
let ty_cx = ty::mk_ctxt(sess,
|
||||
type_arena,
|
||||
substs_arena,
|
||||
def_map,
|
||||
named_region_map,
|
||||
ast_map,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use rustc_trans::back::link;
|
|||
|
||||
use driver;
|
||||
|
||||
use rustc::middle::ty;
|
||||
use rustc::middle::{ty, subst};
|
||||
use rustc::middle::cfg;
|
||||
use rustc::middle::cfg::graphviz::LabelledCFG;
|
||||
use rustc::session::Session;
|
||||
|
|
@ -113,6 +113,7 @@ impl PpSourceMode {
|
|||
sess: Session,
|
||||
ast_map: Option<ast_map::Map<'tcx>>,
|
||||
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<subst::Substs<'tcx>>,
|
||||
id: String,
|
||||
payload: B,
|
||||
f: F) -> A where
|
||||
|
|
@ -135,7 +136,7 @@ impl PpSourceMode {
|
|||
PpmTyped => {
|
||||
let ast_map = ast_map.expect("--pretty=typed missing ast_map");
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map,
|
||||
type_arena, id);
|
||||
type_arena, substs_arena, id);
|
||||
let annotation = TypedAnnotation { analysis: analysis };
|
||||
f(&annotation, payload)
|
||||
}
|
||||
|
|
@ -511,6 +512,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
|
||||
let mut forest = ast_map::Forest::new(krate);
|
||||
let type_arena = TypedArena::new();
|
||||
let substs_arena = TypedArena::new();
|
||||
|
||||
let (krate, ast_map) = if compute_ast_map {
|
||||
let map = driver::assign_node_ids_and_map(&sess, &mut forest);
|
||||
|
|
@ -539,7 +541,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
match (ppm, opt_uii) {
|
||||
(PpmSource(s), None) =>
|
||||
s.call_with_pp_support(
|
||||
sess, ast_map, &type_arena, id, out, |annotation, out| {
|
||||
sess, ast_map, &type_arena, &substs_arena, id, out, |annotation, out| {
|
||||
debug!("pretty printing source code {}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust::print_crate(sess.codemap(),
|
||||
|
|
@ -554,7 +556,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
|
||||
(PpmSource(s), Some(uii)) =>
|
||||
s.call_with_pp_support(
|
||||
sess, ast_map, &type_arena, id, (out,uii), |annotation, (out,uii)| {
|
||||
sess, ast_map, &type_arena, &substs_arena, id, (out,uii), |annotation, (out,uii)| {
|
||||
debug!("pretty printing source code {}", s);
|
||||
let sess = annotation.sess();
|
||||
let ast_map = annotation.ast_map()
|
||||
|
|
@ -597,7 +599,8 @@ pub fn pretty_print_input(sess: Session,
|
|||
Some(code) => {
|
||||
let variants = gather_flowgraph_variants(&sess);
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map,
|
||||
&type_arena, id);
|
||||
&type_arena, &substs_arena,
|
||||
id);
|
||||
print_flowgraph(variants, analysis, code, out)
|
||||
}
|
||||
None => {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::ty_tup(ref elems) => {
|
||||
Univariant(mk_struct(cx, elems[], false, t), false)
|
||||
}
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
let fields = ty::lookup_struct_fields(cx.tcx(), def_id);
|
||||
let mut ftys = fields.iter().map(|field| {
|
||||
ty::lookup_field_type(cx.tcx(), def_id, field.id, substs)
|
||||
|
|
@ -167,12 +167,12 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
Univariant(mk_struct(cx, ftys[], packed, t), dtor)
|
||||
}
|
||||
ty::ty_unboxed_closure(def_id, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(def_id, _, substs) => {
|
||||
let upvars = ty::unboxed_closure_upvars(cx.tcx(), def_id, substs);
|
||||
let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
|
||||
Univariant(mk_struct(cx, upvar_types[], false, t), false)
|
||||
}
|
||||
ty::ty_enum(def_id, ref substs) => {
|
||||
ty::ty_enum(def_id, substs) => {
|
||||
let cases = get_cases(cx.tcx(), def_id, substs);
|
||||
let hint = *ty::lookup_repr_hints(cx.tcx(), def_id)[].get(0)
|
||||
.unwrap_or(&attr::ReprAny);
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
ty::ty_closure(ref f) => {
|
||||
(f.sig.0.inputs.clone(), f.sig.0.output, f.abi, Some(Type::i8p(ccx)))
|
||||
}
|
||||
ty::ty_unboxed_closure(closure_did, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(closure_did, _, substs) => {
|
||||
let unboxed_closures = ccx.tcx().unboxed_closures.borrow();
|
||||
let unboxed_closure = &(*unboxed_closures)[closure_did];
|
||||
let function_type = unboxed_closure.closure_type.clone();
|
||||
|
|
@ -529,9 +529,9 @@ pub fn get_res_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
assert_eq!(did.krate, ast::LOCAL_CRATE);
|
||||
|
||||
// Since we're in trans we don't care for any region parameters
|
||||
let ref substs = subst::Substs::erased(substs.types.clone());
|
||||
let substs = subst::Substs::erased(substs.types.clone());
|
||||
|
||||
let (val, _) = monomorphize::monomorphic_fn(ccx, did, substs, None);
|
||||
let (val, _) = monomorphize::monomorphic_fn(ccx, did, &substs, None);
|
||||
|
||||
val
|
||||
} else if did.krate == ast::LOCAL_CRATE {
|
||||
|
|
@ -749,7 +749,7 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
})
|
||||
}
|
||||
ty::ty_unboxed_closure(def_id, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(def_id, _, substs) => {
|
||||
let repr = adt::represent_type(cx.ccx(), t);
|
||||
let upvars = ty::unboxed_closure_upvars(cx.tcx(), def_id, substs);
|
||||
for (i, upvar) in upvars.iter().enumerate() {
|
||||
|
|
@ -769,7 +769,7 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
cx = f(cx, llfld_a, *arg);
|
||||
}
|
||||
}
|
||||
ty::ty_enum(tid, ref substs) => {
|
||||
ty::ty_enum(tid, substs) => {
|
||||
let fcx = cx.fcx;
|
||||
let ccx = fcx.ccx;
|
||||
|
||||
|
|
@ -2466,7 +2466,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
|
|||
let (fn_sig, abi, has_env) = match fn_ty.sty {
|
||||
ty::ty_closure(ref f) => (f.sig.clone(), f.abi, true),
|
||||
ty::ty_bare_fn(_, ref f) => (f.sig.clone(), f.abi, false),
|
||||
ty::ty_unboxed_closure(closure_did, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(closure_did, _, substs) => {
|
||||
let unboxed_closures = ccx.tcx().unboxed_closures.borrow();
|
||||
let ref function_type = (*unboxed_closures)[closure_did]
|
||||
.closure_type;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ pub use trans::context::CrateContext;
|
|||
fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
|
||||
fields.len() == 1 &&
|
||||
fields[0].name ==
|
||||
|
|
|
|||
|
|
@ -360,11 +360,11 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
ty::ty_float(_) => {
|
||||
push_debuginfo_type_name(cx, type_, false, &mut unique_type_id);
|
||||
},
|
||||
ty::ty_enum(def_id, ref substs) => {
|
||||
ty::ty_enum(def_id, substs) => {
|
||||
unique_type_id.push_str("enum ");
|
||||
from_def_id_and_substs(self, cx, def_id, substs, &mut unique_type_id);
|
||||
},
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
unique_type_id.push_str("struct ");
|
||||
from_def_id_and_substs(self, cx, def_id, substs, &mut unique_type_id);
|
||||
},
|
||||
|
|
@ -469,7 +469,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
closure_ty.clone(),
|
||||
&mut unique_type_id);
|
||||
},
|
||||
ty::ty_unboxed_closure(ref def_id, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(ref def_id, _, substs) => {
|
||||
let closure_ty = cx.tcx().unboxed_closures.borrow()
|
||||
.get(def_id).unwrap().closure_type.subst(cx.tcx(), substs);
|
||||
self.get_unique_type_id_of_closure_type(cx,
|
||||
|
|
@ -3003,12 +3003,12 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::ty_closure(ref closurety) => {
|
||||
subroutine_type_metadata(cx, unique_type_id, &closurety.sig, usage_site_span)
|
||||
}
|
||||
ty::ty_unboxed_closure(ref def_id, _, ref substs) => {
|
||||
ty::ty_unboxed_closure(ref def_id, _, substs) => {
|
||||
let sig = cx.tcx().unboxed_closures.borrow()
|
||||
.get(def_id).unwrap().closure_type.sig.subst(cx.tcx(), substs);
|
||||
subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span)
|
||||
}
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
prepare_struct_metadata(cx,
|
||||
t,
|
||||
def_id,
|
||||
|
|
@ -3763,8 +3763,8 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::ty_uint(ast::TyU64) => output.push_str("u64"),
|
||||
ty::ty_float(ast::TyF32) => output.push_str("f32"),
|
||||
ty::ty_float(ast::TyF64) => output.push_str("f64"),
|
||||
ty::ty_struct(def_id, ref substs) |
|
||||
ty::ty_enum(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) |
|
||||
ty::ty_enum(def_id, substs) => {
|
||||
push_item_name(cx, def_id, qualified, output);
|
||||
push_type_params(cx, substs, output);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let substs = principal.substs().with_self_ty(unadjusted_ty).erase_regions();
|
||||
let trait_ref =
|
||||
Rc::new(ty::Binder(ty::TraitRef { def_id: principal.def_id(),
|
||||
substs: substs }));
|
||||
substs: bcx.tcx().mk_substs(substs) }));
|
||||
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
|
||||
let box_ty = mk_ty(unadjusted_ty);
|
||||
PointerCast(bcx,
|
||||
|
|
@ -1339,7 +1339,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
|
|||
F: FnOnce(ty::Disr, &[ty::field<'tcx>]) -> R,
|
||||
{
|
||||
match ty.sty {
|
||||
ty::ty_struct(did, ref substs) => {
|
||||
ty::ty_struct(did, substs) => {
|
||||
op(0, struct_fields(tcx, did, substs)[])
|
||||
}
|
||||
|
||||
|
|
@ -1347,7 +1347,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
|
|||
op(0, tup_fields(v[])[])
|
||||
}
|
||||
|
||||
ty::ty_enum(_, ref substs) => {
|
||||
ty::ty_enum(_, substs) => {
|
||||
// We want the *variant* ID here, not the enum ID.
|
||||
match node_id_opt {
|
||||
None => {
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info:
|
|||
return (size, align);
|
||||
}
|
||||
match t.sty {
|
||||
ty::ty_struct(id, ref substs) => {
|
||||
ty::ty_struct(id, substs) => {
|
||||
let ccx = bcx.ccx();
|
||||
// First get the size of all statically known fields.
|
||||
// Don't use type_of::sizing_type_of because that expects t to be sized.
|
||||
|
|
@ -407,7 +407,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::ty_struct(did, ref substs) | ty::ty_enum(did, ref substs) => {
|
||||
ty::ty_struct(did, substs) | ty::ty_enum(did, substs) => {
|
||||
let tcx = bcx.tcx();
|
||||
match ty::ty_dtor(tcx, did) {
|
||||
ty::TraitDtor(dtor, true) => {
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ pub fn trans_static_method_callee(bcx: Block,
|
|||
Vec::new()));
|
||||
debug!("trait_substs={}", trait_substs.repr(bcx.tcx()));
|
||||
let trait_ref = Rc::new(ty::Binder(ty::TraitRef { def_id: trait_id,
|
||||
substs: trait_substs }));
|
||||
substs: bcx.tcx().mk_substs(trait_substs) }));
|
||||
let vtbl = fulfill_obligation(bcx.ccx(),
|
||||
DUMMY_SP,
|
||||
trait_ref);
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ fn ast_path_to_trait_ref<'tcx,AC,RS>(
|
|||
regions,
|
||||
assoc_bindings);
|
||||
|
||||
ty::TraitRef::new(trait_def_id, substs)
|
||||
ty::TraitRef::new(trait_def_id, this.tcx().mk_substs(substs))
|
||||
}
|
||||
|
||||
pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
|
||||
|
|
|
|||
|
|
@ -411,13 +411,13 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
|
|||
|
||||
let real_path_ty = fcx.node_ty(pat.id);
|
||||
let (arg_tys, kind_name) = match real_path_ty.sty {
|
||||
ty::ty_enum(enum_def_id, ref expected_substs)
|
||||
ty::ty_enum(enum_def_id, expected_substs)
|
||||
if def == def::DefVariant(enum_def_id, def.def_id(), false) => {
|
||||
let variant = ty::enum_variant_with_id(tcx, enum_def_id, def.def_id());
|
||||
(variant.args.iter().map(|t| t.subst(tcx, expected_substs)).collect::<Vec<_>>(),
|
||||
"variant")
|
||||
}
|
||||
ty::ty_struct(struct_def_id, ref expected_substs) => {
|
||||
ty::ty_struct(struct_def_id, expected_substs) => {
|
||||
let struct_fields = ty::struct_fields(tcx, struct_def_id, expected_substs);
|
||||
(struct_fields.iter().map(|field| field.mt.ty).collect::<Vec<_>>(),
|
||||
"struct")
|
||||
|
|
|
|||
|
|
@ -127,7 +127,8 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
|||
let closure_type = ty::mk_unboxed_closure(fcx.ccx.tcx,
|
||||
expr_def_id,
|
||||
region,
|
||||
fcx.inh.param_env.free_substs.clone());
|
||||
fcx.ccx.tcx.mk_substs(
|
||||
fcx.inh.param_env.free_substs.clone()));
|
||||
|
||||
fcx.write_ty(expr.id, closure_type);
|
||||
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
self.infcx().next_ty_var());
|
||||
|
||||
let trait_ref =
|
||||
Rc::new(ty::TraitRef::new(trait_def_id, substs.clone()));
|
||||
Rc::new(ty::TraitRef::new(trait_def_id, self.tcx().mk_substs(substs.clone())));
|
||||
let origin = MethodTypeParam(MethodParam { trait_ref: trait_ref,
|
||||
method_num: method_num });
|
||||
(substs, origin)
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
|||
|
||||
// Construct a trait-reference `self_ty : Trait<input_tys>`
|
||||
let substs = subst::Substs::new_trait(input_types, Vec::new(), assoc_types, self_ty);
|
||||
let trait_ref = Rc::new(ty::TraitRef::new(trait_def_id, substs));
|
||||
let trait_ref = Rc::new(ty::TraitRef::new(trait_def_id, fcx.tcx().mk_substs(substs)));
|
||||
|
||||
// Construct an obligation
|
||||
let poly_trait_ref = Rc::new(ty::Binder((*trait_ref).clone()));
|
||||
|
|
@ -194,7 +194,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
|||
// Substitute the trait parameters into the method type and
|
||||
// instantiate late-bound regions to get the actual method type.
|
||||
let ref bare_fn_ty = method_ty.fty;
|
||||
let fn_sig = bare_fn_ty.sig.subst(tcx, &trait_ref.substs);
|
||||
let fn_sig = bare_fn_ty.sig.subst(tcx, trait_ref.substs);
|
||||
let fn_sig = fcx.infcx().replace_late_bound_regions_with_fresh_var(span,
|
||||
infer::FnCall,
|
||||
&fn_sig).0;
|
||||
|
|
@ -217,7 +217,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
|||
//
|
||||
// Note that as the method comes from a trait, it should not have
|
||||
// any late-bound regions appearing in its bounds.
|
||||
let method_bounds = method_ty.generics.to_bounds(fcx.tcx(), &trait_ref.substs);
|
||||
let method_bounds = method_ty.generics.to_bounds(fcx.tcx(), trait_ref.substs);
|
||||
assert!(!method_bounds.has_escaping_regions());
|
||||
fcx.add_obligations_for_parameters(
|
||||
traits::ObligationCause::misc(span, fcx.body_id),
|
||||
|
|
@ -425,4 +425,3 @@ fn impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
.find(|m| m.name() == method_name)
|
||||
.and_then(|item| item.as_opt_method())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||
|
||||
// Determine the receiver type that the method itself expects.
|
||||
let xform_self_ty =
|
||||
self.xform_self_ty(&method, &impl_trait_ref.substs);
|
||||
self.xform_self_ty(&method, impl_trait_ref.substs);
|
||||
|
||||
debug!("xform_self_ty={}", xform_self_ty.repr(self.tcx()));
|
||||
|
||||
|
|
|
|||
|
|
@ -3331,7 +3331,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let (_, autoderefs, field_ty) =
|
||||
autoderef(fcx, expr.span, expr_t, Some(base.id), lvalue_pref, |base_t, _| {
|
||||
match base_t.sty {
|
||||
ty::ty_struct(base_id, ref substs) => {
|
||||
ty::ty_struct(base_id, substs) => {
|
||||
debug!("struct named {}", ppaux::ty_to_string(tcx, base_t));
|
||||
let fields = ty::lookup_struct_fields(tcx, base_id);
|
||||
lookup_field_ty(tcx, base_id, fields[],
|
||||
|
|
@ -3392,7 +3392,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let (_, autoderefs, field_ty) =
|
||||
autoderef(fcx, expr.span, expr_t, Some(base.id), lvalue_pref, |base_t, _| {
|
||||
match base_t.sty {
|
||||
ty::ty_struct(base_id, ref substs) => {
|
||||
ty::ty_struct(base_id, substs) => {
|
||||
tuple_like = ty::is_tuple_struct(tcx, base_id);
|
||||
if tuple_like {
|
||||
debug!("tuple struct named {}", ppaux::ty_to_string(tcx, base_t));
|
||||
|
|
@ -3443,7 +3443,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
span: Span,
|
||||
class_id: ast::DefId,
|
||||
node_id: ast::NodeId,
|
||||
substitutions: subst::Substs<'tcx>,
|
||||
substitutions: &'tcx subst::Substs<'tcx>,
|
||||
field_types: &[ty::field_ty],
|
||||
ast_fields: &[ast::Field],
|
||||
check_completeness: bool,
|
||||
|
|
@ -3495,7 +3495,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
Some((field_id, false)) => {
|
||||
expected_field_type =
|
||||
ty::lookup_field_type(
|
||||
tcx, class_id, field_id, &substitutions);
|
||||
tcx, class_id, field_id, substitutions);
|
||||
class_field_map.insert(
|
||||
field.ident.node.name, (field_id, true));
|
||||
fields_found += 1;
|
||||
|
|
@ -3561,7 +3561,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
span,
|
||||
class_id,
|
||||
id,
|
||||
struct_substs,
|
||||
fcx.ccx.tcx.mk_substs(struct_substs),
|
||||
class_fields[],
|
||||
fields,
|
||||
base_expr.is_none(),
|
||||
|
|
@ -3604,7 +3604,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
span,
|
||||
variant_id,
|
||||
id,
|
||||
substitutions,
|
||||
fcx.ccx.tcx.mk_substs(substitutions),
|
||||
variant_fields[],
|
||||
fields,
|
||||
true,
|
||||
|
|
@ -3737,7 +3737,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
Some(mt) => mt.ty,
|
||||
None => {
|
||||
let is_newtype = match oprnd_t.sty {
|
||||
ty::ty_struct(did, ref substs) => {
|
||||
ty::ty_struct(did, substs) => {
|
||||
let fields = ty::struct_fields(fcx.tcx(), did, substs);
|
||||
fields.len() == 1
|
||||
&& fields[0].name ==
|
||||
|
|
@ -4749,7 +4749,7 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
|
|||
return;
|
||||
}
|
||||
match t.sty {
|
||||
ty::ty_struct(did, ref substs) => {
|
||||
ty::ty_struct(did, substs) => {
|
||||
let fields = ty::lookup_struct_fields(tcx, did);
|
||||
if fields.is_empty() {
|
||||
span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty");
|
||||
|
|
@ -5594,7 +5594,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
Ok(did) => (1u,
|
||||
Vec::new(),
|
||||
ty::mk_struct(ccx.tcx, did,
|
||||
subst::Substs::empty())),
|
||||
ccx.tcx.mk_substs(subst::Substs::empty()))),
|
||||
Err(msg) => {
|
||||
tcx.sess.span_fatal(it.span, msg[]);
|
||||
}
|
||||
|
|
@ -5798,4 +5798,3 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
|
|||
self.accumulate_from_object_ty(ty, t.bounds.region_bound, required_region_bounds)
|
||||
}
|
||||
|
||||
ty::ty_enum(def_id, ref substs) |
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_enum(def_id, substs) |
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
self.accumulate_from_adt(ty, def_id, substs)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ impl<'cx,'tcx> BoundsChecker<'cx,'tcx> {
|
|||
pub fn check_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>) {
|
||||
let trait_def = ty::lookup_trait_def(self.fcx.tcx(), trait_ref.def_id);
|
||||
|
||||
let bounds = trait_def.generics.to_bounds(self.tcx(), &trait_ref.substs);
|
||||
let bounds = trait_def.generics.to_bounds(self.tcx(), trait_ref.substs);
|
||||
self.fcx.add_obligations_for_parameters(
|
||||
traits::ObligationCause::new(
|
||||
self.span,
|
||||
|
|
@ -311,8 +311,8 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
|
|||
}
|
||||
|
||||
match t.sty{
|
||||
ty::ty_struct(type_id, ref substs) |
|
||||
ty::ty_enum(type_id, ref substs) => {
|
||||
ty::ty_struct(type_id, substs) |
|
||||
ty::ty_enum(type_id, substs) => {
|
||||
let polytype = ty::lookup_item_type(self.fcx.tcx(), type_id);
|
||||
|
||||
if self.binding_count == 0 {
|
||||
|
|
|
|||
|
|
@ -1264,7 +1264,7 @@ pub fn convert_struct<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
tcx.struct_fields.borrow_mut().insert(local_def(id), Rc::new(field_tys));
|
||||
|
||||
let substs = mk_item_substs(ccx, &pty.generics);
|
||||
let selfty = ty::mk_struct(tcx, local_def(id), substs);
|
||||
let selfty = ty::mk_struct(tcx, local_def(id), tcx.mk_substs(substs));
|
||||
|
||||
// If this struct is enum-like or tuple-like, create the type of its
|
||||
// constructor.
|
||||
|
|
@ -1353,11 +1353,11 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
}
|
||||
};
|
||||
|
||||
let substs = mk_trait_substs(ccx, it.id, generics, items);
|
||||
let substs = ccx.tcx.mk_substs(mk_trait_substs(ccx, it.id, generics, items));
|
||||
|
||||
let ty_generics = ty_generics_for_trait(ccx,
|
||||
it.id,
|
||||
&substs,
|
||||
substs,
|
||||
generics,
|
||||
items);
|
||||
|
||||
|
|
@ -1377,7 +1377,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
bounds: bounds,
|
||||
trait_ref: Rc::new(ty::TraitRef {
|
||||
def_id: def_id,
|
||||
substs: substs
|
||||
substs: ccx.tcx.mk_substs(substs)
|
||||
})
|
||||
});
|
||||
tcx.trait_defs.borrow_mut().insert(def_id, trait_def.clone());
|
||||
|
|
@ -1502,7 +1502,7 @@ pub fn ty_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
|
|||
generics,
|
||||
DontCreateTypeParametersForAssociatedTypes);
|
||||
let substs = mk_item_substs(ccx, &ty_generics);
|
||||
let t = ty::mk_enum(tcx, local_def(it.id), substs);
|
||||
let t = ty::mk_enum(tcx, local_def(it.id), tcx.mk_substs(substs));
|
||||
let pty = Polytype {
|
||||
generics: ty_generics,
|
||||
ty: t
|
||||
|
|
@ -1520,7 +1520,7 @@ pub fn ty_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
|
|||
generics,
|
||||
DontCreateTypeParametersForAssociatedTypes);
|
||||
let substs = mk_item_substs(ccx, &ty_generics);
|
||||
let t = ty::mk_struct(tcx, local_def(it.id), substs);
|
||||
let t = ty::mk_struct(tcx, local_def(it.id), tcx.mk_substs(substs));
|
||||
let pty = Polytype {
|
||||
generics: ty_generics,
|
||||
ty: t
|
||||
|
|
@ -1598,7 +1598,7 @@ fn ty_generics_for_type_or_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
|
||||
fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
trait_id: ast::NodeId,
|
||||
substs: &subst::Substs<'tcx>,
|
||||
substs: &'tcx subst::Substs<'tcx>,
|
||||
ast_generics: &ast::Generics,
|
||||
items: &[ast::TraitItem])
|
||||
-> ty::Generics<'tcx>
|
||||
|
|
@ -1639,7 +1639,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
|
||||
let self_trait_ref =
|
||||
Rc::new(ty::Binder(ty::TraitRef { def_id: local_def(trait_id),
|
||||
substs: (*substs).clone() }));
|
||||
substs: substs }));
|
||||
|
||||
let def = ty::TypeParameterDef {
|
||||
space: subst::SelfSpace,
|
||||
|
|
|
|||
|
|
@ -750,8 +750,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::ty_enum(def_id, ref substs) |
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_enum(def_id, substs) |
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
let item_type = ty::lookup_item_type(self.tcx(), def_id);
|
||||
let generics = &item_type.generics;
|
||||
|
||||
|
|
|
|||
|
|
@ -1464,10 +1464,10 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
|
|||
ty::RegionTraitStore(..) => Closure(decl),
|
||||
}
|
||||
}
|
||||
ty::ty_struct(did, ref substs) |
|
||||
ty::ty_enum(did, ref substs) |
|
||||
ty::ty_struct(did, substs) |
|
||||
ty::ty_enum(did, substs) |
|
||||
ty::ty_trait(box ty::TyTrait {
|
||||
principal: ty::Binder(ty::TraitRef { def_id: did, ref substs }),
|
||||
principal: ty::Binder(ty::TraitRef { def_id: did, substs }),
|
||||
.. }) =>
|
||||
{
|
||||
let fqn = csearch::get_item_path(cx.tcx(), did);
|
||||
|
|
|
|||
|
|
@ -122,9 +122,10 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
|
|||
let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest);
|
||||
|
||||
let type_arena = TypedArena::new();
|
||||
let substs_arena = TypedArena::new();
|
||||
let ty::CrateAnalysis {
|
||||
exported_items, public_items, ty_cx, ..
|
||||
} = driver::phase_3_run_analysis_passes(sess, ast_map, &type_arena, name);
|
||||
} = driver::phase_3_run_analysis_passes(sess, ast_map, &type_arena, &substs_arena, name);
|
||||
|
||||
let ctxt = DocContext {
|
||||
krate: ty_cx.map.krate(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue