Rename UserTypeAnnotation -> UserType
This commit is contained in:
parent
c87144f3ca
commit
ab7bc3a23d
14 changed files with 43 additions and 43 deletions
|
|
@ -1240,16 +1240,16 @@ impl_stable_hash_for!(
|
|||
}
|
||||
);
|
||||
|
||||
impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::UserTypeAnnotation<'gcx> {
|
||||
impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::UserType<'gcx> {
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||
match *self {
|
||||
ty::UserTypeAnnotation::Ty(ref ty) => {
|
||||
ty::UserType::Ty(ref ty) => {
|
||||
ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
ty::UserTypeAnnotation::TypeOf(ref def_id, ref substs) => {
|
||||
ty::UserType::TypeOf(ref def_id, ref substs) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
substs.hash_stable(hcx, hasher);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use ty::subst::{Subst, Substs};
|
|||
use ty::layout::VariantIdx;
|
||||
use ty::{
|
||||
self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt,
|
||||
UserTypeAnnotationIndex, UserTypeAnnotation,
|
||||
UserTypeAnnotationIndex, UserType,
|
||||
};
|
||||
use util::ppaux;
|
||||
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ macro_rules! make_mir_visitor {
|
|||
fn visit_user_type_annotation(
|
||||
&mut self,
|
||||
index: UserTypeAnnotationIndex,
|
||||
ty: & $($mutability)* Canonical<'tcx, UserTypeAnnotation<'tcx>>,
|
||||
ty: & $($mutability)* Canonical<'tcx, UserType<'tcx>>,
|
||||
) {
|
||||
self.super_user_type_annotation(index, ty);
|
||||
}
|
||||
|
|
@ -882,7 +882,7 @@ macro_rules! make_mir_visitor {
|
|||
fn super_user_type_annotation(
|
||||
&mut self,
|
||||
_index: UserTypeAnnotationIndex,
|
||||
_ty: & $($mutability)* Canonical<'tcx, UserTypeAnnotation<'tcx>>,
|
||||
_ty: & $($mutability)* Canonical<'tcx, UserType<'tcx>>,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -800,7 +800,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
|
|||
|
||||
newtype_index! {
|
||||
pub struct UserTypeAnnotationIndex {
|
||||
DEBUG_FORMAT = "UserTypeAnnotation({})",
|
||||
DEBUG_FORMAT = "UserType({})",
|
||||
const START_INDEX = 0,
|
||||
}
|
||||
}
|
||||
|
|
@ -810,15 +810,15 @@ pub type CanonicalUserTypeAnnotations<'tcx> =
|
|||
IndexVec<UserTypeAnnotationIndex, (Span, CanonicalUserTypeAnnotation<'tcx>)>;
|
||||
|
||||
/// Canonicalized user type annotation.
|
||||
pub type CanonicalUserTypeAnnotation<'gcx> = Canonical<'gcx, UserTypeAnnotation<'gcx>>;
|
||||
pub type CanonicalUserTypeAnnotation<'gcx> = Canonical<'gcx, UserType<'gcx>>;
|
||||
|
||||
impl CanonicalUserTypeAnnotation<'gcx> {
|
||||
/// Returns `true` if this represents a substitution of the form `[?0, ?1, ?2]`,
|
||||
/// i.e. each thing is mapped to a canonical variable with the same index.
|
||||
pub fn is_identity(&self) -> bool {
|
||||
match self.value {
|
||||
UserTypeAnnotation::Ty(_) => false,
|
||||
UserTypeAnnotation::TypeOf(_, user_substs) => {
|
||||
UserType::Ty(_) => false,
|
||||
UserType::TypeOf(_, user_substs) => {
|
||||
if user_substs.user_self_ty.is_some() {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -853,7 +853,7 @@ impl CanonicalUserTypeAnnotation<'gcx> {
|
|||
/// from constants that are named via paths, like `Foo::<A>::new` and
|
||||
/// so forth.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub enum UserTypeAnnotation<'tcx> {
|
||||
pub enum UserType<'tcx> {
|
||||
Ty(Ty<'tcx>),
|
||||
|
||||
/// The canonical type is the result of `type_of(def_id)` with the
|
||||
|
|
@ -862,17 +862,17 @@ pub enum UserTypeAnnotation<'tcx> {
|
|||
}
|
||||
|
||||
EnumTypeFoldableImpl! {
|
||||
impl<'tcx> TypeFoldable<'tcx> for UserTypeAnnotation<'tcx> {
|
||||
(UserTypeAnnotation::Ty)(ty),
|
||||
(UserTypeAnnotation::TypeOf)(def, substs),
|
||||
impl<'tcx> TypeFoldable<'tcx> for UserType<'tcx> {
|
||||
(UserType::Ty)(ty),
|
||||
(UserType::TypeOf)(def, substs),
|
||||
}
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for UserTypeAnnotation<'a> {
|
||||
type Lifted = UserTypeAnnotation<'tcx>;
|
||||
(UserTypeAnnotation::Ty)(ty),
|
||||
(UserTypeAnnotation::TypeOf)(def, substs),
|
||||
impl<'a, 'tcx> Lift<'tcx> for UserType<'a> {
|
||||
type Lifted = UserType<'tcx>;
|
||||
(UserType::Ty)(ty),
|
||||
(UserType::TypeOf)(def, substs),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ pub use self::binding::BindingMode::*;
|
|||
pub use self::context::{TyCtxt, FreeRegionInfo, GlobalArenas, AllArenas, tls, keep_local};
|
||||
pub use self::context::{Lift, TypeckTables, CtxtInterners};
|
||||
pub use self::context::{
|
||||
UserTypeAnnotationIndex, UserTypeAnnotation, CanonicalUserTypeAnnotation,
|
||||
UserTypeAnnotationIndex, UserType, CanonicalUserTypeAnnotation,
|
||||
CanonicalUserTypeAnnotations,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use rustc::infer::canonical::Canonical;
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{
|
||||
self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable, UserTypeAnnotation,
|
||||
self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable, UserType,
|
||||
UserTypeAnnotationIndex,
|
||||
};
|
||||
use rustc::mir::{Location, Mir};
|
||||
|
|
@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
|
|||
fn visit_user_type_annotation(
|
||||
&mut self,
|
||||
_index: UserTypeAnnotationIndex,
|
||||
_ty: &mut Canonical<'tcx, UserTypeAnnotation<'tcx>>,
|
||||
_ty: &mut Canonical<'tcx, UserType<'tcx>>,
|
||||
) {
|
||||
// User type annotations represent the types that the user
|
||||
// wrote in the progarm. We don't want to erase the regions
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use rustc::traits::{ObligationCause, PredicateObligations};
|
|||
use rustc::ty::fold::TypeFoldable;
|
||||
use rustc::ty::subst::{Subst, Substs, UnpackedKind};
|
||||
use rustc::ty::{
|
||||
self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind, UserTypeAnnotation,
|
||||
self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind, UserType,
|
||||
UserTypeAnnotationIndex,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
|
|
@ -748,7 +748,7 @@ struct TypeChecker<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
|||
/// annotations. Part of the reason for this setup is that it allows us to enforce basic
|
||||
/// WF criteria on the types even if the code that referenced them is dead
|
||||
/// code (see #54943).
|
||||
instantiated_type_annotations: FxHashMap<UserTypeAnnotationIndex, UserTypeAnnotation<'tcx>>,
|
||||
instantiated_type_annotations: FxHashMap<UserTypeAnnotationIndex, UserType<'tcx>>,
|
||||
}
|
||||
|
||||
struct BorrowCheckContext<'a, 'tcx: 'a> {
|
||||
|
|
@ -925,7 +925,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
*span, &canonical_annotation
|
||||
);
|
||||
match annotation {
|
||||
UserTypeAnnotation::Ty(ref mut ty) =>
|
||||
UserType::Ty(ref mut ty) =>
|
||||
*ty = self.normalize(ty, Locations::All(*span)),
|
||||
_ => {},
|
||||
}
|
||||
|
|
@ -1068,7 +1068,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
let type_annotation = self.instantiated_type_annotations[&user_ty.base];
|
||||
match type_annotation {
|
||||
UserTypeAnnotation::Ty(ty) => {
|
||||
UserType::Ty(ty) => {
|
||||
// The `TypeRelating` code assumes that "unresolved inference
|
||||
// variables" appear in the "a" side, so flip `Contravariant`
|
||||
// ambient variance to get the right relationship.
|
||||
|
|
@ -1107,7 +1107,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
self.relate_types(ty, v1, a, locations, category)?;
|
||||
}
|
||||
}
|
||||
UserTypeAnnotation::TypeOf(def_id, user_substs) => {
|
||||
UserType::TypeOf(def_id, user_substs) => {
|
||||
let projs = self.infcx.tcx.intern_projs(&user_ty.projs);
|
||||
self.fully_perform_op(
|
||||
locations,
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
let user_ty = user_provided_types.get(fun.hir_id)
|
||||
.map(|u_ty| *u_ty)
|
||||
.map(|mut u_ty| {
|
||||
if let UserTypeAnnotation::TypeOf(ref mut did, _) = &mut u_ty.value {
|
||||
if let UserType::TypeOf(ref mut did, _) = &mut u_ty.value {
|
||||
*did = adt_def.did;
|
||||
}
|
||||
u_ty
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::infer::canonical::Canonical;
|
||||
use rustc::middle::region;
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{AdtDef, UpvarSubsts, Ty, Const, LazyConst, UserTypeAnnotation};
|
||||
use rustc::ty::{AdtDef, UpvarSubsts, Ty, Const, LazyConst, UserType};
|
||||
use rustc::ty::layout::VariantIdx;
|
||||
use rustc::hir;
|
||||
use syntax::ast;
|
||||
|
|
@ -265,7 +265,7 @@ pub enum ExprKind<'tcx> {
|
|||
|
||||
/// Optional user-given substs: for something like `let x =
|
||||
/// Bar::<T> { ... }`.
|
||||
user_ty: Option<Canonical<'tcx, UserTypeAnnotation<'tcx>>>,
|
||||
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
|
||||
|
||||
fields: Vec<FieldExprRef<'tcx>>,
|
||||
base: Option<FruInfo<'tcx>>
|
||||
|
|
@ -273,12 +273,12 @@ pub enum ExprKind<'tcx> {
|
|||
PlaceTypeAscription {
|
||||
source: ExprRef<'tcx>,
|
||||
/// Type that the user gave to this expression
|
||||
user_ty: Option<Canonical<'tcx, UserTypeAnnotation<'tcx>>>,
|
||||
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
|
||||
},
|
||||
ValueTypeAscription {
|
||||
source: ExprRef<'tcx>,
|
||||
/// Type that the user gave to this expression
|
||||
user_ty: Option<Canonical<'tcx, UserTypeAnnotation<'tcx>>>,
|
||||
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
|
||||
},
|
||||
Closure {
|
||||
closure_id: DefId,
|
||||
|
|
@ -288,7 +288,7 @@ pub enum ExprKind<'tcx> {
|
|||
},
|
||||
Literal {
|
||||
literal: &'tcx LazyConst<'tcx>,
|
||||
user_ty: Option<Canonical<'tcx, UserTypeAnnotation<'tcx>>>,
|
||||
user_ty: Option<Canonical<'tcx, UserType<'tcx>>>,
|
||||
},
|
||||
InlineAsm {
|
||||
asm: &'tcx hir::InlineAsm,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability};
|
|||
use rustc::mir::{ProjectionElem, UserTypeProjection};
|
||||
use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, sign_extend};
|
||||
use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, Lift};
|
||||
use rustc::ty::{CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, UserTypeAnnotation};
|
||||
use rustc::ty::{CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, UserType};
|
||||
use rustc::ty::subst::{Substs, Kind};
|
||||
use rustc::ty::layout::VariantIdx;
|
||||
use rustc::hir::{self, PatKind, RangeEnd};
|
||||
|
|
@ -1040,7 +1040,7 @@ macro_rules! CloneImpls {
|
|||
CloneImpls!{ <'tcx>
|
||||
Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>,
|
||||
Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef,
|
||||
&'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>,
|
||||
&'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserType<'tcx>,
|
||||
UserTypeProjection<'tcx>, PatternTypeProjection<'tcx>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rustc::hir;
|
||||
use rustc::ty::{self, CanonicalUserTypeAnnotation, TyCtxt, UserTypeAnnotation};
|
||||
use rustc::ty::{self, CanonicalUserTypeAnnotation, TyCtxt, UserType};
|
||||
|
||||
crate trait UserAnnotatedTyHelpers<'gcx: 'tcx, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'_, 'gcx, 'tcx>;
|
||||
|
|
@ -18,7 +18,7 @@ crate trait UserAnnotatedTyHelpers<'gcx: 'tcx, 'tcx> {
|
|||
debug!("user_subts_applied_to_ty_of_hir_id: user_ty={:?}", user_ty);
|
||||
match &self.tables().node_id_to_type(hir_id).sty {
|
||||
ty::Adt(adt_def, ..) => {
|
||||
if let UserTypeAnnotation::TypeOf(ref mut did, _) = &mut user_ty.value {
|
||||
if let UserType::TypeOf(ref mut did, _) = &mut user_ty.value {
|
||||
*did = adt_def.did;
|
||||
}
|
||||
Some(user_ty)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ use rustc::mir::interpret::{ConstValue, GlobalId};
|
|||
use rustc::traits::{self, ObligationCause, ObligationCauseCode, TraitEngine};
|
||||
use rustc::ty::{
|
||||
self, AdtKind, CanonicalUserTypeAnnotation, Ty, TyCtxt, GenericParamDefKind, Visibility,
|
||||
ToPolyTraitRef, ToPredicate, RegionKind, UserTypeAnnotation
|
||||
ToPolyTraitRef, ToPredicate, RegionKind, UserType
|
||||
};
|
||||
use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
|
||||
use rustc::ty::fold::TypeFoldable;
|
||||
|
|
@ -985,7 +985,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
|
||||
let c_ty = self.fcx.inh.infcx.canonicalize_user_type_annotation(
|
||||
&UserTypeAnnotation::Ty(revealed_ty)
|
||||
&UserType::Ty(revealed_ty)
|
||||
);
|
||||
debug!("visit_local: ty.hir_id={:?} o_ty={:?} revealed_ty={:?} c_ty={:?}",
|
||||
ty.hir_id, o_ty, revealed_ty, c_ty);
|
||||
|
|
@ -2194,7 +2194,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
user_self_ty: None, // not relevant here
|
||||
};
|
||||
|
||||
self.infcx.canonicalize_user_type_annotation(&UserTypeAnnotation::TypeOf(
|
||||
self.infcx.canonicalize_user_type_annotation(&UserType::TypeOf(
|
||||
method.def_id,
|
||||
user_substs,
|
||||
))
|
||||
|
|
@ -2239,7 +2239,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
if !substs.is_noop() {
|
||||
let canonicalized = self.infcx.canonicalize_user_type_annotation(
|
||||
&UserTypeAnnotation::TypeOf(def_id, UserSubsts {
|
||||
&UserType::TypeOf(def_id, UserSubsts {
|
||||
substs,
|
||||
user_self_ty,
|
||||
})
|
||||
|
|
@ -2440,7 +2440,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
// although I have my doubts). Other sorts of things are
|
||||
// already sufficiently enforced with erased regions. =)
|
||||
if ty.has_free_regions() || ty.has_projections() {
|
||||
let c_ty = self.infcx.canonicalize_response(&UserTypeAnnotation::Ty(ty));
|
||||
let c_ty = self.infcx.canonicalize_response(&UserType::Ty(ty));
|
||||
debug!("to_ty_saving_user_provided_ty: c_ty={:?}", c_ty);
|
||||
self.tables.borrow_mut().user_provided_types_mut().insert(ast_ty.hir_id, c_ty);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
|
|||
.user_provided_types_mut()
|
||||
.insert(hir_id, c_ty.clone());
|
||||
|
||||
if let ty::UserTypeAnnotation::TypeOf(_, user_substs) = c_ty.value {
|
||||
if let ty::UserType::TypeOf(_, user_substs) = c_ty.value {
|
||||
if self.rustc_dump_user_substs {
|
||||
// This is a unit-testing mechanism.
|
||||
let node_id = self.tcx().hir().hir_to_node_id(hir_id);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn main() {
|
|||
// StorageLive(_4);
|
||||
// _4 = std::option::Option<std::boxed::Box<u32>>::None;
|
||||
// FakeRead(ForLet, _4);
|
||||
// AscribeUserType(_4, o, UserTypeProjection { base: UserTypeAnnotation(1), projs: [] });
|
||||
// AscribeUserType(_4, o, UserTypeProjection { base: UserType(1), projs: [] });
|
||||
// StorageLive(_5);
|
||||
// StorageLive(_6);
|
||||
// _6 = move _4;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue