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/src/code_model.rs | 10 +++++----- crates/ra_hir/src/source_analyzer.rs | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index b6adb7589..fe9149c9d 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -283,7 +283,7 @@ impl StructField { }; let substs = Substs::type_params(db, generic_def_id); let ty = db.field_types(var_id)[self.id].clone().subst(&substs); - Type::new(db, self.parent.module(db).id.krate.into(), var_id, ty) + Type::new(db, self.parent.module(db).id.krate, var_id, ty) } pub fn parent_def(&self, _db: &impl HirDatabase) -> VariantDef { @@ -315,11 +315,11 @@ impl Struct { } pub fn name(self, db: &impl DefDatabase) -> Name { - db.struct_data(self.id.into()).name.clone() + db.struct_data(self.id).name.clone() } pub fn fields(self, db: &impl HirDatabase) -> Vec { - db.struct_data(self.id.into()) + db.struct_data(self.id) .variant_data .fields() .iter() @@ -332,7 +332,7 @@ impl Struct { } fn variant_data(self, db: &impl DefDatabase) -> Arc { - db.struct_data(self.id.into()).variant_data.clone() + db.struct_data(self.id).variant_data.clone() } } @@ -1049,7 +1049,7 @@ impl Type { // FIXME check that? let canonical = Canonical { value: self.ty.value.clone(), num_vars: 0 }; let environment = self.ty.environment.clone(); - let ty = InEnvironment { value: canonical, environment: environment.clone() }; + let ty = InEnvironment { value: canonical, environment }; autoderef(db, Some(self.krate), ty) .map(|canonical| canonical.value) .map(move |ty| self.derived(ty)) diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 94d5b4cfd..efa3f8a79 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -361,9 +361,8 @@ impl SourceAnalyzer { db: &impl HirDatabase, macro_call: InFile<&ast::MacroCall>, ) -> Option { - let macro_call_id = macro_call.as_call_id(db, |path| { - self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into()) - })?; + let macro_call_id = + macro_call.as_call_id(db, |path| self.resolver.resolve_path_as_macro(db, &path))?; Some(Expansion { macro_call_id }) } } -- 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/src/code_model.rs | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index fe9149c9d..1bdcda069 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -988,20 +988,17 @@ impl Type { pub fn fields(&self, db: &impl HirDatabase) -> Vec<(StructField, Type)> { if let Ty::Apply(a_ty) = &self.ty.value { - match a_ty.ctor { - TypeCtor::Adt(AdtId::StructId(s)) => { - let var_def = s.into(); - return db - .field_types(var_def) - .iter() - .map(|(local_id, ty)| { - let def = StructField { parent: var_def.into(), id: local_id }; - let ty = ty.clone().subst(&a_ty.parameters); - (def, self.derived(ty)) - }) - .collect(); - } - _ => {} + if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor { + let var_def = s.into(); + return db + .field_types(var_def) + .iter() + .map(|(local_id, ty)| { + let def = StructField { parent: var_def.into(), id: local_id }; + let ty = ty.clone().subst(&a_ty.parameters); + (def, self.derived(ty)) + }) + .collect(); } }; Vec::new() @@ -1010,14 +1007,11 @@ impl Type { pub fn tuple_fields(&self, _db: &impl HirDatabase) -> Vec { let mut res = Vec::new(); if let Ty::Apply(a_ty) = &self.ty.value { - match a_ty.ctor { - TypeCtor::Tuple { .. } => { - for ty in a_ty.parameters.iter() { - let ty = ty.clone(); - res.push(self.derived(ty)); - } + if let TypeCtor::Tuple { .. } = a_ty.ctor { + for ty in a_ty.parameters.iter() { + let ty = ty.clone(); + res.push(self.derived(ty)); } - _ => {} } }; res -- 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/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 7dc31ad3c..0555a0de7 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -8,9 +8,9 @@ authors = ["rust-analyzer developers"] doctest = false [dependencies] -log = "0.4.5" -rustc-hash = "1.0" -either = "1.5" +log = "0.4.8" +rustc-hash = "1.1.0" +either = "1.5.3" ra_syntax = { path = "../ra_syntax" } ra_db = { path = "../ra_db" } -- cgit v1.2.3