aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-11 23:00:37 +0000
committerGitHub <[email protected]>2020-01-11 23:00:37 +0000
commit86d2af9f7b3f6af2ea9e4eca2584aa501b60aa14 (patch)
treee5ae070838d2ecbb3bb71efad06a2927e42dde70 /crates/ra_hir_def/src/nameres
parentbcfd297f4910bbf2305ec859d7cf42b7dca25f57 (diff)
parent9dc1826cfaa75983a83f9eb7f788067d5dedf5a7 (diff)
Merge #2803
2803: Fix various names, e.g. Iterator not resolving in core prelude r=matklad a=flodiebold 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. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-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 "