diff options
Diffstat (limited to 'crates/ra_hir_def/src/path.rs')
-rw-r--r-- | crates/ra_hir_def/src/path.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 626ebffdc..0e606fd0e 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! A desugared representation of paths like `crate::foo` or `<Type as Trait>::bar`. |
2 | 2 | ||
3 | use std::{iter, sync::Arc}; | 3 | use std::{iter, sync::Arc}; |
4 | 4 | ||
@@ -66,7 +66,7 @@ pub enum PathKind { | |||
66 | 66 | ||
67 | impl Path { | 67 | impl Path { |
68 | /// Calls `cb` with all paths, represented by this use item. | 68 | /// Calls `cb` with all paths, represented by this use item. |
69 | pub fn expand_use_item( | 69 | pub(crate) fn expand_use_item( |
70 | item_src: Source<ast::UseItem>, | 70 | item_src: Source<ast::UseItem>, |
71 | hygiene: &Hygiene, | 71 | hygiene: &Hygiene, |
72 | mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>), | 72 | mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>), |
@@ -76,7 +76,10 @@ impl Path { | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | pub fn from_simple_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> Path { | 79 | pub(crate) fn from_simple_segments( |
80 | kind: PathKind, | ||
81 | segments: impl IntoIterator<Item = Name>, | ||
82 | ) -> Path { | ||
80 | Path { | 83 | Path { |
81 | kind, | 84 | kind, |
82 | segments: segments | 85 | segments: segments |
@@ -94,7 +97,7 @@ impl Path { | |||
94 | 97 | ||
95 | /// Converts an `ast::Path` to `Path`. Works with use trees. | 98 | /// Converts an `ast::Path` to `Path`. Works with use trees. |
96 | /// It correctly handles `$crate` based path from macro call. | 99 | /// It correctly handles `$crate` based path from macro call. |
97 | pub fn from_src(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> { | 100 | pub(crate) fn from_src(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> { |
98 | let mut kind = PathKind::Plain; | 101 | let mut kind = PathKind::Plain; |
99 | let mut segments = Vec::new(); | 102 | let mut segments = Vec::new(); |
100 | loop { | 103 | loop { |
@@ -192,7 +195,7 @@ impl Path { | |||
192 | } | 195 | } |
193 | 196 | ||
194 | /// Converts an `ast::NameRef` into a single-identifier `Path`. | 197 | /// Converts an `ast::NameRef` into a single-identifier `Path`. |
195 | pub fn from_name_ref(name_ref: &ast::NameRef) -> Path { | 198 | pub(crate) fn from_name_ref(name_ref: &ast::NameRef) -> Path { |
196 | name_ref.as_name().into() | 199 | name_ref.as_name().into() |
197 | } | 200 | } |
198 | 201 | ||
@@ -227,7 +230,7 @@ impl Path { | |||
227 | } | 230 | } |
228 | 231 | ||
229 | impl GenericArgs { | 232 | impl GenericArgs { |
230 | pub fn from_ast(node: ast::TypeArgList) -> Option<GenericArgs> { | 233 | pub(crate) fn from_ast(node: ast::TypeArgList) -> Option<GenericArgs> { |
231 | let mut args = Vec::new(); | 234 | let mut args = Vec::new(); |
232 | for type_arg in node.type_args() { | 235 | for type_arg in node.type_args() { |
233 | let type_ref = TypeRef::from_ast_opt(type_arg.type_ref()); | 236 | let type_ref = TypeRef::from_ast_opt(type_arg.type_ref()); |