auto merge of #19549 : huonw/rust/middle-ty-2, r=nikomatsakis
This takes building `librustc/lib.rs` from using 696 MB to 588 (`rustc --no-trans`), and 1.99 GB to 1.87 (`rustc -O`). It also reduces `sty` down to 32 bytes on platforms with 64-bit pointers, at the expense of some more side-tables in `ctxt`. I'm sure there's more gains to be had from reducing the size of the side tables (e.g. by making the actual things they're storing smaller). r? @nikomatsakis
This commit is contained in:
commit
3dcc409fac
62 changed files with 697 additions and 499 deletions
|
@ -1598,7 +1598,7 @@ impl LintPass for MissingCopyImplementations {
|
|||
}
|
||||
ty::mk_struct(cx.tcx,
|
||||
ast_util::local_def(item.id),
|
||||
Substs::empty())
|
||||
cx.tcx.mk_substs(Substs::empty()))
|
||||
}
|
||||
ast::ItemEnum(_, ref ast_generics) => {
|
||||
if ast_generics.is_parameterized() {
|
||||
|
@ -1606,7 +1606,7 @@ impl LintPass for MissingCopyImplementations {
|
|||
}
|
||||
ty::mk_enum(cx.tcx,
|
||||
ast_util::local_def(item.id),
|
||||
Substs::empty())
|
||||
cx.tcx.mk_substs(Substs::empty()))
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
|
|
|
@ -1449,7 +1449,7 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
|
|||
let space = subst::ParamSpace::from_uint(reader::doc_as_u64(doc) as uint);
|
||||
|
||||
let doc = reader::get_doc(rp_doc, tag_region_param_def_index);
|
||||
let index = reader::doc_as_u64(doc) as uint;
|
||||
let index = reader::doc_as_u64(doc) as u32;
|
||||
|
||||
let mut bounds = Vec::new();
|
||||
reader::tagged_docs(rp_doc, tag_items_data_region, |p| {
|
||||
|
|
|
@ -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 {
|
||||
|
@ -281,7 +281,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> subst::RegionSubsts {
|
|||
fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion {
|
||||
match next(st) {
|
||||
'a' => {
|
||||
let id = parse_uint(st);
|
||||
let id = parse_u32(st);
|
||||
assert_eq!(next(st), '|');
|
||||
ty::BrAnon(id)
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion {
|
|||
ty::BrNamed(def, ident.name)
|
||||
}
|
||||
'f' => {
|
||||
let id = parse_uint(st);
|
||||
let id = parse_u32(st);
|
||||
assert_eq!(next(st), '|');
|
||||
ty::BrFresh(id)
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
|
|||
match next(st) {
|
||||
'b' => {
|
||||
assert_eq!(next(st), '[');
|
||||
let id = ty::DebruijnIndex::new(parse_uint(st));
|
||||
let id = ty::DebruijnIndex::new(parse_u32(st));
|
||||
assert_eq!(next(st), '|');
|
||||
let br = parse_bound_region(st, |x,y| conv(x,y));
|
||||
assert_eq!(next(st), ']');
|
||||
|
@ -316,7 +316,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
|
|||
assert_eq!(next(st), '|');
|
||||
let space = parse_param_space(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let index = parse_uint(st);
|
||||
let index = parse_u32(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let nm = token::str_to_ident(parse_str(st, ']')[]);
|
||||
ty::ReEarlyBound(node_id, space, index, nm.name)
|
||||
|
@ -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), '[');
|
||||
|
@ -421,7 +421,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
'p' => {
|
||||
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));
|
||||
debug!("parsed ty_param: did={}", did);
|
||||
let index = parse_uint(st);
|
||||
let index = parse_u32(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let space = parse_param_space(st);
|
||||
assert_eq!(next(st), '|');
|
||||
|
@ -432,7 +432,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
'&' => {
|
||||
let r = parse_region(st, |x,y| conv(x,y));
|
||||
let mt = parse_mt(st, |x,y| conv(x,y));
|
||||
return ty::mk_rptr(st.tcx, r, mt);
|
||||
return ty::mk_rptr(st.tcx, st.tcx.mk_region(r), mt);
|
||||
}
|
||||
'V' => {
|
||||
let t = parse_ty(st, |x,y| conv(x,y));
|
||||
|
@ -454,10 +454,12 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
}
|
||||
'F' => {
|
||||
let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
|
||||
return ty::mk_bare_fn(st.tcx, Some(def_id), parse_bare_fn_ty(st, |x,y| conv(x,y)));
|
||||
return ty::mk_bare_fn(st.tcx, Some(def_id),
|
||||
st.tcx.mk_bare_fn(parse_bare_fn_ty(st, |x,y| conv(x,y))));
|
||||
}
|
||||
'G' => {
|
||||
return ty::mk_bare_fn(st.tcx, None, parse_bare_fn_ty(st, |x,y| conv(x,y)));
|
||||
return ty::mk_bare_fn(st.tcx, None,
|
||||
st.tcx.mk_bare_fn(parse_bare_fn_ty(st, |x,y| conv(x,y))));
|
||||
}
|
||||
'#' => {
|
||||
let pos = parse_hex(st);
|
||||
|
@ -490,7 +492,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 +500,8 @@ 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,
|
||||
st.tcx.mk_region(region), st.tcx.mk_substs(substs));
|
||||
}
|
||||
'e' => {
|
||||
return ty::mk_err();
|
||||
|
@ -535,6 +538,13 @@ fn parse_uint(st: &mut PState) -> uint {
|
|||
};
|
||||
}
|
||||
|
||||
fn parse_u32(st: &mut PState) -> u32 {
|
||||
let n = parse_uint(st);
|
||||
let m = n as u32;
|
||||
assert_eq!(m as uint, n);
|
||||
m
|
||||
}
|
||||
|
||||
fn parse_param_space(st: &mut PState) -> subst::ParamSpace {
|
||||
subst::ParamSpace::from_uint(parse_uint(st))
|
||||
}
|
||||
|
@ -697,7 +707,7 @@ fn parse_type_param_def<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
|
|||
let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
|
||||
let space = parse_param_space(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let index = parse_uint(st);
|
||||
let index = parse_u32(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let associated_with = parse_opt(st, |st| {
|
||||
parse_def(st, NominalType, |x,y| conv(x,y))
|
||||
|
|
|
@ -83,7 +83,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
|
|||
ast::TyF64 => mywrite!(w, "MF"),
|
||||
}
|
||||
}
|
||||
ty::ty_enum(def, ref substs) => {
|
||||
ty::ty_enum(def, substs) => {
|
||||
mywrite!(w, "t[{}|", (cx.ds)(def));
|
||||
enc_substs(w, cx, substs);
|
||||
mywrite!(w, "]");
|
||||
|
@ -104,7 +104,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
|
|||
ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
|
||||
ty::ty_rptr(r, mt) => {
|
||||
mywrite!(w, "&");
|
||||
enc_region(w, cx, r);
|
||||
enc_region(w, cx, *r);
|
||||
enc_mt(w, cx, mt);
|
||||
}
|
||||
ty::ty_vec(t, sz) => {
|
||||
|
@ -123,12 +123,12 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
|
|||
mywrite!(w, "f");
|
||||
enc_closure_ty(w, cx, &**f);
|
||||
}
|
||||
ty::ty_bare_fn(Some(def_id), ref f) => {
|
||||
ty::ty_bare_fn(Some(def_id), f) => {
|
||||
mywrite!(w, "F");
|
||||
mywrite!(w, "{}|", (cx.ds)(def_id));
|
||||
enc_bare_fn_ty(w, cx, f);
|
||||
}
|
||||
ty::ty_bare_fn(None, ref f) => {
|
||||
ty::ty_bare_fn(None, f) => {
|
||||
mywrite!(w, "G");
|
||||
enc_bare_fn_ty(w, cx, f);
|
||||
}
|
||||
|
@ -138,14 +138,14 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
|
|||
ty::ty_param(ParamTy {space, idx: id, def_id: did}) => {
|
||||
mywrite!(w, "p{}|{}|{}|", (cx.ds)(did), id, space.to_uint())
|
||||
}
|
||||
ty::ty_struct(def, ref substs) => {
|
||||
ty::ty_struct(def, substs) => {
|
||||
mywrite!(w, "a[{}|", (cx.ds)(def));
|
||||
enc_substs(w, cx, substs);
|
||||
mywrite!(w, "]");
|
||||
}
|
||||
ty::ty_unboxed_closure(def, region, ref substs) => {
|
||||
ty::ty_unboxed_closure(def, region, substs) => {
|
||||
mywrite!(w, "k[{}|", (cx.ds)(def));
|
||||
enc_region(w, cx, region);
|
||||
enc_region(w, cx, *region);
|
||||
enc_substs(w, cx, substs);
|
||||
mywrite!(w, "]");
|
||||
}
|
||||
|
@ -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) {
|
||||
|
|
|
@ -39,7 +39,7 @@ pub enum Def {
|
|||
DefAssociatedPath(TyParamProvenance, ast::Ident),
|
||||
DefTrait(ast::DefId),
|
||||
DefPrimTy(ast::PrimTy),
|
||||
DefTyParam(ParamSpace, ast::DefId, uint),
|
||||
DefTyParam(ParamSpace, ast::DefId, u32),
|
||||
DefUse(ast::DefId),
|
||||
DefUpvar(ast::NodeId, // id of closed over local
|
||||
ast::NodeId, // expr node that creates the closure
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
_ => {
|
||||
|
@ -861,7 +861,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
};
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.delegate.borrow(expr.id, expr.span, cmt,
|
||||
r, bk, AutoRef);
|
||||
*r, bk, AutoRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1271,4 +1271,3 @@ fn copy_or_move<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
Copy
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
|
||||
self.unpack_actual_value(a, |a| {
|
||||
match a.sty {
|
||||
ty::ty_bare_fn(Some(a_def_id), ref a_f) => {
|
||||
ty::ty_bare_fn(Some(a_def_id), a_f) => {
|
||||
// Function items are coercible to any closure
|
||||
// type; function pointers are not (that would
|
||||
// require double indirection).
|
||||
|
@ -230,7 +230,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
};
|
||||
|
||||
let a_borrowed = ty::mk_rptr(self.tcx(),
|
||||
r_borrow,
|
||||
self.tcx().mk_region(r_borrow),
|
||||
mt {ty: inner_ty, mutbl: mutbl_b});
|
||||
try!(sub.tys(a_borrowed, b));
|
||||
|
||||
|
@ -271,7 +271,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
let coercion = Coercion(self.get_ref().trace.clone());
|
||||
let r_borrow = self.get_ref().infcx.next_region_var(coercion);
|
||||
let ty = ty::mk_rptr(self.tcx(),
|
||||
r_borrow,
|
||||
self.tcx().mk_region(r_borrow),
|
||||
ty::mt{ty: ty, mutbl: mt_b.mutbl});
|
||||
try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
|
||||
debug!("Success, coerced with AutoDerefRef(1, \
|
||||
|
@ -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 {}",
|
||||
|
@ -424,7 +424,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
let r_a = self.get_ref().infcx.next_region_var(coercion);
|
||||
|
||||
self.coerce_object(a, b, b_mutbl,
|
||||
|tr| ty::mk_rptr(tcx, r_a, ty::mt{ mutbl: b_mutbl, ty: tr }),
|
||||
|tr| ty::mk_rptr(tcx, tcx.mk_region(r_a),
|
||||
ty::mt{ mutbl: b_mutbl, ty: tr }),
|
||||
|| AutoPtr(r_a, b_mutbl, None))
|
||||
}
|
||||
|
||||
|
@ -486,7 +487,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
b.repr(self.tcx()));
|
||||
|
||||
match a.sty {
|
||||
ty::ty_bare_fn(Some(a_def_id), ref f) => {
|
||||
ty::ty_bare_fn(Some(a_def_id), f) => {
|
||||
self.coerce_from_fn_item(a, a_def_id, f, b)
|
||||
}
|
||||
_ => {
|
||||
|
@ -498,7 +499,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
fn coerce_from_fn_item(&self,
|
||||
a: Ty<'tcx>,
|
||||
fn_def_id_a: ast::DefId,
|
||||
fn_ty_a: &ty::BareFnTy<'tcx>,
|
||||
fn_ty_a: &'tcx ty::BareFnTy<'tcx>,
|
||||
b: Ty<'tcx>)
|
||||
-> CoerceResult<'tcx> {
|
||||
/*!
|
||||
|
@ -527,7 +528,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
Ok(Some(adj))
|
||||
}
|
||||
ty::ty_bare_fn(None, _) => {
|
||||
let a_fn_pointer = ty::mk_bare_fn(self.tcx(), None, (*fn_ty_a).clone());
|
||||
let a_fn_pointer = ty::mk_bare_fn(self.tcx(), None, fn_ty_a);
|
||||
try!(self.subtype(a_fn_pointer, b));
|
||||
Ok(Some(ty::AdjustReifyFnPointer(fn_def_id_a)))
|
||||
}
|
||||
|
|
|
@ -343,8 +343,8 @@ pub trait Combine<'tcx> {
|
|||
if a.def_id != b.def_id {
|
||||
Err(ty::terr_traits(expected_found(self, a.def_id, b.def_id)))
|
||||
} else {
|
||||
let substs = try!(self.substs(a.def_id, &a.substs, &b.substs));
|
||||
Ok(ty::TraitRef { def_id: a.def_id, substs: substs })
|
||||
let substs = try!(self.substs(a.def_id, a.substs, b.substs));
|
||||
Ok(ty::TraitRef { def_id: a.def_id, substs: self.tcx().mk_substs(substs) })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 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, tcx.mk_region(region), tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => {
|
||||
|
@ -515,7 +515,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
}
|
||||
|
||||
(&ty::ty_rptr(a_r, ref a_mt), &ty::ty_rptr(b_r, ref b_mt)) => {
|
||||
let r = try!(this.contraregions(a_r, b_r));
|
||||
let r = try!(this.contraregions(*a_r, *b_r));
|
||||
// FIXME(14985) If we have mutable references to trait objects, we
|
||||
// used to use covariant subtyping. I have preserved this behaviour,
|
||||
// even though it is probably incorrect. So don't go down the usual
|
||||
|
@ -527,7 +527,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
}
|
||||
_ => try!(this.mts(a_mt, b_mt))
|
||||
};
|
||||
Ok(ty::mk_rptr(tcx, r, mt))
|
||||
Ok(ty::mk_rptr(tcx, tcx.mk_region(r), mt))
|
||||
}
|
||||
|
||||
(&ty::ty_vec(a_t, Some(sz_a)), &ty::ty_vec(b_t, Some(sz_b))) => {
|
||||
|
@ -568,11 +568,11 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
}
|
||||
}
|
||||
|
||||
(&ty::ty_bare_fn(a_opt_def_id, ref a_fty), &ty::ty_bare_fn(b_opt_def_id, ref b_fty))
|
||||
(&ty::ty_bare_fn(a_opt_def_id, a_fty), &ty::ty_bare_fn(b_opt_def_id, b_fty))
|
||||
if a_opt_def_id == b_opt_def_id =>
|
||||
{
|
||||
let fty = try!(this.bare_fn_tys(a_fty, b_fty));
|
||||
Ok(ty::mk_bare_fn(tcx, a_opt_def_id, fty))
|
||||
Ok(ty::mk_bare_fn(tcx, a_opt_def_id, tcx.mk_bare_fn(fty)))
|
||||
}
|
||||
|
||||
(&ty::ty_closure(ref a_fty), &ty::ty_closure(ref b_fty)) => {
|
||||
|
@ -813,5 +813,3 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
|||
self.infcx.next_region_var(MiscVariable(self.span))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -870,11 +870,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
struct RebuildPathInfo<'a> {
|
||||
path: &'a ast::Path,
|
||||
// indexes to insert lifetime on path.lifetimes
|
||||
indexes: Vec<uint>,
|
||||
indexes: Vec<u32>,
|
||||
// number of lifetimes we expect to see on the type referred by `path`
|
||||
// (e.g., expected=1 for struct Foo<'a>)
|
||||
expected: uint,
|
||||
anon_nums: &'a HashSet<uint>,
|
||||
expected: u32,
|
||||
anon_nums: &'a HashSet<u32>,
|
||||
region_names: &'a HashSet<ast::Name>
|
||||
}
|
||||
|
||||
|
@ -885,8 +885,8 @@ struct Rebuilder<'a, 'tcx: 'a> {
|
|||
generics: &'a ast::Generics,
|
||||
same_regions: &'a [SameRegions],
|
||||
life_giver: &'a LifeGiver,
|
||||
cur_anon: Cell<uint>,
|
||||
inserted_anons: RefCell<HashSet<uint>>,
|
||||
cur_anon: Cell<u32>,
|
||||
inserted_anons: RefCell<HashSet<u32>>,
|
||||
}
|
||||
|
||||
enum FreshOrKept {
|
||||
|
@ -976,7 +976,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn extract_anon_nums_and_names(&self, same_regions: &SameRegions)
|
||||
-> (HashSet<uint>, HashSet<ast::Name>) {
|
||||
-> (HashSet<u32>, HashSet<ast::Name>) {
|
||||
let mut anon_nums = HashSet::new();
|
||||
let mut region_names = HashSet::new();
|
||||
for br in same_regions.regions.iter() {
|
||||
|
@ -1008,7 +1008,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
all_region_names
|
||||
}
|
||||
|
||||
fn inc_cur_anon(&self, n: uint) {
|
||||
fn inc_cur_anon(&self, n: u32) {
|
||||
let anon = self.cur_anon.get();
|
||||
self.cur_anon.set(anon+n);
|
||||
}
|
||||
|
@ -1021,12 +1021,12 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
self.cur_anon.set(anon);
|
||||
}
|
||||
|
||||
fn inc_and_offset_cur_anon(&self, n: uint) {
|
||||
fn inc_and_offset_cur_anon(&self, n: u32) {
|
||||
self.inc_cur_anon(n);
|
||||
self.offset_cur_anon();
|
||||
}
|
||||
|
||||
fn track_anon(&self, anon: uint) {
|
||||
fn track_anon(&self, anon: u32) {
|
||||
self.inserted_anons.borrow_mut().insert(anon);
|
||||
}
|
||||
|
||||
|
@ -1070,13 +1070,13 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
let lifetimes = last_seg.parameters.lifetimes();
|
||||
for (i, lt) in lifetimes.iter().enumerate() {
|
||||
if region_names.contains(<.name) {
|
||||
insert.push(i);
|
||||
insert.push(i as u32);
|
||||
}
|
||||
}
|
||||
let rebuild_info = RebuildPathInfo {
|
||||
path: &tr.path,
|
||||
indexes: insert,
|
||||
expected: lifetimes.len(),
|
||||
expected: lifetimes.len() as u32,
|
||||
anon_nums: &HashSet::new(),
|
||||
region_names: region_names
|
||||
};
|
||||
|
@ -1096,7 +1096,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
fn rebuild_expl_self(&self,
|
||||
expl_self_opt: Option<ast::ExplicitSelf_>,
|
||||
lifetime: ast::Lifetime,
|
||||
anon_nums: &HashSet<uint>,
|
||||
anon_nums: &HashSet<u32>,
|
||||
region_names: &HashSet<ast::Name>)
|
||||
-> Option<ast::ExplicitSelf_> {
|
||||
match expl_self_opt {
|
||||
|
@ -1150,7 +1150,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
fn rebuild_args_ty(&self,
|
||||
inputs: &[ast::Arg],
|
||||
lifetime: ast::Lifetime,
|
||||
anon_nums: &HashSet<uint>,
|
||||
anon_nums: &HashSet<u32>,
|
||||
region_names: &HashSet<ast::Name>)
|
||||
-> Vec<ast::Arg> {
|
||||
let mut new_inputs = Vec::new();
|
||||
|
@ -1169,7 +1169,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
|
||||
fn rebuild_output(&self, ty: &ast::FunctionRetTy,
|
||||
lifetime: ast::Lifetime,
|
||||
anon_nums: &HashSet<uint>,
|
||||
anon_nums: &HashSet<u32>,
|
||||
region_names: &HashSet<ast::Name>) -> ast::FunctionRetTy {
|
||||
match *ty {
|
||||
ast::Return(ref ret_ty) => ast::Return(
|
||||
|
@ -1182,7 +1182,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
fn rebuild_arg_ty_or_output(&self,
|
||||
ty: &ast::Ty,
|
||||
lifetime: ast::Lifetime,
|
||||
anon_nums: &HashSet<uint>,
|
||||
anon_nums: &HashSet<u32>,
|
||||
region_names: &HashSet<ast::Name>)
|
||||
-> P<ast::Ty> {
|
||||
let mut new_ty = P(ty.clone());
|
||||
|
@ -1229,7 +1229,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
let generics = ty::lookup_item_type(self.tcx, did).generics;
|
||||
|
||||
let expected =
|
||||
generics.regions.len(subst::TypeSpace);
|
||||
generics.regions.len(subst::TypeSpace) as u32;
|
||||
let lifetimes =
|
||||
path.segments.last().unwrap().parameters.lifetimes();
|
||||
let mut insert = Vec::new();
|
||||
|
@ -1238,7 +1238,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
for (i, a) in range(anon,
|
||||
anon+expected).enumerate() {
|
||||
if anon_nums.contains(&a) {
|
||||
insert.push(i);
|
||||
insert.push(i as u32);
|
||||
}
|
||||
self.track_anon(a);
|
||||
}
|
||||
|
@ -1246,7 +1246,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
} else {
|
||||
for (i, lt) in lifetimes.iter().enumerate() {
|
||||
if region_names.contains(<.name) {
|
||||
insert.push(i);
|
||||
insert.push(i as u32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1363,7 +1363,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
|||
}
|
||||
} else {
|
||||
for (i, lt) in data.lifetimes.iter().enumerate() {
|
||||
if indexes.contains(&i) {
|
||||
if indexes.contains(&(i as u32)) {
|
||||
new_lts.push(lifetime);
|
||||
} else {
|
||||
new_lts.push(*lt);
|
||||
|
|
|
@ -41,7 +41,7 @@ use super::unify::InferCtxtMethodsForSimplyUnifiableTypes;
|
|||
|
||||
pub struct TypeFreshener<'a, 'tcx:'a> {
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
freshen_count: uint,
|
||||
freshen_count: u32,
|
||||
freshen_map: hash_map::HashMap<ty::InferTy, Ty<'tcx>>,
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
|||
key: ty::InferTy,
|
||||
freshener: F)
|
||||
-> Ty<'tcx> where
|
||||
F: FnOnce(uint) -> ty::InferTy,
|
||||
F: FnOnce(u32) -> ty::InferTy,
|
||||
{
|
||||
match opt_ty {
|
||||
Some(ty) => { return ty.fold_with(self); }
|
||||
|
|
|
@ -33,7 +33,7 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
|
|||
use util::ppaux::Repr;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::uint;
|
||||
use std::u32;
|
||||
use syntax::ast;
|
||||
|
||||
mod doc;
|
||||
|
@ -196,8 +196,8 @@ pub struct RegionVarBindings<'a, 'tcx: 'a> {
|
|||
|
||||
lubs: RefCell<CombineMap>,
|
||||
glbs: RefCell<CombineMap>,
|
||||
skolemization_count: Cell<uint>,
|
||||
bound_count: Cell<uint>,
|
||||
skolemization_count: Cell<u32>,
|
||||
bound_count: Cell<u32>,
|
||||
|
||||
// The undo log records actions that might later be undone.
|
||||
//
|
||||
|
@ -219,7 +219,7 @@ pub struct RegionVarBindings<'a, 'tcx: 'a> {
|
|||
#[allow(missing_copy_implementations)]
|
||||
pub struct RegionSnapshot {
|
||||
length: uint,
|
||||
skolemization_count: uint,
|
||||
skolemization_count: u32,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
|
@ -278,7 +278,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
AddVar(vid) => {
|
||||
let mut var_origins = self.var_origins.borrow_mut();
|
||||
var_origins.pop().unwrap();
|
||||
assert_eq!(var_origins.len(), vid.index);
|
||||
assert_eq!(var_origins.len(), vid.index as uint);
|
||||
}
|
||||
AddConstraint(ref constraint) => {
|
||||
self.constraints.borrow_mut().remove(constraint);
|
||||
|
@ -303,8 +303,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.skolemization_count.set(snapshot.skolemization_count);
|
||||
}
|
||||
|
||||
pub fn num_vars(&self) -> uint {
|
||||
self.var_origins.borrow().len()
|
||||
pub fn num_vars(&self) -> u32 {
|
||||
let len = self.var_origins.borrow().len();
|
||||
// enforce no overflow
|
||||
assert!(len as u32 as uint == len);
|
||||
len as u32
|
||||
}
|
||||
|
||||
pub fn new_region_var(&self, origin: RegionVariableOrigin<'tcx>) -> RegionVid {
|
||||
|
@ -547,7 +550,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
match *self.values.borrow() {
|
||||
None => {
|
||||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[rid.index].span(),
|
||||
(*self.var_origins.borrow())[rid.index as uint].span(),
|
||||
"attempt to resolve region variable before values have \
|
||||
been computed!")
|
||||
}
|
||||
|
@ -737,7 +740,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
|
||||
(ReInfer(ReVar(v_id)), _) | (_, ReInfer(ReVar(v_id))) => {
|
||||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[v_id.index].span(),
|
||||
(*self.var_origins.borrow())[v_id.index as uint].span(),
|
||||
format!("lub_concrete_regions invoked with \
|
||||
non-concrete regions: {}, {}",
|
||||
a,
|
||||
|
@ -840,7 +843,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
(ReInfer(ReVar(v_id)), _) |
|
||||
(_, ReInfer(ReVar(v_id))) => {
|
||||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[v_id.index].span(),
|
||||
(*self.var_origins.borrow())[v_id.index as uint].span(),
|
||||
format!("glb_concrete_regions invoked with \
|
||||
non-concrete regions: {}, {}",
|
||||
a,
|
||||
|
@ -972,7 +975,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn construct_var_data(&self) -> Vec<VarData> {
|
||||
Vec::from_fn(self.num_vars(), |_| {
|
||||
Vec::from_fn(self.num_vars() as uint, |_| {
|
||||
VarData {
|
||||
// All nodes are initially classified as contracting; during
|
||||
// the expansion phase, we will shift the classification for
|
||||
|
@ -1001,14 +1004,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
.repr(self.tcx));
|
||||
match *constraint {
|
||||
ConstrainRegSubVar(a_region, b_vid) => {
|
||||
let b_data = &mut var_data[b_vid.index];
|
||||
let b_data = &mut var_data[b_vid.index as uint];
|
||||
self.expand_node(a_region, b_vid, b_data)
|
||||
}
|
||||
ConstrainVarSubVar(a_vid, b_vid) => {
|
||||
match var_data[a_vid.index].value {
|
||||
match var_data[a_vid.index as uint].value {
|
||||
NoValue | ErrorValue => false,
|
||||
Value(a_region) => {
|
||||
let b_node = &mut var_data[b_vid.index];
|
||||
let b_node = &mut var_data[b_vid.index as uint];
|
||||
self.expand_node(a_region, b_vid, b_node)
|
||||
}
|
||||
}
|
||||
|
@ -1089,16 +1092,16 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
false
|
||||
}
|
||||
ConstrainVarSubVar(a_vid, b_vid) => {
|
||||
match var_data[b_vid.index].value {
|
||||
match var_data[b_vid.index as uint].value {
|
||||
NoValue | ErrorValue => false,
|
||||
Value(b_region) => {
|
||||
let a_data = &mut var_data[a_vid.index];
|
||||
let a_data = &mut var_data[a_vid.index as uint];
|
||||
self.contract_node(a_vid, a_data, b_region)
|
||||
}
|
||||
}
|
||||
}
|
||||
ConstrainVarSubReg(a_vid, b_region) => {
|
||||
let a_data = &mut var_data[a_vid.index];
|
||||
let a_data = &mut var_data[a_vid.index as uint];
|
||||
self.contract_node(a_vid, a_data, b_region)
|
||||
}
|
||||
}
|
||||
|
@ -1244,11 +1247,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
// idea is to report errors that derive from independent
|
||||
// regions of the graph, but not those that derive from
|
||||
// overlapping locations.
|
||||
let mut dup_vec = Vec::from_elem(self.num_vars(), uint::MAX);
|
||||
let mut dup_vec = Vec::from_elem(self.num_vars() as uint, u32::MAX);
|
||||
|
||||
let mut opt_graph = None;
|
||||
|
||||
for idx in range(0u, self.num_vars()) {
|
||||
for idx in range(0u, self.num_vars() as uint) {
|
||||
match var_data[idx].value {
|
||||
Value(_) => {
|
||||
/* Inference successful */
|
||||
|
@ -1288,7 +1291,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
let graph = opt_graph.as_ref().unwrap();
|
||||
|
||||
let node_vid = RegionVid { index: idx };
|
||||
let node_vid = RegionVid { index: idx as u32 };
|
||||
match var_data[idx].classification {
|
||||
Expanding => {
|
||||
self.collect_error_for_expanding_node(
|
||||
|
@ -1305,7 +1308,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
Vec::from_fn(self.num_vars(), |idx| var_data[idx].value)
|
||||
Vec::from_fn(self.num_vars() as uint, |idx| var_data[idx].value)
|
||||
}
|
||||
|
||||
fn construct_graph(&self) -> RegionGraph {
|
||||
|
@ -1314,10 +1317,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
let constraints = self.constraints.borrow();
|
||||
let num_edges = constraints.len();
|
||||
|
||||
let mut graph = graph::Graph::with_capacity(num_vars + 1,
|
||||
let mut graph = graph::Graph::with_capacity(num_vars as uint + 1,
|
||||
num_edges);
|
||||
|
||||
for _ in range(0u, num_vars) {
|
||||
for _ in range(0, num_vars) {
|
||||
graph.add_node(());
|
||||
}
|
||||
let dummy_idx = graph.add_node(());
|
||||
|
@ -1325,17 +1328,17 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
for (constraint, _) in constraints.iter() {
|
||||
match *constraint {
|
||||
ConstrainVarSubVar(a_id, b_id) => {
|
||||
graph.add_edge(NodeIndex(a_id.index),
|
||||
NodeIndex(b_id.index),
|
||||
graph.add_edge(NodeIndex(a_id.index as uint),
|
||||
NodeIndex(b_id.index as uint),
|
||||
*constraint);
|
||||
}
|
||||
ConstrainRegSubVar(_, b_id) => {
|
||||
graph.add_edge(dummy_idx,
|
||||
NodeIndex(b_id.index),
|
||||
NodeIndex(b_id.index as uint),
|
||||
*constraint);
|
||||
}
|
||||
ConstrainVarSubReg(a_id, _) => {
|
||||
graph.add_edge(NodeIndex(a_id.index),
|
||||
graph.add_edge(NodeIndex(a_id.index as uint),
|
||||
dummy_idx,
|
||||
*constraint);
|
||||
}
|
||||
|
@ -1349,7 +1352,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
&self,
|
||||
graph: &RegionGraph,
|
||||
var_data: &[VarData],
|
||||
dup_vec: &mut [uint],
|
||||
dup_vec: &mut [u32],
|
||||
node_idx: RegionVid,
|
||||
errors: &mut Vec<RegionResolutionError<'tcx>>)
|
||||
{
|
||||
|
@ -1387,7 +1390,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
if !self.is_subregion_of(lower_bound.region,
|
||||
upper_bound.region) {
|
||||
errors.push(SubSupConflict(
|
||||
(*self.var_origins.borrow())[node_idx.index].clone(),
|
||||
(*self.var_origins.borrow())[node_idx.index as uint].clone(),
|
||||
lower_bound.origin.clone(),
|
||||
lower_bound.region,
|
||||
upper_bound.origin.clone(),
|
||||
|
@ -1398,7 +1401,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
|
||||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[node_idx.index].span(),
|
||||
(*self.var_origins.borrow())[node_idx.index as uint].span(),
|
||||
format!("collect_error_for_expanding_node() could not find error \
|
||||
for var {}, lower_bounds={}, upper_bounds={}",
|
||||
node_idx,
|
||||
|
@ -1410,7 +1413,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
&self,
|
||||
graph: &RegionGraph,
|
||||
var_data: &[VarData],
|
||||
dup_vec: &mut [uint],
|
||||
dup_vec: &mut [u32],
|
||||
node_idx: RegionVid,
|
||||
errors: &mut Vec<RegionResolutionError<'tcx>>)
|
||||
{
|
||||
|
@ -1431,7 +1434,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
errors.push(SupSupConflict(
|
||||
(*self.var_origins.borrow())[node_idx.index].clone(),
|
||||
(*self.var_origins.borrow())[node_idx.index as uint].clone(),
|
||||
upper_bound_1.origin.clone(),
|
||||
upper_bound_1.region,
|
||||
upper_bound_2.origin.clone(),
|
||||
|
@ -1443,7 +1446,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
|
||||
self.tcx.sess.span_bug(
|
||||
(*self.var_origins.borrow())[node_idx.index].span(),
|
||||
(*self.var_origins.borrow())[node_idx.index as uint].span(),
|
||||
format!("collect_error_for_contracting_node() could not find error \
|
||||
for var {}, upper_bounds={}",
|
||||
node_idx,
|
||||
|
@ -1455,7 +1458,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
var_data: &[VarData],
|
||||
orig_node_idx: RegionVid,
|
||||
dir: Direction,
|
||||
dup_vec: &mut [uint])
|
||||
dup_vec: &mut [u32])
|
||||
-> (Vec<RegionAndOrigin<'tcx>>, bool) {
|
||||
struct WalkState<'tcx> {
|
||||
set: FnvHashSet<RegionVid>,
|
||||
|
@ -1477,12 +1480,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
|
||||
while !state.stack.is_empty() {
|
||||
let node_idx = state.stack.pop().unwrap();
|
||||
let classification = var_data[node_idx.index].classification;
|
||||
let classification = var_data[node_idx.index as uint].classification;
|
||||
|
||||
// check whether we've visited this node on some previous walk
|
||||
if dup_vec[node_idx.index] == uint::MAX {
|
||||
dup_vec[node_idx.index] = orig_node_idx.index;
|
||||
} else if dup_vec[node_idx.index] != orig_node_idx.index {
|
||||
if dup_vec[node_idx.index as uint] == u32::MAX {
|
||||
dup_vec[node_idx.index as uint] = orig_node_idx.index;
|
||||
} else if dup_vec[node_idx.index as uint] != orig_node_idx.index {
|
||||
state.dup_found = true;
|
||||
}
|
||||
|
||||
|
@ -1510,7 +1513,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
dir: Direction) {
|
||||
debug!("process_edges(source_vid={}, dir={})", source_vid, dir);
|
||||
|
||||
let source_node_index = NodeIndex(source_vid.index);
|
||||
let source_node_index = NodeIndex(source_vid.index as uint);
|
||||
graph.each_adjacent_edge(source_node_index, dir, |_, edge| {
|
||||
match edge.data {
|
||||
ConstrainVarSubVar(from_vid, to_vid) => {
|
||||
|
@ -1595,7 +1598,7 @@ fn normalize(values: &Vec<VarValue>, r: ty::Region) -> ty::Region {
|
|||
}
|
||||
|
||||
fn lookup(values: &Vec<VarValue>, rid: ty::RegionVid) -> ty::Region {
|
||||
match values[rid.index] {
|
||||
match values[rid.index as uint] {
|
||||
Value(r) => r,
|
||||
NoValue => ReEmpty, // No constraints, return ty::ReEmpty
|
||||
ErrorValue => ReStatic, // Previously reported error.
|
||||
|
|
|
@ -15,7 +15,7 @@ use self::UndoEntry::*;
|
|||
use middle::ty::{mod, Ty};
|
||||
use std::cmp::min;
|
||||
use std::mem;
|
||||
use std::uint;
|
||||
use std::u32;
|
||||
use util::snapshot_vec as sv;
|
||||
|
||||
pub struct TypeVariableTable<'tcx> {
|
||||
|
@ -67,11 +67,11 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
}
|
||||
|
||||
fn relations<'a>(&'a mut self, a: ty::TyVid) -> &'a mut Vec<Relation> {
|
||||
relations(self.values.get_mut(a.index))
|
||||
relations(self.values.get_mut(a.index as uint))
|
||||
}
|
||||
|
||||
pub fn var_diverges<'a>(&'a self, vid: ty::TyVid) -> bool {
|
||||
self.values.get(vid.index).diverging
|
||||
self.values.get(vid.index as uint).diverging
|
||||
}
|
||||
|
||||
/// Records that `a <: b`, `a :> b`, or `a == b`, depending on `dir`.
|
||||
|
@ -95,7 +95,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
stack: &mut Vec<(Ty<'tcx>, RelationDir, ty::TyVid)>)
|
||||
{
|
||||
let old_value = {
|
||||
let value_ptr = &mut self.values.get_mut(vid.index).value;
|
||||
let value_ptr = &mut self.values.get_mut(vid.index as uint).value;
|
||||
mem::replace(value_ptr, Known(ty))
|
||||
};
|
||||
|
||||
|
@ -117,11 +117,11 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
value: Bounded(vec![]),
|
||||
diverging: diverging
|
||||
});
|
||||
ty::TyVid { index: index }
|
||||
ty::TyVid { index: index as u32 }
|
||||
}
|
||||
|
||||
pub fn probe(&self, vid: ty::TyVid) -> Option<Ty<'tcx>> {
|
||||
match self.values.get(vid.index).value {
|
||||
match self.values.get(vid.index as uint).value {
|
||||
Bounded(..) => None,
|
||||
Known(t) => Some(t)
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
* unified `V1` with `T1`, this function would return `{T0}`.
|
||||
*/
|
||||
|
||||
let mut new_elem_threshold = uint::MAX;
|
||||
let mut new_elem_threshold = u32::MAX;
|
||||
let mut escaping_types = Vec::new();
|
||||
let actions_since_snapshot = self.values.actions_since_snapshot(&s.snapshot);
|
||||
debug!("actions_since_snapshot.len() = {}", actions_since_snapshot.len());
|
||||
|
@ -173,7 +173,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
// always be the first one we see). Note that this
|
||||
// action must precede those variables being
|
||||
// specified.
|
||||
new_elem_threshold = min(new_elem_threshold, index);
|
||||
new_elem_threshold = min(new_elem_threshold, index as u32);
|
||||
debug!("NewElem({}) new_elem_threshold={}", index, new_elem_threshold);
|
||||
}
|
||||
|
||||
|
@ -201,12 +201,12 @@ impl<'tcx> sv::SnapshotVecDelegate<TypeVariableData<'tcx>,UndoEntry> for Delegat
|
|||
action: UndoEntry) {
|
||||
match action {
|
||||
SpecifyVar(vid, relations) => {
|
||||
values[vid.index].value = Bounded(relations);
|
||||
values[vid.index as uint].value = Bounded(relations);
|
||||
}
|
||||
|
||||
Relate(a, b) => {
|
||||
relations(&mut (*values)[a.index]).pop();
|
||||
relations(&mut (*values)[b.index]).pop();
|
||||
relations(&mut (*values)[a.index as uint]).pop();
|
||||
relations(&mut (*values)[b.index as uint]).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,4 +218,3 @@ fn relations<'a>(v: &'a mut TypeVariableData) -> &'a mut Vec<Relation> {
|
|||
Bounded(ref mut relations) => relations
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -347,9 +347,9 @@ impl<'a,'tcx,V:SimplyUnifiable<'tcx>,K:UnifyKey<'tcx, Option<V>>>
|
|||
// Integral type keys
|
||||
|
||||
impl<'tcx> UnifyKey<'tcx, Option<IntVarValue>> for ty::IntVid {
|
||||
fn index(&self) -> uint { self.index }
|
||||
fn index(&self) -> uint { self.index as uint }
|
||||
|
||||
fn from_index(i: uint) -> ty::IntVid { ty::IntVid { index: i } }
|
||||
fn from_index(i: uint) -> ty::IntVid { ty::IntVid { index: i as u32 } }
|
||||
|
||||
fn unification_table<'v>(infcx: &'v InferCtxt)
|
||||
-> &'v RefCell<UnificationTable<ty::IntVid, Option<IntVarValue>>>
|
||||
|
@ -380,9 +380,9 @@ impl<'tcx> UnifyValue<'tcx> for Option<IntVarValue> { }
|
|||
// Floating point type keys
|
||||
|
||||
impl<'tcx> UnifyKey<'tcx, Option<ast::FloatTy>> for ty::FloatVid {
|
||||
fn index(&self) -> uint { self.index }
|
||||
fn index(&self) -> uint { self.index as uint }
|
||||
|
||||
fn from_index(i: uint) -> ty::FloatVid { ty::FloatVid { index: i } }
|
||||
fn from_index(i: uint) -> ty::FloatVid { ty::FloatVid { index: i as u32 } }
|
||||
|
||||
fn unification_table<'v>(infcx: &'v InferCtxt)
|
||||
-> &'v RefCell<UnificationTable<ty::FloatVid, Option<ast::FloatTy>>>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -204,7 +204,7 @@ pub fn opt_deref_kind(t: Ty) -> Option<deref_kind> {
|
|||
|
||||
ty::ty_rptr(r, mt) => {
|
||||
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
|
||||
Some(deref_ptr(BorrowedPtr(kind, r)))
|
||||
Some(deref_ptr(BorrowedPtr(kind, *r)))
|
||||
}
|
||||
|
||||
ty::ty_closure(box ty::ClosureTy {
|
||||
|
@ -1071,7 +1071,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||
-> (ast::Mutability, ty::Region) {
|
||||
match slice_ty.sty {
|
||||
ty::ty_rptr(r, ref mt) => match mt.ty.sty {
|
||||
ty::ty_vec(_, None) => (mt.mutbl, r),
|
||||
ty::ty_vec(_, None) => (mt.mutbl, *r),
|
||||
_ => vec_slice_info(tcx, pat, mt.ty),
|
||||
},
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ use util::nodemap::NodeMap;
|
|||
pub enum DefRegion {
|
||||
DefStaticRegion,
|
||||
DefEarlyBoundRegion(/* space */ subst::ParamSpace,
|
||||
/* index */ uint,
|
||||
/* index */ u32,
|
||||
/* lifetime decl */ ast::NodeId),
|
||||
DefLateBoundRegion(ty::DebruijnIndex,
|
||||
/* lifetime decl */ ast::NodeId),
|
||||
|
@ -508,10 +508,10 @@ impl<'a> LifetimeContext<'a> {
|
|||
|
||||
fn search_lifetimes<'a>(lifetimes: &'a Vec<ast::LifetimeDef>,
|
||||
lifetime_ref: &ast::Lifetime)
|
||||
-> Option<(uint, &'a ast::Lifetime)> {
|
||||
-> Option<(u32, &'a ast::Lifetime)> {
|
||||
for (i, lifetime_decl) in lifetimes.iter().enumerate() {
|
||||
if lifetime_decl.lifetime.name == lifetime_ref.name {
|
||||
return Some((i, &lifetime_decl.lifetime));
|
||||
return Some((i as u32, &lifetime_decl.lifetime));
|
||||
}
|
||||
}
|
||||
return None;
|
||||
|
|
|
@ -98,10 +98,10 @@ impl<'tcx> Substs<'tcx> {
|
|||
}
|
||||
|
||||
pub fn type_for_def(&self, ty_param_def: &ty::TypeParameterDef) -> Ty<'tcx> {
|
||||
*self.types.get(ty_param_def.space, ty_param_def.index)
|
||||
*self.types.get(ty_param_def.space, ty_param_def.index as uint)
|
||||
}
|
||||
|
||||
pub fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
pub fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
self.types.iter().any(|&t| ty::type_escapes_depth(t, depth)) || {
|
||||
match self.regions {
|
||||
ErasedRegions =>
|
||||
|
@ -582,7 +582,7 @@ struct SubstFolder<'a, 'tcx: 'a> {
|
|||
ty_stack_depth: uint,
|
||||
|
||||
// Number of region binders we have passed through while doing the substitution
|
||||
region_binders_passed: uint,
|
||||
region_binders_passed: u32,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
||||
|
@ -607,7 +607,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||
match self.substs.regions {
|
||||
ErasedRegions => ty::ReStatic,
|
||||
NonerasedRegions(ref regions) =>
|
||||
match regions.opt_get(space, i) {
|
||||
match regions.opt_get(space, i as uint) {
|
||||
Some(&r) => {
|
||||
self.shift_region_through_binders(r)
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||
impl<'a,'tcx> SubstFolder<'a,'tcx> {
|
||||
fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
// Look up the type in the substitutions. It really should be in there.
|
||||
let opt_ty = self.substs.types.opt_get(p.space, p.idx);
|
||||
let opt_ty = self.substs.types.opt_get(p.space, p.idx as uint);
|
||||
let ty = match opt_ty {
|
||||
Some(t) => *t,
|
||||
None => {
|
||||
|
|
|
@ -806,7 +806,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
// provide an impl, but only for suitable `fn` pointers
|
||||
ty::ty_bare_fn(_, ty::BareFnTy {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
@ -1100,7 +1100,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
} else {
|
||||
// Recursively check all supertraits to find out if any further
|
||||
// bounds are required and thus we must fulfill.
|
||||
let tmp_tr = data.principal_trait_ref_with_self_ty(ty::mk_err());
|
||||
let tmp_tr = data.principal_trait_ref_with_self_ty(self.tcx(),
|
||||
ty::mk_err());
|
||||
for tr in util::supertraits(self.tcx(), tmp_tr) {
|
||||
let td = ty::lookup_trait_def(self.tcx(), tr.def_id());
|
||||
|
||||
|
@ -1210,7 +1211,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 +1249,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 +1258,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()
|
||||
|
@ -1549,7 +1550,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
|
||||
let sig = match self_ty.sty {
|
||||
ty::ty_bare_fn(_, ty::BareFnTy {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
ref sig
|
||||
|
@ -1574,7 +1575,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 +1616,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) => {
|
||||
|
|
|
@ -410,7 +410,7 @@ pub fn type_of_adjust<'tcx>(cx: &ctxt<'tcx>, adj: &AutoAdjustment<'tcx>) -> Opti
|
|||
},
|
||||
&AutoPtr(r, m, Some(box ref autoref)) => {
|
||||
match type_of_autoref(cx, autoref) {
|
||||
Some(ty) => Some(mk_rptr(cx, r, mt {mutbl: m, ty: ty})),
|
||||
Some(ty) => Some(mk_rptr(cx, cx.mk_region(r), mt {mutbl: m, ty: ty})),
|
||||
None => None
|
||||
}
|
||||
}
|
||||
|
@ -604,18 +604,42 @@ pub struct TransmuteRestriction<'tcx> {
|
|||
pub id: ast::NodeId,
|
||||
}
|
||||
|
||||
/// Internal storage
|
||||
pub struct CtxtArenas<'tcx> {
|
||||
type_: TypedArena<TyS<'tcx>>,
|
||||
substs: TypedArena<Substs<'tcx>>,
|
||||
bare_fn: TypedArena<BareFnTy<'tcx>>,
|
||||
region: TypedArena<Region>,
|
||||
}
|
||||
|
||||
impl<'tcx> CtxtArenas<'tcx> {
|
||||
pub fn new() -> CtxtArenas<'tcx> {
|
||||
CtxtArenas {
|
||||
type_: TypedArena::new(),
|
||||
substs: TypedArena::new(),
|
||||
bare_fn: TypedArena::new(),
|
||||
region: TypedArena::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The data structure to keep track of all the information that typechecker
|
||||
/// generates so that so that it can be reused and doesn't have to be redone
|
||||
/// later on.
|
||||
pub struct ctxt<'tcx> {
|
||||
/// The arena that types are allocated from.
|
||||
type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
/// The arenas that types etc are allocated from.
|
||||
arenas: &'tcx CtxtArenas<'tcx>,
|
||||
|
||||
/// Specifically use a speedy hash algorithm for this hash map, it's used
|
||||
/// quite often.
|
||||
// FIXME(eddyb) use a FnvHashSet<InternedTy<'tcx>> when equivalent keys can
|
||||
// queried from a HashSet.
|
||||
interner: RefCell<FnvHashMap<InternedTy<'tcx>, Ty<'tcx>>>,
|
||||
// FIXME as above, use a hashset if equivalent elements can be queried.
|
||||
substs_interner: RefCell<FnvHashMap<&'tcx Substs<'tcx>, &'tcx Substs<'tcx>>>,
|
||||
bare_fn_interner: RefCell<FnvHashMap<&'tcx BareFnTy<'tcx>, &'tcx BareFnTy<'tcx>>>,
|
||||
region_interner: RefCell<FnvHashMap<&'tcx Region, &'tcx Region>>,
|
||||
|
||||
pub sess: Session,
|
||||
pub def_map: DefMap,
|
||||
|
||||
|
@ -779,13 +803,87 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! sty_debug_print {
|
||||
($ctxt: expr, $($variant: ident),*) => {{
|
||||
// curious inner module to allow variant names to be used as
|
||||
// variable names.
|
||||
mod inner {
|
||||
use middle::ty;
|
||||
#[deriving(Copy)]
|
||||
struct DebugStat {
|
||||
total: uint,
|
||||
region_infer: uint,
|
||||
ty_infer: uint,
|
||||
both_infer: uint,
|
||||
}
|
||||
|
||||
pub fn go(tcx: &ty::ctxt) {
|
||||
let mut total = DebugStat {
|
||||
total: 0,
|
||||
region_infer: 0, ty_infer: 0, both_infer: 0,
|
||||
};
|
||||
$(let mut $variant = total;)*
|
||||
|
||||
|
||||
for (_, t) in tcx.interner.borrow().iter() {
|
||||
let variant = match t.sty {
|
||||
ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) |
|
||||
ty::ty_float(..) | ty::ty_str => continue,
|
||||
ty::ty_err => /* unimportant */ continue,
|
||||
$(ty::$variant(..) => &mut $variant,)*
|
||||
};
|
||||
let region = t.flags.intersects(ty::HAS_RE_INFER);
|
||||
let ty = t.flags.intersects(ty::HAS_TY_INFER);
|
||||
|
||||
variant.total += 1;
|
||||
total.total += 1;
|
||||
if region { total.region_infer += 1; variant.region_infer += 1 }
|
||||
if ty { total.ty_infer += 1; variant.ty_infer += 1 }
|
||||
if region && ty { total.both_infer += 1; variant.both_infer += 1 }
|
||||
}
|
||||
println!("Ty interner total ty region both");
|
||||
$(println!(" {:18}: {uses:6} {usespc:4.1}%, \
|
||||
{ty:4.1}% {region:5.1}% {both:4.1}%",
|
||||
stringify!($variant),
|
||||
uses = $variant.total,
|
||||
usespc = $variant.total as f64 * 100.0 / total.total as f64,
|
||||
ty = $variant.ty_infer as f64 * 100.0 / total.total as f64,
|
||||
region = $variant.region_infer as f64 * 100.0 / total.total as f64,
|
||||
both = $variant.both_infer as f64 * 100.0 / total.total as f64);
|
||||
)*
|
||||
println!(" total {uses:6} \
|
||||
{ty:4.1}% {region:5.1}% {both:4.1}%",
|
||||
uses = total.total,
|
||||
ty = total.ty_infer as f64 * 100.0 / total.total as f64,
|
||||
region = total.region_infer as f64 * 100.0 / total.total as f64,
|
||||
both = total.both_infer as f64 * 100.0 / total.total as f64)
|
||||
}
|
||||
}
|
||||
|
||||
inner::go($ctxt)
|
||||
}}
|
||||
}
|
||||
|
||||
impl<'tcx> ctxt<'tcx> {
|
||||
pub fn print_debug_stats(&self) {
|
||||
sty_debug_print!(
|
||||
self,
|
||||
ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_closure, ty_trait,
|
||||
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer);
|
||||
|
||||
println!("Substs interner: #{}", self.substs_interner.borrow().len());
|
||||
println!("BareFnTy interner: #{}", self.bare_fn_interner.borrow().len());
|
||||
println!("Region interner: #{}", self.region_interner.borrow().len());
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Show)]
|
||||
pub struct TyS<'tcx> {
|
||||
pub sty: sty<'tcx>,
|
||||
pub flags: TypeFlags,
|
||||
|
||||
// the maximal depth of any bound regions appearing in this type.
|
||||
region_depth: uint,
|
||||
region_depth: u32,
|
||||
}
|
||||
|
||||
impl fmt::Show for TypeFlags {
|
||||
|
@ -878,7 +976,7 @@ pub fn type_has_escaping_regions(ty: Ty) -> bool {
|
|||
type_escapes_depth(ty, 0)
|
||||
}
|
||||
|
||||
pub fn type_escapes_depth(ty: Ty, depth: uint) -> bool {
|
||||
pub fn type_escapes_depth(ty: Ty, depth: u32) -> bool {
|
||||
ty.region_depth > depth
|
||||
}
|
||||
|
||||
|
@ -932,7 +1030,7 @@ pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
|
|||
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)]
|
||||
pub struct ParamTy {
|
||||
pub space: subst::ParamSpace,
|
||||
pub idx: uint,
|
||||
pub idx: u32,
|
||||
pub def_id: DefId
|
||||
}
|
||||
|
||||
|
@ -979,7 +1077,7 @@ pub struct ParamTy {
|
|||
pub struct DebruijnIndex {
|
||||
// We maintain the invariant that this is never 0. So 1 indicates
|
||||
// the innermost binder. To ensure this, create with `DebruijnIndex::new`.
|
||||
pub depth: uint,
|
||||
pub depth: u32,
|
||||
}
|
||||
|
||||
/// Representation of regions:
|
||||
|
@ -990,7 +1088,7 @@ pub enum Region {
|
|||
// parameters are substituted.
|
||||
ReEarlyBound(/* param id */ ast::NodeId,
|
||||
subst::ParamSpace,
|
||||
/*index*/ uint,
|
||||
/*index*/ u32,
|
||||
ast::Name),
|
||||
|
||||
// Region bound in a function scope, which will be substituted when the
|
||||
|
@ -1140,7 +1238,7 @@ impl Region {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn escapes_depth(&self, depth: uint) -> bool {
|
||||
pub fn escapes_depth(&self, depth: u32) -> bool {
|
||||
match *self {
|
||||
ty::ReLateBound(debruijn, _) => debruijn.depth > depth,
|
||||
_ => false,
|
||||
|
@ -1161,7 +1259,7 @@ pub struct FreeRegion {
|
|||
RustcEncodable, RustcDecodable, Show, Copy)]
|
||||
pub enum BoundRegion {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
BrAnon(uint),
|
||||
BrAnon(u32),
|
||||
|
||||
/// Named region parameters for functions (a in &'a T)
|
||||
///
|
||||
|
@ -1170,7 +1268,7 @@ pub enum BoundRegion {
|
|||
BrNamed(ast::DefId, ast::Name),
|
||||
|
||||
/// Fresh bound identifiers created during GLB computations.
|
||||
BrFresh(uint),
|
||||
BrFresh(u32),
|
||||
|
||||
// Anonymous region for the implicit env pointer parameter
|
||||
// to a closure
|
||||
|
@ -1241,22 +1339,22 @@ 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.
|
||||
ty_ptr(mt<'tcx>),
|
||||
ty_rptr(Region, mt<'tcx>),
|
||||
ty_rptr(&'tcx Region, mt<'tcx>),
|
||||
|
||||
// If the def-id is Some(_), then this is the type of a specific
|
||||
// fn item. Otherwise, if None(_), it a fn pointer type.
|
||||
ty_bare_fn(Option<DefId>, BareFnTy<'tcx>),
|
||||
ty_bare_fn(Option<DefId>, &'tcx BareFnTy<'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, &'tcx Region, &'tcx Substs<'tcx>),
|
||||
|
||||
ty_tup(Vec<Ty<'tcx>>),
|
||||
|
||||
|
@ -1285,12 +1383,13 @@ impl<'tcx> TyTrait<'tcx> {
|
|||
/// we convert the principal trait-ref into a normal trait-ref,
|
||||
/// you must give *some* self-type. A common choice is `mk_err()`
|
||||
/// or some skolemized type.
|
||||
pub fn principal_trait_ref_with_self_ty(&self, self_ty: Ty<'tcx>)
|
||||
pub fn principal_trait_ref_with_self_ty(&self,
|
||||
tcx: &ctxt<'tcx>, self_ty: Ty<'tcx>)
|
||||
-> Rc<ty::PolyTraitRef<'tcx>>
|
||||
{
|
||||
Rc::new(ty::Binder(ty::TraitRef {
|
||||
def_id: self.principal.def_id(),
|
||||
substs: self.principal.substs().with_self_ty(self_ty),
|
||||
substs: tcx.mk_substs(self.principal.substs().with_self_ty(self_ty)),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -1313,7 +1412,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>>;
|
||||
|
@ -1327,8 +1426,8 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
|||
self.0.def_id
|
||||
}
|
||||
|
||||
pub fn substs(&self) -> &Substs<'tcx> {
|
||||
&self.0.substs
|
||||
pub fn substs(&self) -> &'tcx Substs<'tcx> {
|
||||
self.0.substs
|
||||
}
|
||||
|
||||
pub fn input_types(&self) -> &[Ty<'tcx>] {
|
||||
|
@ -1461,22 +1560,22 @@ impl CLike for BuiltinBound {
|
|||
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct TyVid {
|
||||
pub index: uint
|
||||
pub index: u32
|
||||
}
|
||||
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct IntVid {
|
||||
pub index: uint
|
||||
pub index: u32
|
||||
}
|
||||
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct FloatVid {
|
||||
pub index: uint
|
||||
pub index: u32
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
||||
pub struct RegionVid {
|
||||
pub index: uint
|
||||
pub index: u32
|
||||
}
|
||||
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
@ -1488,18 +1587,18 @@ pub enum InferTy {
|
|||
/// A `FreshTy` is one that is generated as a replacement for an
|
||||
/// unbound type variable. This is convenient for caching etc. See
|
||||
/// `middle::infer::freshen` for more details.
|
||||
FreshTy(uint),
|
||||
FreshTy(u32),
|
||||
|
||||
// FIXME -- once integral fallback is impl'd, we should remove
|
||||
// this type. It's only needed to prevent spurious errors for
|
||||
// integers whose type winds up never being constrained.
|
||||
FreshIntTy(uint),
|
||||
FreshIntTy(u32),
|
||||
}
|
||||
|
||||
#[deriving(Clone, RustcEncodable, RustcDecodable, Eq, Hash, Show, Copy)]
|
||||
pub enum InferRegion {
|
||||
ReVar(RegionVid),
|
||||
ReSkolemized(uint, BoundRegion)
|
||||
ReSkolemized(u32, BoundRegion)
|
||||
}
|
||||
|
||||
impl cmp::PartialEq for InferRegion {
|
||||
|
@ -1576,7 +1675,7 @@ pub struct TypeParameterDef<'tcx> {
|
|||
pub name: ast::Name,
|
||||
pub def_id: ast::DefId,
|
||||
pub space: subst::ParamSpace,
|
||||
pub index: uint,
|
||||
pub index: u32,
|
||||
pub associated_with: Option<ast::DefId>,
|
||||
pub bounds: ParamBounds<'tcx>,
|
||||
pub default: Option<Ty<'tcx>>,
|
||||
|
@ -1587,7 +1686,7 @@ pub struct RegionParameterDef {
|
|||
pub name: ast::Name,
|
||||
pub def_id: ast::DefId,
|
||||
pub space: subst::ParamSpace,
|
||||
pub index: uint,
|
||||
pub index: u32,
|
||||
pub bounds: Vec<ty::Region>,
|
||||
}
|
||||
|
||||
|
@ -1749,7 +1848,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 }
|
||||
}
|
||||
|
||||
|
@ -1977,7 +2076,7 @@ impl UnboxedClosureKind {
|
|||
}
|
||||
|
||||
pub fn mk_ctxt<'tcx>(s: Session,
|
||||
type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
arenas: &'tcx CtxtArenas<'tcx>,
|
||||
dm: DefMap,
|
||||
named_region_map: resolve_lifetime::NamedRegionMap,
|
||||
map: ast_map::Map<'tcx>,
|
||||
|
@ -1987,8 +2086,11 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||
lang_items: middle::lang_items::LanguageItems,
|
||||
stability: stability::Index) -> ctxt<'tcx> {
|
||||
ctxt {
|
||||
type_arena: type_arena,
|
||||
arenas: arenas,
|
||||
interner: RefCell::new(FnvHashMap::new()),
|
||||
substs_interner: RefCell::new(FnvHashMap::new()),
|
||||
bare_fn_interner: RefCell::new(FnvHashMap::new()),
|
||||
region_interner: RefCell::new(FnvHashMap::new()),
|
||||
named_region_map: named_region_map,
|
||||
item_variance_map: RefCell::new(DefIdMap::new()),
|
||||
variance_computed: Cell::new(false),
|
||||
|
@ -2048,6 +2150,38 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||
|
||||
// Type constructors
|
||||
|
||||
impl<'tcx> ctxt<'tcx> {
|
||||
pub fn mk_substs(&self, substs: Substs<'tcx>) -> &'tcx Substs<'tcx> {
|
||||
if let Some(substs) = self.substs_interner.borrow().get(&substs) {
|
||||
return *substs;
|
||||
}
|
||||
|
||||
let substs = self.arenas.substs.alloc(substs);
|
||||
self.substs_interner.borrow_mut().insert(substs, substs);
|
||||
substs
|
||||
}
|
||||
|
||||
pub fn mk_bare_fn(&self, bare_fn: BareFnTy<'tcx>) -> &'tcx BareFnTy<'tcx> {
|
||||
if let Some(bare_fn) = self.bare_fn_interner.borrow().get(&bare_fn) {
|
||||
return *bare_fn;
|
||||
}
|
||||
|
||||
let bare_fn = self.arenas.bare_fn.alloc(bare_fn);
|
||||
self.bare_fn_interner.borrow_mut().insert(bare_fn, bare_fn);
|
||||
bare_fn
|
||||
}
|
||||
|
||||
pub fn mk_region(&self, region: Region) -> &'tcx Region {
|
||||
if let Some(region) = self.region_interner.borrow().get(®ion) {
|
||||
return *region;
|
||||
}
|
||||
|
||||
let region = self.arenas.region.alloc(region);
|
||||
self.region_interner.borrow_mut().insert(region, region);
|
||||
region
|
||||
}
|
||||
}
|
||||
|
||||
// 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> {
|
||||
|
@ -2069,7 +2203,7 @@ pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
|
|||
|
||||
let flags = FlagComputation::for_sty(&st);
|
||||
|
||||
let ty = cx.type_arena.alloc(TyS {
|
||||
let ty = cx.arenas.type_.alloc(TyS {
|
||||
sty: st,
|
||||
flags: flags.flags,
|
||||
region_depth: flags.depth,
|
||||
|
@ -2084,7 +2218,7 @@ struct FlagComputation {
|
|||
flags: TypeFlags,
|
||||
|
||||
// maximum depth of any bound region that we have seen thus far
|
||||
depth: uint,
|
||||
depth: u32,
|
||||
}
|
||||
|
||||
impl FlagComputation {
|
||||
|
@ -2102,7 +2236,7 @@ impl FlagComputation {
|
|||
self.flags = self.flags | flags;
|
||||
}
|
||||
|
||||
fn add_depth(&mut self, depth: uint) {
|
||||
fn add_depth(&mut self, depth: u32) {
|
||||
if depth > self.depth {
|
||||
self.depth = depth;
|
||||
}
|
||||
|
@ -2151,7 +2285,7 @@ impl FlagComputation {
|
|||
}
|
||||
}
|
||||
|
||||
&ty_unboxed_closure(_, ref region, ref substs) => {
|
||||
&ty_unboxed_closure(_, region, substs) => {
|
||||
self.add_region(*region);
|
||||
self.add_substs(substs);
|
||||
}
|
||||
|
@ -2160,7 +2294,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);
|
||||
}
|
||||
|
||||
|
@ -2181,7 +2315,7 @@ impl FlagComputation {
|
|||
}
|
||||
|
||||
&ty_rptr(r, ref m) => {
|
||||
self.add_region(r);
|
||||
self.add_region(*r);
|
||||
self.add_ty(m.ty);
|
||||
}
|
||||
|
||||
|
@ -2286,7 +2420,7 @@ pub fn mk_str<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
|||
mk_t(cx, ty_str)
|
||||
}
|
||||
|
||||
pub fn mk_str_slice<'tcx>(cx: &ctxt<'tcx>, r: Region, m: ast::Mutability) -> Ty<'tcx> {
|
||||
pub fn mk_str_slice<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, m: ast::Mutability) -> Ty<'tcx> {
|
||||
mk_rptr(cx, r,
|
||||
mt {
|
||||
ty: mk_t(cx, ty_str),
|
||||
|
@ -2294,7 +2428,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))
|
||||
}
|
||||
|
@ -2303,14 +2437,14 @@ pub fn mk_uniq<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { mk_t(cx, ty_un
|
|||
|
||||
pub fn mk_ptr<'tcx>(cx: &ctxt<'tcx>, tm: mt<'tcx>) -> Ty<'tcx> { mk_t(cx, ty_ptr(tm)) }
|
||||
|
||||
pub fn mk_rptr<'tcx>(cx: &ctxt<'tcx>, r: Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_rptr<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, ty_rptr(r, tm))
|
||||
}
|
||||
|
||||
pub fn mk_mut_rptr<'tcx>(cx: &ctxt<'tcx>, r: Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_mut_rptr<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutMutable})
|
||||
}
|
||||
pub fn mk_imm_rptr<'tcx>(cx: &ctxt<'tcx>, r: Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_imm_rptr<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutImmutable})
|
||||
}
|
||||
|
||||
|
@ -2330,7 +2464,7 @@ pub fn mk_vec<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, sz: Option<uint>) -> Ty<'tcx>
|
|||
mk_t(cx, ty_vec(ty, sz))
|
||||
}
|
||||
|
||||
pub fn mk_slice<'tcx>(cx: &ctxt<'tcx>, r: Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_slice<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
mk_rptr(cx, r,
|
||||
mt {
|
||||
ty: mk_vec(cx, tm.ty, None),
|
||||
|
@ -2352,7 +2486,7 @@ pub fn mk_closure<'tcx>(cx: &ctxt<'tcx>, fty: ClosureTy<'tcx>) -> Ty<'tcx> {
|
|||
|
||||
pub fn mk_bare_fn<'tcx>(cx: &ctxt<'tcx>,
|
||||
opt_def_id: Option<ast::DefId>,
|
||||
fty: BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
fty: &'tcx BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, ty_bare_fn(opt_def_id, fty))
|
||||
}
|
||||
|
||||
|
@ -2363,7 +2497,7 @@ pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
|
|||
let input_args = input_tys.iter().map(|ty| *ty).collect();
|
||||
mk_bare_fn(cx,
|
||||
Some(def_id),
|
||||
BareFnTy {
|
||||
cx.mk_bare_fn(BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(FnSig {
|
||||
|
@ -2371,7 +2505,7 @@ pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
|
|||
output: ty::FnConverging(output),
|
||||
variadic: false
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
@ -2388,13 +2522,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: &'tcx Region, substs: &'tcx Substs<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
mk_t(cx, ty_unboxed_closure(closure_id, region, substs))
|
||||
}
|
||||
|
@ -2416,7 +2550,7 @@ pub fn mk_infer<'tcx>(cx: &ctxt<'tcx>, it: InferTy) -> Ty<'tcx> {
|
|||
}
|
||||
|
||||
pub fn mk_param<'tcx>(cx: &ctxt<'tcx>, space: subst::ParamSpace,
|
||||
n: uint, k: DefId) -> Ty<'tcx> {
|
||||
n: u32, k: DefId) -> Ty<'tcx> {
|
||||
mk_t(cx, ty_param(ParamTy { space: space, idx: n, def_id: k }))
|
||||
}
|
||||
|
||||
|
@ -2488,7 +2622,7 @@ pub fn fold_ty<'tcx, F>(cx: &ctxt<'tcx>, t0: Ty<'tcx>,
|
|||
|
||||
impl ParamTy {
|
||||
pub fn new(space: subst::ParamSpace,
|
||||
index: uint,
|
||||
index: u32,
|
||||
def_id: ast::DefId)
|
||||
-> ParamTy {
|
||||
ParamTy { space: space, idx: index, def_id: def_id }
|
||||
|
@ -2617,7 +2751,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)
|
||||
}
|
||||
|
@ -2716,7 +2850,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);
|
||||
|
@ -2969,9 +3103,10 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
|
||||
ty_rptr(r, ref mt) => {
|
||||
TC::ReachesFfiUnsafe | match mt.ty.sty {
|
||||
ty_str => borrowed_contents(r, ast::MutImmutable),
|
||||
ty_vec(..) => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(r, mt.mutbl)),
|
||||
_ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(r, mt.mutbl)),
|
||||
ty_str => borrowed_contents(*r, ast::MutImmutable),
|
||||
ty_vec(..) => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r,
|
||||
mt.mutbl)),
|
||||
_ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r, mt.mutbl)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2984,7 +3119,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[],
|
||||
|
@ -3000,13 +3135,13 @@ 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);
|
||||
TypeContents::union(upvars.as_slice(),
|
||||
|f| tc_ty(cx, f.ty, cache))
|
||||
| borrowed_contents(r, MutMutable)
|
||||
| borrowed_contents(*r, MutMutable)
|
||||
}
|
||||
|
||||
ty_tup(ref tys) => {
|
||||
|
@ -3014,7 +3149,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| {
|
||||
|
@ -3306,7 +3441,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));
|
||||
|
@ -3314,7 +3449,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))
|
||||
}
|
||||
|
@ -3327,7 +3462,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| {
|
||||
|
@ -3394,11 +3529,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() })
|
||||
|
@ -3406,7 +3541,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))
|
||||
}
|
||||
|
@ -3626,7 +3761,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.
|
||||
|
@ -3678,7 +3813,7 @@ pub fn deref<'tcx>(ty: Ty<'tcx>, explicit: bool) -> Option<mt<'tcx>> {
|
|||
|
||||
pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
ty_open(ty) => mk_rptr(cx, ReStatic, mt {ty: ty, mutbl:ast::MutImmutable}),
|
||||
ty_open(ty) => mk_rptr(cx, cx.mk_region(ReStatic), mt {ty: ty, mutbl:ast::MutImmutable}),
|
||||
_ => cx.sess.bug(format!("Trying to close a non-open type {}",
|
||||
ty_to_string(cx, ty))[])
|
||||
}
|
||||
|
@ -3730,16 +3865,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];
|
||||
|
@ -3758,12 +3893,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")
|
||||
|
@ -3882,7 +4017,7 @@ pub fn ty_region(tcx: &ctxt,
|
|||
span: Span,
|
||||
ty: Ty) -> Region {
|
||||
match ty.sty {
|
||||
ty_rptr(r, _) => r,
|
||||
ty_rptr(r, _) => *r,
|
||||
ref s => {
|
||||
tcx.sess.span_bug(
|
||||
span,
|
||||
|
@ -4025,8 +4160,8 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
|
|||
|
||||
AdjustReifyFnPointer(_) => {
|
||||
match unadjusted_ty.sty {
|
||||
ty::ty_bare_fn(Some(_), ref b) => {
|
||||
ty::mk_bare_fn(cx, None, (*b).clone())
|
||||
ty::ty_bare_fn(Some(_), b) => {
|
||||
ty::mk_bare_fn(cx, None, b)
|
||||
}
|
||||
ref b => {
|
||||
cx.sess.bug(
|
||||
|
@ -4088,7 +4223,7 @@ pub fn adjust_ty_for_autoref<'tcx>(cx: &ctxt<'tcx>,
|
|||
&Some(box ref a) => adjust_ty_for_autoref(cx, span, ty, Some(a)),
|
||||
&None => ty
|
||||
};
|
||||
mk_rptr(cx, r, mt {
|
||||
mk_rptr(cx, cx.mk_region(r), mt {
|
||||
ty: adjusted_ty,
|
||||
mutbl: m
|
||||
})
|
||||
|
@ -4126,12 +4261,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: {}",
|
||||
|
@ -4731,7 +4866,7 @@ pub fn associated_type_parameter_index(cx: &ctxt,
|
|||
-> uint {
|
||||
for type_parameter_def in trait_def.generics.types.iter() {
|
||||
if type_parameter_def.def_id == associated_type_id {
|
||||
return type_parameter_def.index
|
||||
return type_parameter_def.index as uint
|
||||
}
|
||||
}
|
||||
cx.sess.bug("couldn't find associated type parameter index")
|
||||
|
@ -5156,9 +5291,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();
|
||||
|
@ -5375,7 +5511,7 @@ pub fn unboxed_closure_upvars<'tcx>(tcx: &ctxt<'tcx>, closure_id: ast::DefId, su
|
|||
var_id: freevar_def_id.node,
|
||||
closure_expr_id: closure_id.node
|
||||
}].clone();
|
||||
freevar_ty = mk_rptr(tcx, borrow.region, ty::mt {
|
||||
freevar_ty = mk_rptr(tcx, tcx.mk_region(borrow.region), ty::mt {
|
||||
ty: freevar_ty,
|
||||
mutbl: borrow.kind.to_mutbl_lossy()
|
||||
});
|
||||
|
@ -5568,7 +5704,7 @@ pub fn object_region_bounds<'tcx>(tcx: &ctxt<'tcx>,
|
|||
|
||||
let opt_trait_ref = opt_principal.map_or(Vec::new(), |principal| {
|
||||
let substs = principal.substs().with_self_ty(open_ty);
|
||||
vec!(Rc::new(ty::Binder(ty::TraitRef::new(principal.def_id(), substs))))
|
||||
vec!(Rc::new(ty::Binder(ty::TraitRef::new(principal.def_id(), tcx.mk_substs(substs)))))
|
||||
});
|
||||
|
||||
let param_bounds = ty::ParamBounds {
|
||||
|
@ -5927,7 +6063,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
|
|||
}
|
||||
ty_rptr(r, m) => {
|
||||
byte!(13);
|
||||
region(state, r);
|
||||
region(state, *r);
|
||||
mt(state, m);
|
||||
}
|
||||
ty_bare_fn(opt_def_id, ref b) => {
|
||||
|
@ -5987,7 +6123,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
|
|||
ty_unboxed_closure(d, r, _) => {
|
||||
byte!(24);
|
||||
did(state, d);
|
||||
region(state, r);
|
||||
region(state, *r);
|
||||
}
|
||||
}
|
||||
true
|
||||
|
@ -6095,7 +6231,7 @@ pub fn construct_parameter_environment<'tcx>(
|
|||
space,
|
||||
def.repr(tcx),
|
||||
i);
|
||||
let ty = ty::mk_param(tcx, space, i, def.def_id);
|
||||
let ty = ty::mk_param(tcx, space, i as u32, def.def_id);
|
||||
types.push(space, ty);
|
||||
}
|
||||
}
|
||||
|
@ -6229,13 +6365,13 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
|||
walk_ty(ty, |ty| {
|
||||
match ty.sty {
|
||||
ty_rptr(region, _) => {
|
||||
accumulator.push(region)
|
||||
accumulator.push(*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) => {
|
||||
|
@ -6244,7 +6380,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
|||
UniqTraitStore => {}
|
||||
}
|
||||
}
|
||||
ty_unboxed_closure(_, ref region, ref substs) => {
|
||||
ty_unboxed_closure(_, region, substs) => {
|
||||
accumulator.push(*region);
|
||||
accum_substs(accumulator, substs);
|
||||
}
|
||||
|
@ -6416,12 +6552,12 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
|
|||
}
|
||||
|
||||
impl DebruijnIndex {
|
||||
pub fn new(depth: uint) -> DebruijnIndex {
|
||||
pub fn new(depth: u32) -> DebruijnIndex {
|
||||
assert!(depth > 0);
|
||||
DebruijnIndex { depth: depth }
|
||||
}
|
||||
|
||||
pub fn shifted(&self, amount: uint) -> DebruijnIndex {
|
||||
pub fn shifted(&self, amount: u32) -> DebruijnIndex {
|
||||
DebruijnIndex { depth: self.depth + amount }
|
||||
}
|
||||
}
|
||||
|
@ -6559,7 +6695,7 @@ pub fn can_type_implement_copy<'tcx>(tcx: &ctxt<'tcx>,
|
|||
param_env: &ParameterEnvironment<'tcx>)
|
||||
-> Result<(),CopyImplementationError> {
|
||||
match self_type.sty {
|
||||
ty::ty_struct(struct_did, ref substs) => {
|
||||
ty::ty_struct(struct_did, substs) => {
|
||||
let fields = ty::struct_fields(tcx, struct_did, substs);
|
||||
for field in fields.iter() {
|
||||
if type_moves_by_default(tcx, field.mt.ty, param_env) {
|
||||
|
@ -6567,7 +6703,7 @@ pub fn can_type_implement_copy<'tcx>(tcx: &ctxt<'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::ty_enum(enum_did, ref substs) => {
|
||||
ty::ty_enum(enum_did, substs) => {
|
||||
let enum_variants = ty::enum_variants(tcx, enum_did);
|
||||
for variant in enum_variants.iter() {
|
||||
for variant_arg_type in variant.args.iter() {
|
||||
|
@ -6592,43 +6728,42 @@ pub trait RegionEscape {
|
|||
self.has_regions_escaping_depth(0)
|
||||
}
|
||||
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool;
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool;
|
||||
}
|
||||
|
||||
impl<'tcx> RegionEscape for Ty<'tcx> {
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
ty::type_escapes_depth(*self, depth)
|
||||
}
|
||||
}
|
||||
|
||||
impl RegionEscape for Region {
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
self.escapes_depth(depth)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> RegionEscape for TraitRef<'tcx> {
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
self.substs.types.iter().any(|t| t.has_regions_escaping_depth(depth)) &&
|
||||
self.substs.regions().iter().any(|t| t.has_regions_escaping_depth(depth))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx,T:RegionEscape> RegionEscape for Binder<T> {
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
self.0.has_regions_escaping_depth(depth + 1)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> RegionEscape for EquatePredicate<'tcx> {
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
self.0.has_regions_escaping_depth(depth) || self.1.has_regions_escaping_depth(depth)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:RegionEscape,U:RegionEscape> RegionEscape for OutlivesPredicate<T,U> {
|
||||
fn has_regions_escaping_depth(&self, depth: uint) -> bool {
|
||||
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
|
||||
self.0.has_regions_escaping_depth(depth) || self.1.has_regions_escaping_depth(depth)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -527,7 +527,8 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
|||
ty::ty_open(typ.fold_with(this))
|
||||
}
|
||||
ty::ty_enum(tid, ref substs) => {
|
||||
ty::ty_enum(tid, substs.fold_with(this))
|
||||
let substs = substs.fold_with(this);
|
||||
ty::ty_enum(tid, this.tcx().mk_substs(substs))
|
||||
}
|
||||
ty::ty_trait(box ty::TyTrait { ref principal, bounds }) => {
|
||||
ty::ty_trait(box ty::TyTrait {
|
||||
|
@ -539,19 +540,24 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
|||
ty::ty_tup(ts.fold_with(this))
|
||||
}
|
||||
ty::ty_bare_fn(opt_def_id, ref f) => {
|
||||
ty::ty_bare_fn(opt_def_id, f.fold_with(this))
|
||||
let bfn = f.fold_with(this);
|
||||
ty::ty_bare_fn(opt_def_id, this.tcx().mk_bare_fn(bfn))
|
||||
}
|
||||
ty::ty_closure(ref f) => {
|
||||
ty::ty_closure(box f.fold_with(this))
|
||||
}
|
||||
ty::ty_rptr(r, ref tm) => {
|
||||
ty::ty_rptr(r.fold_with(this), tm.fold_with(this))
|
||||
let r = r.fold_with(this);
|
||||
ty::ty_rptr(this.tcx().mk_region(r), tm.fold_with(this))
|
||||
}
|
||||
ty::ty_struct(did, ref substs) => {
|
||||
ty::ty_struct(did, substs.fold_with(this))
|
||||
let substs = substs.fold_with(this);
|
||||
ty::ty_struct(did, this.tcx().mk_substs(substs))
|
||||
}
|
||||
ty::ty_unboxed_closure(did, ref region, ref substs) => {
|
||||
ty::ty_unboxed_closure(did, region.fold_with(this), substs.fold_with(this))
|
||||
let r = region.fold_with(this);
|
||||
let s = substs.fold_with(this);
|
||||
ty::ty_unboxed_closure(did, this.tcx().mk_region(r), this.tcx().mk_substs(s))
|
||||
}
|
||||
ty::ty_bool | ty::ty_char | ty::ty_str |
|
||||
ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
|
||||
|
@ -624,9 +630,10 @@ pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
|||
t: &ty::TraitRef<'tcx>)
|
||||
-> ty::TraitRef<'tcx>
|
||||
{
|
||||
let substs = t.substs.fold_with(this);
|
||||
ty::TraitRef {
|
||||
def_id: t.def_id,
|
||||
substs: t.substs.fold_with(this),
|
||||
substs: this.tcx().mk_substs(substs),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -717,13 +724,13 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
|
|||
|
||||
pub struct RegionFolder<'a, 'tcx: 'a> {
|
||||
tcx: &'a ty::ctxt<'tcx>,
|
||||
current_depth: uint,
|
||||
fld_r: &'a mut (FnMut(ty::Region, uint) -> ty::Region + 'a),
|
||||
current_depth: u32,
|
||||
fld_r: &'a mut (FnMut(ty::Region, u32) -> ty::Region + 'a),
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
|
||||
pub fn new<F>(tcx: &'a ty::ctxt<'tcx>, fld_r: &'a mut F) -> RegionFolder<'a, 'tcx>
|
||||
where F : FnMut(ty::Region, uint) -> ty::Region
|
||||
where F : FnMut(ty::Region, u32) -> ty::Region
|
||||
{
|
||||
RegionFolder {
|
||||
tcx: tcx,
|
||||
|
@ -745,7 +752,7 @@ pub fn fold_regions<'tcx,T,F>(tcx: &ty::ctxt<'tcx>,
|
|||
value: &T,
|
||||
mut f: F)
|
||||
-> T
|
||||
where F : FnMut(ty::Region, uint) -> ty::Region,
|
||||
where F : FnMut(ty::Region, u32) -> ty::Region,
|
||||
T : TypeFoldable<'tcx>,
|
||||
{
|
||||
value.fold_with(&mut RegionFolder::new(tcx, &mut f))
|
||||
|
@ -813,7 +820,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionEraser<'a, 'tcx> {
|
|||
// regions. See comment on `shift_regions_through_binders` method in
|
||||
// `subst.rs` for more details.
|
||||
|
||||
pub fn shift_region(region: ty::Region, amount: uint) -> ty::Region {
|
||||
pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region {
|
||||
match region {
|
||||
ty::ReLateBound(debruijn, br) => {
|
||||
ty::ReLateBound(debruijn.shifted(amount), br)
|
||||
|
@ -825,7 +832,7 @@ pub fn shift_region(region: ty::Region, amount: uint) -> ty::Region {
|
|||
}
|
||||
|
||||
pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>,
|
||||
amount: uint, value: &T) -> T {
|
||||
amount: u32, value: &T) -> T {
|
||||
debug!("shift_regions(value={}, amount={})",
|
||||
value.repr(tcx), amount);
|
||||
|
||||
|
@ -833,4 +840,3 @@ pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>
|
|||
shift_region(region, amount)
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,8 @@ debugging_opts! {
|
|||
PARSE_ONLY,
|
||||
NO_TRANS,
|
||||
NO_ANALYSIS,
|
||||
UNSTABLE_OPTIONS
|
||||
UNSTABLE_OPTIONS,
|
||||
PRINT_ENUM_SIZES
|
||||
]
|
||||
0
|
||||
}
|
||||
|
@ -331,7 +332,9 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
|
|||
("no-analysis", "Parse and expand the source, but run no analysis and",
|
||||
NO_TRANS),
|
||||
("unstable-options", "Adds unstable command line options to rustc interface",
|
||||
UNSTABLE_OPTIONS)]
|
||||
UNSTABLE_OPTIONS),
|
||||
("print-enum-sizes", "Print the size of enums and their variants", PRINT_ENUM_SIZES),
|
||||
]
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
|
|
|
@ -202,6 +202,9 @@ impl Session {
|
|||
pub fn show_span(&self) -> bool {
|
||||
self.debugging_opt(config::SHOW_SPAN)
|
||||
}
|
||||
pub fn print_enum_sizes(&self) -> bool {
|
||||
self.debugging_opt(config::PRINT_ENUM_SIZES)
|
||||
}
|
||||
pub fn sysroot<'a>(&'a self) -> &'a Path {
|
||||
match self.opts.maybe_sysroot {
|
||||
Some (ref sysroot) => sysroot,
|
||||
|
@ -304,4 +307,3 @@ pub fn early_warn(msg: &str) {
|
|||
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
|
||||
emitter.emit(None, msg, None, diagnostic::Warning);
|
||||
}
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
}, ty_to_string(cx, tm.ty))
|
||||
}
|
||||
ty_rptr(r, ref tm) => {
|
||||
let mut buf = region_ptr_to_string(cx, r);
|
||||
let mut buf = region_ptr_to_string(cx, *r);
|
||||
buf.push_str(mt_to_string(cx, tm)[]);
|
||||
buf
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -759,7 +759,7 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
|
|||
let trait_def = ty::lookup_trait_def(tcx, self.def_id);
|
||||
format!("TraitRef({}, {})",
|
||||
self.substs.self_ty().repr(tcx),
|
||||
parameterized(tcx, base.as_slice(), &self.substs, &trait_def.generics, self.def_id))
|
||||
parameterized(tcx, base.as_slice(), self.substs, &trait_def.generics, self.def_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -32,7 +32,6 @@ use serialize::{json, Encodable};
|
|||
use std::io;
|
||||
use std::io::fs;
|
||||
use std::os;
|
||||
use arena::TypedArena;
|
||||
use syntax::ast;
|
||||
use syntax::ast_map;
|
||||
use syntax::attr;
|
||||
|
@ -79,12 +78,23 @@ 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 arenas = ty::CtxtArenas::new();
|
||||
let analysis = phase_3_run_analysis_passes(sess, ast_map, &arenas, id);
|
||||
phase_save_analysis(&analysis.ty_cx.sess, analysis.ty_cx.map.krate(), &analysis, outdir);
|
||||
|
||||
if log_enabled!(::log::INFO) {
|
||||
println!("Pre-trans");
|
||||
analysis.ty_cx.print_debug_stats();
|
||||
}
|
||||
|
||||
if stop_after_phase_3(&analysis.ty_cx.sess) { return; }
|
||||
let (tcx, trans) = phase_4_translate_to_llvm(analysis);
|
||||
|
||||
if log_enabled!(::log::INFO) {
|
||||
println!("Post-trans");
|
||||
tcx.print_debug_stats();
|
||||
}
|
||||
|
||||
// Discard interned strings as they are no longer required.
|
||||
token::get_ident_interner().clear();
|
||||
|
||||
|
@ -331,7 +341,7 @@ pub fn assign_node_ids_and_map<'ast>(sess: &Session,
|
|||
/// structures carrying the results of the analysis.
|
||||
pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
||||
ast_map: ast_map::Map<'tcx>,
|
||||
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
|
||||
arenas: &'tcx ty::CtxtArenas<'tcx>,
|
||||
name: String) -> ty::CrateAnalysis<'tcx> {
|
||||
let time_passes = sess.time_passes();
|
||||
let krate = ast_map.krate();
|
||||
|
@ -391,7 +401,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
|||
middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map));
|
||||
|
||||
let ty_cx = ty::mk_ctxt(sess,
|
||||
type_arena,
|
||||
arenas,
|
||||
def_map,
|
||||
named_region_map,
|
||||
ast_map,
|
||||
|
|
|
@ -40,7 +40,6 @@ use graphviz as dot;
|
|||
use std::io::{mod, MemReader};
|
||||
use std::option;
|
||||
use std::str::FromStr;
|
||||
use arena::TypedArena;
|
||||
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
pub enum PpSourceMode {
|
||||
|
@ -112,7 +111,7 @@ impl PpSourceMode {
|
|||
fn call_with_pp_support<'tcx, A, B, F>(&self,
|
||||
sess: Session,
|
||||
ast_map: Option<ast_map::Map<'tcx>>,
|
||||
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
|
||||
arenas: &'tcx ty::CtxtArenas<'tcx>,
|
||||
id: String,
|
||||
payload: B,
|
||||
f: F) -> A where
|
||||
|
@ -134,8 +133,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);
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map, arenas, id);
|
||||
let annotation = TypedAnnotation { analysis: analysis };
|
||||
f(&annotation, payload)
|
||||
}
|
||||
|
@ -510,7 +508,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
};
|
||||
|
||||
let mut forest = ast_map::Forest::new(krate);
|
||||
let type_arena = TypedArena::new();
|
||||
let arenas = ty::CtxtArenas::new();
|
||||
|
||||
let (krate, ast_map) = if compute_ast_map {
|
||||
let map = driver::assign_node_ids_and_map(&sess, &mut forest);
|
||||
|
@ -539,7 +537,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, &arenas, id, out, |annotation, out| {
|
||||
debug!("pretty printing source code {}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust::print_crate(sess.codemap(),
|
||||
|
@ -554,7 +552,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, &arenas, id, (out,uii), |annotation, (out,uii)| {
|
||||
debug!("pretty printing source code {}", s);
|
||||
let sess = annotation.sess();
|
||||
let ast_map = annotation.ast_map()
|
||||
|
@ -596,8 +594,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
match code {
|
||||
Some(code) => {
|
||||
let variants = gather_flowgraph_variants(&sess);
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map,
|
||||
&type_arena, id);
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map, &arenas, id);
|
||||
print_flowgraph(variants, analysis, code, out)
|
||||
}
|
||||
None => {
|
||||
|
|
|
@ -127,9 +127,9 @@ fn test_env<F>(source_string: &str,
|
|||
let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map);
|
||||
let region_map = region::resolve_crate(&sess, krate);
|
||||
let stability_index = stability::Index::build(krate);
|
||||
let type_arena = TypedArena::new();
|
||||
let arenas = ty::CtxtArenas::new();
|
||||
let tcx = ty::mk_ctxt(sess,
|
||||
&type_arena,
|
||||
&arenas,
|
||||
def_map,
|
||||
named_region_map,
|
||||
ast_map,
|
||||
|
@ -256,7 +256,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
let input_args = input_tys.iter().map(|ty| *ty).collect();
|
||||
ty::mk_bare_fn(self.infcx.tcx,
|
||||
None,
|
||||
ty::BareFnTy {
|
||||
self.infcx.tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
@ -264,7 +264,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
output: ty::FnConverging(output_ty),
|
||||
variadic: false
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn t_nil(&self) -> Ty<'tcx> {
|
||||
|
@ -295,13 +295,13 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn t_param(&self, space: subst::ParamSpace, index: uint) -> Ty<'tcx> {
|
||||
pub fn t_param(&self, space: subst::ParamSpace, index: u32) -> Ty<'tcx> {
|
||||
ty::mk_param(self.infcx.tcx, space, index, ast_util::local_def(ast::DUMMY_NODE_ID))
|
||||
}
|
||||
|
||||
pub fn re_early_bound(&self,
|
||||
space: subst::ParamSpace,
|
||||
index: uint,
|
||||
index: u32,
|
||||
name: &'static str)
|
||||
-> ty::Region
|
||||
{
|
||||
|
@ -309,44 +309,48 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
ty::ReEarlyBound(ast::DUMMY_NODE_ID, space, index, name)
|
||||
}
|
||||
|
||||
pub fn re_late_bound_with_debruijn(&self, id: uint, debruijn: ty::DebruijnIndex) -> ty::Region {
|
||||
pub fn re_late_bound_with_debruijn(&self, id: u32, debruijn: ty::DebruijnIndex) -> ty::Region {
|
||||
ty::ReLateBound(debruijn, ty::BrAnon(id))
|
||||
}
|
||||
|
||||
pub fn t_rptr(&self, r: ty::Region) -> Ty<'tcx> {
|
||||
ty::mk_imm_rptr(self.infcx.tcx, r, ty::mk_int())
|
||||
ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r), ty::mk_int())
|
||||
}
|
||||
|
||||
pub fn t_rptr_late_bound(&self, id: uint) -> Ty<'tcx> {
|
||||
pub fn t_rptr_late_bound(&self, id: u32) -> Ty<'tcx> {
|
||||
let r = self.re_late_bound_with_debruijn(id, ty::DebruijnIndex::new(1));
|
||||
ty::mk_imm_rptr(self.infcx.tcx,
|
||||
self.re_late_bound_with_debruijn(id, ty::DebruijnIndex::new(1)),
|
||||
self.infcx.tcx.mk_region(r),
|
||||
ty::mk_int())
|
||||
}
|
||||
|
||||
pub fn t_rptr_late_bound_with_debruijn(&self,
|
||||
id: uint,
|
||||
id: u32,
|
||||
debruijn: ty::DebruijnIndex)
|
||||
-> Ty<'tcx> {
|
||||
let r = self.re_late_bound_with_debruijn(id, debruijn);
|
||||
ty::mk_imm_rptr(self.infcx.tcx,
|
||||
self.re_late_bound_with_debruijn(id, debruijn),
|
||||
self.infcx.tcx.mk_region(r),
|
||||
ty::mk_int())
|
||||
}
|
||||
|
||||
pub fn t_rptr_scope(&self, id: ast::NodeId) -> Ty<'tcx> {
|
||||
ty::mk_imm_rptr(self.infcx.tcx, ty::ReScope(CodeExtent::from_node_id(id)), ty::mk_int())
|
||||
let r = ty::ReScope(CodeExtent::from_node_id(id));
|
||||
ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r), ty::mk_int())
|
||||
}
|
||||
|
||||
pub fn re_free(&self, nid: ast::NodeId, id: uint) -> ty::Region {
|
||||
pub fn re_free(&self, nid: ast::NodeId, id: u32) -> ty::Region {
|
||||
ty::ReFree(ty::FreeRegion { scope: CodeExtent::from_node_id(nid),
|
||||
bound_region: ty::BrAnon(id)})
|
||||
}
|
||||
|
||||
pub fn t_rptr_free(&self, nid: ast::NodeId, id: uint) -> Ty<'tcx> {
|
||||
ty::mk_imm_rptr(self.infcx.tcx, self.re_free(nid, id), ty::mk_int())
|
||||
pub fn t_rptr_free(&self, nid: ast::NodeId, id: u32) -> Ty<'tcx> {
|
||||
let r = self.re_free(nid, id);
|
||||
ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r), ty::mk_int())
|
||||
}
|
||||
|
||||
pub fn t_rptr_static(&self) -> Ty<'tcx> {
|
||||
ty::mk_imm_rptr(self.infcx.tcx, ty::ReStatic, ty::mk_int())
|
||||
ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(ty::ReStatic), ty::mk_int())
|
||||
}
|
||||
|
||||
pub fn dummy_type_trace(&self) -> infer::TypeTrace<'tcx> {
|
||||
|
@ -816,4 +820,3 @@ fn subst_region_renumber_region() {
|
|||
assert_eq!(t_substituted, t_expected);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -4254,7 +4254,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
|
||||
let def_like = DlDef(DefTyParam(space,
|
||||
local_def(type_parameter.id),
|
||||
index));
|
||||
index as u32));
|
||||
// Associate this type parameter with
|
||||
// the item that bound it
|
||||
self.record_def(type_parameter.id,
|
||||
|
|
|
@ -635,7 +635,7 @@ fn bind_subslice_pat(bcx: Block,
|
|||
let slice_len_offset = C_uint(bcx.ccx(), offset_left + offset_right);
|
||||
let slice_len = Sub(bcx, len, slice_len_offset);
|
||||
let slice_ty = ty::mk_slice(bcx.tcx(),
|
||||
ty::ReStatic,
|
||||
bcx.tcx().mk_region(ty::ReStatic),
|
||||
ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable});
|
||||
let scratch = rvalue_scratch_datum(bcx, slice_ty, "");
|
||||
Store(bcx, slice_begin,
|
||||
|
@ -808,7 +808,9 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
ty::ty_uint(ast::TyU8) => {
|
||||
// NOTE: cast &[u8] to &str and abuse the str_eq lang item,
|
||||
// which calls memcmp().
|
||||
let t = ty::mk_str_slice(cx.tcx(), ty::ReStatic, ast::MutImmutable);
|
||||
let t = ty::mk_str_slice(cx.tcx(),
|
||||
cx.tcx().mk_region(ty::ReStatic),
|
||||
ast::MutImmutable);
|
||||
let lhs = BitCast(cx, lhs, type_of::type_of(cx.ccx(), t).ptr_to());
|
||||
let rhs = BitCast(cx, rhs, type_of::type_of(cx.ccx(), t).ptr_to());
|
||||
compare_str(cx, lhs, rhs, rhs_t)
|
||||
|
|
|
@ -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);
|
||||
|
@ -361,7 +361,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
},
|
||||
|
||||
// Is this the NonZero lang item wrapping a pointer or integer type?
|
||||
ty::ty_struct(did, ref substs) if Some(did) == tcx.lang_items.non_zero() => {
|
||||
ty::ty_struct(did, substs) if Some(did) == tcx.lang_items.non_zero() => {
|
||||
let nonzero_fields = ty::lookup_struct_fields(tcx, did);
|
||||
assert_eq!(nonzero_fields.len(), 1);
|
||||
let nonzero_field = ty::lookup_field_type(tcx, did, nonzero_fields[0].id, substs);
|
||||
|
@ -376,7 +376,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
|
||||
// Perhaps one of the fields of this struct is non-zero
|
||||
// let's recurse and find out
|
||||
ty::ty_struct(def_id, ref substs) => {
|
||||
ty::ty_struct(def_id, substs) => {
|
||||
let fields = ty::lookup_struct_fields(tcx, def_id);
|
||||
for (j, field) in fields.iter().enumerate() {
|
||||
let field_ty = ty::lookup_field_type(tcx, def_id, field.id, substs);
|
||||
|
|
|
@ -264,10 +264,10 @@ pub fn self_type_for_unboxed_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let unboxed_closure = &(*unboxed_closures)[closure_id];
|
||||
match unboxed_closure.kind {
|
||||
ty::FnUnboxedClosureKind => {
|
||||
ty::mk_imm_rptr(ccx.tcx(), ty::ReStatic, fn_ty)
|
||||
ty::mk_imm_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty)
|
||||
}
|
||||
ty::FnMutUnboxedClosureKind => {
|
||||
ty::mk_mut_rptr(ccx.tcx(), ty::ReStatic, fn_ty)
|
||||
ty::mk_mut_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty)
|
||||
}
|
||||
ty::FnOnceUnboxedClosureKind => fn_ty
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -2125,14 +2125,20 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
|
|||
fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, id: ast::NodeId) {
|
||||
let mut sizes = Vec::new(); // does no allocation if no pushes, thankfully
|
||||
|
||||
let print_info = ccx.sess().print_enum_sizes();
|
||||
|
||||
let levels = ccx.tcx().node_lint_levels.borrow();
|
||||
let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCES);
|
||||
let lvlsrc = match levels.get(&(id, lint_id)) {
|
||||
None | Some(&(lint::Allow, _)) => return,
|
||||
Some(&lvlsrc) => lvlsrc,
|
||||
};
|
||||
let lvlsrc = levels.get(&(id, lint_id));
|
||||
let is_allow = lvlsrc.map_or(true, |&(lvl, _)| lvl == lint::Allow);
|
||||
|
||||
let avar = adt::represent_type(ccx, ty::node_id_to_type(ccx.tcx(), id));
|
||||
if is_allow && !print_info {
|
||||
// we're not interested in anything here
|
||||
return
|
||||
}
|
||||
|
||||
let ty = ty::node_id_to_type(ccx.tcx(), id);
|
||||
let avar = adt::represent_type(ccx, ty);
|
||||
match *avar {
|
||||
adt::General(_, ref variants, _) => {
|
||||
for var in variants.iter() {
|
||||
|
@ -2158,13 +2164,29 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span,
|
|||
}
|
||||
);
|
||||
|
||||
if print_info {
|
||||
let llty = type_of::sizing_type_of(ccx, ty);
|
||||
|
||||
let sess = &ccx.tcx().sess;
|
||||
sess.span_note(sp, &*format!("total size: {} bytes", llsize_of_real(ccx, llty)));
|
||||
match *avar {
|
||||
adt::General(..) => {
|
||||
for (i, var) in enum_def.variants.iter().enumerate() {
|
||||
ccx.tcx().sess.span_note(var.span,
|
||||
&*format!("variant data: {} bytes", sizes[i]));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// we only warn if the largest variant is at least thrice as large as
|
||||
// the second-largest.
|
||||
if largest > slargest * 3 && slargest > 0 {
|
||||
if !is_allow && largest > slargest * 3 && slargest > 0 {
|
||||
// Use lint::raw_emit_lint rather than sess.add_lint because the lint-printing
|
||||
// pass for the latter already ran.
|
||||
lint::raw_emit_lint(&ccx.tcx().sess, lint::builtin::VARIANT_SIZE_DIFFERENCES,
|
||||
lvlsrc, Some(sp),
|
||||
*lvlsrc.unwrap(), Some(sp),
|
||||
format!("enum variant is more than three times larger \
|
||||
({} bytes) than the next largest (ignoring padding)",
|
||||
largest)[]);
|
||||
|
@ -2332,8 +2354,12 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
|||
ast::ItemMod(ref m) => {
|
||||
trans_mod(&ccx.rotate(), m);
|
||||
}
|
||||
ast::ItemEnum(ref enum_definition, _) => {
|
||||
enum_variant_size_lint(ccx, enum_definition, item.span, item.id);
|
||||
ast::ItemEnum(ref enum_definition, ref gens) => {
|
||||
if gens.ty_params.is_empty() {
|
||||
// sizes only make sense for non-generic types
|
||||
|
||||
enum_variant_size_lint(ccx, enum_definition, item.span, item.id);
|
||||
}
|
||||
}
|
||||
ast::ItemConst(_, ref expr) => {
|
||||
// Recurse on the expression to catch items in blocks
|
||||
|
@ -2440,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;
|
||||
|
@ -2573,14 +2599,14 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
|
|||
attrs.arg(idx, llvm::ReadOnlyAttribute);
|
||||
}
|
||||
|
||||
if let ReLateBound(_, BrAnon(_)) = b {
|
||||
if let ReLateBound(_, BrAnon(_)) = *b {
|
||||
attrs.arg(idx, llvm::NoCaptureAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
// When a reference in an argument has no named lifetime, it's impossible for that
|
||||
// reference to escape this function (returned or stored beyond the call by a closure).
|
||||
ty::ty_rptr(ReLateBound(_, BrAnon(_)), mt) => {
|
||||
ty::ty_rptr(&ReLateBound(_, BrAnon(_)), mt) => {
|
||||
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
|
||||
attrs.arg(idx, llvm::NoCaptureAttribute)
|
||||
.arg(idx, llvm::DereferenceableAttribute(llsz));
|
||||
|
|
|
@ -272,14 +272,14 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
bare_fn_ty.repr(tcx));
|
||||
|
||||
// This is an impl of `Fn` trait, so receiver is `&self`.
|
||||
let bare_fn_ty_ref = ty::mk_imm_rptr(tcx, ty::ReStatic, bare_fn_ty);
|
||||
let bare_fn_ty_ref = ty::mk_imm_rptr(tcx, tcx.mk_region(ty::ReStatic), bare_fn_ty);
|
||||
|
||||
// Construct the "tuply" version of `bare_fn_ty`. It takes two arguments: `self`,
|
||||
// which is the fn pointer, and `args`, which is the arguments tuple.
|
||||
let (opt_def_id, input_tys, output_ty) =
|
||||
match bare_fn_ty.sty {
|
||||
ty::ty_bare_fn(opt_def_id,
|
||||
ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
&ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::Rust,
|
||||
sig: ty::Binder(ty::FnSig { inputs: ref input_tys,
|
||||
output: output_ty,
|
||||
|
@ -296,14 +296,15 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
let tuple_input_ty = ty::mk_tup(tcx, input_tys.to_vec());
|
||||
let tuple_fn_ty = ty::mk_bare_fn(tcx,
|
||||
opt_def_id,
|
||||
ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_ref,
|
||||
tuple_input_ty],
|
||||
output: output_ty,
|
||||
variadic: false
|
||||
})});
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_ref,
|
||||
tuple_input_ty],
|
||||
output: output_ty,
|
||||
variadic: false
|
||||
})}));
|
||||
debug!("tuple_fn_ty: {}", tuple_fn_ty.repr(tcx));
|
||||
|
||||
//
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
@ -430,7 +430,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
trait_data.principal.substs(),
|
||||
&mut unique_type_id);
|
||||
},
|
||||
ty::ty_bare_fn(_, ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
unique_type_id.push_str("unsafe ");
|
||||
}
|
||||
|
@ -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);
|
||||
},
|
||||
|
@ -3819,7 +3819,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
push_item_name(cx, trait_data.principal.def_id(), false, output);
|
||||
push_type_params(cx, trait_data.principal.substs(), output);
|
||||
},
|
||||
ty::ty_bare_fn(_, ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
output.push_str("unsafe ");
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -350,7 +350,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
expr.id,
|
||||
datum_ty,
|
||||
|t| ty::mk_rptr(tcx,
|
||||
ty::ReStatic,
|
||||
tcx.mk_region(ty::ReStatic),
|
||||
ty::mt{
|
||||
ty: t,
|
||||
mutbl: ast::MutImmutable
|
||||
|
@ -1085,7 +1085,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
None,
|
||||
expr.span,
|
||||
expr.id,
|
||||
ty::mk_struct(tcx, did, substs),
|
||||
ty::mk_struct(tcx, did, tcx.mk_substs(substs)),
|
||||
dest)
|
||||
} else {
|
||||
tcx.sess.span_bug(expr.span,
|
||||
|
@ -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 => {
|
||||
|
@ -2130,7 +2130,7 @@ fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// Compute final type. Note that we are loose with the region and
|
||||
// mutability, since those things don't matter in trans.
|
||||
let referent_ty = lv_datum.ty;
|
||||
let ptr_ty = ty::mk_imm_rptr(bcx.tcx(), ty::ReStatic, referent_ty);
|
||||
let ptr_ty = ty::mk_imm_rptr(bcx.tcx(), bcx.tcx().mk_region(ty::ReStatic), referent_ty);
|
||||
|
||||
// Get the pointer.
|
||||
let llref = lv_datum.to_llref();
|
||||
|
|
|
@ -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);
|
||||
|
@ -639,7 +639,7 @@ fn emit_vtable_methods<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
m.repr(tcx),
|
||||
substs.repr(tcx));
|
||||
if m.generics.has_type_params(subst::FnSpace) ||
|
||||
ty::type_has_self(ty::mk_bare_fn(tcx, None, m.fty.clone()))
|
||||
ty::type_has_self(ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(m.fty.clone())))
|
||||
{
|
||||
debug!("(making impl vtable) method has self or type \
|
||||
params: {}",
|
||||
|
|
|
@ -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>(
|
||||
|
@ -940,7 +940,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
|
|||
let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
|
||||
debug!("ty_rptr r={}", r.repr(this.tcx()));
|
||||
let t = ast_ty_to_ty(this, rscope, &*mt.ty);
|
||||
ty::mk_rptr(tcx, r, ty::mt {ty: t, mutbl: mt.mutbl})
|
||||
ty::mk_rptr(tcx, tcx.mk_region(r), ty::mt {ty: t, mutbl: mt.mutbl})
|
||||
}
|
||||
ast::TyTup(ref fields) => {
|
||||
let flds = fields.iter()
|
||||
|
@ -954,7 +954,8 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
|
|||
tcx.sess.span_err(ast_ty.span,
|
||||
"variadic function must have C calling convention");
|
||||
}
|
||||
ty::mk_bare_fn(tcx, None, ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl))
|
||||
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
|
||||
ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(bare_fn))
|
||||
}
|
||||
ast::TyClosure(ref f) => {
|
||||
// Use corresponding trait store to figure out default bounds
|
||||
|
@ -1217,7 +1218,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx, AC: AstConv<'tcx>>(
|
|||
}
|
||||
ty::ByReferenceExplicitSelfCategory(region, mutability) => {
|
||||
(Some(ty::mk_rptr(this.tcx(),
|
||||
region,
|
||||
this.tcx().mk_region(region),
|
||||
ty::mt {
|
||||
ty: self_info.untransformed_self_ty,
|
||||
mutbl: mutability
|
||||
|
@ -1350,7 +1351,7 @@ fn determine_explicit_self_category<'a, 'tcx, AC: AstConv<'tcx>,
|
|||
ty::ByValueExplicitSelfCategory
|
||||
} else {
|
||||
match explicit_type.sty {
|
||||
ty::ty_rptr(r, mt) => ty::ByReferenceExplicitSelfCategory(r, mt.mutbl),
|
||||
ty::ty_rptr(r, mt) => ty::ByReferenceExplicitSelfCategory(*r, mt.mutbl),
|
||||
ty::ty_uniq(_) => ty::ByBoxExplicitSelfCategory,
|
||||
_ => ty::ByValueExplicitSelfCategory,
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
// and T is the expected type
|
||||
let region_var = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
|
||||
let mt = ty::mt { ty: expected, mutbl: mutbl };
|
||||
let region_ty = ty::mk_rptr(tcx, region_var, mt);
|
||||
let region_ty = ty::mk_rptr(tcx, tcx.mk_region(region_var), mt);
|
||||
demand::eqtype(fcx, pat.span, region_ty, typ);
|
||||
}
|
||||
// otherwise the type of x is the expected type T
|
||||
|
@ -154,7 +154,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
|
||||
let mt = ty::mt { ty: inner_ty, mutbl: mutbl };
|
||||
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
|
||||
let rptr_ty = ty::mk_rptr(tcx, region, mt);
|
||||
let rptr_ty = ty::mk_rptr(tcx, tcx.mk_region(region), mt);
|
||||
|
||||
if check_dereferencable(pcx, pat.span, expected, &**inner) {
|
||||
demand::suptype(fcx, pat.span, expected, rptr_ty);
|
||||
|
@ -178,7 +178,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
})),
|
||||
_ => {
|
||||
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
|
||||
ty::mk_slice(tcx, region, ty::mt {
|
||||
ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
|
||||
ty: inner_ty,
|
||||
mutbl: ty::deref(expected_ty, true)
|
||||
.map_or(ast::MutImmutable, |mt| mt.mutbl)
|
||||
|
@ -197,7 +197,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let mutbl = ty::deref(expected_ty, true)
|
||||
.map_or(ast::MutImmutable, |mt| mt.mutbl);
|
||||
|
||||
let slice_ty = ty::mk_slice(tcx, region, ty::mt {
|
||||
let slice_ty = ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
|
||||
ty: inner_ty,
|
||||
mutbl: mutbl
|
||||
});
|
||||
|
@ -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")
|
||||
|
|
|
@ -126,8 +126,9 @@ 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_region(region),
|
||||
fcx.ccx.tcx.mk_substs(
|
||||
fcx.inh.param_env.free_substs.clone()));
|
||||
|
||||
fcx.write_ty(expr.id, closure_type);
|
||||
|
||||
|
|
|
@ -113,11 +113,11 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
self.add_obligations(&pick, &method_bounds_substs, &method_bounds);
|
||||
|
||||
// Create the final `MethodCallee`.
|
||||
let fty = ty::mk_bare_fn(self.tcx(), None, ty::BareFnTy {
|
||||
let fty = ty::mk_bare_fn(self.tcx(), None, self.tcx().mk_bare_fn(ty::BareFnTy {
|
||||
sig: ty::Binder(method_sig),
|
||||
unsafety: pick.method_ty.fty.unsafety,
|
||||
abi: pick.method_ty.fty.abi.clone(),
|
||||
});
|
||||
}));
|
||||
let callee = MethodCallee {
|
||||
origin: method_origin,
|
||||
ty: fty,
|
||||
|
@ -223,7 +223,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
// been ruled out when we deemed the trait to be
|
||||
// "object safe".
|
||||
let original_poly_trait_ref =
|
||||
data.principal_trait_ref_with_self_ty(object_ty);
|
||||
data.principal_trait_ref_with_self_ty(this.tcx(), object_ty);
|
||||
let upcast_poly_trait_ref =
|
||||
this.upcast(original_poly_trait_ref.clone(), trait_def_id);
|
||||
let upcast_trait_ref =
|
||||
|
@ -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,16 +194,16 @@ 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;
|
||||
let transformed_self_ty = fn_sig.inputs[0];
|
||||
let fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy {
|
||||
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
sig: ty::Binder(fn_sig),
|
||||
unsafety: bare_fn_ty.unsafety,
|
||||
abi: bare_fn_ty.abi.clone(),
|
||||
});
|
||||
}));
|
||||
|
||||
debug!("lookup_in_trait_adjusted: matched method fty={} obligation={}",
|
||||
fty.repr(fcx.tcx()),
|
||||
|
@ -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),
|
||||
|
@ -260,7 +260,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
|||
span,
|
||||
ty::AdjustDerefRef(ty::AutoDerefRef {
|
||||
autoderefs: autoderefs,
|
||||
autoref: Some(ty::AutoPtr(region, mutbl, autoref))
|
||||
autoref: Some(ty::AutoPtr(*region, mutbl, autoref))
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||
// a substitution that replaces `Self` with the object type
|
||||
// itself. Hence, a `&self` method will wind up with an
|
||||
// argument type like `&Trait`.
|
||||
let trait_ref = data.principal_trait_ref_with_self_ty(self_ty);
|
||||
let trait_ref = data.principal_trait_ref_with_self_ty(self.tcx(), self_ty);
|
||||
self.elaborate_bounds(&[trait_ref.clone()], false, |this, new_trait_ref, m, method_num| {
|
||||
let vtable_index =
|
||||
get_method_index(tcx, &*new_trait_ref, trait_ref.clone(), method_num);
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -657,7 +657,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||
let tcx = self.tcx();
|
||||
self.search_mutabilities(
|
||||
|m| AutoRef(m, box step.adjustment.clone()),
|
||||
|m,r| ty::mk_rptr(tcx, r, ty::mt {ty:step.self_ty, mutbl:m}))
|
||||
|m,r| ty::mk_rptr(tcx, tcx.mk_region(r), ty::mt {ty:step.self_ty, mutbl:m}))
|
||||
}
|
||||
|
||||
fn search_mutabilities<F, G>(&mut self,
|
||||
|
|
|
@ -1154,9 +1154,9 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
}
|
||||
|
||||
// Compute skolemized form of impl and trait method tys.
|
||||
let impl_fty = ty::mk_bare_fn(tcx, None, impl_m.fty.clone());
|
||||
let impl_fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(impl_m.fty.clone()));
|
||||
let impl_fty = impl_fty.subst(tcx, &impl_to_skol_substs);
|
||||
let trait_fty = ty::mk_bare_fn(tcx, None, trait_m.fty.clone());
|
||||
let trait_fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(trait_m.fty.clone()));
|
||||
let trait_fty = trait_fty.subst(tcx, &trait_to_skol_substs);
|
||||
|
||||
// Check the impl method type IM is a subtype of the trait method
|
||||
|
@ -2736,9 +2736,10 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let tcx = fcx.ccx.tcx;
|
||||
|
||||
match lit.node {
|
||||
ast::LitStr(..) => ty::mk_str_slice(tcx, ty::ReStatic, ast::MutImmutable),
|
||||
ast::LitStr(..) => ty::mk_str_slice(tcx, tcx.mk_region(ty::ReStatic), ast::MutImmutable),
|
||||
ast::LitBinary(..) => {
|
||||
ty::mk_slice(tcx, ty::ReStatic, ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable })
|
||||
ty::mk_slice(tcx, tcx.mk_region(ty::ReStatic),
|
||||
ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable })
|
||||
}
|
||||
ast::LitByte(_) => ty::mk_u8(),
|
||||
ast::LitChar(_) => ty::mk_char(),
|
||||
|
@ -2949,7 +2950,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
});
|
||||
|
||||
let fn_sig = match fn_ty.sty {
|
||||
ty::ty_bare_fn(_, ty::BareFnTy {ref sig, ..}) |
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy {ref sig, ..}) |
|
||||
ty::ty_closure(box ty::ClosureTy {ref sig, ..}) => sig,
|
||||
_ => {
|
||||
fcx.type_error_message(call_expr.span, |actual| {
|
||||
|
@ -3098,8 +3099,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let (adj_ty, adjustment) = match lhs_ty.sty {
|
||||
ty::ty_rptr(r_in, mt) => {
|
||||
let r_adj = fcx.infcx().next_region_var(infer::Autoref(lhs.span));
|
||||
fcx.mk_subr(infer::Reborrow(lhs.span), r_adj, r_in);
|
||||
let adjusted_ty = ty::mk_rptr(fcx.tcx(), r_adj, mt);
|
||||
fcx.mk_subr(infer::Reborrow(lhs.span), r_adj, *r_in);
|
||||
let adjusted_ty = ty::mk_rptr(fcx.tcx(), fcx.tcx().mk_region(r_adj), mt);
|
||||
let autoptr = ty::AutoPtr(r_adj, mt.mutbl, None);
|
||||
let adjustment = ty::AutoDerefRef { autoderefs: 1, autoref: Some(autoptr) };
|
||||
(adjusted_ty, adjustment)
|
||||
|
@ -3331,7 +3332,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 +3393,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 +3444,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 +3496,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 +3562,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 +3605,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 +3738,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 ==
|
||||
|
@ -3839,11 +3840,11 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// `'static`!
|
||||
let region = fcx.infcx().next_region_var(
|
||||
infer::AddrOfSlice(expr.span));
|
||||
ty::mk_rptr(tcx, region, tm)
|
||||
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
|
||||
}
|
||||
_ => {
|
||||
let region = fcx.infcx().next_region_var(infer::AddrOfRegion(expr.span));
|
||||
ty::mk_rptr(tcx, region, tm)
|
||||
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -4354,7 +4355,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
traits::ItemObligation(did)),
|
||||
&bounds);
|
||||
|
||||
ty::mk_struct(tcx, did, substs)
|
||||
ty::mk_struct(tcx, did, tcx.mk_substs(substs))
|
||||
} else {
|
||||
ty::mk_err()
|
||||
}
|
||||
|
@ -4749,7 +4750,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");
|
||||
|
@ -5502,7 +5503,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
match t.sty {
|
||||
ty::ty_param(ParamTy {idx, ..}) => {
|
||||
debug!("Found use of ty param num {}", idx);
|
||||
tps_used[idx] = true;
|
||||
tps_used[idx as uint] = true;
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
|
@ -5518,7 +5519,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
||||
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: uint) -> Ty<'tcx> {
|
||||
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
|
||||
ty::mk_param(ccx.tcx, subst::FnSpace, n, local_def(0))
|
||||
}
|
||||
|
||||
|
@ -5561,16 +5562,18 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
"breakpoint" => (0, Vec::new(), ty::mk_nil(tcx)),
|
||||
"size_of" |
|
||||
"pref_align_of" | "min_align_of" => (1u, Vec::new(), ty::mk_uint()),
|
||||
"init" => (1u, Vec::new(), param(ccx, 0u)),
|
||||
"uninit" => (1u, Vec::new(), param(ccx, 0u)),
|
||||
"init" => (1u, Vec::new(), param(ccx, 0)),
|
||||
"uninit" => (1u, Vec::new(), param(ccx, 0)),
|
||||
"forget" => (1u, vec!( param(ccx, 0) ), ty::mk_nil(tcx)),
|
||||
"transmute" => (2, vec!( param(ccx, 0) ), param(ccx, 1)),
|
||||
"move_val_init" => {
|
||||
(1u,
|
||||
vec!(
|
||||
ty::mk_mut_rptr(tcx, ty::ReLateBound(ty::DebruijnIndex::new(1), ty::BrAnon(0)),
|
||||
ty::mk_mut_rptr(tcx,
|
||||
tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
ty::BrAnon(0))),
|
||||
param(ccx, 0)),
|
||||
param(ccx, 0u)
|
||||
param(ccx, 0)
|
||||
),
|
||||
ty::mk_nil(tcx))
|
||||
}
|
||||
|
@ -5594,7 +5597,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[]);
|
||||
}
|
||||
|
@ -5769,7 +5772,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
};
|
||||
(n_tps, inputs, ty::FnConverging(output))
|
||||
};
|
||||
let fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy {
|
||||
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
abi: abi::RustIntrinsic,
|
||||
sig: ty::Binder(FnSig {
|
||||
|
@ -5777,7 +5780,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
output: output,
|
||||
variadic: false,
|
||||
}),
|
||||
});
|
||||
}));
|
||||
let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id));
|
||||
let i_n_tps = i_ty.generics.types.len(subst::FnSpace);
|
||||
if i_n_tps != n_tps {
|
||||
|
@ -5798,4 +5801,3 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -645,7 +645,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
|
|||
};
|
||||
if let ty::ty_rptr(r_ptr, _) = base_ty.sty {
|
||||
mk_subregion_due_to_dereference(
|
||||
rcx, expr.span, ty::ReScope(CodeExtent::from_node_id(expr.id)), r_ptr);
|
||||
rcx, expr.span, ty::ReScope(CodeExtent::from_node_id(expr.id)), *r_ptr);
|
||||
}
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
|
@ -763,7 +763,7 @@ fn constrain_cast(rcx: &mut Rcx,
|
|||
/*From:*/ (&ty::ty_rptr(from_r, ref from_mt),
|
||||
/*To: */ &ty::ty_rptr(to_r, ref to_mt)) => {
|
||||
// Target cannot outlive source, naturally.
|
||||
rcx.fcx.mk_subr(infer::Reborrow(cast_expr.span), to_r, from_r);
|
||||
rcx.fcx.mk_subr(infer::Reborrow(cast_expr.span), *to_r, *from_r);
|
||||
walk_cast(rcx, cast_expr, from_mt.ty, to_mt.ty);
|
||||
}
|
||||
|
||||
|
@ -822,7 +822,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
|
|||
// Variables being referenced must be constrained and registered
|
||||
// in the upvar borrow map
|
||||
constrain_free_variables_in_by_ref_closure(
|
||||
rcx, region, expr, freevars);
|
||||
rcx, *region, expr, freevars);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -858,7 +858,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
|
|||
}
|
||||
ty::ty_unboxed_closure(_, region, _) => {
|
||||
ty::with_freevars(tcx, expr.id, |freevars| {
|
||||
let bounds = ty::region_existential_bound(region);
|
||||
let bounds = ty::region_existential_bound(*region);
|
||||
ensure_free_variable_types_outlive_closure_bound(rcx, bounds, expr, freevars);
|
||||
})
|
||||
}
|
||||
|
@ -897,7 +897,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
|
|||
let var_ty = match rcx.fcx.inh.upvar_borrow_map.borrow().get(&upvar_id) {
|
||||
Some(upvar_borrow) => {
|
||||
ty::mk_rptr(rcx.tcx(),
|
||||
upvar_borrow.region,
|
||||
rcx.tcx().mk_region(upvar_borrow.region),
|
||||
ty::mt { mutbl: upvar_borrow.kind.to_mutbl_lossy(),
|
||||
ty: raw_var_ty })
|
||||
}
|
||||
|
@ -1137,7 +1137,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
|
|||
{
|
||||
let mc = mc::MemCategorizationContext::new(rcx.fcx);
|
||||
let self_cmt = mc.cat_expr_autoderefd(deref_expr, i);
|
||||
link_region(rcx, deref_expr.span, r,
|
||||
link_region(rcx, deref_expr.span, *r,
|
||||
ty::BorrowKind::from_mutbl(m), self_cmt);
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
|
|||
|
||||
if let ty::ty_rptr(r_ptr, _) = derefd_ty.sty {
|
||||
mk_subregion_due_to_dereference(rcx, deref_expr.span,
|
||||
r_deref_expr, r_ptr);
|
||||
r_deref_expr, *r_ptr);
|
||||
}
|
||||
|
||||
match ty::deref(derefd_ty, true) {
|
||||
|
@ -1193,7 +1193,7 @@ fn constrain_index<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
|
|||
match mt.ty.sty {
|
||||
ty::ty_vec(_, None) | ty::ty_str => {
|
||||
rcx.fcx.mk_subr(infer::IndexSlice(index_expr.span),
|
||||
r_index_expr, r_ptr);
|
||||
r_index_expr, *r_ptr);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
|
|||
// captured by reference it must also outlive the
|
||||
// region bound on the closure, but this is explicitly
|
||||
// handled by logic in regionck.
|
||||
self.push_region_constraint_from_top(region);
|
||||
self.push_region_constraint_from_top(*region);
|
||||
}
|
||||
|
||||
ty::ty_trait(ref t) => {
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
|
|||
}
|
||||
|
||||
ty::ty_rptr(r_b, mt) => {
|
||||
self.accumulate_from_rptr(ty, r_b, mt.ty);
|
||||
self.accumulate_from_rptr(ty, *r_b, mt.ty);
|
||||
}
|
||||
|
||||
ty::ty_param(p) => {
|
||||
|
|
|
@ -63,8 +63,8 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// Ensure that if &'a T is cast to &'b Trait, then 'b <= 'a
|
||||
infer::mk_subr(fcx.infcx(),
|
||||
infer::RelateObjectBound(source_expr.span),
|
||||
target_region,
|
||||
referent_region);
|
||||
*target_region,
|
||||
*referent_region);
|
||||
|
||||
check_object_safety(fcx.tcx(), object_trait, source_expr.span);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ pub fn check_object_safety<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
object_trait: &ty::TyTrait<'tcx>,
|
||||
span: Span)
|
||||
{
|
||||
let object_trait_ref = object_trait.principal_trait_ref_with_self_ty(ty::mk_err());
|
||||
let object_trait_ref = object_trait.principal_trait_ref_with_self_ty(tcx, ty::mk_err());
|
||||
for tr in traits::supertraits(tcx, object_trait_ref) {
|
||||
check_object_safety_inner(tcx, &*tr, span);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ pub fn register_object_cast_obligations<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
|
||||
// Create the obligation for casting from T to Trait.
|
||||
let object_trait_ref =
|
||||
object_trait.principal_trait_ref_with_self_ty(referent_ty);
|
||||
object_trait.principal_trait_ref_with_self_ty(fcx.tcx(), referent_ty);
|
||||
let object_obligation =
|
||||
Obligation::new(
|
||||
ObligationCause::new(span,
|
||||
|
|
|
@ -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 {
|
||||
|
@ -355,7 +355,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
|
|||
|
||||
self.fold_substs(substs);
|
||||
}
|
||||
ty::ty_bare_fn(_, ty::BareFnTy{sig: ref fn_sig, ..}) |
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{sig: ref fn_sig, ..}) |
|
||||
ty::ty_closure(box ty::ClosureTy{sig: ref fn_sig, ..}) => {
|
||||
self.binding_count += 1;
|
||||
|
||||
|
|
|
@ -235,7 +235,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
|||
// impl, plus its own.
|
||||
let new_polytype = ty::Polytype {
|
||||
generics: new_method_ty.generics.clone(),
|
||||
ty: ty::mk_bare_fn(tcx, Some(new_did), new_method_ty.fty.clone())
|
||||
ty: ty::mk_bare_fn(tcx, Some(new_did),
|
||||
tcx.mk_bare_fn(new_method_ty.fty.clone()))
|
||||
};
|
||||
debug!("new_polytype={}", new_polytype.repr(tcx));
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
m.def_id,
|
||||
Polytype {
|
||||
generics: m.generics.clone(),
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(m.def_id), m.fty.clone()) });
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(m.def_id), ccx.tcx.mk_bare_fn(m.fty.clone())) });
|
||||
}
|
||||
|
||||
fn ty_method_of_trait_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
@ -529,7 +529,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
untransformed_rcvr_ty,
|
||||
rcvr_ty_generics,
|
||||
rcvr_visibility));
|
||||
let fty = ty::mk_bare_fn(tcx, Some(m_def_id), mty.fty.clone());
|
||||
let fty = ty::mk_bare_fn(tcx, Some(m_def_id), tcx.mk_bare_fn(mty.fty.clone()));
|
||||
debug!("method {} (id {}) has type {}",
|
||||
m.pe_ident().repr(tcx),
|
||||
m.id,
|
||||
|
@ -651,7 +651,7 @@ fn is_associated_type_valid_for_param(ty: Ty,
|
|||
generics: &ty::Generics)
|
||||
-> bool {
|
||||
if let ty::ty_param(param_ty) = ty.sty {
|
||||
let type_parameter = generics.types.get(param_ty.space, param_ty.idx);
|
||||
let type_parameter = generics.types.get(param_ty.space, param_ty.idx as uint);
|
||||
for trait_bound in type_parameter.bounds.trait_bounds.iter() {
|
||||
if trait_bound.def_id() == trait_id {
|
||||
return true
|
||||
|
@ -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());
|
||||
|
@ -1397,7 +1397,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
.enumerate()
|
||||
.map(|(i, def)| ty::ReEarlyBound(def.lifetime.id,
|
||||
subst::TypeSpace,
|
||||
i,
|
||||
i as u32,
|
||||
def.lifetime.name))
|
||||
.collect();
|
||||
|
||||
|
@ -1407,7 +1407,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, def)| ty::mk_param(ccx.tcx, subst::TypeSpace,
|
||||
i, local_def(def.id)))
|
||||
i as u32, local_def(def.id)))
|
||||
.collect();
|
||||
|
||||
// ...and also create generics synthesized from the associated types.
|
||||
|
@ -1465,7 +1465,7 @@ pub fn ty_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
|
|||
};
|
||||
let pty = Polytype {
|
||||
generics: ty_generics,
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(local_def(it.id)), tofd)
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(local_def(it.id)), ccx.tcx.mk_bare_fn(tofd))
|
||||
};
|
||||
debug!("type of {} (id {}) is {}",
|
||||
token::get_ident(it.ident),
|
||||
|
@ -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>
|
||||
|
@ -1621,7 +1621,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
ccx,
|
||||
subst::AssocSpace,
|
||||
&associated_type.ty_param,
|
||||
generics.types.len(subst::AssocSpace),
|
||||
generics.types.len(subst::AssocSpace) as u32,
|
||||
Some(local_def(trait_id)));
|
||||
ccx.tcx.ty_param_defs.borrow_mut().insert(associated_type.ty_param.id,
|
||||
def.clone());
|
||||
|
@ -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,
|
||||
|
@ -1746,7 +1746,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
.collect();
|
||||
let def = ty::RegionParameterDef { name: l.lifetime.name,
|
||||
space: space,
|
||||
index: i,
|
||||
index: i as u32,
|
||||
def_id: local_def(l.lifetime.id),
|
||||
bounds: bounds };
|
||||
debug!("ty_generics: def for region param: {}", def);
|
||||
|
@ -1775,7 +1775,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
let def = get_or_create_type_parameter_def(&gcx,
|
||||
space,
|
||||
param,
|
||||
i,
|
||||
i as u32,
|
||||
None);
|
||||
debug!("ty_generics: def for type param: {}, {}",
|
||||
def.repr(this.tcx()),
|
||||
|
@ -1788,7 +1788,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
.get_slice(space)
|
||||
.iter() {
|
||||
assert!(result.types.get_slice(space).len() ==
|
||||
associated_type_param.index);
|
||||
associated_type_param.index as uint);
|
||||
debug!("ty_generics: def for associated type: {}, {}",
|
||||
associated_type_param.repr(this.tcx()),
|
||||
space);
|
||||
|
@ -1915,7 +1915,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
name: associated_type_def.name,
|
||||
def_id: associated_type_def.def_id,
|
||||
space: space,
|
||||
index: types.len() + index,
|
||||
index: types.len() as u32 + index,
|
||||
bounds: ty::ParamBounds {
|
||||
builtin_bounds: associated_type_def.bounds.builtin_bounds,
|
||||
|
||||
|
@ -1963,7 +1963,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
|
||||
space: subst::ParamSpace,
|
||||
param: &ast::TyParam,
|
||||
index: uint,
|
||||
index: u32,
|
||||
associated_with: Option<ast::DefId>)
|
||||
-> ty::TypeParameterDef<'tcx>
|
||||
where AC: AstConv<'tcx>
|
||||
|
@ -2143,13 +2143,13 @@ pub fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
let t_fn = ty::mk_bare_fn(
|
||||
ccx.tcx,
|
||||
None,
|
||||
ty::BareFnTy {
|
||||
ccx.tcx.mk_bare_fn(ty::BareFnTy {
|
||||
abi: abi,
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
sig: ty::Binder(ty::FnSig {inputs: input_tys,
|
||||
output: output,
|
||||
variadic: decl.variadic}),
|
||||
});
|
||||
output: output,
|
||||
variadic: decl.variadic})
|
||||
}));
|
||||
let pty = Polytype {
|
||||
generics: ty_generics_for_fn_or_method,
|
||||
ty: t_fn
|
||||
|
|
|
@ -225,7 +225,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
|||
}
|
||||
_ => ()
|
||||
}
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(main_id)), ty::BareFnTy {
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(main_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
@ -233,7 +233,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
|||
output: ty::FnConverging(ty::mk_nil(tcx)),
|
||||
variadic: false
|
||||
})
|
||||
});
|
||||
}));
|
||||
|
||||
require_same_types(tcx, None, false, main_span, main_t, se_ty,
|
||||
|| {
|
||||
|
@ -273,7 +273,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
_ => ()
|
||||
}
|
||||
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(start_id)), ty::BareFnTy {
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(start_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
@ -284,7 +284,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
output: ty::FnConverging(ty::mk_int()),
|
||||
variadic: false
|
||||
}),
|
||||
});
|
||||
}));
|
||||
|
||||
require_same_types(tcx, None, false, start_span, start_t, se_ty,
|
||||
|| {
|
||||
|
|
|
@ -106,7 +106,7 @@ impl RegionScope for SpecificRscope {
|
|||
/// A scope in which we generate anonymous, late-bound regions for
|
||||
/// omitted regions. This occurs in function signatures.
|
||||
pub struct BindingRscope {
|
||||
anon_bindings: Cell<uint>,
|
||||
anon_bindings: Cell<u32>,
|
||||
}
|
||||
|
||||
impl BindingRscope {
|
||||
|
|
|
@ -732,7 +732,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
|
||||
ty::ty_rptr(region, ref mt) => {
|
||||
let contra = self.contravariant(variance);
|
||||
self.add_constraints_from_region(region, contra);
|
||||
self.add_constraints_from_region(*region, contra);
|
||||
self.add_constraints_from_mt(mt, variance);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -814,7 +814,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::ty_bare_fn(_, ty::BareFnTy { ref sig, .. }) |
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy { ref sig, .. }) |
|
||||
ty::ty_closure(box ty::ClosureTy {
|
||||
ref sig,
|
||||
store: ty::UniqTraitStore,
|
||||
|
@ -854,18 +854,18 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
for p in type_param_defs.iter() {
|
||||
let variance_decl =
|
||||
self.declared_variance(p.def_id, def_id, TypeParam,
|
||||
p.space, p.index);
|
||||
p.space, p.index as uint);
|
||||
let variance_i = self.xform(variance, variance_decl);
|
||||
let substs_ty = *substs.types.get(p.space, p.index);
|
||||
let substs_ty = *substs.types.get(p.space, p.index as uint);
|
||||
self.add_constraints_from_ty(substs_ty, variance_i);
|
||||
}
|
||||
|
||||
for p in region_param_defs.iter() {
|
||||
let variance_decl =
|
||||
self.declared_variance(p.def_id, def_id,
|
||||
RegionParam, p.space, p.index);
|
||||
RegionParam, p.space, p.index as uint);
|
||||
let variance_i = self.xform(variance, variance_decl);
|
||||
let substs_r = *substs.regions().get(p.space, p.index);
|
||||
let substs_r = *substs.regions().get(p.space, p.index as uint);
|
||||
self.add_constraints_from_region(substs_r, variance_i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -620,7 +620,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
|||
let fqn = fqn.into_iter().map(|i| i.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
let path = external_path(cx, fqn.last().unwrap().as_slice(),
|
||||
Some(self.def_id), &self.substs);
|
||||
Some(self.def_id), self.substs);
|
||||
cx.external_paths.borrow_mut().as_mut().unwrap().insert(self.def_id,
|
||||
(fqn, TypeTrait));
|
||||
|
||||
|
@ -634,7 +634,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
|
|||
if let sty::ty_tup(ref ts) = ty_s.sty {
|
||||
for &ty_s in ts.iter() {
|
||||
if let sty::ty_rptr(ref reg, _) = ty_s.sty {
|
||||
if let &Region::ReLateBound(_, _) = reg {
|
||||
if let &Region::ReLateBound(_, _) = *reg {
|
||||
debug!(" hit an ReLateBound {}", reg);
|
||||
if let Some(lt) = reg.clean(cx) {
|
||||
late_bounds.push(lt)
|
||||
|
@ -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);
|
||||
|
|
|
@ -19,7 +19,6 @@ use syntax::{ast, ast_map, codemap, diagnostic};
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use arena::TypedArena;
|
||||
|
||||
use visit_ast::RustdocVisitor;
|
||||
use clean;
|
||||
|
@ -121,10 +120,10 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
|
|||
let mut forest = ast_map::Forest::new(krate);
|
||||
let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest);
|
||||
|
||||
let type_arena = TypedArena::new();
|
||||
let arenas = ty::CtxtArenas::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, &arenas, name);
|
||||
|
||||
let ctxt = DocContext {
|
||||
krate: ty_cx.map.krate(),
|
||||
|
|
|
@ -607,7 +607,7 @@ pub enum Stmt_ {
|
|||
/// Expr with trailing semi-colon (may have any type):
|
||||
StmtSemi(P<Expr>, NodeId),
|
||||
|
||||
StmtMac(Mac, MacStmtStyle),
|
||||
StmtMac(P<Mac>, MacStmtStyle),
|
||||
}
|
||||
|
||||
#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
|
||||
|
|
|
@ -672,7 +672,7 @@ fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
|
|||
StmtMac(mac, style) => (mac, style),
|
||||
_ => return expand_non_macro_stmt(s, fld)
|
||||
};
|
||||
let expanded_stmt = match expand_mac_invoc(mac, s.span,
|
||||
let expanded_stmt = match expand_mac_invoc(mac.and_then(|m| m), s.span,
|
||||
|r| r.make_stmt(),
|
||||
mark_stmt, fld) {
|
||||
Some(stmt) => stmt,
|
||||
|
|
|
@ -1461,7 +1461,7 @@ pub fn noop_fold_stmt<T: Folder>(Spanned {node, span}: Stmt, folder: &mut T)
|
|||
}))
|
||||
}
|
||||
StmtMac(mac, semi) => SmallVector::one(P(Spanned {
|
||||
node: StmtMac(folder.fold_mac(mac), semi),
|
||||
node: StmtMac(mac.map(|m| folder.fold_mac(m)), semi),
|
||||
span: span
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -3746,9 +3746,9 @@ impl<'a> Parser<'a> {
|
|||
if id.name == token::special_idents::invalid.name {
|
||||
P(spanned(lo,
|
||||
hi,
|
||||
StmtMac(spanned(lo,
|
||||
StmtMac(P(spanned(lo,
|
||||
hi,
|
||||
MacInvocTT(pth, tts, EMPTY_CTXT)),
|
||||
MacInvocTT(pth, tts, EMPTY_CTXT))),
|
||||
style)))
|
||||
} else {
|
||||
// if it has a special ident, it's definitely an item
|
||||
|
@ -3911,7 +3911,7 @@ impl<'a> Parser<'a> {
|
|||
_ => {
|
||||
let e = self.mk_mac_expr(span.lo,
|
||||
span.hi,
|
||||
macro.node);
|
||||
macro.and_then(|m| m.node));
|
||||
let e =
|
||||
self.parse_dot_or_call_expr_with(e);
|
||||
self.handle_expression_like_statement(
|
||||
|
@ -3940,7 +3940,7 @@ impl<'a> Parser<'a> {
|
|||
expr = Some(
|
||||
self.mk_mac_expr(span.lo,
|
||||
span.hi,
|
||||
m.node));
|
||||
m.and_then(|x| x.node)));
|
||||
}
|
||||
_ => {
|
||||
stmts.push(P(Spanned {
|
||||
|
|
|
@ -1337,7 +1337,7 @@ impl<'a> State<'a> {
|
|||
ast::MacStmtWithBraces => token::Brace,
|
||||
_ => token::Paren
|
||||
};
|
||||
try!(self.print_mac(mac, delim));
|
||||
try!(self.print_mac(&**mac, delim));
|
||||
match style {
|
||||
ast::MacStmtWithBraces => {}
|
||||
_ => try!(word(&mut self.s, ";")),
|
||||
|
|
|
@ -730,7 +730,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
|||
StmtExpr(ref expression, _) | StmtSemi(ref expression, _) => {
|
||||
visitor.visit_expr(&**expression)
|
||||
}
|
||||
StmtMac(ref macro, _) => visitor.visit_mac(macro),
|
||||
StmtMac(ref macro, _) => visitor.visit_mac(&**macro),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue