We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
unwrap
1 parent abacaf2 commit 2e53625Copy full SHA for 2e53625
compiler/rustc_middle/src/ty/consts/int.rs
@@ -265,7 +265,10 @@ macro_rules! try_from {
265
type Error = Size;
266
#[inline]
267
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())
+ // 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())
272
}
273
274
)*
0 commit comments