@@ -1004,31 +1004,8 @@ pub enum BackwardIncompatibleDropReason {
10041004
10051005#[ derive( Debug , Clone , TyEncodable , TyDecodable , Hash , HashStable , PartialEq ) ]
10061006pub struct SwitchTargets {
1007- /// Possible values. For each value, the location to branch to is found in
1008- /// the corresponding element in the `targets` vector.
1009- pub ( super ) values : SmallVec < [ Pu128 ; 1 ] > ,
1010-
1011- /// Possible branch targets. The last element of this vector is used for
1012- /// the "otherwise" branch, so `targets.len() == values.len() + 1` always
1013- /// holds.
1014- //
1015- // Note: This invariant is non-obvious and easy to violate. This would be a
1016- // more rigorous representation:
1017- //
1018- // normal: SmallVec<[(Pu128, BasicBlock); 1]>,
1019- // otherwise: BasicBlock,
1020- //
1021- // But it's important to have the targets in a sliceable type, because
1022- // target slices show up elsewhere. E.g. `TerminatorKind::InlineAsm` has a
1023- // boxed slice, and `TerminatorKind::FalseEdge` has a single target that
1024- // can be converted to a slice with `slice::from_ref`.
1025- //
1026- // Why does this matter? In functions like `TerminatorKind::successors` we
1027- // return `impl Iterator` and a non-slice-of-targets representation here
1028- // causes problems because multiple different concrete iterator types would
1029- // be involved and we would need a boxed trait object, which requires an
1030- // allocation, which is expensive if done frequently.
1031- pub ( super ) targets : SmallVec < [ BasicBlock ; 2 ] > ,
1007+ pub ( super ) normal : SmallVec < [ ( Pu128 , BasicBlock ) ; 1 ] > ,
1008+ pub ( super ) otherwise : BasicBlock ,
10321009}
10331010
10341011/// Action to be taken when a stack unwind happens.
0 commit comments