@@ -3,6 +3,7 @@ use rustc_hir::LangItem;
3
3
use smallvec:: SmallVec ;
4
4
5
5
use super :: TerminatorKind ;
6
+ use rustc_data_structures:: packed:: Pu128 ;
6
7
use rustc_macros:: HashStable ;
7
8
use std:: slice;
8
9
@@ -14,15 +15,16 @@ impl SwitchTargets {
14
15
/// The iterator may be empty, in which case the `SwitchInt` instruction is equivalent to
15
16
/// `goto otherwise;`.
16
17
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 ( ) ;
18
20
targets. push ( otherwise) ;
19
21
Self { values, targets }
20
22
}
21
23
22
24
/// Builds a switch targets definition that jumps to `then` if the tested value equals `value`,
23
25
/// and to `else_` if not.
24
26
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_] }
26
28
}
27
29
28
30
/// Inverse of `SwitchTargets::static_if`.
@@ -31,7 +33,7 @@ impl SwitchTargets {
31
33
if let & [ value] = & self . values [ ..]
32
34
&& let & [ then, else_] = & self . targets [ ..]
33
35
{
34
- Some ( ( value, then, else_) )
36
+ Some ( ( value. get ( ) , then, else_) )
35
37
} else {
36
38
None
37
39
}
@@ -75,15 +77,15 @@ impl SwitchTargets {
75
77
}
76
78
77
79
pub 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 > > ,
79
81
}
80
82
81
83
impl < ' a > Iterator for SwitchTargetsIter < ' a > {
82
84
type Item = ( u128 , BasicBlock ) ;
83
85
84
86
#[ inline]
85
87
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) )
87
89
}
88
90
89
91
#[ inline]
0 commit comments