Skip to content

Commit 69faf81

Browse files
committed
fix #2377 super::super::*
1 parent e913206 commit 69faf81

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

crates/ra_hir_def/src/nameres/tests.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,42 @@ fn crate_def_map_smoke_test() {
6565
"###)
6666
}
6767

68+
#[test]
69+
fn 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+
68104
#[test]
69105
fn bogus_paths() {
70106
covers!(bogus_paths);

crates/ra_hir_def/src/path/lower/lower_use.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ fn convert_path(prefix: Option<ModPath>, path: ast::Path, hygiene: &Hygiene) ->
103103
ModPath::from_segments(PathKind::Super(0), iter::empty())
104104
}
105105
ast::PathSegmentKind::SuperKw => {
106-
if prefix.is_some() {
107-
return None;
108-
}
109-
ModPath::from_segments(PathKind::Super(1), iter::empty())
106+
let nested_super_count = match prefix.map(|p| p.kind) {
107+
Some(PathKind::Super(n)) => n,
108+
Some(_) => return None,
109+
None => 0,
110+
};
111+
112+
ModPath::from_segments(PathKind::Super(nested_super_count + 1), iter::empty())
110113
}
111114
ast::PathSegmentKind::Type { .. } => {
112115
// not allowed in imports

0 commit comments

Comments
 (0)