diff options
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/method_resolution.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 46 |
2 files changed, 48 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 8b59a8bd6..c19519cf1 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs | |||
@@ -281,6 +281,7 @@ pub fn iterate_method_candidates<T>( | |||
281 | name, | 281 | name, |
282 | mode, | 282 | mode, |
283 | &mut |ty, item| { | 283 | &mut |ty, item| { |
284 | assert!(slot.is_none()); | ||
284 | slot = callback(ty, item); | 285 | slot = callback(ty, item); |
285 | slot.is_some() | 286 | slot.is_some() |
286 | }, | 287 | }, |
@@ -288,7 +289,7 @@ pub fn iterate_method_candidates<T>( | |||
288 | slot | 289 | slot |
289 | } | 290 | } |
290 | 291 | ||
291 | pub fn iterate_method_candidates_impl( | 292 | fn iterate_method_candidates_impl( |
292 | ty: &Canonical<Ty>, | 293 | ty: &Canonical<Ty>, |
293 | db: &dyn HirDatabase, | 294 | db: &dyn HirDatabase, |
294 | env: Arc<TraitEnvironment>, | 295 | env: Arc<TraitEnvironment>, |
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index d7ef9add6..7d8197f8b 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs | |||
@@ -1739,6 +1739,52 @@ fn main() { | |||
1739 | assert_eq!(t, "u32"); | 1739 | assert_eq!(t, "u32"); |
1740 | } | 1740 | } |
1741 | 1741 | ||
1742 | // This test is actually testing the shadowing behavior within ra_hir_def. It | ||
1743 | // lives here because the testing infrastructure in ra_hir_def isn't currently | ||
1744 | // capable of asserting the necessary conditions. | ||
1745 | #[test] | ||
1746 | fn should_be_shadowing_imports() { | ||
1747 | let t = type_at( | ||
1748 | r#" | ||
1749 | mod a { | ||
1750 | pub fn foo() -> i8 {0} | ||
1751 | pub struct foo { a: i8 } | ||
1752 | } | ||
1753 | mod b { pub fn foo () -> u8 {0} } | ||
1754 | mod c { pub struct foo { a: u8 } } | ||
1755 | mod d { | ||
1756 | pub use super::a::*; | ||
1757 | pub use super::c::foo; | ||
1758 | pub use super::b::foo; | ||
1759 | } | ||
1760 | |||
1761 | fn main() { | ||
1762 | d::foo()<|>; | ||
1763 | }"#, | ||
1764 | ); | ||
1765 | assert_eq!(t, "u8"); | ||
1766 | |||
1767 | let t = type_at( | ||
1768 | r#" | ||
1769 | mod a { | ||
1770 | pub fn foo() -> i8 {0} | ||
1771 | pub struct foo { a: i8 } | ||
1772 | } | ||
1773 | mod b { pub fn foo () -> u8 {0} } | ||
1774 | mod c { pub struct foo { a: u8 } } | ||
1775 | mod d { | ||
1776 | pub use super::a::*; | ||
1777 | pub use super::c::foo; | ||
1778 | pub use super::b::foo; | ||
1779 | } | ||
1780 | |||
1781 | fn main() { | ||
1782 | d::foo{a:0<|>}; | ||
1783 | }"#, | ||
1784 | ); | ||
1785 | assert_eq!(t, "u8"); | ||
1786 | } | ||
1787 | |||
1742 | #[test] | 1788 | #[test] |
1743 | fn closure_return() { | 1789 | fn closure_return() { |
1744 | assert_snapshot!( | 1790 | assert_snapshot!( |