Commit graph

13425 commits

Author SHA1 Message Date
Lukas Wirth
acaf270911 Remove stale module 2021-10-12 09:37:16 +02:00
Lukas Wirth
d71a4f40d9 Regenerate lints 2021-10-12 09:35:02 +02:00
Lukas Wirth
ed7c2948b3 Move lint source generator 2021-10-12 08:59:39 +02:00
Brendan Cully
841d4f9dad Only include targets of packages that are workspace members
CargoWorkspace's package list includes packages that are path
dependencies, even if those packages aren't actually members of the
cargo workspace. As a result, rust-analyzer's runnable finder, which
returns the target from the first workspace that has a matching package,
may select the wrong working directory, causing runnables to fail, e.g.,
```
error: package `root` cannot be tested because it requires dev-dependencies and is not a member of the workspace
```

To fix this, we filter out packages that aren't members of the workspace
when searching for targets.

Fixes #7764
2021-10-11 18:28:05 -07:00
bors[bot]
098284aec8
Merge #10522
10522: fix: make signature info response conform to spec r=lnicola a=muscar

This addreses https://github.com/rust-analyzer/rust-analyzer/issues/10464.

This patch picks up `lsp-types` 0.90.1, which serialises the `SignatureInformation` and `ParameterInformation` with the right casing. It also adds `activeSignature` field as part of the top-level signature response. It keeps `activeParameter` at the top-level for backwards compatibility.

Co-authored-by: Alex Muscar <alex@muscar.eu>
2021-10-11 19:58:27 +00:00
Lukas Wirth
5ccaff3c97 Simplify 2021-10-11 21:49:50 +02:00
Alex Muscar
41856e2682 fix: make signature info response conform to spec
This addreses
https://github.com/rust-analyzer/rust-analyzer/issues/10464.

This patch picks up `lsp-types` 0.90.1, which serialises the
`SignatureInformation` and `ParameterInformation` with the right casing.
It also adds `activeSignature` field as part of the top-level signature
response. It keeps `activeParameter` at the top-level for backwards
compatibility.
2021-10-11 20:42:16 +01:00
Quentin Gliech
824b7a8564
Add toolInfo in MetaData vertex in LSIF dumps
This helps with uploading LSIF dumps to Sourcegraph without having to
specify an indexer name.
2021-10-11 14:45:58 +02:00
Lukas Wirth
2ec406bf64 Remove unnecessary unused attribute 2021-10-11 14:42:18 +02:00
Lukas Wirth
d14c9be321 Show cargo check failures to the user 2021-10-11 14:09:20 +02:00
bors[bot]
ed4b312fa7
Merge #10514
10514: internal: clean up code duplication r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-10-10 18:09:13 +00:00
Aleksey Kladov
d4d67406d7 internal: clean up code duplication 2021-10-10 21:08:10 +03:00
Aleksey Kladov
d28a6c36e1 minor: align code to code style
(mutually recursive) data type definitions shall be at the start of the
file.
2021-10-10 19:13:05 +03:00
Aleksey Kladov
634f047d90 internal: add integrated test for token censoring 2021-10-10 16:52:21 +03:00
Aleksey Kladov
a88344152d minor: add a test for derive macros in core 2021-10-10 16:13:45 +03:00
Aleksey Kladov
5af80d8372 internal: move derived tests to the unified macro infra 2021-10-10 16:10:35 +03:00
Aleksey Kladov
55d8be5a24 internal: consistent module naming 2021-10-10 15:44:03 +03:00
Aleksey Kladov
e5acf650d0 move tests 2021-10-10 15:30:54 +03:00
Aleksey Kladov
5f8b708aca move tests 2021-10-10 15:28:24 +03:00
Aleksey Kladov
6a3fc84921 internal: move builtin macro tests to macro expansion suite 2021-10-10 15:17:53 +03:00
Aleksey Kladov
bfc5d8529a drop obsolete tests 2021-10-10 15:11:33 +03:00
Aleksey Kladov
0f849a7a35 move test 2021-10-10 15:06:41 +03:00
Aleksey Kladov
dce41e5a03 move tests 2021-10-10 14:58:25 +03:00
Aleksey Kladov
42fd71e6c8 move tests 2021-10-10 14:40:13 +03:00
Aleksey Kladov
be73cc8f83 move test 2021-10-10 14:28:04 +03:00
Aleksey Kladov
af76db3c36 move tests 2021-10-10 14:26:47 +03:00
Aleksey Kladov
6253213a6e move test 2021-10-10 14:23:52 +03:00
Aleksey Kladov
e55797f59d move tests 2021-10-10 14:21:47 +03:00
Aleksey Kladov
8997d742dc move tests 2021-10-10 14:08:49 +03:00
Aleksey Kladov
464fb9f0d4 add directory for regression tests 2021-10-10 13:56:41 +03:00
Aleksey Kladov
5ad502dbdb move test 2021-10-10 13:54:44 +03:00
Aleksey Kladov
c986568cbb move test 2021-10-10 13:26:07 +03:00
Aleksey Kladov
5b44770102 move test 2021-10-10 13:24:48 +03:00
Aleksey Kladov
e255e9577f internal: move test 2021-10-10 13:21:42 +03:00
Aleksey Kladov
8670e83cec move test 2021-10-10 12:57:18 +03:00
Aleksey Kladov
7d92b9f6ff move test 2021-10-10 12:55:31 +03:00
Aleksey Kladov
748e6881fc move tests 2021-10-10 12:52:28 +03:00
Aleksey Kladov
6fd2f1d25b internal: move tests 2021-10-10 12:45:17 +03:00
Aleksey Kladov
5a854a7253 internal: move tests 2021-10-10 12:39:58 +03:00
Aleksey Kladov
3c9dda6ca9 internal: consistently use ok!(); for succesfull macro expansion 2021-10-10 11:45:05 +03:00
Aleksey Kladov
c88cda04db move some tests 2021-10-10 11:44:46 +03:00
Aleksey Kladov
a3470a8114 move tests 2021-10-10 11:39:08 +03:00
Aleksey Kladov
7e53a3ce23 move test 2021-10-10 11:29:26 +03:00
Aleksey Kladov
408475a593 move test 2021-10-10 11:26:18 +03:00
Aleksey Kladov
b0a104cbd1 test formatting 2021-10-10 11:22:12 +03:00
Aleksey Kladov
2510eaa9b2 test formatting 2021-10-10 11:16:25 +03:00
Aleksey Kladov
9c819eaa9a move tests 2021-10-10 11:15:42 +03:00
Aleksey Kladov
1c15f47e00 internal: move tests 2021-10-10 11:11:50 +03:00
Aleksey Kladov
c6d5c1c946 dead code 2021-10-10 11:09:16 +03:00
Aleksey Kladov
e9902b92ab internal: move some mbe tests 2021-10-10 11:08:02 +03:00
Aleksey Kladov
f17f5d68f9 move tests 2021-10-10 11:08:02 +03:00
Aleksey Kladov
3a47dba761 fix tests 2021-10-10 11:08:02 +03:00
bors[bot]
4439cd8c68
Merge #10506
10506: Add comment r=lnicola a=k-nasa

## Why


This code looks logic-bug ...


ce86534e1c/crates/syntax/src/syntax_node.rs (L50)


However, this code has been intentionally disabled.
It's a good idea to write a comment

ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357

## What

- I added comment

Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:56:47 +00:00
k-nasa
84bc6e159a Add comment 2021-10-10 16:53:37 +09:00
bors[bot]
64ca0f63bf
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa

## Why

Delete clones for efficiency

## What

- I erased unnecessary clones


Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:17:52 +00:00
k-nasa
9dd823a0e1 remove comment 2021-10-10 13:16:34 +09:00
k-nasa
3829cd981a Revert "update comment"
This reverts commit 820393f72d.
2021-10-10 10:51:45 +09:00
k-nasa
b50cb5c261 Remove neesless clone 2021-10-10 10:50:51 +09:00
k-nasa
820393f72d update comment 2021-10-10 10:16:32 +09:00
k-nasa
42377d3dad Add code comment 2021-10-10 10:10:52 +09:00
Aleksey Kladov
a85a3d73ed feat: be more precise in mismatch arg counts highlighting 2021-10-09 22:45:54 +03:00
Aleksey Kladov
de136a5340 move test 2021-10-09 19:11:04 +03:00
Aleksey Kladov
e838da18a9 internal: move tests 2021-10-09 18:54:15 +03:00
Aleksey Kladov
0dc87badd7 internal: move test 2021-10-09 18:51:26 +03:00
Aleksey Kladov
0a32c20142 internal: move test 2021-10-09 18:49:14 +03:00
Aleksey Kladov
993ff1c239 internal: drop duplicated test 2021-10-09 18:47:04 +03:00
Aleksey Kladov
419c234333 internal: move test 2021-10-09 18:46:16 +03:00
Aleksey Kladov
b1cfa51ef5 internal: move tests 2021-10-09 18:43:15 +03:00
Aleksey Kladov
3e8ef943c6 internal: move some tests 2021-10-09 18:18:56 +03:00
Aleksey Kladov
a060b9a4b2 internal: move some macro tests 2021-10-09 18:15:05 +03:00
Aleksey Kladov
c2e425dd00 internal: make sure macro test expand to valid syntax 2021-10-09 18:06:24 +03:00
Aleksey Kladov
c41b7bbe69 internal: allow macro tests to inspect parse tree 2021-10-09 17:58:17 +03:00
Aleksey Kladov
aac23f7832 move tests 2021-10-09 17:43:07 +03:00
Aleksey Kladov
6407e2e789 indent macro output when pprinting 2021-10-09 17:36:41 +03:00
Aleksey Kladov
a0d9e78ec3 align tests to code style 2021-10-09 17:31:24 +03:00
Aleksey Kladov
036c0ff8c7 move some tests 2021-10-09 17:27:38 +03:00
Aleksey Kladov
cb1b6a273f internal: don't un-indent macro tests manually 2021-10-09 17:17:37 +03:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
Aleksey Kladov
959da8caa1 internal: move test 2021-10-09 16:31:26 +03:00
Aleksey Kladov
59c86ff300 rename 2021-10-09 16:28:11 +03:00
Aleksey Kladov
75b0ce17cf move test 2021-10-09 16:27:19 +03:00
Aleksey Kladov
0dd1b35479 move test 2021-10-09 16:25:37 +03:00
Aleksey Kladov
574df660e4 move test 2021-10-09 16:22:42 +03:00
Aleksey Kladov
b21244e080 internal: move test 2021-10-09 16:19:19 +03:00
Aleksey Kladov
84d182c7a2 internal: docs 2021-10-09 15:29:31 +03:00
Aleksey Kladov
ef1251f696 feat: report errors in macro definition
Reporting macro *definition* error at the macro *call site* is a rather
questionable approach, but at least we don't erase the errors
altogether!
2021-10-09 15:23:55 +03:00
Aleksey Kladov
b3d1de93af get organizized 2021-10-09 14:53:15 +03:00
Aleksey Kladov
8e9003447c future proof structure 2021-10-09 14:48:38 +03:00
Aleksey Kladov
5ecda802f1 move test 2021-10-09 14:45:52 +03:00
Aleksey Kladov
f4ee0d736c move tests 2021-10-09 14:39:24 +03:00
Aleksey Kladov
1abe3f8275 internal: move tests 2021-10-09 14:22:49 +03:00
Aleksey Kladov
49f5fecf06 internal: move test 2021-10-09 14:18:53 +03:00
Aleksey Kladov
78ca43ef3d internal: move test 2021-10-09 13:51:02 +03:00
Aleksey Kladov
093f99b809 internal: start new macro test suite
I don't like our macro tests -- they are brittle and don't inspire
confidence. I think the reason for that is that we try to unit-test
them, but that is at odds with reality, where macro expansion
fundamentally depends on name resolution.
2021-10-09 13:42:32 +03:00
k-nasa
aeee70397e Apply make_else_arm to general case 2021-10-09 13:19:21 +09:00
k-nasa
388525fa0d Add test casee 2021-10-09 11:13:27 +09:00
Jonas Schievink
f8acae7895 Support let...else 2021-10-07 17:06:24 +02:00
rainy-me
aaa0771719 Fix: compare pkg via manifest 2021-10-07 23:44:25 +09:00
bors[bot]
4675410f07
Merge #10477 #10482
10477: parser: fix parsing of macro call inside generic args r=Veykril a=cynecx



10482: fix: fix `inline_call` trying to use an uncached syntax node in Semantics r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10475
bors r+

Co-authored-by: cynecx <me@cynecx.net>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-07 13:05:18 +00:00
Lukas Wirth
12465a8a3c Expose HasSource::source through Semantics with caching behaviour 2021-10-07 15:00:14 +02:00
bors[bot]
5191fb755b
Merge #10480
10480: fix: Change `stdx::to_snake_case` to match rustc implementation r=Veykril a=Crauzer

Fixes #10473

Co-authored-by: crauzer <filip.quitko@gmail.com>
2021-10-07 12:56:28 +00:00
bors[bot]
fd3f4c50da
Merge #10467
10467: Optimize CodeLens for references/impls r=Veykril a=ericsampson

Don't do unnecessary work.
Followup to #10447 . cc `@Veykril` 

Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-06 21:47:22 +00:00
Eric Sampson
efca421c43 Refactor to eliminate a vector allocation. 2021-10-06 16:43:37 -05:00
crauzer
ba62a8a075 fix test 2021-10-06 23:37:43 +02:00
crauzer
a4f08c117f Fix stdx::to_snake_case 2021-10-06 23:24:47 +02:00
bors[bot]
f30b62b751
Merge #10479
10479: fix: fix "index out of bounds" panic in name resolution r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10084
Closes https://github.com/rust-analyzer/rust-analyzer/issues/9163

This is really just a salsa update to a version that removes the problematic code (see https://github.com/rust-analyzer/rust-analyzer/issues/10084#issuecomment-934445711)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-06 20:54:27 +00:00
bors[bot]
12d33eafaf
Merge #10476
10476: feat: Add `replace_try_expr_with_match` assist r=Veykril a=Crauzer

Adds the replace_try_expr_with_match assist
#10424

Co-authored-by: crauzer <filip.quitko@gmail.com>
2021-10-06 20:45:14 +00:00
Jonas Schievink
cda9668289 Update salsa 2021-10-06 22:42:54 +02:00
cynecx
07cd19dcef parser: fix parsing of macro call inside generic args 2021-10-06 22:41:35 +02:00
crauzer
1161fa45af fix tests 2021-10-06 20:45:18 +02:00
crauzer
765d7f20f9 add sourcegen 2021-10-06 20:23:22 +02:00
crauzer
05e58afde2 Add replace_try_expr_with_match assist 2021-10-06 20:11:00 +02:00
bors[bot]
94fa49c0a3
Merge #10420
10420: Parse outer attributes on StructPatternEtCetera r=jonas-schievink a=XFFXFF

Try to fix https://github.com/rust-analyzer/rust-analyzer/issues/8610  
Related pr in ungrammer: https://github.com/rust-analyzer/ungrammar/pull/41

Co-authored-by: zhoufan <1247714429@qq.com>
2021-10-06 15:05:40 +00:00
bors[bot]
4cfe237a56
Merge #10459
10459: feat: Add generate constant assist r=Veykril a=longfangsong

Close #10330.
![demo(1)](https://user-images.githubusercontent.com/13777628/135885262-c80de86f-5555-4f84-9508-822243f8a876.gif)



Co-authored-by: longfangsong <longfangsong@icloud.com>
Co-authored-by: 龙方淞 <longfangsong@icloud.com>
2021-10-06 09:38:58 +00:00
Eric Sampson
0d77be67f7 Don't do work and then throw it away. 2021-10-06 01:16:31 -05:00
longfangsong
3fde682bcf cleanup 2021-10-06 10:14:12 +08:00
龙方淞
7228dbadca
Update crates/ide_assists/src/handlers/generate_constant.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-06 10:06:51 +08:00
龙方淞
fab238adf6
Update crates/ide_assists/src/handlers/generate_constant.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-06 10:06:46 +08:00
bors[bot]
5ff992465e
Merge #10447
10447: Add enum variant references CodeLens. r=Veykril a=ericsampson



Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-05 22:03:23 +00:00
Eric Sampson
6d05b07f7d Refactor according to PR comments to remove allocations. 2021-10-05 15:42:45 -05:00
bors[bot]
c409cf0e26
Merge #10458
10458: feat: Implement custom user snippets r=Veykril a=Veykril

![Y24dX7fOWX](https://user-images.githubusercontent.com/3757771/136059454-ceccfc2c-2c90-46da-8ad1-bac9c2e83ec1.gif)

Allows us to address the following issues:
    - `.arc / .rc / .pin, similar to .box?` https://github.com/rust-analyzer/rust-analyzer/issues/7033
    - `Add unsafe snippet` https://github.com/rust-analyzer/rust-analyzer/issues/10392, would allow users to have this without the diagnostic)
    - `.ok() postfix snippet is annoying` https://github.com/rust-analyzer/rust-analyzer/issues/9636, allows us to get rid of the `ok` postfix and similar ones
    - `Postfix vec completion` https://github.com/rust-analyzer/rust-analyzer/issues/7773

cc https://github.com/rust-analyzer/rust-analyzer/issues/772

Zulipd discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Custom.20Postfix.20snippets

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-05 16:41:11 +00:00
Lukas Wirth
041cfbe0f4 Render the expansion of snippets as their docs 2021-10-05 18:11:22 +02:00
Lukas Wirth
77cbf4adbc Bring the implementation closer to VSCode snippet definitions 2021-10-05 17:18:40 +02:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
Eric Sampson
160a7b097a initialize vector to required size. 2021-10-04 16:14:01 -05:00
Lukas Wirth
2b17da60db Resolve macros in snippet require items 2021-10-04 22:53:02 +02:00
Lukas Wirth
ca1fdd75f1 Regen docs 2021-10-04 22:13:12 +02:00
Lukas Wirth
1f7e14e78b Fix multiple imports acting on files on separately 2021-10-04 22:05:30 +02:00
Lukas Wirth
454ecd167c Make multiple import edits work for completions 2021-10-04 21:44:33 +02:00
Lukas Wirth
046c85ef0c Add custom non-postfix snippets 2021-10-04 19:22:41 +02:00
Jonas Schievink
0cd24c14c5 Only add proc_macro to prelude in proc-macro crates 2021-10-04 18:22:39 +02:00
bors[bot]
5bdae82947
Merge #10456
10456: fix: Avoid cycle when lowering predicates for associated item lookup r=flodiebold a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10386

(the salsa bug persists, but this lets us avoid it by fixing the underlying bug)

This reimplements the rustc logic in b27661eb33/compiler/rustc_typeck/src/collect.rs (L556): When resolving an associated type `T::Item`, we've previously lowered all predicates that could affect `T`, but we actually have to look only at those predicates whose traits define an associated type of the right name.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-04 15:58:06 +00:00
longfangsong
4d1a4dc0d6 Add generate_constant assist 2021-10-04 23:53:32 +08:00
Lukas Wirth
88f213eadd Initial implementation of custom postfix snippets 2021-10-04 17:49:21 +02:00
Jonas Schievink
3aa37d7f80 Avoid cycle when lowering predicates for associated item lookup 2021-10-04 17:39:55 +02:00
Laurențiu Nicola
a683c08729 Remove support for old-style sysroot 2021-10-04 18:36:56 +03:00
bors[bot]
9724ca7af1
Merge #10451
10451: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-04 13:18:21 +00:00
Lukas Wirth
7faa35cbbd Simplify 2021-10-04 15:16:13 +02:00
zhoufan
a248f39cb4 make Some(1..) parsed 2021-10-04 17:33:48 +08:00
Eric Sampson
5df6259996 tweak variable names. 2021-10-04 02:42:13 -05:00
Eric Sampson
a0bb31587e Add enum variant references CodeLens. 2021-10-04 02:18:31 -05:00
bors[bot]
10eaa5a0af
Merge #10441
10441: feat: Hide type inlay hints for constructors r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/3022
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 13:35:47 +00:00
Lukas Wirth
a31bc668f5 Hide generic constructors if appropriate 2021-10-03 15:35:26 +02:00
Aramis Razzaghipour
eff195852d
Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
Lukas Wirth
992b4648d9 feat: Hide type inlay hints for constructors 2021-10-03 14:53:18 +02:00
Aramis Razzaghipour
55c0b86cde
Add semicolons for consistency
`clippy::semicolon_if_nothing_returned`
2021-10-03 23:39:43 +11:00
bors[bot]
e28aa1928b
Merge #10439
10439: fix: fix insert_use incorrectly merging glob imports r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6800
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 12:19:02 +00:00
Lukas Wirth
5b0c91d118 fix: fix insert_use incorrectly merging glob imports 2021-10-03 14:06:44 +02:00