diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-26 11:05:05 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-26 11:05:05 +0000 |
commit | 500e022f7decbee29a693b0f0dd2f63789a99e5a (patch) | |
tree | 2f7839288ce5676a89c6d6062cbaf70544e0beed /crates/ra_assists/src/assists/fill_match_arms.rs | |
parent | 5901cc736074bbc4d780a8e45079d405ab2cec4b (diff) | |
parent | e5eadb339039e21718d382c0b3d02a4bf053b3f4 (diff) |
Merge #2398
2398: WIP: introduce hir::Type r=matklad a=matklad
This introduces `hir::Type` wrapper over `hir::Ty`, with two purposes:
* bind `Ty` and it's corresponding environment
* Am I correct that `Ty` without an env doesn't make much sense, because the meaning of type parameters is unclear
* Am I correct that we can safely re-use the same environment for all types derived from the given type?
* hide representation defails of `Ty`. Specifically, I want to change `Ty::Adt` to use `hir_def::AdtId` instead of `hir::Adt`, but IDE doesn't know about underlying IDs. More generally, I feel like IDE shouldn't know that `Ty` is enum.
@flodiebold what do you think about this?
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists/fill_match_arms.rs')
-rw-r--r-- | crates/ra_assists/src/assists/fill_match_arms.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs index 8482897c5..b75bd44eb 100644 --- a/crates/ra_assists/src/assists/fill_match_arms.rs +++ b/crates/ra_assists/src/assists/fill_match_arms.rs | |||
@@ -83,10 +83,11 @@ fn resolve_enum_def( | |||
83 | ) -> Option<ast::EnumDef> { | 83 | ) -> Option<ast::EnumDef> { |
84 | let expr_ty = analyzer.type_of(db, &expr)?; | 84 | let expr_ty = analyzer.type_of(db, &expr)?; |
85 | 85 | ||
86 | analyzer.autoderef(db, expr_ty).find_map(|ty| match ty.as_adt() { | 86 | let res = expr_ty.autoderef(db).find_map(|ty| match ty.as_adt() { |
87 | Some((Adt::Enum(e), _)) => Some(e.source(db).value), | 87 | Some(Adt::Enum(e)) => Some(e.source(db).value), |
88 | _ => None, | 88 | _ => None, |
89 | }) | 89 | }); |
90 | res | ||
90 | } | 91 | } |
91 | 92 | ||
92 | fn build_pat(var: ast::EnumVariant) -> Option<ast::Pat> { | 93 | fn build_pat(var: ast::EnumVariant) -> Option<ast::Pat> { |