From b8ddcb0652f3ec8683023afc1e1f5166d6a712f4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 14:53:02 +0200 Subject: Run cargo +nightly fix --clippy -Z unstable-options --- crates/ra_hir_def/src/body/lower.rs | 2 +- crates/ra_hir_def/src/generics.rs | 2 +- crates/ra_hir_def/src/item_scope.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 2 +- crates/ra_hir_def/src/nameres/raw.rs | 4 +--- crates/ra_hir_def/src/nameres/tests/incremental.rs | 4 ++-- crates/ra_hir_def/src/path/lower/lower_use.rs | 4 +--- crates/ra_hir_def/src/resolver.rs | 6 +++--- 8 files changed, 11 insertions(+), 15 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 1fc892362..b1626fa11 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -448,7 +448,7 @@ where // FIXME expand to statements in statement position ast::Expr::MacroCall(e) => { let macro_call = self.expander.to_source(AstPtr::new(&e)); - match self.expander.enter_expand(self.db, e.clone()) { + match self.expander.enter_expand(self.db, e) { Some((mark, expansion)) => { self.source_map .expansions diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index f765e6edc..e07a4f947 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -71,7 +71,7 @@ impl GenericParams { db: &impl DefDatabase, def: GenericDefId, ) -> Arc { - let (params, _source_map) = GenericParams::new(db, def.into()); + let (params, _source_map) = GenericParams::new(db, def); Arc::new(params) } diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index d74a1cef2..f8dc06d10 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -138,7 +138,7 @@ impl ItemScope { pub(crate) fn push_res(&mut self, name: Name, def: PerNs) -> bool { let mut changed = false; - let existing = self.visible.entry(name.clone()).or_default(); + let existing = self.visible.entry(name).or_default(); if existing.types.is_none() && def.types.is_some() { existing.types = def.types; diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 852304dd0..c5137a0ab 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -156,7 +156,7 @@ impl ModuleOrigin { ModuleOrigin::File { definition, .. } | ModuleOrigin::CrateRoot { definition } => { let file_id = *definition; let sf = db.parse(file_id).tree(); - return InFile::new(file_id.into(), ModuleSource::SourceFile(sf)); + InFile::new(file_id.into(), ModuleSource::SourceFile(sf)) } ModuleOrigin::Inline { definition } => { InFile::new(definition.file_id, ModuleSource::Module(definition.to_node(db))) diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 650cf1f98..0e8c9da76 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -357,9 +357,7 @@ impl RawItemsCollector { let visibility = RawVisibility::from_ast_with_hygiene(extern_crate.visibility(), &self.hygiene); let alias = extern_crate.alias().map(|a| { - a.name() - .map(|it| it.as_name()) - .map_or(ImportAlias::Underscore, |a| ImportAlias::Alias(a)) + a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) }); let attrs = self.parse_attrs(&extern_crate); // FIXME: cfg_attr diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/ra_hir_def/src/nameres/tests/incremental.rs index faeb7aa4d..83f429c29 100644 --- a/crates/ra_hir_def/src/nameres/tests/incremental.rs +++ b/crates/ra_hir_def/src/nameres/tests/incremental.rs @@ -116,7 +116,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() { let events = db.log_executed(|| { let crate_def_map = db.crate_def_map(krate); let (_, module_data) = crate_def_map.modules.iter().last().unwrap(); - assert_eq!(module_data.scope.resolutions().collect::>().len(), 1); + assert_eq!(module_data.scope.resolutions().count(), 1); }); assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) } @@ -126,7 +126,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() { let events = db.log_executed(|| { let crate_def_map = db.crate_def_map(krate); let (_, module_data) = crate_def_map.modules.iter().last().unwrap(); - assert_eq!(module_data.scope.resolutions().collect::>().len(), 1); + assert_eq!(module_data.scope.resolutions().count(), 1); }); assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) } diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs index d2bc9d193..b6d1125e2 100644 --- a/crates/ra_hir_def/src/path/lower/lower_use.rs +++ b/crates/ra_hir_def/src/path/lower/lower_use.rs @@ -32,9 +32,7 @@ pub(crate) fn lower_use_tree( } } else { let alias = tree.alias().map(|a| { - a.name() - .map(|it| it.as_name()) - .map_or(ImportAlias::Underscore, |a| ImportAlias::Alias(a)) + a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) }); let is_glob = tree.has_star(); if let Some(ast_path) = tree.path() { diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index e2b228e80..5365b80e2 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -474,7 +474,7 @@ impl Scope { f(name.clone(), ScopeDef::PerNs(PerNs::macros(macro_, Visibility::Public))); }); m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| { - f(name.clone(), ScopeDef::PerNs(PerNs::types(def.into(), Visibility::Public))); + f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); }); if let Some(prelude) = m.crate_def_map.prelude { let prelude_def_map = db.crate_def_map(prelude.krate); @@ -499,10 +499,10 @@ impl Scope { } } Scope::ImplBlockScope(i) => { - f(name![Self], ScopeDef::ImplSelfType((*i).into())); + f(name![Self], ScopeDef::ImplSelfType(*i)); } Scope::AdtScope(i) => { - f(name![Self], ScopeDef::AdtSelfType((*i).into())); + f(name![Self], ScopeDef::AdtSelfType(*i)); } Scope::ExprScope(scope) => { scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| { -- cgit v1.2.3 From eceaf94f1936436e33ae235ca65bf2a6d4f77da5 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 15:32:19 +0200 Subject: More manual clippy fixes --- crates/ra_hir_def/src/item_scope.rs | 2 +- crates/ra_hir_def/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index f8dc06d10..6e958ca75 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -157,7 +157,7 @@ impl ItemScope { } pub(crate) fn resolutions<'a>(&'a self) -> impl Iterator + 'a { - self.visible.iter().map(|(name, res)| (name.clone(), res.clone())) + self.visible.iter().map(|(name, res)| (name.clone(), *res)) } pub(crate) fn collect_legacy_macros(&self) -> FxHashMap { diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index aa0b558b8..564b5fec5 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -460,7 +460,7 @@ impl AsMacroCall for AstIdWithPath { resolver: impl Fn(path::ModPath) -> Option, ) -> Option { let def = resolver(self.path.clone())?; - Some(def.as_call_id(db, MacroCallKind::FnLike(self.ast_id.clone()))) + Some(def.as_call_id(db, MacroCallKind::FnLike(self.ast_id))) } } @@ -471,6 +471,6 @@ impl AsMacroCall for AstIdWithPath { resolver: impl Fn(path::ModPath) -> Option, ) -> Option { let def = resolver(self.path.clone())?; - Some(def.as_call_id(db, MacroCallKind::Attr(self.ast_id.clone()))) + Some(def.as_call_id(db, MacroCallKind::Attr(self.ast_id))) } } -- cgit v1.2.3 From f6816c253b96e8436f1156d6bd6b0942ee9fb4d3 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 15:57:41 +0200 Subject: Update versions --- crates/ra_hir_def/Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 6b9be9948..5053d0688 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -8,11 +8,11 @@ authors = ["rust-analyzer developers"] doctest = false [dependencies] -log = "0.4.5" -once_cell = "1.0.1" -rustc-hash = "1.0" -either = "1.5" -anymap = "0.12" +log = "0.4.8" +once_cell = "1.3.1" +rustc-hash = "1.1.0" +either = "1.5.3" +anymap = "0.12.1" drop_bomb = "0.1.4" itertools = "0.8.2" @@ -27,4 +27,4 @@ ra_cfg = { path = "../ra_cfg" } tt = { path = "../ra_tt", package = "ra_tt" } [dev-dependencies] -insta = "0.13.0" +insta = "0.13.1" -- cgit v1.2.3