diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-03 14:02:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-03 14:02:23 +0000 |
commit | 15f143f0c33cbd382a2ad7a407d9601cb843d164 (patch) | |
tree | 0a357e2d3333a06e37f5cb8d6613733c1c0c78ac /crates/ra_hir_ty/src/tests.rs | |
parent | ba4f7fa02f746e5bb3efdaa06c2b35beaa4e3440 (diff) | |
parent | e4add45951511f9afe348bf6066a724deb0d3ccf (diff) |
Merge #2468
2468: Fix #2467 r=flodiebold a=flodiebold
The stand-alone `unify` requires that the type doesn't contain any type
variables. So we can't share the code here for now (without more refactoring)...
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index d5b8d10e2..2ea9e261c 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -4820,6 +4820,53 @@ fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> { | |||
4820 | assert_eq!(t, "{unknown}"); | 4820 | assert_eq!(t, "{unknown}"); |
4821 | } | 4821 | } |
4822 | 4822 | ||
4823 | #[test] | ||
4824 | fn bug_2467() { | ||
4825 | assert_snapshot!( | ||
4826 | infer(r#" | ||
4827 | struct S<T>(T); | ||
4828 | impl<T> S<T> { | ||
4829 | fn foo(self) -> T; | ||
4830 | } | ||
4831 | fn test() { | ||
4832 | // needs to nest multiple times for variable indices to get high enough | ||
4833 | let a = S::foo(S(1)); | ||
4834 | let b = S::foo(S(a)); | ||
4835 | let c = S::foo(S(b)); | ||
4836 | let d: u32 = S::foo(S(c)); | ||
4837 | } | ||
4838 | "#), | ||
4839 | @r###" | ||
4840 | [43; 47) 'self': S<T> | ||
4841 | [67; 255) '{ ...c)); }': () | ||
4842 | [153; 154) 'a': u32 | ||
4843 | [157; 163) 'S::foo': fn foo<u32>(S<T>) -> T | ||
4844 | [157; 169) 'S::foo(S(1))': u32 | ||
4845 | [164; 165) 'S': S<u32>(T) -> S<T> | ||
4846 | [164; 168) 'S(1)': S<u32> | ||
4847 | [166; 167) '1': u32 | ||
4848 | [179; 180) 'b': u32 | ||
4849 | [183; 189) 'S::foo': fn foo<u32>(S<T>) -> T | ||
4850 | [183; 195) 'S::foo(S(a))': u32 | ||
4851 | [190; 191) 'S': S<u32>(T) -> S<T> | ||
4852 | [190; 194) 'S(a)': S<u32> | ||
4853 | [192; 193) 'a': u32 | ||
4854 | [205; 206) 'c': u32 | ||
4855 | [209; 215) 'S::foo': fn foo<u32>(S<T>) -> T | ||
4856 | [209; 221) 'S::foo(S(b))': u32 | ||
4857 | [216; 217) 'S': S<u32>(T) -> S<T> | ||
4858 | [216; 220) 'S(b)': S<u32> | ||
4859 | [218; 219) 'b': u32 | ||
4860 | [231; 232) 'd': u32 | ||
4861 | [240; 246) 'S::foo': fn foo<u32>(S<T>) -> T | ||
4862 | [240; 252) 'S::foo(S(c))': u32 | ||
4863 | [247; 248) 'S': S<u32>(T) -> S<T> | ||
4864 | [247; 251) 'S(c)': S<u32> | ||
4865 | [249; 250) 'c': u32 | ||
4866 | "### | ||
4867 | ); | ||
4868 | } | ||
4869 | |||
4823 | fn type_at_pos(db: &TestDB, pos: FilePosition) -> String { | 4870 | fn type_at_pos(db: &TestDB, pos: FilePosition) -> String { |
4824 | let file = db.parse(pos.file_id).ok().unwrap(); | 4871 | let file = db.parse(pos.file_id).ok().unwrap(); |
4825 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); | 4872 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); |