Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
44 changes: 22 additions & 22 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"),
Expand All @@ -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"),
Expand All @@ -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, "/");
Expand All @@ -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");
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/middle/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(_) => {}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
_ => {}
}
}
Expand Down
42 changes: 21 additions & 21 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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()),
Expand All @@ -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);
Expand All @@ -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![])
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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
}
}
Expand Down
Loading