From c9b4ac5be4daaabc062ab1ee663eba8594750003 Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:24:16 +0530 Subject: clippy::redudant_borrow --- crates/hir_def/src/body/lower.rs | 6 +++--- crates/hir_def/src/body/scope.rs | 2 +- crates/hir_def/src/generics.rs | 4 ++-- crates/hir_def/src/item_tree/lower.rs | 6 +++--- crates/hir_def/src/nameres/collector.rs | 12 ++++++------ crates/hir_def/src/nameres/path_resolution.rs | 12 ++++++------ crates/hir_def/src/path/lower.rs | 4 ++-- crates/hir_def/src/resolver.rs | 10 +++++----- crates/hir_def/src/type_ref.rs | 16 ++++++++-------- 9 files changed, 36 insertions(+), 36 deletions(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index da1fdac33..a8bd36a0a 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -1002,16 +1002,16 @@ impl From for Literal { if let builtin @ Some(_) = lit.suffix().and_then(BuiltinFloat::from_suffix) { return Literal::Float(Default::default(), builtin); } else if let builtin @ Some(_) = - lit.suffix().and_then(|it| BuiltinInt::from_suffix(&it)) + lit.suffix().and_then(|it| BuiltinInt::from_suffix(it)) { Literal::Int(lit.value().unwrap_or(0) as i128, builtin) } else { - let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(&it)); + let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(it)); Literal::Uint(lit.value().unwrap_or(0), builtin) } } LiteralKind::FloatNumber(lit) => { - let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(&it)); + let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(it)); Literal::Float(Default::default(), ty) } LiteralKind::ByteString(bs) => { diff --git a/crates/hir_def/src/body/scope.rs b/crates/hir_def/src/body/scope.rs index 6764de3a7..58a1fc81c 100644 --- a/crates/hir_def/src/body/scope.rs +++ b/crates/hir_def/src/body/scope.rs @@ -198,7 +198,7 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope } Expr::Lambda { args, body: body_expr, .. } => { let scope = scopes.new_scope(scope); - scopes.add_params_bindings(body, scope, &args); + scopes.add_params_bindings(body, scope, args); compute_expr_scopes(*body_expr, body, scopes, scope); } Expr::Match { expr, arms } => { diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 44d22b918..6933f6e3c 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs @@ -280,7 +280,7 @@ impl GenericParams { sm.type_params.insert(param_id, Either::Right(type_param.clone())); let type_ref = TypeRef::Path(name.into()); - self.fill_bounds(&lower_ctx, &type_param, Either::Left(type_ref)); + self.fill_bounds(lower_ctx, &type_param, Either::Left(type_ref)); } for lifetime_param in params.lifetime_params() { let name = @@ -289,7 +289,7 @@ impl GenericParams { let param_id = self.lifetimes.alloc(param); sm.lifetime_params.insert(param_id, lifetime_param.clone()); let lifetime_ref = LifetimeRef::new_name(name); - self.fill_bounds(&lower_ctx, &lifetime_param, Either::Right(lifetime_ref)); + self.fill_bounds(lower_ctx, &lifetime_param, Either::Right(lifetime_ref)); } for const_param in params.const_params() { let name = const_param.name().map_or_else(Name::missing, |it| it.as_name()); diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index cfda7cb32..3f90bda74 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -823,7 +823,7 @@ fn is_intrinsic_fn_unsafe(name: &Name) -> bool { known::type_name, known::variant_count, ] - .contains(&name) + .contains(name) } fn lower_abi(abi: ast::Abi) -> Interned { @@ -855,7 +855,7 @@ impl UseTreeLowering<'_> { // E.g. `use something::{inner}` (prefix is `None`, path is `something`) // or `use something::{path::{inner::{innerer}}}` (prefix is `something::path`, path is `inner`) Some(path) => { - match ModPath::from_src(self.db, path, &self.hygiene) { + match ModPath::from_src(self.db, path, self.hygiene) { Some(it) => Some(it), None => return None, // FIXME: report errors somewhere } @@ -874,7 +874,7 @@ impl UseTreeLowering<'_> { } else { let is_glob = tree.star_token().is_some(); let path = match tree.path() { - Some(path) => Some(ModPath::from_src(self.db, path, &self.hygiene)?), + Some(path) => Some(ModPath::from_src(self.db, path, self.hygiene)?), None => None, }; let alias = tree.rename().map(|a| { diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 93f30f23d..6fab58f15 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -500,7 +500,7 @@ impl DefCollector<'_> { let (per_ns, _) = self.def_map.resolve_path( self.db, self.def_map.root, - &path, + path, BuiltinShadowMode::Other, ); @@ -722,7 +722,7 @@ impl DefCollector<'_> { if import.is_extern_crate { let res = self.def_map.resolve_name_in_extern_prelude( self.db, - &import + import .path .as_ident() .expect("extern crate should have been desugared to one-element path"), @@ -1351,7 +1351,7 @@ impl ModCollector<'_, '_> { let imports = Import::from_use( self.def_collector.db, krate, - &self.item_tree, + self.item_tree, ItemTreeId::new(self.file_id, import_id), ); self.def_collector.unresolved_imports.extend(imports.into_iter().map( @@ -1368,7 +1368,7 @@ impl ModCollector<'_, '_> { import: Import::from_extern_crate( self.def_collector.db, krate, - &self.item_tree, + self.item_tree, ItemTreeId::new(self.file_id, import_id), ), status: PartialResolvedImport::Unresolved, @@ -1889,7 +1889,7 @@ impl ModCollector<'_, '_> { self.def_collector.def_map.with_ancestor_maps( self.def_collector.db, self.module_id, - &mut |map, module| map[module].scope.get_legacy_macro(&name), + &mut |map, module| map[module].scope.get_legacy_macro(name), ) }) }, @@ -1993,7 +1993,7 @@ mod tests { } fn do_resolve(code: &str) -> DefMap { - let (db, _file_id) = TestDB::with_single_file(&code); + let (db, _file_id) = TestDB::with_single_file(code); let krate = db.test_crate(); let edition = db.crate_graph()[krate].edition; diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index c984148c3..629bc7952 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs @@ -93,7 +93,7 @@ impl DefMap { let mut vis = match visibility { RawVisibility::Module(path) => { let (result, remaining) = - self.resolve_path(db, original_module, &path, BuiltinShadowMode::Module); + self.resolve_path(db, original_module, path, BuiltinShadowMode::Module); if remaining.is_some() { return None; } @@ -205,7 +205,7 @@ impl DefMap { None => return ResolvePathResult::empty(ReachedFixedPoint::Yes), }; log::debug!("resolving {:?} in crate root (+ extern prelude)", segment); - self.resolve_name_in_crate_root_or_extern_prelude(db, &segment) + self.resolve_name_in_crate_root_or_extern_prelude(db, segment) } PathKind::Plain => { let (_, segment) = match segments.next() { @@ -222,7 +222,7 @@ impl DefMap { if path.segments().len() == 1 { shadow } else { BuiltinShadowMode::Module }; log::debug!("resolving {:?} in module", segment); - self.resolve_name_in_module(db, original_module, &segment, prefer_module) + self.resolve_name_in_module(db, original_module, segment, prefer_module) } PathKind::Super(lvl) => { let mut module = original_module; @@ -269,7 +269,7 @@ impl DefMap { Some((_, segment)) => segment, None => return ResolvePathResult::empty(ReachedFixedPoint::Yes), }; - if let Some(def) = self.extern_prelude.get(&segment) { + if let Some(def) = self.extern_prelude.get(segment) { log::debug!("absolute path {:?} resolved to crate {:?}", path, def); PerNs::types(*def, Visibility::Public) } else { @@ -319,13 +319,13 @@ impl DefMap { }; // Since it is a qualified path here, it should not contains legacy macros - module_data.scope.get(&segment) + module_data.scope.get(segment) } ModuleDefId::AdtId(AdtId::EnumId(e)) => { // enum variant cov_mark::hit!(can_import_enum_variant); let enum_data = db.enum_data(e); - match enum_data.variant(&segment) { + match enum_data.variant(segment) { Some(local_id) => { let variant = EnumVariantId { parent: e, local_id }; match &*enum_data.variants[local_id].variant_data { diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs index f6220aa92..27345d07c 100644 --- a/crates/hir_def/src/path/lower.rs +++ b/crates/hir_def/src/path/lower.rs @@ -208,13 +208,13 @@ fn lower_generic_args_from_fn_path( let params = params?; let mut param_types = Vec::new(); for param in params.params() { - let type_ref = TypeRef::from_ast_opt(&ctx, param.ty()); + let type_ref = TypeRef::from_ast_opt(ctx, param.ty()); param_types.push(type_ref); } let arg = GenericArg::Type(TypeRef::Tuple(param_types)); args.push(arg); if let Some(ret_type) = ret_type { - let type_ref = TypeRef::from_ast_opt(&ctx, ret_type.ty()); + let type_ref = TypeRef::from_ast_opt(ctx, ret_type.ty()); bindings.push(AssociatedTypeBinding { name: name![Output], type_ref: Some(type_ref), diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index fb8a6f260..d4681fa3e 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs @@ -133,7 +133,7 @@ impl Resolver { Some(it) => it, None => return PerNs::none(), }; - let (module_res, segment_index) = item_map.resolve_path(db, module, &path, shadow); + let (module_res, segment_index) = item_map.resolve_path(db, module, path, shadow); if segment_index.is_some() { return PerNs::none(); } @@ -150,7 +150,7 @@ impl Resolver { path: &ModPath, ) -> Option { let (item_map, module) = self.module_scope()?; - let (module_res, ..) = item_map.resolve_path(db, module, &path, BuiltinShadowMode::Module); + let (module_res, ..) = item_map.resolve_path(db, module, path, BuiltinShadowMode::Module); match module_res.take_types()? { ModuleDefId::TraitId(it) => Some(it), _ => None, @@ -325,7 +325,7 @@ impl Resolver { path: &ModPath, ) -> Option { let (item_map, module) = self.module_scope()?; - item_map.resolve_path(db, module, &path, BuiltinShadowMode::Other).0.take_macros() + item_map.resolve_path(db, module, path, BuiltinShadowMode::Other).0.take_macros() } pub fn process_all_names(&self, db: &dyn DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { @@ -561,7 +561,7 @@ impl ModuleItemMap { path: &ModPath, ) -> Option { let (module_def, idx) = - self.def_map.resolve_path_locally(db, self.module_id, &path, BuiltinShadowMode::Other); + self.def_map.resolve_path_locally(db, self.module_id, path, BuiltinShadowMode::Other); match idx { None => { let value = to_value_ns(module_def)?; @@ -591,7 +591,7 @@ impl ModuleItemMap { path: &ModPath, ) -> Option<(TypeNs, Option)> { let (module_def, idx) = - self.def_map.resolve_path_locally(db, self.module_id, &path, BuiltinShadowMode::Other); + self.def_map.resolve_path_locally(db, self.module_id, path, BuiltinShadowMode::Other); let res = to_type_ns(module_def)?; Some((res, idx)) } diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs index cbde6b940..ffe499973 100644 --- a/crates/hir_def/src/type_ref.rs +++ b/crates/hir_def/src/type_ref.rs @@ -128,7 +128,7 @@ impl TypeRef { /// Converts an `ast::TypeRef` to a `hir::TypeRef`. pub fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self { match node { - ast::Type::ParenType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()), + ast::Type::ParenType(inner) => TypeRef::from_ast_opt(ctx, inner.ty()), ast::Type::TupleType(inner) => { TypeRef::Tuple(inner.fields().map(|it| TypeRef::from_ast(ctx, it)).collect()) } @@ -142,7 +142,7 @@ impl TypeRef { .unwrap_or(TypeRef::Error) } ast::Type::PtrType(inner) => { - let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty()); + let inner_ty = TypeRef::from_ast_opt(ctx, inner.ty()); let mutability = Mutability::from_mutable(inner.mut_token().is_some()); TypeRef::RawPtr(Box::new(inner_ty), mutability) } @@ -156,13 +156,13 @@ impl TypeRef { .map(ConstScalar::usize_from_literal_expr) .unwrap_or(ConstScalar::Unknown); - TypeRef::Array(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty())), len) + TypeRef::Array(Box::new(TypeRef::from_ast_opt(ctx, inner.ty())), len) } ast::Type::SliceType(inner) => { - TypeRef::Slice(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty()))) + TypeRef::Slice(Box::new(TypeRef::from_ast_opt(ctx, inner.ty()))) } ast::Type::RefType(inner) => { - let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty()); + let inner_ty = TypeRef::from_ast_opt(ctx, inner.ty()); let lifetime = inner.lifetime().map(|lt| LifetimeRef::new(<)); let mutability = Mutability::from_mutable(inner.mut_token().is_some()); TypeRef::Reference(Box::new(inner_ty), lifetime, mutability) @@ -180,7 +180,7 @@ impl TypeRef { is_varargs = param.dotdotdot_token().is_some(); } - pl.params().map(|p| p.ty()).map(|it| TypeRef::from_ast_opt(&ctx, it)).collect() + pl.params().map(|p| p.ty()).map(|it| TypeRef::from_ast_opt(ctx, it)).collect() } else { Vec::new() }; @@ -188,7 +188,7 @@ impl TypeRef { TypeRef::Fn(params, is_varargs) } // for types are close enough for our purposes to the inner type for now... - ast::Type::ForType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()), + ast::Type::ForType(inner) => TypeRef::from_ast_opt(ctx, inner.ty()), ast::Type::ImplTraitType(inner) => { TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) } @@ -229,7 +229,7 @@ impl TypeRef { TypeRef::RawPtr(type_ref, _) | TypeRef::Reference(type_ref, ..) | TypeRef::Array(type_ref, _) - | TypeRef::Slice(type_ref) => go(&type_ref, f), + | TypeRef::Slice(type_ref) => go(type_ref, f), TypeRef::ImplTrait(bounds) | TypeRef::DynTrait(bounds) => { for bound in bounds { match bound.as_ref() { -- cgit v1.2.3