Visitar URL original
Fix more · RustPython/RustPython@37418c5 · GitHub
Skip to content

Commit 37418c5

Browse files
committed
Fix more
1 parent 840fc07 commit 37418c5

9 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎crates/common/src/static_cell.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ mod non_threading {
6767

6868
impl<T> StaticCell<T> {
6969
#[doc(hidden)]
70+
#[must_use]
7071
pub const fn _from_local_key(inner: &'static LocalKey<OnceCell<&'static T>>) -> Self {
7172
Self { inner }
7273
}
7374

75+
#[must_use]
7476
pub fn get(&'static self) -> Option<&'static T> {
7577
self.inner.with(|x| x.get().copied())
7678
}

‎crates/host_env/src/fileutils.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ pub mod windows {
352352
}
353353
}
354354

355+
#[must_use]
355356
pub fn stat_basic_info_to_stat(info: &FILE_STAT_BASIC_INFORMATION) -> StatStruct {
356357
use windows_sys::Win32::Storage::FileSystem;
357358
use windows_sys::Win32::System::Ioctl;

‎crates/host_env/src/msvcrt.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,25 @@ pub fn setmode_binary(fd: crt_fd::Borrowed<'_>) {
2929
unsafe { suppress_iph!(_setmode(fd, libc::O_BINARY)) };
3030
}
3131

32+
#[must_use]
3233
pub fn getch() -> Vec<u8> {
3334
vec![unsafe { _getch() } as u8]
3435
}
3536

37+
#[must_use]
3638
pub fn getwch() -> String {
3739
let value = unsafe { _getwch() };
3840
char::from_u32(value)
3941
.unwrap_or_else(|| panic!("invalid unicode {value:#x} from _getwch"))
4042
.to_string()
4143
}
4244

45+
#[must_use]
4346
pub fn getche() -> Vec<u8> {
4447
vec![unsafe { _getche() } as u8]
4548
}
4649

50+
#[must_use]
4751
pub fn getwche() -> String {
4852
let value = unsafe { _getwche() };
4953
char::from_u32(value)
@@ -77,6 +81,7 @@ pub fn ungetwch(c: char) -> io::Result<()> {
7781
}
7882
}
7983

84+
#[must_use]
8085
pub fn kbhit() -> i32 {
8186
unsafe { _kbhit() }
8287
}

‎crates/host_env/src/os.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl ErrorExt for io::Error {
102102
/// Get the last error from C runtime library functions (like _dup, _dup2, _fstat, etc.)
103103
/// CRT functions set errno, not GetLastError(), so we need to read errno directly.
104104
#[cfg(windows)]
105+
#[must_use]
105106
pub fn errno_io_error() -> io::Error {
106107
let errno: i32 = get_errno();
107108
let winerror = errno_to_winerror(errno);
@@ -213,6 +214,7 @@ pub mod ffi {
213214
}
214215

215216
#[cfg(windows)]
217+
#[must_use]
216218
pub fn errno_to_winerror(errno: i32) -> i32 {
217219
use libc::*;
218220
use windows_sys::Win32::Foundation::*;
@@ -242,6 +244,7 @@ pub fn errno_to_winerror(errno: i32) -> i32 {
242244
// winerror: https://learn.microsoft.com/windows/win32/debug/system-error-codes--0-499-
243245
// errno: https://learn.microsoft.com/cpp/c-runtime-library/errno-constants?view=msvc-170
244246
#[cfg(windows)]
247+
#[must_use]
245248
pub fn winerror_to_errno(winerror: i32) -> i32 {
246249
use libc::*;
247250
use windows_sys::Win32::{

‎crates/host_env/src/posix.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn set_inheritable(fd: BorrowedFd<'_>, inheritable: bool) -> nix::Result<()>
1313
}
1414

1515
#[cfg(target_os = "macos")]
16+
#[must_use]
1617
pub fn get_number_of_os_threads() -> isize {
1718
type MachPortT = libc::c_uint;
1819
type KernReturnT = libc::c_int;
@@ -60,6 +61,7 @@ pub fn get_number_of_os_threads() -> isize {
6061
}
6162

6263
#[cfg(target_os = "linux")]
64+
#[must_use]
6365
pub fn get_number_of_os_threads() -> isize {
6466
use std::io::Read as _;
6567

‎crates/host_env/src/time.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn duration_since_system_now() -> Result<Duration, SystemTimeError> {
1616

1717
#[cfg(target_env = "msvc")]
1818
#[cfg(not(target_arch = "wasm32"))]
19+
#[must_use]
1920
pub fn get_tz_info() -> windows_sys::Win32::System::Time::TIME_ZONE_INFORMATION {
2021
let mut info = unsafe { core::mem::zeroed() };
2122
unsafe { windows_sys::Win32::System::Time::GetTimeZoneInformation(&mut info) };

‎crates/host_env/src/winapi.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
use windows_sys::Win32::Foundation::HANDLE;
22

3+
#[must_use]
34
pub fn get_acp() -> u32 {
45
unsafe { windows_sys::Win32::Globalization::GetACP() }
56
}
67

8+
#[must_use]
79
pub fn get_current_process() -> HANDLE {
810
unsafe { windows_sys::Win32::System::Threading::GetCurrentProcess() }
911
}
1012

13+
#[must_use]
1114
pub fn get_last_error() -> u32 {
1215
unsafe { windows_sys::Win32::Foundation::GetLastError() }
1316
}
1417

18+
#[must_use]
1519
pub fn get_version() -> u32 {
1620
unsafe { windows_sys::Win32::System::SystemInformation::GetVersion() }
1721
}

‎crates/vm/src/exception_group.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fn create_exception_group(ctx: &Context) -> PyRef<PyType> {
3434
.expect("Failed to create ExceptionGroup type with multiple inheritance")
3535
}
3636

37+
#[must_use]
3738
pub fn exception_group() -> &'static Py<PyType> {
3839
::rustpython_vm::common::static_cell! {
3940
static CELL: ::rustpython_vm::builtins::PyTypeRef;

‎crates/vm/src/vm/context.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ impl Context {
288288
pub const INT_CACHE_POOL_RANGE: core::ops::RangeInclusive<i32> = (-5)..=256;
289289
const INT_CACHE_POOL_MIN: i32 = *Self::INT_CACHE_POOL_RANGE.start();
290290

291+
#[must_use]
291292
pub fn genesis() -> &'static PyRc<Self> {
292293
rustpython_common::static_cell! {
293294
static CONTEXT: PyRc<Context>;

0 commit comments

Comments
 (0)