Update assists test fixtures · rust-lang/rust@b1830a5

File tree

6 files changed

lines changed

  • src/tools/rust-analyzer/crates

    • ide-diagnostics/src/handlers

6 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,5 @@

11

//! Type tree for term search

22
3-

use hir_def::find_path::PrefixKind;

43

use hir_expand::mod_path::ModPath;

54

use hir_ty::{

65

db::HirDatabase,

@@ -21,23 +20,8 @@ fn mod_item_path(

2120

prefer_prelude: bool,

2221

) -> Option<ModPath> {

2322

let db = sema_scope.db;

24-

// Account for locals shadowing items from module

25-

let name_hit_count = def.name(db).map(|def_name| {

26-

let mut name_hit_count = 0;

27-

sema_scope.process_all_names(&mut |name, _| {

28-

if name == def_name {

29-

name_hit_count += 1;

30-

}

31-

});

32-

name_hit_count

33-

});

34-
3523

let m = sema_scope.module();

36-

let prefix = match name_hit_count {

37-

Some(0..=1) | None => PrefixKind::Plain,

38-

Some(_) => PrefixKind::ByCrate,

39-

};

40-

m.find_use_path(db.upcast(), *def, prefix, prefer_no_std, prefer_prelude)

24+

m.find_path(db.upcast(), *def, prefer_no_std, prefer_prelude)

4125

}

4226
4327

/// Helper function to get path to `ModuleDef` as string

Original file line numberDiff line numberDiff line change

@@ -1521,7 +1521,7 @@ mod foo {

15211521

}

15221522

"#,

15231523

r#"

1524-

use crate::foo::Bool;

1524+

use foo::Bool;

15251525
15261526

fn main() {

15271527

use foo::FOO;

@@ -1602,7 +1602,7 @@ pub mod bar {

16021602

"#,

16031603

r#"

16041604

//- /main.rs

1605-

use crate::foo::bar::Bool;

1605+

use foo::bar::Bool;

16061606
16071607

mod foo;

16081608
Original file line numberDiff line numberDiff line change

@@ -811,7 +811,7 @@ pub mod bar {

811811

"#,

812812

r#"

813813

//- /main.rs

814-

use crate::foo::bar::BarResult;

814+

use foo::bar::BarResult;

815815
816816

mod foo;

817817
Original file line numberDiff line numberDiff line change

@@ -881,7 +881,7 @@ fn another_fn() {

881881

r#"use my_mod::my_other_mod::MyField;

882882
883883

mod my_mod {

884-

use self::my_other_mod::MyField;

884+

use my_other_mod::MyField;

885885
886886

fn another_fn() {

887887

let m = my_other_mod::MyEnum::MyField(MyField(1, 1));

Original file line numberDiff line numberDiff line change

@@ -637,13 +637,17 @@ fn get_mod_path(

637637

prefer_no_std: bool,

638638

prefer_prelude: bool,

639639

) -> Option<ModPath> {

640-

module_with_candidate.find_use_path(

641-

db,

642-

item_to_search,

643-

prefixed.unwrap_or(PrefixKind::Plain),

644-

prefer_no_std,

645-

prefer_prelude,

646-

)

640+

if let Some(prefix_kind) = prefixed {

641+

module_with_candidate.find_use_path(

642+

db,

643+

item_to_search,

644+

prefix_kind,

645+

prefer_no_std,

646+

prefer_prelude,

647+

)

648+

} else {

649+

module_with_candidate.find_path(db, item_to_search, prefer_no_std, prefer_prelude)

650+

}

647651

}

648652
649653

impl ImportCandidate {

Original file line numberDiff line numberDiff line change

@@ -368,6 +368,7 @@ fn main() {

368368

);

369369

}

370370
371+

// FIXME

371372

#[test]

372373

fn local_shadow_fn() {

373374

check_fixes_unordered(

@@ -385,7 +386,7 @@ fn f() {

385386

r#"

386387

fn f() {

387388

let f: i32 = 0;

388-

crate::f()

389+

f()

389390

}"#,

390391

],

391392

);