]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #95386 - compiler-errors:try-wrapping, r=oli-obk
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Tue, 29 Mar 2022 20:46:34 +0000 (22:46 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Mar 2022 20:46:34 +0000 (22:46 +0200)
commita0d2862ca41013337d07743c5e0831fe1fbddc99
treef28161a748323926631c797d0ebb9d18ec0a47ab
parent3208ed7b21b8b8f035b8a6bb3172be0763cf45ab
parentfc289a07960b652632f5b050b4a865975f356694
Rollup merge of #95386 - compiler-errors:try-wrapping, r=oli-obk

Suggest wrapping patterns in enum variants

Structured suggestion to wrap a pattern in a single-field enum or struct:

```diff
 struct A;

 enum B {
   A(A),
 }

 fn main(b: B) {
   match b {
-    A => {}
+    B::A(A) => {}
   }
 }
```

Half of #94942, the other half I'm not exactly sure how to fix.

Also includes two drive-by changes (that I am open to splitting out into another PR, but thought they could be rolled up into this one):
07776c111f07b887cd46b752870cd3fd76b2ba7c: Makes sure not to suggest wrapping if it doesn't have tuple field constructor (i.e. has named fields)
8f2bbb18fd53e5008bb488302dbd354577698ede: Also suggest wrapping expressions in a tuple struct (not just enum variants)