diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-10-22 11:58:06 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-10-26 23:44:52 +0200 |
| commit | 28ce99df86bc4e7e1f36a266e4e19da3f1cfff8a (patch) | |
| tree | e9e8572f5915c8591f59d7812d4034f9fc9e5a11 /src/librustc | |
| parent | 36d8432a6d808dcd9e792679930729c0ab9a0212 (diff) | |
| download | rust-28ce99df86bc4e7e1f36a266e4e19da3f1cfff8a.tar.gz rust-28ce99df86bc4e7e1f36a266e4e19da3f1cfff8a.zip | |
Added `mir::UserTypeProjection`, a stub for a structure that projects *into* a given UserTypeAnnotation.
(That is, it will pull out some component type held or referenced by the type annotation.) Note: this still needs to actually do projection itself. That comes in a later commit
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/ich/impls_mir.rs | 2 | ||||
| -rw-r--r-- | src/librustc/mir/mod.rs | 15 | ||||
| -rw-r--r-- | src/librustc/mir/visit.rs | 25 |
3 files changed, 36 insertions, 6 deletions
diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index 4f68569c600..94b85247bb8 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -606,3 +606,5 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for mir::UserTypeAnnotation< } } } + +impl_stable_hash_for!(struct mir::UserTypeProjection<'tcx> { base }); diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 7c3d4713572..d2f67a74420 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -710,7 +710,7 @@ pub struct LocalDecl<'tcx> { /// e.g. via `let x: T`, then we carry that type here. The MIR /// borrow checker needs this information since it can affect /// region inference. - pub user_ty: Option<(UserTypeAnnotation<'tcx>, Span)>, + pub user_ty: Option<(UserTypeProjection<'tcx>, Span)>, /// Name of the local, used in debuginfo and pretty-printing. /// @@ -1741,7 +1741,7 @@ pub enum StatementKind<'tcx> { /// - `Contravariant` -- requires that `T_y :> T` /// - `Invariant` -- requires that `T_y == T` /// - `Bivariant` -- no effect - AscribeUserType(Place<'tcx>, ty::Variance, Box<UserTypeAnnotation<'tcx>>), + AscribeUserType(Place<'tcx>, ty::Variance, Box<UserTypeProjection<'tcx>>), /// No-op. Useful for deleting instructions without affecting statement indices. Nop, @@ -2449,6 +2449,17 @@ EnumLiftImpl! { } } +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +pub struct UserTypeProjection<'tcx> { + pub base: UserTypeAnnotation<'tcx>, +} + +BraceStructTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection<'tcx> { + base + } +} + newtype_index! { pub struct Promoted { DEBUG_FORMAT = "promoted[{}]" diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 1a879ce5f7b..acca7ddcd3f 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -147,7 +147,7 @@ macro_rules! make_mir_visitor { fn visit_ascribe_user_ty(&mut self, place: & $($mutability)* Place<'tcx>, variance: & $($mutability)* ty::Variance, - user_ty: & $($mutability)* UserTypeAnnotation<'tcx>, + user_ty: & $($mutability)* UserTypeProjection<'tcx>, location: Location) { self.super_ascribe_user_ty(place, variance, user_ty, location); } @@ -213,6 +213,13 @@ macro_rules! make_mir_visitor { self.super_ty(ty); } + fn visit_user_type_projection( + &mut self, + ty: & $($mutability)* UserTypeProjection<'tcx>, + ) { + self.super_user_type_projection(ty); + } + fn visit_user_type_annotation( &mut self, ty: & $($mutability)* UserTypeAnnotation<'tcx>, @@ -639,10 +646,10 @@ macro_rules! make_mir_visitor { fn super_ascribe_user_ty(&mut self, place: & $($mutability)* Place<'tcx>, _variance: & $($mutability)* ty::Variance, - user_ty: & $($mutability)* UserTypeAnnotation<'tcx>, + user_ty: & $($mutability)* UserTypeProjection<'tcx>, location: Location) { self.visit_place(place, PlaceContext::Validate, location); - self.visit_user_type_annotation(user_ty); + self.visit_user_type_projection(user_ty); } fn super_place(&mut self, @@ -737,7 +744,7 @@ macro_rules! make_mir_visitor { source_info: *source_info, }); if let Some((user_ty, _)) = user_ty { - self.visit_user_type_annotation(user_ty); + self.visit_user_type_projection(user_ty); } self.visit_source_info(source_info); self.visit_source_scope(visibility_scope); @@ -784,6 +791,16 @@ macro_rules! make_mir_visitor { self.visit_source_scope(scope); } + fn super_user_type_projection( + &mut self, + ty: & $($mutability)* UserTypeProjection<'tcx>, + ) { + let UserTypeProjection { + ref $($mutability)* base, + } = *ty; + self.visit_user_type_annotation(base) + } + fn super_user_type_annotation( &mut self, _ty: & $($mutability)* UserTypeAnnotation<'tcx>, |
