mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Update assists test fixtures
This commit is contained in:
parent
ca06b090d7
commit
760ad445e2
6 changed files with 18 additions and 29 deletions
|
@ -1,6 +1,5 @@
|
||||||
//! Type tree for term search
|
//! Type tree for term search
|
||||||
|
|
||||||
use hir_def::find_path::PrefixKind;
|
|
||||||
use hir_expand::mod_path::ModPath;
|
use hir_expand::mod_path::ModPath;
|
||||||
use hir_ty::{
|
use hir_ty::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
|
@ -21,23 +20,8 @@ fn mod_item_path(
|
||||||
prefer_prelude: bool,
|
prefer_prelude: bool,
|
||||||
) -> Option<ModPath> {
|
) -> Option<ModPath> {
|
||||||
let db = sema_scope.db;
|
let db = sema_scope.db;
|
||||||
// Account for locals shadowing items from module
|
|
||||||
let name_hit_count = def.name(db).map(|def_name| {
|
|
||||||
let mut name_hit_count = 0;
|
|
||||||
sema_scope.process_all_names(&mut |name, _| {
|
|
||||||
if name == def_name {
|
|
||||||
name_hit_count += 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
name_hit_count
|
|
||||||
});
|
|
||||||
|
|
||||||
let m = sema_scope.module();
|
let m = sema_scope.module();
|
||||||
let prefix = match name_hit_count {
|
m.find_path(db.upcast(), *def, prefer_no_std, prefer_prelude)
|
||||||
Some(0..=1) | None => PrefixKind::Plain,
|
|
||||||
Some(_) => PrefixKind::ByCrate,
|
|
||||||
};
|
|
||||||
m.find_use_path(db.upcast(), *def, prefix, prefer_no_std, prefer_prelude)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to get path to `ModuleDef` as string
|
/// Helper function to get path to `ModuleDef` as string
|
||||||
|
|
|
@ -1521,7 +1521,7 @@ mod foo {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
r#"
|
r#"
|
||||||
use crate::foo::Bool;
|
use foo::Bool;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
use foo::FOO;
|
use foo::FOO;
|
||||||
|
@ -1602,7 +1602,7 @@ pub mod bar {
|
||||||
"#,
|
"#,
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs
|
//- /main.rs
|
||||||
use crate::foo::bar::Bool;
|
use foo::bar::Bool;
|
||||||
|
|
||||||
mod foo;
|
mod foo;
|
||||||
|
|
||||||
|
|
|
@ -811,7 +811,7 @@ pub mod bar {
|
||||||
"#,
|
"#,
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs
|
//- /main.rs
|
||||||
use crate::foo::bar::BarResult;
|
use foo::bar::BarResult;
|
||||||
|
|
||||||
mod foo;
|
mod foo;
|
||||||
|
|
||||||
|
|
|
@ -881,7 +881,7 @@ fn another_fn() {
|
||||||
r#"use my_mod::my_other_mod::MyField;
|
r#"use my_mod::my_other_mod::MyField;
|
||||||
|
|
||||||
mod my_mod {
|
mod my_mod {
|
||||||
use self::my_other_mod::MyField;
|
use my_other_mod::MyField;
|
||||||
|
|
||||||
fn another_fn() {
|
fn another_fn() {
|
||||||
let m = my_other_mod::MyEnum::MyField(MyField(1, 1));
|
let m = my_other_mod::MyEnum::MyField(MyField(1, 1));
|
||||||
|
|
|
@ -637,13 +637,17 @@ fn get_mod_path(
|
||||||
prefer_no_std: bool,
|
prefer_no_std: bool,
|
||||||
prefer_prelude: bool,
|
prefer_prelude: bool,
|
||||||
) -> Option<ModPath> {
|
) -> Option<ModPath> {
|
||||||
module_with_candidate.find_use_path(
|
if let Some(prefix_kind) = prefixed {
|
||||||
db,
|
module_with_candidate.find_use_path(
|
||||||
item_to_search,
|
db,
|
||||||
prefixed.unwrap_or(PrefixKind::Plain),
|
item_to_search,
|
||||||
prefer_no_std,
|
prefix_kind,
|
||||||
prefer_prelude,
|
prefer_no_std,
|
||||||
)
|
prefer_prelude,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
module_with_candidate.find_path(db, item_to_search, prefer_no_std, prefer_prelude)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImportCandidate {
|
impl ImportCandidate {
|
||||||
|
|
|
@ -368,6 +368,7 @@ fn main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME
|
||||||
#[test]
|
#[test]
|
||||||
fn local_shadow_fn() {
|
fn local_shadow_fn() {
|
||||||
check_fixes_unordered(
|
check_fixes_unordered(
|
||||||
|
@ -385,7 +386,7 @@ fn f() {
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn f() {
|
||||||
let f: i32 = 0;
|
let f: i32 = 0;
|
||||||
crate::f()
|
f()
|
||||||
}"#,
|
}"#,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue