Skip to content
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

#53576 Renaming TyAnon -> TyOpaque #53705

Merged
merged 2 commits into from
Sep 8, 2018
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/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ for ty::TyKind<'gcx>
Projection(ref projection_ty) => {
projection_ty.hash_stable(hcx, hasher);
}
Anon(def_id, substs) => {
Opaque(def_id, substs) => {
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
| ty::Projection(..)
| ty::Foreign(..)
| ty::Param(..)
| ty::Anon(..) => {
| ty::Opaque(..) => {
if t.flags.intersects(self.needs_canonical_flags) {
t.super_fold_with(self)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
ty::Param(..) |
ty::Closure(..) |
ty::GeneratorWitness(..) |
ty::Anon(..) => {
ty::Opaque(..) => {
t.super_fold_with(self)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use self::outlives::env::OutlivesEnvironment;
use self::type_variable::TypeVariableOrigin;
use self::unify_key::ToType;

pub mod anon_types;
pub mod opaque_types;
pub mod at;
pub mod canonical;
mod combine;
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/librustc/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
ty::Closure(..) |
ty::Generator(..) |
ty::GeneratorWitness(..) |
ty::Anon(..) => {
ty::Opaque(..) => {
bug!("ty_is_local invoked on unexpected type: {:?}", ty)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ty::Tuple(..) => Some(10),
ty::Projection(..) => Some(11),
ty::Param(..) => Some(12),
ty::Anon(..) => Some(13),
ty::Opaque(..) => Some(13),
ty::Never => Some(14),
ty::Adt(adt, ..) => match adt.adt_kind() {
AdtKind::Struct => Some(15),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,

let ty = ty.super_fold_with(self);
match ty.sty {
ty::Anon(def_id, substs) if !substs.has_escaping_regions() => { // (*)
ty::Opaque(def_id, substs) if !substs.has_escaping_regions() => { // (*)
// Only normalize `impl Trait` after type-checking, usually in codegen.
match self.param_env.reveal {
Reveal::UserFacing => ty,
Expand Down Expand Up @@ -986,7 +986,7 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>(
ty::Projection(ref data) => {
(data.trait_ref(tcx).def_id, data.substs)
}
ty::Anon(def_id, substs) => (def_id, substs),
ty::Opaque(def_id, substs) => (def_id, substs),
ty::Infer(ty::TyVar(_)) => {
// If the self-type is an inference variable, then it MAY wind up
// being a projected type, so induce an ambiguity.
Expand Down Expand Up @@ -1518,7 +1518,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind {
let item_substs = Substs::identity_for_item(tcx, assoc_ty.item.def_id);
tcx.mk_anon(assoc_ty.item.def_id, item_substs)
tcx.mk_opaque(assoc_ty.item.def_id, item_substs)
} else {
tcx.type_of(assoc_ty.item.def_id)
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/dropck_outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
ty::Dynamic(..)
| ty::Projection(..)
| ty::Param(_)
| ty::Anon(..)
| ty::Opaque(..)
| ty::Infer(_)
| ty::Generator(..) => false,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
let ty = ty.super_fold_with(self);
match ty.sty {
ty::Anon(def_id, substs) if !substs.has_escaping_regions() => {
ty::Opaque(def_id, substs) if !substs.has_escaping_regions() => {
// (*)
// Only normalize `impl Trait` after type-checking, usually in codegen.
match self.param_env.reveal {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// before we go into the whole skolemization thing, just
// quickly check if the self-type is a projection at all.
match obligation.predicate.skip_binder().trait_ref.self_ty().sty {
ty::Projection(_) | ty::Anon(..) => {}
ty::Projection(_) | ty::Opaque(..) => {}
ty::Infer(ty::TyVar(_)) => {
span_bug!(obligation.cause.span,
"Self=_ should have been handled by assemble_candidates");
Expand Down Expand Up @@ -1528,7 +1528,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
let (def_id, substs) = match skol_trait_predicate.trait_ref.self_ty().sty {
ty::Projection(ref data) =>
(data.trait_ref(self.tcx()).def_id, data.substs),
ty::Anon(def_id, substs) => (def_id, substs),
ty::Opaque(def_id, substs) => (def_id, substs),
_ => {
span_bug!(
obligation.cause.span,
Expand Down Expand Up @@ -2203,7 +2203,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
))
}

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

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

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

ty::Anon(def_id, substs) => {
ty::Opaque(def_id, substs) => {
// We can resolve the `impl Trait` to its concrete type,
// which enforces a DAG between the functions requiring
// the auto trait bounds in question.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
self,
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
Param, Infer, Projection, Anon, Foreign);
Param, Infer, Projection, Opaque, Foreign);

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

pub fn mk_anon(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
self.mk_ty(Anon(def_id, substs))
pub fn mk_opaque(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
self.mk_ty(Opaque(def_id, substs))
}

pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>])
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
"type parameter".to_string()
}
}
ty::Anon(..) => "anonymized type".to_string(),
ty::Opaque(..) => "opaque type".to_string(),
ty::Error => "type error".to_string(),
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/fast_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub enum SimplifiedTypeGen<D>
ClosureSimplifiedType(D),
GeneratorSimplifiedType(D),
GeneratorWitnessSimplifiedType(usize),
AnonSimplifiedType(D),
OpaqueSimplifiedType(D),
FunctionSimplifiedType(usize),
ParameterSimplifiedType,
ForeignSimplifiedType(DefId),
Expand Down Expand Up @@ -115,8 +115,8 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
None
}
}
ty::Anon(def_id, _) => {
Some(AnonSimplifiedType(def_id))
ty::Opaque(def_id, _) => {
Some(OpaqueSimplifiedType(def_id))
}
ty::Foreign(def_id) => {
Some(ForeignSimplifiedType(def_id))
Expand Down Expand Up @@ -146,7 +146,7 @@ impl<D: Copy + Debug + Ord + Eq + Hash> SimplifiedTypeGen<D> {
ClosureSimplifiedType(d) => ClosureSimplifiedType(map(d)),
GeneratorSimplifiedType(d) => GeneratorSimplifiedType(map(d)),
GeneratorWitnessSimplifiedType(n) => GeneratorWitnessSimplifiedType(n),
AnonSimplifiedType(d) => AnonSimplifiedType(map(d)),
OpaqueSimplifiedType(d) => OpaqueSimplifiedType(map(d)),
FunctionSimplifiedType(n) => FunctionSimplifiedType(n),
ParameterSimplifiedType => ParameterSimplifiedType,
ForeignSimplifiedType(d) => ForeignSimplifiedType(d),
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'a, 'gcx, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
ClosureSimplifiedType(d) => d.hash_stable(hcx, hasher),
GeneratorSimplifiedType(d) => d.hash_stable(hcx, hasher),
GeneratorWitnessSimplifiedType(n) => n.hash_stable(hcx, hasher),
AnonSimplifiedType(d) => d.hash_stable(hcx, hasher),
OpaqueSimplifiedType(d) => d.hash_stable(hcx, hasher),
FunctionSimplifiedType(n) => n.hash_stable(hcx, hasher),
ForeignSimplifiedType(d) => d.hash_stable(hcx, hasher),
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl FlagComputation {
self.add_projection_ty(data);
}

&ty::Anon(_, substs) => {
&ty::Opaque(_, substs) => {
self.add_flags(TypeFlags::HAS_PROJECTION);
self.add_substs(substs);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
// in the normalized form
if self.just_constrained {
match t.sty {
ty::Projection(..) | ty::Anon(..) => { return false; }
ty::Projection(..) | ty::Opaque(..) => { return false; }
_ => { }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/item_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
ty::FnPtr(_) |
ty::Projection(_) |
ty::Param(_) |
ty::Anon(..) |
ty::Opaque(..) |
ty::Infer(_) |
ty::Error |
ty::GeneratorWitness(..) |
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
}

// Types with no meaningful known layout.
ty::Projection(_) | ty::Anon(..) => {
ty::Projection(_) | ty::Opaque(..) => {
let normalized = tcx.normalize_erasing_regions(param_env, ty);
if ty == normalized {
return Err(LayoutError::Unknown(ty));
Expand Down Expand Up @@ -1373,7 +1373,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
}
}

ty::Projection(_) | ty::Anon(..) => {
ty::Projection(_) | ty::Opaque(..) => {
let normalized = tcx.normalize_erasing_regions(param_env, ty);
if ty == normalized {
Err(err)
Expand Down Expand Up @@ -1685,7 +1685,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
}
}

ty::Projection(_) | ty::Anon(..) | ty::Param(_) |
ty::Projection(_) | ty::Opaque(..) | ty::Param(_) |
ty::Infer(_) | ty::Error => {
bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ impl<'tcx> TyS<'tcx> {

pub fn is_suggestable(&self) -> bool {
match self.sty {
TyKind::Anon(..) |
TyKind::Opaque(..) |
TyKind::FnDef(..) |
TyKind::FnPtr(..) |
TyKind::Dynamic(..) |
Expand Down Expand Up @@ -2265,7 +2265,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
.collect()
}

Projection(..) | Anon(..) => {
Projection(..) | Opaque(..) => {
// must calculate explicitly.
// FIXME: consider special-casing always-Sized projections
vec![ty]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
ty::Float(..) | // OutlivesScalar
ty::Never | // ...
ty::Adt(..) | // OutlivesNominalType
ty::Anon(..) | // OutlivesNominalType (ish)
ty::Opaque(..) | // OutlivesNominalType (ish)
ty::Foreign(..) | // OutlivesNominalType
ty::Str | // OutlivesScalar (ish)
ty::Array(..) | // ...
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
Ok(tcx.mk_projection(projection_ty.item_def_id, projection_ty.substs))
}

(&ty::Anon(a_def_id, a_substs), &ty::Anon(b_def_id, b_substs))
(&ty::Opaque(a_def_id, a_substs), &ty::Opaque(b_def_id, b_substs))
if a_def_id == b_def_id =>
{
let substs = relate_substs(relation, None, a_substs, b_substs)?;
Ok(tcx.mk_anon(a_def_id, substs))
Ok(tcx.mk_opaque(a_def_id, substs))
}

_ =>
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
ty::Projection(ref data) => ty::Projection(data.fold_with(folder)),
ty::Anon(did, substs) => ty::Anon(did, substs.fold_with(folder)),
ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)),
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
ty::Param(..) | ty::Never | ty::Foreign(..) => return self
Expand Down Expand Up @@ -900,7 +900,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
ty::Projection(ref data) => data.visit_with(visitor),
ty::Anon(_, ref substs) => substs.visit_with(visitor),
ty::Opaque(_, ref substs) => substs.visit_with(visitor),
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
ty::Param(..) | ty::Never | ty::Foreign(..) => false,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ pub enum TyKind<'tcx> {
/// `<T as Trait<..>>::N`.
Projection(ProjectionTy<'tcx>),

/// Anonymized (`impl Trait`) type found in a return type.
/// Opaque (`impl Trait`) type found in a return type.
/// The DefId comes either from
/// * the `impl Trait` ast::Ty node,
/// * or the `existential type` declaration
/// The substitutions are for the generics of the function in question.
/// After typeck, the concrete type can be found in the `types` map.
Anon(DefId, &'tcx Substs<'tcx>),
Opaque(DefId, &'tcx Substs<'tcx>),

/// A type parameter; for example, `T` in `fn f<T>(x: T) {}
Param(ParamTy),
Expand Down Expand Up @@ -1764,7 +1764,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {

pub fn is_impl_trait(&self) -> bool {
match self.sty {
Anon(..) => true,
Opaque(..) => true,
_ => false,
}
}
Expand All @@ -1791,7 +1791,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
}
v
}
Adt(_, substs) | Anon(_, substs) => {
Adt(_, substs) | Opaque(_, substs) => {
substs.regions().collect()
}
Closure(_, ClosureSubsts { ref substs }) |
Expand Down Expand Up @@ -1876,7 +1876,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
ty::Adt(def, _substs) =>
def.sized_constraint(tcx).is_empty(),

ty::Projection(_) | ty::Param(_) | ty::Anon(..) => false,
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,

ty::Infer(ty::TyVar(_)) => false,

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Can refer to a type which may drop.
// FIXME(eddyb) check this against a ParamEnv.
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) |
ty::Anon(..) | ty::Infer(_) | ty::Error => true,
ty::Opaque(..) | ty::Infer(_) | ty::Error => true,

// Structural recursion.
ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
substs.types().rev().chain(opt_ty)
}));
}
ty::Adt(_, substs) | ty::Anon(_, substs) => {
ty::Adt(_, substs) | ty::Opaque(_, substs) => {
stack.extend(substs.types().rev());
}
ty::Closure(_, ref substs) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
// types appearing in the fn signature
}

ty::Anon(did, substs) => {
ty::Opaque(did, substs) => {
// all of the requirements on type parameters
// should've been checked by the instantiation
// of whatever returned this exact `impl Trait`.
Expand Down
Loading