Skip to content

Commit d6f5175

Browse files
author
Lukas Markeffsky
committed
tweak valtree unwrappers inlining
1 parent f11504e commit d6f5175

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: compiler/rustc_middle/src/ty/consts/valtree.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,29 @@ pub enum ValTreeKind<'tcx> {
4242

4343
impl<'tcx> ValTreeKind<'tcx> {
4444
#[inline]
45+
#[track_caller]
4546
pub fn unwrap_leaf(&self) -> ScalarInt {
4647
match self {
4748
Self::Leaf(s) => *s,
48-
_ => bug!("expected leaf, got {:?}", self),
49+
_ => self.unwrap_failed(),
4950
}
5051
}
5152

5253
#[inline]
54+
#[track_caller]
5355
pub fn unwrap_branch(&self) -> &[ValTree<'tcx>] {
5456
match self {
5557
Self::Branch(branch) => &**branch,
56-
_ => bug!("expected branch, got {:?}", self),
58+
_ => self.unwrap_failed(),
5759
}
5860
}
5961

62+
#[inline(never)]
63+
#[track_caller]
64+
fn unwrap_failed(&self) -> ! {
65+
bug!("unexpected valtree kind, got {self:?}")
66+
}
67+
6068
pub fn try_to_scalar(&self) -> Option<Scalar> {
6169
self.try_to_scalar_int().map(Scalar::Int)
6270
}

0 commit comments

Comments
 (0)