10484: internal: Update match checking algorithm r=lnicola a=iDawer
Sync match checking algorithm with rust-lang/rust f31622a50 2021-11-12 (https://github.com/rust-lang/rust/pull/90813)
This update brings huge simplification to the match checking and introduces an easy to use machinery for pattern destructuring and also:
1. Add a function to do post-inference normalization `hir_ty::infer::normalize(...)`.
2. Store binding modes in `InferenceResult`.
Todo:
- [x] Rebase & test (https://github.com/rust-analyzer/rust-analyzer/pull/10484#issuecomment-996669665)
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
11062: fix: Don't say "a reference to" for `Copy` types in the generate getter assist r=Veykril a=patrick-gu
This changes the generate getter assist to not say "a reference to" in the documentation stub if the type is `Copy`, as the getter does not return a reference.
To determine whether the type is `Copy`, I have added an `is_copy` method to `ReferenceConversion`.
Co-authored-by: patrick-gu <55641350+patrick-gu@users.noreply.github.com>
This changes the generate getter assist to not say "a reference to" in the documentation stub if the type is Copy, as the getter does not return a reference.
11054: fix#11049 by removing double trimming r=Veykril a=Heinenen
The `unwrap_trivial_block()` removes the braces around trivial blocks (as the name suggests). This violates the precondition of `update_expr_string()` which removes the first and the last non-whitespace character and thus expects braces to still exist around all blocks.
Co-authored-by: ucrhh <ucrrh@sutdent.kit.edu>
11053: feat: Publish platform-specific Code VSIXes r=me a=lnicola
Closes#10483
CC #10371
Some notes:
- we still build a plain VSIX, just in case
- we build the extension on every platform to make the release workflow arguably cleaner
- the Windows VSIX includes the PDB (but let's leave #10371 open until we change the Windows stand-alone release to a ZIP file)
- `npm` doesn't run if started from `xtask`, possibly something related to path mapping; I moved the `npm` calls outside, but..
- the `Patch` thingy doesn't work any more, so you'll end up with a dirty `package.json` of you run `cargo xtask --client-patch-version`; I don't think we should block on this
- there's an untested Alpine build; for better or worse, we special-case `musl` distros as `alpine`
- I tested this as much as I could, but not the publishing and nightly updates
- you can find some sample artifacts under https://github.com/lnicola/rust-analyzer/releases
- we can now run the server from the install location (is Code planning to switch to compressed extensions?), except on NixOS
- Code lets you install a VSIX for the wrong platform (with the results one would expect)
- I don't know what happens if we try to publish a VSIX without a target
This is a relatively risky, but we'll probably have to take our chances with it.
r? `@rust-analyzer/review`
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
11047: internal: Prepare Code extension for bundling r=lnicola a=lnicola
CC #10483
This is slightly ugly, but we'll be able to clean it up after ripping the download parts (unless we decide to temporarily drop support for the nightlies).
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
11043: fix: fix incorrect mismatched argument count diagnostic with `std::arch` functions r=jonas-schievink a=jonas-schievink
Adds basic support for `#[rustc_legacy_const_generics]`.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10009
Full support would involve actually checking call arguments against the right expected types.
bors r+
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
11030: Add comma for "move if to guard" r=Veykril a=weirane
As I mentioned in #11017, there is a little issue in the implementation for if branch. This code
```rust
let y = match 92 {
x => {
if x == 0 {$0
false
}
}
_ => true,
};
```
will be transformed to
```rust
let y = match 92 {
x if x == 0 => false
_ => true,
};
```
a comma is missing after the false. I moved the fix from the code handling else branch to above.
Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>