aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-18 14:37:34 +0000
committerGitHub <[email protected]>2020-02-18 14:37:34 +0000
commitcecf25b72f2af84fc1535cf52d6f3c1b52802565 (patch)
tree37c8dde0a459caacae6629da08d86be270469ef5 /crates/ra_hir
parenteab80cd961919b9321e1d34343ae3f3adb0502e5 (diff)
parentf6816c253b96e8436f1156d6bd6b0942ee9fb4d3 (diff)
Merge #3220
3220: Fix clippy warnings, update Cargo.toml versions r=matklad a=SomeoneToIgnore In the `cargo xtask lint` ouptut, there were two interesting Clippy warnings that might be interesting to investigate further: * warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) * warning: large size difference between variants Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/Cargo.toml6
-rw-r--r--crates/ra_hir/src/code_model.rs46
-rw-r--r--crates/ra_hir/src/source_analyzer.rs5
3 files changed, 25 insertions, 32 deletions
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"]
8doctest = false 8doctest = false
9 9
10[dependencies] 10[dependencies]
11log = "0.4.5" 11log = "0.4.8"
12rustc-hash = "1.0" 12rustc-hash = "1.1.0"
13either = "1.5" 13either = "1.5.3"
14 14
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
16ra_db = { path = "../ra_db" } 16ra_db = { path = "../ra_db" }
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index b6adb7589..1bdcda069 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -283,7 +283,7 @@ impl StructField {
283 }; 283 };
284 let substs = Substs::type_params(db, generic_def_id); 284 let substs = Substs::type_params(db, generic_def_id);
285 let ty = db.field_types(var_id)[self.id].clone().subst(&substs); 285 let ty = db.field_types(var_id)[self.id].clone().subst(&substs);
286 Type::new(db, self.parent.module(db).id.krate.into(), var_id, ty) 286 Type::new(db, self.parent.module(db).id.krate, var_id, ty)
287 } 287 }
288 288
289 pub fn parent_def(&self, _db: &impl HirDatabase) -> VariantDef { 289 pub fn parent_def(&self, _db: &impl HirDatabase) -> VariantDef {
@@ -315,11 +315,11 @@ impl Struct {
315 } 315 }
316 316
317 pub fn name(self, db: &impl DefDatabase) -> Name { 317 pub fn name(self, db: &impl DefDatabase) -> Name {
318 db.struct_data(self.id.into()).name.clone() 318 db.struct_data(self.id).name.clone()
319 } 319 }
320 320
321 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> { 321 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
322 db.struct_data(self.id.into()) 322 db.struct_data(self.id)
323 .variant_data 323 .variant_data
324 .fields() 324 .fields()
325 .iter() 325 .iter()
@@ -332,7 +332,7 @@ impl Struct {
332 } 332 }
333 333
334 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 334 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
335 db.struct_data(self.id.into()).variant_data.clone() 335 db.struct_data(self.id).variant_data.clone()
336 } 336 }
337} 337}
338 338
@@ -988,20 +988,17 @@ impl Type {
988 988
989 pub fn fields(&self, db: &impl HirDatabase) -> Vec<(StructField, Type)> { 989 pub fn fields(&self, db: &impl HirDatabase) -> Vec<(StructField, Type)> {
990 if let Ty::Apply(a_ty) = &self.ty.value { 990 if let Ty::Apply(a_ty) = &self.ty.value {
991 match a_ty.ctor { 991 if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor {
992 TypeCtor::Adt(AdtId::StructId(s)) => { 992 let var_def = s.into();
993 let var_def = s.into(); 993 return db
994 return db 994 .field_types(var_def)
995 .field_types(var_def) 995 .iter()
996 .iter() 996 .map(|(local_id, ty)| {
997 .map(|(local_id, ty)| { 997 let def = StructField { parent: var_def.into(), id: local_id };
998 let def = StructField { parent: var_def.into(), id: local_id }; 998 let ty = ty.clone().subst(&a_ty.parameters);
999 let ty = ty.clone().subst(&a_ty.parameters); 999 (def, self.derived(ty))
1000 (def, self.derived(ty)) 1000 })
1001 }) 1001 .collect();
1002 .collect();
1003 }
1004 _ => {}
1005 } 1002 }
1006 }; 1003 };
1007 Vec::new() 1004 Vec::new()
@@ -1010,14 +1007,11 @@ impl Type {
1010 pub fn tuple_fields(&self, _db: &impl HirDatabase) -> Vec<Type> { 1007 pub fn tuple_fields(&self, _db: &impl HirDatabase) -> Vec<Type> {
1011 let mut res = Vec::new(); 1008 let mut res = Vec::new();
1012 if let Ty::Apply(a_ty) = &self.ty.value { 1009 if let Ty::Apply(a_ty) = &self.ty.value {
1013 match a_ty.ctor { 1010 if let TypeCtor::Tuple { .. } = a_ty.ctor {
1014 TypeCtor::Tuple { .. } => { 1011 for ty in a_ty.parameters.iter() {
1015 for ty in a_ty.parameters.iter() { 1012 let ty = ty.clone();
1016 let ty = ty.clone(); 1013 res.push(self.derived(ty));
1017 res.push(self.derived(ty));
1018 }
1019 } 1014 }
1020 _ => {}
1021 } 1015 }
1022 }; 1016 };
1023 res 1017 res
@@ -1049,7 +1043,7 @@ impl Type {
1049 // FIXME check that? 1043 // FIXME check that?
1050 let canonical = Canonical { value: self.ty.value.clone(), num_vars: 0 }; 1044 let canonical = Canonical { value: self.ty.value.clone(), num_vars: 0 };
1051 let environment = self.ty.environment.clone(); 1045 let environment = self.ty.environment.clone();
1052 let ty = InEnvironment { value: canonical, environment: environment.clone() }; 1046 let ty = InEnvironment { value: canonical, environment };
1053 autoderef(db, Some(self.krate), ty) 1047 autoderef(db, Some(self.krate), ty)
1054 .map(|canonical| canonical.value) 1048 .map(|canonical| canonical.value)
1055 .map(move |ty| self.derived(ty)) 1049 .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 {
361 db: &impl HirDatabase, 361 db: &impl HirDatabase,
362 macro_call: InFile<&ast::MacroCall>, 362 macro_call: InFile<&ast::MacroCall>,
363 ) -> Option<Expansion> { 363 ) -> Option<Expansion> {
364 let macro_call_id = macro_call.as_call_id(db, |path| { 364 let macro_call_id =
365 self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into()) 365 macro_call.as_call_id(db, |path| self.resolver.resolve_path_as_macro(db, &path))?;
366 })?;
367 Some(Expansion { macro_call_id }) 366 Some(Expansion { macro_call_id })
368 } 367 }
369} 368}