diff options
| author | Kornel <kornel@geekhood.net> | 2025-02-11 11:04:43 +0000 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2025-02-14 12:00:13 +0000 |
| commit | 00964aa401214ceab23d232b7d819b9b3286343f (patch) | |
| tree | 2d4afeea36f85d3587ce183736060ff42181d5a5 /library/std/src/sys | |
| parent | d88ffcdb8bfc6f8b917574c1693eb9764a20eff5 (diff) | |
| download | rust-00964aa401214ceab23d232b7d819b9b3286343f.tar.gz rust-00964aa401214ceab23d232b7d819b9b3286343f.zip | |
Add safe new to NotAllOnes
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/pal/solid/fs.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/library/std/src/sys/pal/solid/fs.rs b/library/std/src/sys/pal/solid/fs.rs index fa2e470d6b6..cc424141ea8 100644 --- a/library/std/src/sys/pal/solid/fs.rs +++ b/library/std/src/sys/pal/solid/fs.rs @@ -22,12 +22,9 @@ struct FileDesc { impl FileDesc { #[inline] + #[track_caller] fn new(fd: c_int) -> FileDesc { - assert_ne!(fd, -1i32); - // Safety: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - let fd = unsafe { CIntNotMinusOne::new_unchecked(fd) }; - FileDesc { fd } + FileDesc { fd: CIntNotMinusOne::new(fd).expect("fd != -1") } } #[inline] |
