rust-analyzer/crates/hir-def/src
bors 2ff505ab48 Auto merge of #12428 - lowr:experimental/destructuring-assignment, r=flodiebold
feat: implement destructuring assignment

This is an attempt to implement destructuring assignments, or more specifically, type inference for [assignee expressions](https://doc.rust-lang.org/reference/expressions.html#place-expressions-and-value-expressions).

I'm not sure if this is the right approach, so I don't even expect this to be merged (hence the branch name 😉) but rather want to propose one direction we could choose. I don't mind getting merged if this is good enough though!

Some notes on the implementation choices:

- Assignee expressions are **not** desugared on HIR level unlike rustc, but are inferred directly along with other expressions. This matches the processing of other syntaxes that are desugared in rustc but not in r-a. I find this reasonable because r-a only needs to infer types and it's easier to relate AST nodes and HIR nodes, so I followed it.
- Assignee expressions obviously resemble patterns, so type inference for each kind of pattern and its corresponding assignee expressions share a significant amount of logic. I tried to reuse the type inference functions for patterns by introducing `PatLike` trait which generalizes assignee expressions and patterns.
  - This is not the most elegant solution I suspect (and I really don't like the name of the trait!), but it's cleaner and the change is smaller than other ways I experimented, like making the functions generic without such trait, or making them take `Either<ExprId, PatId>` in place of `PatId`.

in case this is merged:
Closes #11532
Closes #11839
Closes #12322
2022-06-30 09:14:12 +00:00
..
body Auto merge of #12428 - lowr:experimental/destructuring-assignment, r=flodiebold 2022-06-30 09:14:12 +00:00
item_tree remove inherit_visibility test case in item_tree 2022-06-14 23:24:48 +08:00
macro_expansion_tests feat: Support $$ in macros. 2022-06-02 21:48:28 +02:00
nameres fix: Report proc macro errors in expressions correctly as well 2022-06-28 10:43:22 +02:00
path style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
adt.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
attr.rs fix: add docs and remove unnecessary check 2022-05-05 13:41:33 +09:00
body.rs fix: Report proc macro errors in expressions correctly as well 2022-06-28 10:43:22 +02:00
builtin_attr.rs Remove handling of #[rustc_deprecated] 2022-05-04 22:25:58 -04:00
builtin_type.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
child_by_source.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
data.rs check if the container is trait and inherit the visibility 2022-06-15 07:47:06 +08:00
db.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
dyn_map.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
expr.rs Add Expr::Underscore 2022-06-01 01:21:57 +09:00
find_path.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
generics.rs internal: Simplify 2022-06-23 20:08:29 +02:00
import_map.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
intern.rs internal: Update dashmap and freeze its version 2022-06-10 16:19:52 +02:00
item_scope.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
item_tree.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
keys.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
lang_item.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
lib.rs revert hir-def lib.rs 2022-06-15 07:48:34 +08:00
macro_expansion_tests.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
nameres.rs Use the correct crates proc-macro loading error message 2022-06-15 18:06:33 +02:00
path.rs internal: Simplify 2022-06-23 20:08:29 +02:00
per_ns.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
resolver.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
src.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
test_db.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
trace.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
type_ref.rs internal: Simplify 2022-06-23 20:08:29 +02:00
visibility.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00