Commit Graph

22441 Commits

Author SHA1 Message Date
Lukas Wirth
b34e27d25e minor: Reduce move-guard trigger range 2022-06-03 17:00:03 +02:00
Lukas Wirth
d0e3114441 internal: Don't log default build script outputs 2022-06-03 16:46:16 +02:00
Lukas Wirth
2a60b8452e Deduplicate 2022-06-03 16:33:37 +02:00
Lukas Wirth
522f66545f Remove prev-sibling completion machinery 2022-06-03 16:25:37 +02:00
Lukas Wirth
6550a241fb More precise where keyword completions 2022-06-03 16:11:26 +02:00
Lukas Wirth
c522669f00 Remove dead code 2022-06-03 15:46:17 +02:00
Lukas Wirth
c5dcc77b40 Fix visibility mods not being completed for field defs 2022-06-03 15:42:28 +02:00
Lukas Wirth
519ac81b57 internal: Move most remaining keyword completions to item list completions 2022-06-03 15:15:21 +02:00
bors
58b6d46d5a Auto merge of #12333 - nolanderc:order-import-assist, r=Veykril
Order auto-imports by relevance

Fixes #10337.

Basically we sort the imports according to how "far away" the imported item is from where we want to import it to. This change makes it so that imports from the current crate are sorted before any third-party crates. Additionally, we make an exception for builtin crates (`std`, `core`, etc.) so that they are sorted before any third-party crates.

There are probably other heuristics that should be added to improve the experience (such as preferring imports that are common elsewhere in the same crate, and ranking crates depending on the dependency graph). However, I think this is a first good step.

PS. This is my first time contributing here, so please be gentle if I have missed something obvious :-)
2022-06-03 07:49:59 +00:00
bors
ea15e1000f Auto merge of #12452 - iDawer:assist.merge_selected_imports, r=Veykril
feature: `Merge imports` assist can merge multiple selected imports.

The selected imports have to have a common prefix in paths.

Select imports or use trees to merge:
```rust
$0use std::fmt::Display;
use std::fmt::Debug;
use std::fmt::Write;$0
```
Apply `Merge imports`:
```rust
use std::fmt::{Display, Debug, Write};
```

Closes #12426
2022-06-03 07:40:34 +00:00
bors
29fae10345 Auto merge of #12451 - TimNN:double-dollar, r=Veykril
feat: Support `$$` in macros.

The implementation mirrors what `rustc` currently does [1]. Part of #11952.

\[1]: 0595ea1d12/compiler/rustc_expand/src/mbe/quoted.rs (L230-L241)
2022-06-03 07:23:48 +00:00
bors
d1968a38b9 Auto merge of #12456 - lnicola:thread-names, r=lnicola
internal: Shorten main thread names

Linux effectively has a 15 byte limit, which resulted in `rust-analyzer s` and `rust-analyzer p`. That's still unambiguous, but probably not obvious.
2022-06-03 04:28:07 +00:00
Laurențiu Nicola
7066b8e0ca Shorten main thread name 2022-06-03 07:27:48 +03:00
bitgaoshu
1a97ab34db fix: #12441 False-positive type-mismatch error with generic future 2022-06-03 10:47:41 +08:00
Tim Neumann
40bfb29e50 feat: Support $$ in macros.
The implementation mirrors what `rustc` currently does [1]. Part of #11952.

[1]: 0595ea1d12/compiler/rustc_expand/src/mbe/quoted.rs (L230-L241)
2022-06-02 21:48:28 +02:00
iDawer
ea8899a445 Allow merging of multiple selected imports.
The selected imports have to have a common prefix in paths.

Before
```rust
$0use std::fmt::Display;
use std::fmt::Debug;$0
```
After
```rust
use std::fmt::{Display, Debug};
```
2022-06-02 23:15:55 +05:00
Lukas Wirth
a2a3ea86ea Bring the version command output in line with other rust tools 2022-06-02 18:36:02 +02:00
bors
88024c7ec2 Auto merge of #12444 - XFFXFF:fix_12442, r=Veykril
fix: parsing of `?` opt-out trait bounds

fixes #12442
2022-06-02 14:02:36 +00:00
XFFXFF
df67bbdcb3 fix: parsing of ? opt-out trait bounds
thanks to Veykril
2022-06-02 21:30:18 +08:00
bors
2f0814ea35 Auto merge of #12347 - feniljain:fix_extract_module, r=Veykril
fix(extract_module) resolving import panics and improve import resolution

- Should solve #11766
- While adding a test case for this issue, I observed another issue:
For this test case:
```rust
            mod x {
                pub struct Foo;
                pub struct Bar;
            }

            use x::{Bar, Foo};

            $0type A = (Foo, Bar);$0
```
extract module should yield this:

```rust
            mod x {
                pub struct Foo;
                pub struct Bar;
            }

            use x::{};

            mod modname {
                use super::Bar;

                use super::Foo;

                pub(crate) type A = (Foo, Bar);
            }
```

instead it gave:

```rust
            mod x {
                pub struct Foo;
                pub struct Bar;
            }

            use x::{};

            mod modname {
                use x::Bar;

                use x::Foo;

                pub(crate) type A = (Foo, Bar);
            }
```

So fixed this problem with second commit
2022-06-02 12:37:17 +00:00
bors
6f7c5589ab Auto merge of #12443 - Veykril:fmtfix, r=Veykril
minor: Fix rustfmt failing on main_loop.rs
2022-06-01 19:23:22 +00:00
Lukas Wirth
343562c54d minor: Fix rustfmt failing on main_loop.rs 2022-06-01 21:20:54 +02:00
bors
cf10a1ee3e Auto merge of #12440 - Maan2003:empty-msg-diag, r=jonas-schievink
fix(diagnostic): Don't remove diagnostic with empty message

Use " " as message if it is empty

[discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/empty.20diagnostic.20message)

![image](https://user-images.githubusercontent.com/49202620/171412661-9b9575e9-e71b-4b84-a5c0-00271548d50c.png)
2022-06-01 14:31:14 +00:00
Maan2003
bad931116e
fix(diagnostic): Don't remove diagnostic with empty message
Use " " as message if it is empty
2022-06-01 18:38:53 +05:30
bors
4f5c7aafff Auto merge of #12431 - Veykril:request-retry, r=Veykril
fix: Fix completions disappearing when typing two keys in quick succession

With this PR we now retry requests if they get cancelled due to document changes.

This fixes the completions problem we have where completions seem to randomly disappear, see https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Completions.20not.20always.20appearing

Fixes https://github.com/rust-lang/rust-analyzer/issues/10187
Fixes https://github.com/rust-lang/rust-analyzer/issues/7560
Fixes https://github.com/rust-lang/rust-analyzer/issues/12153
2022-06-01 10:18:50 +00:00
Lukas Wirth
d88ae66ed9 Sync handlers cannot be cancelled 2022-06-01 12:18:15 +02:00
bors
30672cbf0c Auto merge of #12435 - jhgg:vscode/status-bar-color-fix, r=Veykril
[editors/vscode] cleaer status bar bg color / command  when server status returns to OK

fixes #12433
2022-06-01 07:19:42 +00:00
Jake Heinz
a965161dce [editors/vscode] cleaer status bar bg color / command when server status returns to OK 2022-06-01 06:58:16 +00:00
Lukas Wirth
e2da967578 fix: Fix completions disappearing when typing two keys in quick succession 2022-06-01 00:20:47 +02:00
bors
e25cbf8584 Auto merge of #12430 - Veykril:completions, r=Veykril
minor: Remove unused code
2022-05-31 18:22:41 +00:00
Lukas Wirth
1234d8647f minor: Remove unused code 2022-05-31 20:21:50 +02:00
Ryo Yoshida
b7a4175cbb
Implement type inference for assignee expressions 2022-06-01 01:28:12 +09:00
Ryo Yoshida
62d6b5a594
Generalize some inference functions for patterns 2022-06-01 01:22:11 +09:00
Ryo Yoshida
c1c867506b
Add Expr::Underscore 2022-06-01 01:21:57 +09:00
bors
e10799536a Auto merge of #12427 - Veykril:configfix, r=Veykril
fix: Fix VSCode config patching incorrectly patching some configs
2022-05-31 11:48:42 +00:00
Lukas Wirth
3e25c853cf fix: Fix VSCode config patching incorrectly patching some configs 2022-05-31 13:38:48 +02:00
bors
c2099fe941 Auto merge of #12336 - bitgaoshu:mismatch, r=flodiebold
fix: #12267  type-mismatch when using equals w/ a trait bound
2022-05-31 09:48:54 +00:00
bors
f65d734abc Auto merge of #12425 - feniljain:fix_bugs, r=lnicola
fix: float display impl

should solve #12414
2022-05-31 04:52:36 +00:00
feniljain
25f3e7a33c fix: float display impl 2022-05-31 10:13:03 +05:30
feniljain
8a1ef52f5c fix(extract_module): Remove redundancy causing else, and also add import fix loop for names 2022-05-31 09:51:42 +05:30
bors
a5d7ab54f9 Auto merge of #12418 - Veykril:completions, r=Veykril
internal: More precise completion filtering with existing item qualifiers

Now we are approaching the more complex cases for filtering completions
2022-05-30 14:05:37 +00:00
Lukas Wirth
0327df224b More precise completion filtering 2022-05-30 16:01:17 +02:00
bors
c551d1a6af Auto merge of #12417 - jonas-schievink:pr-msg-style, r=jonas-schievink
minor: Update commit/PR style guide

What matters for the changelog is having PR title/description from the user's perspective, while commits can be internal.
2022-05-30 13:56:54 +00:00
Jonas Schievink
592bc5106c Update commit/PR style 2022-05-30 15:55:40 +02:00
Lukas Wirth
ea594c4c44 Use char for trigger character 2022-05-30 14:17:58 +02:00
bors
edb2e571fe Auto merge of #12416 - Veykril:inlay-hints, r=Veykril
Add implicit static lifetime hints
2022-05-30 12:00:54 +00:00
Lukas Wirth
aced76d0ff Add implicit static lifetime hints 2022-05-30 13:59:58 +02:00
bors
9ceaff91d3 Auto merge of #12406 - harpsword:fix-add-inlayHints-closures-without-block, r=Veykril
fix: add an option to show inlay hint for return type of closures wit…

fix #12321
2022-05-30 11:36:55 +00:00
bors
bd0c2344f2 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.
2022-05-30 11:29:55 +00:00
bors
e4ead8a7c6 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
2022-05-30 11:22:10 +00:00