aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs2
-rw-r--r--crates/ra_hir_def/src/generics.rs2
-rw-r--r--crates/ra_hir_def/src/item_scope.rs2
-rw-r--r--crates/ra_hir_def/src/nameres.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs4
-rw-r--r--crates/ra_hir_def/src/nameres/tests/incremental.rs4
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs4
-rw-r--r--crates/ra_hir_def/src/resolver.rs6
8 files changed, 11 insertions, 15 deletions
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
448 // FIXME expand to statements in statement position 448 // FIXME expand to statements in statement position
449 ast::Expr::MacroCall(e) => { 449 ast::Expr::MacroCall(e) => {
450 let macro_call = self.expander.to_source(AstPtr::new(&e)); 450 let macro_call = self.expander.to_source(AstPtr::new(&e));
451 match self.expander.enter_expand(self.db, e.clone()) { 451 match self.expander.enter_expand(self.db, e) {
452 Some((mark, expansion)) => { 452 Some((mark, expansion)) => {
453 self.source_map 453 self.source_map
454 .expansions 454 .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 {
71 db: &impl DefDatabase, 71 db: &impl DefDatabase,
72 def: GenericDefId, 72 def: GenericDefId,
73 ) -> Arc<GenericParams> { 73 ) -> Arc<GenericParams> {
74 let (params, _source_map) = GenericParams::new(db, def.into()); 74 let (params, _source_map) = GenericParams::new(db, def);
75 Arc::new(params) 75 Arc::new(params)
76 } 76 }
77 77
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 {
138 138
139 pub(crate) fn push_res(&mut self, name: Name, def: PerNs) -> bool { 139 pub(crate) fn push_res(&mut self, name: Name, def: PerNs) -> bool {
140 let mut changed = false; 140 let mut changed = false;
141 let existing = self.visible.entry(name.clone()).or_default(); 141 let existing = self.visible.entry(name).or_default();
142 142
143 if existing.types.is_none() && def.types.is_some() { 143 if existing.types.is_none() && def.types.is_some() {
144 existing.types = def.types; 144 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 {
156 ModuleOrigin::File { definition, .. } | ModuleOrigin::CrateRoot { definition } => { 156 ModuleOrigin::File { definition, .. } | ModuleOrigin::CrateRoot { definition } => {
157 let file_id = *definition; 157 let file_id = *definition;
158 let sf = db.parse(file_id).tree(); 158 let sf = db.parse(file_id).tree();
159 return InFile::new(file_id.into(), ModuleSource::SourceFile(sf)); 159 InFile::new(file_id.into(), ModuleSource::SourceFile(sf))
160 } 160 }
161 ModuleOrigin::Inline { definition } => { 161 ModuleOrigin::Inline { definition } => {
162 InFile::new(definition.file_id, ModuleSource::Module(definition.to_node(db))) 162 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 {
357 let visibility = 357 let visibility =
358 RawVisibility::from_ast_with_hygiene(extern_crate.visibility(), &self.hygiene); 358 RawVisibility::from_ast_with_hygiene(extern_crate.visibility(), &self.hygiene);
359 let alias = extern_crate.alias().map(|a| { 359 let alias = extern_crate.alias().map(|a| {
360 a.name() 360 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
361 .map(|it| it.as_name())
362 .map_or(ImportAlias::Underscore, |a| ImportAlias::Alias(a))
363 }); 361 });
364 let attrs = self.parse_attrs(&extern_crate); 362 let attrs = self.parse_attrs(&extern_crate);
365 // FIXME: cfg_attr 363 // 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() {
116 let events = db.log_executed(|| { 116 let events = db.log_executed(|| {
117 let crate_def_map = db.crate_def_map(krate); 117 let crate_def_map = db.crate_def_map(krate);
118 let (_, module_data) = crate_def_map.modules.iter().last().unwrap(); 118 let (_, module_data) = crate_def_map.modules.iter().last().unwrap();
119 assert_eq!(module_data.scope.resolutions().collect::<Vec<_>>().len(), 1); 119 assert_eq!(module_data.scope.resolutions().count(), 1);
120 }); 120 });
121 assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) 121 assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events)
122 } 122 }
@@ -126,7 +126,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() {
126 let events = db.log_executed(|| { 126 let events = db.log_executed(|| {
127 let crate_def_map = db.crate_def_map(krate); 127 let crate_def_map = db.crate_def_map(krate);
128 let (_, module_data) = crate_def_map.modules.iter().last().unwrap(); 128 let (_, module_data) = crate_def_map.modules.iter().last().unwrap();
129 assert_eq!(module_data.scope.resolutions().collect::<Vec<_>>().len(), 1); 129 assert_eq!(module_data.scope.resolutions().count(), 1);
130 }); 130 });
131 assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) 131 assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events)
132 } 132 }
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(
32 } 32 }
33 } else { 33 } else {
34 let alias = tree.alias().map(|a| { 34 let alias = tree.alias().map(|a| {
35 a.name() 35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
36 .map(|it| it.as_name())
37 .map_or(ImportAlias::Underscore, |a| ImportAlias::Alias(a))
38 }); 36 });
39 let is_glob = tree.has_star(); 37 let is_glob = tree.has_star();
40 if let Some(ast_path) = tree.path() { 38 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 {
474 f(name.clone(), ScopeDef::PerNs(PerNs::macros(macro_, Visibility::Public))); 474 f(name.clone(), ScopeDef::PerNs(PerNs::macros(macro_, Visibility::Public)));
475 }); 475 });
476 m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| { 476 m.crate_def_map.extern_prelude.iter().for_each(|(name, &def)| {
477 f(name.clone(), ScopeDef::PerNs(PerNs::types(def.into(), Visibility::Public))); 477 f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public)));
478 }); 478 });
479 if let Some(prelude) = m.crate_def_map.prelude { 479 if let Some(prelude) = m.crate_def_map.prelude {
480 let prelude_def_map = db.crate_def_map(prelude.krate); 480 let prelude_def_map = db.crate_def_map(prelude.krate);
@@ -499,10 +499,10 @@ impl Scope {
499 } 499 }
500 } 500 }
501 Scope::ImplBlockScope(i) => { 501 Scope::ImplBlockScope(i) => {
502 f(name![Self], ScopeDef::ImplSelfType((*i).into())); 502 f(name![Self], ScopeDef::ImplSelfType(*i));
503 } 503 }
504 Scope::AdtScope(i) => { 504 Scope::AdtScope(i) => {
505 f(name![Self], ScopeDef::AdtSelfType((*i).into())); 505 f(name![Self], ScopeDef::AdtSelfType(*i));
506 } 506 }
507 Scope::ExprScope(scope) => { 507 Scope::ExprScope(scope) => {
508 scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| { 508 scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| {