diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 82f0f835c80..dda5ed699c1 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs @@ -65,6 +65,42 @@ enum E { V } "###) } +#[test] +fn crate_def_map_super_super() { + let map = def_map( + " + //- /lib.rs + mod a { + const A: usize = 0; + + mod b { + const B: usize = 0; + + mod c { + use super::super::*; + } + } + } + ", + ); + assert_snapshot!(map, @r###" + ⋮crate + ⋮a: t + ⋮ + ⋮crate::a + ⋮A: v + ⋮b: t + ⋮ + ⋮crate::a::b + ⋮B: v + ⋮c: t + ⋮ + ⋮crate::a::b::c + ⋮A: v + ⋮b: t + "###) +} + #[test] fn bogus_paths() { covers!(bogus_paths); 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 b6d1125e20e..278d5196e7b 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, path: ast::Path, hygiene: &Hygiene) -> ModPath::from_segments(PathKind::Super(0), iter::empty()) } ast::PathSegmentKind::SuperKw => { - if prefix.is_some() { - return None; - } - ModPath::from_segments(PathKind::Super(1), iter::empty()) + let nested_super_count = match prefix.map(|p| p.kind) { + Some(PathKind::Super(n)) => n, + Some(_) => return None, + None => 0, + }; + + ModPath::from_segments(PathKind::Super(nested_super_count + 1), iter::empty()) } ast::PathSegmentKind::Type { .. } => { // not allowed in imports