Skip to content

Commit 2e53625

Browse files
committed
Document an unwrap
1 parent abacaf2 commit 2e53625

File tree

1 file changed

+4
-1
lines changed
  • compiler/rustc_middle/src/ty/consts

1 file changed

+4
-1
lines changed

compiler/rustc_middle/src/ty/consts/int.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ macro_rules! try_from {
265265
type Error = Size;
266266
#[inline]
267267
fn try_from(int: ScalarInt) -> Result<Self, Size> {
268-
int.to_bits(Size::from_bytes(std::mem::size_of::<$ty>())).map(|u| u.try_into().unwrap())
268+
// The `unwrap` cannot fail because to_bits (if it succeeds)
269+
// is guaranteed to return a value that fits into the size.
270+
int.to_bits(Size::from_bytes(std::mem::size_of::<$ty>()))
271+
.map(|u| u.try_into().unwrap())
269272
}
270273
}
271274
)*

0 commit comments

Comments
 (0)