fix #2377 super::super::*

This commit is contained in:
Josh Mcguigan 2020-02-29 19:48:55 -08:00
parent e91320632a
commit 69faf81e0d
2 changed files with 43 additions and 4 deletions

View File

@ -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);

View File

@ -103,10 +103,13 @@ fn convert_path(prefix: Option<ModPath>, 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