@@ -3,6 +3,7 @@ use rustc_hir::LangItem;
33use smallvec:: SmallVec ;
44
55use super :: TerminatorKind ;
6+ use rustc_data_structures:: packed:: Pu128 ;
67use rustc_macros:: HashStable ;
78use std:: slice;
89
@@ -14,15 +15,16 @@ impl SwitchTargets {
1415 /// The iterator may be empty, in which case the `SwitchInt` instruction is equivalent to
1516 /// `goto otherwise;`.
1617 pub fn new ( targets : impl Iterator < Item = ( u128 , BasicBlock ) > , otherwise : BasicBlock ) -> Self {
17- let ( values, mut targets) : ( SmallVec < _ > , SmallVec < _ > ) = targets. unzip ( ) ;
18+ let ( values, mut targets) : ( SmallVec < _ > , SmallVec < _ > ) =
19+ targets. map ( |( v, t) | ( Pu128 ( v) , t) ) . unzip ( ) ;
1820 targets. push ( otherwise) ;
1921 Self { values, targets }
2022 }
2123
2224 /// Builds a switch targets definition that jumps to `then` if the tested value equals `value`,
2325 /// and to `else_` if not.
2426 pub fn static_if ( value : u128 , then : BasicBlock , else_ : BasicBlock ) -> Self {
25- Self { values : smallvec ! [ value] , targets : smallvec ! [ then, else_] }
27+ Self { values : smallvec ! [ Pu128 ( value) ] , targets : smallvec ! [ then, else_] }
2628 }
2729
2830 /// Inverse of `SwitchTargets::static_if`.
@@ -31,7 +33,7 @@ impl SwitchTargets {
3133 if let & [ value] = & self . values [ ..]
3234 && let & [ then, else_] = & self . targets [ ..]
3335 {
34- Some ( ( value, then, else_) )
36+ Some ( ( value. get ( ) , then, else_) )
3537 } else {
3638 None
3739 }
@@ -75,15 +77,15 @@ impl SwitchTargets {
7577}
7678
7779pub struct SwitchTargetsIter < ' a > {
78- inner : iter:: Zip < slice:: Iter < ' a , u128 > , slice:: Iter < ' a , BasicBlock > > ,
80+ inner : iter:: Zip < slice:: Iter < ' a , Pu128 > , slice:: Iter < ' a , BasicBlock > > ,
7981}
8082
8183impl < ' a > Iterator for SwitchTargetsIter < ' a > {
8284 type Item = ( u128 , BasicBlock ) ;
8385
8486 #[ inline]
8587 fn next ( & mut self ) -> Option < Self :: Item > {
86- self . inner . next ( ) . map ( |( val, bb) | ( * val, * bb) )
88+ self . inner . next ( ) . map ( |( val, bb) | ( val. get ( ) , * bb) )
8789 }
8890
8991 #[ inline]
0 commit comments