mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 22:54:00 +00:00
Auto merge of #16862 - matthiaskrgr:noclone, r=Veykril
internal: remove redundant clone()s
This commit is contained in:
commit
c1122c9eeb
8 changed files with 17 additions and 17 deletions
|
@ -966,7 +966,7 @@ pub fn iterate_method_candidates_dyn(
|
|||
// the methods by autoderef order of *receiver types*, not *self
|
||||
// types*.
|
||||
|
||||
let mut table = InferenceTable::new(db, env.clone());
|
||||
let mut table = InferenceTable::new(db, env);
|
||||
let ty = table.instantiate_canonical(ty.clone());
|
||||
let deref_chain = autoderef_method_receiver(&mut table, ty);
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ fn iterate_method_candidates_with_autoref(
|
|||
let ref_muted = Canonical {
|
||||
value: TyKind::Ref(Mutability::Mut, static_lifetime(), receiver_ty.value.clone())
|
||||
.intern(Interner),
|
||||
binders: receiver_ty.binders.clone(),
|
||||
binders: receiver_ty.binders,
|
||||
};
|
||||
|
||||
iterate_method_candidates_by_receiver(ref_muted, first_adjustment.with_autoref(Mutability::Mut))
|
||||
|
@ -1060,7 +1060,7 @@ fn iterate_method_candidates_by_receiver(
|
|||
name: Option<&Name>,
|
||||
mut callback: &mut dyn FnMut(ReceiverAdjustments, AssocItemId, bool) -> ControlFlow<()>,
|
||||
) -> ControlFlow<()> {
|
||||
let receiver_ty = table.instantiate_canonical(receiver_ty.clone());
|
||||
let receiver_ty = table.instantiate_canonical(receiver_ty);
|
||||
// We're looking for methods with *receiver* type receiver_ty. These could
|
||||
// be found in any of the derefs of receiver_ty, so we have to go through
|
||||
// that, including raw derefs.
|
||||
|
@ -1456,7 +1456,7 @@ fn is_valid_trait_method_candidate(
|
|||
if let Some(receiver_ty) = receiver_ty {
|
||||
check_that!(data.has_self_param());
|
||||
|
||||
let fn_subst = TyBuilder::subst_for_def(db, fn_id, Some(impl_subst.clone()))
|
||||
let fn_subst = TyBuilder::subst_for_def(db, fn_id, Some(impl_subst))
|
||||
.fill_with_inference_vars(table)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
|
|||
if let Some(syntax_ptr) = body_source_map.self_param_syntax() {
|
||||
let root = db.parse_or_expand(syntax_ptr.file_id);
|
||||
let node = syntax_ptr.map(|ptr| ptr.to_node(&root).syntax().clone());
|
||||
types.push((node.clone(), ty));
|
||||
types.push((node, ty));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1099,7 +1099,7 @@ impl Field {
|
|||
VariantDef::Union(it) => it.id.into(),
|
||||
VariantDef::Variant(it) => it.parent_enum(db).id.into(),
|
||||
};
|
||||
let mut generics = generics.map(|it| it.ty.clone());
|
||||
let mut generics = generics.map(|it| it.ty);
|
||||
let substs = TyBuilder::subst_for_def(db, def_id, None)
|
||||
.fill(|x| match x {
|
||||
ParamKind::Type => {
|
||||
|
@ -1440,7 +1440,7 @@ impl Adt {
|
|||
/// the greatest API, FIXME find a better one.
|
||||
pub fn ty_with_args(self, db: &dyn HirDatabase, args: impl Iterator<Item = Type>) -> Type {
|
||||
let id = AdtId::from(self);
|
||||
let mut it = args.map(|t| t.ty.clone());
|
||||
let mut it = args.map(|t| t.ty);
|
||||
let ty = TyBuilder::def_ty(db, id.into(), None)
|
||||
.fill(|x| {
|
||||
let r = it.next().unwrap_or_else(|| TyKind::Error.intern(Interner));
|
||||
|
@ -1859,7 +1859,7 @@ impl Function {
|
|||
ItemContainerId::TraitId(it) => Some(it.into()),
|
||||
ItemContainerId::ModuleId(_) | ItemContainerId::ExternBlockId(_) => None,
|
||||
};
|
||||
let mut generics = generics.map(|it| it.ty.clone());
|
||||
let mut generics = generics.map(|it| it.ty);
|
||||
let mut filler = |x: &_| match x {
|
||||
ParamKind::Type => {
|
||||
generics.next().unwrap_or_else(|| TyKind::Error.intern(Interner)).cast(Interner)
|
||||
|
@ -1954,7 +1954,7 @@ impl Function {
|
|||
ItemContainerId::TraitId(it) => Some(it.into()),
|
||||
ItemContainerId::ModuleId(_) | ItemContainerId::ExternBlockId(_) => None,
|
||||
};
|
||||
let mut generics = generics.map(|it| it.ty.clone());
|
||||
let mut generics = generics.map(|it| it.ty);
|
||||
let parent_substs = parent_id.map(|id| {
|
||||
TyBuilder::subst_for_def(db, id, None)
|
||||
.fill(|x| match x {
|
||||
|
@ -2215,7 +2215,7 @@ impl SelfParam {
|
|||
}
|
||||
};
|
||||
|
||||
let mut generics = generics.map(|it| it.ty.clone());
|
||||
let mut generics = generics.map(|it| it.ty);
|
||||
let mut filler = |x: &_| match x {
|
||||
ParamKind::Type => {
|
||||
generics.next().unwrap_or_else(|| TyKind::Error.intern(Interner)).cast(Interner)
|
||||
|
|
|
@ -177,7 +177,7 @@ pub(super) fn type_constructor<'a, DB: HirDatabase>(
|
|||
// Note that we need special case for 0 param constructors because of multi cartesian
|
||||
// product
|
||||
let variant_exprs: Vec<Expr> = if param_exprs.is_empty() {
|
||||
vec![Expr::Variant { variant, generics: generics.clone(), params: Vec::new() }]
|
||||
vec![Expr::Variant { variant, generics, params: Vec::new() }]
|
||||
} else {
|
||||
param_exprs
|
||||
.into_iter()
|
||||
|
|
|
@ -312,7 +312,7 @@ pub(crate) fn render_expr(
|
|||
None => ctx.source_range(),
|
||||
};
|
||||
|
||||
let mut item = CompletionItem::new(CompletionItemKind::Expression, source_range, label.clone());
|
||||
let mut item = CompletionItem::new(CompletionItemKind::Expression, source_range, label);
|
||||
|
||||
let snippet = format!(
|
||||
"{}$0",
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) fn remove_unnecessary_else(
|
|||
fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option<Vec<Assist>> {
|
||||
let root = ctx.sema.db.parse_or_expand(d.if_expr.file_id);
|
||||
let if_expr = d.if_expr.value.to_node(&root);
|
||||
let if_expr = ctx.sema.original_ast_node(if_expr.clone())?;
|
||||
let if_expr = ctx.sema.original_ast_node(if_expr)?;
|
||||
|
||||
let mut indent = IndentLevel::from_node(if_expr.syntax());
|
||||
let has_parent_if_expr = if_expr.syntax().parent().and_then(ast::IfExpr::cast).is_some();
|
||||
|
|
|
@ -399,9 +399,9 @@ pub fn diagnostics(
|
|||
.iter_mut()
|
||||
.filter_map(|it| {
|
||||
Some((
|
||||
it.main_node
|
||||
.map(|ptr| ptr.map(|node| node.to_node(&ctx.sema.parse_or_expand(ptr.file_id))))
|
||||
.clone()?,
|
||||
it.main_node.map(|ptr| {
|
||||
ptr.map(|node| node.to_node(&ctx.sema.parse_or_expand(ptr.file_id)))
|
||||
})?,
|
||||
it,
|
||||
))
|
||||
})
|
||||
|
|
|
@ -76,7 +76,7 @@ impl Tester {
|
|||
);
|
||||
|
||||
let workspace = ProjectWorkspace::DetachedFiles {
|
||||
files: vec![tmp_file.clone()],
|
||||
files: vec![tmp_file],
|
||||
sysroot,
|
||||
rustc_cfg: vec![],
|
||||
toolchain: None,
|
||||
|
|
Loading…
Reference in a new issue