mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Merge #11259
11259: fix: fix `use super::{super::...};` r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11249 bors r+ Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
This commit is contained in:
commit
a3393c9a57
2 changed files with 53 additions and 6 deletions
|
@ -790,14 +790,26 @@ impl UseTree {
|
||||||
}
|
}
|
||||||
Some((prefix, ImportKind::Plain))
|
Some((prefix, ImportKind::Plain))
|
||||||
}
|
}
|
||||||
(Some(prefix), PathKind::Super(0)) => {
|
(Some(mut prefix), PathKind::Super(n))
|
||||||
// `some::path::self` == `some::path`
|
if *n > 0 && prefix.segments().is_empty() =>
|
||||||
if path.segments().is_empty() {
|
{
|
||||||
Some((prefix, ImportKind::TypeOnly))
|
// `super::super` + `super::rest`
|
||||||
} else {
|
match &mut prefix.kind {
|
||||||
None
|
PathKind::Super(m) => {
|
||||||
|
cov_mark::hit!(concat_super_mod_paths);
|
||||||
|
*m += *n;
|
||||||
|
for segment in path.segments() {
|
||||||
|
prefix.push_segment(segment.clone());
|
||||||
|
}
|
||||||
|
Some((prefix, ImportKind::Plain))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(Some(prefix), PathKind::Super(0)) if path.segments().is_empty() => {
|
||||||
|
// `some::path::self` == `some::path`
|
||||||
|
Some((prefix, ImportKind::TypeOnly))
|
||||||
|
}
|
||||||
(Some(_), _) => None,
|
(Some(_), _) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -890,3 +890,38 @@ pub struct Struct;
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn braced_supers_in_use_tree() {
|
||||||
|
cov_mark::check!(concat_super_mod_paths);
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
mod some_module {
|
||||||
|
pub fn unknown_func() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod other_module {
|
||||||
|
mod some_submodule {
|
||||||
|
use { super::{ super::unknown_func, }, };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use some_module::unknown_func;
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
other_module: t
|
||||||
|
some_module: t
|
||||||
|
unknown_func: v
|
||||||
|
|
||||||
|
crate::some_module
|
||||||
|
unknown_func: v
|
||||||
|
|
||||||
|
crate::other_module
|
||||||
|
some_submodule: t
|
||||||
|
|
||||||
|
crate::other_module::some_submodule
|
||||||
|
unknown_func: v
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue