11use rustc:: ty:: { self , TyCtxt } ;
22use rustc:: mir:: * ;
33use rustc:: util:: nodemap:: FxHashMap ;
4- use rustc_data_structures:: indexed_vec:: { IndexVec } ;
4+ use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
55use smallvec:: SmallVec ;
66use syntax_pos:: { Span } ;
77
@@ -12,66 +12,23 @@ use self::abs_domain::{AbstractElem, Lift};
1212
1313mod abs_domain;
1414
15- // This submodule holds some newtype'd Index wrappers that are using
16- // NonZero to ensure that Option<Index> occupies only a single word.
17- // They are in a submodule to impose privacy restrictions; namely, to
18- // ensure that other code does not accidentally access `index.0`
19- // (which is likely to yield a subtle off-by-one error).
20- pub ( crate ) mod indexes {
21- use std:: fmt;
22- use std:: num:: NonZeroUsize ;
23- use rustc_data_structures:: indexed_vec:: Idx ;
24-
25- macro_rules! new_index {
26- ( $( #[ $attrs: meta] ) * $Index: ident, $debug_name: expr) => {
27- #[ derive( Copy , Clone , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
28- pub struct $Index( NonZeroUsize ) ;
29-
30- impl Idx for $Index {
31- fn new( idx: usize ) -> Self {
32- $Index( NonZeroUsize :: new( idx + 1 ) . unwrap( ) )
33- }
34- fn index( self ) -> usize {
35- self . 0 . get( ) - 1
36- }
37- }
38-
39- impl fmt:: Debug for $Index {
40- fn fmt( & self , fmt: & mut fmt:: Formatter <' _>) -> fmt:: Result {
41- write!( fmt, "{}{}" , $debug_name, self . index( ) )
42- }
43- }
44- }
15+ newtype_index ! {
16+ pub struct MovePathIndex {
17+ DEBUG_FORMAT = "mp{}"
4518 }
19+ }
4620
47- new_index ! (
48- /// Index into MovePathData.move_paths
49- MovePathIndex ,
50- "mp"
51- ) ;
52-
53- new_index ! (
54- /// Index into MoveData.moves.
55- MoveOutIndex ,
56- "mo"
57- ) ;
58-
59- new_index ! (
60- /// Index into MoveData.inits.
61- InitIndex ,
62- "in"
63- ) ;
64-
65- new_index ! (
66- /// Index into Borrows.locations
67- BorrowIndex ,
68- "bw"
69- ) ;
21+ newtype_index ! {
22+ pub struct MoveOutIndex {
23+ DEBUG_FORMAT = "mo{}"
24+ }
7025}
7126
72- pub use self :: indexes:: MovePathIndex ;
73- pub use self :: indexes:: MoveOutIndex ;
74- pub use self :: indexes:: InitIndex ;
27+ newtype_index ! {
28+ pub struct InitIndex {
29+ DEBUG_FORMAT = "in{}"
30+ }
31+ }
7532
7633impl MoveOutIndex {
7734 pub fn move_path_index ( & self , move_data : & MoveData < ' _ > ) -> MovePathIndex {
0 commit comments