mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-18 11:20:36 +00:00
remove a couple of clones
This commit is contained in:
parent
6c9cf51c55
commit
573c47c9ba
32 changed files with 71 additions and 90 deletions
|
|
@ -3685,24 +3685,16 @@ impl GenericDef {
|
|||
}
|
||||
|
||||
let source_map = match def {
|
||||
GenericDefId::AdtId(AdtId::EnumId(it)) => {
|
||||
db.enum_signature_with_source_map(it).1.clone()
|
||||
}
|
||||
GenericDefId::AdtId(AdtId::StructId(it)) => {
|
||||
db.struct_signature_with_source_map(it).1.clone()
|
||||
}
|
||||
GenericDefId::AdtId(AdtId::UnionId(it)) => {
|
||||
db.union_signature_with_source_map(it).1.clone()
|
||||
}
|
||||
GenericDefId::AdtId(AdtId::EnumId(it)) => db.enum_signature_with_source_map(it).1,
|
||||
GenericDefId::AdtId(AdtId::StructId(it)) => db.struct_signature_with_source_map(it).1,
|
||||
GenericDefId::AdtId(AdtId::UnionId(it)) => db.union_signature_with_source_map(it).1,
|
||||
GenericDefId::ConstId(_) => return,
|
||||
GenericDefId::FunctionId(it) => db.function_signature_with_source_map(it).1.clone(),
|
||||
GenericDefId::ImplId(it) => db.impl_signature_with_source_map(it).1.clone(),
|
||||
GenericDefId::FunctionId(it) => db.function_signature_with_source_map(it).1,
|
||||
GenericDefId::ImplId(it) => db.impl_signature_with_source_map(it).1,
|
||||
GenericDefId::StaticId(_) => return,
|
||||
GenericDefId::TraitAliasId(it) => {
|
||||
db.trait_alias_signature_with_source_map(it).1.clone()
|
||||
}
|
||||
GenericDefId::TraitId(it) => db.trait_signature_with_source_map(it).1.clone(),
|
||||
GenericDefId::TypeAliasId(it) => db.type_alias_signature_with_source_map(it).1.clone(),
|
||||
GenericDefId::TraitAliasId(it) => db.trait_alias_signature_with_source_map(it).1,
|
||||
GenericDefId::TraitId(it) => db.trait_signature_with_source_map(it).1,
|
||||
GenericDefId::TypeAliasId(it) => db.type_alias_signature_with_source_map(it).1,
|
||||
};
|
||||
|
||||
expr_store_diagnostics(db, acc, &source_map);
|
||||
|
|
@ -3802,7 +3794,7 @@ impl GenericSubstitution {
|
|||
container_params
|
||||
.chain(self_params)
|
||||
.filter_map(|(ty, name)| {
|
||||
Some((name?.symbol().clone(), Type { ty: ty.clone(), env: self.env.clone() }))
|
||||
Some((name?.symbol().clone(), Type { ty, env: self.env.clone() }))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,7 +926,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
token: InRealFile<SyntaxToken>,
|
||||
mut cb: impl FnMut(InFile<SyntaxToken>, SyntaxContext) -> ControlFlow<T>,
|
||||
) -> Option<T> {
|
||||
self.descend_into_macros_impl(token.clone(), &mut cb)
|
||||
self.descend_into_macros_impl(token, &mut cb)
|
||||
}
|
||||
|
||||
/// Descends the token into expansions, returning the tokens that matches the input
|
||||
|
|
@ -958,17 +958,13 @@ impl<'db> SemanticsImpl<'db> {
|
|||
let text = token.text();
|
||||
let kind = token.kind();
|
||||
if let Ok(token) = self.wrap_token_infile(token.clone()).into_real_file() {
|
||||
self.descend_into_macros_breakable(
|
||||
token.clone(),
|
||||
|InFile { value, file_id: _ }, _ctx| {
|
||||
let mapped_kind = value.kind();
|
||||
let any_ident_match =
|
||||
|| kind.is_any_identifier() && value.kind().is_any_identifier();
|
||||
let matches =
|
||||
(kind == mapped_kind || any_ident_match()) && text == value.text();
|
||||
if matches { ControlFlow::Break(value) } else { ControlFlow::Continue(()) }
|
||||
},
|
||||
)
|
||||
self.descend_into_macros_breakable(token, |InFile { value, file_id: _ }, _ctx| {
|
||||
let mapped_kind = value.kind();
|
||||
let any_ident_match =
|
||||
|| kind.is_any_identifier() && value.kind().is_any_identifier();
|
||||
let matches = (kind == mapped_kind || any_ident_match()) && text == value.text();
|
||||
if matches { ControlFlow::Break(value) } else { ControlFlow::Continue(()) }
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ impl SourceToDefCtx<'_, '_> {
|
|||
let item = match ast::Item::cast(value.clone()) {
|
||||
Some(it) => it,
|
||||
None => {
|
||||
let variant = ast::Variant::cast(value.clone())?;
|
||||
let variant = ast::Variant::cast(value)?;
|
||||
return this
|
||||
.enum_variant_to_def(InFile::new(file_id, &variant))
|
||||
.map(Into::into);
|
||||
|
|
|
|||
|
|
@ -1431,7 +1431,7 @@ impl SourceAnalyzer {
|
|||
}
|
||||
|
||||
fn ty_of_expr(&self, expr: ast::Expr) -> Option<&Ty> {
|
||||
self.infer()?.type_of_expr_or_pat(self.expr_id(expr.clone())?)
|
||||
self.infer()?.type_of_expr_or_pat(self.expr_id(expr)?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue