Skip to content

Commit

Permalink
Remove Ty prefix from Ty{Foreign|Param}
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Aug 22, 2018
1 parent 6f637da commit 04fa5d3
Show file tree
Hide file tree
Showing 68 changed files with 160 additions and 160 deletions.
12 changes: 6 additions & 6 deletions src/librustc/hir/def.rs
Expand Up @@ -53,13 +53,13 @@ pub enum Def {
Existential(DefId),
/// `type Foo = Bar;`
TyAlias(DefId),
TyForeign(DefId),
Foreign(DefId),
TraitAlias(DefId),
AssociatedTy(DefId),
/// `existential type Foo: Bar;`
AssociatedExistential(DefId),
PrimTy(hir::PrimTy),
TyParam(DefId),
Param(DefId),
SelfTy(Option<DefId> /* trait */, Option<DefId> /* impl */),
ToolMod, // e.g. `rustfmt` in `#[rustfmt::skip]`

Expand Down Expand Up @@ -269,10 +269,10 @@ impl Def {
Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) |
Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) |
Def::TyAlias(id) | Def::TraitAlias(id) |
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
Def::AssociatedTy(id) | Def::Param(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
Def::AssociatedConst(id) | Def::Macro(id, ..) |
Def::Existential(id) | Def::AssociatedExistential(id) | Def::TyForeign(id) => {
Def::Existential(id) | Def::AssociatedExistential(id) | Def::Foreign(id) => {
id
}

Expand Down Expand Up @@ -311,11 +311,11 @@ impl Def {
Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"),
Def::Union(..) => "union",
Def::Trait(..) => "trait",
Def::TyForeign(..) => "foreign type",
Def::Foreign(..) => "foreign type",
Def::Method(..) => "method",
Def::Const(..) => "constant",
Def::AssociatedConst(..) => "associated constant",
Def::TyParam(..) => "type parameter",
Def::Param(..) => "type parameter",
Def::PrimTy(..) => "builtin type",
Def::Local(..) => "local variable",
Def::Upvar(..) => "closure capture",
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/lowering.rs
Expand Up @@ -1183,7 +1183,7 @@ impl<'a> LoweringContext<'a> {
}
ImplTraitContext::Universal(in_band_ty_params) => {
self.lower_node_id(def_node_id);
// Add a definition for the in-band TyParam
// Add a definition for the in-band Param
let def_index = self
.resolver
.definitions()
Expand Down Expand Up @@ -1213,7 +1213,7 @@ impl<'a> LoweringContext<'a> {
None,
P(hir::Path {
span,
def: Def::TyParam(DefId::local(def_index)),
def: Def::Param(DefId::local(def_index)),
segments: hir_vec![hir::PathSegment::from_ident(ident)],
}),
))
Expand Down Expand Up @@ -2352,7 +2352,7 @@ impl<'a> LoweringContext<'a> {
if path.segments.len() == 1
&& bound_pred.bound_generic_params.is_empty() =>
{
if let Some(Def::TyParam(def_id)) = self.resolver
if let Some(Def::Param(def_id)) = self.resolver
.get_resolution(bound_pred.bounded_ty.id)
.map(|d| d.base_def())
{
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/mod.rs
Expand Up @@ -453,7 +453,7 @@ impl<'hir> Map<'hir> {
match item.node {
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),
ForeignItemKind::Type => Some(Def::TyForeign(def_id)),
ForeignItemKind::Type => Some(Def::Foreign(def_id)),
}
}
NodeTraitItem(item) => {
Expand Down Expand Up @@ -499,7 +499,7 @@ impl<'hir> Map<'hir> {
NodeGenericParam(param) => {
Some(match param.kind {
GenericParamKind::Lifetime { .. } => Def::Local(param.id),
GenericParamKind::Type { .. } => Def::TyParam(self.local_def_id(param.id)),
GenericParamKind::Type { .. } => Def::Param(self.local_def_id(param.id)),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ich/impls_hir.rs
Expand Up @@ -1010,9 +1010,9 @@ impl_stable_hash_for!(enum hir::def::Def {
AssociatedTy(def_id),
AssociatedExistential(def_id),
PrimTy(prim_ty),
TyParam(def_id),
Param(def_id),
SelfTy(trait_def_id, impl_def_id),
TyForeign(def_id),
Foreign(def_id),
Fn(def_id),
Const(def_id),
Static(def_id, is_mutbl),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ich/impls_ty.rs
Expand Up @@ -874,10 +874,10 @@ for ty::TyKind<'gcx>
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
TyParam(param_ty) => {
Param(param_ty) => {
param_ty.hash_stable(hcx, hasher);
}
TyForeign(def_id) => {
Foreign(def_id) => {
def_id.hash_stable(hcx, hasher);
}
Infer(infer_ty) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/canonical/canonicalizer.rs
Expand Up @@ -283,8 +283,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
| ty::Never
| ty::Tuple(..)
| ty::Projection(..)
| ty::TyForeign(..)
| ty::TyParam(..)
| ty::Foreign(..)
| ty::Param(..)
| ty::Anon(..) => {
if t.flags.intersects(self.needs_canonical_flags) {
t.super_fold_with(self)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Expand Up @@ -1123,7 +1123,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let type_param = generics.type_param(param, self.tcx);
let hir = &self.tcx.hir;
hir.as_local_node_id(type_param.def_id).map(|id| {
// Get the `hir::TyParam` to verify whether it already has any bounds.
// Get the `hir::Param` to verify whether it already has any bounds.
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
// instead we suggest `T: 'a + 'b` in that case.
let mut has_bounds = false;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/freshen.rs
Expand Up @@ -193,8 +193,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
ty::Never |
ty::Tuple(..) |
ty::Projection(..) |
ty::TyForeign(..) |
ty::TyParam(..) |
ty::Foreign(..) |
ty::Param(..) |
ty::Closure(..) |
ty::GeneratorWitness(..) |
ty::Anon(..) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/outlives/obligations.rs
Expand Up @@ -450,7 +450,7 @@ where

fn type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
match ty.sty {
ty::TyParam(p) => self.param_bound(p),
ty::Param(p) => self.param_bound(p),
ty::Projection(data) => {
let declared_bounds = self.projection_declared_bounds(data);
self.projection_bound(declared_bounds, data)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve_lifetime.rs
Expand Up @@ -1326,7 +1326,7 @@ fn object_lifetime_defaults_for_item(
_ => continue,
};

if def == Def::TyParam(param_def_id) {
if def == Def::Param(param_def_id) {
add_bounds(&mut set, &data.bounds);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/auto_trait.rs
Expand Up @@ -606,7 +606,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
}

return match substs.type_at(0).sty {
ty::TyParam(_) => true,
ty::Param(_) => true,
ty::Projection(p) => self.is_of_param(p.substs),
_ => false,
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/coherence.rs
Expand Up @@ -407,7 +407,7 @@ fn uncovered_tys<'tcx>(tcx: TyCtxt, ty: Ty<'tcx>, in_crate: InCrate)

fn is_possibly_remote_type(ty: Ty, _in_crate: InCrate) -> bool {
match ty.sty {
ty::Projection(..) | ty::TyParam(..) => true,
ty::Projection(..) | ty::Param(..) => true,
_ => false,
}
}
Expand Down Expand Up @@ -455,7 +455,7 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
ty::Ref(..) |
ty::Never |
ty::Tuple(..) |
ty::TyParam(..) |
ty::Param(..) |
ty::Projection(..) => {
false
}
Expand All @@ -468,7 +468,7 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
},

ty::Adt(def, _) => def_id_is_local(def.did, in_crate),
ty::TyForeign(did) => def_id_is_local(did, in_crate),
ty::Foreign(did) => def_id_is_local(did, in_crate),

ty::Dynamic(ref tt, ..) => {
tt.principal().map_or(false, |p| {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/traits/error_reporting.rs
Expand Up @@ -256,7 +256,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ty::Closure(..) => Some(9),
ty::Tuple(..) => Some(10),
ty::Projection(..) => Some(11),
ty::TyParam(..) => Some(12),
ty::Param(..) => Some(12),
ty::Anon(..) => Some(13),
ty::Never => Some(14),
ty::Adt(adt, ..) => match adt.adt_kind() {
Expand All @@ -265,7 +265,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
AdtKind::Enum => Some(17),
},
ty::Generator(..) => Some(18),
ty::TyForeign(..) => Some(19),
ty::Foreign(..) => Some(19),
ty::GeneratorWitness(..) => Some(20),
ty::Infer(..) | ty::Error => None
}
Expand Down Expand Up @@ -785,7 +785,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {

let found_did = match found_trait_ty.sty {
ty::Closure(did, _) |
ty::TyForeign(did) |
ty::Foreign(did) |
ty::FnDef(did, _) => Some(did),
ty::Adt(def, _) => Some(def.did),
_ => None,
Expand Down Expand Up @@ -1348,7 +1348,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.infcx.tcx }

fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::TyParam(ty::ParamTy {name, ..}) = ty.sty {
if let ty::Param(ty::ParamTy {name, ..}) = ty.sty {
let infcx = self.infcx;
self.var_map.entry(ty).or_insert_with(||
infcx.next_ty_var(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/object_safety.rs
Expand Up @@ -371,7 +371,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let mut error = false;
ty.maybe_walk(|ty| {
match ty.sty {
ty::TyParam(ref param_ty) => {
ty::Param(ref param_ty) => {
if param_ty.is_self() {
error = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/query/dropck_outlives.rs
Expand Up @@ -228,7 +228,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
| ty::RawPtr(_)
| ty::Ref(..)
| ty::TyStr
| ty::TyForeign(..)
| ty::Foreign(..)
| ty::Error => true,

// [T; N] and [T] have same properties as T.
Expand Down Expand Up @@ -257,7 +257,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
// The following *might* require a destructor: it would deeper inspection to tell.
ty::Dynamic(..)
| ty::Projection(..)
| ty::TyParam(_)
| ty::Param(_)
| ty::Anon(..)
| ty::Infer(_)
| ty::Generator(..) => false,
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/traits/select.rs
Expand Up @@ -1810,13 +1810,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// say nothing; a candidate may be added by
// `assemble_candidates_from_object_ty`.
}
ty::TyForeign(..) => {
ty::Foreign(..) => {
// Since the contents of foreign types is unknown,
// we don't add any `..` impl. Default traits could
// still be provided by a manual implementation for
// this trait and type.
}
ty::TyParam(..) |
ty::Param(..) |
ty::Projection(..) => {
// In these cases, we don't know what the actual
// type is. Therefore, we cannot break it down
Expand Down Expand Up @@ -2189,7 +2189,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
Where(ty::Binder::dummy(Vec::new()))
}

ty::TyStr | ty::Slice(_) | ty::Dynamic(..) | ty::TyForeign(..) => None,
ty::TyStr | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None,

ty::Tuple(tys) => {
Where(ty::Binder::bind(tys.last().into_iter().cloned().collect()))
Expand All @@ -2203,7 +2203,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
))
}

ty::Projection(_) | ty::TyParam(_) | ty::Anon(..) => None,
ty::Projection(_) | ty::Param(_) | ty::Anon(..) => None,
ty::Infer(ty::TyVar(_)) => Ambiguous,

ty::Infer(ty::CanonicalTy(_)) |
Expand Down Expand Up @@ -2239,7 +2239,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
}

ty::Dynamic(..) | ty::TyStr | ty::Slice(..) |
ty::Generator(..) | ty::GeneratorWitness(..) | ty::TyForeign(..) |
ty::Generator(..) | ty::GeneratorWitness(..) | ty::Foreign(..) |
ty::Ref(_, _, hir::MutMutable) => {
None
}
Expand All @@ -2265,7 +2265,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
}
}

ty::Adt(..) | ty::Projection(..) | ty::TyParam(..) | ty::Anon(..) => {
ty::Adt(..) | ty::Projection(..) | ty::Param(..) | ty::Anon(..) => {
// Fallback to whatever user-defined impls exist in this case.
None
}
Expand Down Expand Up @@ -2316,8 +2316,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
}

ty::Dynamic(..) |
ty::TyParam(..) |
ty::TyForeign(..) |
ty::Param(..) |
ty::Foreign(..) |
ty::Projection(..) |
ty::Infer(ty::CanonicalTy(_)) |
ty::Infer(ty::TyVar(_)) |
Expand Down Expand Up @@ -3072,7 +3072,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
let mut ty_params = BitArray::new(substs_a.types().count());
let mut found = false;
for ty in field.walk() {
if let ty::TyParam(p) = ty.sty {
if let ty::Param(p) = ty.sty {
ty_params.insert(p.idx as usize);
found = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/specialize/mod.rs
Expand Up @@ -90,7 +90,7 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
.unwrap()
.subst(infcx.tcx, &source_substs);

// translate the Self and TyParam parts of the substitution, since those
// translate the Self and Param parts of the substitution, since those
// vary across impls
let target_substs = match target_node {
specialization_graph::Node::Impl(target_impl) => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Expand Up @@ -2078,7 +2078,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
self,
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
TyParam, Infer, Projection, Anon, TyForeign);
Param, Infer, Projection, Anon, Foreign);

println!("Substs interner: #{}", self.interners.substs.borrow().len());
println!("Region interner: #{}", self.interners.region.borrow().len());
Expand Down Expand Up @@ -2387,7 +2387,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> {
self.mk_ty(TyForeign(def_id))
self.mk_ty(Foreign(def_id))
}

pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> {
Expand Down Expand Up @@ -2532,7 +2532,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn mk_ty_param(self,
index: u32,
name: InternedString) -> Ty<'tcx> {
self.mk_ty(TyParam(ParamTy { idx: index, name: name }))
self.mk_ty(Param(ParamTy { idx: index, name: name }))
}

pub fn mk_self_type(self) -> Ty<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/error.rs
Expand Up @@ -180,7 +180,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
ty::Tuple(ref tys) if tys.is_empty() => self.to_string(),

ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)),
ty::TyForeign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)),
ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)),
ty::Array(_, n) => {
match n.assert_usize(tcx) {
Some(n) => format!("array of {} elements", n),
Expand Down Expand Up @@ -222,7 +222,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(),
ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(),
ty::Projection(_) => "associated type".to_string(),
ty::TyParam(ref p) => {
ty::Param(ref p) => {
if p.is_self() {
"Self".to_string()
} else {
Expand Down

0 comments on commit 04fa5d3

Please sign in to comment.