feat: Add trailing `;` when typing `=` in assignment
![Peek 2022-04-12 19-41](https://user-images.githubusercontent.com/1786438/163022079-1ed114ef-7c75-490f-a8ed-731a13f0b44d.gif)
This does have a false positive to keep in mind, it will add a trailing `;` in the following snippet too, which is probably not desired:
```rust
fn is_zero(i: i32) -> bool {
i $0 0
}
```
However, that function is unlikely to be written from the "inside out" like that, so it might be acceptable. Typically `=` is only inserted last when the author realizes that an existing expression should be assigned to some variable.
feat: allow customizing the command for running build scripts
I have tested this locally and it fixed#9201 with some small changes on the compiler side with suggestions from https://github.com/rust-analyzer/rust-analyzer/issues/9201#issuecomment-1019554086.
I have also added an environment variable `IS_RA_BUILDSCRIPT_CHECK` for crates to detect that it is a check for buildscripts, and allows defaulting to bogus values for expected environment variables.
11883: fix(ide): move moudle directory when rename r=rainy-me a=rainy-me
fix: #10992
Added `FileSystemEdit::MoveDir` variant for move dirs. Original implemented as recursively move child mod files but had many issues like
1. left empty dir after rename file
2. only affect rust file
3. not performant
so changed to current version
Co-authored-by: rainy-me <github@yue.coffee>
11964: internal: Show more project building errors to the user r=Veykril a=Veykril
Something very fishy is going on with the `rustc_workspace` handling, which caused this bug to only manifest in the `std` library but not other library crate... So there is either a bug there or just the fact that we seem to add duplicate dependencies (I think this is what we are doing with this right?) might be tripping something up somewhere.
cc https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Rust-analyzer.20use.20inside.20stdlib
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
11953: fix: `extract_module` is too eager r=Veykril a=iDawer
Refactored `extract_module`.
Searching for usages and import resolving are done lazily.
Close#11944
Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
- `T: ~const Drop` has a special meaning in Rust 1.61 that we don't implement.
(So ideally, we'd only ignore `~const Drop`, but this should be fine
for now.)
- `Destruct` impls are built-in in 1.62 (current nightlies as of 08-04-2022), so until
the builtin impls are supported by Chalk, we ignore them as well.
Since `Destruct` is implemented for everything in non-const contexts
IIUC, this should also work fine.
Fixes#11932.
11920: Consider types of const generics r=flodiebold a=HKalbasi
fix#11913
We should emit type_mismatch in const generics, probably after #7434. Currently they will lead to a misleading, time of use type error (like the added test).
Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
11925: internal: Add and use `HirFormatter::write_{str,char}` r=Veykril a=lnicola
Saves slightly over 3 KB of `text`, but comparing the total with that from two weeks ago in #11776, this is a losing battle (we're 951 KB larger).
```
text data bss dec hex filename
24693512 1542704 4424 26240640 1906680 rust-analyzer-baseline
24690216 1542112 4424 26236752 1905750 rust-analyzer-pr
```
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
While we don't support const args in type inference yet, we can at least
make use of the fallback path resolution to resolve paths in const args
in the IDE layer to enable some features for them.
11905: internal: Remove hir_expand macro recursion check r=jonas-schievink a=jonas-schievink
This check is insufficient to ensure finite macro nesting, and so all callers already have their own recursion limit, which makes this check redundant.
...at least I hope it's redundant. Would be great if someone could double-check this.
Originally, this check was added in https://github.com/rust-analyzer/rust-analyzer/pull/3671
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
11891: Better error message on Flycheck Error message (from: unactionable error message if we are using `clippy` as the checker) r=Veykril a=flipbit03
I have commented on this [S-unactionable issue](https://github.com/rust-analyzer/rust-analyzer/issues/6589) that the Flycheck error message should maybe provide a hint about what tool it actually runs. Searching on some places on the Internet I've found multiple people, including myself, losing copious amounts of time on the same issue. So I've decided to make this very small PR :-)
From an user experience standpoint, the current error message is unhelpful to the end user, because the end user does not know exactly what it needs to check/fix (outdated, broken, or missing `cargo clippy`). In my own case, `cargo clippy` was actually missing altogether (developing off `rust:1.59.0-bullseye` official Docker image).
Thanks in advance!
Co-authored-by: Cadu <cadu.coelho@gmail.com>
11896: fix: Show the path to be created in the unresolved-module fix label r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
11894: complete pattern args based on type name r=Veykril a=cameron1024
Addresses #11892
Changes function argument completion to cover a case like this:
```rust
struct Foo { bar: i32 }
fn qux(Foo { bar }: Foo) {
println!("{bar}");
}
```
When completing the function call for `qux`, instead of expanding to `qux(_)`, it will now expand to `qux(foo)` (based on the snake-cased version of the name of the ADT)
Non ADTs are unaffected
Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: cameron1024 <cameron.studdstreet@gmail.com>