aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2020-03-01 03:48:55 +0000
committerJosh Mcguigan <[email protected]>2020-03-01 03:48:55 +0000
commit69faf81e0db5abe54b97708c5b8089934fca32f6 (patch)
treeeb7912438471345d4c92108c04ae76d3c5f2728d /crates/ra_hir_def
parente91320632a9dfee937c3c2ba3ffafd3f5ffb22dc (diff)
fix #2377 super::super::*
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/nameres/tests.rs36
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs11
2 files changed, 43 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index 82f0f835c..dda5ed699 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -66,6 +66,42 @@ fn crate_def_map_smoke_test() {
66} 66}
67 67
68#[test] 68#[test]
69fn crate_def_map_super_super() {
70 let map = def_map(
71 "
72 //- /lib.rs
73 mod a {
74 const A: usize = 0;
75
76 mod b {
77 const B: usize = 0;
78
79 mod c {
80 use super::super::*;
81 }
82 }
83 }
84 ",
85 );
86 assert_snapshot!(map, @r###"
87 ⋮crate
88 ⋮a: t
89
90 ⋮crate::a
91 ⋮A: v
92 ⋮b: t
93
94 ⋮crate::a::b
95 ⋮B: v
96 ⋮c: t
97
98 ⋮crate::a::b::c
99 ⋮A: v
100 ⋮b: t
101 "###)
102}
103
104#[test]
69fn bogus_paths() { 105fn bogus_paths() {
70 covers!(bogus_paths); 106 covers!(bogus_paths);
71 let map = def_map( 107 let map = def_map(
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs
index b6d1125e2..278d5196e 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -103,10 +103,13 @@ fn convert_path(prefix: Option<ModPath>, path: ast::Path, hygiene: &Hygiene) ->
103 ModPath::from_segments(PathKind::Super(0), iter::empty()) 103 ModPath::from_segments(PathKind::Super(0), iter::empty())
104 } 104 }
105 ast::PathSegmentKind::SuperKw => { 105 ast::PathSegmentKind::SuperKw => {
106 if prefix.is_some() { 106 let nested_super_count = match prefix.map(|p| p.kind) {
107 return None; 107 Some(PathKind::Super(n)) => n,
108 } 108 Some(_) => return None,
109 ModPath::from_segments(PathKind::Super(1), iter::empty()) 109 None => 0,
110 };
111
112 ModPath::from_segments(PathKind::Super(nested_super_count + 1), iter::empty())
110 } 113 }
111 ast::PathSegmentKind::Type { .. } => { 114 ast::PathSegmentKind::Type { .. } => {
112 // not allowed in imports 115 // not allowed in imports