Fix multiple deprecation problems

This commit is contained in:
Zhang Junyang
2024-06-20 16:09:42 +00:00
committed by Tate, Hongliang Tian
parent cda8ffa7da
commit 952fbacaf1
8 changed files with 28 additions and 18 deletions

View File

@ -3,7 +3,7 @@
#![allow(dead_code)]
#![allow(unused_variables)]
use core::ops::Range;
use core::{fmt::Display, ops::Range};
use aster_frame::mm::VmIo;
use aster_rights::Full;
@ -737,9 +737,9 @@ impl ExfatName {
}
}
impl ToString for ExfatName {
fn to_string(&self) -> String {
String::from_utf16_lossy(&self.0)
impl Display for ExfatName {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", String::from_utf16_lossy(&self.0))
}
}

View File

@ -481,6 +481,8 @@ impl ExfatInodeInner {
target_name.to_string()
};
// FIXME: This isn't expected by the compiler.
#[allow(non_local_definitions)]
impl DirentVisitor for Vec<(String, usize)> {
fn visit(
&mut self,
@ -992,6 +994,8 @@ impl ExfatInode {
let new_parent_hash = self.hash_index();
let sub_dir = inner.num_sub_inodes;
let mut child_offsets: Vec<usize> = vec![];
// FIXME: This isn't expected by the compiler.
#[allow(non_local_definitions)]
impl DirentVisitor for Vec<usize> {
fn visit(
&mut self,

View File

@ -118,7 +118,7 @@ impl InodeHandle_ {
let mut offset = self.offset.lock();
let new_offset: isize = match pos {
SeekFrom::Start(off /* as usize */) => {
if off > isize::max_value() as usize {
if off > isize::MAX as usize {
return_errno_with_message!(Errno::EINVAL, "file offset is too large");
}
off as isize
@ -137,7 +137,7 @@ impl InodeHandle_ {
if new_offset < 0 {
return_errno_with_message!(Errno::EINVAL, "file offset must not be negative");
}
// Invariant: 0 <= new_offset <= isize::max_value()
// Invariant: 0 <= new_offset <= isize::MAX
let new_offset = new_offset as usize;
*offset = new_offset;
Ok(new_offset)

View File

@ -351,12 +351,12 @@ impl DirInMemory {
match old {
DentryInMemory::Dir(ref mut dir) => {
dir.inode = lookup_new_inode_result.unwrap();
dir.name = new_name.clone();
dir.name.clone_from(new_name);
dir.depth = self.depth + 1;
}
DentryInMemory::File(ref mut file) => {
file.inode = lookup_new_inode_result.unwrap();
file.name = new_name.clone();
file.name.clone_from(new_name);
}
}
if exist {

View File

@ -67,10 +67,7 @@ pub struct RLimit64 {
impl RLimit64 {
pub fn new(cur: u64) -> Self {
Self {
cur,
max: u64::max_value(),
}
Self { cur, max: u64::MAX }
}
pub fn get_cur(&self) -> u64 {
@ -85,8 +82,8 @@ impl RLimit64 {
impl Default for RLimit64 {
fn default() -> Self {
Self {
cur: u64::max_value(),
max: u64::max_value(),
cur: u64::MAX,
max: u64::MAX,
}
}
}

View File

@ -69,11 +69,15 @@ pub fn expand_require(item: RequireItem, mut require_attr: RequireAttr) -> Token
match item {
RequireItem::Impl(item_impl) => {
let new_item_impl = require_attr.fold_item_impl(item_impl);
quote!(#new_item_impl)
quote!(
#[allow(clippy::multiple_bound_locations)]
#new_item_impl
)
}
RequireItem::Fn(item_fn) => {
let new_item_fn = require_attr.fold_item_fn(item_fn);
quote!(
#[allow(clippy::multiple_bound_locations)]
#new_item_fn
)
}

View File

@ -152,7 +152,7 @@ fn match_and_call(
} else {
panic!("The path of {} cannot recognized by component system", str);
}
str = str.trim_end_matches('/').to_owned();
let str = str.trim_end_matches('/').to_owned();
let mut info = components
.remove(&str)

View File

@ -190,7 +190,9 @@ impl<T: ?Sized> Eq for KeyableArc<T> {}
impl<T: ?Sized> Ord for KeyableArc<T> {
fn cmp(&self, other: &Self) -> Ordering {
Arc::as_ptr(&self.0).cmp(&Arc::as_ptr(&other.0))
Arc::as_ptr(&self.0)
.cast::<()>()
.cmp(&Arc::as_ptr(&other.0).cast::<()>())
}
}
@ -281,7 +283,10 @@ impl<T: ?Sized> Eq for KeyableWeak<T> {}
impl<T: ?Sized> Ord for KeyableWeak<T> {
fn cmp(&self, other: &Self) -> Ordering {
self.0.as_ptr().cmp(&other.0.as_ptr())
self.0
.as_ptr()
.cast::<()>()
.cmp(&other.0.as_ptr().cast::<()>())
}
}