Skip to content

Commit 2bf307a

Browse files
cranelift-entity: track_caller for PackedOption (bytecodealliance#9083)
This commit adds the `#[track_caller]` attribute to `PackedOption::unwrap` and `PackedOption::expect`. Using this attribute greatly improves the panic message of any `.expect` or `.unwrap` on a `PackedOption` by using the caller's location, not the location within `cranelift-entity`.
1 parent 25ea52a commit 2bf307a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cranelift/entity/src/packed_option.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ impl<T: ReservedValue> PackedOption<T> {
5555
}
5656

5757
/// Unwrap a packed `Some` value or panic.
58+
#[track_caller]
5859
pub fn unwrap(self) -> T {
5960
self.expand().unwrap()
6061
}
6162

6263
/// Unwrap a packed `Some` value or panic.
64+
#[track_caller]
6365
pub fn expect(self, msg: &str) -> T {
6466
self.expand().expect(msg)
6567
}

0 commit comments

Comments
 (0)