bors [Mon, 30 May 2022 11:29:55 +0000 (11:29 +0000)]
Auto merge of #12387 - 00nktk:fix-mod-rename, r=Veykril
fix(ide-db): correct single-file module rename
Fixes a bug where rust-analyzer would emit `WorkspaceEdit`s with paths to dirs instead of files for the following project layout.
lib.rs
```rust
mod foo;
```
foo.rs
```rust
mod bar {
struct Bar;
}
```
Also fixes emitted paths for modules with mod.rs.
The bug resulted in panic in helix editor when attempting to rename a module.
bors [Mon, 30 May 2022 11:22:10 +0000 (11:22 +0000)]
Auto merge of #12412 - yue4u:fix/visibility-completion, r=Veykril
fix: Retrigger visibility completion after parentheses
close #12390
This PR add `(` to trigger_characters as discussed in original issue.
Some questions:
1. Is lsp's `ctx.trigger_character` from `params.context` is the same as `ctx.original_token` inside actually completions?
1. If not what's the difference?
2. if they are the same, it's unnecessary to pass it down from handler at all.
3. if they are the same, maybe we could parse it from fixture directly instead of using the `check_with_trigger_character` I added.
2. Some completion fixtures written as `($0)` ( https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-completion/src/tests/fn_param.rs#L105 as an example), If I understand correctly they are not invoked outside tests at all?
1. using `ctx.original_token` directly would break these tests as well as parsing trigger_character from fixture for now.
2. I think it make sense to allow `(` triggering these cases?
3. I hope this line up with #12144
bors [Sun, 29 May 2022 08:45:15 +0000 (08:45 +0000)]
Auto merge of #12409 - lowr:fix/usize-overflow, r=Veykril
fix overflow during type inference for tuple struct patterns
The following code causes integer overflow during type inference for (malformed) tuple struct patterns.
```rust
struct S(usize);
let S(.., a, b) = S(1);
```
It has been panicking only in debug builds, and working in a way in release builds but it was inconsistent with type inference for tuple patterns:
```rust
struct S(usize);
let S(.., a, b) = S(1); // a -> unknown, b -> usize
let (.., a, b) = (1,); // a -> usize, b -> unknown
```
With this PR, the overflow no longer happens by utilizing `saturating_sub()` like in other places and type inference for tuple struct patterns is in line with that for tuple patterns.
bors [Fri, 27 May 2022 12:35:48 +0000 (12:35 +0000)]
Auto merge of #12341 - vemoo:exclude_dirs, r=Veykril
make `files.excludeDirs` work
There's a small issue because if all projects are excluded, this: https://github.com/rust-lang/rust-analyzer/blob/01d412f4d7bd7ef21a7e8f0461e9ba3439e3c4bf/crates/rust-analyzer/src/main_loop.rs#L114 will be shown.
I thought about not showing it if `files.excludeDirs` is set, but that is not necessarily correct.
bors [Mon, 23 May 2022 10:38:19 +0000 (10:38 +0000)]
Auto merge of #12355 - ruabmbua:fix-inference-pattern-wildcards, r=flodiebold
Fix inference when pattern matching a tuple field with a wildcard
This should fix the following issue: https://github.com/rust-lang/rust-analyzer/issues/12331
* Replaced the `err_ty` in `infer_pat()` with a new type variable.
* Had to change the iterator code a bit, to get around multiple mutable borrows of `self` in `infer_pat()`.
Also added a test
* Also added a test
bors [Mon, 23 May 2022 06:16:56 +0000 (06:16 +0000)]
Auto merge of #12350 - umanwizard:fix_bsd, r=lnicola
Fix build on OpenBSD (and probably other BSDs too)
notify-5.0.0-pre.14 does not build on these systems; this was fixed in
https://github.com/notify-rs/notify/commit/41a74f0e98a1af386749ad3be4a197865054f17f , which landed in pre.15.
Brennan Vincent [Sun, 22 May 2022 21:04:57 +0000 (17:04 -0400)]
Fix build on OpenBSD (and probably other BSDs too)
notify-5.0.0-pre.14 does not build on these systems; this was fixed in
https://github.com/notify-rs/notify/commit/41a74f0e98a1af386749ad3be4a197865054f17f , which landed in pre.15.
bors [Sun, 22 May 2022 17:01:26 +0000 (17:01 +0000)]
Auto merge of #12334 - fasterthanlime:gh-11635, r=Veykril
Generate enum variant assist
So, this is kind of a weird PR!
I'm a complete newcomer to the `rust-analyzer` codebase, and so I browsed the "good first issue" tag, and found #11635. Then I found two separate folks had taken stabs at it, most recently `@maartenflippo` — and there had been a review 3 days ago, but no activity in a little while, and the PR needed to be rebased since the crates were renamed from `snake_case` to `kebab-case`.
So to get acquainted with the codebase I typed this PR by hand, looking at the diff in #11995, and I also added a doc-test (that passes).
I haven't taken into account the comments `@Veykril` left in #11995, but I don't want to steal any of `@maartenflippo's` thunder! Closing this PR is perfectly fine. Or Maarten could use it as a "restart point"? Or I could finish it up, whichever feels best to everyone.
I think what remains to be done in this PR, at least, is:
* [x] Only disable the "generate function" assist if the name is `PascalCase`
* [x] Only enable the "generate variant" assistant if the name is `PascalCase`
* [x] Simplify with `adt.source()` as mentioned here: https://github.com/rust-lang/rust-analyzer/pull/11995#discussion_r875134175
* [ ] Add more tests for edge cases? Are there cases where simply adding one more indent level than the enum's indent level is not good enough? Some nested trickery I'm not thinking of right now?
Anyway. This PR can go in any direction. You can tell me "no, tackle your own issue!" And I'll go do that and still be happy I got to take a look at rust-analyzer some by doing this. Or you can tell me "okay, now _you_ finish it", and I guess I'll try and finish it :)
bors [Sun, 22 May 2022 15:14:26 +0000 (15:14 +0000)]
Auto merge of #12281 - lnicola:increase-overflow-depth, r=lnicola
Increase defalt chalk overflow depth to match max solver size
TBC:
- #12279: ok above 480
- ~~#12182~~
- ~~#12095~~
- #11902: ok above 350
- ~~#11668~~
- #11370: ok above 450
- #9754: probably ok above 250 (!), and the code in cause and branch are gone
bors [Sun, 22 May 2022 08:59:04 +0000 (08:59 +0000)]
Auto merge of #11830 - nemethf:on-type-formatting, r=nemethf
On typing handler for angle brackets(<) with snippets
I implemented my idea in #11398 in "cargo cult programming"-style without actually know what I'm doing, so feedback is welcome. The PR is split into two commits to ease the review. I used `@unexge's` original prototype, which forms the basis of the PR.