diff --git a/crates/nu-command/src/system/registry_query.rs b/crates/nu-command/src/system/registry_query.rs index 5cb5f9d29d..90bc14bb15 100644 --- a/crates/nu-command/src/system/registry_query.rs +++ b/crates/nu-command/src/system/registry_query.rs @@ -308,16 +308,21 @@ fn reg_value_to_nu_list_string(reg_value: winreg::RegValue, call_span: Span) -> } fn reg_value_to_nu_int(reg_value: winreg::RegValue, call_span: Span) -> nu_protocol::Value { - let value = match reg_value.vtype { - REG_DWORD => u32::from_reg_value(®_value).unwrap() as i64, - REG_DWORD_BIG_ENDIAN => { - // winreg (v0.51.0) doesn't natively decode REG_DWORD_BIG_ENDIAN - u32::from_be_bytes(unsafe { *reg_value.bytes.as_ptr().cast() }) as i64 - } - REG_QWORD => u64::from_reg_value(®_value).unwrap() as i64, - _ => unreachable!( - "registry value type should be REG_DWORD, REG_DWORD_BIG_ENDIAN, or REG_QWORD" - ), - }; + let value = + match reg_value.vtype { + // See discussion here https://github.com/nushell/nushell/pull/10806#issuecomment-1791832088 + // "The unwraps here are effectively infallible...", so I changed them to expects. + REG_DWORD => u32::from_reg_value(®_value) + .expect("registry value type should be REG_DWORD") as i64, + REG_DWORD_BIG_ENDIAN => { + // winreg (v0.51.0) doesn't natively decode REG_DWORD_BIG_ENDIAN + u32::from_be_bytes(unsafe { *reg_value.bytes.as_ptr().cast() }) as i64 + } + REG_QWORD => u64::from_reg_value(®_value) + .expect("registry value type should be REG_QWORD") as i64, + _ => unreachable!( + "registry value type should be REG_DWORD, REG_DWORD_BIG_ENDIAN, or REG_QWORD" + ), + }; Value::int(value, call_span) }