clippy: Enable borrowed_box rule

This commit is contained in:
Tetsuharu Ohzeki 2024-02-09 23:56:47 +09:00
parent d45cabd029
commit c6637f39c0
3 changed files with 7 additions and 6 deletions

View File

@ -168,7 +168,6 @@ new_ret_no_self = "allow"
useless_asref = "allow" useless_asref = "allow"
## Following lints should be tackled at some point ## Following lints should be tackled at some point
borrowed_box = "allow"
too_many_arguments = "allow" too_many_arguments = "allow"
type_complexity = "allow" type_complexity = "allow"
wrong_self_convention = "allow" wrong_self_convention = "allow"

View File

@ -264,7 +264,7 @@ fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx<'_>, where_clause: ast:
self.add_where_predicate_from_bound( self.add_where_predicate_from_bound(
lower_ctx, lower_ctx,
bound, bound,
lifetimes.as_ref(), lifetimes.as_deref(),
target.clone(), target.clone(),
); );
} }
@ -275,14 +275,14 @@ fn add_where_predicate_from_bound(
&mut self, &mut self,
lower_ctx: &LowerCtx<'_>, lower_ctx: &LowerCtx<'_>,
bound: ast::TypeBound, bound: ast::TypeBound,
hrtb_lifetimes: Option<&Box<[Name]>>, hrtb_lifetimes: Option<&[Name]>,
target: Either<TypeRef, LifetimeRef>, target: Either<TypeRef, LifetimeRef>,
) { ) {
let bound = TypeBound::from_ast(lower_ctx, bound); let bound = TypeBound::from_ast(lower_ctx, bound);
let predicate = match (target, bound) { let predicate = match (target, bound) {
(Either::Left(type_ref), bound) => match hrtb_lifetimes { (Either::Left(type_ref), bound) => match hrtb_lifetimes {
Some(hrtb_lifetimes) => WherePredicate::ForLifetime { Some(hrtb_lifetimes) => WherePredicate::ForLifetime {
lifetimes: hrtb_lifetimes.clone(), lifetimes: hrtb_lifetimes.to_vec().into_boxed_slice(),
target: WherePredicateTypeTarget::TypeRef(Interned::new(type_ref)), target: WherePredicateTypeTarget::TypeRef(Interned::new(type_ref)),
bound: Interned::new(bound), bound: Interned::new(bound),
}, },

View File

@ -228,7 +228,7 @@ fn transform_addresses(
&self, &self,
mut f: impl FnMut(&[u8], usize) -> Result<usize, MirEvalError>, mut f: impl FnMut(&[u8], usize) -> Result<usize, MirEvalError>,
) -> Result<FxHashMap<usize, usize>, MirEvalError> { ) -> Result<FxHashMap<usize, usize>, MirEvalError> {
let mut transform = |(addr, val): (&usize, &Box<[u8]>)| { let mut transform = |(addr, val): (&usize, &[u8])| {
let addr = *addr; let addr = *addr;
let align = if addr == 0 { 64 } else { (addr - (addr & (addr - 1))).min(64) }; let align = if addr == 0 { 64 } else { (addr - (addr & (addr - 1))).min(64) };
f(val, align).map(|it| (addr, it)) f(val, align).map(|it| (addr, it))
@ -240,7 +240,9 @@ fn transform_addresses(
map.insert(addr, val); map.insert(addr, val);
map map
}), }),
MemoryMap::Complex(cm) => cm.memory.iter().map(transform).collect(), MemoryMap::Complex(cm) => {
cm.memory.iter().map(|(addr, val)| transform((addr, val))).collect()
}
} }
} }