Skip to content

Commit adcae00

Browse files
committed
Auto merge of #26895 - jroesch:modernize-typeck-names, r=nikomatsakis
This PR modernizes some names in the type checker. The only remaining snake_case name in ty.rs is `ctxt` which should be resolved by @eddyb's pending refactor. We can bike shed over the names, it would just be nice to bring the type checker inline with modern Rust. r? @eddyb cc @nikomatsakis
2 parents 50d305e + 19218ee commit adcae00

Some content is hidden

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

48 files changed

+316
-312
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub fn get_item_attrs(cstore: &cstore::CStore,
197197

198198
pub fn get_struct_fields(cstore: &cstore::CStore,
199199
def: ast::DefId)
200-
-> Vec<ty::field_ty> {
200+
-> Vec<ty::FieldTy> {
201201
let cdata = cstore.get_crate_data(def.krate);
202202
decoder::get_struct_fields(cstore.intr.clone(), &*cdata, def.node)
203203
}

src/librustc/metadata/decoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ fn struct_field_family_to_visibility(family: Family) -> ast::Visibility {
10491049
}
10501050

10511051
pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
1052-
-> Vec<ty::field_ty> {
1052+
-> Vec<ty::FieldTy> {
10531053
let data = cdata.data();
10541054
let item = lookup_item(id, data);
10551055
reader::tagged_docs(item, tag_item_field).filter_map(|an_item| {
@@ -1059,7 +1059,7 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
10591059
let did = item_def_id(an_item, cdata);
10601060
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
10611061
let origin_id = translated_def_id(cdata, tagdoc);
1062-
Some(ty::field_ty {
1062+
Some(ty::FieldTy {
10631063
name: name,
10641064
id: did,
10651065
vis: struct_field_family_to_visibility(f),
@@ -1073,7 +1073,7 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
10731073
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
10741074
let f = item_family(an_item);
10751075
let origin_id = translated_def_id(cdata, tagdoc);
1076-
ty::field_ty {
1076+
ty::FieldTy {
10771077
name: special_idents::unnamed_field.name,
10781078
id: did,
10791079
vis: struct_field_family_to_visibility(f),

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn encode_parent_item(rbml_w: &mut Encoder, id: DefId) {
267267
}
268268

269269
fn encode_struct_fields(rbml_w: &mut Encoder,
270-
fields: &[ty::field_ty],
270+
fields: &[ty::FieldTy],
271271
origin: DefId) {
272272
for f in fields {
273273
if f.name == special_idents::unnamed_field.name {
@@ -636,7 +636,7 @@ fn encode_provided_source(rbml_w: &mut Encoder,
636636
/* Returns an index of items in this class */
637637
fn encode_info_for_struct(ecx: &EncodeContext,
638638
rbml_w: &mut Encoder,
639-
fields: &[ty::field_ty],
639+
fields: &[ty::FieldTy],
640640
global_index: &mut Vec<entry<i64>>)
641641
-> Vec<entry<i64>> {
642642
/* Each class has its own index, since different classes

src/librustc/metadata/tydecode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
525525
assert_eq!(next(st), ':');
526526
let len = parse_hex(st);
527527
assert_eq!(next(st), '#');
528-
let key = ty::creader_cache_key {cnum: st.krate,
528+
let key = ty::CReaderCacheKey {cnum: st.krate,
529529
pos: pos,
530530
len: len };
531531

@@ -587,11 +587,11 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
587587
}
588588
}
589589

590-
fn parse_mt_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> ty::mt<'tcx> where
590+
fn parse_mt_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> ty::TypeAndMut<'tcx> where
591591
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
592592
{
593593
let m = parse_mutability(st);
594-
ty::mt { ty: parse_ty_(st, conv), mutbl: m }
594+
ty::TypeAndMut { ty: parse_ty_(st, conv), mutbl: m }
595595
}
596596

597597
fn parse_def_<F>(st: &mut PState, source: DefIdSource, conv: &mut F) -> ast::DefId where

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn enc_mutability(w: &mut Encoder, mt: ast::Mutability) {
183183
}
184184

185185
fn enc_mt<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
186-
mt: ty::mt<'tcx>) {
186+
mt: ty::TypeAndMut<'tcx>) {
187187
enc_mutability(w, mt.mutbl);
188188
enc_ty(w, cx, mt.ty);
189189
}

src/librustc/middle/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub enum CastTy<'tcx> {
3636
/// Function Pointers
3737
FnPtr,
3838
/// Raw pointers
39-
Ptr(&'tcx ty::mt<'tcx>),
39+
Ptr(&'tcx ty::TypeAndMut<'tcx>),
4040
/// References
41-
RPtr(&'tcx ty::mt<'tcx>),
41+
RPtr(&'tcx ty::TypeAndMut<'tcx>),
4242
}
4343

4444
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
535535
}
536536
}
537537

538-
ty::TyRef(_, ty::mt { ty, mutbl }) => {
538+
ty::TyRef(_, ty::TypeAndMut { ty, mutbl }) => {
539539
match ty.sty {
540540
ty::TyArray(_, n) => match ctor {
541541
&Single => {
@@ -600,7 +600,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
600600
ty::TyBool =>
601601
[true, false].iter().map(|b| ConstantValue(ConstVal::Bool(*b))).collect(),
602602

603-
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
603+
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
604604
ty::TySlice(_) =>
605605
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
606606
_ => vec!(Single)
@@ -808,7 +808,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
808808
match ty.sty {
809809
ty::TyTuple(ref fs) => fs.len(),
810810
ty::TyBox(_) => 1,
811-
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
811+
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
812812
ty::TySlice(_) => match *ctor {
813813
Slice(length) => length,
814814
ConstantValue(_) => 0,

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
720720
// are properly handled.
721721
self.walk_expr(with_expr);
722722

723-
fn contains_field_named(field: &ty::field,
723+
fn contains_field_named(field: &ty::Field,
724724
fields: &Vec<ast::Field>)
725725
-> bool
726726
{

src/librustc/middle/implicator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
115115

116116
ty::TyArray(t, _) |
117117
ty::TySlice(t) |
118-
ty::TyRawPtr(ty::mt { ty: t, .. }) |
118+
ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) |
119119
ty::TyBox(t) => {
120120
self.accumulate_from_ty(t)
121121
}

src/librustc/middle/infer/combine.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf};
4343

4444
use middle::ty::{TyVar};
4545
use middle::ty::{IntType, UintType};
46-
use middle::ty::{self, Ty};
46+
use middle::ty::{self, Ty, TypeError};
4747
use middle::ty_fold;
4848
use middle::ty_fold::{TypeFolder, TypeFoldable};
4949
use middle::ty_relate::{self, Relate, RelateResult, TypeRelation};
@@ -108,7 +108,7 @@ pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>,
108108
// All other cases of inference are errors
109109
(&ty::TyInfer(_), _) |
110110
(_, &ty::TyInfer(_)) => {
111-
Err(ty::terr_sorts(ty_relate::expected_found(relation, &a, &b)))
111+
Err(TypeError::Sorts(ty_relate::expected_found(relation, &a, &b)))
112112
}
113113

114114

@@ -278,7 +278,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
278278
};
279279
let u = ty.fold_with(&mut generalize);
280280
if generalize.cycle_detected {
281-
Err(ty::terr_cyclic_ty)
281+
Err(TypeError::CyclicTy)
282282
} else {
283283
Ok(u)
284284
}
@@ -363,12 +363,12 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
363363

364364
pub trait RelateResultCompare<'tcx, T> {
365365
fn compare<F>(&self, t: T, f: F) -> RelateResult<'tcx, T> where
366-
F: FnOnce() -> ty::type_err<'tcx>;
366+
F: FnOnce() -> ty::TypeError<'tcx>;
367367
}
368368

369369
impl<'tcx, T:Clone + PartialEq> RelateResultCompare<'tcx, T> for RelateResult<'tcx, T> {
370370
fn compare<F>(&self, t: T, f: F) -> RelateResult<'tcx, T> where
371-
F: FnOnce() -> ty::type_err<'tcx>,
371+
F: FnOnce() -> ty::TypeError<'tcx>,
372372
{
373373
self.clone().and_then(|s| {
374374
if s == t {
@@ -381,16 +381,16 @@ impl<'tcx, T:Clone + PartialEq> RelateResultCompare<'tcx, T> for RelateResult<'t
381381
}
382382

383383
fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::IntVarValue))
384-
-> ty::type_err<'tcx>
384+
-> ty::TypeError<'tcx>
385385
{
386386
let (a, b) = v;
387-
ty::terr_int_mismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
387+
TypeError::IntMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
388388
}
389389

390390
fn float_unification_error<'tcx>(a_is_expected: bool,
391391
v: (ast::FloatTy, ast::FloatTy))
392-
-> ty::type_err<'tcx>
392+
-> ty::TypeError<'tcx>
393393
{
394394
let (a, b) = v;
395-
ty::terr_float_mismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
395+
TypeError::FloatMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
396396
}

0 commit comments

Comments
 (0)