Cleanup: rename middle::ty::sty and its variants.

Use camel-case naming, and use names which actually make sense in modern Rust.
This commit is contained in:
Eli Friedman 2015-06-11 16:21:46 -07:00
parent 0da58cc361
commit 3c69db4c3c
89 changed files with 1382 additions and 1335 deletions

View file

@ -719,7 +719,7 @@ pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::Nod
item, tcx, cdata);
let name = item_name(&*intr, item);
let (ctor_ty, arg_tys, arg_names) = match ctor_ty.sty {
ty::ty_bare_fn(_, ref f) =>
ty::TyBareFn(_, ref f) =>
(Some(ctor_ty), f.sig.0.inputs.clone(), None),
_ => { // Nullary or struct enum variant.
let mut arg_names = Vec::new();

View file

@ -28,7 +28,7 @@ use syntax::abi;
use syntax::ast;
use syntax::parse::token;
// Compact string representation for Ty values. API ty_str &
// Compact string representation for Ty values. API TyStr &
// parse_from_str. Extra parameters are for converting to/from def_ids in the
// data buffer. Whatever format you choose should not contain pipe characters.

View file

@ -41,7 +41,7 @@ pub struct ctxt<'a, 'tcx: 'a> {
pub abbrevs: &'a abbrev_map<'tcx>
}
// Compact string representation for Ty values. API ty_str & parse_from_str.
// Compact string representation for Ty values. API TyStr & parse_from_str.
// Extra parameters are for converting to/from def_ids in the string rep.
// Whatever format you choose should not contain pipe characters.
pub struct ty_abbrev {
@ -60,9 +60,9 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
let pos = w.mark_stable_position();
match t.sty {
ty::ty_bool => mywrite!(w, "b"),
ty::ty_char => mywrite!(w, "c"),
ty::ty_int(t) => {
ty::TyBool => mywrite!(w, "b"),
ty::TyChar => mywrite!(w, "c"),
ty::TyInt(t) => {
match t {
ast::TyIs => mywrite!(w, "is"),
ast::TyI8 => mywrite!(w, "MB"),
@ -71,7 +71,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
ast::TyI64 => mywrite!(w, "MD")
}
}
ty::ty_uint(t) => {
ty::TyUint(t) => {
match t {
ast::TyUs => mywrite!(w, "us"),
ast::TyU8 => mywrite!(w, "Mb"),
@ -80,37 +80,37 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
ast::TyU64 => mywrite!(w, "Md")
}
}
ty::ty_float(t) => {
ty::TyFloat(t) => {
match t {
ast::TyF32 => mywrite!(w, "Mf"),
ast::TyF64 => mywrite!(w, "MF"),
}
}
ty::ty_enum(def, substs) => {
ty::TyEnum(def, substs) => {
mywrite!(w, "t[{}|", (cx.ds)(def));
enc_substs(w, cx, substs);
mywrite!(w, "]");
}
ty::ty_trait(box ty::TyTrait { ref principal,
ty::TyTrait(box ty::TraitTy { ref principal,
ref bounds }) => {
mywrite!(w, "x[");
enc_trait_ref(w, cx, principal.0);
enc_existential_bounds(w, cx, bounds);
mywrite!(w, "]");
}
ty::ty_tup(ref ts) => {
ty::TyTuple(ref ts) => {
mywrite!(w, "T[");
for t in ts { enc_ty(w, cx, *t); }
mywrite!(w, "]");
}
ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
ty::ty_rptr(r, mt) => {
ty::TyBox(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
ty::TyRawPtr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
ty::TyRef(r, mt) => {
mywrite!(w, "&");
enc_region(w, cx, *r);
enc_mt(w, cx, mt);
}
ty::ty_vec(t, sz) => {
ty::TyArray(t, sz) => {
mywrite!(w, "V");
enc_ty(w, cx, t);
mywrite!(w, "/");
@ -119,40 +119,40 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
None => mywrite!(w, "|"),
}
}
ty::ty_str => {
ty::TyStr => {
mywrite!(w, "v");
}
ty::ty_bare_fn(Some(def_id), f) => {
ty::TyBareFn(Some(def_id), f) => {
mywrite!(w, "F");
mywrite!(w, "{}|", (cx.ds)(def_id));
enc_bare_fn_ty(w, cx, f);
}
ty::ty_bare_fn(None, f) => {
ty::TyBareFn(None, f) => {
mywrite!(w, "G");
enc_bare_fn_ty(w, cx, f);
}
ty::ty_infer(_) => {
ty::TyInfer(_) => {
cx.diag.handler().bug("cannot encode inference variable types");
}
ty::ty_param(ParamTy {space, idx, name}) => {
ty::TyParam(ParamTy {space, idx, name}) => {
mywrite!(w, "p[{}|{}|{}]", idx, space.to_uint(), token::get_name(name))
}
ty::ty_struct(def, substs) => {
ty::TyStruct(def, substs) => {
mywrite!(w, "a[{}|", (cx.ds)(def));
enc_substs(w, cx, substs);
mywrite!(w, "]");
}
ty::ty_closure(def, substs) => {
ty::TyClosure(def, substs) => {
mywrite!(w, "k[{}|", (cx.ds)(def));
enc_substs(w, cx, substs);
mywrite!(w, "]");
}
ty::ty_projection(ref data) => {
ty::TyProjection(ref data) => {
mywrite!(w, "P[");
enc_trait_ref(w, cx, data.trait_ref);
mywrite!(w, "{}]", token::get_name(data.item_name));
}
ty::ty_err => {
ty::TyError => {
mywrite!(w, "e");
}
}

View file

@ -61,16 +61,16 @@ impl<'tcx> CastTy<'tcx> {
pub fn from_ty(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>)
-> Option<CastTy<'tcx>> {
match t.sty {
ty::ty_bool => Some(CastTy::Int(IntTy::Bool)),
ty::ty_char => Some(CastTy::Int(IntTy::Char)),
ty::ty_int(_) => Some(CastTy::Int(IntTy::I)),
ty::ty_uint(u) => Some(CastTy::Int(IntTy::U(u))),
ty::ty_float(_) => Some(CastTy::Float),
ty::ty_enum(..) if ty::type_is_c_like_enum(
ty::TyBool => Some(CastTy::Int(IntTy::Bool)),
ty::TyChar => Some(CastTy::Int(IntTy::Char)),
ty::TyInt(_) => Some(CastTy::Int(IntTy::I)),
ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))),
ty::TyFloat(_) => Some(CastTy::Float),
ty::TyEnum(..) if ty::type_is_c_like_enum(
tcx, t) => Some(CastTy::Int(IntTy::CEnum)),
ty::ty_ptr(ref mt) => Some(CastTy::Ptr(mt)),
ty::ty_rptr(_, ref mt) => Some(CastTy::RPtr(mt)),
ty::ty_bare_fn(..) => Some(CastTy::FnPtr),
ty::TyRawPtr(ref mt) => Some(CastTy::Ptr(mt)),
ty::TyRef(_, ref mt) => Some(CastTy::RPtr(mt)),
ty::TyBareFn(..) => Some(CastTy::FnPtr),
_ => None,
}
}

View file

@ -423,7 +423,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
self.visit_expr(&**element);
// The count is checked elsewhere (typeck).
let count = match node_ty.sty {
ty::ty_vec(_, Some(n)) => n,
ty::TyArray(_, Some(n)) => n,
_ => unreachable!()
};
// [element; 0] is always zero-sized.
@ -454,7 +454,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
visit::walk_expr(self, ex);
let div_or_rem = op.node == ast::BiDiv || op.node == ast::BiRem;
match node_ty.sty {
ty::ty_uint(_) | ty::ty_int(_) if div_or_rem => {
ty::TyUint(_) | ty::TyInt(_) if div_or_rem => {
if !self.qualif.intersects(ConstQualif::NOT_CONST) {
match const_eval::eval_const_expr_partial(self.tcx, ex, None) {
Ok(_) => {}
@ -529,8 +529,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
e: &ast::Expr, node_ty: Ty<'tcx>) {
match node_ty.sty {
ty::ty_struct(did, _) |
ty::ty_enum(did, _) if ty::has_dtor(v.tcx, did) => {
ty::TyStruct(did, _) |
ty::TyEnum(did, _) if ty::has_dtor(v.tcx, did) => {
v.add_qualif(ConstQualif::NEEDS_DROP);
if v.mode != Mode::Var {
v.tcx.sess.span_err(e.span,
@ -562,7 +562,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
}
ast::ExprUnary(op, ref inner) => {
match ty::node_id_to_type(v.tcx, inner.id).sty {
ty::ty_ptr(_) => {
ty::TyRawPtr(_) => {
assert!(op == ast::UnDeref);
v.add_qualif(ConstQualif::NOT_CONST);
@ -576,7 +576,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
}
ast::ExprBinary(op, ref lhs, _) => {
match ty::node_id_to_type(v.tcx, lhs.id).sty {
ty::ty_ptr(_) => {
ty::TyRawPtr(_) => {
assert!(op.node == ast::BiEq || op.node == ast::BiNe ||
op.node == ast::BiLe || op.node == ast::BiLt ||
op.node == ast::BiGe || op.node == ast::BiGt);
@ -612,7 +612,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
}
Some(def::DefStruct(_)) => {
if let ty::ty_bare_fn(..) = node_ty.sty {
if let ty::TyBareFn(..) = node_ty.sty {
// Count the function pointer.
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
}
@ -854,7 +854,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'tcx> {
// Mutable slices are the only `&mut` allowed in globals,
// but only in `static mut`, nowhere else.
match cmt.ty.sty {
ty::ty_vec(_, _) => break,
ty::TyArray(_, _) => break,
_ => {}
}
}

View file

@ -234,7 +234,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
match p.node {
ast::PatIdent(ast::BindByValue(ast::MutImmutable), ident, None) => {
let pat_ty = ty::pat_ty(cx.tcx, p);
if let ty::ty_enum(def_id, _) = pat_ty.sty {
if let ty::TyEnum(def_id, _) = pat_ty.sty {
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
if let Some(DefLocal(_)) = def {
if ty::enum_variants(cx.tcx, def_id).iter().any(|variant|
@ -506,9 +506,9 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
let pats_len = pats.len();
let mut pats = pats.into_iter().map(|p| P((*p).clone()));
let pat = match left_ty.sty {
ty::ty_tup(_) => ast::PatTup(pats.collect()),
ty::TyTuple(_) => ast::PatTup(pats.collect()),
ty::ty_enum(cid, _) | ty::ty_struct(cid, _) => {
ty::TyEnum(cid, _) | ty::TyStruct(cid, _) => {
let (vid, is_structure) = match ctor {
&Variant(vid) =>
(vid, ty::enum_variant_with_id(cx.tcx, cid, vid).arg_names.is_some()),
@ -535,23 +535,23 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
}
ty::ty_rptr(_, ty::mt { ty, mutbl }) => {
ty::TyRef(_, ty::mt { ty, mutbl }) => {
match ty.sty {
ty::ty_vec(_, Some(n)) => match ctor {
ty::TyArray(_, Some(n)) => match ctor {
&Single => {
assert_eq!(pats_len, n);
ast::PatVec(pats.collect(), None, vec!())
},
_ => unreachable!()
},
ty::ty_vec(_, None) => match ctor {
ty::TyArray(_, None) => match ctor {
&Slice(n) => {
assert_eq!(pats_len, n);
ast::PatVec(pats.collect(), None, vec!())
},
_ => unreachable!()
},
ty::ty_str => ast::PatWild(ast::PatWildSingle),
ty::TyStr => ast::PatWild(ast::PatWildSingle),
_ => {
assert_eq!(pats_len, 1);
@ -560,7 +560,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
}
ty::ty_vec(_, Some(len)) => {
ty::TyArray(_, Some(len)) => {
assert_eq!(pats_len, len);
ast::PatVec(pats.collect(), None, vec![])
}
@ -597,16 +597,16 @@ fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix,
fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
max_slice_length: usize) -> Vec<Constructor> {
match left_ty.sty {
ty::ty_bool =>
ty::TyBool =>
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty.sty {
ty::ty_vec(_, None) =>
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
ty::TyArray(_, None) =>
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
_ => vec!(Single)
},
ty::ty_enum(eid, _) =>
ty::TyEnum(eid, _) =>
ty::enum_variants(cx.tcx, eid)
.iter()
.map(|va| Variant(va.id))
@ -779,7 +779,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))),
ast::PatVec(ref before, ref slice, ref after) =>
match left_ty.sty {
ty::ty_vec(_, Some(_)) => vec!(Single),
ty::TyArray(_, Some(_)) => vec!(Single),
_ => if slice.is_some() {
range_inclusive(before.len() + after.len(), max_slice_length)
.map(|length| Slice(length))
@ -804,25 +804,25 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
/// A struct pattern's arity is the number of fields it contains, etc.
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usize {
match ty.sty {
ty::ty_tup(ref fs) => fs.len(),
ty::ty_uniq(_) => 1,
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty.sty {
ty::ty_vec(_, None) => match *ctor {
ty::TyTuple(ref fs) => fs.len(),
ty::TyBox(_) => 1,
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
ty::TyArray(_, None) => match *ctor {
Slice(length) => length,
ConstantValue(_) => 0,
_ => unreachable!()
},
ty::ty_str => 0,
ty::TyStr => 0,
_ => 1
},
ty::ty_enum(eid, _) => {
ty::TyEnum(eid, _) => {
match *ctor {
Variant(id) => enum_variant_with_id(cx.tcx, eid, id).args.len(),
_ => unreachable!()
}
}
ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
ty::ty_vec(_, Some(n)) => n,
ty::TyStruct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
ty::TyArray(_, Some(n)) => n,
_ => 0
}
}

View file

@ -732,11 +732,11 @@ pub fn eval_const_expr_with_substs<'tcx, S>(tcx: &ty::ctxt<'tcx>,
// bindings so that isize/usize is mapped to a type with an
// inherently known bitwidth.
let expr_int_type = ety.and_then(|ty| {
if let ty::ty_int(t) = ty.sty {
if let ty::TyInt(t) = ty.sty {
Some(IntTy::from(tcx, t)) } else { None }
});
let expr_uint_type = ety.and_then(|ty| {
if let ty::ty_uint(t) = ty.sty {
if let ty::TyUint(t) = ty.sty {
Some(UintTy::from(tcx, t)) } else { None }
});
@ -1093,33 +1093,33 @@ fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: const_val, ty: Ty) -> CastResult
// Issue #23890: If isize/usize, then dispatch to appropriate target representation type
match (&ty.sty, tcx.sess.target.int_type, tcx.sess.target.uint_type) {
(&ty::ty_int(ast::TyIs), ast::TyI32, _) => return convert_val!(i32, const_int, i64),
(&ty::ty_int(ast::TyIs), ast::TyI64, _) => return convert_val!(i64, const_int, i64),
(&ty::ty_int(ast::TyIs), _, _) => panic!("unexpected target.int_type"),
(&ty::TyInt(ast::TyIs), ast::TyI32, _) => return convert_val!(i32, const_int, i64),
(&ty::TyInt(ast::TyIs), ast::TyI64, _) => return convert_val!(i64, const_int, i64),
(&ty::TyInt(ast::TyIs), _, _) => panic!("unexpected target.int_type"),
(&ty::ty_uint(ast::TyUs), _, ast::TyU32) => return convert_val!(u32, const_uint, u64),
(&ty::ty_uint(ast::TyUs), _, ast::TyU64) => return convert_val!(u64, const_uint, u64),
(&ty::ty_uint(ast::TyUs), _, _) => panic!("unexpected target.uint_type"),
(&ty::TyUint(ast::TyUs), _, ast::TyU32) => return convert_val!(u32, const_uint, u64),
(&ty::TyUint(ast::TyUs), _, ast::TyU64) => return convert_val!(u64, const_uint, u64),
(&ty::TyUint(ast::TyUs), _, _) => panic!("unexpected target.uint_type"),
_ => {}
}
match ty.sty {
ty::ty_int(ast::TyIs) => unreachable!(),
ty::ty_uint(ast::TyUs) => unreachable!(),
ty::TyInt(ast::TyIs) => unreachable!(),
ty::TyUint(ast::TyUs) => unreachable!(),
ty::ty_int(ast::TyI8) => convert_val!(i8, const_int, i64),
ty::ty_int(ast::TyI16) => convert_val!(i16, const_int, i64),
ty::ty_int(ast::TyI32) => convert_val!(i32, const_int, i64),
ty::ty_int(ast::TyI64) => convert_val!(i64, const_int, i64),
ty::TyInt(ast::TyI8) => convert_val!(i8, const_int, i64),
ty::TyInt(ast::TyI16) => convert_val!(i16, const_int, i64),
ty::TyInt(ast::TyI32) => convert_val!(i32, const_int, i64),
ty::TyInt(ast::TyI64) => convert_val!(i64, const_int, i64),
ty::ty_uint(ast::TyU8) => convert_val!(u8, const_uint, u64),
ty::ty_uint(ast::TyU16) => convert_val!(u16, const_uint, u64),
ty::ty_uint(ast::TyU32) => convert_val!(u32, const_uint, u64),
ty::ty_uint(ast::TyU64) => convert_val!(u64, const_uint, u64),
ty::TyUint(ast::TyU8) => convert_val!(u8, const_uint, u64),
ty::TyUint(ast::TyU16) => convert_val!(u16, const_uint, u64),
ty::TyUint(ast::TyU32) => convert_val!(u32, const_uint, u64),
ty::TyUint(ast::TyU64) => convert_val!(u64, const_uint, u64),
ty::ty_float(ast::TyF32) => convert_val!(f32, const_float, f64),
ty::ty_float(ast::TyF64) => convert_val!(f64, const_float, f64),
ty::TyFloat(ast::TyF32) => convert_val!(f32, const_float, f64),
ty::TyFloat(ast::TyF64) => convert_val!(f64, const_float, f64),
_ => Err(ErrKind::CannotCast),
}
}
@ -1135,7 +1135,7 @@ fn lit_to_const(lit: &ast::Lit, ty_hint: Option<Ty>) -> const_val {
ast::LitInt(n, ast::SignedIntLit(_, ast::Plus)) => const_int(n as i64),
ast::LitInt(n, ast::UnsuffixedIntLit(ast::Plus)) => {
match ty_hint.map(|ty| &ty.sty) {
Some(&ty::ty_uint(_)) => const_uint(n),
Some(&ty::TyUint(_)) => const_uint(n),
_ => const_int(n as i64)
}
}

View file

@ -129,7 +129,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn handle_field_access(&mut self, lhs: &ast::Expr, name: ast::Name) {
match ty::expr_ty_adjusted(self.tcx, lhs).sty {
ty::ty_struct(id, _) => {
ty::TyStruct(id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, id);
let field_id = fields.iter()
.find(|field| field.name == name).unwrap().id;
@ -141,7 +141,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn handle_tup_field_access(&mut self, lhs: &ast::Expr, idx: usize) {
match ty::expr_ty_adjusted(self.tcx, lhs).sty {
ty::ty_struct(id, _) => {
ty::TyStruct(id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, id);
let field_id = fields[idx].id;
self.live_symbols.insert(field_id.node);

View file

@ -31,7 +31,7 @@ enum UnsafeContext {
fn type_is_unsafe_function(ty: Ty) -> bool {
match ty.sty {
ty::ty_bare_fn(_, ref f) => f.unsafety == ast::Unsafety::Unsafe,
ty::TyBareFn(_, ref f) => f.unsafety == ast::Unsafety::Unsafe,
_ => false,
}
}
@ -69,11 +69,11 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
debug!("effect: checking index with base type {}",
ppaux::ty_to_string(self.tcx, base_type));
match base_type.sty {
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => if ty::ty_str == ty.sty {
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
span_err!(self.tcx.sess, e.span, E0134,
"modification of string types is not allowed");
},
ty::ty_str => {
ty::TyStr => {
span_err!(self.tcx.sess, e.span, E0135,
"modification of string types is not allowed");
}
@ -161,7 +161,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
let base_type = ty::node_id_to_type(self.tcx, base.id);
debug!("effect: unary case, base type is {}",
ppaux::ty_to_string(self.tcx, base_type));
if let ty::ty_ptr(_) = base_type.sty {
if let ty::TyRawPtr(_) = base_type.sty {
self.require_unsafe(expr.span, "dereference of raw pointer")
}
}

View file

@ -622,10 +622,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
callee.repr(self.tcx()), callee_ty.repr(self.tcx()));
let call_scope = region::CodeExtent::from_node_id(call.id);
match callee_ty.sty {
ty::ty_bare_fn(..) => {
ty::TyBareFn(..) => {
self.consume_expr(callee);
}
ty::ty_err => { }
ty::TyError => { }
_ => {
let overloaded_call_type =
match self.typer.node_method_origin(MethodCall::expr(call.id)) {
@ -740,7 +740,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// Select just those fields of the `with`
// expression that will actually be used
let with_fields = match with_cmt.ty.sty {
ty::ty_struct(did, substs) => {
ty::TyStruct(did, substs) => {
ty::struct_fields(self.tcx(), did, substs)
}
_ => {
@ -826,7 +826,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
let self_ty = ty::no_late_bound_regions(self.tcx(), &self_ty).unwrap();
let (m, r) = match self_ty.sty {
ty::ty_rptr(r, ref m) => (m.mutbl, r),
ty::TyRef(r, ref m) => (m.mutbl, r),
_ => self.tcx().sess.span_bug(expr.span,
&format!("bad overloaded deref type {}",
method_ty.repr(self.tcx())))

View file

@ -48,51 +48,51 @@ pub fn simplify_type(tcx: &ty::ctxt,
-> Option<SimplifiedType>
{
match ty.sty {
ty::ty_bool => Some(BoolSimplifiedType),
ty::ty_char => Some(CharSimplifiedType),
ty::ty_int(int_type) => Some(IntSimplifiedType(int_type)),
ty::ty_uint(uint_type) => Some(UintSimplifiedType(uint_type)),
ty::ty_float(float_type) => Some(FloatSimplifiedType(float_type)),
ty::ty_enum(def_id, _) => Some(EnumSimplifiedType(def_id)),
ty::ty_str => Some(StrSimplifiedType),
ty::ty_vec(..) => Some(VecSimplifiedType),
ty::ty_ptr(_) => Some(PtrSimplifiedType),
ty::ty_trait(ref trait_info) => {
ty::TyBool => Some(BoolSimplifiedType),
ty::TyChar => Some(CharSimplifiedType),
ty::TyInt(int_type) => Some(IntSimplifiedType(int_type)),
ty::TyUint(uint_type) => Some(UintSimplifiedType(uint_type)),
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
ty::TyEnum(def_id, _) => Some(EnumSimplifiedType(def_id)),
ty::TyStr => Some(StrSimplifiedType),
ty::TyArray(..) => Some(VecSimplifiedType),
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
ty::TyTrait(ref trait_info) => {
Some(TraitSimplifiedType(trait_info.principal_def_id()))
}
ty::ty_struct(def_id, _) => {
ty::TyStruct(def_id, _) => {
Some(StructSimplifiedType(def_id))
}
ty::ty_rptr(_, mt) => {
ty::TyRef(_, mt) => {
// since we introduce auto-refs during method lookup, we
// just treat &T and T as equivalent from the point of
// view of possibly unifying
simplify_type(tcx, mt.ty, can_simplify_params)
}
ty::ty_uniq(_) => {
ty::TyBox(_) => {
// treat like we would treat `Box`
let def_id = tcx.lang_items.owned_box().unwrap();
Some(StructSimplifiedType(def_id))
}
ty::ty_closure(def_id, _) => {
ty::TyClosure(def_id, _) => {
Some(ClosureSimplifiedType(def_id))
}
ty::ty_tup(ref tys) => {
ty::TyTuple(ref tys) => {
Some(TupleSimplifiedType(tys.len()))
}
ty::ty_bare_fn(_, ref f) => {
ty::TyBareFn(_, ref f) => {
Some(FunctionSimplifiedType(f.sig.0.inputs.len()))
}
ty::ty_projection(_) => {
ty::TyProjection(_) => {
None
}
ty::ty_param(_) => {
ty::TyParam(_) => {
if can_simplify_params {
Some(ParameterSimplifiedType)
} else {
None
}
}
ty::ty_infer(_) | ty::ty_err => None,
ty::TyInfer(_) | ty::TyError => None,
}
}

View file

@ -88,61 +88,61 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
}
match ty.sty {
ty::ty_bool |
ty::ty_char |
ty::ty_int(..) |
ty::ty_uint(..) |
ty::ty_float(..) |
ty::ty_bare_fn(..) |
ty::ty_err |
ty::ty_str => {
ty::TyBool |
ty::TyChar |
ty::TyInt(..) |
ty::TyUint(..) |
ty::TyFloat(..) |
ty::TyBareFn(..) |
ty::TyError |
ty::TyStr => {
// No borrowed content reachable here.
}
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
let &(r_a, opt_ty) = self.stack.last().unwrap();
self.out.push(Implication::RegionSubClosure(opt_ty, r_a, def_id, substs));
}
ty::ty_trait(ref t) => {
ty::TyTrait(ref t) => {
let required_region_bounds =
object_region_bounds(self.tcx(), &t.principal, t.bounds.builtin_bounds);
self.accumulate_from_object_ty(ty, t.bounds.region_bound, required_region_bounds)
}
ty::ty_enum(def_id, substs) |
ty::ty_struct(def_id, substs) => {
ty::TyEnum(def_id, substs) |
ty::TyStruct(def_id, substs) => {
let item_scheme = ty::lookup_item_type(self.tcx(), def_id);
self.accumulate_from_adt(ty, def_id, &item_scheme.generics, substs)
}
ty::ty_vec(t, _) |
ty::ty_ptr(ty::mt { ty: t, .. }) |
ty::ty_uniq(t) => {
ty::TyArray(t, _) |
ty::TyRawPtr(ty::mt { ty: t, .. }) |
ty::TyBox(t) => {
self.accumulate_from_ty(t)
}
ty::ty_rptr(r_b, mt) => {
ty::TyRef(r_b, mt) => {
self.accumulate_from_rptr(ty, *r_b, mt.ty);
}
ty::ty_param(p) => {
ty::TyParam(p) => {
self.push_param_constraint_from_top(p);
}
ty::ty_projection(ref data) => {
ty::TyProjection(ref data) => {
// `<T as TraitRef<..>>::Name`
self.push_projection_constraint_from_top(data);
}
ty::ty_tup(ref tuptys) => {
ty::TyTuple(ref tuptys) => {
for &tupty in tuptys {
self.accumulate_from_ty(tupty);
}
}
ty::ty_infer(_) => {
ty::TyInfer(_) => {
// This should not happen, BUT:
//
// Currently we uncover region relationships on

View file

@ -81,17 +81,17 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(a_id)), &ty::ty_infer(TyVar(b_id))) => {
(&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => {
infcx.type_variables.borrow_mut().relate_vars(a_id, BiTo, b_id);
Ok(a)
}
(&ty::ty_infer(TyVar(a_id)), _) => {
(&ty::TyInfer(TyVar(a_id)), _) => {
try!(self.fields.instantiate(b, BiTo, a_id));
Ok(a)
}
(_, &ty::ty_infer(TyVar(b_id))) => {
(_, &ty::TyInfer(TyVar(b_id))) => {
try!(self.fields.instantiate(a, BiTo, b_id));
Ok(a)
}

View file

@ -70,44 +70,44 @@ pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>,
match (&a.sty, &b.sty) {
// Relate integral variables to other types
(&ty::ty_infer(ty::IntVar(a_id)), &ty::ty_infer(ty::IntVar(b_id))) => {
(&ty::TyInfer(ty::IntVar(a_id)), &ty::TyInfer(ty::IntVar(b_id))) => {
try!(infcx.int_unification_table
.borrow_mut()
.unify_var_var(a_id, b_id)
.map_err(|e| int_unification_error(a_is_expected, e)));
Ok(a)
}
(&ty::ty_infer(ty::IntVar(v_id)), &ty::ty_int(v)) => {
(&ty::TyInfer(ty::IntVar(v_id)), &ty::TyInt(v)) => {
unify_integral_variable(infcx, a_is_expected, v_id, IntType(v))
}
(&ty::ty_int(v), &ty::ty_infer(ty::IntVar(v_id))) => {
(&ty::TyInt(v), &ty::TyInfer(ty::IntVar(v_id))) => {
unify_integral_variable(infcx, !a_is_expected, v_id, IntType(v))
}
(&ty::ty_infer(ty::IntVar(v_id)), &ty::ty_uint(v)) => {
(&ty::TyInfer(ty::IntVar(v_id)), &ty::TyUint(v)) => {
unify_integral_variable(infcx, a_is_expected, v_id, UintType(v))
}
(&ty::ty_uint(v), &ty::ty_infer(ty::IntVar(v_id))) => {
(&ty::TyUint(v), &ty::TyInfer(ty::IntVar(v_id))) => {
unify_integral_variable(infcx, !a_is_expected, v_id, UintType(v))
}
// Relate floating-point variables to other types
(&ty::ty_infer(ty::FloatVar(a_id)), &ty::ty_infer(ty::FloatVar(b_id))) => {
(&ty::TyInfer(ty::FloatVar(a_id)), &ty::TyInfer(ty::FloatVar(b_id))) => {
try!(infcx.float_unification_table
.borrow_mut()
.unify_var_var(a_id, b_id)
.map_err(|e| float_unification_error(relation.a_is_expected(), e)));
Ok(a)
}
(&ty::ty_infer(ty::FloatVar(v_id)), &ty::ty_float(v)) => {
(&ty::TyInfer(ty::FloatVar(v_id)), &ty::TyFloat(v)) => {
unify_float_variable(infcx, a_is_expected, v_id, v)
}
(&ty::ty_float(v), &ty::ty_infer(ty::FloatVar(v_id))) => {
(&ty::TyFloat(v), &ty::TyInfer(ty::FloatVar(v_id))) => {
unify_float_variable(infcx, !a_is_expected, v_id, v)
}
// All other cases of inference are errors
(&ty::ty_infer(_), _) |
(_, &ty::ty_infer(_)) => {
(&ty::TyInfer(_), _) |
(_, &ty::TyInfer(_)) => {
Err(ty::terr_sorts(ty_relate::expected_found(relation, &a, &b)))
}
@ -262,7 +262,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
/// Attempts to generalize `ty` for the type variable `for_vid`. This checks for cycle -- that
/// is, whether the type `ty` references `for_vid`. If `make_region_vars` is true, it will also
/// replace all regions with fresh variables. Returns `ty_err` in the case of a cycle, `Ok`
/// replace all regions with fresh variables. Returns `TyError` in the case of a cycle, `Ok`
/// otherwise.
fn generalize(&self,
ty: Ty<'tcx>,
@ -308,7 +308,7 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
// (In particular, you could have something like `$0 = Box<$1>`
// where `$1` has already been instantiated with `Box<$0>`)
match t.sty {
ty::ty_infer(ty::TyVar(vid)) => {
ty::TyInfer(ty::TyVar(vid)) => {
if vid == self.for_vid {
self.cycle_detected = true;
self.tcx().types.err

View file

@ -53,17 +53,17 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(a_id)), &ty::ty_infer(TyVar(b_id))) => {
(&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => {
infcx.type_variables.borrow_mut().relate_vars(a_id, EqTo, b_id);
Ok(a)
}
(&ty::ty_infer(TyVar(a_id)), _) => {
(&ty::TyInfer(TyVar(a_id)), _) => {
try!(self.fields.instantiate(b, EqTo, a_id));
Ok(a)
}
(_, &ty::ty_infer(TyVar(b_id))) => {
(_, &ty::TyInfer(TyVar(b_id))) => {
try!(self.fields.instantiate(a, EqTo, b_id));
Ok(a)
}

View file

@ -111,14 +111,14 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
let tcx = self.infcx.tcx;
match t.sty {
ty::ty_infer(ty::TyVar(v)) => {
ty::TyInfer(ty::TyVar(v)) => {
self.freshen(
self.infcx.type_variables.borrow().probe(v),
ty::TyVar(v),
ty::FreshTy)
}
ty::ty_infer(ty::IntVar(v)) => {
ty::TyInfer(ty::IntVar(v)) => {
self.freshen(
self.infcx.int_unification_table.borrow_mut()
.probe(v)
@ -127,7 +127,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
ty::FreshIntTy)
}
ty::ty_infer(ty::FloatVar(v)) => {
ty::TyInfer(ty::FloatVar(v)) => {
self.freshen(
self.infcx.float_unification_table.borrow_mut()
.probe(v)
@ -136,9 +136,9 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
ty::FreshFloatTy)
}
ty::ty_infer(ty::FreshTy(c)) |
ty::ty_infer(ty::FreshIntTy(c)) |
ty::ty_infer(ty::FreshFloatTy(c)) => {
ty::TyInfer(ty::FreshTy(c)) |
ty::TyInfer(ty::FreshIntTy(c)) |
ty::TyInfer(ty::FreshFloatTy(c)) => {
if c >= self.freshen_count {
tcx.sess.bug(
&format!("Encountered a freshend type with id {} \
@ -149,25 +149,25 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
t
}
ty::ty_bool |
ty::ty_char |
ty::ty_int(..) |
ty::ty_uint(..) |
ty::ty_float(..) |
ty::ty_enum(..) |
ty::ty_uniq(..) |
ty::ty_str |
ty::ty_err |
ty::ty_vec(..) |
ty::ty_ptr(..) |
ty::ty_rptr(..) |
ty::ty_bare_fn(..) |
ty::ty_trait(..) |
ty::ty_struct(..) |
ty::ty_closure(..) |
ty::ty_tup(..) |
ty::ty_projection(..) |
ty::ty_param(..) => {
ty::TyBool |
ty::TyChar |
ty::TyInt(..) |
ty::TyUint(..) |
ty::TyFloat(..) |
ty::TyEnum(..) |
ty::TyBox(..) |
ty::TyStr |
ty::TyError |
ty::TyArray(..) |
ty::TyRawPtr(..) |
ty::TyRef(..) |
ty::TyBareFn(..) |
ty::TyTrait(..) |
ty::TyStruct(..) |
ty::TyClosure(..) |
ty::TyTuple(..) |
ty::TyProjection(..) |
ty::TyParam(..) => {
ty_fold::super_fold_ty(self, t)
}
}

View file

@ -64,15 +64,15 @@ pub fn super_lattice_tys<'a,'tcx,L:LatticeDir<'a,'tcx>>(this: &mut L,
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(..)), &ty::ty_infer(TyVar(..)))
(&ty::TyInfer(TyVar(..)), &ty::TyInfer(TyVar(..)))
if infcx.type_var_diverges(a) && infcx.type_var_diverges(b) => {
let v = infcx.next_diverging_ty_var();
try!(this.relate_bound(v, a, b));
Ok(v)
}
(&ty::ty_infer(TyVar(..)), _) |
(_, &ty::ty_infer(TyVar(..))) => {
(&ty::TyInfer(TyVar(..)), _) |
(_, &ty::TyInfer(TyVar(..))) => {
let v = infcx.next_ty_var();
try!(this.relate_bound(v, a, b));
Ok(v)

View file

@ -440,7 +440,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn type_var_diverges(&'a self, ty: Ty) -> bool {
match ty.sty {
ty::ty_infer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid),
ty::TyInfer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid),
_ => false
}
}
@ -452,14 +452,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn type_is_unconstrained_numeric(&'a self, ty: Ty) -> UnconstrainedNumeric {
use middle::ty::UnconstrainedNumeric::{Neither, UnconstrainedInt, UnconstrainedFloat};
match ty.sty {
ty::ty_infer(ty::IntVar(vid)) => {
ty::TyInfer(ty::IntVar(vid)) => {
if self.int_unification_table.borrow_mut().has_value(vid) {
Neither
} else {
UnconstrainedInt
}
},
ty::ty_infer(ty::FloatVar(vid)) => {
ty::TyInfer(ty::FloatVar(vid)) => {
if self.float_unification_table.borrow_mut().has_value(vid) {
Neither
} else {
@ -878,7 +878,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
match typ.sty {
ty::ty_infer(ty::TyVar(v)) => {
ty::TyInfer(ty::TyVar(v)) => {
// Not entirely obvious: if `typ` is a type variable,
// it can be resolved to an int/float variable, which
// can then be recursively resolved, hence the
@ -894,7 +894,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
.unwrap_or(typ)
}
ty::ty_infer(ty::IntVar(v)) => {
ty::TyInfer(ty::IntVar(v)) => {
self.int_unification_table
.borrow_mut()
.probe(v)
@ -902,7 +902,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
.unwrap_or(typ)
}
ty::ty_infer(ty::FloatVar(v)) => {
ty::TyInfer(ty::FloatVar(v)) => {
self.float_unification_table
.borrow_mut()
.probe(v)
@ -945,13 +945,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
// [Note-Type-error-reporting]
// An invariant is that anytime the expected or actual type is ty_err (the special
// An invariant is that anytime the expected or actual type is TyError (the special
// error type, meaning that an error occurred when typechecking this expression),
// this is a derived error. The error cascaded from another error (that was already
// reported), so it's not useful to display it to the user.
// The following four methods -- type_error_message_str, type_error_message_str_with_expected,
// type_error_message, and report_mismatched_types -- implement this logic.
// They check if either the actual or expected type is ty_err, and don't print the error
// They check if either the actual or expected type is TyError, and don't print the error
// in this case. The typechecker should only ever report type errors involving mismatched
// types using one of these four methods, and should not call span_err directly for such
// errors.
@ -1004,7 +1004,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
{
let actual_ty = self.resolve_type_vars_if_possible(&actual_ty);
// Don't report an error if actual type is ty_err.
// Don't report an error if actual type is TyError.
if ty::type_is_error(actual_ty) {
return;
}

View file

@ -81,19 +81,19 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
} else {
let t = self.infcx.shallow_resolve(t);
match t.sty {
ty::ty_infer(ty::TyVar(vid)) => {
ty::TyInfer(ty::TyVar(vid)) => {
self.err = Some(unresolved_ty(vid));
self.tcx().types.err
}
ty::ty_infer(ty::IntVar(vid)) => {
ty::TyInfer(ty::IntVar(vid)) => {
self.err = Some(unresolved_int_ty(vid));
self.tcx().types.err
}
ty::ty_infer(ty::FloatVar(vid)) => {
ty::TyInfer(ty::FloatVar(vid)) => {
self.err = Some(unresolved_float_ty(vid));
self.tcx().types.err
}
ty::ty_infer(_) => {
ty::TyInfer(_) => {
self.infcx.tcx.sess.bug(
&format!("Unexpected type in full type resolver: {}",
t.repr(self.infcx.tcx)));

View file

@ -57,24 +57,24 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(a_id)), &ty::ty_infer(TyVar(b_id))) => {
(&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => {
infcx.type_variables
.borrow_mut()
.relate_vars(a_id, SubtypeOf, b_id);
Ok(a)
}
(&ty::ty_infer(TyVar(a_id)), _) => {
(&ty::TyInfer(TyVar(a_id)), _) => {
try!(self.fields
.switch_expected()
.instantiate(b, SupertypeOf, a_id));
Ok(a)
}
(_, &ty::ty_infer(TyVar(b_id))) => {
(_, &ty::TyInfer(TyVar(b_id))) => {
try!(self.fields.instantiate(a, SubtypeOf, b_id));
Ok(a)
}
(&ty::ty_err, _) | (_, &ty::ty_err) => {
(&ty::TyError, _) | (_, &ty::TyError) => {
Ok(self.tcx().types.err)
}

View file

@ -131,7 +131,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
pub fn replace_if_possible(&self, t: Ty<'tcx>) -> Ty<'tcx> {
match t.sty {
ty::ty_infer(ty::TyVar(v)) => {
ty::TyInfer(ty::TyVar(v)) => {
match self.probe(v) {
None => t,
Some(u) => u

View file

@ -12,7 +12,7 @@ use ast_map::NodeForeignItem;
use metadata::csearch;
use middle::def::DefFn;
use middle::subst::{Subst, Substs, EnumeratedItems};
use middle::ty::{TransmuteRestriction, ctxt, ty_bare_fn};
use middle::ty::{TransmuteRestriction, ctxt, TyBareFn};
use middle::ty::{self, Ty};
use util::ppaux::Repr;
@ -54,7 +54,7 @@ struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
let intrinsic = match ty::lookup_item_type(self.tcx, def_id).ty.sty {
ty::ty_bare_fn(_, ref bfty) => bfty.abi == RustIntrinsic,
ty::TyBareFn(_, ref bfty) => bfty.abi == RustIntrinsic,
_ => return false
};
if def_id.krate == ast::LOCAL_CRATE {
@ -256,7 +256,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
DefFn(did, _) if self.def_id_is_transmute(did) => {
let typ = ty::node_id_to_type(self.tcx, expr.id);
match typ.sty {
ty_bare_fn(_, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
TyBareFn(_, ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => {
if let ty::FnConverging(to) = bare_fn_ty.sig.0.output {
let from = bare_fn_ty.sig.0.inputs[0];
self.check_transmute(expr.span, from, to, expr.id);

View file

@ -1498,7 +1498,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn fn_ret(&self, id: NodeId) -> ty::PolyFnOutput<'tcx> {
let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
match fn_ty.sty {
ty::ty_closure(closure_def_id, substs) =>
ty::TyClosure(closure_def_id, substs) =>
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
_ =>
ty::ty_fn_ret(fn_ty),

View file

@ -212,25 +212,25 @@ type DerefKindContext = Option<InteriorOffsetKind>;
// pointer adjustment).
fn deref_kind(t: Ty, context: DerefKindContext) -> McResult<deref_kind> {
match t.sty {
ty::ty_uniq(_) => {
ty::TyBox(_) => {
Ok(deref_ptr(Unique))
}
ty::ty_rptr(r, mt) => {
ty::TyRef(r, mt) => {
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
Ok(deref_ptr(BorrowedPtr(kind, *r)))
}
ty::ty_ptr(ref mt) => {
ty::TyRawPtr(ref mt) => {
Ok(deref_ptr(UnsafePtr(mt.mutbl)))
}
ty::ty_enum(..) |
ty::ty_struct(..) => { // newtype
ty::TyEnum(..) |
ty::TyStruct(..) => { // newtype
Ok(deref_interior(InteriorField(PositionalField(0))))
}
ty::ty_vec(_, _) | ty::ty_str => {
ty::TyArray(_, _) | ty::TyStr => {
// no deref of indexed content without supplying InteriorOffsetKind
if let Some(context) = context {
Ok(deref_interior(InteriorElement(context, element_kind(t))))
@ -523,7 +523,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// The index method always returns an `&T`, so
// dereference it to find the result type.
let elem_ty = match ret_ty.sty {
ty::ty_rptr(_, mt) => mt.ty,
ty::TyRef(_, mt) => mt.ty,
_ => {
debug!("cat_expr_unadjusted: return type of overloaded index is {}?",
ret_ty.repr(self.tcx()));
@ -621,7 +621,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
def::DefUpvar(var_id, fn_node_id) => {
let ty = try!(self.node_ty(fn_node_id));
match ty.sty {
ty::ty_closure(closure_id, _) => {
ty::TyClosure(closure_id, _) => {
match self.typer.closure_kind(closure_id) {
Some(kind) => {
self.cat_upvar(id, span, var_id, fn_node_id, kind)
@ -791,7 +791,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// that the above is actually immutable and
// has a ref type. However, nothing should
// actually look at the type, so we can get
// away with stuffing a `ty_err` in there
// away with stuffing a `TyError` in there
// instead of bothering to construct a proper
// one.
let cmt_result = cmt_ {
@ -843,7 +843,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// Only promote `[T; 0]` before an RFC for rvalue promotions
// is accepted.
let qualif = match expr_ty.sty {
ty::ty_vec(_, Some(0)) => qualif,
ty::TyArray(_, Some(0)) => qualif,
_ => check_const::ConstQualif::NOT_CONST
};
@ -1129,8 +1129,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
slice_ty: Ty)
-> (ast::Mutability, ty::Region) {
match slice_ty.sty {
ty::ty_rptr(r, ref mt) => match mt.ty.sty {
ty::ty_vec(_, None) => (mt.mutbl, *r),
ty::TyRef(r, ref mt) => match mt.ty.sty {
ty::TyArray(_, None) => (mt.mutbl, *r),
_ => vec_slice_info(tcx, pat, mt.ty),
},
@ -1667,12 +1667,12 @@ impl<'tcx> Repr<'tcx> for InteriorKind {
fn element_kind(t: Ty) -> ElementKind {
match t.sty {
ty::ty_rptr(_, ty::mt{ty, ..}) |
ty::ty_uniq(ty) => match ty.sty {
ty::ty_vec(_, None) => VecElement,
ty::TyRef(_, ty::mt{ty, ..}) |
ty::TyBox(ty) => match ty.sty {
ty::TyArray(_, None) => VecElement,
_ => OtherElement
},
ty::ty_vec(..) => VecElement,
ty::TyArray(..) => VecElement,
_ => OtherElement
}
}

View file

@ -387,7 +387,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
ast::ExprField(ref base_e, ref field) => {
span = field.span;
match ty::expr_ty_adjusted(tcx, base_e).sty {
ty::ty_struct(did, _) => {
ty::TyStruct(did, _) => {
ty::lookup_struct_fields(tcx, did)
.iter()
.find(|f| f.name == field.node.name)
@ -404,7 +404,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
ast::ExprTupField(ref base_e, ref field) => {
span = field.span;
match ty::expr_ty_adjusted(tcx, base_e).sty {
ty::ty_struct(did, _) => {
ty::TyStruct(did, _) => {
ty::lookup_struct_fields(tcx, did)
.get(field.node)
.unwrap_or_else(|| {
@ -413,7 +413,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
})
.id
}
ty::ty_tup(..) => return,
ty::TyTuple(..) => return,
_ => tcx.sess.span_bug(e.span,
"stability::check_expr: unnamed field access on \
something other than a tuple or struct")
@ -422,7 +422,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
ast::ExprStruct(_, ref expr_fields, _) => {
let type_ = ty::expr_ty(tcx, e);
match type_.sty {
ty::ty_struct(did, _) => {
ty::TyStruct(did, _) => {
let struct_fields = ty::lookup_struct_fields(tcx, did);
// check the stability of each field that appears
// in the construction expression.
@ -445,7 +445,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
// we don't look at stability attributes on
// struct-like enums (yet...), but it's definitely not
// a bug to have construct one.
ty::ty_enum(..) => return,
ty::TyEnum(..) => return,
_ => {
tcx.sess.span_bug(e.span,
&format!("stability::check_expr: struct construction \
@ -478,7 +478,7 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &ast::Pat,
if is_internal(tcx, pat.span) { return; }
let did = match ty::pat_ty_opt(tcx, pat) {
Some(&ty::TyS { sty: ty::ty_struct(did, _), .. }) => did,
Some(&ty::TyS { sty: ty::TyStruct(did, _), .. }) => did,
Some(_) | None => return,
};
let struct_fields = ty::lookup_struct_fields(tcx, did);

View file

@ -647,7 +647,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
self.ty_stack_depth += 1;
let t1 = match t.sty {
ty::ty_param(p) => {
ty::TyParam(p) => {
self.ty_for_param(p, t)
}
_ => {

View file

@ -265,7 +265,7 @@ fn uncovered_tys<'tcx>(tcx: &ty::ctxt<'tcx>,
fn is_type_parameter<'tcx>(ty: Ty<'tcx>) -> bool {
match ty.sty {
// FIXME(#20590) straighten story about projection types
ty::ty_projection(..) | ty::ty_param(..) => true,
ty::TyProjection(..) | ty::TyParam(..) => true,
_ => false,
}
}
@ -279,11 +279,11 @@ fn ty_is_local<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>, infer_is_local: InferIs
fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool
{
match ty.sty {
ty::ty_uniq(..) | ty::ty_rptr(..) =>
ty::TyBox(..) | ty::TyRef(..) =>
true,
ty::ty_enum(def_id, _) | ty::ty_struct(def_id, _) =>
ty::TyEnum(def_id, _) | ty::TyStruct(def_id, _) =>
ty::has_attr(tcx, def_id, "fundamental"),
ty::ty_trait(ref data) =>
ty::TyTrait(ref data) =>
ty::has_attr(tcx, data.principal_def_id(), "fundamental"),
_ =>
false
@ -298,42 +298,42 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
debug!("ty_is_local_constructor({})", ty.repr(tcx));
match ty.sty {
ty::ty_bool |
ty::ty_char |
ty::ty_int(..) |
ty::ty_uint(..) |
ty::ty_float(..) |
ty::ty_str(..) |
ty::ty_bare_fn(..) |
ty::ty_vec(..) |
ty::ty_ptr(..) |
ty::ty_rptr(..) |
ty::ty_tup(..) |
ty::ty_param(..) |
ty::ty_projection(..) => {
ty::TyBool |
ty::TyChar |
ty::TyInt(..) |
ty::TyUint(..) |
ty::TyFloat(..) |
ty::TyStr(..) |
ty::TyBareFn(..) |
ty::TyArray(..) |
ty::TyRawPtr(..) |
ty::TyRef(..) |
ty::TyTuple(..) |
ty::TyParam(..) |
ty::TyProjection(..) => {
false
}
ty::ty_infer(..) => {
ty::TyInfer(..) => {
infer_is_local.0
}
ty::ty_enum(def_id, _) |
ty::ty_struct(def_id, _) => {
ty::TyEnum(def_id, _) |
ty::TyStruct(def_id, _) => {
def_id.krate == ast::LOCAL_CRATE
}
ty::ty_uniq(_) => { // Box<T>
ty::TyBox(_) => { // Box<T>
let krate = tcx.lang_items.owned_box().map(|d| d.krate);
krate == Some(ast::LOCAL_CRATE)
}
ty::ty_trait(ref tt) => {
ty::TyTrait(ref tt) => {
tt.principal_def_id().krate == ast::LOCAL_CRATE
}
ty::ty_closure(..) |
ty::ty_err => {
ty::TyClosure(..) |
ty::TyError => {
tcx.sess.bug(
&format!("ty_is_local invoked on unexpected type: {}",
ty.repr(tcx)))

View file

@ -60,10 +60,10 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
{
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
// The ty_err created by normalize_to_error can end up being unified
// The TyError created by normalize_to_error can end up being unified
// into all obligations: for example, if our obligation is something
// like `$X = <() as Foo<$X>>::Out` and () does not implement Foo<_>,
// then $X will be unified with ty_err, but the error still needs to be
// then $X will be unified with TyError, but the error still needs to be
// reported.
if !infcx.tcx.sess.has_errors() || !predicate.references_error() {
span_err!(infcx.tcx.sess, obligation.cause.span, E0271,

View file

@ -308,7 +308,7 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>,
let mut error = false;
ty::maybe_walk_ty(ty, |ty| {
match ty.sty {
ty::ty_param(ref param_ty) => {
ty::TyParam(ref param_ty) => {
if param_ty.space == SelfSpace {
error = true;
}
@ -316,7 +316,7 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>,
false // no contained types to walk
}
ty::ty_projection(ref data) => {
ty::TyProjection(ref data) => {
// This is a projected type `<Foo as SomeTrait>::X`.
// Compute supertraits of current trait lazily.
@ -367,7 +367,7 @@ impl<'tcx> Repr<'tcx> for ObjectSafetyViolation<'tcx> {
fn is_self<'tcx>(ty: Ty<'tcx>) -> bool {
match ty.sty {
ty::ty_param(ref data) => data.space == subst::SelfSpace,
ty::TyParam(ref data) => data.space == subst::SelfSpace,
_ => false,
}
}

View file

@ -153,7 +153,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext
debug!("consider_unification_despite_ambiguity: self_ty.sty={:?}",
self_ty.sty);
match self_ty.sty {
ty::ty_closure(closure_def_id, substs) => {
ty::TyClosure(closure_def_id, substs) => {
let closure_typer = selcx.closure_typer();
let closure_type = closure_typer.closure_type(closure_def_id, substs);
let ty::Binder((_, ret_type)) =
@ -261,7 +261,7 @@ impl<'a,'b,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'b,'tcx> {
let ty = ty_fold::super_fold_ty(self, ty);
match ty.sty {
ty::ty_projection(ref data) if !data.has_escaping_regions() => { // (*)
ty::TyProjection(ref data) if !data.has_escaping_regions() => { // (*)
// (*) This is kind of hacky -- we need to be able to
// handle normalization within binders because
@ -408,11 +408,11 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
}
}
/// in various error cases, we just set ty_err and return an obligation
/// in various error cases, we just set TyError and return an obligation
/// that, when fulfilled, will lead to an error.
///
/// FIXME: the ty_err created here can enter the obligation we create,
/// leading to error messages involving ty_err.
/// FIXME: the TyError created here can enter the obligation we create,
/// leading to error messages involving TyError.
fn normalize_to_error<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
@ -554,8 +554,8 @@ fn assemble_candidates_from_trait_def<'cx,'tcx>(
{
// Check whether the self-type is itself a projection.
let trait_ref = match obligation_trait_ref.self_ty().sty {
ty::ty_projection(ref data) => data.trait_ref.clone(),
ty::ty_infer(ty::TyVar(_)) => {
ty::TyProjection(ref data) => data.trait_ref.clone(),
ty::TyInfer(ty::TyVar(_)) => {
// If the self-type is an inference variable, then it MAY wind up
// being a projected type, so induce an ambiguity.
candidate_set.ambiguous = true;
@ -625,7 +625,7 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
debug!("assemble_candidates_from_object_type(object_ty={})",
object_ty.repr(infcx.tcx));
let data = match object_ty.sty {
ty::ty_trait(ref data) => data,
ty::TyTrait(ref data) => data,
_ => {
selcx.tcx().sess.span_bug(
obligation.cause.span,
@ -883,7 +883,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
// definition for the associated type. This error
// ought to be reported by the type checker method
// `check_impl_items_against_trait`, so here we
// just return ty_err.
// just return TyError.
return (selcx.tcx().types.err, vec!());
}
}

View file

@ -350,7 +350,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// lifetimes can appear inside the self-type.
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
let (closure_def_id, substs) = match self_ty.sty {
ty::ty_closure(id, ref substs) => (id, substs.clone()),
ty::TyClosure(id, ref substs) => (id, substs.clone()),
_ => { return; }
};
assert!(!substs.has_escaping_regions());
@ -950,8 +950,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// before we go into the whole skolemization thing, just
// quickly check if the self-type is a projection at all.
let trait_def_id = match poly_trait_predicate.0.trait_ref.self_ty().sty {
ty::ty_projection(ref data) => data.trait_ref.def_id,
ty::ty_infer(ty::TyVar(_)) => {
ty::TyProjection(ref data) => data.trait_ref.def_id,
ty::TyInfer(ty::TyVar(_)) => {
// If the self-type is an inference variable, then it MAY wind up
// being a projected type, so induce an ambiguity.
//
@ -994,7 +994,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
skol_map.repr(self.tcx()));
let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty {
ty::ty_projection(ref data) => &data.trait_ref,
ty::TyProjection(ref data) => &data.trait_ref,
_ => {
self.tcx().sess.span_bug(
obligation.cause.span,
@ -1134,8 +1134,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// type/region parameters
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
let (closure_def_id, substs) = match self_ty.sty {
ty::ty_closure(id, substs) => (id, substs),
ty::ty_infer(ty::TyVar(_)) => {
ty::TyClosure(id, substs) => (id, substs),
ty::TyInfer(ty::TyVar(_)) => {
debug!("assemble_unboxed_closure_candidates: ambiguous self-type");
candidates.ambiguous = true;
return Ok(());
@ -1179,13 +1179,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// ok to skip binder because what we are inspecting doesn't involve bound regions
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
match self_ty.sty {
ty::ty_infer(ty::TyVar(_)) => {
ty::TyInfer(ty::TyVar(_)) => {
debug!("assemble_fn_pointer_candidates: ambiguous self-type");
candidates.ambiguous = true; // could wind up being a fn() type
}
// provide an impl, but only for suitable `fn` pointers
ty::ty_bare_fn(_, &ty::BareFnTy {
ty::TyBareFn(_, &ty::BareFnTy {
unsafety: ast::Unsafety::Normal,
abi: abi::Rust,
sig: ty::Binder(ty::FnSig {
@ -1241,7 +1241,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if ty::trait_has_default_impl(self.tcx(), def_id) {
match self_ty.sty {
ty::ty_trait(..) => {
ty::TyTrait(..) => {
// For object types, we don't know what the closed
// over types are. For most traits, this means we
// conservatively say nothing; a candidate may be
@ -1255,8 +1255,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
candidates.vec.push(DefaultImplObjectCandidate(def_id));
}
}
ty::ty_param(..) |
ty::ty_projection(..) => {
ty::TyParam(..) |
ty::TyProjection(..) => {
// In these cases, we don't know what the actual
// type is. Therefore, we cannot break it down
// into its constituent types. So we don't
@ -1271,7 +1271,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// for an example of a test case that exercises
// this path.
}
ty::ty_infer(ty::TyVar(_)) => {
ty::TyInfer(ty::TyVar(_)) => {
// the defaulted impl might apply, we don't know
candidates.ambiguous = true;
}
@ -1325,7 +1325,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let (self_ty, _) =
self.infcx().skolemize_late_bound_regions(&bound_self_ty, snapshot);
let poly_trait_ref = match self_ty.sty {
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
match self.tcx().lang_items.to_builtin_kind(obligation.predicate.def_id()) {
Some(bound @ ty::BoundSend) | Some(bound @ ty::BoundSync) => {
if data.bounds.builtin_bounds.contains(&bound) {
@ -1340,7 +1340,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
data.principal_trait_ref_with_self_ty(self.tcx(), self_ty)
}
ty::ty_infer(ty::TyVar(_)) => {
ty::TyInfer(ty::TyVar(_)) => {
debug!("assemble_candidates_from_object_ty: ambiguous");
candidates.ambiguous = true; // could wind up being an object type
return Ok(());
@ -1399,7 +1399,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let may_apply = match (&source.sty, &target.sty) {
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
(&ty::ty_trait(ref data_a), &ty::ty_trait(ref data_b)) => {
(&ty::TyTrait(ref data_a), &ty::TyTrait(ref data_b)) => {
// Upcasts permit two things:
//
// 1. Dropping builtin bounds, e.g. `Foo+Send` to `Foo`
@ -1416,23 +1416,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// T -> Trait.
(_, &ty::ty_trait(_)) => true,
(_, &ty::TyTrait(_)) => true,
// Ambiguous handling is below T -> Trait, because inference
// variables can still implement Unsize<Trait> and nested
// obligations will have the final say (likely deferred).
(&ty::ty_infer(ty::TyVar(_)), _) |
(_, &ty::ty_infer(ty::TyVar(_))) => {
(&ty::TyInfer(ty::TyVar(_)), _) |
(_, &ty::TyInfer(ty::TyVar(_))) => {
debug!("assemble_candidates_for_unsizing: ambiguous");
candidates.ambiguous = true;
false
}
// [T; n] -> [T].
(&ty::ty_vec(_, Some(_)), &ty::ty_vec(_, None)) => true,
(&ty::TyArray(_, Some(_)), &ty::TyArray(_, None)) => true,
// Struct<T> -> Struct<U>.
(&ty::ty_struct(def_id_a, _), &ty::ty_struct(def_id_b, _)) => {
(&ty::TyStruct(def_id_a, _), &ty::TyStruct(def_id_b, _)) => {
def_id_a == def_id_b
}
@ -1579,19 +1579,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let self_ty = self.infcx.shallow_resolve(obligation.predicate.0.self_ty());
return match self_ty.sty {
ty::ty_infer(ty::IntVar(_)) |
ty::ty_infer(ty::FloatVar(_)) |
ty::ty_uint(_) |
ty::ty_int(_) |
ty::ty_bool |
ty::ty_float(_) |
ty::ty_bare_fn(..) |
ty::ty_char => {
ty::TyInfer(ty::IntVar(_)) |
ty::TyInfer(ty::FloatVar(_)) |
ty::TyUint(_) |
ty::TyInt(_) |
ty::TyBool |
ty::TyFloat(_) |
ty::TyBareFn(..) |
ty::TyChar => {
// safe for everything
ok_if(Vec::new())
}
ty::ty_uniq(_) => { // Box<T>
ty::TyBox(_) => { // Box<T>
match bound {
ty::BoundCopy => Err(Unimplemented),
@ -1603,7 +1603,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::ty_ptr(..) => { // *const T, *mut T
ty::TyRawPtr(..) => { // *const T, *mut T
match bound {
ty::BoundCopy | ty::BoundSized => ok_if(Vec::new()),
@ -1613,7 +1613,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
match bound {
ty::BoundSized => Err(Unimplemented),
ty::BoundCopy => {
@ -1641,7 +1641,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::ty_rptr(_, ty::mt { ty: _, mutbl }) => {
ty::TyRef(_, ty::mt { ty: _, mutbl }) => {
// &mut T or &T
match bound {
ty::BoundCopy => {
@ -1662,7 +1662,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::ty_vec(element_ty, ref len) => {
ty::TyArray(element_ty, ref len) => {
// [T; n] and [T]
match bound {
ty::BoundCopy => {
@ -1689,7 +1689,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::ty_str => {
ty::TyStr => {
// Equivalent to [u8]
match bound {
ty::BoundSync | ty::BoundSend => {
@ -1701,9 +1701,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
ty::ty_tup(ref tys) => ok_if(tys.clone()),
ty::TyTuple(ref tys) => ok_if(tys.clone()),
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
// FIXME -- This case is tricky. In the case of by-ref
// closures particularly, we need the results of
// inference to decide how to reflect the type of each
@ -1738,7 +1738,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
let types: Vec<Ty> =
ty::struct_fields(self.tcx(), def_id, substs).iter()
.map(|f| f.mt.ty)
@ -1746,7 +1746,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
nominal(bound, types)
}
ty::ty_enum(def_id, substs) => {
ty::TyEnum(def_id, substs) => {
let types: Vec<Ty> =
ty::substd_enum_variants(self.tcx(), def_id, substs)
.iter()
@ -1756,7 +1756,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
nominal(bound, types)
}
ty::ty_projection(_) | ty::ty_param(_) => {
ty::TyProjection(_) | ty::TyParam(_) => {
// Note: A type parameter is only considered to meet a
// particular bound if there is a where clause telling
// us that it does, and that case is handled by
@ -1764,7 +1764,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Ok(ParameterBuiltin)
}
ty::ty_infer(ty::TyVar(_)) => {
ty::TyInfer(ty::TyVar(_)) => {
// Unbound type variable. Might or might not have
// applicable impls and so forth, depending on what
// those type variables wind up being bound to.
@ -1772,11 +1772,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Ok(AmbiguousBuiltin)
}
ty::ty_err => ok_if(Vec::new()),
ty::TyError => ok_if(Vec::new()),
ty::ty_infer(ty::FreshTy(_))
| ty::ty_infer(ty::FreshIntTy(_))
| ty::ty_infer(ty::FreshFloatTy(_)) => {
ty::TyInfer(ty::FreshTy(_))
| ty::TyInfer(ty::FreshIntTy(_))
| ty::TyInfer(ty::FreshFloatTy(_)) => {
self.tcx().sess.bug(
&format!(
"asked to assemble builtin bounds of unexpected type: {}",
@ -1820,51 +1820,51 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
/// ```
fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Option<Vec<Ty<'tcx>>> {
match t.sty {
ty::ty_uint(_) |
ty::ty_int(_) |
ty::ty_bool |
ty::ty_float(_) |
ty::ty_bare_fn(..) |
ty::ty_str |
ty::ty_err |
ty::ty_infer(ty::IntVar(_)) |
ty::ty_infer(ty::FloatVar(_)) |
ty::ty_char => {
ty::TyUint(_) |
ty::TyInt(_) |
ty::TyBool |
ty::TyFloat(_) |
ty::TyBareFn(..) |
ty::TyStr |
ty::TyError |
ty::TyInfer(ty::IntVar(_)) |
ty::TyInfer(ty::FloatVar(_)) |
ty::TyChar => {
Some(Vec::new())
}
ty::ty_trait(..) |
ty::ty_param(..) |
ty::ty_projection(..) |
ty::ty_infer(ty::TyVar(_)) |
ty::ty_infer(ty::FreshTy(_)) |
ty::ty_infer(ty::FreshIntTy(_)) |
ty::ty_infer(ty::FreshFloatTy(_)) => {
ty::TyTrait(..) |
ty::TyParam(..) |
ty::TyProjection(..) |
ty::TyInfer(ty::TyVar(_)) |
ty::TyInfer(ty::FreshTy(_)) |
ty::TyInfer(ty::FreshIntTy(_)) |
ty::TyInfer(ty::FreshFloatTy(_)) => {
self.tcx().sess.bug(
&format!(
"asked to assemble constituent types of unexpected type: {}",
t.repr(self.tcx())));
}
ty::ty_uniq(referent_ty) => { // Box<T>
ty::TyBox(referent_ty) => { // Box<T>
Some(vec![referent_ty])
}
ty::ty_ptr(ty::mt { ty: element_ty, ..}) |
ty::ty_rptr(_, ty::mt { ty: element_ty, ..}) => {
ty::TyRawPtr(ty::mt { ty: element_ty, ..}) |
ty::TyRef(_, ty::mt { ty: element_ty, ..}) => {
Some(vec![element_ty])
},
ty::ty_vec(element_ty, _) => {
ty::TyArray(element_ty, _) => {
Some(vec![element_ty])
}
ty::ty_tup(ref tys) => {
ty::TyTuple(ref tys) => {
// (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
Some(tys.clone())
}
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
match self.closure_typer.closure_upvars(def_id, substs) {
@ -1878,19 +1878,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// for `PhantomData<T>`, we pass `T`
ty::ty_struct(def_id, substs)
ty::TyStruct(def_id, substs)
if Some(def_id) == self.tcx().lang_items.phantom_data() =>
{
Some(substs.types.get_slice(TypeSpace).to_vec())
}
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
Some(ty::struct_fields(self.tcx(), def_id, substs).iter()
.map(|f| f.mt.ty)
.collect())
}
ty::ty_enum(def_id, substs) => {
ty::TyEnum(def_id, substs) => {
Some(ty::substd_enum_variants(self.tcx(), def_id, substs)
.iter()
.flat_map(|variant| &variant.args)
@ -2169,7 +2169,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// OK to skip binder, it is reintroduced below
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
match self_ty.sty {
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
// OK to skip the binder, it is reintroduced below
let input_types = data.principal.skip_binder().substs.types.get_slice(TypeSpace);
let assoc_types = data.bounds.projection_bounds
@ -2299,7 +2299,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// case that results. -nmatsakis
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
let poly_trait_ref = match self_ty.sty {
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
data.principal_trait_ref_with_self_ty(self.tcx(), self_ty)
}
_ => {
@ -2437,7 +2437,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let mut nested = vec![];
match (&source.sty, &target.sty) {
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
(&ty::ty_trait(ref data_a), &ty::ty_trait(ref data_b)) => {
(&ty::TyTrait(ref data_a), &ty::TyTrait(ref data_b)) => {
// See assemble_candidates_for_unsizing for more info.
let bounds = ty::ExistentialBounds {
region_bound: data_b.bounds.region_bound,
@ -2463,7 +2463,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// T -> Trait.
(_, &ty::ty_trait(ref data)) => {
(_, &ty::TyTrait(ref data)) => {
let object_did = data.principal_def_id();
if !object_safety::is_object_safe(tcx, object_did) {
return Err(TraitNotObjectSafe(object_did));
@ -2510,7 +2510,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// [T; n] -> [T].
(&ty::ty_vec(a, Some(_)), &ty::ty_vec(b, None)) => {
(&ty::TyArray(a, Some(_)), &ty::TyArray(b, None)) => {
let origin = infer::Misc(obligation.cause.span);
if self.infcx.sub_types(false, origin, a, b).is_err() {
return Err(Unimplemented);
@ -2518,7 +2518,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// Struct<T> -> Struct<U>.
(&ty::ty_struct(def_id, substs_a), &ty::ty_struct(_, substs_b)) => {
(&ty::TyStruct(def_id, substs_a), &ty::TyStruct(_, substs_b)) => {
let fields = ty::lookup_struct_fields(tcx, def_id).iter().map(|f| {
ty::lookup_field_type_unsubstituted(tcx, def_id, f.id)
}).collect::<Vec<_>>();
@ -2531,7 +2531,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
};
let mut ty_params = vec![];
ty::walk_ty(field, |ty| {
if let ty::ty_param(p) = ty.sty {
if let ty::TyParam(p) = ty.sty {
assert!(p.space == TypeSpace);
let idx = p.idx as usize;
if !ty_params.contains(&idx) {
@ -2544,7 +2544,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// Replace type parameters used in unsizing with
// ty_err and ensure they do not affect any other fields.
// TyError and ensure they do not affect any other fields.
// This could be checked after type collection for any struct
// with a potentially unsized trailing field.
let mut new_substs = substs_a.clone();

File diff suppressed because it is too large Load diff

View file

@ -590,51 +590,51 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
ty: Ty<'tcx>)
-> Ty<'tcx> {
let sty = match ty.sty {
ty::ty_uniq(typ) => {
ty::ty_uniq(typ.fold_with(this))
ty::TyBox(typ) => {
ty::TyBox(typ.fold_with(this))
}
ty::ty_ptr(ref tm) => {
ty::ty_ptr(tm.fold_with(this))
ty::TyRawPtr(ref tm) => {
ty::TyRawPtr(tm.fold_with(this))
}
ty::ty_vec(typ, sz) => {
ty::ty_vec(typ.fold_with(this), sz)
ty::TyArray(typ, sz) => {
ty::TyArray(typ.fold_with(this), sz)
}
ty::ty_enum(tid, ref substs) => {
ty::TyEnum(tid, ref substs) => {
let substs = substs.fold_with(this);
ty::ty_enum(tid, this.tcx().mk_substs(substs))
ty::TyEnum(tid, this.tcx().mk_substs(substs))
}
ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
ty::ty_trait(box ty::TyTrait {
ty::TyTrait(box ty::TraitTy { ref principal, ref bounds }) => {
ty::TyTrait(box ty::TraitTy {
principal: principal.fold_with(this),
bounds: bounds.fold_with(this),
})
}
ty::ty_tup(ref ts) => {
ty::ty_tup(ts.fold_with(this))
ty::TyTuple(ref ts) => {
ty::TyTuple(ts.fold_with(this))
}
ty::ty_bare_fn(opt_def_id, ref f) => {
ty::TyBareFn(opt_def_id, ref f) => {
let bfn = f.fold_with(this);
ty::ty_bare_fn(opt_def_id, this.tcx().mk_bare_fn(bfn))
ty::TyBareFn(opt_def_id, this.tcx().mk_bare_fn(bfn))
}
ty::ty_rptr(r, ref tm) => {
ty::TyRef(r, ref tm) => {
let r = r.fold_with(this);
ty::ty_rptr(this.tcx().mk_region(r), tm.fold_with(this))
ty::TyRef(this.tcx().mk_region(r), tm.fold_with(this))
}
ty::ty_struct(did, ref substs) => {
ty::TyStruct(did, ref substs) => {
let substs = substs.fold_with(this);
ty::ty_struct(did, this.tcx().mk_substs(substs))
ty::TyStruct(did, this.tcx().mk_substs(substs))
}
ty::ty_closure(did, ref substs) => {
ty::TyClosure(did, ref substs) => {
let s = substs.fold_with(this);
ty::ty_closure(did, this.tcx().mk_substs(s))
ty::TyClosure(did, this.tcx().mk_substs(s))
}
ty::ty_projection(ref data) => {
ty::ty_projection(data.fold_with(this))
ty::TyProjection(ref data) => {
ty::TyProjection(data.fold_with(this))
}
ty::ty_bool | ty::ty_char | ty::ty_str |
ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
ty::ty_err | ty::ty_infer(_) |
ty::ty_param(..) => {
ty::TyBool | ty::TyChar | ty::TyStr |
ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
ty::TyError | ty::TyInfer(_) |
ty::TyParam(..) => {
ty.sty.clone()
}
};

View file

@ -66,18 +66,18 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> {
if a == b { return Ok(a); }
match (&a.sty, &b.sty) {
(_, &ty::ty_infer(ty::FreshTy(_))) |
(_, &ty::ty_infer(ty::FreshIntTy(_))) |
(_, &ty::ty_infer(ty::FreshFloatTy(_))) => {
(_, &ty::TyInfer(ty::FreshTy(_))) |
(_, &ty::TyInfer(ty::FreshIntTy(_))) |
(_, &ty::TyInfer(ty::FreshFloatTy(_))) => {
Ok(a)
}
(&ty::ty_infer(_), _) |
(_, &ty::ty_infer(_)) => {
(&ty::TyInfer(_), _) |
(_, &ty::TyInfer(_)) => {
Err(ty::terr_sorts(ty_relate::expected_found(self, &a, &b)))
}
(&ty::ty_err, _) | (_, &ty::ty_err) => {
(&ty::TyError, _) | (_, &ty::TyError) => {
Ok(self.tcx().types.err)
}

View file

@ -438,87 +438,87 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
let b_sty = &b.sty;
debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty);
match (a_sty, b_sty) {
(&ty::ty_infer(_), _) |
(_, &ty::ty_infer(_)) =>
(&ty::TyInfer(_), _) |
(_, &ty::TyInfer(_)) =>
{
// The caller should handle these cases!
tcx.sess.bug("var types encountered in super_relate_tys")
}
(&ty::ty_err, _) | (_, &ty::ty_err) =>
(&ty::TyError, _) | (_, &ty::TyError) =>
{
Ok(tcx.types.err)
}
(&ty::ty_char, _) |
(&ty::ty_bool, _) |
(&ty::ty_int(_), _) |
(&ty::ty_uint(_), _) |
(&ty::ty_float(_), _) |
(&ty::ty_str, _)
(&ty::TyChar, _) |
(&ty::TyBool, _) |
(&ty::TyInt(_), _) |
(&ty::TyUint(_), _) |
(&ty::TyFloat(_), _) |
(&ty::TyStr, _)
if a == b =>
{
Ok(a)
}
(&ty::ty_param(ref a_p), &ty::ty_param(ref b_p))
(&ty::TyParam(ref a_p), &ty::TyParam(ref b_p))
if a_p.idx == b_p.idx && a_p.space == b_p.space =>
{
Ok(a)
}
(&ty::ty_enum(a_id, a_substs), &ty::ty_enum(b_id, b_substs))
(&ty::TyEnum(a_id, a_substs), &ty::TyEnum(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_enum(tcx, a_id, tcx.mk_substs(substs)))
}
(&ty::ty_trait(ref a_), &ty::ty_trait(ref b_)) =>
(&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))
}
(&ty::ty_struct(a_id, a_substs), &ty::ty_struct(b_id, b_substs))
(&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)))
}
(&ty::ty_closure(a_id, a_substs),
&ty::ty_closure(b_id, b_substs))
(&ty::TyClosure(a_id, a_substs),
&ty::TyClosure(b_id, b_substs))
if a_id == b_id =>
{
// All ty_closure types with the same id represent
// All TyClosure types with the same id represent
// 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)))
}
(&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) =>
(&ty::TyBox(a_inner), &ty::TyBox(b_inner)) =>
{
let typ = try!(relation.relate(&a_inner, &b_inner));
Ok(ty::mk_uniq(tcx, typ))
}
(&ty::ty_ptr(ref a_mt), &ty::ty_ptr(ref b_mt)) =>
(&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))
}
(&ty::ty_rptr(a_r, ref a_mt), &ty::ty_rptr(b_r, ref b_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))
}
(&ty::ty_vec(a_t, Some(sz_a)), &ty::ty_vec(b_t, Some(sz_b))) =>
(&ty::TyArray(a_t, Some(sz_a)), &ty::TyArray(b_t, Some(sz_b))) =>
{
let t = try!(relation.relate(&a_t, &b_t));
if sz_a == sz_b {
@ -528,13 +528,13 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
}
}
(&ty::ty_vec(a_t, None), &ty::ty_vec(b_t, None)) =>
(&ty::TyArray(a_t, None), &ty::TyArray(b_t, None)) =>
{
let t = try!(relation.relate(&a_t, &b_t));
Ok(ty::mk_vec(tcx, t, None))
}
(&ty::ty_tup(ref as_), &ty::ty_tup(ref bs)) =>
(&ty::TyTuple(ref as_), &ty::TyTuple(ref bs)) =>
{
if as_.len() == bs.len() {
let ts = try!(as_.iter().zip(bs)
@ -549,14 +549,14 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
}
}
(&ty::ty_bare_fn(a_opt_def_id, a_fty), &ty::ty_bare_fn(b_opt_def_id, b_fty))
(&ty::TyBareFn(a_opt_def_id, a_fty), &ty::TyBareFn(b_opt_def_id, b_fty))
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)))
}
(&ty::ty_projection(ref a_data), &ty::ty_projection(ref b_data)) =>
(&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))

View file

@ -68,33 +68,33 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> IntoIter<Ty<'tcx>> {
fn push_subtypes<'tcx>(stack: &mut Vec<Ty<'tcx>>, parent_ty: Ty<'tcx>) {
match parent_ty.sty {
ty::ty_bool | ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
ty::ty_str | ty::ty_infer(_) | ty::ty_param(_) | ty::ty_err => {
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyError => {
}
ty::ty_uniq(ty) | ty::ty_vec(ty, _) => {
ty::TyBox(ty) | ty::TyArray(ty, _) => {
stack.push(ty);
}
ty::ty_ptr(ref mt) | ty::ty_rptr(_, ref mt) => {
ty::TyRawPtr(ref mt) | ty::TyRef(_, ref mt) => {
stack.push(mt.ty);
}
ty::ty_projection(ref data) => {
ty::TyProjection(ref data) => {
push_reversed(stack, data.trait_ref.substs.types.as_slice());
}
ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
ty::TyTrait(box ty::TraitTy { ref principal, ref bounds }) => {
push_reversed(stack, principal.substs().types.as_slice());
push_reversed(stack, &bounds.projection_bounds.iter().map(|pred| {
pred.0.ty
}).collect::<Vec<_>>());
}
ty::ty_enum(_, ref substs) |
ty::ty_struct(_, ref substs) |
ty::ty_closure(_, ref substs) => {
ty::TyEnum(_, ref substs) |
ty::TyStruct(_, ref substs) |
ty::TyClosure(_, ref substs) => {
push_reversed(stack, substs.types.as_slice());
}
ty::ty_tup(ref ts) => {
ty::TyTuple(ref ts) => {
push_reversed(stack, ts);
}
ty::ty_bare_fn(_, ref ft) => {
ty::TyBareFn(_, ref ft) => {
push_sig_subtypes(stack, &ft.sig);
}
}

View file

@ -19,11 +19,11 @@ use middle::ty::{ReEarlyBound, BrFresh, ctxt};
use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty};
use middle::ty::{ReSkolemized, ReVar, BrEnv};
use middle::ty::{mt, Ty, ParamTy};
use middle::ty::{ty_bool, ty_char, ty_struct, ty_enum};
use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn};
use middle::ty::{ty_param, ty_ptr, ty_rptr, ty_tup};
use middle::ty::ty_closure;
use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer};
use middle::ty::{TyBool, TyChar, TyStruct, TyEnum};
use middle::ty::{TyError, TyStr, TyArray, TyFloat, TyBareFn};
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
use middle::ty::TyClosure;
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
use middle::ty;
use middle::ty_fold::{self, TypeFoldable};
@ -363,24 +363,24 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
// pretty print the structural type representation:
match typ.sty {
ty_bool => "bool".to_string(),
ty_char => "char".to_string(),
ty_int(t) => ast_util::int_ty_to_string(t, None).to_string(),
ty_uint(t) => ast_util::uint_ty_to_string(t, None).to_string(),
ty_float(t) => ast_util::float_ty_to_string(t).to_string(),
ty_uniq(typ) => format!("Box<{}>", ty_to_string(cx, typ)),
ty_ptr(ref tm) => {
TyBool => "bool".to_string(),
TyChar => "char".to_string(),
TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(),
TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(),
TyFloat(t) => ast_util::float_ty_to_string(t).to_string(),
TyBox(typ) => format!("Box<{}>", ty_to_string(cx, typ)),
TyRawPtr(ref tm) => {
format!("*{} {}", match tm.mutbl {
ast::MutMutable => "mut",
ast::MutImmutable => "const",
}, ty_to_string(cx, tm.ty))
}
ty_rptr(r, ref tm) => {
TyRef(r, ref tm) => {
let mut buf = region_ptr_to_string(cx, *r);
buf.push_str(&mt_to_string(cx, tm));
buf
}
ty_tup(ref elems) => {
TyTuple(ref elems) => {
let strs = elems
.iter()
.map(|elem| ty_to_string(cx, *elem))
@ -390,28 +390,28 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
strs => format!("({})", strs.connect(", "))
}
}
ty_bare_fn(opt_def_id, ref f) => {
TyBareFn(opt_def_id, ref f) => {
bare_fn_to_string(cx, opt_def_id, f.unsafety, f.abi, None, &f.sig)
}
ty_infer(infer_ty) => infer_ty_to_string(cx, infer_ty),
ty_err => "[type error]".to_string(),
ty_param(ref param_ty) => param_ty.user_string(cx),
ty_enum(did, substs) | ty_struct(did, substs) => {
TyInfer(infer_ty) => infer_ty_to_string(cx, infer_ty),
TyError => "[type error]".to_string(),
TyParam(ref param_ty) => param_ty.user_string(cx),
TyEnum(did, substs) | TyStruct(did, substs) => {
let base = ty::item_path_str(cx, did);
parameterized(cx, &base, substs, did, &[],
|| ty::lookup_item_type(cx, did).generics)
}
ty_trait(ref data) => {
TyTrait(ref data) => {
data.user_string(cx)
}
ty::ty_projection(ref data) => {
ty::TyProjection(ref data) => {
format!("<{} as {}>::{}",
data.trait_ref.self_ty().user_string(cx),
data.trait_ref.user_string(cx),
data.item_name.user_string(cx))
}
ty_str => "str".to_string(),
ty_closure(ref did, substs) => {
TyStr => "str".to_string(),
TyClosure(ref did, substs) => {
let closure_tys = cx.closure_tys.borrow();
closure_tys.get(did).map(|closure_type| {
closure_to_string(cx, &closure_type.subst(cx, substs), did)
@ -431,7 +431,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
}
})
}
ty_vec(t, sz) => {
TyArray(t, sz) => {
let inner_str = ty_to_string(cx, t);
match sz {
Some(n) => format!("[{}; {}]", inner_str, n),
@ -701,9 +701,9 @@ impl<'tcx> UserString<'tcx> for TraitAndProjections<'tcx> {
}
}
impl<'tcx> UserString<'tcx> for ty::TyTrait<'tcx> {
impl<'tcx> UserString<'tcx> for ty::TraitTy<'tcx> {
fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
let &ty::TyTrait { ref principal, ref bounds } = self;
let &ty::TraitTy { ref principal, ref bounds } = self;
let mut components = vec![];

View file

@ -752,7 +752,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
}
LpExtend(ref lp_base, _, LpInterior(InteriorField(_))) => {
match lp_base.to_type().sty {
ty::ty_struct(def_id, _) | ty::ty_enum(def_id, _) => {
ty::TyStruct(def_id, _) | ty::TyEnum(def_id, _) => {
if ty::has_dtor(self.tcx(), def_id) {
// In the case where the owner implements drop, then
// the path must be initialized to prevent a case of

View file

@ -339,7 +339,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
};
match (&parent_ty.sty, enum_variant_info) {
(&ty::ty_tup(ref v), None) => {
(&ty::TyTuple(ref v), None) => {
let tuple_idx = match *origin_field_name {
mc::PositionalField(tuple_idx) => tuple_idx,
mc::NamedField(_) =>
@ -354,7 +354,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
}
}
(&ty::ty_struct(def_id, ref _substs), None) => {
(&ty::TyStruct(def_id, ref _substs), None) => {
let fields = ty::lookup_struct_fields(tcx, def_id);
match *origin_field_name {
mc::NamedField(ast_name) => {
@ -378,7 +378,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
}
}
(&ty::ty_enum(enum_def_id, substs), ref enum_variant_info) => {
(&ty::TyEnum(enum_def_id, substs), ref enum_variant_info) => {
let variant_info = {
let mut variants = ty::substd_enum_variants(tcx, enum_def_id, substs);
match *enum_variant_info {

View file

@ -179,7 +179,7 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
mc::cat_interior(ref b, mc::InteriorField(_)) |
mc::cat_interior(ref b, mc::InteriorElement(Kind::Pattern, _)) => {
match b.ty.sty {
ty::ty_struct(did, _) | ty::ty_enum(did, _) => {
ty::TyStruct(did, _) | ty::TyEnum(did, _) => {
if ty::has_dtor(bccx.tcx, did) {
Some(cmt.clone())
} else {

View file

@ -137,8 +137,8 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
mc::cat_downcast(ref b, _) |
mc::cat_interior(ref b, mc::InteriorField(_)) => {
match b.ty.sty {
ty::ty_struct(did, _) |
ty::ty_enum(did, _) if ty::has_dtor(bccx.tcx, did) => {
ty::TyStruct(did, _) |
ty::TyEnum(did, _) if ty::has_dtor(bccx.tcx, did) => {
bccx.span_err(
move_from.span,
&format!("cannot move out of type `{}`, \

View file

@ -656,7 +656,7 @@ fn glb_bound_free_infer() {
// `&'_ isize`
let t_resolve1 = env.infcx.shallow_resolve(t_infer1);
match t_resolve1.sty {
ty::ty_rptr(..) => { }
ty::TyRef(..) => { }
_ => { panic!("t_resolve1={}", t_resolve1.repr(env.infcx.tcx)); }
}
})

View file

@ -145,7 +145,7 @@ impl LintPass for TypeLimits {
_ => {
let t = ty::expr_ty(cx.tcx, &**expr);
match t.sty {
ty::ty_uint(_) => {
ty::TyUint(_) => {
cx.span_lint(UNSIGNED_NEGATION, e.span,
"negation of unsigned int variable may \
be unintentional");
@ -170,8 +170,8 @@ impl LintPass for TypeLimits {
if is_shift_binop(binop.node) {
let opt_ty_bits = match ty::expr_ty(cx.tcx, &**l).sty {
ty::ty_int(t) => Some(int_ty_bits(t, cx.sess().target.int_type)),
ty::ty_uint(t) => Some(uint_ty_bits(t, cx.sess().target.uint_type)),
ty::TyInt(t) => Some(int_ty_bits(t, cx.sess().target.int_type)),
ty::TyUint(t) => Some(uint_ty_bits(t, cx.sess().target.uint_type)),
_ => None
};
@ -195,7 +195,7 @@ impl LintPass for TypeLimits {
},
ast::ExprLit(ref lit) => {
match ty::expr_ty(cx.tcx, e).sty {
ty::ty_int(t) => {
ty::TyInt(t) => {
match lit.node {
ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
@ -219,7 +219,7 @@ impl LintPass for TypeLimits {
_ => panic!()
};
},
ty::ty_uint(t) => {
ty::TyUint(t) => {
let uint_type = if let ast::TyUs = t {
cx.sess().target.uint_type
} else {
@ -236,7 +236,7 @@ impl LintPass for TypeLimits {
&*format!("literal out of range for {:?}", t));
}
},
ty::ty_float(t) => {
ty::TyFloat(t) => {
let (min, max) = float_ty_range(t);
let lit_val: f64 = match lit.node {
ast::LitFloat(ref v, _) |
@ -345,7 +345,7 @@ impl LintPass for TypeLimits {
binop
};
match ty::expr_ty(tcx, expr).sty {
ty::ty_int(int_ty) => {
ty::TyInt(int_ty) => {
let (min, max) = int_ty_range(int_ty);
let lit_val: i64 = match lit.node {
ast::ExprLit(ref li) => match li.node {
@ -359,7 +359,7 @@ impl LintPass for TypeLimits {
};
is_valid(norm_binop, lit_val, min, max)
}
ty::ty_uint(uint_ty) => {
ty::TyUint(uint_ty) => {
let (min, max): (u64, u64) = uint_ty_range(uint_ty);
let lit_val: u64 = match lit.node {
ast::ExprLit(ref li) => match li.node {
@ -486,7 +486,7 @@ impl BoxPointers {
let mut n_uniq: usize = 0;
ty::fold_ty(cx.tcx, ty, |t| {
match t.sty {
ty::ty_uniq(_) => {
ty::TyBox(_) => {
n_uniq += 1;
}
_ => ()
@ -591,8 +591,8 @@ impl LintPass for RawPointerDerive {
}
match ty::node_id_to_type(cx.tcx, item.id).sty {
ty::ty_enum(did, _) => did,
ty::ty_struct(did, _) => did,
ty::TyEnum(did, _) => did,
ty::TyStruct(did, _) => did,
_ => return,
}
}
@ -736,10 +736,10 @@ impl LintPass for UnusedResults {
let t = ty::expr_ty(cx.tcx, expr);
let warned = match t.sty {
ty::ty_tup(ref tys) if tys.is_empty() => return,
ty::ty_bool => return,
ty::ty_struct(did, _) |
ty::ty_enum(did, _) => {
ty::TyTuple(ref tys) if tys.is_empty() => return,
ty::TyBool => return,
ty::TyStruct(did, _) |
ty::TyEnum(did, _) => {
if ast_util::is_local(did) {
if let ast_map::NodeItem(it) = cx.tcx.map.get(did.node) {
check_must_use(cx, &it.attrs, s.span)
@ -2162,7 +2162,7 @@ impl LintPass for MutableTransmutes {
let msg = "mutating transmuted &mut T from &T may cause undefined behavior,\
consider instead using an UnsafeCell";
match get_transmute_from_to(cx, expr) {
Some((&ty::ty_rptr(_, from_mt), &ty::ty_rptr(_, to_mt))) => {
Some((&ty::TyRef(_, from_mt), &ty::TyRef(_, to_mt))) => {
if to_mt.mutbl == ast::Mutability::MutMutable
&& from_mt.mutbl == ast::Mutability::MutImmutable {
cx.span_lint(MUTABLE_TRANSMUTES, expr.span, msg);
@ -2172,7 +2172,7 @@ impl LintPass for MutableTransmutes {
}
fn get_transmute_from_to<'a, 'tcx>(cx: &Context<'a, 'tcx>, expr: &ast::Expr)
-> Option<(&'tcx ty::sty<'tcx>, &'tcx ty::sty<'tcx>)> {
-> Option<(&'tcx ty::TypeVariants<'tcx>, &'tcx ty::TypeVariants<'tcx>)> {
match expr.node {
ast::ExprPath(..) => (),
_ => return None
@ -2183,7 +2183,7 @@ impl LintPass for MutableTransmutes {
}
let typ = ty::node_id_to_type(cx.tcx, expr.id);
match typ.sty {
ty::ty_bare_fn(_, ref bare_fn) if bare_fn.abi == RustIntrinsic => {
ty::TyBareFn(_, ref bare_fn) if bare_fn.abi == RustIntrinsic => {
if let ty::FnConverging(to) = bare_fn.sig.0.output {
let from = bare_fn.sig.0.inputs[0];
return Some((&from.sty, &to.sty));
@ -2197,7 +2197,7 @@ impl LintPass for MutableTransmutes {
fn def_id_is_transmute(cx: &Context, def_id: DefId) -> bool {
match ty::lookup_item_type(cx.tcx, def_id).ty.sty {
ty::ty_bare_fn(_, ref bfty) if bfty.abi == RustIntrinsic => (),
ty::TyBareFn(_, ref bfty) if bfty.abi == RustIntrinsic => (),
_ => return false
}
ty::with_path(cx.tcx, def_id, |path| match path.last() {
@ -2260,9 +2260,9 @@ impl LintPass for DropWithReprExtern {
};
match dtor_self_type.sty {
ty::ty_enum(self_type_did, _) |
ty::ty_struct(self_type_did, _) |
ty::ty_closure(self_type_did, _) => {
ty::TyEnum(self_type_did, _) |
ty::TyStruct(self_type_did, _) |
ty::TyClosure(self_type_did, _) => {
let hints = ty::lookup_repr_hints(ctx.tcx, self_type_did);
if hints.iter().any(|attr| *attr == attr::ReprExtern) &&
ty::ty_dtor(ctx.tcx, self_type_did).has_drop_flag() {

View file

@ -711,10 +711,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
let struct_type = ty::lookup_item_type(self.tcx, id).ty;
let struct_desc = match struct_type.sty {
ty::ty_struct(_, _) =>
ty::TyStruct(_, _) =>
format!("struct `{}`", ty::item_path_str(self.tcx, id)),
// struct variant fields have inherited visibility
ty::ty_enum(..) => return,
ty::TyEnum(..) => return,
_ => self.tcx.sess.span_bug(span, "can't find struct for field")
};
let msg = match name {
@ -893,12 +893,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &ast::Expr) {
match expr.node {
ast::ExprField(ref base, ident) => {
if let ty::ty_struct(id, _) = ty::expr_ty_adjusted(self.tcx, &**base).sty {
if let ty::TyStruct(id, _) = ty::expr_ty_adjusted(self.tcx, &**base).sty {
self.check_field(expr.span, id, NamedField(ident.node.name));
}
}
ast::ExprTupField(ref base, idx) => {
if let ty::ty_struct(id, _) = ty::expr_ty_adjusted(self.tcx, &**base).sty {
if let ty::TyStruct(id, _) = ty::expr_ty_adjusted(self.tcx, &**base).sty {
self.check_field(expr.span, id, UnnamedField(idx.node));
}
}
@ -918,7 +918,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
ast::ExprStruct(_, ref fields, _) => {
match ty::expr_ty(self.tcx, expr).sty {
ty::ty_struct(ctor_id, _) => {
ty::TyStruct(ctor_id, _) => {
// RFC 736: ensure all unmentioned fields are visible.
// Rather than computing the set of unmentioned fields
// (i.e. `all_fields - fields`), just check them all.
@ -928,7 +928,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
NamedField(field.name));
}
}
ty::ty_enum(_, _) => {
ty::TyEnum(_, _) => {
match self.tcx.def_map.borrow().get(&expr.id).unwrap().full_def() {
def::DefVariant(_, variant_id, _) => {
for field in fields {
@ -995,13 +995,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
match pattern.node {
ast::PatStruct(_, ref fields, _) => {
match ty::pat_ty(self.tcx, pattern).sty {
ty::ty_struct(id, _) => {
ty::TyStruct(id, _) => {
for field in fields {
self.check_field(pattern.span, id,
NamedField(field.node.ident.name));
}
}
ty::ty_enum(_, _) => {
ty::TyEnum(_, _) => {
match self.tcx.def_map.borrow().get(&pattern.id).map(|d| d.full_def()) {
Some(def::DefVariant(_, variant_id, _)) => {
for field in fields {
@ -1026,7 +1026,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
// elsewhere).
ast::PatEnum(_, Some(ref fields)) => {
match ty::pat_ty(self.tcx, pattern).sty {
ty::ty_struct(id, _) => {
ty::TyStruct(id, _) => {
for (i, field) in fields.iter().enumerate() {
if let ast::PatWild(..) = field.node {
continue
@ -1034,7 +1034,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
self.check_field(field.span, id, UnnamedField(i));
}
}
ty::ty_enum(..) => {
ty::TyEnum(..) => {
// enum fields have no privacy at this time
}
_ => {}

View file

@ -903,7 +903,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, ex).sty;
let struct_def = match *ty {
ty::ty_struct(def_id, _) => {
ty::TyStruct(def_id, _) => {
let sub_span = self.span.span_for_last_ident(path.span);
self.fmt.ref_str(recorder::StructRef,
path.span,
@ -1316,7 +1316,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, &**sub_ex).sty;
match *ty {
ty::ty_struct(def_id, _) => {
ty::TyStruct(def_id, _) => {
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, def_id);
for (i, f) in fields.iter().enumerate() {
if i == idx.node {
@ -1330,7 +1330,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
}
}
}
ty::ty_tup(_) => {}
ty::TyTuple(_) => {}
_ => self.sess.span_bug(ex.span,
&format!("Expected struct or tuple \
type, found {:?}", ty)),

View file

@ -223,7 +223,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
ast::ExprField(ref sub_ex, ident) => {
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, &sub_ex).sty;
match *ty {
ty::ty_struct(def_id, _) => {
ty::TyStruct(def_id, _) => {
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, def_id);
for f in &fields {
if f.name == ident.node.name {

View file

@ -850,10 +850,10 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
}
match rhs_t.sty {
ty::ty_rptr(_, mt) => match mt.ty.sty {
ty::ty_str => compare_str(cx, lhs, rhs, rhs_t, debug_loc),
ty::ty_vec(ty, _) => match ty.sty {
ty::ty_uint(ast::TyU8) => {
ty::TyRef(_, mt) => match mt.ty.sty {
ty::TyStr => compare_str(cx, lhs, rhs, rhs_t, debug_loc),
ty::TyArray(ty, _) => match ty.sty {
ty::TyUint(ast::TyU8) => {
// 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();
@ -1092,7 +1092,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
).collect();
match left_ty.sty {
ty::ty_struct(def_id, substs) if !type_is_sized(bcx.tcx(), left_ty) => {
ty::TyStruct(def_id, substs) if !type_is_sized(bcx.tcx(), left_ty) => {
// The last field is technically unsized but
// since we can only ever match that field behind
// a reference we construct a fat ptr here.
@ -1116,7 +1116,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
Some(vec!(Load(bcx, val)))
} else {
match left_ty.sty {
ty::ty_vec(_, Some(n)) => {
ty::TyArray(_, Some(n)) => {
let args = extract_vec_elems(bcx, left_ty, n, 0, val);
Some(args.vals)
}

View file

@ -206,10 +206,10 @@ fn dtor_active(flag: u8) -> bool {
fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
t: Ty<'tcx>) -> Repr<'tcx> {
match t.sty {
ty::ty_tup(ref elems) => {
ty::TyTuple(ref elems) => {
Univariant(mk_struct(cx, &elems[..], false, t), 0)
}
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
let fields = ty::lookup_struct_fields(cx.tcx(), def_id);
let mut ftys = fields.iter().map(|field| {
let fty = ty::lookup_field_type(cx.tcx(), def_id, field.id, substs);
@ -223,13 +223,13 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
Univariant(mk_struct(cx, &ftys[..], packed, t), dtor_to_init_u8(dtor))
}
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
let typer = NormalizingClosureTyper::new(cx.tcx());
let upvars = typer.closure_upvars(def_id, substs).unwrap();
let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
Univariant(mk_struct(cx, &upvar_types[..], false, t), 0)
}
ty::ty_enum(def_id, substs) => {
ty::TyEnum(def_id, substs) => {
let cases = get_cases(cx.tcx(), def_id, substs);
let hint = *ty::lookup_repr_hints(cx.tcx(), def_id).get(0)
.unwrap_or(&attr::ReprAny);
@ -400,28 +400,28 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
mut path: DiscrField) -> Option<DiscrField> {
match ty.sty {
// Fat &T/&mut T/Box<T> i.e. T is [T], str, or Trait
ty::ty_rptr(_, ty::mt { ty, .. }) | ty::ty_uniq(ty) if !type_is_sized(tcx, ty) => {
ty::TyRef(_, ty::mt { ty, .. }) | ty::TyBox(ty) if !type_is_sized(tcx, ty) => {
path.push(FAT_PTR_ADDR);
Some(path)
},
// Regular thin pointer: &T/&mut T/Box<T>
ty::ty_rptr(..) | ty::ty_uniq(..) => Some(path),
ty::TyRef(..) | ty::TyBox(..) => Some(path),
// Functions are just pointers
ty::ty_bare_fn(..) => Some(path),
ty::TyBareFn(..) => Some(path),
// Is this the NonZero lang item wrapping a pointer or integer type?
ty::ty_struct(did, substs) if Some(did) == tcx.lang_items.non_zero() => {
ty::TyStruct(did, substs) if Some(did) == tcx.lang_items.non_zero() => {
let nonzero_fields = ty::lookup_struct_fields(tcx, did);
assert_eq!(nonzero_fields.len(), 1);
let nonzero_field = ty::lookup_field_type(tcx, did, nonzero_fields[0].id, substs);
match nonzero_field.sty {
ty::ty_ptr(ty::mt { ty, .. }) if !type_is_sized(tcx, ty) => {
ty::TyRawPtr(ty::mt { ty, .. }) if !type_is_sized(tcx, ty) => {
path.push_all(&[0, FAT_PTR_ADDR]);
Some(path)
},
ty::ty_ptr(..) | ty::ty_int(..) | ty::ty_uint(..) => {
ty::TyRawPtr(..) | ty::TyInt(..) | ty::TyUint(..) => {
path.push(0);
Some(path)
},
@ -431,7 +431,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
// Perhaps one of the fields of this struct is non-zero
// let's recurse and find out
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
let fields = ty::lookup_struct_fields(tcx, def_id);
for (j, field) in fields.iter().enumerate() {
let field_ty = ty::lookup_field_type(tcx, def_id, field.id, substs);
@ -445,7 +445,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
// Perhaps one of the upvars of this struct is non-zero
// Let's recurse and find out!
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
let typer = NormalizingClosureTyper::new(tcx);
let upvars = typer.closure_upvars(def_id, substs).unwrap();
let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
@ -460,7 +460,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
},
// Can we use one of the fields in this tuple?
ty::ty_tup(ref tys) => {
ty::TyTuple(ref tys) => {
for (j, &ty) in tys.iter().enumerate() {
if let Some(mut fpath) = find_discr_field_candidate(tcx, ty, path.clone()) {
fpath.push(j);
@ -472,7 +472,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
// Is this a fixed-size array of something non-zero
// with at least one element?
ty::ty_vec(ety, Some(d)) if d > 0 => {
ty::TyArray(ety, Some(d)) if d > 0 => {
if let Some(mut vpath) = find_discr_field_candidate(tcx, ety, path) {
vpath.push(0);
Some(vpath)

View file

@ -128,8 +128,8 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
let function_type;
let (fn_sig, abi, env_ty) = match fn_type.sty {
ty::ty_bare_fn(_, ref f) => (&f.sig, f.abi, None),
ty::ty_closure(closure_did, substs) => {
ty::TyBareFn(_, ref f) => (&f.sig, f.abi, None),
ty::TyClosure(closure_did, substs) => {
let typer = common::NormalizingClosureTyper::new(ccx.tcx());
function_type = typer.closure_type(closure_did, substs);
let self_type = base::self_type_for_closure(ccx, closure_did, fn_type);
@ -146,11 +146,11 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// These have an odd calling convention, so we need to manually
// unpack the input ty's
let input_tys = match fn_type.sty {
ty::ty_closure(..) => {
ty::TyClosure(..) => {
assert!(abi == abi::RustCall);
match fn_sig.inputs[0].sty {
ty::ty_tup(ref inputs) => {
ty::TyTuple(ref inputs) => {
let mut full_inputs = vec![env_ty.expect("Missing closure environment")];
full_inputs.push_all(inputs);
full_inputs
@ -158,11 +158,11 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
_ => ccx.sess().bug("expected tuple'd inputs")
}
},
ty::ty_bare_fn(..) if abi == abi::RustCall => {
ty::TyBareFn(..) if abi == abi::RustCall => {
let mut inputs = vec![fn_sig.inputs[0]];
match fn_sig.inputs[1].sty {
ty::ty_tup(ref t_in) => {
ty::TyTuple(ref t_in) => {
inputs.push_all(&t_in[..]);
inputs
}
@ -198,7 +198,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
match ret_ty.sty {
// `Box` pointer return values never alias because ownership
// is transferred
ty::ty_uniq(it) if common::type_is_sized(ccx.tcx(), it) => {
ty::TyBox(it) if common::type_is_sized(ccx.tcx(), it) => {
attrs.ret(llvm::Attribute::NoAlias);
}
_ => {}
@ -207,15 +207,15 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// We can also mark the return value as `dereferenceable` in certain cases
match ret_ty.sty {
// These are not really pointers but pairs, (pointer, len)
ty::ty_rptr(_, ty::mt { ty: inner, .. })
| ty::ty_uniq(inner) if common::type_is_sized(ccx.tcx(), inner) => {
ty::TyRef(_, ty::mt { ty: inner, .. })
| ty::TyBox(inner) if common::type_is_sized(ccx.tcx(), inner) => {
let llret_sz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner));
attrs.ret(llvm::DereferenceableAttribute(llret_sz));
}
_ => {}
}
if let ty::ty_bool = ret_ty.sty {
if let ty::TyBool = ret_ty.sty {
attrs.ret(llvm::Attribute::ZExt);
}
}
@ -235,12 +235,12 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
.arg(idx, llvm::DereferenceableAttribute(llarg_sz));
}
ty::ty_bool => {
ty::TyBool => {
attrs.arg(idx, llvm::Attribute::ZExt);
}
// `Box` pointer parameters never alias because ownership is transferred
ty::ty_uniq(inner) => {
ty::TyBox(inner) => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner));
attrs.arg(idx, llvm::Attribute::NoAlias)
@ -252,7 +252,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as both
// `readonly` and `noalias`, as LLVM's definition of `noalias` is based solely on
// memory dependencies rather than pointer equality
ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable ||
ty::TyRef(b, mt) if mt.mutbl == ast::MutMutable ||
!ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
@ -270,7 +270,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// When a reference in an argument has no named lifetime, it's impossible for that
// reference to escape this function (returned or stored beyond the call by a closure).
ty::ty_rptr(&ReLateBound(_, BrAnon(_)), mt) => {
ty::TyRef(&ReLateBound(_, BrAnon(_)), mt) => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
attrs.arg(idx, llvm::Attribute::NoCapture)
.arg(idx, llvm::DereferenceableAttribute(llsz));
@ -278,7 +278,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// & pointer parameters are also never null and we know exactly how
// many bytes we can dereference
ty::ty_rptr(_, mt) => {
ty::TyRef(_, mt) => {
let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
attrs.arg(idx, llvm::DereferenceableAttribute(llsz));
}

View file

@ -320,7 +320,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
debug_loc: DebugLoc)
-> ValueRef {
match t.sty {
ty::ty_tup(ref tys) if tys.is_empty() => {
ty::TyTuple(ref tys) if tys.is_empty() => {
// We don't need to do actual comparisons for nil.
// () == () holds but () < () does not.
match op {
@ -330,16 +330,16 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
_ => bcx.sess().bug("compare_scalar_types: must be a comparison operator")
}
}
ty::ty_bare_fn(..) | ty::ty_bool | ty::ty_uint(_) | ty::ty_char => {
ty::TyBareFn(..) | ty::TyBool | ty::TyUint(_) | ty::TyChar => {
ICmp(bcx, bin_op_to_icmp_predicate(bcx.ccx(), op, false), lhs, rhs, debug_loc)
}
ty::ty_ptr(mt) if common::type_is_sized(bcx.tcx(), mt.ty) => {
ty::TyRawPtr(mt) if common::type_is_sized(bcx.tcx(), mt.ty) => {
ICmp(bcx, bin_op_to_icmp_predicate(bcx.ccx(), op, false), lhs, rhs, debug_loc)
}
ty::ty_int(_) => {
ty::TyInt(_) => {
ICmp(bcx, bin_op_to_icmp_predicate(bcx.ccx(), op, true), lhs, rhs, debug_loc)
}
ty::ty_float(_) => {
ty::TyFloat(_) => {
FCmp(bcx, bin_op_to_fcmp_predicate(bcx.ccx(), op), lhs, rhs, debug_loc)
}
// Should never get here, because t is scalar.
@ -355,7 +355,7 @@ pub fn compare_simd_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
debug_loc: DebugLoc)
-> ValueRef {
let signed = match t.sty {
ty::ty_float(_) => {
ty::TyFloat(_) => {
// The comparison operators for floating point vectors are challenging.
// LLVM outputs a `< size x i1 >`, but if we perform a sign extension
// then bitcast to a floating point vector, the result will be `-NaN`
@ -363,8 +363,8 @@ pub fn compare_simd_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
bcx.sess().bug("compare_simd_types: comparison operators \
not supported for floating point SIMD types")
},
ty::ty_uint(_) => false,
ty::ty_int(_) => true,
ty::TyUint(_) => false,
ty::TyInt(_) => true,
_ => bcx.sess().bug("compare_simd_types: invalid SIMD type"),
};
@ -416,7 +416,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
let mut cx = cx;
match t.sty {
ty::ty_struct(..) => {
ty::TyStruct(..) => {
let repr = adt::represent_type(cx.ccx(), t);
expr::with_field_tys(cx.tcx(), t, None, |discr, field_tys| {
for (i, field_ty) in field_tys.iter().enumerate() {
@ -435,7 +435,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
}
})
}
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
let repr = adt::represent_type(cx.ccx(), t);
let typer = common::NormalizingClosureTyper::new(cx.tcx());
let upvars = typer.closure_upvars(def_id, substs).unwrap();
@ -444,23 +444,23 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
cx = f(cx, llupvar, upvar.ty);
}
}
ty::ty_vec(_, Some(n)) => {
ty::TyArray(_, Some(n)) => {
let (base, len) = tvec::get_fixed_base_and_len(cx, data_ptr, n);
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
}
ty::ty_vec(_, None) | ty::ty_str => {
ty::TyArray(_, None) | ty::TyStr => {
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
cx = tvec::iter_vec_raw(cx, data_ptr, unit_ty, info.unwrap(), f);
}
ty::ty_tup(ref args) => {
ty::TyTuple(ref args) => {
let repr = adt::represent_type(cx.ccx(), t);
for (i, arg) in args.iter().enumerate() {
let llfld_a = adt::trans_field_ptr(cx, &*repr, data_ptr, 0, i);
cx = f(cx, llfld_a, *arg);
}
}
ty::ty_enum(tid, substs) => {
ty::TyEnum(tid, substs) => {
let fcx = cx.fcx;
let ccx = fcx.ccx;
@ -574,7 +574,7 @@ fn cast_shift_rhs<F, G>(op: ast::BinOp_,
pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
val_t: Ty<'tcx>) -> (Type, u64) {
match val_t.sty {
ty::ty_int(t) => {
ty::TyInt(t) => {
let llty = Type::int_from_ty(cx.ccx(), t);
let min = match t {
ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
@ -608,15 +608,15 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
let debug_loc = call_info.debug_loc();
let (is_zero, is_signed) = match rhs_t.sty {
ty::ty_int(t) => {
ty::TyInt(t) => {
let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0, false);
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), true)
}
ty::ty_uint(t) => {
ty::TyUint(t) => {
let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0, false);
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), false)
}
ty::ty_struct(_, _) if type_is_simd(cx.tcx(), rhs_t) => {
ty::TyStruct(_, _) if type_is_simd(cx.tcx(), rhs_t) => {
let mut res = C_bool(cx.ccx(), false);
for i in 0 .. simd_size(cx.tcx(), rhs_t) {
res = Or(cx, res,
@ -665,7 +665,7 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
did: ast::DefId, t: Ty<'tcx>) -> ValueRef {
let name = csearch::get_symbol(&ccx.sess().cstore, did);
match t.sty {
ty::ty_bare_fn(_, ref fn_ty) => {
ty::TyBareFn(_, ref fn_ty) => {
match ccx.sess().target.target.adjust_abi(fn_ty.abi) {
Rust | RustCall => {
get_extern_rust_fn(ccx, t, &name[..], did)
@ -1317,7 +1317,7 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
// This is the last argument. Tuple it.
match arg_ty.sty {
ty::ty_tup(ref tupled_arg_tys) => {
ty::TyTuple(ref tupled_arg_tys) => {
let tuple_args_scope_id = cleanup::CustomScope(arg_scope);
let tuple =
unpack_datum!(bcx,
@ -1660,7 +1660,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let tcx = ccx.tcx();
let result_ty = match ctor_ty.sty {
ty::ty_bare_fn(_, ref bft) => {
ty::TyBareFn(_, ref bft) => {
ty::erase_late_bound_regions(bcx.tcx(), &bft.sig.output()).unwrap()
}
_ => ccx.sess().bug(
@ -1738,7 +1738,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
let ctor_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &ctor_ty);
let result_ty = match ctor_ty.sty {
ty::ty_bare_fn(_, ref bft) => {
ty::TyBareFn(_, ref bft) => {
ty::erase_late_bound_regions(ccx.tcx(), &bft.sig.output())
}
_ => ccx.sess().bug(
@ -2108,7 +2108,7 @@ fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
node_id: ast::NodeId,
node_type: Ty<'tcx>)
-> ValueRef {
if let ty::ty_bare_fn(_, ref f) = node_type.sty {
if let ty::TyBareFn(_, ref f) = node_type.sty {
if f.abi != Rust && f.abi != RustCall {
ccx.sess().span_bug(sp, &format!("only the `{}` or `{}` calling conventions are valid \
for this function; `{}` was specified",
@ -2464,7 +2464,7 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
let sym = exported_name(ccx, id, mty, &attrs);
if let ty::ty_bare_fn(_, ref f) = mty.sty {
if let ty::TyBareFn(_, ref f) = mty.sty {
let llfn = if f.abi == Rust || f.abi == RustCall {
register_fn(ccx, span, sym, id, mty)
} else {

View file

@ -107,7 +107,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
-> Callee<'blk, 'tcx> {
let DatumBlock { bcx, datum, .. } = expr::trans(bcx, expr);
match datum.ty.sty {
ty::ty_bare_fn(..) => {
ty::TyBareFn(..) => {
let llval = datum.to_llscalarish(bcx);
return Callee {
bcx: bcx,
@ -156,7 +156,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
}
}
def::DefFn(did, _) if match expr_ty.sty {
ty::ty_bare_fn(_, ref f) => f.abi == synabi::RustIntrinsic,
ty::TyBareFn(_, ref f) => f.abi == synabi::RustIntrinsic,
_ => false
} => {
let substs = common::node_id_substs(bcx.ccx(),
@ -299,7 +299,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
// which is the fn pointer, and `args`, which is the arguments tuple.
let (opt_def_id, sig) =
match bare_fn_ty.sty {
ty::ty_bare_fn(opt_def_id,
ty::TyBareFn(opt_def_id,
&ty::BareFnTy { unsafety: ast::Unsafety::Normal,
abi: synabi::Rust,
ref sig }) => {
@ -621,7 +621,7 @@ pub fn trans_method_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let method_ty = match bcx.tcx().method_map.borrow().get(&method_call) {
Some(method) => match method.origin {
ty::MethodTraitObject(_) => match method.ty.sty {
ty::ty_bare_fn(_, ref fty) => {
ty::TyBareFn(_, ref fty) => {
ty::mk_bare_fn(bcx.tcx(), None, meth::opaque_method_ty(bcx.tcx(), fty))
}
_ => method.ty
@ -699,7 +699,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
let mut bcx = callee.bcx;
let (abi, ret_ty) = match callee_ty.sty {
ty::ty_bare_fn(_, ref f) => {
ty::TyBareFn(_, ref f) => {
let output = ty::erase_late_bound_regions(bcx.tcx(), &f.sig.output());
(f.abi, output)
}
@ -943,7 +943,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
let tuple_type = common::node_id_type(bcx, tuple_expr.id);
match tuple_type.sty {
ty::ty_tup(ref field_types) => {
ty::TyTuple(ref field_types) => {
let tuple_datum = unpack_datum!(bcx,
expr::trans(bcx, &**tuple_expr));
let tuple_lvalue_datum =
@ -1002,7 +1002,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
// Now untuple the rest of the arguments.
let tuple_type = arg_tys[1];
match tuple_type.sty {
ty::ty_tup(ref field_types) => {
ty::TyTuple(ref field_types) => {
for (i, &field_type) in field_types.iter().enumerate() {
let arg_datum =
unpack_datum!(bcx, expr::trans(bcx, arg_exprs[i + 1]));

View file

@ -143,7 +143,7 @@ pub fn get_or_create_declaration_if_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tc
// duplicate declarations
let function_type = erase_regions(ccx.tcx(), &function_type);
let params = match function_type.sty {
ty::ty_closure(_, substs) => &substs.types,
ty::TyClosure(_, substs) => &substs.types,
_ => unreachable!()
};
let mono_id = MonoId {
@ -421,7 +421,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
// the remaining arguments will be packed up in a tuple.
let input_tys = match sig.inputs[1].sty {
ty::ty_tup(ref tys) => &**tys,
ty::TyTuple(ref tys) => &**tys,
_ => bcx.sess().bug(&format!("trans_fn_once_adapter_shim: not rust-call! \
closure_def_id={}",
closure_def_id.repr(tcx)))

View file

@ -125,9 +125,9 @@ pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty {
ty::ty_ptr(ty::mt{ty, ..}) |
ty::ty_rptr(_, ty::mt{ty, ..}) |
ty::ty_uniq(ty) => {
ty::TyRawPtr(ty::mt{ty, ..}) |
ty::TyRef(_, ty::mt{ty, ..}) |
ty::TyBox(ty) => {
!type_is_sized(cx, ty)
}
_ => {
@ -158,10 +158,10 @@ pub fn type_needs_unwind_cleanup<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<
let mut needs_unwind_cleanup = false;
ty::maybe_walk_ty(ty, |ty| {
needs_unwind_cleanup |= match ty.sty {
ty::ty_bool | ty::ty_int(_) | ty::ty_uint(_) |
ty::ty_float(_) | ty::ty_tup(_) | ty::ty_ptr(_) => false,
ty::TyBool | ty::TyInt(_) | ty::TyUint(_) |
ty::TyFloat(_) | ty::TyTuple(_) | ty::TyRawPtr(_) => false,
ty::ty_enum(did, substs) =>
ty::TyEnum(did, substs) =>
ty::enum_variants(tcx, did).iter().any(|v|
v.args.iter().any(|&aty| {
let t = aty.subst(tcx, substs);
@ -218,7 +218,7 @@ fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>,
fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
match ty.sty {
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
let fields = ty::lookup_struct_fields(ccx.tcx(), def_id);
fields.len() == 1 && {
let ty = ty::lookup_field_type(ccx.tcx(), def_id, fields[0].id, substs);
@ -246,8 +246,8 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
return false;
}
match ty.sty {
ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) | ty::ty_vec(_, Some(_)) |
ty::ty_closure(..) => {
ty::TyStruct(..) | ty::TyEnum(..) | ty::TyTuple(..) | ty::TyArray(_, Some(_)) |
ty::TyClosure(..) => {
let llty = sizing_type_of(ccx, ty);
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
}

View file

@ -59,10 +59,10 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
ast::LitInt(i, ast::UnsuffixedIntLit(_)) => {
let lit_int_ty = ty::node_id_to_type(cx.tcx(), e.id);
match lit_int_ty.sty {
ty::ty_int(t) => {
ty::TyInt(t) => {
C_integral(Type::int_from_ty(cx, t), i as u64, true)
}
ty::ty_uint(t) => {
ty::TyUint(t) => {
C_integral(Type::uint_from_ty(cx, t), i as u64, false)
}
_ => cx.sess().span_bug(lit.span,
@ -77,7 +77,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
ast::LitFloatUnsuffixed(ref fs) => {
let lit_float_ty = ty::node_id_to_type(cx.tcx(), e.id);
match lit_float_ty.sty {
ty::ty_float(t) => {
ty::TyFloat(t) => {
C_floating(&fs, Type::float_from_ty(cx, t))
}
_ => {
@ -392,7 +392,7 @@ fn check_unary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
if let ast::ExprLit(_) = inner_e.node { return; }
let result = match t.sty {
ty::ty_int(int_type) => {
ty::TyInt(int_type) => {
let input = match const_to_opt_int(te) {
Some(v) => v,
None => return,
@ -400,7 +400,7 @@ fn check_unary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
const_int_checked_neg(
input, e, Some(const_eval::IntTy::from(cx.tcx(), int_type)))
}
ty::ty_uint(uint_type) => {
ty::TyUint(uint_type) => {
let input = match const_to_opt_uint(te) {
Some(v) => v,
None => return,
@ -423,7 +423,7 @@ fn check_binary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
let b = if let ast::ExprBinary(b, _, _) = e.node { b } else { return };
let result = match t.sty {
ty::ty_int(int_type) => {
ty::TyInt(int_type) => {
let (lhs, rhs) = match (const_to_opt_int(te1),
const_to_opt_int(te2)) {
(Some(v1), Some(v2)) => (v1, v2),
@ -442,7 +442,7 @@ fn check_binary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
_ => return,
}
}
ty::ty_uint(uint_type) => {
ty::TyUint(uint_type) => {
let (lhs, rhs) = match (const_to_opt_uint(te1),
const_to_opt_uint(te2)) {
(Some(v1), Some(v2)) => (v1, v2),
@ -609,13 +609,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
"index is not an integer-constant expression")
};
let (arr, len) = match bt.sty {
ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)),
ty::ty_vec(_, None) | ty::ty_str => {
ty::TyArray(_, Some(u)) => (bv, C_uint(cx, u)),
ty::TyArray(_, None) | ty::TyStr => {
let e1 = const_get_elt(cx, bv, &[0]);
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
}
ty::ty_rptr(_, mt) => match mt.ty.sty {
ty::ty_vec(_, Some(u)) => {
ty::TyRef(_, mt) => match mt.ty.sty {
ty::TyArray(_, Some(u)) => {
(const_deref_ptr(cx, bv), C_uint(cx, u))
},
_ => cx.sess().span_bug(base.span,
@ -631,8 +631,8 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
let len = match bt.sty {
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty.sty {
ty::ty_str => {
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => match ty.sty {
ty::TyStr => {
assert!(len > 0);
len - 1
}
@ -842,7 +842,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
def::DefStruct(_) => {
if let ty::ty_bare_fn(..) = ety.sty {
if let ty::TyBareFn(..) = ety.sty {
// Tuple struct.
expr::trans_def_fn_unadjusted(cx, e, def, param_substs).val
} else {

View file

@ -171,26 +171,26 @@ impl<'tcx> TypeMap<'tcx> {
unique_type_id.push('{');
match type_.sty {
ty::ty_bool |
ty::ty_char |
ty::ty_str |
ty::ty_int(_) |
ty::ty_uint(_) |
ty::ty_float(_) => {
ty::TyBool |
ty::TyChar |
ty::TyStr |
ty::TyInt(_) |
ty::TyUint(_) |
ty::TyFloat(_) => {
push_debuginfo_type_name(cx, type_, false, &mut unique_type_id);
},
ty::ty_enum(def_id, substs) => {
ty::TyEnum(def_id, substs) => {
unique_type_id.push_str("enum ");
from_def_id_and_substs(self, cx, def_id, substs, &mut unique_type_id);
},
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
unique_type_id.push_str("struct ");
from_def_id_and_substs(self, cx, def_id, substs, &mut unique_type_id);
},
ty::ty_tup(ref component_types) if component_types.is_empty() => {
ty::TyTuple(ref component_types) if component_types.is_empty() => {
push_debuginfo_type_name(cx, type_, false, &mut unique_type_id);
},
ty::ty_tup(ref component_types) => {
ty::TyTuple(ref component_types) => {
unique_type_id.push_str("tuple ");
for &component_type in component_types {
let component_type_id =
@ -200,13 +200,13 @@ impl<'tcx> TypeMap<'tcx> {
unique_type_id.push_str(&component_type_id[..]);
}
},
ty::ty_uniq(inner_type) => {
ty::TyBox(inner_type) => {
unique_type_id.push_str("box ");
let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
unique_type_id.push_str(&inner_type_id[..]);
},
ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => {
ty::TyRawPtr(ty::mt { ty: inner_type, mutbl } ) => {
unique_type_id.push('*');
if mutbl == ast::MutMutable {
unique_type_id.push_str("mut");
@ -216,7 +216,7 @@ impl<'tcx> TypeMap<'tcx> {
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
unique_type_id.push_str(&inner_type_id[..]);
},
ty::ty_rptr(_, ty::mt { ty: inner_type, mutbl }) => {
ty::TyRef(_, ty::mt { ty: inner_type, mutbl }) => {
unique_type_id.push('&');
if mutbl == ast::MutMutable {
unique_type_id.push_str("mut");
@ -226,7 +226,7 @@ impl<'tcx> TypeMap<'tcx> {
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
unique_type_id.push_str(&inner_type_id[..]);
},
ty::ty_vec(inner_type, optional_length) => {
ty::TyArray(inner_type, optional_length) => {
match optional_length {
Some(len) => {
unique_type_id.push_str(&format!("[{}]", len));
@ -240,7 +240,7 @@ impl<'tcx> TypeMap<'tcx> {
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
unique_type_id.push_str(&inner_type_id[..]);
},
ty::ty_trait(ref trait_data) => {
ty::TyTrait(ref trait_data) => {
unique_type_id.push_str("trait ");
let principal =
@ -253,7 +253,7 @@ impl<'tcx> TypeMap<'tcx> {
principal.substs,
&mut unique_type_id);
},
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
ty::TyBareFn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
if unsafety == ast::Unsafety::Unsafe {
unique_type_id.push_str("unsafe ");
}
@ -289,7 +289,7 @@ impl<'tcx> TypeMap<'tcx> {
}
}
},
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
let typer = NormalizingClosureTyper::new(cx.tcx());
let closure_ty = typer.closure_type(def_id, substs);
self.get_unique_type_id_of_closure_type(cx,
@ -635,7 +635,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// return type
signature_metadata.push(match signature.output {
ty::FnConverging(ret_ty) => match ret_ty.sty {
ty::ty_tup(ref tys) if tys.is_empty() => ptr::null_mut(),
ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(),
_ => type_metadata(cx, ret_ty, span)
},
ty::FnDiverging => diverging_type_metadata(cx)
@ -674,7 +674,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// But it does not describe the trait's methods.
let def_id = match trait_type.sty {
ty::ty_trait(ref data) => data.principal_def_id(),
ty::TyTrait(ref data) => data.principal_def_id(),
_ => {
let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_type);
cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \
@ -742,39 +742,39 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let sty = &t.sty;
let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty {
ty::ty_bool |
ty::ty_char |
ty::ty_int(_) |
ty::ty_uint(_) |
ty::ty_float(_) => {
ty::TyBool |
ty::TyChar |
ty::TyInt(_) |
ty::TyUint(_) |
ty::TyFloat(_) => {
MetadataCreationResult::new(basic_type_metadata(cx, t), false)
}
ty::ty_tup(ref elements) if elements.is_empty() => {
ty::TyTuple(ref elements) if elements.is_empty() => {
MetadataCreationResult::new(basic_type_metadata(cx, t), false)
}
ty::ty_enum(def_id, _) => {
ty::TyEnum(def_id, _) => {
prepare_enum_metadata(cx, t, def_id, unique_type_id, usage_site_span).finalize(cx)
}
ty::ty_vec(typ, len) => {
ty::TyArray(typ, len) => {
fixed_vec_metadata(cx, unique_type_id, typ, len.map(|x| x as u64), usage_site_span)
}
ty::ty_str => {
ty::TyStr => {
fixed_vec_metadata(cx, unique_type_id, cx.tcx().types.i8, None, usage_site_span)
}
ty::ty_trait(..) => {
ty::TyTrait(..) => {
MetadataCreationResult::new(
trait_pointer_metadata(cx, t, None, unique_type_id),
false)
}
ty::ty_uniq(ty) | ty::ty_ptr(ty::mt{ty, ..}) | ty::ty_rptr(_, ty::mt{ty, ..}) => {
ty::TyBox(ty) | ty::TyRawPtr(ty::mt{ty, ..}) | ty::TyRef(_, ty::mt{ty, ..}) => {
match ty.sty {
ty::ty_vec(typ, None) => {
ty::TyArray(typ, None) => {
vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)
}
ty::ty_str => {
ty::TyStr => {
vec_slice_metadata(cx, t, cx.tcx().types.u8, unique_type_id, usage_site_span)
}
ty::ty_trait(..) => {
ty::TyTrait(..) => {
MetadataCreationResult::new(
trait_pointer_metadata(cx, ty, Some(t), unique_type_id),
false)
@ -794,15 +794,15 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
}
ty::ty_bare_fn(_, ref barefnty) => {
ty::TyBareFn(_, ref barefnty) => {
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
}
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
let typer = NormalizingClosureTyper::new(cx.tcx());
let sig = typer.closure_type(def_id, substs).sig;
subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span)
}
ty::ty_struct(def_id, substs) => {
ty::TyStruct(def_id, substs) => {
prepare_struct_metadata(cx,
t,
def_id,
@ -810,7 +810,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
unique_type_id,
usage_site_span).finalize(cx)
}
ty::ty_tup(ref elements) => {
ty::TyTuple(ref elements) => {
prepare_tuple_metadata(cx,
t,
&elements[..],
@ -936,25 +936,25 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
debug!("basic_type_metadata: {:?}", t);
let (name, encoding) = match t.sty {
ty::ty_tup(ref elements) if elements.is_empty() =>
ty::TyTuple(ref elements) if elements.is_empty() =>
("()".to_string(), DW_ATE_unsigned),
ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
ty::ty_char => ("char".to_string(), DW_ATE_unsigned_char),
ty::ty_int(int_ty) => match int_ty {
ty::TyBool => ("bool".to_string(), DW_ATE_boolean),
ty::TyChar => ("char".to_string(), DW_ATE_unsigned_char),
ty::TyInt(int_ty) => match int_ty {
ast::TyIs => ("isize".to_string(), DW_ATE_signed),
ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
},
ty::ty_uint(uint_ty) => match uint_ty {
ty::TyUint(uint_ty) => match uint_ty {
ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
ast::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
},
ty::ty_float(float_ty) => match float_ty {
ty::TyFloat(float_ty) => match float_ty {
ast::TyF32 => ("f32".to_string(), DW_ATE_float),
ast::TyF64 => ("f64".to_string(), DW_ATE_float),
},
@ -1179,7 +1179,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let mut fields = ty::struct_fields(cx.tcx(), def_id, substs);
// The `Ty` values returned by `ty::struct_fields` can still contain
// `ty_projection` variants, so normalize those away.
// `TyProjection` variants, so normalize those away.
for field in &mut fields {
field.mt.ty = monomorphize::normalize_associated_type(cx.tcx(), &field.mt.ty);
}

View file

@ -40,27 +40,27 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
qualified: bool,
output: &mut String) {
match t.sty {
ty::ty_bool => output.push_str("bool"),
ty::ty_char => output.push_str("char"),
ty::ty_str => output.push_str("str"),
ty::ty_int(ast::TyIs) => output.push_str("isize"),
ty::ty_int(ast::TyI8) => output.push_str("i8"),
ty::ty_int(ast::TyI16) => output.push_str("i16"),
ty::ty_int(ast::TyI32) => output.push_str("i32"),
ty::ty_int(ast::TyI64) => output.push_str("i64"),
ty::ty_uint(ast::TyUs) => output.push_str("usize"),
ty::ty_uint(ast::TyU8) => output.push_str("u8"),
ty::ty_uint(ast::TyU16) => output.push_str("u16"),
ty::ty_uint(ast::TyU32) => output.push_str("u32"),
ty::ty_uint(ast::TyU64) => output.push_str("u64"),
ty::ty_float(ast::TyF32) => output.push_str("f32"),
ty::ty_float(ast::TyF64) => output.push_str("f64"),
ty::ty_struct(def_id, substs) |
ty::ty_enum(def_id, substs) => {
ty::TyBool => output.push_str("bool"),
ty::TyChar => output.push_str("char"),
ty::TyStr => output.push_str("str"),
ty::TyInt(ast::TyIs) => output.push_str("isize"),
ty::TyInt(ast::TyI8) => output.push_str("i8"),
ty::TyInt(ast::TyI16) => output.push_str("i16"),
ty::TyInt(ast::TyI32) => output.push_str("i32"),
ty::TyInt(ast::TyI64) => output.push_str("i64"),
ty::TyUint(ast::TyUs) => output.push_str("usize"),
ty::TyUint(ast::TyU8) => output.push_str("u8"),
ty::TyUint(ast::TyU16) => output.push_str("u16"),
ty::TyUint(ast::TyU32) => output.push_str("u32"),
ty::TyUint(ast::TyU64) => output.push_str("u64"),
ty::TyFloat(ast::TyF32) => output.push_str("f32"),
ty::TyFloat(ast::TyF64) => output.push_str("f64"),
ty::TyStruct(def_id, substs) |
ty::TyEnum(def_id, substs) => {
push_item_name(cx, def_id, qualified, output);
push_type_params(cx, substs, output);
},
ty::ty_tup(ref component_types) => {
ty::TyTuple(ref component_types) => {
output.push('(');
for &component_type in component_types {
push_debuginfo_type_name(cx, component_type, true, output);
@ -72,12 +72,12 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
output.push(')');
},
ty::ty_uniq(inner_type) => {
ty::TyBox(inner_type) => {
output.push_str("Box<");
push_debuginfo_type_name(cx, inner_type, true, output);
output.push('>');
},
ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => {
ty::TyRawPtr(ty::mt { ty: inner_type, mutbl } ) => {
output.push('*');
match mutbl {
ast::MutImmutable => output.push_str("const "),
@ -86,7 +86,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
push_debuginfo_type_name(cx, inner_type, true, output);
},
ty::ty_rptr(_, ty::mt { ty: inner_type, mutbl }) => {
ty::TyRef(_, ty::mt { ty: inner_type, mutbl }) => {
output.push('&');
if mutbl == ast::MutMutable {
output.push_str("mut ");
@ -94,7 +94,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
push_debuginfo_type_name(cx, inner_type, true, output);
},
ty::ty_vec(inner_type, optional_length) => {
ty::TyArray(inner_type, optional_length) => {
output.push('[');
push_debuginfo_type_name(cx, inner_type, true, output);
@ -107,12 +107,12 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
output.push(']');
},
ty::ty_trait(ref trait_data) => {
ty::TyTrait(ref trait_data) => {
let principal = ty::erase_late_bound_regions(cx.tcx(), &trait_data.principal);
push_item_name(cx, principal.def_id, false, output);
push_type_params(cx, principal.substs, output);
},
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
ty::TyBareFn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
if unsafety == ast::Unsafety::Unsafe {
output.push_str("unsafe ");
}
@ -156,13 +156,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
},
ty::ty_closure(..) => {
ty::TyClosure(..) => {
output.push_str("closure");
}
ty::ty_err |
ty::ty_infer(_) |
ty::ty_projection(..) |
ty::ty_param(_) => {
ty::TyError |
ty::TyInfer(_) |
ty::TyProjection(..) |
ty::TyParam(_) => {
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t)));
}

View file

@ -114,10 +114,10 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
let function_type; // placeholder so that the memory ownership works out ok
let (sig, abi, env) = match fn_type.sty {
ty::ty_bare_fn(_, ref f) => {
ty::TyBareFn(_, ref f) => {
(&f.sig, f.abi, None)
}
ty::ty_closure(closure_did, substs) => {
ty::TyClosure(closure_did, substs) => {
let typer = common::NormalizingClosureTyper::new(ccx.tcx());
function_type = typer.closure_type(closure_did, substs);
let self_type = base::self_type_for_closure(ccx, closure_did, fn_type);

View file

@ -313,14 +313,14 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
-> ValueRef {
let (source, target) = ty::struct_lockstep_tails(ccx.tcx(), source, target);
match (&source.sty, &target.sty) {
(&ty::ty_vec(_, Some(len)), &ty::ty_vec(_, None)) => C_uint(ccx, len),
(&ty::ty_trait(_), &ty::ty_trait(_)) => {
(&ty::TyArray(_, Some(len)), &ty::TyArray(_, None)) => C_uint(ccx, len),
(&ty::TyTrait(_), &ty::TyTrait(_)) => {
// For now, upcasts are limited to changes in marker
// traits, and hence never actually require an actual
// change to the vtable.
old_info.expect("unsized_info: missing old info for trait upcast")
}
(_, &ty::ty_trait(box ty::TyTrait { ref principal, .. })) => {
(_, &ty::TyTrait(box ty::TraitTy { ref principal, .. })) => {
// Note that we preserve binding levels here:
let substs = principal.0.substs.with_self_ty(source).erase_regions();
let substs = ccx.tcx().mk_substs(substs);
@ -369,7 +369,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// a different region or mutability, but we don't care here).
match datum.ty.sty {
// Don't skip a conversion from Box<T> to &T, etc.
ty::ty_rptr(..) => {
ty::TyRef(..) => {
let method_call = MethodCall::autoderef(expr.id, 0);
if bcx.tcx().method_map.borrow().contains_key(&method_call) {
// Don't skip an overloaded deref.
@ -442,10 +442,10 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
target.to_string(bcx.ccx()));
match (&source.ty.sty, &target.ty.sty) {
(&ty::ty_uniq(a), &ty::ty_uniq(b)) |
(&ty::ty_rptr(_, ty::mt { ty: a, .. }), &ty::ty_rptr(_, ty::mt { ty: b, .. })) |
(&ty::ty_rptr(_, ty::mt { ty: a, .. }), &ty::ty_ptr(ty::mt { ty: b, .. })) |
(&ty::ty_ptr(ty::mt { ty: a, .. }), &ty::ty_ptr(ty::mt { ty: b, .. })) => {
(&ty::TyBox(a), &ty::TyBox(b)) |
(&ty::TyRef(_, ty::mt { ty: a, .. }), &ty::TyRef(_, ty::mt { ty: b, .. })) |
(&ty::TyRef(_, ty::mt { ty: a, .. }), &ty::TyRawPtr(ty::mt { ty: b, .. })) |
(&ty::TyRawPtr(ty::mt { ty: a, .. }), &ty::TyRawPtr(ty::mt { ty: b, .. })) => {
let (inner_source, inner_target) = (a, b);
let (base, old_info) = if !type_is_sized(bcx.tcx(), inner_source) {
@ -479,8 +479,8 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
// This can be extended to enums and tuples in the future.
// (&ty::ty_enum(def_id_a, _), &ty::ty_enum(def_id_b, _)) |
(&ty::ty_struct(def_id_a, _), &ty::ty_struct(def_id_b, _)) => {
// (&ty::TyEnum(def_id_a, _), &ty::TyEnum(def_id_b, _)) |
(&ty::TyStruct(def_id_a, _), &ty::TyStruct(def_id_b, _)) => {
assert_eq!(def_id_a, def_id_b);
// The target is already by-ref because it's to be written to.
@ -657,7 +657,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let box_ty = expr_ty(bcx, expr);
let contents_ty = expr_ty(bcx, &**contents);
match box_ty.sty {
ty::ty_uniq(..) => {
ty::TyBox(..) => {
trans_uniq_expr(bcx, expr, box_ty, &**contents, contents_ty)
}
_ => bcx.sess().span_bug(expr.span,
@ -1245,7 +1245,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
def::DefStruct(_) => {
let ty = expr_ty(bcx, ref_expr);
match ty.sty {
ty::ty_struct(did, _) if ty::has_dtor(bcx.tcx(), did) => {
ty::TyStruct(did, _) if ty::has_dtor(bcx.tcx(), did) => {
let repr = adt::represent_type(bcx.ccx(), ty);
adt::trans_set_discr(bcx, &*repr, lldest, 0);
}
@ -1339,17 +1339,17 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
F: FnOnce(ty::Disr, &[ty::field<'tcx>]) -> R,
{
match ty.sty {
ty::ty_struct(did, substs) => {
ty::TyStruct(did, substs) => {
let fields = struct_fields(tcx, did, substs);
let fields = monomorphize::normalize_associated_type(tcx, &fields);
op(0, &fields[..])
}
ty::ty_tup(ref v) => {
ty::TyTuple(ref v) => {
op(0, &tup_fields(&v[..]))
}
ty::ty_enum(_, substs) => {
ty::TyEnum(_, substs) => {
// We want the *variant* ID here, not the enum ID.
match node_id_opt {
None => {
@ -2253,7 +2253,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
};
let r = match datum.ty.sty {
ty::ty_uniq(content_ty) => {
ty::TyBox(content_ty) => {
// Make sure we have an lvalue datum here to get the
// proper cleanups scheduled
let datum = unpack_datum!(
@ -2274,8 +2274,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
ty::ty_ptr(ty::mt { ty: content_ty, .. }) |
ty::ty_rptr(_, ty::mt { ty: content_ty, .. }) => {
ty::TyRawPtr(ty::mt { ty: content_ty, .. }) |
ty::TyRef(_, ty::mt { ty: content_ty, .. }) => {
if type_is_sized(bcx.tcx(), content_ty) {
let ptr = datum.to_llscalarish(bcx);
@ -2347,61 +2347,61 @@ impl OverflowOpViaIntrinsic {
fn to_intrinsic_name(&self, tcx: &ty::ctxt, ty: Ty) -> &'static str {
use syntax::ast::IntTy::*;
use syntax::ast::UintTy::*;
use middle::ty::{ty_int, ty_uint};
use middle::ty::{TyInt, TyUint};
let new_sty = match ty.sty {
ty_int(TyIs) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => ty_int(TyI32),
"64" => ty_int(TyI64),
TyInt(TyIs) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => TyInt(TyI32),
"64" => TyInt(TyI64),
_ => panic!("unsupported target word size")
},
ty_uint(TyUs) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => ty_uint(TyU32),
"64" => ty_uint(TyU64),
TyUint(TyUs) => match &tcx.sess.target.target.target_pointer_width[..] {
"32" => TyUint(TyU32),
"64" => TyUint(TyU64),
_ => panic!("unsupported target word size")
},
ref t @ ty_uint(_) | ref t @ ty_int(_) => t.clone(),
ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
_ => panic!("tried to get overflow intrinsic for {:?} applied to non-int type",
*self)
};
match *self {
OverflowOpViaIntrinsic::Add => match new_sty {
ty_int(TyI8) => "llvm.sadd.with.overflow.i8",
ty_int(TyI16) => "llvm.sadd.with.overflow.i16",
ty_int(TyI32) => "llvm.sadd.with.overflow.i32",
ty_int(TyI64) => "llvm.sadd.with.overflow.i64",
TyInt(TyI8) => "llvm.sadd.with.overflow.i8",
TyInt(TyI16) => "llvm.sadd.with.overflow.i16",
TyInt(TyI32) => "llvm.sadd.with.overflow.i32",
TyInt(TyI64) => "llvm.sadd.with.overflow.i64",
ty_uint(TyU8) => "llvm.uadd.with.overflow.i8",
ty_uint(TyU16) => "llvm.uadd.with.overflow.i16",
ty_uint(TyU32) => "llvm.uadd.with.overflow.i32",
ty_uint(TyU64) => "llvm.uadd.with.overflow.i64",
TyUint(TyU8) => "llvm.uadd.with.overflow.i8",
TyUint(TyU16) => "llvm.uadd.with.overflow.i16",
TyUint(TyU32) => "llvm.uadd.with.overflow.i32",
TyUint(TyU64) => "llvm.uadd.with.overflow.i64",
_ => unreachable!(),
},
OverflowOpViaIntrinsic::Sub => match new_sty {
ty_int(TyI8) => "llvm.ssub.with.overflow.i8",
ty_int(TyI16) => "llvm.ssub.with.overflow.i16",
ty_int(TyI32) => "llvm.ssub.with.overflow.i32",
ty_int(TyI64) => "llvm.ssub.with.overflow.i64",
TyInt(TyI8) => "llvm.ssub.with.overflow.i8",
TyInt(TyI16) => "llvm.ssub.with.overflow.i16",
TyInt(TyI32) => "llvm.ssub.with.overflow.i32",
TyInt(TyI64) => "llvm.ssub.with.overflow.i64",
ty_uint(TyU8) => "llvm.usub.with.overflow.i8",
ty_uint(TyU16) => "llvm.usub.with.overflow.i16",
ty_uint(TyU32) => "llvm.usub.with.overflow.i32",
ty_uint(TyU64) => "llvm.usub.with.overflow.i64",
TyUint(TyU8) => "llvm.usub.with.overflow.i8",
TyUint(TyU16) => "llvm.usub.with.overflow.i16",
TyUint(TyU32) => "llvm.usub.with.overflow.i32",
TyUint(TyU64) => "llvm.usub.with.overflow.i64",
_ => unreachable!(),
},
OverflowOpViaIntrinsic::Mul => match new_sty {
ty_int(TyI8) => "llvm.smul.with.overflow.i8",
ty_int(TyI16) => "llvm.smul.with.overflow.i16",
ty_int(TyI32) => "llvm.smul.with.overflow.i32",
ty_int(TyI64) => "llvm.smul.with.overflow.i64",
TyInt(TyI8) => "llvm.smul.with.overflow.i8",
TyInt(TyI16) => "llvm.smul.with.overflow.i16",
TyInt(TyI32) => "llvm.smul.with.overflow.i32",
TyInt(TyI64) => "llvm.smul.with.overflow.i64",
ty_uint(TyU8) => "llvm.umul.with.overflow.i8",
ty_uint(TyU16) => "llvm.umul.with.overflow.i16",
ty_uint(TyU32) => "llvm.umul.with.overflow.i32",
ty_uint(TyU64) => "llvm.umul.with.overflow.i64",
TyUint(TyU8) => "llvm.umul.with.overflow.i8",
TyUint(TyU16) => "llvm.umul.with.overflow.i16",
TyUint(TyU32) => "llvm.umul.with.overflow.i32",
TyUint(TyU64) => "llvm.umul.with.overflow.i64",
_ => unreachable!(),
},

View file

@ -129,7 +129,7 @@ pub fn register_static(ccx: &CrateContext,
}
};
let llty2 = match ty.sty {
ty::ty_ptr(ref mt) => type_of::type_of(ccx, mt.ty),
ty::TyRawPtr(ref mt) => type_of::type_of(ccx, mt.ty),
_ => {
ccx.sess().span_fatal(foreign_item.span,
"must have type `*T` or `*mut T`");
@ -243,7 +243,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ccx.tn().val_to_string(llretptr));
let (fn_abi, fn_sig) = match callee_ty.sty {
ty::ty_bare_fn(_, ref fn_ty) => (fn_ty.abi, &fn_ty.sig),
ty::TyBareFn(_, ref fn_ty) => (fn_ty.abi, &fn_ty.sig),
_ => ccx.sess().bug("trans_native_call called on non-function type")
};
let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
@ -474,7 +474,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
abi => {
let ty = ty::node_id_to_type(ccx.tcx(), foreign_item.id);
match ty.sty {
ty::ty_bare_fn(_, bft) => gate_simd_ffi(ccx.tcx(), &**decl, bft),
ty::TyBareFn(_, bft) => gate_simd_ffi(ccx.tcx(), &**decl, bft),
_ => ccx.tcx().sess.span_bug(foreign_item.span,
"foreign fn's sty isn't a bare_fn_ty?")
}
@ -526,7 +526,7 @@ pub fn decl_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let tys = foreign_types_for_fn_ty(ccx, t);
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
let cconv = match t.sty {
ty::ty_bare_fn(_, ref fn_ty) => {
ty::TyBareFn(_, ref fn_ty) => {
llvm_calling_convention(ccx, fn_ty.abi)
}
_ => panic!("expected bare fn in decl_rust_fn_with_foreign_abi")
@ -550,7 +550,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
let t = ty::node_id_to_type(ccx.tcx(), node_id);
let cconv = match t.sty {
ty::ty_bare_fn(_, ref fn_ty) => {
ty::TyBareFn(_, ref fn_ty) => {
llvm_calling_convention(ccx, fn_ty.abi)
}
_ => panic!("expected bare fn in register_rust_fn_with_foreign_abi")
@ -606,7 +606,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// Compute the type that the function would have if it were just a
// normal Rust function. This will be the type of the wrappee fn.
match t.sty {
ty::ty_bare_fn(_, ref f) => {
ty::TyBareFn(_, ref f) => {
assert!(f.abi != Rust && f.abi != RustIntrinsic);
}
_ => {
@ -926,7 +926,7 @@ fn foreign_types_for_id<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty: Ty<'tcx>) -> ForeignTypes<'tcx> {
let fn_sig = match ty.sty {
ty::ty_bare_fn(_, ref fn_ty) => &fn_ty.sig,
ty::TyBareFn(_, ref fn_ty) => &fn_ty.sig,
_ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
};
let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);

View file

@ -114,7 +114,7 @@ pub fn get_drop_glue_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
return tcx.types.i8;
}
match t.sty {
ty::ty_uniq(typ) if !type_needs_drop(tcx, typ)
ty::TyBox(typ) if !type_needs_drop(tcx, typ)
&& type_is_sized(tcx, typ) => {
let llty = sizing_type_of(ccx, typ);
// `Box<ZeroSizeType>` does not allocate.
@ -398,7 +398,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
return (size, align);
}
match t.sty {
ty::ty_struct(id, substs) => {
ty::TyStruct(id, substs) => {
let ccx = bcx.ccx();
// First get the size of all statically known fields.
// Don't use type_of::sizing_type_of because that expects t to be sized.
@ -427,7 +427,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
unsized_align);
(size, align)
}
ty::ty_trait(..) => {
ty::TyTrait(..) => {
// info points to the vtable and the second entry in the vtable is the
// dynamic size of the object.
let info = PointerCast(bcx, info, Type::int(bcx.ccx()).ptr_to());
@ -435,7 +435,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
let align_ptr = GEPi(bcx, info, &[2]);
(Load(bcx, size_ptr), Load(bcx, align_ptr))
}
ty::ty_vec(_, None) | ty::ty_str => {
ty::TyArray(_, None) | ty::TyStr => {
let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
// The info in this case is the length of the str, so the size is that
// times the unit size.
@ -466,10 +466,10 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
let dropped_pattern = C_integral(inttype, adt::dtor_done_usize(bcx.fcx.ccx) as u64, false);
match t.sty {
ty::ty_uniq(content_ty) => {
// Support for ty_uniq is built-in and its drop glue is
ty::TyBox(content_ty) => {
// Support for TyBox is built-in and its drop glue is
// special. It may move to library and have Drop impl. As
// a safe-guard, assert ty_uniq not used with TyContents.
// a safe-guard, assert TyBox not used with TyContents.
assert!(!skip_dtor);
if !type_is_sized(bcx.tcx(), content_ty) {
let llval = GEPi(bcx, v0, &[0, abi::FAT_PTR_ADDR]);
@ -505,7 +505,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
})
}
}
ty::ty_struct(did, substs) | ty::ty_enum(did, substs) => {
ty::TyStruct(did, substs) | ty::TyEnum(did, substs) => {
let tcx = bcx.tcx();
match (ty::ty_dtor(tcx, did), skip_dtor) {
(ty::TraitDtor(dtor, true), false) => {
@ -534,7 +534,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
}
}
}
ty::ty_trait(..) => {
ty::TyTrait(..) => {
// No support in vtable for distinguishing destroying with
// versus without calling Drop::drop. Assert caller is
// okay with always calling the Drop impl, if any.

View file

@ -163,7 +163,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let _icx = push_ctxt("trans_intrinsic_call");
let ret_ty = match callee_ty.sty {
ty::ty_bare_fn(_, ref f) => {
ty::TyBareFn(_, ref f) => {
ty::erase_late_bound_regions(bcx.tcx(), &f.sig.output())
}
_ => panic!("expected bare_fn in trans_intrinsic_call")
@ -755,7 +755,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
(_, "discriminant_value") => {
let val_ty = substs.types.get(FnSpace, 0);
match val_ty.sty {
ty::ty_enum(..) => {
ty::TyEnum(..) => {
let repr = adt::represent_type(ccx, *val_ty);
adt::trans_get_discr(bcx, &*repr, llargs[0], Some(llret_ty))
}

View file

@ -493,7 +493,7 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Replace the self type (&Self or Box<Self>) with an opaque pointer.
let llcallee_ty = match callee_ty.sty {
ty::ty_bare_fn(_, ref f) if f.abi == Rust || f.abi == RustCall => {
ty::TyBareFn(_, ref f) if f.abi == Rust || f.abi == RustCall => {
let fake_sig =
ty::Binder(ty::FnSig {
inputs: f.sig.0.inputs[1..].to_vec(),
@ -563,7 +563,7 @@ pub fn trans_object_shim<'a, 'tcx>(
let object_trait_ref =
match object_ty.sty {
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
data.principal_trait_ref_with_self_ty(tcx, object_ty)
}
_ => {
@ -624,7 +624,7 @@ pub fn trans_object_shim<'a, 'tcx>(
RustCall => {
// unpack the tuple to extract the input type arguments:
match sig.inputs[1].sty {
ty::ty_tup(ref tys) => &**tys,
ty::TyTuple(ref tys) => &**tys,
_ => {
bcx.sess().bug(
&format!("rust-call expects a tuple not {}",

View file

@ -310,15 +310,15 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let ccx = bcx.ccx();
match vec_ty.sty {
ty::ty_vec(_, Some(n)) => get_fixed_base_and_len(bcx, llval, n),
ty::ty_vec(_, None) | ty::ty_str => {
ty::TyArray(_, Some(n)) => get_fixed_base_and_len(bcx, llval, n),
ty::TyArray(_, None) | ty::TyStr => {
let base = Load(bcx, expr::get_dataptr(bcx, llval));
let len = Load(bcx, expr::get_len(bcx, llval));
(base, len)
}
// Only used for pattern matching.
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => {
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => {
let inner = if type_is_sized(bcx.tcx(), ty) {
Load(bcx, llval)
} else {

View file

@ -79,7 +79,7 @@ pub fn untuple_arguments_if_necessary<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
match inputs[inputs.len() - 1].sty {
ty::ty_tup(ref tupled_arguments) => {
ty::TyTuple(ref tupled_arguments) => {
debug!("untuple_arguments_if_necessary(): untupling arguments");
for &tupled_argument in tupled_arguments {
result.push(tupled_argument);
@ -147,7 +147,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Given a function type and a count of ty params, construct an llvm type
pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>) -> Type {
match fty.sty {
ty::ty_bare_fn(_, ref f) => {
ty::TyBareFn(_, ref f) => {
// FIXME(#19925) once fn item types are
// zero-sized, we'll need to do something here
if f.abi == abi::Rust || f.abi == abi::RustCall {
@ -184,13 +184,13 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false)
}
ty::ty_bool => Type::bool(cx),
ty::ty_char => Type::char(cx),
ty::ty_int(t) => Type::int_from_ty(cx, t),
ty::ty_uint(t) => Type::uint_from_ty(cx, t),
ty::ty_float(t) => Type::float_from_ty(cx, t),
ty::TyBool => Type::bool(cx),
ty::TyChar => Type::char(cx),
ty::TyInt(t) => Type::int_from_ty(cx, t),
ty::TyUint(t) => Type::uint_from_ty(cx, t),
ty::TyFloat(t) => Type::float_from_ty(cx, t),
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => {
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) | ty::TyRawPtr(ty::mt{ty, ..}) => {
if type_is_sized(cx.tcx(), ty) {
Type::i8p(cx)
} else {
@ -198,25 +198,25 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
}
}
ty::ty_bare_fn(..) => Type::i8p(cx),
ty::TyBareFn(..) => Type::i8p(cx),
ty::ty_vec(ty, Some(size)) => {
ty::TyArray(ty, Some(size)) => {
let llty = sizing_type_of(cx, ty);
let size = size as u64;
ensure_array_fits_in_address_space(cx, llty, size, t);
Type::array(&llty, size)
}
ty::ty_tup(ref tys) if tys.is_empty() => {
ty::TyTuple(ref tys) if tys.is_empty() => {
Type::nil(cx)
}
ty::ty_tup(..) | ty::ty_enum(..) | ty::ty_closure(..) => {
ty::TyTuple(..) | ty::TyEnum(..) | ty::TyClosure(..) => {
let repr = adt::represent_type(cx, t);
adt::sizing_type_of(cx, &*repr, false)
}
ty::ty_struct(..) => {
ty::TyStruct(..) => {
if ty::type_is_simd(cx.tcx(), t) {
let llet = type_of(cx, ty::simd_type(cx.tcx(), t));
let n = ty::simd_size(cx.tcx(), t) as u64;
@ -228,11 +228,11 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
}
}
ty::ty_projection(..) | ty::ty_infer(..) | ty::ty_param(..) | ty::ty_err(..) => {
ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError(..) => {
cx.sess().bug(&format!("fictitious type {} in sizing_type_of()",
ppaux::ty_to_string(cx.tcx(), t)))
}
ty::ty_vec(_, None) | ty::ty_trait(..) | ty::ty_str => unreachable!()
ty::TyArray(_, None) | ty::TyTrait(..) | ty::TyStr => unreachable!()
};
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
@ -323,12 +323,12 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
}
let mut llty = match t.sty {
ty::ty_bool => Type::bool(cx),
ty::ty_char => Type::char(cx),
ty::ty_int(t) => Type::int_from_ty(cx, t),
ty::ty_uint(t) => Type::uint_from_ty(cx, t),
ty::ty_float(t) => Type::float_from_ty(cx, t),
ty::ty_enum(did, ref substs) => {
ty::TyBool => Type::bool(cx),
ty::TyChar => Type::char(cx),
ty::TyInt(t) => Type::int_from_ty(cx, t),
ty::TyUint(t) => Type::uint_from_ty(cx, t),
ty::TyFloat(t) => Type::float_from_ty(cx, t),
ty::TyEnum(did, ref substs) => {
// Only create the named struct, but don't fill it in. We
// fill it in *after* placing it into the type cache. This
// avoids creating more than one copy of the enum when one
@ -338,7 +338,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
let name = llvm_type_name(cx, did, tps);
adt::incomplete_type_of(cx, &*repr, &name[..])
}
ty::ty_closure(..) => {
ty::TyClosure(..) => {
// Only create the named struct, but don't fill it in. We
// fill it in *after* placing it into the type cache.
let repr = adt::represent_type(cx, t);
@ -349,9 +349,9 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
adt::incomplete_type_of(cx, &*repr, "closure")
}
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => {
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) | ty::TyRawPtr(ty::mt{ty, ..}) => {
if !type_is_sized(cx.tcx(), ty) {
if let ty::ty_str = ty.sty {
if let ty::TyStr = ty.sty {
// This means we get a nicer name in the output (str is always
// unsized).
cx.tn().find_type("str_slice").unwrap()
@ -359,10 +359,10 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
let ptr_ty = in_memory_type_of(cx, ty).ptr_to();
let unsized_part = ty::struct_tail(cx.tcx(), ty);
let info_ty = match unsized_part.sty {
ty::ty_str | ty::ty_vec(..) => {
ty::TyStr | ty::TyArray(..) => {
Type::uint_from_ty(cx, ast::TyUs)
}
ty::ty_trait(_) => Type::vtable_ptr(cx),
ty::TyTrait(_) => Type::vtable_ptr(cx),
_ => panic!("Unexpected type returned from \
struct_tail: {} for ty={}",
unsized_part.repr(cx.tcx()), ty.repr(cx.tcx()))
@ -374,7 +374,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
}
}
ty::ty_vec(ty, Some(size)) => {
ty::TyArray(ty, Some(size)) => {
let size = size as u64;
let llty = in_memory_type_of(cx, ty);
ensure_array_fits_in_address_space(cx, llty, size, t);
@ -385,18 +385,18 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
// traits have the type of u8. This is so that the data pointer inside
// fat pointers is of the right type (e.g. for array accesses), even
// when taking the address of an unsized field in a struct.
ty::ty_vec(ty, None) => in_memory_type_of(cx, ty),
ty::ty_str | ty::ty_trait(..) => Type::i8(cx),
ty::TyArray(ty, None) => in_memory_type_of(cx, ty),
ty::TyStr | ty::TyTrait(..) => Type::i8(cx),
ty::ty_bare_fn(..) => {
ty::TyBareFn(..) => {
type_of_fn_from_ty(cx, t).ptr_to()
}
ty::ty_tup(ref tys) if tys.is_empty() => Type::nil(cx),
ty::ty_tup(..) => {
ty::TyTuple(ref tys) if tys.is_empty() => Type::nil(cx),
ty::TyTuple(..) => {
let repr = adt::represent_type(cx, t);
adt::type_of(cx, &*repr)
}
ty::ty_struct(did, ref substs) => {
ty::TyStruct(did, ref substs) => {
if ty::type_is_simd(cx.tcx(), t) {
let llet = in_memory_type_of(cx, ty::simd_type(cx.tcx(), t));
let n = ty::simd_size(cx.tcx(), t) as u64;
@ -413,10 +413,10 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
}
}
ty::ty_infer(..) => cx.sess().bug("type_of with ty_infer"),
ty::ty_projection(..) => cx.sess().bug("type_of with ty_projection"),
ty::ty_param(..) => cx.sess().bug("type_of with ty_param"),
ty::ty_err(..) => cx.sess().bug("type_of with ty_err"),
ty::TyInfer(..) => cx.sess().bug("type_of with TyInfer"),
ty::TyProjection(..) => cx.sess().bug("type_of with TyProjection"),
ty::TyParam(..) => cx.sess().bug("type_of with ty_param"),
ty::TyError(..) => cx.sess().bug("type_of with TyError"),
};
debug!("--> mapped t={} {:?} to llty={}",
@ -428,7 +428,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
// If this was an enum or struct, fill in the type now.
match t.sty {
ty::ty_enum(..) | ty::ty_struct(..) | ty::ty_closure(..)
ty::TyEnum(..) | ty::TyStruct(..) | ty::TyClosure(..)
if !ty::type_is_simd(cx.tcx(), t) => {
let repr = adt::represent_type(cx, t);
adt::finish_type_of(cx, &*repr, &mut llty);

View file

@ -1040,7 +1040,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>,
bounds: ty::ExistentialBounds<'tcx>)
-> Ty<'tcx> {
let tcx = this.tcx();
let object = ty::TyTrait {
let object = ty::TraitTy {
principal: principal,
bounds: bounds
};
@ -1224,8 +1224,8 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
_ => unreachable!()
}
}
(&ty::ty_param(_), def::DefTyParam(..)) |
(&ty::ty_param(_), def::DefSelfTy(Some(_), None)) => {
(&ty::TyParam(_), def::DefTyParam(..)) |
(&ty::TyParam(_), def::DefSelfTy(Some(_), None)) => {
// A type parameter or Self, we need to find the associated item from
// a bound.
let ty_param_node_id = ty_path_def.local_node_id();
@ -1471,7 +1471,7 @@ pub fn finish_resolving_def_to_ty<'tcx>(this: &AstConv<'tcx>,
let mut def = *def;
// If any associated type segments remain, attempt to resolve them.
for segment in assoc_segments {
if ty.sty == ty::ty_err {
if ty.sty == ty::TyError {
break;
}
// This is pretty bad (it will fail except for T::A and Self::A).
@ -1529,7 +1529,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
}
ast::TyRptr(ref region, ref mt) => {
let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
debug!("ty_rptr r={}", r.repr(this.tcx()));
debug!("TyRef r={}", r.repr(this.tcx()));
let rscope1 =
&ObjectLifetimeDefaultRscope::new(
rscope,
@ -1583,7 +1583,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
&path.segments[..base_ty_end],
&path.segments[base_ty_end..]);
if path_res.depth != 0 && ty.sty != ty::ty_err {
if path_res.depth != 0 && ty.sty != ty::TyError {
// Write back the new resolution.
tcx.def_map.borrow_mut().insert(ast_ty.id, def::PathResolution {
base_def: def,
@ -1853,8 +1853,8 @@ fn determine_explicit_self_category<'a, 'tcx>(this: &AstConv<'tcx>,
ty::ByValueExplicitSelfCategory
} else {
match explicit_type.sty {
ty::ty_rptr(r, mt) => ty::ByReferenceExplicitSelfCategory(*r, mt.mutbl),
ty::ty_uniq(_) => ty::ByBoxExplicitSelfCategory,
ty::TyRef(r, mt) => ty::ByReferenceExplicitSelfCategory(*r, mt.mutbl),
ty::TyBox(_) => ty::ByBoxExplicitSelfCategory,
_ => ty::ByValueExplicitSelfCategory,
}
}
@ -1863,8 +1863,8 @@ fn determine_explicit_self_category<'a, 'tcx>(this: &AstConv<'tcx>,
fn count_modifiers(ty: Ty) -> usize {
match ty.sty {
ty::ty_rptr(_, mt) => count_modifiers(mt.ty) + 1,
ty::ty_uniq(t) => count_modifiers(t) + 1,
ty::TyRef(_, mt) => count_modifiers(mt.ty) + 1,
ty::TyBox(t) => count_modifiers(t) + 1,
_ => 0,
}
}

View file

@ -58,8 +58,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
if let ast::ExprLit(ref lt) = lt.node {
if let ast::LitBinary(_) = lt.node {
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
if let ty::ty_rptr(_, mt) = expected_ty.sty {
if let ty::ty_vec(_, None) = mt.ty.sty {
if let ty::TyRef(_, mt) = expected_ty.sty {
if let ty::TyArray(_, None) = mt.ty.sty {
pat_ty = ty::mk_slice(tcx, tcx.mk_region(ty::ReStatic),
ty::mt{ ty: tcx.types.u8, mutbl: ast::MutImmutable })
}
@ -293,7 +293,7 @@ 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::ty_vec(_, Some(size)) => ty::mk_vec(tcx, inner_ty, Some({
ty::TyArray(_, Some(size)) => ty::mk_vec(tcx, inner_ty, Some({
let min_len = before.len() + after.len();
match *slice {
Some(_) => cmp::max(min_len, size),
@ -413,7 +413,7 @@ pub fn check_dereferencable<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
if pat_is_binding(&tcx.def_map, inner) {
let expected = fcx.infcx().shallow_resolve(expected);
ty::deref(expected, true).map_or(true, |mt| match mt.ty.sty {
ty::ty_trait(_) => {
ty::TyTrait(_) => {
// This is "x = SomeTrait" being reduced from
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
span_err!(tcx.sess, span, E0033,
@ -558,9 +558,9 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
_ => {
let def_type = ty::lookup_item_type(tcx, def.def_id());
match def_type.ty.sty {
ty::ty_struct(struct_def_id, _) =>
ty::TyStruct(struct_def_id, _) =>
(struct_def_id, struct_def_id),
ty::ty_enum(enum_def_id, _)
ty::TyEnum(enum_def_id, _)
if def == def::DefVariant(enum_def_id, def.def_id(), true) =>
(enum_def_id, def.def_id()),
_ => {
@ -662,7 +662,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
let real_path_ty = fcx.node_ty(pat.id);
let (arg_tys, kind_name): (Vec<_>, &'static str) = match real_path_ty.sty {
ty::ty_enum(enum_def_id, expected_substs)
ty::TyEnum(enum_def_id, expected_substs)
if def == def::DefVariant(enum_def_id, def.def_id(), false) =>
{
let variant = ty::enum_variant_with_id(tcx, enum_def_id, def.def_id());
@ -671,7 +671,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
.collect(),
"variant")
}
ty::ty_struct(struct_def_id, expected_substs) => {
ty::TyStruct(struct_def_id, expected_substs) => {
let struct_fields = ty::struct_fields(tcx, struct_def_id, expected_substs);
(struct_fields.iter()
.map(|field| fcx.instantiate_type_scheme(pat.span,

View file

@ -127,12 +127,12 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// If the callee is a bare function or a closure, then we're all set.
match structurally_resolved_type(fcx, callee_expr.span, adjusted_ty).sty {
ty::ty_bare_fn(..) => {
ty::TyBareFn(..) => {
fcx.write_autoderef_adjustment(callee_expr.id, autoderefs);
return Some(CallStep::Builtin);
}
ty::ty_closure(def_id, substs) => {
ty::TyClosure(def_id, substs) => {
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
// Check whether this is a call to a closure where we
@ -165,7 +165,7 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// over the top. The simplest fix by far is to just ignore
// this case and deref again, so we wind up with
// `FnMut::call_mut(&mut *x, ())`.
ty::ty_rptr(..) if autoderefs == 0 => {
ty::TyRef(..) if autoderefs == 0 => {
return None;
}
@ -222,7 +222,7 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
let error_fn_sig;
let fn_sig = match callee_ty.sty {
ty::ty_bare_fn(_, &ty::BareFnTy {ref sig, ..}) => {
ty::TyBareFn(_, &ty::BareFnTy {ref sig, ..}) => {
sig
}
_ => {

View file

@ -74,17 +74,17 @@ fn unsize_kind<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>,
t: Ty<'tcx>)
-> Option<UnsizeKind<'tcx>> {
match t.sty {
ty::ty_vec(_, None) | ty::ty_str => Some(UnsizeKind::Length),
ty::ty_trait(_) => Some(UnsizeKind::Vtable),
ty::ty_struct(did, substs) => {
ty::TyArray(_, None) | ty::TyStr => Some(UnsizeKind::Length),
ty::TyTrait(_) => Some(UnsizeKind::Vtable),
ty::TyStruct(did, substs) => {
match ty::struct_fields(fcx.tcx(), did, substs).pop() {
None => None,
Some(f) => unsize_kind(fcx, f.mt.ty)
}
}
// We should really try to normalize here.
ty::ty_projection(ref pi) => Some(UnsizeKind::OfProjection(pi)),
ty::ty_param(ref p) => Some(UnsizeKind::OfParam(p)),
ty::TyProjection(ref pi) => Some(UnsizeKind::OfProjection(pi)),
ty::TyParam(ref p) => Some(UnsizeKind::OfParam(p)),
_ => None
}
}
@ -337,7 +337,7 @@ impl<'tcx> CastCheck<'tcx> {
// array-ptr-cast.
if m_expr.mutbl == ast::MutImmutable && m_cast.mutbl == ast::MutImmutable {
if let ty::ty_vec(ety, Some(_)) = m_expr.ty.sty {
if let ty::TyArray(ety, Some(_)) = m_expr.ty.sty {
// Due to the limitations of LLVM global constants,
// region pointers end up pointing at copies of
// vector elements instead of the original values.

View file

@ -107,7 +107,7 @@ fn deduce_expectations_from_expected_type<'a,'tcx>(
expected_ty.repr(fcx.tcx()));
match expected_ty.sty {
ty::ty_trait(ref object_type) => {
ty::TyTrait(ref object_type) => {
let proj_bounds = object_type.projection_bounds_with_self_ty(fcx.tcx(),
fcx.tcx().types.err);
let sig = proj_bounds.iter()
@ -116,7 +116,7 @@ fn deduce_expectations_from_expected_type<'a,'tcx>(
let kind = fcx.tcx().lang_items.fn_trait_kind(object_type.principal_def_id());
(sig, kind)
}
ty::ty_infer(ty::TyVar(vid)) => {
ty::TyInfer(ty::TyVar(vid)) => {
deduce_expectations_from_obligations(fcx, vid)
}
_ => {
@ -214,7 +214,7 @@ fn deduce_sig_from_projection<'a,'tcx>(
debug!("deduce_sig_from_projection: arg_param_ty {}", arg_param_ty.repr(tcx));
let input_tys = match arg_param_ty.sty {
ty::ty_tup(ref tys) => { (*tys).clone() }
ty::TyTuple(ref tys) => { (*tys).clone() }
_ => { return None; }
};
debug!("deduce_sig_from_projection: input_tys {}", input_tys.repr(tcx));
@ -244,7 +244,7 @@ fn self_type_matches_expected_vid<'a,'tcx>(
trait_ref.repr(fcx.tcx()),
self_ty.repr(fcx.tcx()));
match self_ty.sty {
ty::ty_infer(ty::TyVar(v)) if expected_vid == v => Some(trait_ref),
ty::TyInfer(ty::TyVar(v)) if expected_vid == v => Some(trait_ref),
_ => None,
}
}

View file

@ -121,13 +121,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
// Note: does not attempt to resolve type variables we encounter.
// See above for details.
match b.sty {
ty::ty_ptr(mt_b) => {
ty::TyRawPtr(mt_b) => {
return self.unpack_actual_value(a, |a| {
self.coerce_unsafe_ptr(a, b, mt_b.mutbl)
});
}
ty::ty_rptr(_, mt_b) => {
ty::TyRef(_, mt_b) => {
return self.unpack_actual_value(a, |a| {
self.coerce_borrowed_pointer(expr_a, a, b, mt_b.mutbl)
});
@ -138,13 +138,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
self.unpack_actual_value(a, |a| {
match a.sty {
ty::ty_bare_fn(Some(_), a_f) => {
ty::TyBareFn(Some(_), a_f) => {
// Function items are coercible to any closure
// type; function pointers are not (that would
// require double indirection).
self.coerce_from_fn_item(a, a_f, b)
}
ty::ty_bare_fn(None, a_f) => {
ty::TyBareFn(None, a_f) => {
// We permit coercion of fn pointers to drop the
// unsafe qualifier.
self.coerce_from_fn_pointer(a, a_f, b)
@ -177,7 +177,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
// yield.
match a.sty {
ty::ty_rptr(_, mt_a) => {
ty::TyRef(_, mt_a) => {
try!(coerce_mutbls(mt_a.mutbl, mutbl_b));
}
_ => return self.subtype(a, b)
@ -258,7 +258,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
// Handle reborrows before selecting `Source: CoerceUnsized<Target>`.
let (source, reborrow) = match (&source.sty, &target.sty) {
(&ty::ty_rptr(_, mt_a), &ty::ty_rptr(_, mt_b)) => {
(&ty::TyRef(_, mt_a), &ty::TyRef(_, mt_b)) => {
try!(coerce_mutbls(mt_a.mutbl, mt_b.mutbl));
let coercion = Coercion(self.origin.span());
@ -266,7 +266,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
let region = self.tcx().mk_region(r_borrow);
(mt_a.ty, Some(ty::AutoPtr(region, mt_b.mutbl)))
}
(&ty::ty_rptr(_, mt_a), &ty::ty_ptr(mt_b)) => {
(&ty::TyRef(_, mt_a), &ty::TyRawPtr(mt_b)) => {
try!(coerce_mutbls(mt_a.mutbl, mt_b.mutbl));
(mt_a.ty, Some(ty::AutoUnsafe(mt_b.mutbl)))
}
@ -355,7 +355,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
debug!("coerce_from_fn_pointer(a={}, b={})",
a.repr(self.tcx()), b.repr(self.tcx()));
if let ty::ty_bare_fn(None, fn_ty_b) = b.sty {
if let ty::TyBareFn(None, fn_ty_b) = b.sty {
match (fn_ty_a.unsafety, fn_ty_b.unsafety) {
(ast::Unsafety::Normal, ast::Unsafety::Unsafe) => {
let unsafe_a = self.tcx().safe_to_unsafe_fn_ty(fn_ty_a);
@ -384,7 +384,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
a.repr(self.tcx()), b.repr(self.tcx()));
match b.sty {
ty::ty_bare_fn(None, _) => {
ty::TyBareFn(None, _) => {
let a_fn_pointer = ty::mk_bare_fn(self.tcx(), None, fn_ty_a);
try!(self.subtype(a_fn_pointer, b));
Ok(Some(ty::AdjustReifyFnPointer))
@ -404,7 +404,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
b.repr(self.tcx()));
let mt_a = match a.sty {
ty::ty_rptr(_, mt) | ty::ty_ptr(mt) => mt,
ty::TyRef(_, mt) | ty::TyRawPtr(mt) => mt,
_ => {
return self.subtype(a, b);
}

View file

@ -41,9 +41,9 @@ pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: ast::DefId) -> Result<(),
ty: ref dtor_self_type } = ty::lookup_item_type(tcx, drop_impl_did);
let dtor_predicates = ty::lookup_predicates(tcx, drop_impl_did);
match dtor_self_type.sty {
ty::ty_enum(self_type_did, self_to_impl_substs) |
ty::ty_struct(self_type_did, self_to_impl_substs) |
ty::ty_closure(self_type_did, self_to_impl_substs) => {
ty::TyEnum(self_type_did, self_to_impl_substs) |
ty::TyStruct(self_type_did, self_to_impl_substs) |
ty::TyClosure(self_type_did, self_to_impl_substs) => {
try!(ensure_drop_params_and_item_params_correspond(tcx,
drop_impl_did,
dtor_generics,
@ -366,7 +366,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
// with `T`, the type it represents as owned by the
// surrounding context, before doing further analysis.
let (typ, xref_depth) = match typ.sty {
ty::ty_struct(struct_did, substs) => {
ty::TyStruct(struct_did, substs) => {
if opt_phantom_data_def_id == Some(struct_did) {
let item_type = ty::lookup_item_type(rcx.tcx(), struct_did);
let tp_def = item_type.generics.types
@ -380,11 +380,11 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
}
}
// Note: When ty_uniq is removed from compiler, the
// Note: When TyBox is removed from compiler, the
// definition of `Box<T>` must carry a PhantomData that
// puts us into the previous case.
ty::ty_uniq(new_typ) => {
debug!("replacing ty_uniq {} with {}",
ty::TyBox(new_typ) => {
debug!("replacing TyBox {} with {}",
typ.repr(rcx.tcx()), new_typ.repr(rcx.tcx()));
(new_typ, xref_depth_orig + 1)
}
@ -395,14 +395,14 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
};
let dtor_kind = match typ.sty {
ty::ty_enum(def_id, _) |
ty::ty_struct(def_id, _) => {
ty::TyEnum(def_id, _) |
ty::TyStruct(def_id, _) => {
match destructor_for_type.get(&def_id) {
Some(def_id) => DtorKind::KnownDropMethod(*def_id),
None => DtorKind::PureRecur,
}
}
ty::ty_trait(ref ty_trait) => {
ty::TyTrait(ref ty_trait) => {
DtorKind::Unknown(ty_trait.bounds.clone())
}
_ => DtorKind::PureRecur,
@ -466,7 +466,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
// destructor.
match typ.sty {
ty::ty_struct(struct_did, substs) => {
ty::TyStruct(struct_did, substs) => {
debug!("typ: {} is struct; traverse structure and not type-expression",
typ.repr(rcx.tcx()));
// Don't recurse; we extract type's substructure,
@ -496,7 +496,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
}
}
ty::ty_enum(enum_did, substs) => {
ty::TyEnum(enum_did, substs) => {
debug!("typ: {} is enum; traverse structure and not type-expression",
typ.repr(rcx.tcx()));
// Don't recurse; we extract type's substructure,
@ -526,7 +526,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
}
}
ty::ty_rptr(..) | ty::ty_ptr(_) | ty::ty_bare_fn(..) => {
ty::TyRef(..) | ty::TyRawPtr(_) | ty::TyBareFn(..) => {
// Don't recurse, since references, pointers,
// and bare functions don't own instances
// of the types appearing within them.

View file

@ -296,7 +296,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
}
fn extract_trait_ref<R, F>(&mut self, self_ty: Ty<'tcx>, mut closure: F) -> R where
F: FnMut(&mut ConfirmContext<'a, 'tcx>, Ty<'tcx>, &ty::TyTrait<'tcx>) -> R,
F: FnMut(&mut ConfirmContext<'a, 'tcx>, Ty<'tcx>, &ty::TraitTy<'tcx>) -> R,
{
// If we specified that this is an object method, then the
// self-type ought to be something that can be dereferenced to
@ -311,7 +311,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
NoPreference,
|ty, _| {
match ty.sty {
ty::ty_trait(ref data) => Some(closure(self, ty, &**data)),
ty::TyTrait(ref data) => Some(closure(self, ty, &**data)),
_ => None,
}
});
@ -456,12 +456,12 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
fn fixup_derefs_on_method_receiver_if_necessary(&self,
method_callee: &MethodCallee) {
let sig = match method_callee.ty.sty {
ty::ty_bare_fn(_, ref f) => f.sig.clone(),
ty::TyBareFn(_, ref f) => f.sig.clone(),
_ => return,
};
match sig.0.inputs[0].sty {
ty::ty_rptr(_, ty::mt {
ty::TyRef(_, ty::mt {
ty: _,
mutbl: ast::MutMutable,
}) => {}

View file

@ -254,7 +254,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// Trait method is fn(&self) or fn(&mut self), need an
// autoref. Pull the region etc out of the type of first argument.
match transformed_self_ty.sty {
ty::ty_rptr(region, ty::mt { mutbl, ty: _ }) => {
ty::TyRef(region, ty::mt { mutbl, ty: _ }) => {
fcx.write_adjustment(self_expr.id,
ty::AdjustDerefRef(ty::AutoDerefRef {
autoderefs: autoderefs,

View file

@ -202,7 +202,7 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
});
match final_ty.sty {
ty::ty_vec(elem_ty, Some(_)) => {
ty::TyArray(elem_ty, Some(_)) => {
let slice_ty = ty::mk_vec(fcx.tcx(), elem_ty, None);
steps.push(CandidateStep {
self_ty: slice_ty,
@ -210,7 +210,7 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
unsize: true
});
}
ty::ty_err => return None,
ty::TyError => return None,
_ => (),
}
@ -270,88 +270,88 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
self_ty.repr(self.tcx()));
match self_ty.sty {
ty::ty_trait(box ref data) => {
ty::TyTrait(box ref data) => {
self.assemble_inherent_candidates_from_object(self_ty, data);
self.assemble_inherent_impl_candidates_for_type(data.principal_def_id());
}
ty::ty_enum(did, _) |
ty::ty_struct(did, _) |
ty::ty_closure(did, _) => {
ty::TyEnum(did, _) |
ty::TyStruct(did, _) |
ty::TyClosure(did, _) => {
self.assemble_inherent_impl_candidates_for_type(did);
}
ty::ty_uniq(_) => {
ty::TyBox(_) => {
if let Some(box_did) = self.tcx().lang_items.owned_box() {
self.assemble_inherent_impl_candidates_for_type(box_did);
}
}
ty::ty_param(p) => {
ty::TyParam(p) => {
self.assemble_inherent_candidates_from_param(self_ty, p);
}
ty::ty_char => {
ty::TyChar => {
let lang_def_id = self.tcx().lang_items.char_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_str => {
ty::TyStr => {
let lang_def_id = self.tcx().lang_items.str_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_vec(_, None) => {
ty::TyArray(_, None) => {
let lang_def_id = self.tcx().lang_items.slice_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutImmutable }) => {
ty::TyRawPtr(ty::mt { ty: _, mutbl: ast::MutImmutable }) => {
let lang_def_id = self.tcx().lang_items.const_ptr_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutMutable }) => {
ty::TyRawPtr(ty::mt { ty: _, mutbl: ast::MutMutable }) => {
let lang_def_id = self.tcx().lang_items.mut_ptr_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_int(ast::TyI8) => {
ty::TyInt(ast::TyI8) => {
let lang_def_id = self.tcx().lang_items.i8_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_int(ast::TyI16) => {
ty::TyInt(ast::TyI16) => {
let lang_def_id = self.tcx().lang_items.i16_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_int(ast::TyI32) => {
ty::TyInt(ast::TyI32) => {
let lang_def_id = self.tcx().lang_items.i32_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_int(ast::TyI64) => {
ty::TyInt(ast::TyI64) => {
let lang_def_id = self.tcx().lang_items.i64_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_int(ast::TyIs) => {
ty::TyInt(ast::TyIs) => {
let lang_def_id = self.tcx().lang_items.isize_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_uint(ast::TyU8) => {
ty::TyUint(ast::TyU8) => {
let lang_def_id = self.tcx().lang_items.u8_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_uint(ast::TyU16) => {
ty::TyUint(ast::TyU16) => {
let lang_def_id = self.tcx().lang_items.u16_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_uint(ast::TyU32) => {
ty::TyUint(ast::TyU32) => {
let lang_def_id = self.tcx().lang_items.u32_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_uint(ast::TyU64) => {
ty::TyUint(ast::TyU64) => {
let lang_def_id = self.tcx().lang_items.u64_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_uint(ast::TyUs) => {
ty::TyUint(ast::TyUs) => {
let lang_def_id = self.tcx().lang_items.usize_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_float(ast::TyF32) => {
ty::TyFloat(ast::TyF32) => {
let lang_def_id = self.tcx().lang_items.f32_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::ty_float(ast::TyF64) => {
ty::TyFloat(ast::TyF64) => {
let lang_def_id = self.tcx().lang_items.f64_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
@ -413,7 +413,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
fn assemble_inherent_candidates_from_object(&mut self,
self_ty: Ty<'tcx>,
data: &ty::TyTrait<'tcx>) {
data: &ty::TraitTy<'tcx>) {
debug!("assemble_inherent_candidates_from_object(self_ty={})",
self_ty.repr(self.tcx()));
@ -460,7 +460,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
match *predicate {
ty::Predicate::Trait(ref trait_predicate) => {
match trait_predicate.0.trait_ref.self_ty().sty {
ty::ty_param(ref p) if *p == param_ty => {
ty::TyParam(ref p) if *p == param_ty => {
Some(trait_predicate.to_poly_trait_ref())
}
_ => None
@ -702,7 +702,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
let steps = self.steps.clone();
for step in steps.iter() {
let closure_def_id = match step.self_ty.sty {
ty::ty_closure(a, _) => a,
ty::TyClosure(a, _) => a,
_ => continue,
};
@ -759,7 +759,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
step.repr(self.tcx()));
let projection_trait_ref = match step.self_ty.sty {
ty::ty_projection(ref data) => &data.trait_ref,
ty::TyProjection(ref data) => &data.trait_ref,
_ => continue,
};
@ -924,7 +924,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
pick.autoderefs = step.autoderefs;
// Insert a `&*` or `&mut *` if this is a reference type:
if let ty::ty_rptr(_, mt) = step.self_ty.sty {
if let ty::TyRef(_, mt) = step.self_ty.sty {
pick.autoderefs += 1;
pick.autoref = Some(mt.mutbl);
}

View file

@ -61,7 +61,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
None);
// If the item has the name of a field, give a help note
if let (&ty::ty_struct(did, _), Some(_)) = (&rcvr_ty.sty, rcvr_expr) {
if let (&ty::TyStruct(did, _), Some(_)) = (&rcvr_ty.sty, rcvr_expr) {
let fields = ty::lookup_struct_fields(cx, did);
if fields.iter().any(|f| f.name == item_name) {
cx.sess.span_note(span,
@ -238,11 +238,11 @@ fn type_derefs_to_local<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
rcvr_expr: Option<&ast::Expr>) -> bool {
fn is_local(ty: Ty) -> bool {
match ty.sty {
ty::ty_enum(did, _) | ty::ty_struct(did, _) => ast_util::is_local(did),
ty::TyEnum(did, _) | ty::TyStruct(did, _) => ast_util::is_local(did),
ty::ty_trait(ref tr) => ast_util::is_local(tr.principal_def_id()),
ty::TyTrait(ref tr) => ast_util::is_local(tr.principal_def_id()),
ty::ty_param(_) => true,
ty::TyParam(_) => true,
// everything else (primitive types etc.) is effectively
// non-local (there are "edge" cases, e.g. (LocalType,), but

View file

@ -506,7 +506,7 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
param_env: ty::ParameterEnvironment<'a, 'tcx>)
{
match raw_fty.sty {
ty::ty_bare_fn(_, ref fn_ty) => {
ty::TyBareFn(_, ref fn_ty) => {
let inh = Inherited::new(ccx.tcx, param_env);
// Compute the fty from point of view of inside fn.
@ -1142,7 +1142,7 @@ fn report_cast_to_unsized_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
format!("cast to unsized type: `{}` as `{}`", actual, tstr)
}, t_expr, None);
match t_expr.sty {
ty::ty_rptr(_, ty::mt { mutbl: mt, .. }) => {
ty::TyRef(_, ty::mt { mutbl: mt, .. }) => {
let mtstr = match mt {
ast::MutMutable => "mut ",
ast::MutImmutable => ""
@ -1164,7 +1164,7 @@ fn report_cast_to_unsized_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
mtstr, tstr);
}
}
ty::ty_uniq(..) => {
ty::TyBox(..) => {
match fcx.tcx().sess.codemap().span_to_snippet(t_span) {
Ok(s) => {
fcx.tcx().sess.span_suggestion(t_span,
@ -1920,8 +1920,8 @@ impl LvaluePreference {
/// Whether `autoderef` requires types to resolve.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum UnresolvedTypeAction {
/// Produce an error and return `ty_err` whenever a type cannot
/// be resolved (i.e. it is `ty_infer`).
/// Produce an error and return `TyError` whenever a type cannot
/// be resolved (i.e. it is `TyInfer`).
Error,
/// Go on without emitting any errors, and return the unresolved
/// type. Useful for probing, e.g. in coercions.
@ -2096,7 +2096,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::ty_vec(element_ty, Some(_)) = ty.sty {
if let ty::TyArray(element_ty, Some(_)) = ty.sty {
let adjusted_ty = ty::mk_vec(fcx.tcx(), element_ty, None);
try_index_step(fcx, MethodCall::expr(expr.id), expr, base_expr,
adjusted_ty, autoderefs, true, lvalue_pref, idx_ty)
@ -2134,7 +2134,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// First, try built-in indexing.
match (ty::index(adjusted_ty), &index_ty.sty) {
(Some(ty), &ty::ty_uint(ast::TyUs)) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => {
(Some(ty), &ty::TyUint(ast::TyUs)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
debug!("try_index_step: success, using built-in indexing");
// If we had `[T; N]`, we should've caught it before unsizing to `[T]`.
assert!(!unsize);
@ -2212,7 +2212,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
ty::FnConverging(fcx.tcx().types.err)
} else {
match method_fn_ty.sty {
ty::ty_bare_fn(_, ref fty) => {
ty::TyBareFn(_, ref fty) => {
// HACK(eddyb) ignore self in the definition (see above).
let expected_arg_tys = expected_types_for_fn_args(fcx,
sp,
@ -2260,7 +2260,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let formal_tys = if tuple_arguments == TupleArguments {
let tuple_type = structurally_resolved_type(fcx, sp, fn_inputs[0]);
match tuple_type.sty {
ty::ty_tup(ref arg_types) => {
ty::TyTuple(ref arg_types) => {
if arg_types.len() != args.len() {
span_err!(tcx.sess, sp, E0057,
"this function takes {} parameter{} but {} parameter{} supplied",
@ -2273,7 +2273,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
} else {
expected_arg_tys = match expected_arg_tys.get(0) {
Some(&ty) => match ty.sty {
ty::ty_tup(ref tys) => &**tys,
ty::TyTuple(ref tys) => &**tys,
_ => &[]
},
None => &[]
@ -2391,21 +2391,21 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let arg_ty = structurally_resolved_type(fcx, arg.span,
fcx.expr_ty(&**arg));
match arg_ty.sty {
ty::ty_float(ast::TyF32) => {
ty::TyFloat(ast::TyF32) => {
fcx.type_error_message(arg.span,
|t| {
format!("can't pass an {} to variadic \
function, cast to c_double", t)
}, arg_ty, None);
}
ty::ty_int(ast::TyI8) | ty::ty_int(ast::TyI16) | ty::ty_bool => {
ty::TyInt(ast::TyI8) | ty::TyInt(ast::TyI16) | ty::TyBool => {
fcx.type_error_message(arg.span, |t| {
format!("can't pass {} to variadic \
function, cast to c_int",
t)
}, arg_ty, None);
}
ty::ty_uint(ast::TyU8) | ty::ty_uint(ast::TyU16) => {
ty::TyUint(ast::TyU8) | ty::TyUint(ast::TyU16) => {
fcx.type_error_message(arg.span, |t| {
format!("can't pass {} to variadic \
function, cast to c_uint",
@ -2455,10 +2455,10 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
ast::LitInt(_, ast::UnsuffixedIntLit(_)) => {
let opt_ty = expected.to_option(fcx).and_then(|ty| {
match ty.sty {
ty::ty_int(_) | ty::ty_uint(_) => Some(ty),
ty::ty_char => Some(tcx.types.u8),
ty::ty_ptr(..) => Some(tcx.types.usize),
ty::ty_bare_fn(..) => Some(tcx.types.usize),
ty::TyInt(_) | ty::TyUint(_) => Some(ty),
ty::TyChar => Some(tcx.types.u8),
ty::TyRawPtr(..) => Some(tcx.types.usize),
ty::TyBareFn(..) => Some(tcx.types.usize),
_ => None
}
});
@ -2469,7 +2469,7 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
ast::LitFloatUnsuffixed(_) => {
let opt_ty = expected.to_option(fcx).and_then(|ty| {
match ty.sty {
ty::ty_float(_) => Some(ty),
ty::TyFloat(_) => Some(ty),
_ => None
}
});
@ -2621,7 +2621,7 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
/// strict, _|_ can appear in the type of an expression that does not,
/// itself, diverge: for example, fn() -> _|_.)
/// Note that inspecting a type's structure *directly* may expose the fact
/// that there are actually multiple representations for `ty_err`, so avoid
/// that there are actually multiple representations for `TyError`, so avoid
/// that when err needs to be handled differently.
fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
expr: &'tcx ast::Expr,
@ -2746,7 +2746,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
lvalue_pref,
|base_t, _| {
match base_t.sty {
ty::ty_struct(base_id, substs) => {
ty::TyStruct(base_id, substs) => {
debug!("struct named {}", ppaux::ty_to_string(tcx, base_t));
let fields = ty::lookup_struct_fields(tcx, base_id);
fcx.lookup_field_ty(expr.span, base_id, &fields[..],
@ -2787,7 +2787,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
actual)
},
expr_t, None);
if let ty::ty_struct(did, _) = expr_t.sty {
if let ty::TyStruct(did, _) = expr_t.sty {
suggest_field_names(did, field, tcx, vec![]);
}
}
@ -2848,7 +2848,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
lvalue_pref,
|base_t, _| {
match base_t.sty {
ty::ty_struct(base_id, substs) => {
ty::TyStruct(base_id, substs) => {
tuple_like = ty::is_tuple_struct(tcx, base_id);
if tuple_like {
debug!("tuple struct named {}", ppaux::ty_to_string(tcx, base_t));
@ -2859,7 +2859,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
None
}
}
ty::ty_tup(ref v) => {
ty::TyTuple(ref v) => {
tuple_like = true;
if idx.node < v.len() { Some(v[idx.node]) } else { None }
}
@ -3138,7 +3138,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
let expected_inner = expected.to_option(fcx).map_or(NoExpectation, |ty| {
match unop {
ast::UnUniq => match ty.sty {
ty::ty_uniq(ty) => {
ty::TyBox(ty) => {
Expectation::rvalue_hint(ty)
}
_ => {
@ -3188,7 +3188,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
oprnd_t);
if !(ty::type_is_integral(oprnd_t) ||
oprnd_t.sty == ty::ty_bool) {
oprnd_t.sty == ty::TyBool) {
oprnd_t = op::check_user_unop(fcx, "!", "not",
tcx.lang_items.not_trait(),
expr, &**oprnd, oprnd_t, unop);
@ -3203,7 +3203,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
tcx.lang_items.neg_trait(),
expr, &**oprnd, oprnd_t, unop);
}
if let ty::ty_uint(_) = oprnd_t.sty {
if let ty::TyUint(_) = oprnd_t.sty {
if !tcx.sess.features.borrow().negate_unsigned {
feature_gate::emit_feature_err(
&tcx.sess.parse_sess.span_diagnostic,
@ -3220,7 +3220,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
ast::ExprAddrOf(mutbl, ref oprnd) => {
let hint = expected.only_has_type(fcx).map_or(NoExpectation, |ty| {
match ty.sty {
ty::ty_rptr(_, ref mt) | ty::ty_ptr(ref mt) => {
ty::TyRef(_, ref mt) | ty::TyRawPtr(ref mt) => {
if ty::expr_is_lval(fcx.tcx(), &**oprnd) {
// Lvalues may legitimately have unsized types.
// For example, dereferences of a fat pointer and
@ -3453,7 +3453,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
ast::ExprVec(ref args) => {
let uty = expected.to_option(fcx).and_then(|uty| {
match uty.sty {
ty::ty_vec(ty, _) => Some(ty),
ty::TyArray(ty, _) => Some(ty),
_ => None
}
});
@ -3483,7 +3483,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
let uty = match expected {
ExpectHasType(uty) => {
match uty.sty {
ty::ty_vec(ty, _) => Some(ty),
ty::TyArray(ty, _) => Some(ty),
_ => None
}
}
@ -3522,7 +3522,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
ast::ExprTup(ref elts) => {
let flds = expected.only_has_type(fcx).and_then(|ty| {
match ty.sty {
ty::ty_tup(ref flds) => Some(&flds[..]),
ty::TyTuple(ref flds) => Some(&flds[..]),
_ => None
}
});
@ -3573,7 +3573,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
// Verify that this was actually a struct.
let typ = ty::lookup_item_type(fcx.ccx.tcx, def.def_id());
match typ.ty.sty {
ty::ty_struct(struct_did, _) => {
ty::TyStruct(struct_did, _) => {
check_struct_constructor(fcx,
id,
expr.span,
@ -3863,7 +3863,7 @@ impl<'tcx> Expectation<'tcx> {
/// for examples of where this comes up,.
fn rvalue_hint(ty: Ty<'tcx>) -> Expectation<'tcx> {
match ty.sty {
ty::ty_vec(_, None) | ty::ty_trait(..) => {
ty::TyArray(_, None) | ty::TyTrait(..) => {
ExpectRvalueLikeUnsized(ty)
}
_ => ExpectHasType(ty)
@ -4213,7 +4213,7 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
return;
}
match t.sty {
ty::ty_struct(did, substs) => {
ty::TyStruct(did, substs) => {
let fields = ty::lookup_struct_fields(tcx, did);
if fields.is_empty() {
span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty");
@ -4959,7 +4959,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
ty::walk_ty(ty, |t| {
match t.sty {
ty::ty_param(ParamTy {idx, ..}) => {
ty::TyParam(ParamTy {idx, ..}) => {
debug!("Found use of ty param num {}", idx);
tps_used[idx as usize] = true;
}

View file

@ -669,7 +669,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
}
None => rcx.resolve_node_type(base.id)
};
if let ty::ty_rptr(r_ptr, _) = base_ty.sty {
if let ty::TyRef(r_ptr, _) = base_ty.sty {
mk_subregion_due_to_dereference(
rcx, expr.span, ty::ReScope(CodeExtent::from_node_id(expr.id)), *r_ptr);
}
@ -762,23 +762,23 @@ fn constrain_cast(rcx: &mut Rcx,
from_ty.repr(rcx.tcx()),
to_ty.repr(rcx.tcx()));
match (&from_ty.sty, &to_ty.sty) {
/*From:*/ (&ty::ty_rptr(from_r, ref from_mt),
/*To: */ &ty::ty_rptr(to_r, ref to_mt)) => {
/*From:*/ (&ty::TyRef(from_r, ref from_mt),
/*To: */ &ty::TyRef(to_r, ref to_mt)) => {
// Target cannot outlive source, naturally.
rcx.fcx.mk_subr(infer::Reborrow(cast_expr.span), *to_r, *from_r);
walk_cast(rcx, cast_expr, from_mt.ty, to_mt.ty);
}
/*From:*/ (_,
/*To: */ &ty::ty_trait(box ty::TyTrait { ref bounds, .. })) => {
/*To: */ &ty::TyTrait(box ty::TraitTy { ref bounds, .. })) => {
// When T is existentially quantified as a trait
// `Foo+'to`, it must outlive the region bound `'to`.
type_must_outlive(rcx, infer::RelateObjectBound(cast_expr.span),
from_ty, bounds.region_bound);
}
/*From:*/ (&ty::ty_uniq(from_referent_ty),
/*To: */ &ty::ty_uniq(to_referent_ty)) => {
/*From:*/ (&ty::TyBox(from_referent_ty),
/*To: */ &ty::TyBox(to_referent_ty)) => {
walk_cast(rcx, cast_expr, from_referent_ty, to_referent_ty);
}
@ -801,7 +801,7 @@ fn constrain_callee(rcx: &mut Rcx,
_callee_expr: &ast::Expr) {
let callee_ty = rcx.resolve_node_type(callee_id);
match callee_ty.sty {
ty::ty_bare_fn(..) => { }
ty::TyBareFn(..) => { }
_ => {
// this should not happen, but it does if the program is
// erroneous
@ -899,7 +899,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
ty::no_late_bound_regions(rcx.tcx(), fn_sig).unwrap();
let self_ty = fn_sig.inputs[0];
let (m, r) = match self_ty.sty {
ty::ty_rptr(r, ref m) => (m.mutbl, r),
ty::TyRef(r, ref m) => (m.mutbl, r),
_ => {
rcx.tcx().sess.span_bug(
deref_expr.span,
@ -935,7 +935,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
None => derefd_ty
};
if let ty::ty_rptr(r_ptr, _) = derefd_ty.sty {
if let ty::TyRef(r_ptr, _) = derefd_ty.sty {
mk_subregion_due_to_dereference(rcx, deref_expr.span,
r_deref_expr, *r_ptr);
}
@ -995,9 +995,9 @@ fn constrain_index<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
rcx.fcx.infcx().ty_to_string(indexed_ty));
let r_index_expr = ty::ReScope(CodeExtent::from_node_id(index_expr.id));
if let ty::ty_rptr(r_ptr, mt) = indexed_ty.sty {
if let ty::TyRef(r_ptr, mt) = indexed_ty.sty {
match mt.ty.sty {
ty::ty_vec(_, None) | ty::ty_str => {
ty::TyArray(_, None) | ty::TyStr => {
rcx.fcx.mk_subr(infer::IndexSlice(index_expr.span),
r_index_expr, *r_ptr);
}

View file

@ -403,7 +403,7 @@ fn reject_non_type_param_bounds<'tcx>(tcx: &ty::ctxt<'tcx>,
fn is_ty_param(ty: ty::Ty) -> bool {
match &ty.sty {
&ty::sty::ty_param(_) => true,
&ty::TyParam(_) => true,
_ => false
}
}
@ -568,8 +568,8 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
}
match t.sty{
ty::ty_struct(type_id, substs) |
ty::ty_enum(type_id, substs) => {
ty::TyStruct(type_id, substs) |
ty::TyEnum(type_id, substs) => {
let type_predicates = ty::lookup_predicates(self.fcx.tcx(), type_id);
let bounds = self.fcx.instantiate_bounds(self.span, substs,
&type_predicates);

View file

@ -22,12 +22,12 @@ use middle::traits;
use middle::ty::RegionEscape;
use middle::ty::{ImplContainer, ImplOrTraitItemId, ConstTraitItemId};
use middle::ty::{MethodTraitItemId, TypeTraitItemId, ParameterEnvironment};
use middle::ty::{Ty, ty_bool, ty_char, ty_enum, ty_err};
use middle::ty::{ty_param, TypeScheme, ty_ptr};
use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup};
use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int};
use middle::ty::{ty_uint, ty_closure, ty_uniq, ty_bare_fn};
use middle::ty::ty_projection;
use middle::ty::{Ty, TyBool, TyChar, TyEnum, TyError};
use middle::ty::{TyParam, TypeScheme, TyRawPtr};
use middle::ty::{TyRef, TyStruct, TyTrait, TyTuple};
use middle::ty::{TyStr, TyArray, TyFloat, TyInfer, TyInt};
use middle::ty::{TyUint, TyClosure, TyBox, TyBareFn};
use middle::ty::TyProjection;
use middle::ty;
use middle::free_region::FreeRegionMap;
use CrateCtxt;
@ -56,27 +56,27 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
ty: Ty<'tcx>)
-> Option<DefId> {
match ty.sty {
ty_enum(def_id, _) |
ty_struct(def_id, _) => {
TyEnum(def_id, _) |
TyStruct(def_id, _) => {
Some(def_id)
}
ty_trait(ref t) => {
TyTrait(ref t) => {
Some(t.principal_def_id())
}
ty_uniq(_) => {
TyBox(_) => {
inference_context.tcx.lang_items.owned_box()
}
ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_tup(..) |
ty_param(..) | ty_err |
ty_ptr(_) | ty_rptr(_, _) | ty_projection(..) => {
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
TyStr(..) | TyArray(..) | TyBareFn(..) | TyTuple(..) |
TyParam(..) | TyError |
TyRawPtr(_) | TyRef(_, _) | TyProjection(..) => {
None
}
ty_infer(..) | ty_closure(..) => {
TyInfer(..) | TyClosure(..) => {
// `ty` comes from a user declaration so we should only expect types
// that the user can type
inference_context.tcx.sess.span_bug(
@ -315,9 +315,9 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
let self_type = ty::lookup_item_type(tcx, impl_did);
match self_type.ty.sty {
ty::ty_enum(type_def_id, _) |
ty::ty_struct(type_def_id, _) |
ty::ty_closure(type_def_id, _) => {
ty::TyEnum(type_def_id, _) |
ty::TyStruct(type_def_id, _) |
ty::TyClosure(type_def_id, _) => {
tcx.destructor_for_type
.borrow_mut()
.insert(type_def_id, method_def_id.def_id());
@ -465,19 +465,19 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
(mt_a.ty, mt_b.ty, unsize_trait, None)
};
let (source, target, trait_def_id, kind) = match (&source.sty, &target.sty) {
(&ty::ty_uniq(a), &ty::ty_uniq(b)) => (a, b, unsize_trait, None),
(&ty::TyBox(a), &ty::TyBox(b)) => (a, b, unsize_trait, None),
(&ty::ty_rptr(r_a, mt_a), &ty::ty_rptr(r_b, mt_b)) => {
(&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))
}
(&ty::ty_rptr(_, mt_a), &ty::ty_ptr(mt_b)) |
(&ty::ty_ptr(mt_a), &ty::ty_ptr(mt_b)) => {
(&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))
}
(&ty::ty_struct(def_id_a, substs_a), &ty::ty_struct(def_id_b, substs_b)) => {
(&ty::TyStruct(def_id_a, substs_a), &ty::TyStruct(def_id_b, substs_b)) => {
if def_id_a != def_id_b {
let source_path = ty::item_path_str(tcx, def_id_a);
let target_path = ty::item_path_str(tcx, def_id_b);

View file

@ -69,129 +69,129 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
debug!("coherence2::orphan check: inherent impl {}", item.repr(self.tcx));
let self_ty = ty::lookup_item_type(self.tcx, def_id).ty;
match self_ty.sty {
ty::ty_enum(def_id, _) |
ty::ty_struct(def_id, _) => {
ty::TyEnum(def_id, _) |
ty::TyStruct(def_id, _) => {
self.check_def_id(item, def_id);
}
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
self.check_def_id(item, data.principal_def_id());
}
ty::ty_uniq(..) => {
ty::TyBox(..) => {
self.check_def_id(item, self.tcx.lang_items.owned_box().unwrap());
}
ty::ty_char => {
ty::TyChar => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.char_impl(),
"char",
"char",
item.span);
}
ty::ty_str => {
ty::TyStr => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.str_impl(),
"str",
"str",
item.span);
}
ty::ty_vec(_, None) => {
ty::TyArray(_, None) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.slice_impl(),
"slice",
"[T]",
item.span);
}
ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutImmutable }) => {
ty::TyRawPtr(ty::mt { ty: _, mutbl: ast::MutImmutable }) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.const_ptr_impl(),
"const_ptr",
"*const T",
item.span);
}
ty::ty_ptr(ty::mt { ty: _, mutbl: ast::MutMutable }) => {
ty::TyRawPtr(ty::mt { ty: _, mutbl: ast::MutMutable }) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.mut_ptr_impl(),
"mut_ptr",
"*mut T",
item.span);
}
ty::ty_int(ast::TyI8) => {
ty::TyInt(ast::TyI8) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i8_impl(),
"i8",
"i8",
item.span);
}
ty::ty_int(ast::TyI16) => {
ty::TyInt(ast::TyI16) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i16_impl(),
"i16",
"i16",
item.span);
}
ty::ty_int(ast::TyI32) => {
ty::TyInt(ast::TyI32) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i32_impl(),
"i32",
"i32",
item.span);
}
ty::ty_int(ast::TyI64) => {
ty::TyInt(ast::TyI64) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.i64_impl(),
"i64",
"i64",
item.span);
}
ty::ty_int(ast::TyIs) => {
ty::TyInt(ast::TyIs) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.isize_impl(),
"isize",
"isize",
item.span);
}
ty::ty_uint(ast::TyU8) => {
ty::TyUint(ast::TyU8) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u8_impl(),
"u8",
"u8",
item.span);
}
ty::ty_uint(ast::TyU16) => {
ty::TyUint(ast::TyU16) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u16_impl(),
"u16",
"u16",
item.span);
}
ty::ty_uint(ast::TyU32) => {
ty::TyUint(ast::TyU32) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u32_impl(),
"u32",
"u32",
item.span);
}
ty::ty_uint(ast::TyU64) => {
ty::TyUint(ast::TyU64) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.u64_impl(),
"u64",
"u64",
item.span);
}
ty::ty_uint(ast::TyUs) => {
ty::TyUint(ast::TyUs) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.usize_impl(),
"usize",
"usize",
item.span);
}
ty::ty_float(ast::TyF32) => {
ty::TyFloat(ast::TyF32) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.f32_impl(),
"f32",
"f32",
item.span);
}
ty::ty_float(ast::TyF64) => {
ty::TyFloat(ast::TyF64) => {
self.check_primitive_impl(def_id,
self.tcx.lang_items.f64_impl(),
"f64",
@ -275,9 +275,9 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
{
let self_ty = trait_ref.self_ty();
let opt_self_def_id = match self_ty.sty {
ty::ty_struct(self_def_id, _) | ty::ty_enum(self_def_id, _) =>
ty::TyStruct(self_def_id, _) | ty::TyEnum(self_def_id, _) =>
Some(self_def_id),
ty::ty_uniq(..) =>
ty::TyBox(..) =>
self.tcx.lang_items.owned_box(),
_ =>
None

View file

@ -198,7 +198,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
let trait_ref = ty::impl_trait_ref(self.tcx, impl_def_id).unwrap();
let trait_def_id = trait_ref.def_id;
match trait_ref.self_ty().sty {
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
// This is something like impl Trait1 for Trait2. Illegal
// if Trait1 is a supertrait of Trait2 or Trait2 is not object safe.

View file

@ -1882,7 +1882,7 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
ty::walk_ty(ty, |t| {
match t.sty {
ty::ty_param(p) => if p.idx > cur_idx {
ty::TyParam(p) => if p.idx > cur_idx {
span_err!(tcx.sess, path.span, E0128,
"type parameters with a default cannot use \
forward declared identifiers");
@ -2174,8 +2174,8 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
if let ast::SelfExplicit(ref ast_type, _) = explicit_self.node {
let typ = ccx.icx(&method_type.predicates).to_ty(rs, &**ast_type);
let base_type = match typ.sty {
ty::ty_rptr(_, tm) => tm.ty,
ty::ty_uniq(typ) => typ,
ty::TyRef(_, tm) => tm.ty,
ty::TyBox(typ) => typ,
_ => typ,
};

View file

@ -40,14 +40,14 @@ pub fn parameters_for_trait_ref<'tcx>(trait_ref: &ty::TraitRef<'tcx>) -> Vec<Par
fn parameters_for_type_shallow<'tcx>(ty: Ty<'tcx>) -> Vec<Parameter> {
match ty.sty {
ty::ty_param(ref d) =>
ty::TyParam(ref d) =>
vec![Parameter::Type(d.clone())],
ty::ty_rptr(region, _) =>
ty::TyRef(region, _) =>
parameters_for_region(region).into_iter().collect(),
ty::ty_struct(_, substs) |
ty::ty_enum(_, substs) =>
ty::TyStruct(_, substs) |
ty::TyEnum(_, substs) =>
parameters_for_regions_in_substs(substs),
ty::ty_trait(ref data) =>
ty::TyTrait(ref data) =>
parameters_for_regions_in_substs(&data.principal.skip_binder().substs),
_ =>
vec![],

View file

@ -212,7 +212,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
let tcx = ccx.tcx;
let main_t = ty::node_id_to_type(tcx, main_id);
match main_t.sty {
ty::ty_bare_fn(..) => {
ty::TyBareFn(..) => {
match tcx.map.find(main_id) {
Some(ast_map::NodeItem(it)) => {
match it.node {
@ -259,7 +259,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
let tcx = ccx.tcx;
let start_t = ty::node_id_to_type(tcx, start_id);
match start_t.sty {
ty::ty_bare_fn(..) => {
ty::TyBareFn(..) => {
match tcx.map.find(start_id) {
Some(ast_map::NodeItem(it)) => {
match it.node {

View file

@ -873,39 +873,39 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
variance);
match ty.sty {
ty::ty_bool |
ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) |
ty::ty_float(_) | ty::ty_str => {
ty::TyBool |
ty::TyChar | ty::TyInt(_) | ty::TyUint(_) |
ty::TyFloat(_) | ty::TyStr => {
/* leaf type -- noop */
}
ty::ty_closure(..) => {
ty::TyClosure(..) => {
self.tcx().sess.bug("Unexpected closure type in variance computation");
}
ty::ty_rptr(region, ref mt) => {
ty::TyRef(region, ref mt) => {
let contra = self.contravariant(variance);
self.add_constraints_from_region(generics, *region, contra);
self.add_constraints_from_mt(generics, mt, variance);
}
ty::ty_uniq(typ) | ty::ty_vec(typ, _) => {
ty::TyBox(typ) | ty::TyArray(typ, _) => {
self.add_constraints_from_ty(generics, typ, variance);
}
ty::ty_ptr(ref mt) => {
ty::TyRawPtr(ref mt) => {
self.add_constraints_from_mt(generics, mt, variance);
}
ty::ty_tup(ref subtys) => {
ty::TyTuple(ref subtys) => {
for &subty in subtys {
self.add_constraints_from_ty(generics, subty, variance);
}
}
ty::ty_enum(def_id, substs) |
ty::ty_struct(def_id, substs) => {
ty::TyEnum(def_id, substs) |
ty::TyStruct(def_id, substs) => {
let item_type = ty::lookup_item_type(self.tcx(), def_id);
// All type parameters on enums and structs should be
@ -924,7 +924,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
variance);
}
ty::ty_projection(ref data) => {
ty::TyProjection(ref data) => {
let trait_ref = &data.trait_ref;
let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id);
self.add_constraints_from_substs(
@ -936,7 +936,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
variance);
}
ty::ty_trait(ref data) => {
ty::TyTrait(ref data) => {
let poly_trait_ref =
data.principal_trait_ref_with_self_ty(self.tcx(),
self.tcx().types.err);
@ -955,7 +955,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
}
}
ty::ty_param(ref data) => {
ty::TyParam(ref data) => {
let def_id = generics.types.get(data.space, data.idx as usize).def_id;
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
match self.terms_cx.inferred_map.get(&def_id.node) {
@ -970,16 +970,16 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
}
}
ty::ty_bare_fn(_, &ty::BareFnTy { ref sig, .. }) => {
ty::TyBareFn(_, &ty::BareFnTy { ref sig, .. }) => {
self.add_constraints_from_sig(generics, sig, variance);
}
ty::ty_err => {
ty::TyError => {
// we encounter this when walking the trait references for object
// types, where we use ty_err as the Self type
// types, where we use TyError as the Self type
}
ty::ty_infer(..) => {
ty::TyInfer(..) => {
self.tcx().sess.bug(
&format!("unexpected type encountered in \
variance inference: {}",

View file

@ -167,7 +167,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Function {
let t = ty::lookup_item_type(tcx, did);
let (decl, style, abi) = match t.ty.sty {
ty::ty_bare_fn(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
ty::TyBareFn(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
_ => panic!("bad function"),
};
let predicates = ty::lookup_predicates(tcx, did);
@ -204,7 +204,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEn
let t = ty::lookup_item_type(tcx, did);
let predicates = ty::lookup_predicates(tcx, did);
match t.ty.sty {
ty::ty_enum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
ty::TyEnum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
return clean::EnumItem(clean::Enum {
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
variants_stripped: false,

View file

@ -579,7 +579,6 @@ impl<'tcx> Clean<(Vec<TyParamBound>, Vec<TypeBinding>)> for ty::ExistentialBound
fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
bindings: Vec<TypeBinding>, substs: &subst::Substs) -> PathParameters {
use rustc::middle::ty::sty;
let lifetimes = substs.regions().get_slice(subst::TypeSpace)
.iter()
.filter_map(|v| v.clean(cx))
@ -591,7 +590,7 @@ fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
(Some(did), Some(ref tcx)) if tcx.lang_items.fn_trait_kind(did).is_some() => {
assert_eq!(types.len(), 1);
let inputs = match types[0].sty {
sty::ty_tup(ref tys) => tys.iter().map(|t| t.clean(cx)).collect(),
ty::TyTuple(ref tys) => tys.iter().map(|t| t.clean(cx)).collect(),
_ => {
return PathParameters::AngleBracketed {
lifetimes: lifetimes,
@ -603,7 +602,7 @@ fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
let output = None;
// FIXME(#20299) return type comes from a projection now
// match types[1].sty {
// sty::ty_tup(ref v) if v.is_empty() => None, // -> ()
// ty::TyTuple(ref v) if v.is_empty() => None, // -> ()
// _ => Some(types[1].clean(cx))
// };
PathParameters::Parenthesized {
@ -691,11 +690,10 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
// collect any late bound regions
let mut late_bounds = vec![];
for &ty_s in self.substs.types.get_slice(ParamSpace::TypeSpace) {
use rustc::middle::ty::{Region, sty};
if let sty::ty_tup(ref ts) = ty_s.sty {
if let ty::TyTuple(ref ts) = ty_s.sty {
for &ty_s in ts {
if let sty::ty_rptr(ref reg, _) = ty_s.sty {
if let &Region::ReLateBound(_, _) = *reg {
if let ty::TyRef(ref reg, _) = ty_s.sty {
if let &ty::Region::ReLateBound(_, _) = *reg {
debug!(" hit an ReLateBound {:?}", reg);
if let Some(lt) = reg.clean(cx) {
late_bounds.push(lt)
@ -1326,7 +1324,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
ty::ByValueExplicitSelfCategory => SelfValue,
ty::ByReferenceExplicitSelfCategory(..) => {
match self.fty.sig.0.inputs[0].sty {
ty::ty_rptr(r, mt) => {
ty::TyRef(r, mt) => {
SelfBorrowed(r.clean(cx), mt.mutbl.clean(cx))
}
_ => unreachable!(),
@ -1633,37 +1631,37 @@ impl Clean<Type> for ast::Ty {
impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
fn clean(&self, cx: &DocContext) -> Type {
match self.sty {
ty::ty_bool => Primitive(Bool),
ty::ty_char => Primitive(Char),
ty::ty_int(ast::TyIs) => Primitive(Isize),
ty::ty_int(ast::TyI8) => Primitive(I8),
ty::ty_int(ast::TyI16) => Primitive(I16),
ty::ty_int(ast::TyI32) => Primitive(I32),
ty::ty_int(ast::TyI64) => Primitive(I64),
ty::ty_uint(ast::TyUs) => Primitive(Usize),
ty::ty_uint(ast::TyU8) => Primitive(U8),
ty::ty_uint(ast::TyU16) => Primitive(U16),
ty::ty_uint(ast::TyU32) => Primitive(U32),
ty::ty_uint(ast::TyU64) => Primitive(U64),
ty::ty_float(ast::TyF32) => Primitive(F32),
ty::ty_float(ast::TyF64) => Primitive(F64),
ty::ty_str => Primitive(Str),
ty::ty_uniq(t) => {
ty::TyBool => Primitive(Bool),
ty::TyChar => Primitive(Char),
ty::TyInt(ast::TyIs) => Primitive(Isize),
ty::TyInt(ast::TyI8) => Primitive(I8),
ty::TyInt(ast::TyI16) => Primitive(I16),
ty::TyInt(ast::TyI32) => Primitive(I32),
ty::TyInt(ast::TyI64) => Primitive(I64),
ty::TyUint(ast::TyUs) => Primitive(Usize),
ty::TyUint(ast::TyU8) => Primitive(U8),
ty::TyUint(ast::TyU16) => Primitive(U16),
ty::TyUint(ast::TyU32) => Primitive(U32),
ty::TyUint(ast::TyU64) => Primitive(U64),
ty::TyFloat(ast::TyF32) => Primitive(F32),
ty::TyFloat(ast::TyF64) => Primitive(F64),
ty::TyStr => Primitive(Str),
ty::TyBox(t) => {
let box_did = cx.tcx_opt().and_then(|tcx| {
tcx.lang_items.owned_box()
});
lang_struct(cx, box_did, t, "Box", Unique)
}
ty::ty_vec(ty, None) => Vector(box ty.clean(cx)),
ty::ty_vec(ty, Some(i)) => FixedVector(box ty.clean(cx),
ty::TyArray(ty, None) => Vector(box ty.clean(cx)),
ty::TyArray(ty, Some(i)) => FixedVector(box ty.clean(cx),
format!("{}", i)),
ty::ty_ptr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
ty::ty_rptr(r, mt) => BorrowedRef {
ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
ty::TyRef(r, mt) => BorrowedRef {
lifetime: r.clean(cx),
mutability: mt.mutbl.clean(cx),
type_: box mt.ty.clean(cx),
},
ty::ty_bare_fn(_, ref fty) => BareFunction(box BareFunctionDecl {
ty::TyBareFn(_, ref fty) => BareFunction(box BareFunctionDecl {
unsafety: fty.unsafety,
generics: Generics {
lifetimes: Vec::new(),
@ -1673,12 +1671,12 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
decl: (ast_util::local_def(0), &fty.sig).clean(cx),
abi: fty.abi.to_string(),
}),
ty::ty_struct(did, substs) |
ty::ty_enum(did, substs) => {
ty::TyStruct(did, substs) |
ty::TyEnum(did, substs) => {
let fqn = csearch::get_item_path(cx.tcx(), did);
let fqn: Vec<_> = fqn.into_iter().map(|i| i.to_string()).collect();
let kind = match self.sty {
ty::ty_struct(..) => TypeStruct,
ty::TyStruct(..) => TypeStruct,
_ => TypeEnum,
};
let path = external_path(cx, &fqn.last().unwrap().to_string(),
@ -1691,7 +1689,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
is_generic: false,
}
}
ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
ty::TyTrait(box ty::TraitTy { ref principal, ref bounds }) => {
let did = principal.def_id();
let fqn = csearch::get_item_path(cx.tcx(), did);
let fqn: Vec<_> = fqn.into_iter().map(|i| i.to_string()).collect();
@ -1706,16 +1704,16 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
is_generic: false,
}
}
ty::ty_tup(ref t) => Tuple(t.clean(cx)),
ty::TyTuple(ref t) => Tuple(t.clean(cx)),
ty::ty_projection(ref data) => data.clean(cx),
ty::TyProjection(ref data) => data.clean(cx),
ty::ty_param(ref p) => Generic(token::get_name(p.name).to_string()),
ty::TyParam(ref p) => Generic(token::get_name(p.name).to_string()),
ty::ty_closure(..) => Tuple(vec![]), // FIXME(pcwalton)
ty::TyClosure(..) => Tuple(vec![]), // FIXME(pcwalton)
ty::ty_infer(..) => panic!("ty_infer"),
ty::ty_err => panic!("ty_err"),
ty::TyInfer(..) => panic!("TyInfer"),
ty::TyError => panic!("TyError"),
}
}
}

View file

@ -34,54 +34,54 @@ pub mod testtypes {
// Skipping ty_bot
// Tests ty_bool
// Tests TyBool
pub type FooBool = bool;
// Tests ty_char
// Tests TyChar
pub type FooChar = char;
// Tests ty_int (does not test all variants of IntTy)
// Tests TyInt (does not test all variants of IntTy)
pub type FooInt = isize;
// Tests ty_uint (does not test all variants of UintTy)
// Tests TyUint (does not test all variants of UintTy)
pub type FooUint = usize;
// Tests ty_float (does not test all variants of FloatTy)
// Tests TyFloat (does not test all variants of FloatTy)
pub type FooFloat = f64;
// For ty_str, what kind of string should I use? &'static str? String? Raw str?
// For TyStr, what kind of string should I use? &'static str? String? Raw str?
// Tests ty_enum
// Tests TyEnum
pub enum FooEnum {
VarA(usize),
VarB(usize, usize)
}
// Tests ty_uniq (of u8)
// Tests TyBox (of u8)
pub type FooUniq = Box<u8>;
// As with ty_str, what type should be used for ty_vec?
// As with TyStr, what type should be used for TyArray?
// Tests ty_ptr
// Tests TyRawPtr
pub type FooPtr = *const u8;
// Skipping ty_rptr
// Skipping TyRef
// Skipping ty_bare_fn (how do you get a bare function type, rather than proc or closure?)
// Skipping TyBareFn (how do you get a bare function type, rather than proc or closure?)
// Tests ty_trait
// Tests TyTrait
pub trait FooTrait {
fn foo_method(&self) -> usize;
fn foo_static_method() -> usize;
}
// Tests ty_struct
// Tests TyStruct
pub struct FooStruct {
pub pub_foo_field: usize,
foo_field: usize
}
// Tests ty_tup
// Tests TyTuple
pub type FooTuple = (u8, i8, bool);
// Skipping ty_param
@ -90,7 +90,7 @@ pub mod testtypes {
// Skipping ty_self
// Skipping ty_infer
// Skipping TyInfer
// Skipping ty_err
// Skipping TyError
}

View file

@ -12,7 +12,7 @@
//
// error: internal compiler error: get_unique_type_id_of_type() -
// unexpected type: closure,
// ty_closure(syntax::ast::DefId{krate: 0, node: 66},
// TyClosure(syntax::ast::DefId{krate: 0, node: 66},
// ReScope(63))
//
// This is a regression test for issue #17021.