aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/descriptors/module/nameres.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/nameres.rs b/crates/ra_analysis/src/descriptors/module/nameres.rs
index 137aa8b17..b65b6adb7 100644
--- a/crates/ra_analysis/src/descriptors/module/nameres.rs
+++ b/crates/ra_analysis/src/descriptors/module/nameres.rs
@@ -136,7 +136,50 @@ impl InputModuleItems {
136} 136}
137 137
138fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> { 138fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> {
139 prefix 139 let prefix = if let Some(qual) = path.qualifier() {
140 Some(convert_path(prefix, qual)?)
141 } else {
142 None
143 };
144 let segment = path.segment()?;
145 let res = match segment.kind()? {
146 ast::PathSegmentKind::Name(name) => {
147 let mut res = prefix.unwrap_or_else(|| Path {
148 kind: PathKind::Abs,
149 segments: Vec::with_capacity(1),
150 });
151 res.segments.push(name.text());
152 res
153 }
154 ast::PathSegmentKind::CrateKw => {
155 if prefix.is_some() {
156 return None;
157 }
158 Path {
159 kind: PathKind::Crate,
160 segments: Vec::new(),
161 }
162 }
163 ast::PathSegmentKind::SelfKw => {
164 if prefix.is_some() {
165 return None;
166 }
167 Path {
168 kind: PathKind::Self_,
169 segments: Vec::new(),
170 }
171 }
172 ast::PathSegmentKind::SuperKw => {
173 if prefix.is_some() {
174 return None;
175 }
176 Path {
177 kind: PathKind::Super,
178 segments: Vec::new(),
179 }
180 }
181 };
182 Some(res)
140} 183}
141 184
142impl ModuleItem { 185impl ModuleItem {