mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Clippy trivially_copy_pass_by_ref
This commit is contained in:
parent
ec6f71576a
commit
001e34e6e3
11 changed files with 30 additions and 30 deletions
|
@ -34,8 +34,8 @@ impl AdtDef {
|
|||
}
|
||||
|
||||
impl Struct {
|
||||
pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.struct_data(*self).variant_data.clone()
|
||||
pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.struct_data(self).variant_data.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ fn variants(enum_def: &ast::EnumDef) -> impl Iterator<Item = &ast::EnumVariant>
|
|||
|
||||
impl EnumVariant {
|
||||
pub(crate) fn source_impl(
|
||||
&self,
|
||||
self,
|
||||
db: &(impl DefDatabase + AstDatabase),
|
||||
) -> Source<TreeArc<ast::EnumVariant>> {
|
||||
let src = self.parent.source(db);
|
||||
|
@ -81,7 +81,7 @@ impl EnumVariant {
|
|||
.to_owned();
|
||||
Source { file_id: src.file_id, ast }
|
||||
}
|
||||
pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.enum_data(self.parent).variants[self.id].variant_data.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
let body = self.func.body(db);
|
||||
for e in body.exprs() {
|
||||
if let (id, Expr::StructLit { path, fields, spread }) = e {
|
||||
self.validate_struct_literal(id, path, fields, spread, db);
|
||||
self.validate_struct_literal(id, path, fields, *spread, db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
id: ExprId,
|
||||
_path: &Option<Path>,
|
||||
fields: &[StructLitField],
|
||||
spread: &Option<ExprId>,
|
||||
spread: Option<ExprId>,
|
||||
db: &impl HirDatabase,
|
||||
) {
|
||||
if spread.is_some() {
|
||||
|
|
|
@ -359,8 +359,8 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId {
|
|||
}
|
||||
|
||||
impl MacroCallId {
|
||||
pub fn debug_dump(&self, db: &impl AstDatabase) -> String {
|
||||
let loc = self.clone().loc(db);
|
||||
pub fn debug_dump(self, db: &impl AstDatabase) -> String {
|
||||
let loc = self.loc(db);
|
||||
let node = loc.ast_id.to_node(db);
|
||||
let syntax_str = node.syntax().text().chunks().collect::<Vec<_>>().join(" ");
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ enum BindingMode {
|
|||
}
|
||||
|
||||
impl BindingMode {
|
||||
pub fn convert(annotation: &BindingAnnotation) -> BindingMode {
|
||||
pub fn convert(annotation: BindingAnnotation) -> BindingMode {
|
||||
match annotation {
|
||||
BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move,
|
||||
BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared),
|
||||
|
@ -778,7 +778,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
let mode = if mode == &BindingAnnotation::Unannotated {
|
||||
default_bm
|
||||
} else {
|
||||
BindingMode::convert(mode)
|
||||
BindingMode::convert(*mode)
|
||||
};
|
||||
let inner_ty = if let Some(subpat) = subpat {
|
||||
self.infer_pat(*subpat, expected, default_bm)
|
||||
|
|
|
@ -58,7 +58,7 @@ impl CrateImplBlocks {
|
|||
|
||||
pub fn lookup_impl_blocks_for_trait<'a>(
|
||||
&'a self,
|
||||
tr: &Trait,
|
||||
tr: Trait,
|
||||
) -> impl Iterator<Item = ImplBlock> + 'a {
|
||||
self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map(
|
||||
move |(module_id, impl_id)| {
|
||||
|
@ -68,8 +68,8 @@ impl CrateImplBlocks {
|
|||
)
|
||||
}
|
||||
|
||||
fn collect_recursive(&mut self, db: &impl HirDatabase, module: &Module) {
|
||||
let module_impl_blocks = db.impls_in_module(module.clone());
|
||||
fn collect_recursive(&mut self, db: &impl HirDatabase, module: Module) {
|
||||
let module_impl_blocks = db.impls_in_module(module);
|
||||
|
||||
for (impl_id, _) in module_impl_blocks.impls.iter() {
|
||||
let impl_block = ImplBlock::from_id(module_impl_blocks.module, impl_id);
|
||||
|
@ -94,7 +94,7 @@ impl CrateImplBlocks {
|
|||
}
|
||||
|
||||
for child in module.children(db) {
|
||||
self.collect_recursive(db, &child);
|
||||
self.collect_recursive(db, child);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ impl CrateImplBlocks {
|
|||
impls_by_trait: FxHashMap::default(),
|
||||
};
|
||||
if let Some(module) = krate.root_module(db) {
|
||||
crate_impl_blocks.collect_recursive(db, &module);
|
||||
crate_impl_blocks.collect_recursive(db, module);
|
||||
}
|
||||
Arc::new(crate_impl_blocks)
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ impl IntTy {
|
|||
IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 }
|
||||
}
|
||||
|
||||
pub(crate) fn ty_to_string(&self) -> &'static str {
|
||||
pub(crate) fn ty_to_string(self) -> &'static str {
|
||||
match (self.signedness, self.bitness) {
|
||||
(Signedness::Signed, IntBitness::Xsize) => "isize",
|
||||
(Signedness::Signed, IntBitness::X8) => "i8",
|
||||
|
|
|
@ -50,7 +50,7 @@ pub(crate) fn impls_for_trait_query(
|
|||
impls.extend(db.impls_for_trait(dep.krate, trait_).iter());
|
||||
}
|
||||
let crate_impl_blocks = db.impls_in_crate(krate);
|
||||
impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(&trait_));
|
||||
impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(trait_));
|
||||
impls.into_iter().collect::<Vec<_>>().into()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue