aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-15 17:57:32 +0000
committerLukas Wirth <[email protected]>2021-01-15 18:21:23 +0000
commitcb863390f23bc2eac6561d55def9bd3ba54605fc (patch)
treeb19b39d9b6231e8857a4096cc803cf35e2ddbe81 /crates/hir
parent0c58aa9dc0e24f0fa6a6ee7eb0c35041dedddb0a (diff)
Handle self/super/crate in PathSegment as NameRef
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/semantics.rs1
-rw-r--r--crates/hir/src/semantics/source_to_def.rs9
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index cd689c869..ab213e04c 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -750,6 +750,7 @@ to_def_impls![
750 (crate::ConstParam, ast::ConstParam, const_param_to_def), 750 (crate::ConstParam, ast::ConstParam, const_param_to_def),
751 (crate::MacroDef, ast::MacroRules, macro_rules_to_def), 751 (crate::MacroDef, ast::MacroRules, macro_rules_to_def),
752 (crate::Local, ast::IdentPat, bind_pat_to_def), 752 (crate::Local, ast::IdentPat, bind_pat_to_def),
753 (crate::Local, ast::SelfParam, self_param_to_def),
753 (crate::Label, ast::Label, label_to_def), 754 (crate::Label, ast::Label, label_to_def),
754]; 755];
755 756
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index 4b9ebff72..9bf60c72a 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -114,6 +114,15 @@ impl SourceToDefCtx<'_, '_> {
114 let pat_id = source_map.node_pat(src.as_ref())?; 114 let pat_id = source_map.node_pat(src.as_ref())?;
115 Some((container, pat_id)) 115 Some((container, pat_id))
116 } 116 }
117 pub(super) fn self_param_to_def(
118 &mut self,
119 src: InFile<ast::SelfParam>,
120 ) -> Option<(DefWithBodyId, PatId)> {
121 let container = self.find_pat_or_label_container(src.as_ref().map(|it| it.syntax()))?;
122 let (_body, source_map) = self.db.body_with_source_map(container);
123 let pat_id = source_map.node_self_param(src.as_ref())?;
124 Some((container, pat_id))
125 }
117 pub(super) fn label_to_def( 126 pub(super) fn label_to_def(
118 &mut self, 127 &mut self,
119 src: InFile<ast::Label>, 128 src: InFile<ast::Label>,