@@ -119,8 +119,7 @@ fn find_path_inner(
119
119
120
120
// - if the item is the crate root, return `crate`
121
121
let root = def_map. crate_root ( db) ;
122
- if item == ItemInNs :: Types ( ModuleDefId :: ModuleId ( root) ) && def_map. block_id ( ) . is_none ( ) {
123
- // FIXME: the `block_id()` check should be unnecessary, but affects the result
122
+ if item == ItemInNs :: Types ( ModuleDefId :: ModuleId ( root) ) {
124
123
return Some ( ModPath :: from_segments ( PathKind :: Crate , Vec :: new ( ) ) ) ;
125
124
}
126
125
@@ -131,7 +130,7 @@ fn find_path_inner(
131
130
}
132
131
133
132
// - if the item is the crate root of a dependency crate, return the name from the extern prelude
134
- for ( name, def_id) in def_map. extern_prelude ( ) {
133
+ for ( name, def_id) in root . def_map ( db ) . extern_prelude ( ) {
135
134
if item == ItemInNs :: Types ( * def_id) {
136
135
let name = scope_name. unwrap_or_else ( || name. clone ( ) ) ;
137
136
return Some ( ModPath :: from_segments ( PathKind :: Plain , vec ! [ name] ) ) ;
@@ -298,6 +297,7 @@ fn find_local_import_locations(
298
297
let data = & def_map[ from. local_id ] ;
299
298
let mut worklist =
300
299
data. children . values ( ) . map ( |child| def_map. module_id ( * child) ) . collect :: < Vec < _ > > ( ) ;
300
+ // FIXME: do we need to traverse out of block expressions here?
301
301
for ancestor in iter:: successors ( from. containing_module ( db) , |m| m. containing_module ( db) ) {
302
302
worklist. push ( ancestor) ;
303
303
}
@@ -947,10 +947,11 @@ fn main() {
947
947
$0
948
948
}
949
949
"# ,
950
+ // FIXME: these could use fewer/better prefixes
950
951
"module::CompleteMe" ,
951
- "module::CompleteMe" ,
952
952
"crate::module::CompleteMe" ,
953
- "self::module::CompleteMe" ,
953
+ "crate::module::CompleteMe" ,
954
+ "crate::module::CompleteMe" ,
954
955
)
955
956
}
956
957
@@ -977,6 +978,28 @@ mod bar {
977
978
)
978
979
}
979
980
981
+ #[ test]
982
+ fn from_inside_module_with_inner_items ( ) {
983
+ check_found_path (
984
+ r#"
985
+ mod baz {
986
+ pub struct Foo {}
987
+ }
988
+
989
+ mod bar {
990
+ fn bar() {
991
+ fn inner() {}
992
+ $0
993
+ }
994
+ }
995
+ "# ,
996
+ "crate::baz::Foo" ,
997
+ "crate::baz::Foo" ,
998
+ "crate::baz::Foo" ,
999
+ "crate::baz::Foo" ,
1000
+ )
1001
+ }
1002
+
980
1003
#[ test]
981
1004
fn recursive_pub_mod_reexport ( ) {
982
1005
cov_mark:: check!( recursive_imports) ;
@@ -1004,4 +1027,34 @@ pub mod name {
1004
1027
"self::name::AsName" ,
1005
1028
) ;
1006
1029
}
1030
+
1031
+ #[ test]
1032
+ fn extern_crate ( ) {
1033
+ check_found_path (
1034
+ r#"
1035
+ //- /main.rs crate:main deps:dep
1036
+ $0
1037
+ //- /dep.rs crate:dep
1038
+ "# ,
1039
+ "dep" ,
1040
+ "dep" ,
1041
+ "dep" ,
1042
+ "dep" ,
1043
+ ) ;
1044
+
1045
+ check_found_path (
1046
+ r#"
1047
+ //- /main.rs crate:main deps:dep
1048
+ fn f() {
1049
+ fn inner() {}
1050
+ $0
1051
+ }
1052
+ //- /dep.rs crate:dep
1053
+ "# ,
1054
+ "dep" ,
1055
+ "dep" ,
1056
+ "dep" ,
1057
+ "dep" ,
1058
+ ) ;
1059
+ }
1007
1060
}
0 commit comments