aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-06 19:50:55 +0000
committerGitHub <[email protected]>2020-03-06 19:50:55 +0000
commit26ae35c62e29610552167d8cfced8e7e19096576 (patch)
tree7eaa1d80fffcd5a02f3652c1938d3eb7fbb5475c /crates/ra_hir_ty/src/tests
parenta42f29166b2b771927fef6061dd427f82eb28d68 (diff)
parentd17c5416af3d90b4c827224d4cd73366fa5a294b (diff)
Merge #3499
3499: Resolve `Self::AssocTy` in impls r=matklad a=flodiebold To do this we need to carry around the original resolution a bit, because `Self` gets resolved to the actual type immediately, but you're not allowed to write the equivalent type in a projection. (I tried just comparing the projection base type with the impl self type, but that seemed too dirty.) This is basically how rustc does it as well. Fixes #3249. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index 547010b35..f009a708c 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -1803,6 +1803,47 @@ fn test<T, U>() where T::Item: Trait2, T: Trait<U::Item>, U: Trait<()> {
1803} 1803}
1804 1804
1805#[test] 1805#[test]
1806fn unselected_projection_on_trait_self() {
1807 assert_snapshot!(infer(
1808 r#"
1809//- /main.rs
1810trait Trait {
1811 type Item;
1812
1813 fn f(&self, x: Self::Item);
1814}
1815
1816struct S;
1817
1818impl Trait for S {
1819 type Item = u32;
1820 fn f(&self, x: Self::Item) { let y = x; }
1821}
1822
1823struct S2;
1824
1825impl Trait for S2 {
1826 type Item = i32;
1827 fn f(&self, x: <Self>::Item) { let y = x; }
1828}
1829"#,
1830 ), @r###"
1831 [54; 58) 'self': &Self
1832 [60; 61) 'x': {unknown}
1833 [140; 144) 'self': &S
1834 [146; 147) 'x': u32
1835 [161; 175) '{ let y = x; }': ()
1836 [167; 168) 'y': u32
1837 [171; 172) 'x': u32
1838 [242; 246) 'self': &S2
1839 [248; 249) 'x': i32
1840 [265; 279) '{ let y = x; }': ()
1841 [271; 272) 'y': i32
1842 [275; 276) 'x': i32
1843 "###);
1844}
1845
1846#[test]
1806fn trait_impl_self_ty() { 1847fn trait_impl_self_ty() {
1807 let t = type_at( 1848 let t = type_at(
1808 r#" 1849 r#"