mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
remove redundant clones
This commit is contained in:
parent
f595e60b6d
commit
476e10e961
23 changed files with 34 additions and 34 deletions
|
@ -164,7 +164,7 @@ fn layout_of_simd_ty(
|
|||
};
|
||||
|
||||
// Compute the ABI of the element type:
|
||||
let e_ly = db.layout_of_ty(e_ty, env.clone())?;
|
||||
let e_ly = db.layout_of_ty(e_ty, env)?;
|
||||
let Abi::Scalar(e_abi) = e_ly.abi else {
|
||||
return Err(LayoutError::Unknown);
|
||||
};
|
||||
|
@ -204,17 +204,17 @@ pub fn layout_of_ty_query(
|
|||
};
|
||||
let cx = LayoutCx { target: &target };
|
||||
let dl = &*cx.current_data_layout();
|
||||
let ty = normalize(db, trait_env.clone(), ty.clone());
|
||||
let ty = normalize(db, trait_env.clone(), ty);
|
||||
let result = match ty.kind(Interner) {
|
||||
TyKind::Adt(AdtId(def), subst) => {
|
||||
if let hir_def::AdtId::StructId(s) = def {
|
||||
let data = db.struct_data(*s);
|
||||
let repr = data.repr.unwrap_or_default();
|
||||
if repr.simd() {
|
||||
return layout_of_simd_ty(db, *s, subst, trait_env.clone(), &target);
|
||||
return layout_of_simd_ty(db, *s, subst, trait_env, &target);
|
||||
}
|
||||
};
|
||||
return db.layout_of_adt(*def, subst.clone(), trait_env.clone());
|
||||
return db.layout_of_adt(*def, subst.clone(), trait_env);
|
||||
}
|
||||
TyKind::Scalar(s) => match s {
|
||||
chalk_ir::Scalar::Bool => Layout::scalar(
|
||||
|
@ -280,7 +280,7 @@ pub fn layout_of_ty_query(
|
|||
}
|
||||
TyKind::Array(element, count) => {
|
||||
let count = try_const_usize(db, &count).ok_or(LayoutError::HasErrorConst)? as u64;
|
||||
let element = db.layout_of_ty(element.clone(), trait_env.clone())?;
|
||||
let element = db.layout_of_ty(element.clone(), trait_env)?;
|
||||
let size = element.size.checked_mul(count, dl).ok_or(LayoutError::SizeOverflow)?;
|
||||
|
||||
let abi = if count != 0 && matches!(element.abi, Abi::Uninhabited) {
|
||||
|
@ -303,7 +303,7 @@ pub fn layout_of_ty_query(
|
|||
}
|
||||
}
|
||||
TyKind::Slice(element) => {
|
||||
let element = db.layout_of_ty(element.clone(), trait_env.clone())?;
|
||||
let element = db.layout_of_ty(element.clone(), trait_env)?;
|
||||
Layout {
|
||||
variants: Variants::Single { index: struct_variant_idx() },
|
||||
fields: FieldsShape::Array { stride: element.size, count: 0 },
|
||||
|
@ -345,7 +345,7 @@ pub fn layout_of_ty_query(
|
|||
}))
|
||||
.intern(Interner);
|
||||
}
|
||||
unsized_part = normalize(db, trait_env.clone(), unsized_part);
|
||||
unsized_part = normalize(db, trait_env, unsized_part);
|
||||
let metadata = match unsized_part.kind(Interner) {
|
||||
TyKind::Slice(_) | TyKind::Str => {
|
||||
scalar_unit(dl, Primitive::Int(dl.ptr_sized_integer(), false))
|
||||
|
@ -384,7 +384,7 @@ pub fn layout_of_ty_query(
|
|||
match impl_trait_id {
|
||||
crate::ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||
let infer = db.infer(func.into());
|
||||
return db.layout_of_ty(infer.type_of_rpit[idx].clone(), trait_env.clone());
|
||||
return db.layout_of_ty(infer.type_of_rpit[idx].clone(), trait_env);
|
||||
}
|
||||
crate::ImplTraitId::AsyncBlockTypeImplTrait(_, _) => {
|
||||
return Err(LayoutError::NotImplemented)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue