feat: show only missing variant suggestion for enums in patterns completion and bump them in list too
Fixes#12438
### Points to help in review:
- This PR can be reviewed commit wise, first commit is about bumping enum variant completions up in the list of completions and second commit is about only showing enum variants which are not complete
- I am calculating missing variants in analysis.rs by firstly locating the enum and then comparing each of it's variant's name and checking if arm string already contains that name, this is kinda hacky but I didn't want to implement complete missing_arms assist here as that would have been too bulky to run on each completion cycle ( if we can improve this somehow would appreciate some inputs on it )
### Output:
https://user-images.githubusercontent.com/49019259/208245540-57d7321b-b275-477e-bef0-b3a1ff8b7040.mov
Relevant Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Issue.20.2312438
Previously, it would walk each directory twice: once in the main `Walk`
iterator, and once to count the number of entries in the directory. Now
it only walks each directory once.
- Skip files in `skip` wherever possible to avoid reading their contents
- Don't look for `tidy-alphabetic-start` in tests. It's never currently used and slows the check down a lot.
- Add new `filter_not_rust` helper function
Rollup of 9 pull requests
Successful merges:
- #109102 (Erase escaping late-bound regions when probing for ambiguous associated types)
- #109200 (Fix index out of bounds in `suggest_trait_fn_ty_for_impl_fn_infer`)
- #109211 (E0206 - update description )
- #109222 (Do not ICE for unexpected lifetime with ConstGeneric rib)
- #109235 (fallback to lstat when stat fails on Windows)
- #109248 (Pass the right HIR back from `get_fn_decl`)
- #109251 (Suggest surrounding the macro with `{}` to interpret as a statement)
- #109256 (Check for llvm-tools before install)
- #109257 (resolve: Improve debug impls for `NameBinding`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
resolve: Improve debug impls for `NameBinding`
Print at least the Some/None/Ok/Err status of the nested bindings if not the bindings themselves.
Noticed while reviewing https://github.com/rust-lang/rust/pull/108729.
Pass the right HIR back from `get_fn_decl`
Fixes#109232
Makes sure that the `fn_id: HirId` that we pass to `suggest_missing_return_type` matches up with the `fn_decl: hir::FnDecl` that we pass to it, so the late-bound vars that we fetch from the former match up with the types in the latter...
This HIR suggestion code really needs a big refactor. I've tried to do it in the past (a couple of attempts), but it's a super tangled mess. It really shouldn't be passing around things like `hir::Node` and just deal with `LocalDefId`s everywhere... Anyways, I'd rather fix this ICE, now.
Do not ICE for unexpected lifetime with ConstGeneric rib
Fixes#109143
r? ````@petrochenkov````
Combining this test with the previous test will affect the previous diagnostics, so I added a separate test case.
- only borrow the refcell once per loop
- avoid complex matches to reduce branch paths in the hot loop
- use a by-ref fast path that avoids mutations at the expense of having false negatives
- Separate out functions so that each unit test doesn't create a file on disk
- Add a few unit tests
Notably, verifying that we generate valid toml relies on python 3.11 so
we can use `tomllib`.