|
4 | 4 | //! field-deref on a local variable, `x.field`, has the same meaning
|
5 | 5 | //! in both domains). Indexed projections are the exception: `a[x]`
|
6 | 6 | //! needs to be treated as mapping to the same move path as `a[y]` as
|
7 |
| -//! well as `a[13]`, etc. |
| 7 | +//! well as `a[13]`, etc. So we map these `x`/`y` values to `()`. |
8 | 8 | //!
|
9 | 9 | //! (In theory, the analysis could be extended to work with sets of
|
10 | 10 | //! paths, so that `a[0]` and `a[13]` could be kept distinct, while
|
11 | 11 | //! `a[x]` would still overlap them both. But that is not this
|
12 | 12 | //! representation does today.)
|
13 | 13 |
|
14 |
| -use rustc_middle::mir::{Local, Operand, PlaceElem, ProjectionElem}; |
15 |
| -use rustc_middle::ty::Ty; |
16 |
| - |
17 |
| -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] |
18 |
| -pub(crate) struct AbstractOperand; |
19 |
| -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] |
20 |
| -pub(crate) struct AbstractType; |
21 |
| -pub(crate) type AbstractElem = ProjectionElem<AbstractOperand, AbstractType>; |
| 14 | +use rustc_middle::mir::{PlaceElem, ProjectionElem, ProjectionKind}; |
22 | 15 |
|
23 | 16 | pub(crate) trait Lift {
|
24 |
| - type Abstract; |
25 |
| - fn lift(&self) -> Self::Abstract; |
26 |
| -} |
27 |
| -impl<'tcx> Lift for Operand<'tcx> { |
28 |
| - type Abstract = AbstractOperand; |
29 |
| - fn lift(&self) -> Self::Abstract { |
30 |
| - AbstractOperand |
31 |
| - } |
32 |
| -} |
33 |
| -impl Lift for Local { |
34 |
| - type Abstract = AbstractOperand; |
35 |
| - fn lift(&self) -> Self::Abstract { |
36 |
| - AbstractOperand |
37 |
| - } |
38 |
| -} |
39 |
| -impl<'tcx> Lift for Ty<'tcx> { |
40 |
| - type Abstract = AbstractType; |
41 |
| - fn lift(&self) -> Self::Abstract { |
42 |
| - AbstractType |
43 |
| - } |
| 17 | + fn lift(&self) -> ProjectionKind; |
44 | 18 | }
|
| 19 | + |
45 | 20 | impl<'tcx> Lift for PlaceElem<'tcx> {
|
46 |
| - type Abstract = AbstractElem; |
47 |
| - fn lift(&self) -> Self::Abstract { |
| 21 | + fn lift(&self) -> ProjectionKind { |
48 | 22 | match *self {
|
49 | 23 | ProjectionElem::Deref => ProjectionElem::Deref,
|
50 |
| - ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, ty.lift()), |
51 |
| - ProjectionElem::OpaqueCast(ty) => ProjectionElem::OpaqueCast(ty.lift()), |
52 |
| - ProjectionElem::Index(ref i) => ProjectionElem::Index(i.lift()), |
| 24 | + ProjectionElem::Field(f, _ty) => ProjectionElem::Field(f, ()), |
| 25 | + ProjectionElem::OpaqueCast(_ty) => ProjectionElem::OpaqueCast(()), |
| 26 | + ProjectionElem::Index(_i) => ProjectionElem::Index(()), |
53 | 27 | ProjectionElem::Subslice { from, to, from_end } => {
|
54 | 28 | ProjectionElem::Subslice { from, to, from_end }
|
55 | 29 | }
|
56 | 30 | ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
|
57 | 31 | ProjectionElem::ConstantIndex { offset, min_length, from_end }
|
58 | 32 | }
|
59 | 33 | ProjectionElem::Downcast(a, u) => ProjectionElem::Downcast(a, u),
|
60 |
| - ProjectionElem::Subtype(ty) => ProjectionElem::Subtype(ty.lift()), |
| 34 | + ProjectionElem::Subtype(_ty) => ProjectionElem::Subtype(()), |
61 | 35 | }
|
62 | 36 | }
|
63 | 37 | }
|
0 commit comments