Skip to content

Modernize type names in the compiler #26895

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 4 commits into from
Jul 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/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub fn get_item_attrs(cstore: &cstore::CStore,

pub fn get_struct_fields(cstore: &cstore::CStore,
def: ast::DefId)
-> Vec<ty::field_ty> {
-> Vec<ty::FieldTy> {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_struct_fields(cstore.intr.clone(), &*cdata, def.node)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ fn struct_field_family_to_visibility(family: Family) -> ast::Visibility {
}

pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
-> Vec<ty::field_ty> {
-> Vec<ty::FieldTy> {
let data = cdata.data();
let item = lookup_item(id, data);
reader::tagged_docs(item, tag_item_field).filter_map(|an_item| {
Expand All @@ -1059,7 +1059,7 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
let did = item_def_id(an_item, cdata);
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
let origin_id = translated_def_id(cdata, tagdoc);
Some(ty::field_ty {
Some(ty::FieldTy {
name: name,
id: did,
vis: struct_field_family_to_visibility(f),
Expand All @@ -1073,7 +1073,7 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
let f = item_family(an_item);
let origin_id = translated_def_id(cdata, tagdoc);
ty::field_ty {
ty::FieldTy {
name: special_idents::unnamed_field.name,
id: did,
vis: struct_field_family_to_visibility(f),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn encode_parent_item(rbml_w: &mut Encoder, id: DefId) {
}

fn encode_struct_fields(rbml_w: &mut Encoder,
fields: &[ty::field_ty],
fields: &[ty::FieldTy],
origin: DefId) {
for f in fields {
if f.name == special_idents::unnamed_field.name {
Expand Down Expand Up @@ -636,7 +636,7 @@ fn encode_provided_source(rbml_w: &mut Encoder,
/* Returns an index of items in this class */
fn encode_info_for_struct(ecx: &EncodeContext,
rbml_w: &mut Encoder,
fields: &[ty::field_ty],
fields: &[ty::FieldTy],
global_index: &mut Vec<entry<i64>>)
-> Vec<entry<i64>> {
/* Each class has its own index, since different classes
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
assert_eq!(next(st), ':');
let len = parse_hex(st);
assert_eq!(next(st), '#');
let key = ty::creader_cache_key {cnum: st.krate,
let key = ty::CReaderCacheKey {cnum: st.krate,
pos: pos,
len: len };

Expand Down Expand Up @@ -587,11 +587,11 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
}
}

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

fn parse_def_<F>(st: &mut PState, source: DefIdSource, conv: &mut F) -> ast::DefId where
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fn enc_mutability(w: &mut Encoder, mt: ast::Mutability) {
}

fn enc_mt<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
mt: ty::mt<'tcx>) {
mt: ty::TypeAndMut<'tcx>) {
enc_mutability(w, mt.mutbl);
enc_ty(w, cx, mt.ty);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub enum CastTy<'tcx> {
/// Function Pointers
FnPtr,
/// Raw pointers
Ptr(&'tcx ty::mt<'tcx>),
Ptr(&'tcx ty::TypeAndMut<'tcx>),
/// References
RPtr(&'tcx ty::mt<'tcx>),
RPtr(&'tcx ty::TypeAndMut<'tcx>),
}

/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
}

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

ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
ty::TySlice(_) =>
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
_ => vec!(Single)
Expand Down Expand Up @@ -808,7 +808,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
match ty.sty {
ty::TyTuple(ref fs) => fs.len(),
ty::TyBox(_) => 1,
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) => match ty.sty {
ty::TySlice(_) => match *ctor {
Slice(length) => length,
ConstantValue(_) => 0,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
// are properly handled.
self.walk_expr(with_expr);

fn contains_field_named(field: &ty::field,
fn contains_field_named(field: &ty::Field,
fields: &Vec<ast::Field>)
-> bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/implicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {

ty::TyArray(t, _) |
ty::TySlice(t) |
ty::TyRawPtr(ty::mt { ty: t, .. }) |
ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) |
ty::TyBox(t) => {
self.accumulate_from_ty(t)
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/middle/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf};

use middle::ty::{TyVar};
use middle::ty::{IntType, UintType};
use middle::ty::{self, Ty};
use middle::ty::{self, Ty, TypeError};
use middle::ty_fold;
use middle::ty_fold::{TypeFolder, TypeFoldable};
use middle::ty_relate::{self, Relate, RelateResult, TypeRelation};
Expand Down Expand Up @@ -108,7 +108,7 @@ pub fn super_combine_tys<'a,'tcx:'a,R>(infcx: &InferCtxt<'a, 'tcx>,
// All other cases of inference are errors
(&ty::TyInfer(_), _) |
(_, &ty::TyInfer(_)) => {
Err(ty::terr_sorts(ty_relate::expected_found(relation, &a, &b)))
Err(TypeError::Sorts(ty_relate::expected_found(relation, &a, &b)))
}


Expand Down Expand Up @@ -278,7 +278,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
};
let u = ty.fold_with(&mut generalize);
if generalize.cycle_detected {
Err(ty::terr_cyclic_ty)
Err(TypeError::CyclicTy)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to ask for this, but I'd rather have ty::TypeError::CyclicTy (i.e., not pub use all the names from the enum)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wanted to do it, but wasn't sure how much pain it was to fix. I'll bite the bullet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you be okay with just TypeError::Variant? I think it is slightly less verbose and just as clear.

} else {
Ok(u)
}
Expand Down Expand Up @@ -363,12 +363,12 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {

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

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

fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::IntVarValue))
-> ty::type_err<'tcx>
-> ty::TypeError<'tcx>
{
let (a, b) = v;
ty::terr_int_mismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
TypeError::IntMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
}

fn float_unification_error<'tcx>(a_is_expected: bool,
v: (ast::FloatTy, ast::FloatTy))
-> ty::type_err<'tcx>
-> ty::TypeError<'tcx>
{
let (a, b) = v;
ty::terr_float_mismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
TypeError::FloatMismatch(ty_relate::expected_found_bool(a_is_expected, &a, &b))
}
24 changes: 12 additions & 12 deletions src/librustc/middle/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use middle::def;
use middle::infer;
use middle::region;
use middle::subst;
use middle::ty::{self, Ty, HasTypeFlags};
use middle::ty::{self, Ty, TypeError, HasTypeFlags};
use middle::ty::{Region, ReFree};

use std::cell::{Cell, RefCell};
Expand Down Expand Up @@ -220,17 +220,17 @@ pub trait ErrorReporting<'tcx> {
fn process_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>)
-> Vec<RegionResolutionError<'tcx>>;

fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>);
fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::TypeError<'tcx>);

fn report_and_explain_type_error(&self,
trace: TypeTrace<'tcx>,
terr: &ty::type_err<'tcx>);
terr: &ty::TypeError<'tcx>);

fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String>;

fn expected_found_str<T: fmt::Display + Resolvable<'tcx> + HasTypeFlags>(
&self,
exp_found: &ty::expected_found<T>)
exp_found: &ty::ExpectedFound<T>)
-> Option<String>;

fn report_concrete_failure(&self,
Expand Down Expand Up @@ -260,7 +260,7 @@ pub trait ErrorReporting<'tcx> {

fn report_processed_errors(&self,
var_origin: &[RegionVariableOrigin],
trace_origin: &[(TypeTrace<'tcx>, ty::type_err<'tcx>)],
trace_origin: &[(TypeTrace<'tcx>, ty::TypeError<'tcx>)],
same_regions: &[SameRegions]);

fn give_suggestion(&self, same_regions: &[SameRegions]);
Expand Down Expand Up @@ -351,8 +351,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
match free_regions_from_same_fn(self.tcx, sub, sup) {
Some(ref same_frs) if trace.is_some() => {
let trace = trace.unwrap();
let terr = ty::terr_regions_does_not_outlive(sup,
sub);
let terr = TypeError::RegionsDoesNotOutlive(sup,
sub);
trace_origins.push((trace, terr));
append_to_same_regions(&mut same_regions, same_frs);
}
Expand Down Expand Up @@ -467,7 +467,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
}
}

fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>) {
fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::TypeError<'tcx>) {
let expected_found_str = match self.values_str(&trace.values) {
Some(v) => v,
None => {
Expand All @@ -490,7 +490,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {

fn report_and_explain_type_error(&self,
trace: TypeTrace<'tcx>,
terr: &ty::type_err<'tcx>) {
terr: &ty::TypeError<'tcx>) {
let span = trace.origin.span();
self.report_type_error(trace, terr);
self.tcx.note_and_explain_type_err(terr, span);
Expand All @@ -508,7 +508,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {

fn expected_found_str<T: fmt::Display + Resolvable<'tcx> + HasTypeFlags>(
&self,
exp_found: &ty::expected_found<T>)
exp_found: &ty::ExpectedFound<T>)
-> Option<String>
{
let expected = exp_found.expected.resolve(self);
Expand Down Expand Up @@ -595,7 +595,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
match origin {
infer::Subtype(trace) |
infer::DefaultExistentialBound(trace) => {
let terr = ty::terr_regions_does_not_outlive(sup, sub);
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
self.report_and_explain_type_error(trace, &terr);
}
infer::Reborrow(span) => {
Expand Down Expand Up @@ -888,7 +888,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {

fn report_processed_errors(&self,
var_origins: &[RegionVariableOrigin],
trace_origins: &[(TypeTrace<'tcx>, ty::type_err<'tcx>)],
trace_origins: &[(TypeTrace<'tcx>, ty::TypeError<'tcx>)],
same_regions: &[SameRegions]) {
for vo in var_origins {
self.report_inference_failure(vo.clone());
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/infer/higher_ranked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::{CombinedSnapshot, InferCtxt, HigherRankedType, SkolemizationMap};
use super::combine::CombineFields;

use middle::subst;
use middle::ty::{self, Binder};
use middle::ty::{self, TypeError, Binder};
use middle::ty_fold::{self, TypeFoldable};
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
use syntax::codemap::Span;
Expand Down Expand Up @@ -85,11 +85,11 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
Err((skol_br, tainted_region)) => {
if self.a_is_expected {
debug!("Not as polymorphic!");
return Err(ty::terr_regions_insufficiently_polymorphic(skol_br,
return Err(TypeError::RegionsInsufficientlyPolymorphic(skol_br,
tainted_region));
} else {
debug!("Overly polymorphic!");
return Err(ty::terr_regions_overly_polymorphic(skol_br,
return Err(TypeError::RegionsOverlyPolymorphic(skol_br,
tainted_region));
}
}
Expand Down
Loading