diff options
author | Aleksey Kladov <[email protected]> | 2019-12-18 16:41:33 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-18 16:41:33 +0000 |
commit | 04715cbe1caf92e55d393a352a12454ba958845e (patch) | |
tree | 8c4a839f9b3ac037429d20b568c5a573c7d65825 /crates/ra_hir_def/src/path | |
parent | 88c6109897417e7ab815ea1711f49545bff94601 (diff) |
Forbid <T>::foo syntax in mod paths
Diffstat (limited to 'crates/ra_hir_def/src/path')
-rw-r--r-- | crates/ra_hir_def/src/path/lower.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs index c71b52d89..62aafd508 100644 --- a/crates/ra_hir_def/src/path/lower.rs +++ b/crates/ra_hir_def/src/path/lower.rs | |||
@@ -22,6 +22,7 @@ pub(super) use lower_use::lower_use_tree; | |||
22 | /// It correctly handles `$crate` based path from macro call. | 22 | /// It correctly handles `$crate` based path from macro call. |
23 | pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> { | 23 | pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> { |
24 | let mut kind = PathKind::Plain; | 24 | let mut kind = PathKind::Plain; |
25 | let mut type_anchor = None; | ||
25 | let mut segments = Vec::new(); | 26 | let mut segments = Vec::new(); |
26 | let mut generic_args = Vec::new(); | 27 | let mut generic_args = Vec::new(); |
27 | loop { | 28 | loop { |
@@ -63,7 +64,8 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> | |||
63 | match trait_ref { | 64 | match trait_ref { |
64 | // <T>::foo | 65 | // <T>::foo |
65 | None => { | 66 | None => { |
66 | kind = PathKind::Type(Box::new(self_type)); | 67 | type_anchor = Some(Box::new(self_type)); |
68 | kind = PathKind::Plain; | ||
67 | } | 69 | } |
68 | // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo | 70 | // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo |
69 | Some(trait_ref) => { | 71 | Some(trait_ref) => { |
@@ -111,7 +113,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> | |||
111 | segments.reverse(); | 113 | segments.reverse(); |
112 | generic_args.reverse(); | 114 | generic_args.reverse(); |
113 | let mod_path = ModPath { kind, segments }; | 115 | let mod_path = ModPath { kind, segments }; |
114 | return Some(Path { mod_path, generic_args }); | 116 | return Some(Path { type_anchor, mod_path, generic_args }); |
115 | 117 | ||
116 | fn qualifier(path: &ast::Path) -> Option<ast::Path> { | 118 | fn qualifier(path: &ast::Path) -> Option<ast::Path> { |
117 | if let Some(q) = path.qualifier() { | 119 | if let Some(q) = path.qualifier() { |