Fix rust 1.80 warnings (#5363)

* Fix rust 1.80 warnings

* Fix nightly clippy warnings
This commit is contained in:
Jeong, YunWon
2024-07-28 10:43:40 +09:00
committed by GitHub
parent f1f05303db
commit b1a38c2d50
9 changed files with 20 additions and 28 deletions

View File

@@ -1,7 +1,6 @@
fn main() {
process_python_libs("../vm/Lib/python_builtins/*");
#[cfg(not(feature = "stdlib"))]
process_python_libs("../vm/Lib/core_modules/*");
#[cfg(feature = "freeze-stdlib")]
if cfg!(windows) {

View File

@@ -359,13 +359,7 @@ fn settings_from(matches: &ArgMatches) -> (Settings, RunMode) {
/// Get environment variable and turn it into integer.
fn get_env_var_value(name: &str) -> Result<u8, std::env::VarError> {
env::var(name).map(|value| {
if let Ok(value) = u8::from_str(&value) {
value
} else {
1
}
})
env::var(name).map(|value| u8::from_str(&value).unwrap_or(1))
}
/// Helper function to retrieve a sequence of paths from an environment variable.

View File

@@ -1,4 +1,10 @@
fn main() {
println!(r#"cargo::rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_COMP"))"#);
println!("cargo::rustc-check-cfg=cfg(ossl101)");
println!("cargo::rustc-check-cfg=cfg(ossl102)");
println!("cargo::rustc-check-cfg=cfg(ossl110)");
println!("cargo::rustc-check-cfg=cfg(ossl110g)");
println!("cargo::rustc-check-cfg=cfg(ossl111)");
#[allow(clippy::unusual_byte_groupings)]
if let Ok(v) = std::env::var("DEP_OPENSSL_VERSION_NUMBER") {
println!("cargo:rustc-env=OPENSSL_API_VERSION={v}");

View File

@@ -337,13 +337,12 @@ mod _socket {
target_os = "linux",
any(
target_arch = "aarch64",
target_arch = "i686",
target_arch = "x86",
target_arch = "loongarch64",
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le",
target_arch = "riscv64gc",
target_arch = "riscv64",
target_arch = "s390x",
target_arch = "x86_64"
)
@@ -388,13 +387,12 @@ mod _socket {
target_os = "linux",
any(
target_arch = "aarch64",
target_arch = "i686",
target_arch = "x86",
target_arch = "loongarch64",
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le",
target_arch = "riscv64gc",
target_arch = "riscv64",
target_arch = "s390x",
target_arch = "x86_64"
)

View File

@@ -494,6 +494,8 @@ impl PyObject {
/// A borrow of a reference to a Python object. This avoids having clone the `PyRef<T>`/
/// `PyObjectRef`, which isn't that cheap as that increments the atomic reference counter.
// TODO: check if we still need this
#[allow(dead_code)]
pub struct PyLease<'a, T: PyObjectPayload> {
inner: PyRwLockReadGuard<'a, PyRef<T>>,
}

View File

@@ -19,17 +19,12 @@ pub trait MaybeTraverse {
/// Type that need traverse it's children should impl `Traverse`(Not `MaybeTraverse`)
/// # Safety
/// impl `traverse()` with caution! Following those guideline so traverse doesn't cause memory error!:
/// - Make sure that every owned object(Every PyObjectRef/PyRef) is called with traverse_fn **at most once**.
/// If some field is not called, the worst results is just memory leak,
/// but if some field is called repeatedly, panic and deadlock can happen.
///
/// - _**DO NOT**_ clone a `PyObjectRef` or `Pyef<T>` in `traverse()`
/// Please carefully read [`traverse()`] and follow the guideline
pub unsafe trait Traverse {
/// impl `traverse()` with caution! Following those guideline so traverse doesn't cause memory error!:
/// - Make sure that every owned object(Every PyObjectRef/PyRef) is called with traverse_fn **at most once**.
/// If some field is not called, the worst results is just memory leak,
/// but if some field is called repeatedly, panic and deadlock can happen.
/// If some field is not called, the worst results is just memory leak,
/// but if some field is called repeatedly, panic and deadlock can happen.
///
/// - _**DO NOT**_ clone a `PyObjectRef` or `Pyef<T>` in `traverse()`
fn traverse(&self, traverse_fn: &mut TraverseFn);

View File

@@ -118,9 +118,8 @@ impl PyObject {
.class()
.mro_find_map(|cls| cls.slots.getattro.load())
.unwrap();
getattro(self, attr_name, vm).map_err(|exc| {
vm.set_attribute_error_context(&exc, self.to_owned(), attr_name.to_owned());
exc
getattro(self, attr_name, vm).inspect_err(|exc| {
vm.set_attribute_error_context(exc, self.to_owned(), attr_name.to_owned());
})
}

View File

@@ -871,10 +871,9 @@ pub mod module {
let (rfd, wfd) = pipe().map_err(|err| err.into_pyexception(vm))?;
set_inheritable(rfd, false, vm)
.and_then(|_| set_inheritable(wfd, false, vm))
.map_err(|err| {
.inspect_err(|_| {
let _ = close(rfd);
let _ = close(wfd);
err
})?;
Ok((rfd, wfd))
}

View File

@@ -302,7 +302,7 @@ mod decl {
Ok(get_thread_time(vm)?.as_nanos() as u64)
}
#[cfg(any(windows, all(target_arch = "wasm32", target_arch = "emscripten")))]
#[cfg(any(windows, all(target_arch = "wasm32", target_os = "emscripten")))]
pub(super) fn time_muldiv(ticks: i64, mul: i64, div: i64) -> u64 {
let intpart = ticks / div;
let ticks = ticks % div;