mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
fix: handle aliased pattern and simplify testcase
This commit is contained in:
parent
cf5f1e8620
commit
962d340460
2 changed files with 32 additions and 23 deletions
|
@ -294,7 +294,7 @@ pub(crate) fn render_resolution_with_import_pat(
|
|||
import_edit: LocatedImport,
|
||||
) -> Option<Builder> {
|
||||
let resolution = ScopeDef::from(import_edit.original_item);
|
||||
let local_name = scope_def_to_name(resolution, &ctx, &import_edit)?;
|
||||
let local_name = get_import_name(resolution, &ctx, &import_edit)?;
|
||||
Some(render_resolution_pat(ctx, pattern_ctx, local_name, Some(import_edit), resolution))
|
||||
}
|
||||
|
||||
|
|
|
@ -1671,43 +1671,52 @@ mod module {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn re_export_aliased_function() {
|
||||
fn re_export_aliased() {
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs crate:bar
|
||||
pub fn func(_: i32) -> i32 {}
|
||||
|
||||
//- /lib.rs crate:foo deps:bar
|
||||
pub use bar::func as my_func;
|
||||
|
||||
//- /main.rs crate:main deps:foo
|
||||
fn main() {
|
||||
m$0
|
||||
mod outer {
|
||||
mod inner {
|
||||
pub struct BarStruct;
|
||||
pub fn bar_fun() {}
|
||||
pub mod bar {}
|
||||
}
|
||||
pub use inner::bar as foo;
|
||||
pub use inner::bar_fun as foo_fun;
|
||||
pub use inner::BarStruct as FooStruct;
|
||||
}
|
||||
fn function() {
|
||||
foo$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn my_func(…) (use foo::my_func) fn(i32) -> i32
|
||||
st FooStruct (use outer::FooStruct) BarStruct
|
||||
md foo (use outer::foo)
|
||||
fn foo_fun() (use outer::foo_fun) fn()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn re_export_aliased_module() {
|
||||
fn re_export_aliased_pattern() {
|
||||
check(
|
||||
r#"
|
||||
//- /lib.rs crate:bar
|
||||
pub mod baz {}
|
||||
|
||||
//- /lib.rs crate:foo deps:bar
|
||||
pub use bar::baz as my_baz;
|
||||
|
||||
//- /main.rs crate:main deps:foo
|
||||
fn main() {
|
||||
m$0
|
||||
mod outer {
|
||||
mod inner {
|
||||
pub struct BarStruct;
|
||||
pub fn bar_fun() {}
|
||||
pub mod bar {}
|
||||
}
|
||||
pub use inner::bar as foo;
|
||||
pub use inner::bar_fun as foo_fun;
|
||||
pub use inner::BarStruct as FooStruct;
|
||||
}
|
||||
fn function() {
|
||||
let foo$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
md my_baz (use foo::my_baz)
|
||||
st FooStruct (use outer::FooStruct)
|
||||
md foo (use outer::foo)
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue