aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-11 22:19:58 +0000
committerFlorian Diebold <[email protected]>2020-01-11 22:37:58 +0000
commit9dc1826cfaa75983a83f9eb7f788067d5dedf5a7 (patch)
treec92f033b4b97ee393dafb3a83537f47c4c82d435 /crates/ra_hir_def
parent2e09a96f82d4ba15de2c8b8fbbe40fd78e21c185 (diff)
Fix various names, e.g. Iterator not resolving in core prelude
Basically, `Iterator` is re-exported via several steps, which happened to not be resolved yet when we got to the prelude import, but since the name resolved to the reexport from `core::iter` (just to no actual items), we gave up trying to resolve it further. Maybe part of the problem is that we can have `PartialResolvedImport::Unresolved` or `PartialResolvedImport::Indeterminate` with `None` in all namespaces, and handle them differently. Fixes #2683.
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/tests/mod_resolution.rs45
2 files changed, 46 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 35b852ee2..7499dff31 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -328,7 +328,7 @@ where
328 ); 328 );
329 329
330 let def = res.resolved_def; 330 let def = res.resolved_def;
331 if res.reached_fixedpoint == ReachedFixedPoint::No { 331 if res.reached_fixedpoint == ReachedFixedPoint::No || def.is_none() {
332 return PartialResolvedImport::Unresolved; 332 return PartialResolvedImport::Unresolved;
333 } 333 }
334 334
diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
index e800cc68e..22103ab29 100644
--- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
@@ -53,6 +53,51 @@ fn nested_module_resolution() {
53} 53}
54 54
55#[test] 55#[test]
56fn nested_module_resolution_2() {
57 let map = def_map(
58 "
59 //- /lib.rs
60 mod prelude;
61 mod iter;
62
63 //- /prelude.rs
64 pub use crate::iter::Iterator;
65
66 //- /iter.rs
67 pub use self::traits::Iterator;
68 mod traits;
69
70 //- /iter/traits.rs
71 pub use self::iterator::Iterator;
72 mod iterator;
73
74 //- /iter/traits/iterator.rs
75 pub trait Iterator;
76 ",
77 );
78
79 assert_snapshot!(map, @r###"
80 crate
81 iter: t
82 prelude: t
83
84 crate::iter
85 Iterator: t
86 traits: t
87
88 crate::iter::traits
89 Iterator: t
90 iterator: t
91
92 crate::iter::traits::iterator
93 Iterator: t
94
95 crate::prelude
96 Iterator: t
97 "###);
98}
99
100#[test]
56fn module_resolution_works_for_non_standard_filenames() { 101fn module_resolution_works_for_non_standard_filenames() {
57 let map = def_map( 102 let map = def_map(
58 " 103 "