diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-25 12:03:57 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-25 12:03:57 +0000 |
commit | 7c9acf2f834c582d9cad4f7d0679a0697c591432 (patch) | |
tree | 5829e5a0e4567c532a5d430ed9406a8cd072f5ca /crates/ra_hir/src/ty/snapshots | |
parent | 4f67df904252c5fbbf3b892bb2e8405778bc904a (diff) | |
parent | cff9a7dfadc6069bbc7b49c3ceb8497c78d426ab (diff) |
Merge #897
897: Add basic const/static type inference r=flodiebold a=vipentti
This adds basic const/static type inference discussed in #887.
Currently the inference does not work for const/static declared inside a block. In addition the inference does not work inside the bodies of const/static.
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/snapshots')
3 files changed, 37 insertions, 7 deletions
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap index 131d1fa16..51f3fd4c0 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_associated_const.snap | |||
@@ -1,14 +1,14 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-02-21T21:51:46.497925200Z" | 2 | created: "2019-02-25T08:36:33.885804400Z" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | source: crates/ra_hir/src/ty/tests.rs | 4 | source: crates/ra_hir/src/ty/tests.rs |
5 | expression: "&result" | 5 | expression: "&result" |
6 | --- | 6 | --- |
7 | [227; 305) '{ ...:ID; }': () | 7 | [227; 305) '{ ...:ID; }': () |
8 | [237; 238) 'x': [unknown] | 8 | [237; 238) 'x': u32 |
9 | [241; 252) 'Struct::FOO': [unknown] | 9 | [241; 252) 'Struct::FOO': u32 |
10 | [262; 263) 'y': [unknown] | 10 | [262; 263) 'y': u32 |
11 | [266; 275) 'Enum::BAR': [unknown] | 11 | [266; 275) 'Enum::BAR': u32 |
12 | [285; 286) 'z': [unknown] | 12 | [285; 286) 'z': u32 |
13 | [289; 302) 'TraitTest::ID': [unknown] | 13 | [289; 302) 'TraitTest::ID': u32 |
14 | 14 | ||
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_const.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_const.snap new file mode 100644 index 000000000..a5eba3980 --- /dev/null +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_const.snap | |||
@@ -0,0 +1,14 @@ | |||
1 | --- | ||
2 | created: "2019-02-25T07:26:34.115351100Z" | ||
3 | creator: [email protected] | ||
4 | source: crates/ra_hir/src/ty/tests.rs | ||
5 | expression: "&result" | ||
6 | --- | ||
7 | [95; 213) '{ ...NST; }': () | ||
8 | [138; 139) 'x': [unknown] | ||
9 | [142; 153) 'LOCAL_CONST': [unknown] | ||
10 | [163; 164) 'z': u32 | ||
11 | [167; 179) 'GLOBAL_CONST': u32 | ||
12 | [189; 191) 'id': u32 | ||
13 | [194; 210) 'Foo::A..._CONST': u32 | ||
14 | |||
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_static.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_static.snap new file mode 100644 index 000000000..5d90f56ed --- /dev/null +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_static.snap | |||
@@ -0,0 +1,16 @@ | |||
1 | --- | ||
2 | created: "2019-02-25T08:20:17.807316Z" | ||
3 | creator: [email protected] | ||
4 | source: crates/ra_hir/src/ty/tests.rs | ||
5 | expression: "&result" | ||
6 | --- | ||
7 | [85; 280) '{ ...MUT; }': () | ||
8 | [173; 174) 'x': [unknown] | ||
9 | [177; 189) 'LOCAL_STATIC': [unknown] | ||
10 | [199; 200) 'y': [unknown] | ||
11 | [203; 219) 'LOCAL_...IC_MUT': [unknown] | ||
12 | [229; 230) 'z': u32 | ||
13 | [233; 246) 'GLOBAL_STATIC': u32 | ||
14 | [256; 257) 'w': u32 | ||
15 | [260; 277) 'GLOBAL...IC_MUT': u32 | ||
16 | |||