Skip to content

Commit f4bdebf

Browse files
committed
Auto merge of #26232 - eefriedman:rename-sty, r=nrc
Use camel-case naming, and use names which actually make sense in modern Rust.
2 parents a2f2a64 + 00f86fe commit f4bdebf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1384
-1335
lines changed

src/librustc/metadata/decoder.rs

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

src/librustc/metadata/tydecode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::abi;
2828
use syntax::ast;
2929
use syntax::parse::token;
3030

31-
// Compact string representation for Ty values. API ty_str &
31+
// Compact string representation for Ty values. API TyStr &
3232
// parse_from_str. Extra parameters are for converting to/from def_ids in the
3333
// data buffer. Whatever format you choose should not contain pipe characters.
3434

src/librustc/metadata/tyencode.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct ctxt<'a, 'tcx: 'a> {
4141
pub abbrevs: &'a abbrev_map<'tcx>
4242
}
4343

44-
// Compact string representation for Ty values. API ty_str & parse_from_str.
44+
// Compact string representation for Ty values. API TyStr & parse_from_str.
4545
// Extra parameters are for converting to/from def_ids in the string rep.
4646
// Whatever format you choose should not contain pipe characters.
4747
pub struct ty_abbrev {
@@ -60,9 +60,9 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
6060
let pos = w.mark_stable_position();
6161

6262
match t.sty {
63-
ty::ty_bool => mywrite!(w, "b"),
64-
ty::ty_char => mywrite!(w, "c"),
65-
ty::ty_int(t) => {
63+
ty::TyBool => mywrite!(w, "b"),
64+
ty::TyChar => mywrite!(w, "c"),
65+
ty::TyInt(t) => {
6666
match t {
6767
ast::TyIs => mywrite!(w, "is"),
6868
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>) {
7171
ast::TyI64 => mywrite!(w, "MD")
7272
}
7373
}
74-
ty::ty_uint(t) => {
74+
ty::TyUint(t) => {
7575
match t {
7676
ast::TyUs => mywrite!(w, "us"),
7777
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>) {
8080
ast::TyU64 => mywrite!(w, "Md")
8181
}
8282
}
83-
ty::ty_float(t) => {
83+
ty::TyFloat(t) => {
8484
match t {
8585
ast::TyF32 => mywrite!(w, "Mf"),
8686
ast::TyF64 => mywrite!(w, "MF"),
8787
}
8888
}
89-
ty::ty_enum(def, substs) => {
89+
ty::TyEnum(def, substs) => {
9090
mywrite!(w, "t[{}|", (cx.ds)(def));
9191
enc_substs(w, cx, substs);
9292
mywrite!(w, "]");
9393
}
94-
ty::ty_trait(box ty::TyTrait { ref principal,
94+
ty::TyTrait(box ty::TraitTy { ref principal,
9595
ref bounds }) => {
9696
mywrite!(w, "x[");
9797
enc_trait_ref(w, cx, principal.0);
9898
enc_existential_bounds(w, cx, bounds);
9999
mywrite!(w, "]");
100100
}
101-
ty::ty_tup(ref ts) => {
101+
ty::TyTuple(ref ts) => {
102102
mywrite!(w, "T[");
103103
for t in ts { enc_ty(w, cx, *t); }
104104
mywrite!(w, "]");
105105
}
106-
ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
107-
ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
108-
ty::ty_rptr(r, mt) => {
106+
ty::TyBox(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
107+
ty::TyRawPtr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
108+
ty::TyRef(r, mt) => {
109109
mywrite!(w, "&");
110110
enc_region(w, cx, *r);
111111
enc_mt(w, cx, mt);
112112
}
113-
ty::ty_vec(t, sz) => {
113+
ty::TyArray(t, sz) => {
114114
mywrite!(w, "V");
115115
enc_ty(w, cx, t);
116116
mywrite!(w, "/");
@@ -119,40 +119,40 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
119119
None => mywrite!(w, "|"),
120120
}
121121
}
122-
ty::ty_str => {
122+
ty::TyStr => {
123123
mywrite!(w, "v");
124124
}
125-
ty::ty_bare_fn(Some(def_id), f) => {
125+
ty::TyBareFn(Some(def_id), f) => {
126126
mywrite!(w, "F");
127127
mywrite!(w, "{}|", (cx.ds)(def_id));
128128
enc_bare_fn_ty(w, cx, f);
129129
}
130-
ty::ty_bare_fn(None, f) => {
130+
ty::TyBareFn(None, f) => {
131131
mywrite!(w, "G");
132132
enc_bare_fn_ty(w, cx, f);
133133
}
134-
ty::ty_infer(_) => {
134+
ty::TyInfer(_) => {
135135
cx.diag.handler().bug("cannot encode inference variable types");
136136
}
137-
ty::ty_param(ParamTy {space, idx, name}) => {
137+
ty::TyParam(ParamTy {space, idx, name}) => {
138138
mywrite!(w, "p[{}|{}|{}]", idx, space.to_uint(), token::get_name(name))
139139
}
140-
ty::ty_struct(def, substs) => {
140+
ty::TyStruct(def, substs) => {
141141
mywrite!(w, "a[{}|", (cx.ds)(def));
142142
enc_substs(w, cx, substs);
143143
mywrite!(w, "]");
144144
}
145-
ty::ty_closure(def, substs) => {
145+
ty::TyClosure(def, substs) => {
146146
mywrite!(w, "k[{}|", (cx.ds)(def));
147147
enc_substs(w, cx, substs);
148148
mywrite!(w, "]");
149149
}
150-
ty::ty_projection(ref data) => {
150+
ty::TyProjection(ref data) => {
151151
mywrite!(w, "P[");
152152
enc_trait_ref(w, cx, data.trait_ref);
153153
mywrite!(w, "{}]", token::get_name(data.item_name));
154154
}
155-
ty::ty_err => {
155+
ty::TyError => {
156156
mywrite!(w, "e");
157157
}
158158
}

src/librustc/middle/cast.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ impl<'tcx> CastTy<'tcx> {
6161
pub fn from_ty(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>)
6262
-> Option<CastTy<'tcx>> {
6363
match t.sty {
64-
ty::ty_bool => Some(CastTy::Int(IntTy::Bool)),
65-
ty::ty_char => Some(CastTy::Int(IntTy::Char)),
66-
ty::ty_int(_) => Some(CastTy::Int(IntTy::I)),
67-
ty::ty_uint(u) => Some(CastTy::Int(IntTy::U(u))),
68-
ty::ty_float(_) => Some(CastTy::Float),
69-
ty::ty_enum(..) if ty::type_is_c_like_enum(
64+
ty::TyBool => Some(CastTy::Int(IntTy::Bool)),
65+
ty::TyChar => Some(CastTy::Int(IntTy::Char)),
66+
ty::TyInt(_) => Some(CastTy::Int(IntTy::I)),
67+
ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))),
68+
ty::TyFloat(_) => Some(CastTy::Float),
69+
ty::TyEnum(..) if ty::type_is_c_like_enum(
7070
tcx, t) => Some(CastTy::Int(IntTy::CEnum)),
71-
ty::ty_ptr(ref mt) => Some(CastTy::Ptr(mt)),
72-
ty::ty_rptr(_, ref mt) => Some(CastTy::RPtr(mt)),
73-
ty::ty_bare_fn(..) => Some(CastTy::FnPtr),
71+
ty::TyRawPtr(ref mt) => Some(CastTy::Ptr(mt)),
72+
ty::TyRef(_, ref mt) => Some(CastTy::RPtr(mt)),
73+
ty::TyBareFn(..) => Some(CastTy::FnPtr),
7474
_ => None,
7575
}
7676
}

src/librustc/middle/check_const.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
423423
self.visit_expr(&**element);
424424
// The count is checked elsewhere (typeck).
425425
let count = match node_ty.sty {
426-
ty::ty_vec(_, Some(n)) => n,
426+
ty::TyArray(_, Some(n)) => n,
427427
_ => unreachable!()
428428
};
429429
// [element; 0] is always zero-sized.
@@ -454,7 +454,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
454454
visit::walk_expr(self, ex);
455455
let div_or_rem = op.node == ast::BiDiv || op.node == ast::BiRem;
456456
match node_ty.sty {
457-
ty::ty_uint(_) | ty::ty_int(_) if div_or_rem => {
457+
ty::TyUint(_) | ty::TyInt(_) if div_or_rem => {
458458
if !self.qualif.intersects(ConstQualif::NOT_CONST) {
459459
match const_eval::eval_const_expr_partial(self.tcx, ex, None) {
460460
Ok(_) => {}
@@ -529,8 +529,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
529529
fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
530530
e: &ast::Expr, node_ty: Ty<'tcx>) {
531531
match node_ty.sty {
532-
ty::ty_struct(did, _) |
533-
ty::ty_enum(did, _) if ty::has_dtor(v.tcx, did) => {
532+
ty::TyStruct(did, _) |
533+
ty::TyEnum(did, _) if ty::has_dtor(v.tcx, did) => {
534534
v.add_qualif(ConstQualif::NEEDS_DROP);
535535
if v.mode != Mode::Var {
536536
v.tcx.sess.span_err(e.span,
@@ -562,7 +562,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
562562
}
563563
ast::ExprUnary(op, ref inner) => {
564564
match ty::node_id_to_type(v.tcx, inner.id).sty {
565-
ty::ty_ptr(_) => {
565+
ty::TyRawPtr(_) => {
566566
assert!(op == ast::UnDeref);
567567

568568
v.add_qualif(ConstQualif::NOT_CONST);
@@ -576,7 +576,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
576576
}
577577
ast::ExprBinary(op, ref lhs, _) => {
578578
match ty::node_id_to_type(v.tcx, lhs.id).sty {
579-
ty::ty_ptr(_) => {
579+
ty::TyRawPtr(_) => {
580580
assert!(op.node == ast::BiEq || op.node == ast::BiNe ||
581581
op.node == ast::BiLe || op.node == ast::BiLt ||
582582
op.node == ast::BiGe || op.node == ast::BiGt);
@@ -612,7 +612,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
612612
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
613613
}
614614
Some(def::DefStruct(_)) => {
615-
if let ty::ty_bare_fn(..) = node_ty.sty {
615+
if let ty::TyBareFn(..) = node_ty.sty {
616616
// Count the function pointer.
617617
v.add_qualif(ConstQualif::NON_ZERO_SIZED);
618618
}
@@ -854,7 +854,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'tcx> {
854854
// Mutable slices are the only `&mut` allowed in globals,
855855
// but only in `static mut`, nowhere else.
856856
match cmt.ty.sty {
857-
ty::ty_vec(_, _) => break,
857+
ty::TyArray(_, _) => break,
858858
_ => {}
859859
}
860860
}

src/librustc/middle/check_match.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
234234
match p.node {
235235
ast::PatIdent(ast::BindByValue(ast::MutImmutable), ident, None) => {
236236
let pat_ty = ty::pat_ty(cx.tcx, p);
237-
if let ty::ty_enum(def_id, _) = pat_ty.sty {
237+
if let ty::TyEnum(def_id, _) = pat_ty.sty {
238238
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
239239
if let Some(DefLocal(_)) = def {
240240
if ty::enum_variants(cx.tcx, def_id).iter().any(|variant|
@@ -506,9 +506,9 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
506506
let pats_len = pats.len();
507507
let mut pats = pats.into_iter().map(|p| P((*p).clone()));
508508
let pat = match left_ty.sty {
509-
ty::ty_tup(_) => ast::PatTup(pats.collect()),
509+
ty::TyTuple(_) => ast::PatTup(pats.collect()),
510510

511-
ty::ty_enum(cid, _) | ty::ty_struct(cid, _) => {
511+
ty::TyEnum(cid, _) | ty::TyStruct(cid, _) => {
512512
let (vid, is_structure) = match ctor {
513513
&Variant(vid) =>
514514
(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,
535535
}
536536
}
537537

538-
ty::ty_rptr(_, ty::mt { ty, mutbl }) => {
538+
ty::TyRef(_, ty::mt { ty, mutbl }) => {
539539
match ty.sty {
540-
ty::ty_vec(_, Some(n)) => match ctor {
540+
ty::TyArray(_, Some(n)) => match ctor {
541541
&Single => {
542542
assert_eq!(pats_len, n);
543543
ast::PatVec(pats.collect(), None, vec!())
544544
},
545545
_ => unreachable!()
546546
},
547-
ty::ty_vec(_, None) => match ctor {
547+
ty::TyArray(_, None) => match ctor {
548548
&Slice(n) => {
549549
assert_eq!(pats_len, n);
550550
ast::PatVec(pats.collect(), None, vec!())
551551
},
552552
_ => unreachable!()
553553
},
554-
ty::ty_str => ast::PatWild(ast::PatWildSingle),
554+
ty::TyStr => ast::PatWild(ast::PatWildSingle),
555555

556556
_ => {
557557
assert_eq!(pats_len, 1);
@@ -560,7 +560,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
560560
}
561561
}
562562

563-
ty::ty_vec(_, Some(len)) => {
563+
ty::TyArray(_, Some(len)) => {
564564
assert_eq!(pats_len, len);
565565
ast::PatVec(pats.collect(), None, vec![])
566566
}
@@ -597,16 +597,16 @@ fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix,
597597
fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
598598
max_slice_length: usize) -> Vec<Constructor> {
599599
match left_ty.sty {
600-
ty::ty_bool =>
600+
ty::TyBool =>
601601
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
602602

603-
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty.sty {
604-
ty::ty_vec(_, None) =>
603+
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
604+
ty::TyArray(_, None) =>
605605
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
606606
_ => vec!(Single)
607607
},
608608

609-
ty::ty_enum(eid, _) =>
609+
ty::TyEnum(eid, _) =>
610610
ty::enum_variants(cx.tcx, eid)
611611
.iter()
612612
.map(|va| Variant(va.id))
@@ -779,7 +779,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
779779
vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))),
780780
ast::PatVec(ref before, ref slice, ref after) =>
781781
match left_ty.sty {
782-
ty::ty_vec(_, Some(_)) => vec!(Single),
782+
ty::TyArray(_, Some(_)) => vec!(Single),
783783
_ => if slice.is_some() {
784784
range_inclusive(before.len() + after.len(), max_slice_length)
785785
.map(|length| Slice(length))
@@ -804,25 +804,25 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
804804
/// A struct pattern's arity is the number of fields it contains, etc.
805805
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usize {
806806
match ty.sty {
807-
ty::ty_tup(ref fs) => fs.len(),
808-
ty::ty_uniq(_) => 1,
809-
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty.sty {
810-
ty::ty_vec(_, None) => match *ctor {
807+
ty::TyTuple(ref fs) => fs.len(),
808+
ty::TyBox(_) => 1,
809+
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
810+
ty::TyArray(_, None) => match *ctor {
811811
Slice(length) => length,
812812
ConstantValue(_) => 0,
813813
_ => unreachable!()
814814
},
815-
ty::ty_str => 0,
815+
ty::TyStr => 0,
816816
_ => 1
817817
},
818-
ty::ty_enum(eid, _) => {
818+
ty::TyEnum(eid, _) => {
819819
match *ctor {
820820
Variant(id) => enum_variant_with_id(cx.tcx, eid, id).args.len(),
821821
_ => unreachable!()
822822
}
823823
}
824-
ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
825-
ty::ty_vec(_, Some(n)) => n,
824+
ty::TyStruct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
825+
ty::TyArray(_, Some(n)) => n,
826826
_ => 0
827827
}
828828
}

0 commit comments

Comments
 (0)