From 6753051a45e067fb8267f7ecbbf1b894558718d1 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Wed, 6 Feb 2019 15:50:26 -0500 Subject: Some clippy cleanups --- crates/ra_hir/src/expr.rs | 6 +++--- crates/ra_hir/src/expr/scope.rs | 4 ++-- crates/ra_hir/src/impl_block.rs | 2 +- crates/ra_hir/src/resolve.rs | 2 +- crates/ra_hir/src/ty.rs | 8 ++++---- crates/ra_hir/src/ty/method_resolution.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index f9f702ae2..6826e966b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -805,7 +805,7 @@ impl ExprCollector { let lit = match child.flavor() { LiteralFlavor::IntNumber { suffix } => { let known_name = suffix - .map(|s| Name::new(s)) + .map(Name::new) .and_then(|name| UncertainIntTy::from_name(&name)); Literal::Int( @@ -815,7 +815,7 @@ impl ExprCollector { } LiteralFlavor::FloatNumber { suffix } => { let known_name = suffix - .map(|s| Name::new(s)) + .map(Name::new) .and_then(|name| UncertainFloatTy::from_name(&name)); Literal::Float( @@ -910,7 +910,7 @@ impl ExprCollector { } ast::PatKind::PathPat(p) => { let path = p.path().and_then(Path::from_ast); - path.map(|path| Pat::Path(path)).unwrap_or(Pat::Missing) + path.map(Pat::Path).unwrap_or(Pat::Missing) } ast::PatKind::TuplePat(p) => { let args = p.args().map(|p| self.collect_pat(p)).collect(); diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 9202e3671..368994bf7 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -105,7 +105,7 @@ impl ExprScopes { fn add_params_bindings(&mut self, scope: ScopeId, params: &[PatId]) { let body = Arc::clone(&self.body); params - .into_iter() + .iter() .for_each(|pat| self.add_bindings(&body, scope, *pat)); } @@ -147,7 +147,7 @@ impl ScopesWithSyntaxMapping { }) } - pub fn scope_for_offset<'a>(&'a self, offset: TextUnit) -> Option { + pub fn scope_for_offset(&self, offset: TextUnit) -> Option { self.scopes .scope_for .iter() diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 738c58fbe..094dbedb3 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs @@ -72,7 +72,7 @@ impl ImplBlock { } pub fn module(&self) -> Module { - self.module_impl_blocks.module.clone() + self.module_impl_blocks.module } pub fn target_trait_ref(&self) -> Option<&TypeRef> { diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 5ca7bacb5..0f60d4742 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs @@ -78,7 +78,7 @@ impl Resolver { _ => return PerNs::none(), }; let module_res = item_map.resolve_path(db, module, path); - module_res.map(|def| Resolution::Def(def)) + module_res.map(Resolution::Def) } } diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index cc5afad75..86a7f8b83 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -1225,7 +1225,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { Ty::Tuple(ref tuple_args) => &**tuple_args, _ => &[], }; - let expectations_iter = expectations.into_iter().chain(repeat(&Ty::Unknown)); + let expectations_iter = expectations.iter().chain(repeat(&Ty::Unknown)); let inner_tys = args .iter() @@ -1398,10 +1398,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let method_ty = self.insert_type_vars(method_ty); let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { Ty::FnPtr(sig) => { - if sig.input.len() > 0 { + if !sig.input.is_empty() { ( sig.input[0].clone(), - sig.input[1..].iter().cloned().collect(), + sig.input[1..].to_vec(), sig.output.clone(), ) } else { @@ -1411,7 +1411,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { Ty::FnDef { substs, sig, .. } => { let ret_ty = sig.output.clone().subst(&substs); - if sig.input.len() > 0 { + if !sig.input.is_empty() { let mut arg_iter = sig.input.iter().map(|ty| ty.clone().subst(&substs)); let receiver_ty = arg_iter.next().unwrap(); (receiver_ty, arg_iter.collect(), ret_ty) diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 2282286b0..a7d4517ee 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -113,7 +113,7 @@ impl CrateImplBlocks { krate: Crate, ) -> Arc { let mut crate_impl_blocks = CrateImplBlocks { - krate: krate.clone(), + krate, impls: FxHashMap::default(), impls_by_trait: FxHashMap::default(), }; -- cgit v1.2.3