From cb863390f23bc2eac6561d55def9bd3ba54605fc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 15 Jan 2021 18:57:32 +0100 Subject: Handle self/super/crate in PathSegment as NameRef --- crates/hir/src/semantics/source_to_def.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/hir/src/semantics/source_to_def.rs') 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<'_, '_> { let pat_id = source_map.node_pat(src.as_ref())?; Some((container, pat_id)) } + pub(super) fn self_param_to_def( + &mut self, + src: InFile, + ) -> Option<(DefWithBodyId, PatId)> { + let container = self.find_pat_or_label_container(src.as_ref().map(|it| it.syntax()))?; + let (_body, source_map) = self.db.body_with_source_map(container); + let pat_id = source_map.node_self_param(src.as_ref())?; + Some((container, pat_id)) + } pub(super) fn label_to_def( &mut self, src: InFile, -- cgit v1.2.3