@@ -25,50 +25,9 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
2525
2626use std:: fmt;
2727
28- #[ cfg( feature = "rustc" ) ]
29- pub mod index {
30- // Faster version when the indices of variants are `0..variants.len()`.
31- pub use rustc_index:: bit_set:: BitSet as IdxSet ;
32- pub use rustc_index:: Idx ;
33- pub use rustc_index:: IndexVec as IdxContainer ;
34- }
35- #[ cfg( not( feature = "rustc" ) ) ]
36- pub mod index {
37- // Slower version when the indices of variants are something else.
38- pub trait Idx : Copy + PartialEq + Eq + std:: hash:: Hash { }
39- impl < T : Copy + PartialEq + Eq + std:: hash:: Hash > Idx for T { }
40-
41- #[ derive( Debug ) ]
42- pub struct IdxContainer < K , V > ( pub rustc_hash:: FxHashMap < K , V > ) ;
43- impl < K : Idx , V > IdxContainer < K , V > {
44- pub fn len ( & self ) -> usize {
45- self . 0 . len ( )
46- }
47- pub fn iter_enumerated ( & self ) -> impl Iterator < Item = ( K , & V ) > {
48- self . 0 . iter ( ) . map ( |( k, v) | ( * k, v) )
49- }
50- }
51-
52- impl < V > FromIterator < V > for IdxContainer < usize , V > {
53- fn from_iter < T : IntoIterator < Item = V > > ( iter : T ) -> Self {
54- Self ( iter. into_iter ( ) . enumerate ( ) . collect ( ) )
55- }
56- }
57-
58- #[ derive( Debug ) ]
59- pub struct IdxSet < T > ( pub rustc_hash:: FxHashSet < T > ) ;
60- impl < T : Idx > IdxSet < T > {
61- pub fn new_empty ( _len : usize ) -> Self {
62- Self ( Default :: default ( ) )
63- }
64- pub fn contains ( & self , elem : T ) -> bool {
65- self . 0 . contains ( & elem)
66- }
67- pub fn insert ( & mut self , elem : T ) {
68- self . 0 . insert ( elem) ;
69- }
70- }
71- }
28+ // Re-exports to avoid rustc_index version issues.
29+ pub use rustc_index:: Idx ;
30+ pub use rustc_index:: IndexVec ;
7231
7332#[ cfg( feature = "rustc" ) ]
7433use rustc_middle:: ty:: Ty ;
@@ -96,7 +55,7 @@ pub trait PatCx: Sized + fmt::Debug {
9655 /// Errors that can abort analysis.
9756 type Error : fmt:: Debug ;
9857 /// The index of an enum variant.
99- type VariantIdx : Clone + index :: Idx + fmt:: Debug ;
58+ type VariantIdx : Clone + Idx + fmt:: Debug ;
10059 /// A string literal
10160 type StrLit : Clone + PartialEq + fmt:: Debug ;
10261 /// Extra data to store in a match arm.
0 commit comments