From 9dc1826cfaa75983a83f9eb7f788067d5dedf5a7 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 11 Jan 2020 23:19:58 +0100 Subject: 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. --- crates/ra_hir_ty/src/tests/regression.rs | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index 6c5d39549..aa948dcbf 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs @@ -2,6 +2,8 @@ use insta::assert_snapshot; use test_utils::covers; use super::infer; +use crate::test_db::TestDB; +use ra_db::fixture::WithFixture; #[test] fn bug_484() { @@ -399,3 +401,55 @@ fn test() { "### ); } + +#[test] +fn issue_2683_chars_impl() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs crate:main deps:std +fn test() { + let chars: std::str::Chars<'_>; + (chars.next(), chars.nth(1))<|>; +} + +//- /std.rs crate:std +#[prelude_import] +use prelude::*; + +pub mod prelude { + pub use crate::iter::Iterator; + pub use crate::option::Option; +} + +pub mod iter { + pub use self::traits::Iterator; + pub mod traits { + pub use self::iterator::Iterator; + + pub mod iterator { + pub trait Iterator { + type Item; + fn next(&mut self) -> Option; + fn nth(&mut self, n: usize) -> Option {} + } + } + } +} + +pub mod option { + pub enum Option {} +} + +pub mod str { + pub struct Chars<'a> {} + impl<'a> Iterator for Chars<'a> { + type Item = char; + fn next(&mut self) -> Option {} + } +} +"#, + ); + + // should be Option, but currently not because of Chalk ambiguity problem + assert_eq!("(Option<{unknown}>, Option<{unknown}>)", super::type_at_pos(&db, pos)); +} -- cgit v1.2.3