rustc: make ty::mk_* constructors into methods on ty::ctxt.
This commit is contained in:
parent
2332765cbc
commit
6db5126240
48 changed files with 492 additions and 537 deletions
|
|
@ -471,14 +471,14 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
|
|||
let def = parse_def_(st, NominalType, conv);
|
||||
let substs = parse_substs_(st, conv);
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_enum(tcx, def, st.tcx.mk_substs(substs));
|
||||
return tcx.mk_enum(def, st.tcx.mk_substs(substs));
|
||||
}
|
||||
'x' => {
|
||||
assert_eq!(next(st), '[');
|
||||
let trait_ref = ty::Binder(parse_trait_ref_(st, conv));
|
||||
let bounds = parse_existential_bounds_(st, conv);
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_trait(tcx, trait_ref, bounds);
|
||||
return tcx.mk_trait(trait_ref, bounds);
|
||||
}
|
||||
'p' => {
|
||||
assert_eq!(next(st), '[');
|
||||
|
|
@ -487,38 +487,38 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
|
|||
let space = parse_param_space(st);
|
||||
assert_eq!(next(st), '|');
|
||||
let name = token::intern(&parse_str(st, ']'));
|
||||
return ty::mk_param(tcx, space, index, name);
|
||||
return tcx.mk_param(space, index, name);
|
||||
}
|
||||
'~' => return ty::mk_uniq(tcx, parse_ty_(st, conv)),
|
||||
'*' => return ty::mk_ptr(tcx, parse_mt_(st, conv)),
|
||||
'~' => return tcx.mk_box(parse_ty_(st, conv)),
|
||||
'*' => return tcx.mk_ptr(parse_mt_(st, conv)),
|
||||
'&' => {
|
||||
let r = parse_region_(st, conv);
|
||||
let mt = parse_mt_(st, conv);
|
||||
return ty::mk_rptr(tcx, tcx.mk_region(r), mt);
|
||||
return tcx.mk_ref(tcx.mk_region(r), mt);
|
||||
}
|
||||
'V' => {
|
||||
let t = parse_ty_(st, conv);
|
||||
let sz = parse_size(st);
|
||||
return ty::mk_vec(tcx, t, sz);
|
||||
return match parse_size(st) {
|
||||
Some(n) => tcx.mk_array(t, n),
|
||||
None => tcx.mk_slice(t)
|
||||
};
|
||||
}
|
||||
'v' => {
|
||||
return ty::mk_str(tcx);
|
||||
return tcx.mk_str();
|
||||
}
|
||||
'T' => {
|
||||
assert_eq!(next(st), '[');
|
||||
let mut params = Vec::new();
|
||||
while peek(st) != ']' { params.push(parse_ty_(st, conv)); }
|
||||
st.pos = st.pos + 1;
|
||||
return ty::mk_tup(tcx, params);
|
||||
return tcx.mk_tup(params);
|
||||
}
|
||||
'F' => {
|
||||
let def_id = parse_def_(st, NominalType, conv);
|
||||
return ty::mk_bare_fn(tcx, Some(def_id),
|
||||
tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
|
||||
return tcx.mk_fn(Some(def_id), tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
|
||||
}
|
||||
'G' => {
|
||||
return ty::mk_bare_fn(tcx, None,
|
||||
tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
|
||||
return tcx.mk_fn(None, tcx.mk_bare_fn(parse_bare_fn_ty_(st, conv)));
|
||||
}
|
||||
'#' => {
|
||||
let pos = parse_hex(st);
|
||||
|
|
@ -558,20 +558,20 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
|
|||
let did = parse_def_(st, NominalType, conv);
|
||||
let substs = parse_substs_(st, conv);
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_struct(st.tcx, did, st.tcx.mk_substs(substs));
|
||||
return st.tcx.mk_struct(did, st.tcx.mk_substs(substs));
|
||||
}
|
||||
'k' => {
|
||||
assert_eq!(next(st), '[');
|
||||
let did = parse_def_(st, ClosureSource, conv);
|
||||
let substs = parse_substs_(st, conv);
|
||||
assert_eq!(next(st), ']');
|
||||
return ty::mk_closure(st.tcx, did, st.tcx.mk_substs(substs));
|
||||
return st.tcx.mk_closure(did, st.tcx.mk_substs(substs));
|
||||
}
|
||||
'P' => {
|
||||
assert_eq!(next(st), '[');
|
||||
let trait_ref = parse_trait_ref_(st, conv);
|
||||
let name = token::intern(&parse_str(st, ']'));
|
||||
return ty::mk_projection(tcx, trait_ref, name);
|
||||
return tcx.mk_projection(trait_ref, name);
|
||||
}
|
||||
'e' => {
|
||||
return tcx.types.err;
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ pub fn prim_ty_to_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
match nty {
|
||||
ast::TyBool => tcx.types.bool,
|
||||
ast::TyChar => tcx.types.char,
|
||||
ast::TyInt(it) => ty::mk_mach_int(tcx, it),
|
||||
ast::TyUint(uit) => ty::mk_mach_uint(tcx, uit),
|
||||
ast::TyFloat(ft) => ty::mk_mach_float(tcx, ft),
|
||||
ast::TyStr => ty::mk_str(tcx)
|
||||
ast::TyInt(it) => tcx.mk_mach_int(it),
|
||||
ast::TyUint(uit) => tcx.mk_mach_uint(uit),
|
||||
ast::TyFloat(ft) => tcx.mk_mach_float(ft),
|
||||
ast::TyStr => tcx.mk_str()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ fn is_useful(cx: &MatchCheckCtxt,
|
|||
None => v[0]
|
||||
};
|
||||
let left_ty = if real_pat.id == DUMMY_NODE_ID {
|
||||
ty::mk_nil(cx.tcx)
|
||||
cx.tcx.mk_nil()
|
||||
} else {
|
||||
let left_ty = ty::pat_ty(cx.tcx, &*real_pat);
|
||||
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||
let assoc_type_projections: Vec<_> =
|
||||
trait_def.associated_type_names
|
||||
.iter()
|
||||
.map(|&name| ty::mk_projection(self.tcx(), trait_ref.clone(), name))
|
||||
.map(|&name| self.tcx().mk_projection(trait_ref.clone(), name))
|
||||
.collect();
|
||||
debug!("accumulate_from_assoc_types: assoc_type_projections={:?}",
|
||||
assoc_type_projections);
|
||||
|
|
@ -437,7 +437,7 @@ pub fn object_region_bounds<'tcx>(
|
|||
// Since we don't actually *know* the self type for an object,
|
||||
// this "open(err)" serves as a kind of dummy standin -- basically
|
||||
// a skolemized type.
|
||||
let open_ty = ty::mk_infer(tcx, ty::FreshTy(0));
|
||||
let open_ty = tcx.mk_infer(ty::FreshTy(0));
|
||||
|
||||
// Note that we preserve the overall binding levels here.
|
||||
assert!(!open_ty.has_escaping_regions());
|
||||
|
|
|
|||
|
|
@ -129,8 +129,8 @@ fn unify_integral_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
.unify_var_value(vid, val)
|
||||
.map_err(|e| int_unification_error(vid_is_expected, e)));
|
||||
match val {
|
||||
IntType(v) => Ok(ty::mk_mach_int(infcx.tcx, v)),
|
||||
UintType(v) => Ok(ty::mk_mach_uint(infcx.tcx, v)),
|
||||
IntType(v) => Ok(infcx.tcx.mk_mach_int(v)),
|
||||
UintType(v) => Ok(infcx.tcx.mk_mach_uint(v)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ fn unify_float_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
.borrow_mut()
|
||||
.unify_var_value(vid, val)
|
||||
.map_err(|e| float_unification_error(vid_is_expected, e)));
|
||||
Ok(ty::mk_mach_float(infcx.tcx, val))
|
||||
Ok(infcx.tcx.mk_mach_float(val))
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
|||
Entry::Vacant(entry) => {
|
||||
let index = self.freshen_count;
|
||||
self.freshen_count += 1;
|
||||
let t = ty::mk_infer(self.infcx.tcx, freshener(index));
|
||||
let t = self.infcx.tcx.mk_infer(freshener(index));
|
||||
entry.insert(t);
|
||||
t
|
||||
}
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ pub fn construct_skolemized_substs<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
types: &mut subst::VecPerParamSpace<ty::Ty<'tcx>>,
|
||||
defs: &[ty::TypeParameterDef<'tcx>]) {
|
||||
for def in defs {
|
||||
let ty = ty::mk_param_from_def(tcx, def);
|
||||
let ty = tcx.mk_param_from_def(def);
|
||||
types.push(def.space, ty);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -772,11 +772,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn next_ty_var(&self) -> Ty<'tcx> {
|
||||
ty::mk_var(self.tcx, self.next_ty_var_id(false))
|
||||
self.tcx.mk_var(self.next_ty_var_id(false))
|
||||
}
|
||||
|
||||
pub fn next_diverging_ty_var(&self) -> Ty<'tcx> {
|
||||
ty::mk_var(self.tcx, self.next_ty_var_id(true))
|
||||
self.tcx.mk_var(self.next_ty_var_id(true))
|
||||
}
|
||||
|
||||
pub fn next_ty_vars(&self, n: usize) -> Vec<Ty<'tcx>> {
|
||||
|
|
|
|||
|
|
@ -1672,7 +1672,7 @@ impl<'tcx> GenericKind<'tcx> {
|
|||
GenericKind::Param(ref p) =>
|
||||
p.to_ty(tcx),
|
||||
GenericKind::Projection(ref p) =>
|
||||
ty::mk_projection(tcx, p.trait_ref.clone(), p.item_name),
|
||||
tcx.mk_projection(p.trait_ref.clone(), p.item_name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ impl UnifyKey for ty::IntVid {
|
|||
impl<'tcx> ToType<'tcx> for IntVarValue {
|
||||
fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
ty::IntType(i) => ty::mk_mach_int(tcx, i),
|
||||
ty::UintType(i) => ty::mk_mach_uint(tcx, i),
|
||||
ty::IntType(i) => tcx.mk_mach_int(i),
|
||||
ty::UintType(i) => tcx.mk_mach_uint(i),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,6 @@ impl UnifyKey for ty::FloatVid {
|
|||
|
||||
impl<'tcx> ToType<'tcx> for ast::FloatTy {
|
||||
fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
|
||||
ty::mk_mach_float(tcx, *self)
|
||||
tcx.mk_mach_float(*self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub fn check_crate(tcx: &ctxt) {
|
|||
tcx: tcx,
|
||||
param_envs: Vec::new(),
|
||||
dummy_sized_ty: tcx.types.isize,
|
||||
dummy_unsized_ty: ty::mk_vec(tcx, tcx.types.isize, None),
|
||||
dummy_unsized_ty: tcx.mk_slice(tcx.types.isize),
|
||||
};
|
||||
visit::walk_crate(&mut visitor, tcx.map.krate());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -524,9 +524,9 @@ fn project_type<'cx,'tcx>(
|
|||
Ok(ProjectedTy::Progress(ty, obligations))
|
||||
}
|
||||
None => {
|
||||
Ok(ProjectedTy::NoProgress(ty::mk_projection(selcx.tcx(),
|
||||
obligation.predicate.trait_ref.clone(),
|
||||
obligation.predicate.item_name)))
|
||||
Ok(ProjectedTy::NoProgress(selcx.tcx().mk_projection(
|
||||
obligation.predicate.trait_ref.clone(),
|
||||
obligation.predicate.item_name)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2451,7 +2451,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
projection_bounds: data_a.bounds.projection_bounds.clone(),
|
||||
};
|
||||
|
||||
let new_trait = ty::mk_trait(tcx, data_a.principal.clone(), bounds);
|
||||
let new_trait = tcx.mk_trait(data_a.principal.clone(), bounds);
|
||||
let origin = infer::Misc(obligation.cause.span);
|
||||
if self.infcx.sub_types(false, origin, new_trait, target).is_err() {
|
||||
return Err(Unimplemented);
|
||||
|
|
@ -2573,7 +2573,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let param_b = *substs_b.types.get(TypeSpace, i);
|
||||
new_substs.types.get_mut_slice(TypeSpace)[i] = param_b;
|
||||
}
|
||||
let new_struct = ty::mk_struct(tcx, def_id, tcx.mk_substs(new_substs));
|
||||
let new_struct = tcx.mk_struct(def_id, tcx.mk_substs(new_substs));
|
||||
let origin = infer::Misc(obligation.cause.span);
|
||||
if self.infcx.sub_types(false, origin, new_struct, target).is_err() {
|
||||
return Err(Unimplemented);
|
||||
|
|
|
|||
|
|
@ -456,14 +456,14 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
|
|||
{
|
||||
let arguments_tuple = match tuple_arguments {
|
||||
TupleArgumentsFlag::No => sig.0.inputs[0],
|
||||
TupleArgumentsFlag::Yes => ty::mk_tup(tcx, sig.0.inputs.to_vec()),
|
||||
TupleArgumentsFlag::Yes => tcx.mk_tup(sig.0.inputs.to_vec()),
|
||||
};
|
||||
let trait_substs = Substs::new_trait(vec![arguments_tuple], vec![], self_ty);
|
||||
let trait_ref = ty::TraitRef {
|
||||
def_id: fn_trait_def_id,
|
||||
substs: tcx.mk_substs(trait_substs),
|
||||
};
|
||||
ty::Binder((trait_ref, sig.0.output.unwrap_or(ty::mk_nil(tcx))))
|
||||
ty::Binder((trait_ref, sig.0.output.unwrap_or(tcx.mk_nil())))
|
||||
}
|
||||
|
||||
impl<'tcx,O:fmt::Debug> fmt::Debug for super::Obligation<'tcx, O> {
|
||||
|
|
|
|||
|
|
@ -3034,7 +3034,7 @@ impl<'tcx> ctxt<'tcx> {
|
|||
abi: bare_fn.abi,
|
||||
sig: bare_fn.sig.clone()
|
||||
});
|
||||
ty::mk_bare_fn(self, None, unsafe_fn_ty_a)
|
||||
self.mk_fn(None, unsafe_fn_ty_a)
|
||||
}
|
||||
|
||||
pub fn mk_bare_fn(&self, bare_fn: BareFnTy<'tcx>) -> &'tcx BareFnTy<'tcx> {
|
||||
|
|
@ -3085,13 +3085,6 @@ impl<'tcx> ctxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
// 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: TypeVariants<'tcx>) -> Ty<'tcx> {
|
||||
let mut interner = cx.interner.borrow_mut();
|
||||
intern_ty(&cx.arenas.type_, &mut *interner, st)
|
||||
}
|
||||
|
||||
fn intern_ty<'tcx>(type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
interner: &mut FnvHashMap<InternedTy<'tcx>, Ty<'tcx>>,
|
||||
st: TypeVariants<'tcx>)
|
||||
|
|
@ -3309,140 +3302,192 @@ impl FlagComputation {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyIs => tcx.types.isize,
|
||||
ast::TyI8 => tcx.types.i8,
|
||||
ast::TyI16 => tcx.types.i16,
|
||||
ast::TyI32 => tcx.types.i32,
|
||||
ast::TyI64 => tcx.types.i64,
|
||||
impl<'tcx> ctxt<'tcx> {
|
||||
// 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_ty(&self, st: TypeVariants<'tcx>) -> Ty<'tcx> {
|
||||
let mut interner = self.interner.borrow_mut();
|
||||
intern_ty(&self.arenas.type_, &mut *interner, st)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_mach_uint<'tcx>(tcx: &ctxt<'tcx>, tm: ast::UintTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyUs => tcx.types.usize,
|
||||
ast::TyU8 => tcx.types.u8,
|
||||
ast::TyU16 => tcx.types.u16,
|
||||
ast::TyU32 => tcx.types.u32,
|
||||
ast::TyU64 => tcx.types.u64,
|
||||
pub fn mk_mach_int(&self, tm: ast::IntTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyIs => self.types.isize,
|
||||
ast::TyI8 => self.types.i8,
|
||||
ast::TyI16 => self.types.i16,
|
||||
ast::TyI32 => self.types.i32,
|
||||
ast::TyI64 => self.types.i64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_mach_float<'tcx>(tcx: &ctxt<'tcx>, tm: ast::FloatTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyF32 => tcx.types.f32,
|
||||
ast::TyF64 => tcx.types.f64,
|
||||
pub fn mk_mach_uint(&self, tm: ast::UintTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyUs => self.types.usize,
|
||||
ast::TyU8 => self.types.u8,
|
||||
ast::TyU16 => self.types.u16,
|
||||
ast::TyU32 => self.types.u32,
|
||||
ast::TyU64 => self.types.u64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_str<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, TyStr)
|
||||
}
|
||||
pub fn mk_mach_float(&self, tm: ast::FloatTy) -> Ty<'tcx> {
|
||||
match tm {
|
||||
ast::TyF32 => self.types.f32,
|
||||
ast::TyF64 => self.types.f64,
|
||||
}
|
||||
}
|
||||
|
||||
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, TyStr),
|
||||
mutbl: m
|
||||
pub fn mk_str(&self) -> Ty<'tcx> {
|
||||
self.mk_ty(TyStr)
|
||||
}
|
||||
|
||||
pub fn mk_static_str(&self) -> Ty<'tcx> {
|
||||
self.mk_imm_ref(self.mk_region(ty::ReStatic), self.mk_str())
|
||||
}
|
||||
|
||||
pub fn mk_enum(&self, did: ast::DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
self.mk_ty(TyEnum(did, substs))
|
||||
}
|
||||
|
||||
pub fn mk_box(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyBox(ty))
|
||||
}
|
||||
|
||||
pub fn mk_ptr(&self, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyRawPtr(tm))
|
||||
}
|
||||
|
||||
pub fn mk_ref(&self, r: &'tcx Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyRef(r, tm))
|
||||
}
|
||||
|
||||
pub fn mk_mut_ref(&self, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ref(r, mt {ty: ty, mutbl: ast::MutMutable})
|
||||
}
|
||||
|
||||
pub fn mk_imm_ref(&self, r: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ref(r, mt {ty: ty, mutbl: ast::MutImmutable})
|
||||
}
|
||||
|
||||
pub fn mk_mut_ptr(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ptr(mt {ty: ty, mutbl: ast::MutMutable})
|
||||
}
|
||||
|
||||
pub fn mk_imm_ptr(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ptr(mt {ty: ty, mutbl: ast::MutImmutable})
|
||||
}
|
||||
|
||||
pub fn mk_nil_ptr(&self) -> Ty<'tcx> {
|
||||
self.mk_imm_ptr(self.mk_nil())
|
||||
}
|
||||
|
||||
pub fn mk_array(&self, ty: Ty<'tcx>, n: usize) -> Ty<'tcx> {
|
||||
self.mk_ty(TyArray(ty, n))
|
||||
}
|
||||
|
||||
pub fn mk_slice(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TySlice(ty))
|
||||
}
|
||||
|
||||
pub fn mk_tup(&self, ts: Vec<Ty<'tcx>>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyTuple(ts))
|
||||
}
|
||||
|
||||
pub fn mk_nil(&self) -> Ty<'tcx> {
|
||||
self.mk_tup(Vec::new())
|
||||
}
|
||||
|
||||
pub fn mk_bool(&self) -> Ty<'tcx> {
|
||||
self.mk_ty(TyBool)
|
||||
}
|
||||
|
||||
pub fn mk_fn(&self,
|
||||
opt_def_id: Option<ast::DefId>,
|
||||
fty: &'tcx BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyBareFn(opt_def_id, fty))
|
||||
}
|
||||
|
||||
pub fn mk_ctor_fn(&self,
|
||||
def_id: ast::DefId,
|
||||
input_tys: &[Ty<'tcx>],
|
||||
output: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let input_args = input_tys.iter().cloned().collect();
|
||||
self.mk_fn(Some(def_id), self.mk_bare_fn(BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(FnSig {
|
||||
inputs: input_args,
|
||||
output: ty::FnConverging(output),
|
||||
variadic: false
|
||||
})
|
||||
}
|
||||
|
||||
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, TyEnum(did, substs))
|
||||
}
|
||||
|
||||
pub fn mk_uniq<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { mk_t(cx, TyBox(ty)) }
|
||||
|
||||
pub fn mk_ptr<'tcx>(cx: &ctxt<'tcx>, tm: mt<'tcx>) -> Ty<'tcx> { mk_t(cx, TyRawPtr(tm)) }
|
||||
|
||||
pub fn mk_rptr<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, TyRef(r, tm))
|
||||
}
|
||||
|
||||
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: &'tcx Region, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
mk_rptr(cx, r, mt {ty: ty, mutbl: ast::MutImmutable})
|
||||
}
|
||||
|
||||
pub fn mk_mut_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
mk_ptr(cx, mt {ty: ty, mutbl: ast::MutMutable})
|
||||
}
|
||||
|
||||
pub fn mk_imm_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
mk_ptr(cx, mt {ty: ty, mutbl: ast::MutImmutable})
|
||||
}
|
||||
|
||||
pub fn mk_nil_ptr<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
mk_ptr(cx, mt {ty: mk_nil(cx), mutbl: ast::MutImmutable})
|
||||
}
|
||||
|
||||
pub fn mk_vec<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, sz: Option<usize>) -> Ty<'tcx> {
|
||||
match sz {
|
||||
Some(n) => mk_t(cx, TyArray(ty, n)),
|
||||
None => mk_t(cx, TySlice(ty))
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
mutbl: tm.mutbl
|
||||
})
|
||||
}
|
||||
pub fn mk_trait(&self,
|
||||
principal: ty::PolyTraitRef<'tcx>,
|
||||
bounds: ExistentialBounds<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
assert!(bound_list_is_sorted(&bounds.projection_bounds));
|
||||
|
||||
pub fn mk_tup<'tcx>(cx: &ctxt<'tcx>, ts: Vec<Ty<'tcx>>) -> Ty<'tcx> {
|
||||
mk_t(cx, TyTuple(ts))
|
||||
}
|
||||
let inner = box TraitTy {
|
||||
principal: principal,
|
||||
bounds: bounds
|
||||
};
|
||||
self.mk_ty(TyTrait(inner))
|
||||
}
|
||||
|
||||
pub fn mk_nil<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
mk_tup(cx, Vec::new())
|
||||
}
|
||||
pub fn mk_projection(&self,
|
||||
trait_ref: TraitRef<'tcx>,
|
||||
item_name: ast::Name)
|
||||
-> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
let inner = ProjectionTy { trait_ref: trait_ref, item_name: item_name };
|
||||
self.mk_ty(TyProjection(inner))
|
||||
}
|
||||
|
||||
pub fn mk_bool<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, TyBool)
|
||||
}
|
||||
pub fn mk_struct(&self, struct_id: ast::DefId,
|
||||
substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
self.mk_ty(TyStruct(struct_id, substs))
|
||||
}
|
||||
|
||||
pub fn mk_bare_fn<'tcx>(cx: &ctxt<'tcx>,
|
||||
opt_def_id: Option<ast::DefId>,
|
||||
fty: &'tcx BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, TyBareFn(opt_def_id, fty))
|
||||
}
|
||||
pub fn mk_closure(&self, closure_id: ast::DefId, substs: &'tcx Substs<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
self.mk_ty(TyClosure(closure_id, substs))
|
||||
}
|
||||
|
||||
pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
|
||||
def_id: ast::DefId,
|
||||
input_tys: &[Ty<'tcx>],
|
||||
output: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let input_args = input_tys.iter().cloned().collect();
|
||||
mk_bare_fn(cx,
|
||||
Some(def_id),
|
||||
cx.mk_bare_fn(BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(FnSig {
|
||||
inputs: input_args,
|
||||
output: ty::FnConverging(output),
|
||||
variadic: false
|
||||
})
|
||||
}))
|
||||
}
|
||||
pub fn mk_var(&self, v: TyVid) -> Ty<'tcx> {
|
||||
self.mk_infer(TyVar(v))
|
||||
}
|
||||
|
||||
pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
|
||||
principal: ty::PolyTraitRef<'tcx>,
|
||||
bounds: ExistentialBounds<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
assert!(bound_list_is_sorted(&bounds.projection_bounds));
|
||||
pub fn mk_int_var(&self, v: IntVid) -> Ty<'tcx> {
|
||||
self.mk_infer(IntVar(v))
|
||||
}
|
||||
|
||||
let inner = box TraitTy {
|
||||
principal: principal,
|
||||
bounds: bounds
|
||||
};
|
||||
mk_t(cx, TyTrait(inner))
|
||||
pub fn mk_float_var(&self, v: FloatVid) -> Ty<'tcx> {
|
||||
self.mk_infer(FloatVar(v))
|
||||
}
|
||||
|
||||
pub fn mk_infer(&self, it: InferTy) -> Ty<'tcx> {
|
||||
self.mk_ty(TyInfer(it))
|
||||
}
|
||||
|
||||
pub fn mk_param(&self,
|
||||
space: subst::ParamSpace,
|
||||
index: u32,
|
||||
name: ast::Name) -> Ty<'tcx> {
|
||||
self.mk_ty(TyParam(ParamTy { space: space, idx: index, name: name }))
|
||||
}
|
||||
|
||||
pub fn mk_self_type(&self) -> Ty<'tcx> {
|
||||
self.mk_param(subst::SelfSpace, 0, special_idents::type_self.name)
|
||||
}
|
||||
|
||||
pub fn mk_param_from_def(&self, def: &TypeParameterDef) -> Ty<'tcx> {
|
||||
self.mk_param(def.space, def.index, def.name)
|
||||
}
|
||||
}
|
||||
|
||||
fn bound_list_is_sorted(bounds: &[ty::PolyProjectionPredicate]) -> bool {
|
||||
|
|
@ -3455,57 +3500,6 @@ pub fn sort_bounds_list(bounds: &mut [ty::PolyProjectionPredicate]) {
|
|||
bounds.sort_by(|a, b| a.sort_key().cmp(&b.sort_key()))
|
||||
}
|
||||
|
||||
pub fn mk_projection<'tcx>(cx: &ctxt<'tcx>,
|
||||
trait_ref: TraitRef<'tcx>,
|
||||
item_name: ast::Name)
|
||||
-> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
let inner = ProjectionTy { trait_ref: trait_ref, item_name: item_name };
|
||||
mk_t(cx, TyProjection(inner))
|
||||
}
|
||||
|
||||
pub fn mk_struct<'tcx>(cx: &ctxt<'tcx>, struct_id: ast::DefId,
|
||||
substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
mk_t(cx, TyStruct(struct_id, substs))
|
||||
}
|
||||
|
||||
pub fn mk_closure<'tcx>(cx: &ctxt<'tcx>, closure_id: ast::DefId, substs: &'tcx Substs<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
mk_t(cx, TyClosure(closure_id, substs))
|
||||
}
|
||||
|
||||
pub fn mk_var<'tcx>(cx: &ctxt<'tcx>, v: TyVid) -> Ty<'tcx> {
|
||||
mk_infer(cx, TyVar(v))
|
||||
}
|
||||
|
||||
pub fn mk_int_var<'tcx>(cx: &ctxt<'tcx>, v: IntVid) -> Ty<'tcx> {
|
||||
mk_infer(cx, IntVar(v))
|
||||
}
|
||||
|
||||
pub fn mk_float_var<'tcx>(cx: &ctxt<'tcx>, v: FloatVid) -> Ty<'tcx> {
|
||||
mk_infer(cx, FloatVar(v))
|
||||
}
|
||||
|
||||
pub fn mk_infer<'tcx>(cx: &ctxt<'tcx>, it: InferTy) -> Ty<'tcx> {
|
||||
mk_t(cx, TyInfer(it))
|
||||
}
|
||||
|
||||
pub fn mk_param<'tcx>(cx: &ctxt<'tcx>,
|
||||
space: subst::ParamSpace,
|
||||
index: u32,
|
||||
name: ast::Name) -> Ty<'tcx> {
|
||||
mk_t(cx, TyParam(ParamTy { space: space, idx: index, name: name }))
|
||||
}
|
||||
|
||||
pub fn mk_self_type<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
mk_param(cx, subst::SelfSpace, 0, special_idents::type_self.name)
|
||||
}
|
||||
|
||||
pub fn mk_param_from_def<'tcx>(cx: &ctxt<'tcx>, def: &TypeParameterDef) -> Ty<'tcx> {
|
||||
mk_param(cx, def.space, def.index, def.name)
|
||||
}
|
||||
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
/// Iterator that walks `self` and any types reachable from
|
||||
/// `self`, in depth-first order. Note that just walks the types
|
||||
|
|
@ -3586,7 +3580,7 @@ impl ParamTy {
|
|||
}
|
||||
|
||||
pub fn to_ty<'tcx>(self, tcx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
ty::mk_param(tcx, self.space, self.idx, self.name)
|
||||
tcx.mk_param(self.space, self.idx, self.name)
|
||||
}
|
||||
|
||||
pub fn is_self(&self) -> bool {
|
||||
|
|
@ -3657,7 +3651,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
pub fn sequence_element_type(&self, cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
TyStr => mk_mach_uint(cx, ast::TyU8),
|
||||
TyStr => cx.mk_mach_uint(ast::TyU8),
|
||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
||||
self)),
|
||||
}
|
||||
|
|
@ -4745,18 +4739,6 @@ pub fn ty_region(tcx: &ctxt,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn free_region_from_def(outlives_extent: region::DestructionScopeData,
|
||||
def: &RegionParameterDef)
|
||||
-> ty::Region
|
||||
{
|
||||
let ret =
|
||||
ty::ReFree(ty::FreeRegion { scope: outlives_extent,
|
||||
bound_region: ty::BrNamed(def.def_id,
|
||||
def.name) });
|
||||
debug!("free_region_from_def returns {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
|
||||
// doesn't provide type parameter substitutions.
|
||||
pub fn pat_ty<'tcx>(cx: &ctxt<'tcx>, pat: &ast::Pat) -> Ty<'tcx> {
|
||||
|
|
@ -4860,7 +4842,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
|
|||
AdjustReifyFnPointer => {
|
||||
match unadjusted_ty.sty {
|
||||
ty::TyBareFn(Some(_), b) => {
|
||||
ty::mk_bare_fn(cx, None, b)
|
||||
cx.mk_fn(None, b)
|
||||
}
|
||||
_ => {
|
||||
cx.sess.bug(
|
||||
|
|
@ -4932,10 +4914,10 @@ pub fn adjust_ty_for_autoref<'tcx>(cx: &ctxt<'tcx>,
|
|||
match autoref {
|
||||
None => ty,
|
||||
Some(AutoPtr(r, m)) => {
|
||||
mk_rptr(cx, r, mt { ty: ty, mutbl: m })
|
||||
cx.mk_ref(r, mt { ty: ty, mutbl: m })
|
||||
}
|
||||
Some(AutoUnsafe(m)) => {
|
||||
mk_ptr(cx, mt { ty: ty, mutbl: m })
|
||||
cx.mk_ptr(mt { ty: ty, mutbl: m })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6185,12 +6167,11 @@ pub fn closure_upvars<'tcx>(typer: &mc::Typer<'tcx>,
|
|||
freevar_ty
|
||||
}
|
||||
UpvarCapture::ByRef(borrow) => {
|
||||
mk_rptr(tcx,
|
||||
tcx.mk_region(borrow.region),
|
||||
ty::mt {
|
||||
ty: freevar_ty,
|
||||
mutbl: borrow.kind.to_mutbl_lossy(),
|
||||
})
|
||||
tcx.mk_ref(tcx.mk_region(borrow.region),
|
||||
ty::mt {
|
||||
ty: freevar_ty,
|
||||
mutbl: borrow.kind.to_mutbl_lossy(),
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -6698,8 +6679,12 @@ pub fn construct_free_substs<'a,'tcx>(
|
|||
all_outlive_extent: region::DestructionScopeData,
|
||||
region_params: &[RegionParameterDef])
|
||||
{
|
||||
for r in region_params {
|
||||
regions.push(r.space, ty::free_region_from_def(all_outlive_extent, r));
|
||||
for def in region_params {
|
||||
let region =
|
||||
ReFree(FreeRegion { scope: all_outlive_extent,
|
||||
bound_region: BrNamed(def.def_id, def.name) });
|
||||
debug!("push_region_params {:?}", region);
|
||||
regions.push(def.space, region);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6709,7 +6694,7 @@ pub fn construct_free_substs<'a,'tcx>(
|
|||
for def in defs {
|
||||
debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
|
||||
def);
|
||||
let ty = ty::mk_param_from_def(tcx, def);
|
||||
let ty = tcx.mk_param_from_def(def);
|
||||
types.push(def.space, ty);
|
||||
}
|
||||
}
|
||||
|
|
@ -7161,7 +7146,7 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ctxt<'tcx>,
|
|||
let meth_tps: Vec<Ty> =
|
||||
method.generics.types.get_slice(subst::FnSpace)
|
||||
.iter()
|
||||
.map(|def| ty::mk_param_from_def(tcx, def))
|
||||
.map(|def| tcx.mk_param_from_def(def))
|
||||
.collect();
|
||||
let meth_regions: Vec<ty::Region> =
|
||||
method.generics.regions.get_slice(subst::FnSpace)
|
||||
|
|
|
|||
|
|
@ -641,7 +641,7 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
|||
ty.sty.clone()
|
||||
}
|
||||
};
|
||||
ty::mk_t(this.tcx(), sty)
|
||||
this.tcx().mk_ty(sty)
|
||||
}
|
||||
|
||||
pub fn super_fold_substs<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
||||
|
|
|
|||
|
|
@ -469,21 +469,21 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||
if a_id == b_id =>
|
||||
{
|
||||
let substs = try!(relate_item_substs(relation, a_id, a_substs, b_substs));
|
||||
Ok(ty::mk_enum(tcx, a_id, tcx.mk_substs(substs)))
|
||||
Ok(tcx.mk_enum(a_id, tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::TyTrait(ref a_), &ty::TyTrait(ref b_)) =>
|
||||
{
|
||||
let principal = try!(relation.relate(&a_.principal, &b_.principal));
|
||||
let bounds = try!(relation.relate(&a_.bounds, &b_.bounds));
|
||||
Ok(ty::mk_trait(tcx, principal, bounds))
|
||||
Ok(tcx.mk_trait(principal, bounds))
|
||||
}
|
||||
|
||||
(&ty::TyStruct(a_id, a_substs), &ty::TyStruct(b_id, b_substs))
|
||||
if a_id == b_id =>
|
||||
{
|
||||
let substs = try!(relate_item_substs(relation, a_id, a_substs, b_substs));
|
||||
Ok(ty::mk_struct(tcx, a_id, tcx.mk_substs(substs)))
|
||||
Ok(tcx.mk_struct(a_id, tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::TyClosure(a_id, a_substs),
|
||||
|
|
@ -494,33 +494,33 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||
// the (anonymous) type of the same closure expression. So
|
||||
// all of their regions should be equated.
|
||||
let substs = try!(relate_substs(relation, None, a_substs, b_substs));
|
||||
Ok(ty::mk_closure(tcx, a_id, tcx.mk_substs(substs)))
|
||||
Ok(tcx.mk_closure(a_id, tcx.mk_substs(substs)))
|
||||
}
|
||||
|
||||
(&ty::TyBox(a_inner), &ty::TyBox(b_inner)) =>
|
||||
{
|
||||
let typ = try!(relation.relate(&a_inner, &b_inner));
|
||||
Ok(ty::mk_uniq(tcx, typ))
|
||||
Ok(tcx.mk_box(typ))
|
||||
}
|
||||
|
||||
(&ty::TyRawPtr(ref a_mt), &ty::TyRawPtr(ref b_mt)) =>
|
||||
{
|
||||
let mt = try!(relation.relate(a_mt, b_mt));
|
||||
Ok(ty::mk_ptr(tcx, mt))
|
||||
Ok(tcx.mk_ptr(mt))
|
||||
}
|
||||
|
||||
(&ty::TyRef(a_r, ref a_mt), &ty::TyRef(b_r, ref b_mt)) =>
|
||||
{
|
||||
let r = try!(relation.relate_with_variance(ty::Contravariant, a_r, b_r));
|
||||
let mt = try!(relation.relate(a_mt, b_mt));
|
||||
Ok(ty::mk_rptr(tcx, tcx.mk_region(r), mt))
|
||||
Ok(tcx.mk_ref(tcx.mk_region(r), mt))
|
||||
}
|
||||
|
||||
(&ty::TyArray(a_t, sz_a), &ty::TyArray(b_t, sz_b)) =>
|
||||
{
|
||||
let t = try!(relation.relate(&a_t, &b_t));
|
||||
if sz_a == sz_b {
|
||||
Ok(ty::mk_vec(tcx, t, Some(sz_a)))
|
||||
Ok(tcx.mk_array(t, sz_a))
|
||||
} else {
|
||||
Err(ty::terr_fixed_array_size(expected_found(relation, &sz_a, &sz_b)))
|
||||
}
|
||||
|
|
@ -529,7 +529,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||
(&ty::TySlice(a_t), &ty::TySlice(b_t)) =>
|
||||
{
|
||||
let t = try!(relation.relate(&a_t, &b_t));
|
||||
Ok(ty::mk_vec(tcx, t, None))
|
||||
Ok(tcx.mk_slice(t))
|
||||
}
|
||||
|
||||
(&ty::TyTuple(ref as_), &ty::TyTuple(ref bs)) =>
|
||||
|
|
@ -538,7 +538,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||
let ts = try!(as_.iter().zip(bs)
|
||||
.map(|(a, b)| relation.relate(a, b))
|
||||
.collect::<Result<_, _>>());
|
||||
Ok(ty::mk_tup(tcx, ts))
|
||||
Ok(tcx.mk_tup(ts))
|
||||
} else if !(as_.is_empty() || bs.is_empty()) {
|
||||
Err(ty::terr_tuple_size(
|
||||
expected_found(relation, &as_.len(), &bs.len())))
|
||||
|
|
@ -551,13 +551,13 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||
if a_opt_def_id == b_opt_def_id =>
|
||||
{
|
||||
let fty = try!(relation.relate(a_fty, b_fty));
|
||||
Ok(ty::mk_bare_fn(tcx, a_opt_def_id, tcx.mk_bare_fn(fty)))
|
||||
Ok(tcx.mk_fn(a_opt_def_id, tcx.mk_bare_fn(fty)))
|
||||
}
|
||||
|
||||
(&ty::TyProjection(ref a_data), &ty::TyProjection(ref b_data)) =>
|
||||
{
|
||||
let projection_ty = try!(relation.relate(a_data, b_data));
|
||||
Ok(ty::mk_projection(tcx, projection_ty.trait_ref, projection_ty.item_name))
|
||||
Ok(tcx.mk_projection(projection_ty.trait_ref, projection_ty.item_name))
|
||||
}
|
||||
|
||||
_ =>
|
||||
|
|
|
|||
|
|
@ -256,30 +256,29 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
-> Ty<'tcx>
|
||||
{
|
||||
let input_args = input_tys.iter().cloned().collect();
|
||||
ty::mk_bare_fn(self.infcx.tcx,
|
||||
None,
|
||||
self.infcx.tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: input_args,
|
||||
output: ty::FnConverging(output_ty),
|
||||
variadic: false
|
||||
})
|
||||
}))
|
||||
self.infcx.tcx.mk_fn(None,
|
||||
self.infcx.tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: input_args,
|
||||
output: ty::FnConverging(output_ty),
|
||||
variadic: false
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn t_nil(&self) -> Ty<'tcx> {
|
||||
ty::mk_nil(self.infcx.tcx)
|
||||
self.infcx.tcx.mk_nil()
|
||||
}
|
||||
|
||||
pub fn t_pair(&self, ty1: Ty<'tcx>, ty2: Ty<'tcx>) -> Ty<'tcx> {
|
||||
ty::mk_tup(self.infcx.tcx, vec![ty1, ty2])
|
||||
self.infcx.tcx.mk_tup(vec![ty1, ty2])
|
||||
}
|
||||
|
||||
pub fn t_param(&self, space: subst::ParamSpace, index: u32) -> Ty<'tcx> {
|
||||
let name = format!("T{}", index);
|
||||
ty::mk_param(self.infcx.tcx, space, index, token::intern(&name[..]))
|
||||
self.infcx.tcx.mk_param(space, index, token::intern(&name[..]))
|
||||
}
|
||||
|
||||
pub fn re_early_bound(&self,
|
||||
|
|
@ -302,16 +301,14 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn t_rptr(&self, r: ty::Region) -> Ty<'tcx> {
|
||||
ty::mk_imm_rptr(self.infcx.tcx,
|
||||
self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
}
|
||||
|
||||
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.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
}
|
||||
|
||||
pub fn t_rptr_late_bound_with_debruijn(&self,
|
||||
|
|
@ -319,15 +316,14 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
debruijn: ty::DebruijnIndex)
|
||||
-> Ty<'tcx> {
|
||||
let r = self.re_late_bound_with_debruijn(id, debruijn);
|
||||
ty::mk_imm_rptr(self.infcx.tcx,
|
||||
self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
}
|
||||
|
||||
pub fn t_rptr_scope(&self, id: ast::NodeId) -> Ty<'tcx> {
|
||||
let r = ty::ReScope(CodeExtent::from_node_id(id));
|
||||
ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
}
|
||||
|
||||
pub fn re_free(&self, nid: ast::NodeId, id: u32) -> ty::Region {
|
||||
|
|
@ -337,15 +333,13 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
|
||||
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),
|
||||
self.tcx().types.isize)
|
||||
self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r),
|
||||
self.tcx().types.isize)
|
||||
}
|
||||
|
||||
pub fn t_rptr_static(&self) -> Ty<'tcx> {
|
||||
ty::mk_imm_rptr(self.infcx.tcx,
|
||||
self.infcx.tcx.mk_region(ty::ReStatic),
|
||||
self.tcx().types.isize)
|
||||
self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(ty::ReStatic),
|
||||
self.tcx().types.isize)
|
||||
}
|
||||
|
||||
pub fn dummy_type_trace(&self) -> infer::TypeTrace<'tcx> {
|
||||
|
|
@ -804,9 +798,9 @@ fn walk_ty() {
|
|||
let tcx = env.infcx.tcx;
|
||||
let int_ty = tcx.types.isize;
|
||||
let uint_ty = tcx.types.usize;
|
||||
let tup1_ty = ty::mk_tup(tcx, vec!(int_ty, uint_ty, int_ty, uint_ty));
|
||||
let tup2_ty = ty::mk_tup(tcx, vec!(tup1_ty, tup1_ty, uint_ty));
|
||||
let uniq_ty = ty::mk_uniq(tcx, tup2_ty);
|
||||
let tup1_ty = tcx.mk_tup(vec!(int_ty, uint_ty, int_ty, uint_ty));
|
||||
let tup2_ty = tcx.mk_tup(vec!(tup1_ty, tup1_ty, uint_ty));
|
||||
let uniq_ty = tcx.mk_box(tup2_ty);
|
||||
let walked: Vec<_> = uniq_ty.walk().collect();
|
||||
assert_eq!(walked, [uniq_ty,
|
||||
tup2_ty,
|
||||
|
|
@ -822,9 +816,9 @@ fn walk_ty_skip_subtree() {
|
|||
let tcx = env.infcx.tcx;
|
||||
let int_ty = tcx.types.isize;
|
||||
let uint_ty = tcx.types.usize;
|
||||
let tup1_ty = ty::mk_tup(tcx, vec!(int_ty, uint_ty, int_ty, uint_ty));
|
||||
let tup2_ty = ty::mk_tup(tcx, vec!(tup1_ty, tup1_ty, uint_ty));
|
||||
let uniq_ty = ty::mk_uniq(tcx, tup2_ty);
|
||||
let tup1_ty = tcx.mk_tup(vec!(int_ty, uint_ty, int_ty, uint_ty));
|
||||
let tup2_ty = tcx.mk_tup(vec!(tup1_ty, tup1_ty, uint_ty));
|
||||
let uniq_ty = tcx.mk_box(tup2_ty);
|
||||
|
||||
// types we expect to see (in order), plus a boolean saying
|
||||
// whether to skip the subtree.
|
||||
|
|
|
|||
|
|
@ -1699,15 +1699,15 @@ impl LintPass for MissingCopyImplementations {
|
|||
if ast_generics.is_parameterized() {
|
||||
return;
|
||||
}
|
||||
ty::mk_struct(cx.tcx, local_def(item.id),
|
||||
cx.tcx.mk_substs(Substs::empty()))
|
||||
cx.tcx.mk_struct(local_def(item.id),
|
||||
cx.tcx.mk_substs(Substs::empty()))
|
||||
}
|
||||
ast::ItemEnum(_, ref ast_generics) => {
|
||||
if ast_generics.is_parameterized() {
|
||||
return;
|
||||
}
|
||||
ty::mk_enum(cx.tcx, local_def(item.id),
|
||||
cx.tcx.mk_substs(Substs::empty()))
|
||||
cx.tcx.mk_enum(local_def(item.id),
|
||||
cx.tcx.mk_substs(Substs::empty()))
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -674,9 +674,8 @@ fn bind_subslice_pat(bcx: Block,
|
|||
let slice_begin = InBoundsGEP(bcx, base, &[C_uint(bcx.ccx(), offset_left)]);
|
||||
let slice_len_offset = C_uint(bcx.ccx(), offset_left + offset_right);
|
||||
let slice_len = Sub(bcx, len, slice_len_offset, DebugLoc::None);
|
||||
let slice_ty = ty::mk_slice(bcx.tcx(),
|
||||
bcx.tcx().mk_region(ty::ReStatic),
|
||||
ty::mt {ty: unit_ty, mutbl: ast::MutImmutable});
|
||||
let slice_ty = bcx.tcx().mk_imm_ref(bcx.tcx().mk_region(ty::ReStatic),
|
||||
bcx.tcx().mk_slice(unit_ty));
|
||||
let scratch = rvalue_scratch_datum(bcx, slice_ty, "");
|
||||
Store(bcx, slice_begin,
|
||||
GEPi(bcx, scratch.val, &[0, abi::FAT_PTR_ADDR]));
|
||||
|
|
@ -854,9 +853,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
// NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
|
||||
// which calls memcmp().
|
||||
let pat_len = val_ty(rhs).element_type().array_length();
|
||||
let ty_str_slice = ty::mk_str_slice(cx.tcx(),
|
||||
cx.tcx().mk_region(ty::ReStatic),
|
||||
ast::MutImmutable);
|
||||
let ty_str_slice = cx.tcx().mk_static_str();
|
||||
|
||||
let rhs_str = alloc_ty(cx, ty_str_slice, "rhs_str");
|
||||
Store(cx, GEPi(cx, rhs, &[0, 0]), expr::get_dataptr(cx, rhs_str));
|
||||
|
|
@ -1063,7 +1060,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
.unwrap_or(DUMMY_NODE_ID);
|
||||
|
||||
let left_ty = if pat_id == DUMMY_NODE_ID {
|
||||
ty::mk_nil(tcx)
|
||||
tcx.mk_nil()
|
||||
} else {
|
||||
node_id_type(bcx, pat_id)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -623,8 +623,8 @@ fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool {
|
|||
|
||||
pub fn ty_of_inttype<'tcx>(tcx: &ty::ctxt<'tcx>, ity: IntType) -> Ty<'tcx> {
|
||||
match ity {
|
||||
attr::SignedInt(t) => ty::mk_mach_int(tcx, t),
|
||||
attr::UnsignedInt(t) => ty::mk_mach_uint(tcx, t)
|
||||
attr::SignedInt(t) => tcx.mk_mach_int(t),
|
||||
attr::UnsignedInt(t) => tcx.mk_mach_uint(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1078,7 +1078,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
-> datum::DatumBlock<'blk, 'tcx, datum::Expr>
|
||||
{
|
||||
let tcx = bcx.tcx();
|
||||
let ptr_ty = ty::mk_imm_ptr(bcx.tcx(), tcx.dtor_type());
|
||||
let ptr_ty = bcx.tcx().mk_imm_ptr(tcx.dtor_type());
|
||||
match *r {
|
||||
Univariant(ref st, dtor) if dtor_active(dtor) => {
|
||||
let flag_ptr = GEPi(bcx, val, &[0, st.fields.len() - 1]);
|
||||
|
|
|
|||
|
|
@ -202,10 +202,10 @@ pub fn self_type_for_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let closure_kind = ccx.tcx().closure_kind(closure_id);
|
||||
match closure_kind {
|
||||
ty::FnClosureKind => {
|
||||
ty::mk_imm_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty)
|
||||
ccx.tcx().mk_imm_ref(ccx.tcx().mk_region(ty::ReStatic), fn_ty)
|
||||
}
|
||||
ty::FnMutClosureKind => {
|
||||
ty::mk_mut_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty)
|
||||
ccx.tcx().mk_mut_ref(ccx.tcx().mk_region(ty::ReStatic), fn_ty)
|
||||
}
|
||||
ty::FnOnceClosureKind => fn_ty
|
||||
}
|
||||
|
|
@ -1579,7 +1579,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
// Tuple up closure argument types for the "rust-call" ABI.
|
||||
closure::ClosureEnv::Closure(_) => {
|
||||
vec![ty::mk_tup(ccx.tcx(), monomorphized_arg_types)]
|
||||
vec![ccx.tcx().mk_tup(monomorphized_arg_types)]
|
||||
}
|
||||
};
|
||||
for monomorphized_arg_type in &monomorphized_arg_types {
|
||||
|
|
@ -2115,7 +2115,7 @@ pub fn register_fn_llvmty(ccx: &CrateContext,
|
|||
debug!("register_fn_llvmty id={} sym={}", node_id, sym);
|
||||
|
||||
let llfn = declare::define_fn(ccx, &sym[..], cc, llfty,
|
||||
ty::FnConverging(ty::mk_nil(ccx.tcx()))).unwrap_or_else(||{
|
||||
ty::FnConverging(ccx.tcx().mk_nil())).unwrap_or_else(||{
|
||||
ccx.sess().span_fatal(sp, &format!("symbol `{}` is already defined", sym));
|
||||
});
|
||||
finish_register_fn(ccx, sym, node_id, llfn);
|
||||
|
|
@ -2197,7 +2197,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
|
|||
&ccx.int_type());
|
||||
|
||||
let llfn = declare::define_cfn(ccx, "main", llfty,
|
||||
ty::mk_nil(ccx.tcx())).unwrap_or_else(||{
|
||||
ccx.tcx().mk_nil()).unwrap_or_else(||{
|
||||
ccx.sess().span_err(sp, "entry symbol `main` defined multiple times");
|
||||
// FIXME: We should be smart and show a better diagnostic here.
|
||||
ccx.sess().help("did you use #[no_mangle] on `fn main`? Use #[start] instead");
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
ty::FnOnceClosureKind => false,
|
||||
};
|
||||
let bare_fn_ty_maybe_ref = if is_by_ref {
|
||||
ty::mk_imm_rptr(tcx, tcx.mk_region(ty::ReStatic), bare_fn_ty)
|
||||
tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic), bare_fn_ty)
|
||||
} else {
|
||||
bare_fn_ty
|
||||
};
|
||||
|
|
@ -308,18 +308,17 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
}
|
||||
};
|
||||
let sig = ty::erase_late_bound_regions(tcx, sig);
|
||||
let tuple_input_ty = ty::mk_tup(tcx, sig.inputs.to_vec());
|
||||
let tuple_fn_ty = ty::mk_bare_fn(tcx,
|
||||
opt_def_id,
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_maybe_ref,
|
||||
tuple_input_ty],
|
||||
output: sig.output,
|
||||
variadic: false
|
||||
})}));
|
||||
let tuple_input_ty = tcx.mk_tup(sig.inputs.to_vec());
|
||||
let tuple_fn_ty = tcx.mk_fn(opt_def_id,
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_maybe_ref,
|
||||
tuple_input_ty],
|
||||
output: sig.output,
|
||||
variadic: false
|
||||
})}));
|
||||
debug!("tuple_fn_ty: {:?}", tuple_fn_ty);
|
||||
|
||||
//
|
||||
|
|
@ -615,7 +614,7 @@ pub fn trans_method_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
Some(method) => match method.origin {
|
||||
ty::MethodTraitObject(_) => match method.ty.sty {
|
||||
ty::TyBareFn(_, ref fty) => {
|
||||
ty::mk_bare_fn(bcx.tcx(), None, meth::opaque_method_ty(bcx.tcx(), fty))
|
||||
bcx.tcx().mk_fn(None, meth::opaque_method_ty(bcx.tcx(), fty))
|
||||
}
|
||||
_ => method.ty
|
||||
},
|
||||
|
|
@ -749,7 +748,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
expr::Ignore => {
|
||||
let ret_ty = match ret_ty {
|
||||
ty::FnConverging(ret_ty) => ret_ty,
|
||||
ty::FnDiverging => ty::mk_nil(ccx.tcx())
|
||||
ty::FnDiverging => ccx.tcx().mk_nil()
|
||||
};
|
||||
if !is_rust_fn ||
|
||||
type_of::return_uses_outptr(ccx, ret_ty) ||
|
||||
|
|
|
|||
|
|
@ -363,8 +363,8 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
|
|||
// Find a version of the closure type. Substitute static for the
|
||||
// region since it doesn't really matter.
|
||||
let substs = tcx.mk_substs(substs);
|
||||
let closure_ty = ty::mk_closure(tcx, closure_def_id, substs);
|
||||
let ref_closure_ty = ty::mk_imm_rptr(tcx, tcx.mk_region(ty::ReStatic), closure_ty);
|
||||
let closure_ty = tcx.mk_closure(closure_def_id, substs);
|
||||
let ref_closure_ty = tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic), closure_ty);
|
||||
|
||||
// Make a version with the type of by-ref closure.
|
||||
let ty::ClosureTy { unsafety, abi, mut sig } = typer.closure_type(closure_def_id, substs);
|
||||
|
|
@ -372,7 +372,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
|
|||
let llref_bare_fn_ty = tcx.mk_bare_fn(ty::BareFnTy { unsafety: unsafety,
|
||||
abi: abi,
|
||||
sig: sig.clone() });
|
||||
let llref_fn_ty = ty::mk_bare_fn(tcx, None, llref_bare_fn_ty);
|
||||
let llref_fn_ty = tcx.mk_fn(None, llref_bare_fn_ty);
|
||||
debug!("trans_fn_once_adapter_shim: llref_fn_ty={:?}",
|
||||
llref_fn_ty);
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
|
|||
let llonce_bare_fn_ty = tcx.mk_bare_fn(ty::BareFnTy { unsafety: unsafety,
|
||||
abi: abi,
|
||||
sig: sig });
|
||||
let llonce_fn_ty = ty::mk_bare_fn(tcx, None, llonce_bare_fn_ty);
|
||||
let llonce_fn_ty = tcx.mk_fn(None, llonce_bare_fn_ty);
|
||||
|
||||
// Create the by-value helper.
|
||||
let function_name = link::mangle_internal_name_by_type_and_seq(ccx, llonce_fn_ty, "once_shim");
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
// Don't copy data to do a deref+ref
|
||||
// (i.e., skip the last auto-deref).
|
||||
llconst = addr_of(cx, llconst, "autoref");
|
||||
ty = ty::mk_imm_rptr(cx.tcx(), cx.tcx().mk_region(ty::ReStatic), ty);
|
||||
ty = cx.tcx().mk_imm_ref(cx.tcx().mk_region(ty::ReStatic), ty);
|
||||
}
|
||||
} else {
|
||||
let (dv, dt) = const_deref(cx, llconst, ty);
|
||||
|
|
|
|||
|
|
@ -791,7 +791,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
|
|||
($name:expr, fn() -> $ret:expr) => (
|
||||
if *key == $name {
|
||||
let f = declare::declare_cfn(ccx, $name, Type::func(&[], &$ret),
|
||||
ty::mk_nil(ccx.tcx()));
|
||||
ccx.tcx().mk_nil());
|
||||
ccx.intrinsics().borrow_mut().insert($name, f.clone());
|
||||
return Some(f);
|
||||
}
|
||||
|
|
@ -799,7 +799,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
|
|||
($name:expr, fn($($arg:expr),*) -> $ret:expr) => (
|
||||
if *key == $name {
|
||||
let f = declare::declare_cfn(ccx, $name, Type::func(&[$($arg),*], &$ret),
|
||||
ty::mk_nil(ccx.tcx()));
|
||||
ccx.tcx().mk_nil());
|
||||
ccx.intrinsics().borrow_mut().insert($name, f.clone());
|
||||
return Some(f);
|
||||
}
|
||||
|
|
@ -939,7 +939,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
|
|||
} else if *key == $name {
|
||||
let f = declare::declare_cfn(ccx, stringify!($cname),
|
||||
Type::func(&[$($arg),*], &void),
|
||||
ty::mk_nil(ccx.tcx()));
|
||||
ccx.tcx().mk_nil());
|
||||
llvm::SetLinkage(f, llvm::InternalLinkage);
|
||||
|
||||
let bld = ccx.builder();
|
||||
|
|
@ -962,7 +962,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
|
|||
} else if *key == $name {
|
||||
let f = declare::declare_cfn(ccx, stringify!($cname),
|
||||
Type::func(&[$($arg),*], &$ret),
|
||||
ty::mk_nil(ccx.tcx()));
|
||||
ccx.tcx().mk_nil());
|
||||
ccx.intrinsics().borrow_mut().insert($name, f.clone());
|
||||
return Some(f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
unique_type_id: UniqueTypeId,
|
||||
span: Span)
|
||||
-> MetadataCreationResult {
|
||||
let data_ptr_type = ty::mk_ptr(cx.tcx(), ty::mt {
|
||||
let data_ptr_type = cx.tcx().mk_ptr(ty::mt {
|
||||
ty: element_type,
|
||||
mutbl: ast::MutImmutable
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1110,7 +1110,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
None,
|
||||
expr.span,
|
||||
expr.id,
|
||||
ty::mk_struct(tcx, did, tcx.mk_substs(substs)),
|
||||
tcx.mk_struct(did, tcx.mk_substs(substs)),
|
||||
dest)
|
||||
} else {
|
||||
tcx.sess.span_bug(expr.span,
|
||||
|
|
@ -1697,7 +1697,7 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
fn ref_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
lval: Datum<'tcx, Lvalue>)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let dest_ty = ty::mk_imm_rptr(bcx.tcx(), bcx.tcx().mk_region(ty::ReStatic), lval.ty);
|
||||
let dest_ty = bcx.tcx().mk_imm_ref(bcx.tcx().mk_region(ty::ReStatic), lval.ty);
|
||||
let scratch = rvalue_scratch_datum(bcx, dest_ty, "__fat_ptr");
|
||||
memcpy_ty(bcx, scratch.val, lval.val, scratch.ty);
|
||||
|
||||
|
|
@ -2180,7 +2180,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(), bcx.tcx().mk_region(ty::ReStatic), referent_ty);
|
||||
let ptr_ty = bcx.tcx().mk_imm_ref(bcx.tcx().mk_region(ty::ReStatic), referent_ty);
|
||||
|
||||
// Get the pointer.
|
||||
let llref = lv_datum.to_llref();
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ pub fn decl_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
_ => panic!("expected bare fn in decl_rust_fn_with_foreign_abi")
|
||||
};
|
||||
let llfn = declare::declare_fn(ccx, name, cconv, llfn_ty,
|
||||
ty::FnConverging(ty::mk_nil(ccx.tcx())));
|
||||
ty::FnConverging(ccx.tcx().mk_nil()));
|
||||
add_argument_attributes(&tys, llfn);
|
||||
debug!("decl_rust_fn_with_foreign_abi(llfn_ty={}, llfn={})",
|
||||
ccx.tn().type_to_string(llfn_ty), ccx.tn().val_to_string(llfn));
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let llty = if type_is_sized(ccx.tcx(), t) {
|
||||
type_of(ccx, t).ptr_to()
|
||||
} else {
|
||||
type_of(ccx, ty::mk_uniq(ccx.tcx(), t)).ptr_to()
|
||||
type_of(ccx, ccx.tcx().mk_box(t)).ptr_to()
|
||||
};
|
||||
|
||||
let llfnty = Type::glue_fn(ccx, llty);
|
||||
|
|
@ -226,13 +226,13 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
// To avoid infinite recursion, don't `make_drop_glue` until after we've
|
||||
// added the entry to the `drop_glues` cache.
|
||||
if let Some(old_sym) = ccx.available_drop_glues().borrow().get(&g) {
|
||||
let llfn = declare::declare_cfn(ccx, &old_sym, llfnty, ty::mk_nil(ccx.tcx()));
|
||||
let llfn = declare::declare_cfn(ccx, &old_sym, llfnty, ccx.tcx().mk_nil());
|
||||
ccx.drop_glues().borrow_mut().insert(g, llfn);
|
||||
return llfn;
|
||||
};
|
||||
|
||||
let fn_nm = mangle_internal_name_by_type_and_seq(ccx, t, "drop");
|
||||
let llfn = declare::define_cfn(ccx, &fn_nm, llfnty, ty::mk_nil(ccx.tcx())).unwrap_or_else(||{
|
||||
let llfn = declare::define_cfn(ccx, &fn_nm, llfnty, ccx.tcx().mk_nil()).unwrap_or_else(||{
|
||||
ccx.sess().bug(&format!("symbol `{}` already defined", fn_nm));
|
||||
});
|
||||
ccx.available_drop_glues().borrow_mut().insert(g, fn_nm);
|
||||
|
|
@ -243,10 +243,10 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let (arena, fcx): (TypedArena<_>, FunctionContext);
|
||||
arena = TypedArena::new();
|
||||
fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false,
|
||||
ty::FnConverging(ty::mk_nil(ccx.tcx())),
|
||||
ty::FnConverging(ccx.tcx().mk_nil()),
|
||||
empty_substs, None, &arena);
|
||||
|
||||
let bcx = init_function(&fcx, false, ty::FnConverging(ty::mk_nil(ccx.tcx())));
|
||||
let bcx = init_function(&fcx, false, ty::FnConverging(ccx.tcx().mk_nil()));
|
||||
|
||||
update_linkage(ccx, llfn, None, OriginalTranslation);
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
let llrawptr0 = get_param(llfn, fcx.arg_offset() as c_uint);
|
||||
let bcx = make_drop_glue(bcx, llrawptr0, g);
|
||||
finish_fn(&fcx, bcx, ty::FnConverging(ty::mk_nil(ccx.tcx())), DebugLoc::None);
|
||||
finish_fn(&fcx, bcx, ty::FnConverging(ccx.tcx().mk_nil()), DebugLoc::None);
|
||||
|
||||
llfn
|
||||
}
|
||||
|
|
@ -328,10 +328,9 @@ pub fn get_res_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let name = csearch::get_symbol(&ccx.sess().cstore, did);
|
||||
let class_ty = ty::lookup_item_type(tcx, parent_id).ty.subst(tcx, substs);
|
||||
let llty = type_of_dtor(ccx, class_ty);
|
||||
let dtor_ty = ty::mk_ctor_fn(ccx.tcx(),
|
||||
did,
|
||||
&[get_drop_glue_type(ccx, t)],
|
||||
ty::mk_nil(ccx.tcx()));
|
||||
let dtor_ty = ccx.tcx().mk_ctor_fn(did,
|
||||
&[get_drop_glue_type(ccx, t)],
|
||||
ccx.tcx().mk_nil());
|
||||
foreign::get_extern_fn(ccx, &mut *ccx.externs().borrow_mut(), &name[..], llvm::CCallConv,
|
||||
llty, dtor_ty)
|
||||
}
|
||||
|
|
@ -371,7 +370,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
bcx.fcx.schedule_drop_adt_contents(cleanup::CustomScope(contents_scope), v0, t);
|
||||
|
||||
let glue_type = get_drop_glue_type(bcx.ccx(), t);
|
||||
let dtor_ty = ty::mk_ctor_fn(bcx.tcx(), class_did, &[glue_type], ty::mk_nil(bcx.tcx()));
|
||||
let dtor_ty = bcx.tcx().mk_ctor_fn(class_did, &[glue_type], bcx.tcx().mk_nil());
|
||||
let (_, bcx) = invoke(bcx, dtor_addr, &[v0], dtor_ty, DebugLoc::None);
|
||||
|
||||
bcx.fcx.pop_and_trans_custom_cleanup_scope(bcx, contents_scope)
|
||||
|
|
|
|||
|
|
@ -584,8 +584,8 @@ pub fn trans_object_shim<'a, 'tcx>(
|
|||
debug!("trans_object_shim: fty={:?} method_ty={:?}", fty, method_ty);
|
||||
|
||||
//
|
||||
let shim_fn_ty = ty::mk_bare_fn(tcx, None, fty);
|
||||
let method_bare_fn_ty = ty::mk_bare_fn(tcx, None, method_ty);
|
||||
let shim_fn_ty = tcx.mk_fn(None, fty);
|
||||
let method_bare_fn_ty = tcx.mk_fn(None, method_ty);
|
||||
let function_name = link::mangle_internal_name_by_type_and_seq(ccx, shim_fn_ty, "object_shim");
|
||||
let llfn = declare::define_internal_rust_fn(ccx, &function_name, shim_fn_ty).unwrap_or_else(||{
|
||||
ccx.sess().bug(&format!("symbol `{}` already defined", function_name));
|
||||
|
|
@ -827,7 +827,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
pub fn opaque_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>)
|
||||
-> &'tcx ty::BareFnTy<'tcx> {
|
||||
let mut inputs = method_ty.sig.0.inputs.clone();
|
||||
inputs[0] = ty::mk_mut_ptr(tcx, ty::mk_mach_int(tcx, ast::TyI8));
|
||||
inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(ast::TyI8));
|
||||
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: method_ty.unsafety,
|
||||
|
|
|
|||
|
|
@ -106,9 +106,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let count = elements_required(bcx, content_expr);
|
||||
debug!(" vt={}, count={}", vt.to_string(ccx), count);
|
||||
|
||||
let fixed_ty = ty::mk_vec(bcx.tcx(),
|
||||
vt.unit_ty,
|
||||
Some(count));
|
||||
let fixed_ty = bcx.tcx().mk_array(vt.unit_ty, count);
|
||||
let llfixed_ty = type_of::type_of(bcx.ccx(), fixed_ty);
|
||||
|
||||
// Always create an alloca even if zero-sized, to preserve
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ pub fn arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
|
|||
/// For the raw type without far pointer indirection, see `in_memory_type_of`.
|
||||
pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type {
|
||||
let ty = if !type_is_sized(cx.tcx(), ty) {
|
||||
ty::mk_imm_ptr(cx.tcx(), ty)
|
||||
cx.tcx().mk_imm_ptr(ty)
|
||||
} else {
|
||||
ty
|
||||
};
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ fn convert_parenthesized_parameters<'tcx>(this: &AstConv<'tcx>,
|
|||
let (implied_output_region,
|
||||
params_lifetimes) = find_implied_output_region(&*inputs, input_params);
|
||||
|
||||
let input_ty = ty::mk_tup(this.tcx(), inputs);
|
||||
let input_ty = this.tcx().mk_tup(inputs);
|
||||
|
||||
let (output, output_span) = match data.output {
|
||||
Some(ref output_ty) => {
|
||||
|
|
@ -590,7 +590,7 @@ fn convert_parenthesized_parameters<'tcx>(this: &AstConv<'tcx>,
|
|||
output_ty.span)
|
||||
}
|
||||
None => {
|
||||
(ty::mk_nil(this.tcx()), data.span)
|
||||
(this.tcx().mk_nil(), data.span)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -852,7 +852,7 @@ fn ast_type_binding_to_poly_projection_predicate<'tcx>(
|
|||
// this, we currently insert a dummy type and then remove it
|
||||
// later. Yuck.
|
||||
|
||||
let dummy_self_ty = ty::mk_infer(tcx, ty::FreshTy(0));
|
||||
let dummy_self_ty = tcx.mk_infer(ty::FreshTy(0));
|
||||
if self_ty.is_none() { // if converting for an object type
|
||||
let mut dummy_substs = trait_ref.skip_binder().substs.clone(); // binder moved here -+
|
||||
assert!(dummy_substs.self_ty().is_none()); // |
|
||||
|
|
@ -924,7 +924,7 @@ fn ast_path_to_ty<'tcx>(
|
|||
// FIXME(#12938): This is a hack until we have full support for DST.
|
||||
if Some(did) == this.tcx().lang_items.owned_box() {
|
||||
assert_eq!(substs.types.len(TypeSpace), 1);
|
||||
return ty::mk_uniq(this.tcx(), *substs.types.get(TypeSpace, 0));
|
||||
return this.tcx().mk_box(*substs.types.get(TypeSpace, 0));
|
||||
}
|
||||
|
||||
decl_ty.subst(this.tcx(), &substs)
|
||||
|
|
@ -1081,7 +1081,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>,
|
|||
ty::item_path_str(tcx, trait_def_id));
|
||||
}
|
||||
|
||||
ty::mk_trait(tcx, object.principal, object.bounds)
|
||||
tcx.mk_trait(object.principal, object.bounds)
|
||||
}
|
||||
|
||||
fn report_ambiguous_associated_type(tcx: &ty::ctxt,
|
||||
|
|
@ -1393,7 +1393,7 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
}
|
||||
def::DefTyParam(space, index, _, name) => {
|
||||
check_path_args(tcx, base_segments, NO_TPS | NO_REGIONS);
|
||||
ty::mk_param(tcx, space, index, name)
|
||||
tcx.mk_param(space, index, name)
|
||||
}
|
||||
def::DefSelfTy(_, Some((_, self_ty_id))) => {
|
||||
// Self in impl (we know the concrete type).
|
||||
|
|
@ -1411,7 +1411,7 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
def::DefSelfTy(Some(_), None) => {
|
||||
// Self in trait.
|
||||
check_path_args(tcx, base_segments, NO_TPS | NO_REGIONS);
|
||||
ty::mk_self_type(tcx)
|
||||
tcx.mk_self_type()
|
||||
}
|
||||
def::DefAssociatedTy(trait_did, _) => {
|
||||
check_path_args(tcx, &base_segments[..base_segments.len()-2], NO_TPS | NO_REGIONS);
|
||||
|
|
@ -1509,7 +1509,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
|
||||
let typ = match ast_ty.node {
|
||||
ast::TyVec(ref ty) => {
|
||||
ty::mk_vec(tcx, ast_ty_to_ty(this, rscope, &**ty), None)
|
||||
tcx.mk_slice(ast_ty_to_ty(this, rscope, &**ty))
|
||||
}
|
||||
ast::TyObjectSum(ref ty, ref bounds) => {
|
||||
match ast_ty_to_trait_ref(this, rscope, &**ty, bounds) {
|
||||
|
|
@ -1527,7 +1527,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
}
|
||||
}
|
||||
ast::TyPtr(ref mt) => {
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: ast_ty_to_ty(this, rscope, &*mt.ty),
|
||||
mutbl: mt.mutbl
|
||||
})
|
||||
|
|
@ -1540,13 +1540,13 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
rscope,
|
||||
Some(ty::ObjectLifetimeDefault::Specific(r)));
|
||||
let t = ast_ty_to_ty(this, rscope1, &*mt.ty);
|
||||
ty::mk_rptr(tcx, tcx.mk_region(r), ty::mt {ty: t, mutbl: mt.mutbl})
|
||||
tcx.mk_ref(tcx.mk_region(r), ty::mt {ty: t, mutbl: mt.mutbl})
|
||||
}
|
||||
ast::TyTup(ref fields) => {
|
||||
let flds = fields.iter()
|
||||
.map(|t| ast_ty_to_ty(this, rscope, &**t))
|
||||
.collect();
|
||||
ty::mk_tup(tcx, flds)
|
||||
tcx.mk_tup(flds)
|
||||
}
|
||||
ast::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ),
|
||||
ast::TyBareFn(ref bf) => {
|
||||
|
|
@ -1555,7 +1555,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
"variadic function must have C calling convention");
|
||||
}
|
||||
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))
|
||||
tcx.mk_fn(None, tcx.mk_bare_fn(bare_fn))
|
||||
}
|
||||
ast::TyPolyTraitRef(ref bounds) => {
|
||||
conv_ty_poly_trait_ref(this, rscope, ast_ty.span, bounds)
|
||||
|
|
@ -1603,11 +1603,11 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
|
|||
Ok(r) => {
|
||||
match r {
|
||||
ConstVal::Int(i) =>
|
||||
ty::mk_vec(tcx, ast_ty_to_ty(this, rscope, &**ty),
|
||||
Some(i as usize)),
|
||||
tcx.mk_array(ast_ty_to_ty(this, rscope, &**ty),
|
||||
i as usize),
|
||||
ConstVal::Uint(i) =>
|
||||
ty::mk_vec(tcx, ast_ty_to_ty(this, rscope, &**ty),
|
||||
Some(i as usize)),
|
||||
tcx.mk_array(ast_ty_to_ty(this, rscope, &**ty),
|
||||
i as usize),
|
||||
_ => {
|
||||
span_err!(tcx.sess, ast_ty.span, E0249,
|
||||
"expected constant integer expression \
|
||||
|
|
@ -1724,7 +1724,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
|
|||
(Some(self_info.untransformed_self_ty), None)
|
||||
}
|
||||
ty::ByReferenceExplicitSelfCategory(region, mutability) => {
|
||||
(Some(ty::mk_rptr(this.tcx(),
|
||||
(Some(this.tcx().mk_ref(
|
||||
this.tcx().mk_region(region),
|
||||
ty::mt {
|
||||
ty: self_info.untransformed_self_ty,
|
||||
|
|
@ -1733,7 +1733,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
|
|||
Some(region))
|
||||
}
|
||||
ty::ByBoxExplicitSelfCategory => {
|
||||
(Some(ty::mk_uniq(this.tcx(), self_info.untransformed_self_ty)), None)
|
||||
(Some(this.tcx().mk_box(self_info.untransformed_self_ty)), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1779,7 +1779,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
|
|||
implied_output_region,
|
||||
lifetimes_for_params,
|
||||
&**output)),
|
||||
ast::DefaultReturn(..) => ty::FnConverging(ty::mk_nil(this.tcx())),
|
||||
ast::DefaultReturn(..) => ty::FnConverging(this.tcx().mk_nil()),
|
||||
ast::NoReturn(..) => ty::FnDiverging
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
|
||||
if let ty::TyRef(_, mt) = expected_ty.sty {
|
||||
if let ty::TySlice(_) = mt.ty.sty {
|
||||
pat_ty = ty::mk_slice(tcx, tcx.mk_region(ty::ReStatic),
|
||||
ty::mt{ ty: tcx.types.u8, mutbl: ast::MutImmutable })
|
||||
pat_ty = tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic),
|
||||
tcx.mk_slice(tcx.types.u8))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -171,7 +171,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, tcx.mk_region(region_var), mt);
|
||||
let region_ty = tcx.mk_ref(tcx.mk_region(region_var), mt);
|
||||
|
||||
// `x` is assigned a value of type `&M T`, hence `&M T <: typeof(x)` is
|
||||
// required. However, we use equality, which is stronger. See (*) for
|
||||
|
|
@ -246,7 +246,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let element_tys: Vec<_> =
|
||||
(0..elements.len()).map(|_| fcx.infcx().next_ty_var())
|
||||
.collect();
|
||||
let pat_ty = ty::mk_tup(tcx, element_tys.clone());
|
||||
let pat_ty = tcx.mk_tup(element_tys.clone());
|
||||
fcx.write_ty(pat.id, pat_ty);
|
||||
demand::eqtype(fcx, pat.span, expected, pat_ty);
|
||||
for (element_pat, element_ty) in elements.iter().zip(element_tys) {
|
||||
|
|
@ -255,7 +255,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
}
|
||||
ast::PatBox(ref inner) => {
|
||||
let inner_ty = fcx.infcx().next_ty_var();
|
||||
let uniq_ty = ty::mk_uniq(tcx, inner_ty);
|
||||
let uniq_ty = tcx.mk_box(inner_ty);
|
||||
|
||||
if check_dereferencable(pcx, pat.span, expected, &**inner) {
|
||||
// Here, `demand::subtype` is good enough, but I don't
|
||||
|
|
@ -274,7 +274,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, tcx.mk_region(region), mt);
|
||||
let rptr_ty = tcx.mk_ref(tcx.mk_region(region), mt);
|
||||
|
||||
if check_dereferencable(pcx, pat.span, expected, &**inner) {
|
||||
// `demand::subtype` would be good enough, but using
|
||||
|
|
@ -292,17 +292,17 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
|
||||
let inner_ty = fcx.infcx().next_ty_var();
|
||||
let pat_ty = match expected_ty.sty {
|
||||
ty::TyArray(_, size) => ty::mk_vec(tcx, inner_ty, Some({
|
||||
ty::TyArray(_, size) => tcx.mk_array(inner_ty, {
|
||||
let min_len = before.len() + after.len();
|
||||
match *slice {
|
||||
Some(_) => cmp::max(min_len, size),
|
||||
None => min_len
|
||||
}
|
||||
})),
|
||||
}),
|
||||
_ => {
|
||||
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
|
||||
ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
|
||||
ty: inner_ty,
|
||||
tcx.mk_ref(tcx.mk_region(region), ty::mt {
|
||||
ty: tcx.mk_slice(inner_ty),
|
||||
mutbl: expected_ty.builtin_deref(true).map(|mt| mt.mutbl)
|
||||
.unwrap_or(ast::MutImmutable)
|
||||
})
|
||||
|
|
@ -324,8 +324,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
let mutbl = expected_ty.builtin_deref(true)
|
||||
.map_or(ast::MutImmutable, |mt| mt.mutbl);
|
||||
|
||||
let slice_ty = ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
|
||||
ty: inner_ty,
|
||||
let slice_ty = tcx.mk_ref(tcx.mk_region(region), ty::mt {
|
||||
ty: tcx.mk_slice(inner_ty),
|
||||
mutbl: mutbl
|
||||
});
|
||||
check_pat(pcx, &**slice, slice_ty);
|
||||
|
|
@ -485,7 +485,7 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// us to give better error messages (pointing to a usually better
|
||||
// arm for inconsistent arms or to the whole match when a `()` type
|
||||
// is required).
|
||||
Expectation::ExpectHasType(ety) if ety != ty::mk_nil(fcx.tcx()) => {
|
||||
Expectation::ExpectHasType(ety) if ety != fcx.tcx().mk_nil() => {
|
||||
check_expr_coercable_to_type(fcx, &*arm.body, ety);
|
||||
ety
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> {
|
|||
demand::eqtype(fcx, self.call_expr.span, self_arg_ty, method_arg_ty);
|
||||
}
|
||||
|
||||
let nilty = ty::mk_nil(fcx.tcx());
|
||||
let nilty = fcx.tcx().mk_nil();
|
||||
demand::eqtype(fcx,
|
||||
self.call_expr.span,
|
||||
method_sig.output.unwrap_or(nilty),
|
||||
|
|
|
|||
|
|
@ -60,10 +60,8 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
|||
abi::RustCall,
|
||||
expected_sig);
|
||||
|
||||
let closure_type = ty::mk_closure(fcx.ccx.tcx,
|
||||
expr_def_id,
|
||||
fcx.ccx.tcx.mk_substs(
|
||||
fcx.inh.param_env.free_substs.clone()));
|
||||
let closure_type = fcx.ccx.tcx.mk_closure(expr_def_id,
|
||||
fcx.ccx.tcx.mk_substs(fcx.inh.param_env.free_substs.clone()));
|
||||
|
||||
fcx.write_ty(expr.id, closure_type);
|
||||
|
||||
|
|
@ -83,7 +81,7 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
|||
|
||||
// Tuple up the arguments and insert the resulting function type into
|
||||
// the `closures` table.
|
||||
fn_ty.sig.0.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.0.inputs)];
|
||||
fn_ty.sig.0.inputs = vec![fcx.tcx().mk_tup(fn_ty.sig.0.inputs)];
|
||||
|
||||
debug!("closure for {:?} --> sig={:?} opt_kind={:?}",
|
||||
expr_def_id,
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
// &T to autoref to &&T.
|
||||
return None;
|
||||
}
|
||||
let ty = ty::mk_rptr(self.tcx(), r_borrow,
|
||||
mt {ty: inner_ty, mutbl: mutbl_b});
|
||||
let ty = self.tcx().mk_ref(r_borrow,
|
||||
mt {ty: inner_ty, mutbl: mutbl_b});
|
||||
if let Err(err) = self.subtype(ty, b) {
|
||||
if first_error.is_none() {
|
||||
first_error = Some(err);
|
||||
|
|
@ -384,7 +384,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
|
||||
match b.sty {
|
||||
ty::TyBareFn(None, _) => {
|
||||
let a_fn_pointer = ty::mk_bare_fn(self.tcx(), None, fn_ty_a);
|
||||
let a_fn_pointer = self.tcx().mk_fn(None, fn_ty_a);
|
||||
try!(self.subtype(a_fn_pointer, b));
|
||||
Ok(Some(ty::AdjustReifyFnPointer))
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
};
|
||||
|
||||
// Check that the types which they point at are compatible.
|
||||
let a_unsafe = ty::mk_ptr(self.tcx(), ty::mt{ mutbl: mutbl_b, ty: mt_a.ty });
|
||||
let a_unsafe = self.tcx().mk_ptr(ty::mt{ mutbl: mutbl_b, ty: mt_a.ty });
|
||||
try!(self.subtype(a_unsafe, b));
|
||||
try!(coerce_mutbls(mt_a.mutbl, mutbl_b));
|
||||
|
||||
|
|
|
|||
|
|
@ -275,9 +275,9 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
// type.
|
||||
|
||||
// Compute skolemized form of impl and trait method tys.
|
||||
let impl_fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(impl_m.fty.clone()));
|
||||
let impl_fty = tcx.mk_fn(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, tcx.mk_bare_fn(trait_m.fty.clone()));
|
||||
let trait_fty = tcx.mk_fn(None, tcx.mk_bare_fn(trait_m.fty.clone()));
|
||||
let trait_fty = trait_fty.subst(tcx, &trait_to_skol_substs);
|
||||
|
||||
let err = infcx.commit_if_ok(|snapshot| {
|
||||
|
|
@ -296,12 +296,11 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
impl_m_span,
|
||||
impl_m_body_id,
|
||||
&impl_sig);
|
||||
let impl_fty =
|
||||
ty::mk_bare_fn(tcx,
|
||||
None,
|
||||
tcx.mk_bare_fn(ty::BareFnTy { unsafety: impl_m.fty.unsafety,
|
||||
abi: impl_m.fty.abi,
|
||||
sig: ty::Binder(impl_sig) }));
|
||||
let impl_fty = tcx.mk_fn(None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: impl_m.fty.unsafety,
|
||||
abi: impl_m.fty.abi,
|
||||
sig: ty::Binder(impl_sig)
|
||||
}));
|
||||
debug!("compare_impl_method: impl_fty={:?}",
|
||||
impl_fty);
|
||||
|
||||
|
|
@ -316,12 +315,11 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
impl_m_span,
|
||||
impl_m_body_id,
|
||||
&trait_sig);
|
||||
let trait_fty =
|
||||
ty::mk_bare_fn(tcx,
|
||||
None,
|
||||
tcx.mk_bare_fn(ty::BareFnTy { unsafety: trait_m.fty.unsafety,
|
||||
abi: trait_m.fty.abi,
|
||||
sig: ty::Binder(trait_sig) }));
|
||||
let trait_fty = tcx.mk_fn(None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: trait_m.fty.unsafety,
|
||||
abi: trait_m.fty.abi,
|
||||
sig: ty::Binder(trait_sig)
|
||||
}));
|
||||
|
||||
debug!("compare_impl_method: trait_fty={:?}",
|
||||
trait_fty);
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
|
||||
// Create the final `MethodCallee`.
|
||||
let method_ty = pick.item.as_opt_method().unwrap();
|
||||
let fty = ty::mk_bare_fn(self.tcx(), None, self.tcx().mk_bare_fn(ty::BareFnTy {
|
||||
let fty = self.tcx().mk_fn(None, self.tcx().mk_bare_fn(ty::BareFnTy {
|
||||
sig: ty::Binder(method_sig),
|
||||
unsafety: method_ty.fty.unsafety,
|
||||
abi: method_ty.fty.abi.clone(),
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
&method_ty.fty.sig).0;
|
||||
let fn_sig = fcx.instantiate_type_scheme(span, trait_ref.substs, &fn_sig);
|
||||
let transformed_self_ty = fn_sig.inputs[0];
|
||||
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
let fty = tcx.mk_fn(None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
sig: ty::Binder(fn_sig),
|
||||
unsafety: method_ty.fty.unsafety,
|
||||
abi: method_ty.fty.abi.clone(),
|
||||
|
|
|
|||
|
|
@ -218,9 +218,8 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
|
||||
match final_ty.sty {
|
||||
ty::TyArray(elem_ty, _) => {
|
||||
let slice_ty = ty::mk_vec(fcx.tcx(), elem_ty, None);
|
||||
steps.push(CandidateStep {
|
||||
self_ty: slice_ty,
|
||||
self_ty: fcx.tcx().mk_slice(elem_ty),
|
||||
autoderefs: dereferences,
|
||||
unsize: true
|
||||
});
|
||||
|
|
@ -984,7 +983,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||
|
||||
// Search through mutabilities in order to find one where pick works:
|
||||
[ast::MutImmutable, ast::MutMutable].iter().filter_map(|&m| {
|
||||
let autoref_ty = ty::mk_rptr(tcx, region, ty::mt {
|
||||
let autoref_ty = tcx.mk_ref(region, ty::mt {
|
||||
ty: step.self_ty,
|
||||
mutbl: m
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1377,7 +1377,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
for (_, &mut ref ty) in &mut *self.inh.node_types.borrow_mut() {
|
||||
let resolved = self.infcx().resolve_type_vars_if_possible(ty);
|
||||
if self.infcx().type_var_diverges(resolved) {
|
||||
demand::eqtype(self, codemap::DUMMY_SP, *ty, ty::mk_nil(self.tcx()));
|
||||
demand::eqtype(self, codemap::DUMMY_SP, *ty, self.tcx().mk_nil());
|
||||
} else {
|
||||
match self.infcx().type_is_unconstrained_numeric(resolved) {
|
||||
UnconstrainedInt => {
|
||||
|
|
@ -1557,7 +1557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn write_nil(&self, node_id: ast::NodeId) {
|
||||
self.write_ty(node_id, ty::mk_nil(self.tcx()));
|
||||
self.write_ty(node_id, self.tcx().mk_nil());
|
||||
}
|
||||
pub fn write_error(&self, node_id: ast::NodeId) {
|
||||
self.write_ty(node_id, self.tcx().types.err);
|
||||
|
|
@ -2089,7 +2089,7 @@ fn lookup_indexing<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// After we have fully autoderef'd, if the resulting type is [T; n], then
|
||||
// do a final unsized coercion to yield [T].
|
||||
if let ty::TyArray(element_ty, _) = ty.sty {
|
||||
let adjusted_ty = ty::mk_vec(fcx.tcx(), element_ty, None);
|
||||
let adjusted_ty = fcx.tcx().mk_slice(element_ty);
|
||||
try_index_step(fcx, MethodCall::expr(expr.id), expr, base_expr,
|
||||
adjusted_ty, autoderefs, true, lvalue_pref, idx_ty)
|
||||
} else {
|
||||
|
|
@ -2191,7 +2191,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
|
||||
let err_inputs = match tuple_arguments {
|
||||
DontTupleArguments => err_inputs,
|
||||
TupleArguments => vec![ty::mk_tup(fcx.tcx(), err_inputs)],
|
||||
TupleArguments => vec![fcx.tcx().mk_tup(err_inputs)],
|
||||
};
|
||||
|
||||
check_argument_types(fcx,
|
||||
|
|
@ -2433,17 +2433,15 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let tcx = fcx.ccx.tcx;
|
||||
|
||||
match lit.node {
|
||||
ast::LitStr(..) => ty::mk_str_slice(tcx, tcx.mk_region(ty::ReStatic), ast::MutImmutable),
|
||||
ast::LitStr(..) => tcx.mk_static_str(),
|
||||
ast::LitBinary(ref v) => {
|
||||
ty::mk_rptr(tcx, tcx.mk_region(ty::ReStatic), ty::mt {
|
||||
ty: ty::mk_vec(tcx, tcx.types.u8, Some(v.len())),
|
||||
mutbl: ast::MutImmutable,
|
||||
})
|
||||
tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic),
|
||||
tcx.mk_array(tcx.types.u8, v.len()))
|
||||
}
|
||||
ast::LitByte(_) => tcx.types.u8,
|
||||
ast::LitChar(_) => tcx.types.char,
|
||||
ast::LitInt(_, ast::SignedIntLit(t, _)) => ty::mk_mach_int(tcx, t),
|
||||
ast::LitInt(_, ast::UnsignedIntLit(t)) => ty::mk_mach_uint(tcx, t),
|
||||
ast::LitInt(_, ast::SignedIntLit(t, _)) => tcx.mk_mach_int(t),
|
||||
ast::LitInt(_, ast::UnsignedIntLit(t)) => tcx.mk_mach_uint(t),
|
||||
ast::LitInt(_, ast::UnsuffixedIntLit(_)) => {
|
||||
let opt_ty = expected.to_option(fcx).and_then(|ty| {
|
||||
match ty.sty {
|
||||
|
|
@ -2455,9 +2453,9 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
});
|
||||
opt_ty.unwrap_or_else(
|
||||
|| ty::mk_int_var(tcx, fcx.infcx().next_int_var_id()))
|
||||
|| tcx.mk_int_var(fcx.infcx().next_int_var_id()))
|
||||
}
|
||||
ast::LitFloat(_, t) => ty::mk_mach_float(tcx, t),
|
||||
ast::LitFloat(_, t) => tcx.mk_mach_float(t),
|
||||
ast::LitFloatUnsuffixed(_) => {
|
||||
let opt_ty = expected.to_option(fcx).and_then(|ty| {
|
||||
match ty.sty {
|
||||
|
|
@ -2466,7 +2464,7 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
});
|
||||
opt_ty.unwrap_or_else(
|
||||
|| ty::mk_float_var(tcx, fcx.infcx().next_float_var_id()))
|
||||
|| tcx.mk_float_var(fcx.infcx().next_float_var_id()))
|
||||
}
|
||||
ast::LitBool(_) => tcx.types.bool
|
||||
}
|
||||
|
|
@ -2705,7 +2703,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
infer::IfExpressionWithNoElse(sp),
|
||||
false,
|
||||
then_ty,
|
||||
ty::mk_nil(fcx.tcx()))
|
||||
fcx.tcx().mk_nil())
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -2991,8 +2989,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
if !error_happened {
|
||||
fcx.write_ty(node_id, ty::mk_struct(fcx.ccx.tcx,
|
||||
class_id, substitutions));
|
||||
fcx.write_ty(node_id, fcx.ccx.tcx.mk_struct(class_id, substitutions));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3102,7 +3099,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let def_id = definition.def_id();
|
||||
let referent_ty = fcx.expr_ty(&**subexpr);
|
||||
if tcx.lang_items.exchange_heap() == Some(def_id) {
|
||||
fcx.write_ty(id, ty::mk_uniq(tcx, referent_ty));
|
||||
fcx.write_ty(id, tcx.mk_box(referent_ty));
|
||||
checked = true
|
||||
}
|
||||
}
|
||||
|
|
@ -3156,7 +3153,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
if !oprnd_t.references_error() {
|
||||
match unop {
|
||||
ast::UnUniq => {
|
||||
oprnd_t = ty::mk_uniq(tcx, oprnd_t);
|
||||
oprnd_t = tcx.mk_box(oprnd_t);
|
||||
}
|
||||
ast::UnDeref => {
|
||||
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
|
||||
|
|
@ -3247,7 +3244,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// value whose address was taken can actually be made to live
|
||||
// as long as it needs to live.
|
||||
let region = fcx.infcx().next_region_var(infer::AddrOfRegion(expr.span));
|
||||
ty::mk_rptr(tcx, tcx.mk_region(region), tm)
|
||||
tcx.mk_ref(tcx.mk_region(region), tm)
|
||||
};
|
||||
fcx.write_ty(id, oprnd_t);
|
||||
}
|
||||
|
|
@ -3308,7 +3305,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
match *expr_opt {
|
||||
None =>
|
||||
if let Err(_) = fcx.mk_eqty(false, infer::Misc(expr.span),
|
||||
result_type, ty::mk_nil(fcx.tcx())) {
|
||||
result_type, fcx.tcx().mk_nil()) {
|
||||
span_err!(tcx.sess, expr.span, E0069,
|
||||
"`return;` in a function whose return type is \
|
||||
not `()`");
|
||||
|
|
@ -3463,7 +3460,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
t
|
||||
}
|
||||
};
|
||||
let typ = ty::mk_vec(tcx, typ, Some(args.len()));
|
||||
let typ = tcx.mk_array(typ, args.len());
|
||||
fcx.write_ty(id, typ);
|
||||
}
|
||||
ast::ExprRepeat(ref element, ref count_expr) => {
|
||||
|
|
@ -3505,7 +3502,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
if element_ty.references_error() {
|
||||
fcx.write_error(id);
|
||||
} else {
|
||||
let t = ty::mk_vec(tcx, t, Some(count));
|
||||
let t = tcx.mk_array(t, count);
|
||||
fcx.write_ty(id, t);
|
||||
}
|
||||
}
|
||||
|
|
@ -3536,7 +3533,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
if err_field {
|
||||
fcx.write_error(id);
|
||||
} else {
|
||||
let typ = ty::mk_tup(tcx, elt_ts);
|
||||
let typ = tcx.mk_tup(elt_ts);
|
||||
fcx.write_ty(id, typ);
|
||||
}
|
||||
}
|
||||
|
|
@ -3712,7 +3709,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
traits::ItemObligation(did)),
|
||||
&bounds);
|
||||
|
||||
ty::mk_struct(tcx, did, tcx.mk_substs(substs))
|
||||
tcx.mk_struct(did, tcx.mk_substs(substs))
|
||||
} else {
|
||||
span_err!(tcx.sess, expr.span, E0236, "no lang item for range syntax");
|
||||
fcx.tcx().types.err
|
||||
|
|
@ -3722,7 +3719,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
// Neither start nor end => RangeFull
|
||||
if let Some(did) = tcx.lang_items.range_full_struct() {
|
||||
let substs = Substs::new_type(vec![], vec![]);
|
||||
ty::mk_struct(tcx, did, tcx.mk_substs(substs))
|
||||
tcx.mk_struct(did, tcx.mk_substs(substs))
|
||||
} else {
|
||||
span_err!(tcx.sess, expr.span, E0237, "no lang item for range syntax");
|
||||
fcx.tcx().types.err
|
||||
|
|
@ -3967,7 +3964,7 @@ pub fn check_stmt<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, stmt: &'tcx ast::Stmt) {
|
|||
ast::StmtExpr(ref expr, id) => {
|
||||
node_id = id;
|
||||
// Check with expected type of ()
|
||||
check_expr_has_type(fcx, &**expr, ty::mk_nil(fcx.tcx()));
|
||||
check_expr_has_type(fcx, &**expr, fcx.tcx().mk_nil());
|
||||
let expr_ty = fcx.expr_ty(&**expr);
|
||||
saw_bot = saw_bot || fcx.infcx().type_var_diverges(expr_ty);
|
||||
saw_err = saw_err || expr_ty.references_error();
|
||||
|
|
@ -3993,12 +3990,12 @@ pub fn check_stmt<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, stmt: &'tcx ast::Stmt) {
|
|||
}
|
||||
|
||||
pub fn check_block_no_value<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, blk: &'tcx ast::Block) {
|
||||
check_block_with_expected(fcx, blk, ExpectHasType(ty::mk_nil(fcx.tcx())));
|
||||
check_block_with_expected(fcx, blk, ExpectHasType(fcx.tcx().mk_nil()));
|
||||
let blkty = fcx.node_ty(blk.id);
|
||||
if blkty.references_error() {
|
||||
fcx.write_error(blk.id);
|
||||
} else {
|
||||
let nilty = ty::mk_nil(fcx.tcx());
|
||||
let nilty = fcx.tcx().mk_nil();
|
||||
demand::suptype(fcx, blk.span, nilty, blkty);
|
||||
}
|
||||
}
|
||||
|
|
@ -4734,8 +4731,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let input_tys: Vec<Ty> =
|
||||
data.inputs.iter().map(|ty| fcx.to_ty(&**ty)).collect();
|
||||
|
||||
let tuple_ty =
|
||||
ty::mk_tup(fcx.tcx(), input_tys);
|
||||
let tuple_ty = fcx.tcx().mk_tup(input_tys);
|
||||
|
||||
if type_count >= 1 {
|
||||
substs.types.push(space, tuple_ty);
|
||||
|
|
@ -4745,7 +4741,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
data.output.as_ref().map(|ty| fcx.to_ty(&**ty));
|
||||
|
||||
let output_ty =
|
||||
output_ty.unwrap_or(ty::mk_nil(fcx.tcx()));
|
||||
output_ty.unwrap_or(fcx.tcx().mk_nil());
|
||||
|
||||
if type_count >= 2 {
|
||||
substs.types.push(space, output_ty);
|
||||
|
|
@ -4952,7 +4948,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: u32) -> Ty<'tcx> {
|
||||
let name = token::intern(&format!("P{}", n));
|
||||
ty::mk_param(ccx.tcx, subst::FnSpace, n, name)
|
||||
ccx.tcx.mk_param(subst::FnSpace, n, name)
|
||||
}
|
||||
|
||||
let tcx = ccx.tcx;
|
||||
|
|
@ -4963,22 +4959,22 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
|
||||
//We only care about the operation here
|
||||
let (n_tps, inputs, output) = match split[1] {
|
||||
"cxchg" => (1, vec!(ty::mk_mut_ptr(tcx, param(ccx, 0)),
|
||||
"cxchg" => (1, vec!(tcx.mk_mut_ptr(param(ccx, 0)),
|
||||
param(ccx, 0),
|
||||
param(ccx, 0)),
|
||||
param(ccx, 0)),
|
||||
"load" => (1, vec!(ty::mk_imm_ptr(tcx, param(ccx, 0))),
|
||||
"load" => (1, vec!(tcx.mk_imm_ptr(param(ccx, 0))),
|
||||
param(ccx, 0)),
|
||||
"store" => (1, vec!(ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0)),
|
||||
ty::mk_nil(tcx)),
|
||||
"store" => (1, vec!(tcx.mk_mut_ptr(param(ccx, 0)), param(ccx, 0)),
|
||||
tcx.mk_nil()),
|
||||
|
||||
"xchg" | "xadd" | "xsub" | "and" | "nand" | "or" | "xor" | "max" |
|
||||
"min" | "umax" | "umin" => {
|
||||
(1, vec!(ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0)),
|
||||
(1, vec!(tcx.mk_mut_ptr(param(ccx, 0)), param(ccx, 0)),
|
||||
param(ccx, 0))
|
||||
}
|
||||
"fence" | "singlethreadfence" => {
|
||||
(0, Vec::new(), ty::mk_nil(tcx))
|
||||
(0, Vec::new(), tcx.mk_nil())
|
||||
}
|
||||
op => {
|
||||
span_err!(tcx.sess, it.span, E0092,
|
||||
|
|
@ -4991,50 +4987,47 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
(0, Vec::new(), ty::FnDiverging)
|
||||
} else {
|
||||
let (n_tps, inputs, output) = match &name[..] {
|
||||
"breakpoint" => (0, Vec::new(), ty::mk_nil(tcx)),
|
||||
"breakpoint" => (0, Vec::new(), tcx.mk_nil()),
|
||||
"size_of" |
|
||||
"pref_align_of" | "min_align_of" => (1, Vec::new(), ccx.tcx.types.usize),
|
||||
"size_of_val" | "min_align_of_val" => {
|
||||
(1, vec![
|
||||
ty::mk_imm_rptr(tcx,
|
||||
tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
tcx.mk_imm_ref(tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
ty::BrAnon(0))),
|
||||
param(ccx, 0))
|
||||
], ccx.tcx.types.usize)
|
||||
}
|
||||
"init" | "init_dropped" => (1, Vec::new(), param(ccx, 0)),
|
||||
"uninit" => (1, Vec::new(), param(ccx, 0)),
|
||||
"forget" => (1, vec!( param(ccx, 0) ), ty::mk_nil(tcx)),
|
||||
"forget" => (1, vec!( param(ccx, 0) ), tcx.mk_nil()),
|
||||
"transmute" => (2, vec!( param(ccx, 0) ), param(ccx, 1)),
|
||||
"move_val_init" => {
|
||||
(1,
|
||||
vec!(
|
||||
ty::mk_mut_rptr(tcx,
|
||||
tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
tcx.mk_mut_ref(tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
ty::BrAnon(0))),
|
||||
param(ccx, 0)),
|
||||
param(ccx, 0)
|
||||
),
|
||||
ty::mk_nil(tcx))
|
||||
tcx.mk_nil())
|
||||
}
|
||||
"drop_in_place" => {
|
||||
(1, vec![ty::mk_mut_ptr(tcx, param(ccx, 0))], ty::mk_nil(tcx))
|
||||
(1, vec![tcx.mk_mut_ptr(param(ccx, 0))], tcx.mk_nil())
|
||||
}
|
||||
"needs_drop" => (1, Vec::new(), ccx.tcx.types.bool),
|
||||
|
||||
"type_name" => (1, Vec::new(), ty::mk_str_slice(tcx, tcx.mk_region(ty::ReStatic),
|
||||
ast::MutImmutable)),
|
||||
"type_name" => (1, Vec::new(), tcx.mk_static_str()),
|
||||
"type_id" => (1, Vec::new(), ccx.tcx.types.u64),
|
||||
"offset" | "arith_offset" => {
|
||||
(1,
|
||||
vec!(
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutImmutable
|
||||
}),
|
||||
ccx.tcx.types.isize
|
||||
),
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutImmutable
|
||||
}))
|
||||
|
|
@ -5042,44 +5035,44 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
"copy" | "copy_nonoverlapping" => {
|
||||
(1,
|
||||
vec!(
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutImmutable
|
||||
}),
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutMutable
|
||||
}),
|
||||
tcx.types.usize,
|
||||
),
|
||||
ty::mk_nil(tcx))
|
||||
tcx.mk_nil())
|
||||
}
|
||||
"volatile_copy_memory" | "volatile_copy_nonoverlapping_memory" => {
|
||||
(1,
|
||||
vec!(
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutMutable
|
||||
}),
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutImmutable
|
||||
}),
|
||||
tcx.types.usize,
|
||||
),
|
||||
ty::mk_nil(tcx))
|
||||
tcx.mk_nil())
|
||||
}
|
||||
"write_bytes" | "volatile_set_memory" => {
|
||||
(1,
|
||||
vec!(
|
||||
ty::mk_ptr(tcx, ty::mt {
|
||||
tcx.mk_ptr(ty::mt {
|
||||
ty: param(ccx, 0),
|
||||
mutbl: ast::MutMutable
|
||||
}),
|
||||
tcx.types.u8,
|
||||
tcx.types.usize,
|
||||
),
|
||||
ty::mk_nil(tcx))
|
||||
tcx.mk_nil())
|
||||
}
|
||||
"sqrtf32" => (0, vec!( tcx.types.f32 ), tcx.types.f32),
|
||||
"sqrtf64" => (0, vec!( tcx.types.f64 ), tcx.types.f64),
|
||||
|
|
@ -5160,41 +5153,41 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
"bswap64" => (0, vec!( tcx.types.u64 ), tcx.types.u64),
|
||||
|
||||
"volatile_load" =>
|
||||
(1, vec!( ty::mk_imm_ptr(tcx, param(ccx, 0)) ), param(ccx, 0)),
|
||||
(1, vec!( tcx.mk_imm_ptr(param(ccx, 0)) ), param(ccx, 0)),
|
||||
"volatile_store" =>
|
||||
(1, vec!( ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0) ), ty::mk_nil(tcx)),
|
||||
(1, vec!( tcx.mk_mut_ptr(param(ccx, 0)), param(ccx, 0) ), tcx.mk_nil()),
|
||||
|
||||
"i8_add_with_overflow" | "i8_sub_with_overflow" | "i8_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.i8, tcx.types.i8),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.i8, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.i8, tcx.types.bool))),
|
||||
|
||||
"i16_add_with_overflow" | "i16_sub_with_overflow" | "i16_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.i16, tcx.types.i16),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.i16, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.i16, tcx.types.bool))),
|
||||
|
||||
"i32_add_with_overflow" | "i32_sub_with_overflow" | "i32_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.i32, tcx.types.i32),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.i32, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.i32, tcx.types.bool))),
|
||||
|
||||
"i64_add_with_overflow" | "i64_sub_with_overflow" | "i64_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.i64, tcx.types.i64),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.i64, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.i64, tcx.types.bool))),
|
||||
|
||||
"u8_add_with_overflow" | "u8_sub_with_overflow" | "u8_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.u8, tcx.types.u8),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.u8, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.u8, tcx.types.bool))),
|
||||
|
||||
"u16_add_with_overflow" | "u16_sub_with_overflow" | "u16_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.u16, tcx.types.u16),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.u16, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.u16, tcx.types.bool))),
|
||||
|
||||
"u32_add_with_overflow" | "u32_sub_with_overflow" | "u32_mul_with_overflow"=>
|
||||
(0, vec!(tcx.types.u32, tcx.types.u32),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.u32, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.u32, tcx.types.bool))),
|
||||
|
||||
"u64_add_with_overflow" | "u64_sub_with_overflow" | "u64_mul_with_overflow" =>
|
||||
(0, vec!(tcx.types.u64, tcx.types.u64),
|
||||
ty::mk_tup(tcx, vec!(tcx.types.u64, tcx.types.bool))),
|
||||
tcx.mk_tup(vec!(tcx.types.u64, tcx.types.bool))),
|
||||
|
||||
"unchecked_udiv" | "unchecked_sdiv" | "unchecked_urem" | "unchecked_srem" =>
|
||||
(1, vec![param(ccx, 0), param(ccx, 0)], param(ccx, 0)),
|
||||
|
|
@ -5202,13 +5195,12 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
"overflowing_add" | "overflowing_sub" | "overflowing_mul" =>
|
||||
(1, vec![param(ccx, 0), param(ccx, 0)], param(ccx, 0)),
|
||||
|
||||
"return_address" => (0, vec![], ty::mk_imm_ptr(tcx, tcx.types.u8)),
|
||||
"return_address" => (0, vec![], tcx.mk_imm_ptr(tcx.types.u8)),
|
||||
|
||||
"assume" => (0, vec![tcx.types.bool], ty::mk_nil(tcx)),
|
||||
"assume" => (0, vec![tcx.types.bool], tcx.mk_nil()),
|
||||
|
||||
"discriminant_value" => (1, vec![
|
||||
ty::mk_imm_rptr(tcx,
|
||||
tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
tcx.mk_imm_ref(tcx.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1),
|
||||
ty::BrAnon(0))),
|
||||
param(ccx, 0))], tcx.types.u64),
|
||||
|
||||
|
|
@ -5220,7 +5212,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, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
let fty = tcx.mk_fn(None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
abi: abi::RustIntrinsic,
|
||||
sig: ty::Binder(FnSig {
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
match BinOpCategory::from(op) {
|
||||
BinOpCategory::Shortcircuit => {
|
||||
// && and || are a simple case.
|
||||
demand::suptype(fcx, lhs_expr.span, ty::mk_bool(tcx), lhs_ty);
|
||||
check_expr_coercable_to_type(fcx, rhs_expr, ty::mk_bool(tcx));
|
||||
fcx.write_ty(expr.id, ty::mk_bool(tcx));
|
||||
demand::suptype(fcx, lhs_expr.span, tcx.mk_bool(), lhs_ty);
|
||||
check_expr_coercable_to_type(fcx, rhs_expr, tcx.mk_bool());
|
||||
fcx.write_ty(expr.id, tcx.mk_bool());
|
||||
}
|
||||
_ => {
|
||||
// Otherwise, we always treat operators as if they are
|
||||
|
|
@ -148,9 +148,9 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
let tcx = fcx.tcx();
|
||||
match BinOpCategory::from(op) {
|
||||
BinOpCategory::Shortcircuit => {
|
||||
demand::suptype(fcx, lhs_expr.span, ty::mk_bool(tcx), lhs_ty);
|
||||
demand::suptype(fcx, rhs_expr.span, ty::mk_bool(tcx), rhs_ty);
|
||||
ty::mk_bool(tcx)
|
||||
demand::suptype(fcx, lhs_expr.span, tcx.mk_bool(), lhs_ty);
|
||||
demand::suptype(fcx, rhs_expr.span, tcx.mk_bool(), rhs_ty);
|
||||
tcx.mk_bool()
|
||||
}
|
||||
|
||||
BinOpCategory::Shift => {
|
||||
|
|
@ -193,7 +193,7 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
lhs_ty
|
||||
}
|
||||
} else {
|
||||
ty::mk_bool(tcx)
|
||||
tcx.mk_bool()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1520,7 +1520,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>,
|
|||
debug!("projection_bounds(projection_ty={:?})",
|
||||
projection_ty);
|
||||
|
||||
let ty = ty::mk_projection(tcx, projection_ty.trait_ref.clone(), projection_ty.item_name);
|
||||
let ty = tcx.mk_projection(projection_ty.trait_ref.clone(), projection_ty.item_name);
|
||||
|
||||
// Say we have a projection `<T as SomeTrait<'a>>::SomeType`. We are interested
|
||||
// in looking for a trait definition like:
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
|||
// impl, plus its own.
|
||||
let new_polytype = ty::TypeScheme {
|
||||
generics: new_method_ty.generics.clone(),
|
||||
ty: ty::mk_bare_fn(tcx, Some(new_did),
|
||||
tcx.mk_bare_fn(new_method_ty.fty.clone()))
|
||||
ty: tcx.mk_fn(Some(new_did),
|
||||
tcx.mk_bare_fn(new_method_ty.fty.clone()))
|
||||
};
|
||||
debug!("new_polytype={:?}", new_polytype);
|
||||
|
||||
|
|
@ -468,12 +468,12 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
|||
|
||||
(&ty::TyRef(r_a, mt_a), &ty::TyRef(r_b, mt_b)) => {
|
||||
infer::mk_subr(&infcx, infer::RelateObjectBound(span), *r_b, *r_a);
|
||||
check_mutbl(mt_a, mt_b, &|ty| ty::mk_imm_rptr(tcx, r_b, ty))
|
||||
check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ref(r_b, ty))
|
||||
}
|
||||
|
||||
(&ty::TyRef(_, mt_a), &ty::TyRawPtr(mt_b)) |
|
||||
(&ty::TyRawPtr(mt_a), &ty::TyRawPtr(mt_b)) => {
|
||||
check_mutbl(mt_a, mt_b, &|ty| ty::mk_imm_ptr(tcx, ty))
|
||||
check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ptr(ty))
|
||||
}
|
||||
|
||||
(&ty::TyStruct(def_id_a, substs_a), &ty::TyStruct(def_id_b, substs_b)) => {
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> {
|
|||
item_name: ast::Name)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
ty::mk_projection(self.tcx(), trait_ref, item_name)
|
||||
self.tcx().mk_projection(trait_ref, item_name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -508,7 +508,7 @@ impl<'tcx> GetTypeParameterBounds<'tcx> for ast::Generics {
|
|||
// `where T:Foo`.
|
||||
|
||||
let def = astconv.tcx().type_parameter_def(node_id);
|
||||
let ty = ty::mk_param_from_def(astconv.tcx(), &def);
|
||||
let ty = astconv.tcx().mk_param_from_def(&def);
|
||||
|
||||
let from_ty_params =
|
||||
self.ty_params
|
||||
|
|
@ -577,7 +577,7 @@ fn get_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
ast::TupleVariantKind(ref args) if !args.is_empty() => {
|
||||
let rs = ExplicitRscope;
|
||||
let input_tys: Vec<_> = args.iter().map(|va| icx.to_ty(&rs, &*va.ty)).collect();
|
||||
ty::mk_ctor_fn(tcx, variant_def_id, &input_tys, enum_scheme.ty)
|
||||
tcx.mk_ctor_fn(variant_def_id, &input_tys, enum_scheme.ty)
|
||||
}
|
||||
|
||||
ast::TupleVariantKind(_) => {
|
||||
|
|
@ -631,8 +631,8 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
container,
|
||||
None);
|
||||
|
||||
let fty = ty::mk_bare_fn(ccx.tcx, Some(def_id),
|
||||
ccx.tcx.mk_bare_fn(ty_method.fty.clone()));
|
||||
let fty = ccx.tcx.mk_fn(Some(def_id),
|
||||
ccx.tcx.mk_bare_fn(ty_method.fty.clone()));
|
||||
debug!("method {} (id {}) has type {:?}",
|
||||
ident, id, fty);
|
||||
ccx.tcx.tcache.borrow_mut().insert(def_id,TypeScheme {
|
||||
|
|
@ -995,7 +995,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
convert_methods(ccx,
|
||||
TraitContainer(local_def(it.id)),
|
||||
methods,
|
||||
ty::mk_self_type(tcx),
|
||||
tcx.mk_self_type(),
|
||||
&trait_def.generics,
|
||||
&trait_predicates);
|
||||
|
||||
|
|
@ -1026,7 +1026,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
check_method_self_type(ccx,
|
||||
&BindingRscope::new(),
|
||||
ccx.method_ty(trait_item.id),
|
||||
ty::mk_self_type(tcx),
|
||||
tcx.mk_self_type(),
|
||||
&sig.explicit_self,
|
||||
it.id)
|
||||
}
|
||||
|
|
@ -1088,7 +1088,7 @@ 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, &scheme.generics);
|
||||
let selfty = ty::mk_struct(tcx, local_def(id), tcx.mk_substs(substs));
|
||||
let selfty = tcx.mk_struct(local_def(id), tcx.mk_substs(substs));
|
||||
|
||||
// If this struct is enum-like or tuple-like, create the type of its
|
||||
// constructor.
|
||||
|
|
@ -1110,8 +1110,7 @@ fn convert_struct<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
.unwrap()
|
||||
.ty)
|
||||
.collect();
|
||||
let ctor_fn_ty = ty::mk_ctor_fn(tcx,
|
||||
local_def(ctor_id),
|
||||
let ctor_fn_ty = tcx.mk_ctor_fn(local_def(ctor_id),
|
||||
&inputs[..],
|
||||
selfty);
|
||||
write_ty_to_tcx(tcx, ctor_id, ctor_fn_ty);
|
||||
|
|
@ -1177,7 +1176,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt,
|
|||
let scope = &(generics, &self_predicate);
|
||||
|
||||
// Convert the bounds that follow the colon, e.g. `Bar+Zed` in `trait Foo : Bar+Zed`.
|
||||
let self_param_ty = ty::mk_self_type(tcx);
|
||||
let self_param_ty = tcx.mk_self_type();
|
||||
let superbounds1 = compute_bounds(&ccx.icx(scope),
|
||||
self_param_ty,
|
||||
bounds,
|
||||
|
|
@ -1295,12 +1294,12 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
generics.ty_params
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, def)| ty::mk_param(tcx, TypeSpace,
|
||||
.map(|(i, def)| tcx.mk_param(TypeSpace,
|
||||
i as u32, def.ident.name))
|
||||
.collect();
|
||||
|
||||
// ...and also create the `Self` parameter.
|
||||
let self_ty = ty::mk_self_type(tcx);
|
||||
let self_ty = tcx.mk_self_type();
|
||||
|
||||
Substs::new_trait(types, regions, self_ty)
|
||||
}
|
||||
|
|
@ -1389,9 +1388,8 @@ fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
|
|||
}
|
||||
};
|
||||
|
||||
let assoc_ty = ty::mk_projection(ccx.tcx,
|
||||
self_trait_ref,
|
||||
trait_item.ident.name);
|
||||
let assoc_ty = ccx.tcx.mk_projection(self_trait_ref,
|
||||
trait_item.ident.name);
|
||||
|
||||
let bounds = compute_bounds(&ccx.icx(&(ast_generics, trait_predicates)),
|
||||
assoc_ty,
|
||||
|
|
@ -1450,7 +1448,7 @@ fn compute_type_scheme_of_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
|||
ast::ItemFn(ref decl, unsafety, _, abi, ref generics, _) => {
|
||||
let ty_generics = ty_generics_for_fn(ccx, generics, &ty::Generics::empty());
|
||||
let tofd = astconv::ty_of_bare_fn(&ccx.icx(generics), unsafety, abi, &**decl);
|
||||
let ty = ty::mk_bare_fn(tcx, Some(local_def(it.id)), tcx.mk_bare_fn(tofd));
|
||||
let ty = tcx.mk_fn(Some(local_def(it.id)), tcx.mk_bare_fn(tofd));
|
||||
ty::TypeScheme { ty: ty, generics: ty_generics }
|
||||
}
|
||||
ast::ItemTy(ref t, ref generics) => {
|
||||
|
|
@ -1462,13 +1460,13 @@ fn compute_type_scheme_of_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
|||
// Create a new generic polytype.
|
||||
let ty_generics = ty_generics_for_type_or_impl(ccx, generics);
|
||||
let substs = mk_item_substs(ccx, &ty_generics);
|
||||
let t = ty::mk_enum(tcx, local_def(it.id), tcx.mk_substs(substs));
|
||||
let t = tcx.mk_enum(local_def(it.id), tcx.mk_substs(substs));
|
||||
ty::TypeScheme { ty: t, generics: ty_generics }
|
||||
}
|
||||
ast::ItemStruct(_, ref generics) => {
|
||||
let ty_generics = ty_generics_for_type_or_impl(ccx, generics);
|
||||
let substs = mk_item_substs(ccx, &ty_generics);
|
||||
let t = ty::mk_struct(tcx, local_def(it.id), tcx.mk_substs(substs));
|
||||
let t = tcx.mk_struct(local_def(it.id), tcx.mk_substs(substs));
|
||||
ty::TypeScheme { ty: t, generics: ty_generics }
|
||||
}
|
||||
ast::ItemDefaultImpl(..) |
|
||||
|
|
@ -2121,14 +2119,12 @@ fn compute_type_scheme_of_foreign_fn_decl<'a, 'tcx>(
|
|||
ast::Return(ref ty) =>
|
||||
ty::FnConverging(ast_ty_to_ty(&ccx.icx(ast_generics), &rb, &**ty)),
|
||||
ast::DefaultReturn(..) =>
|
||||
ty::FnConverging(ty::mk_nil(ccx.tcx)),
|
||||
ty::FnConverging(ccx.tcx.mk_nil()),
|
||||
ast::NoReturn(..) =>
|
||||
ty::FnDiverging
|
||||
};
|
||||
|
||||
let t_fn = ty::mk_bare_fn(
|
||||
ccx.tcx,
|
||||
None,
|
||||
let t_fn = ccx.tcx.mk_fn(None,
|
||||
ccx.tcx.mk_bare_fn(ty::BareFnTy {
|
||||
abi: abi,
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
|
|
@ -2149,7 +2145,7 @@ fn mk_item_substs<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
{
|
||||
let types =
|
||||
ty_generics.types.map(
|
||||
|def| ty::mk_param_from_def(ccx.tcx, def));
|
||||
|def| ccx.tcx.mk_param_from_def(def));
|
||||
|
||||
let regions =
|
||||
ty_generics.regions.map(
|
||||
|
|
|
|||
|
|
@ -226,12 +226,12 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
|||
}
|
||||
_ => ()
|
||||
}
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(main_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
let se_ty = tcx.mk_fn(Some(local_def(main_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: Vec::new(),
|
||||
output: ty::FnConverging(ty::mk_nil(tcx)),
|
||||
output: ty::FnConverging(tcx.mk_nil()),
|
||||
variadic: false
|
||||
})
|
||||
}));
|
||||
|
|
@ -272,13 +272,13 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
_ => ()
|
||||
}
|
||||
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(start_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
let se_ty = tcx.mk_fn(Some(local_def(start_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec!(
|
||||
tcx.types.isize,
|
||||
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, tcx.types.u8))
|
||||
tcx.mk_imm_ptr(tcx.mk_imm_ptr(tcx.types.u8))
|
||||
),
|
||||
output: ty::FnConverging(tcx.types.isize),
|
||||
variadic: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue