Commit Graph

11376 Commits

Author SHA1 Message Date
Jonas Schievink
c0d93bc4d6 Clarify field name 2021-05-19 20:23:26 +02:00
Jonas Schievink
ea8555b155 Simplify eager macro representation 2021-05-19 20:19:08 +02:00
bors[bot]
c7196620ab
Merge #8875
8875: fix: false positive "Missing match arm" when an or-pattern has mismatched types r=flodiebold a=iDawer

![Screenshot_20210519_114510](https://user-images.githubusercontent.com/7803845/118768935-19e12c00-b86f-11eb-90c4-1eed3f2bf57f.jpg)
`InferenceResult` now records pattern type mismatches.

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-05-19 17:46:38 +00:00
bors[bot]
1cf0794f5e
Merge #8882
8882: internal: resolve attributes in name resolution (minimal version) r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/pull/7049

This should not have any observable effect, since we don't attempt to expand attribute macros yet, and I have implemented a fallback that treats items with unresolved attributes as if the attribute wasn't there.

Derive helpers are not yet resolved. `#![register_{attr,tool}]` are not yet supported.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-19 17:06:49 +00:00
Jonas Schievink
383635a13e Rewrite resolve_imports to use an iterator
This allows reusing the original vector's allocation
2021-05-19 19:05:03 +02:00
Jonas Schievink
aebb60de5c Restructure nameres loop to be a bit clearer 2021-05-19 18:56:00 +02:00
Lukas Tobias Wirth
b4fe479236 Replace ImportGranularity::Guess with guessing boolean flag 2021-05-19 15:57:10 +02:00
Jonas Schievink
3e186d4778 internal: resolve attributes in name resolution 2021-05-19 15:17:57 +02:00
bors[bot]
f4afffc7e9
Merge #8877
8877: feat: allow clients to feature detect symbol filtering r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-19 12:31:44 +00:00
bors[bot]
dc0f2c20f2
Merge #8880
8880: fix: prepare_rename failing for modules r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-19 12:21:21 +00:00
Lukas Tobias Wirth
2c7a8c4857 Fix prepare_rename failing for modules 2021-05-19 14:19:44 +02:00
Aleksey Kladov
1fd31f7f4c feat: allow clients to feature detect symbol filtering 2021-05-19 13:28:58 +03:00
Dawer
e2b1c69f74 Check patterns for type match recursively. 2021-05-19 11:08:59 +05:00
Dawer
472317c008 internal: Record mismatches of pattern types. 2021-05-19 11:08:59 +05:00
bors[bot]
49a5d6a8d4
Merge #7698
7698: Add new LSP extension for workspace symbol lookup r=matklad a=alcroito

As well as all symbol types (functions, modules).

Remove outdated documentation regarding symbol lookup filtering.

Closes #4881

Co-authored-by: alcroito <placinta@gmail.com>
2021-05-18 19:20:51 +00:00
bors[bot]
16b03d21dc
Merge #8871
8871: internal: Simplify `DefCollector::resolve_macros` r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-18 19:02:32 +00:00
Lukas Tobias Wirth
5fd9f6c7b9 Add ImportGranularity::Guess 2021-05-18 20:21:47 +02:00
Lukas Tobias Wirth
b8a99692d1 Implement import-granularity guessing 2021-05-18 20:10:39 +02:00
Lukas Tobias Wirth
64f7072c25 MergeBehavior -> ImportGranularity 2021-05-18 19:53:20 +02:00
Jonas Schievink
4884d9ec1d Simplify DefCollector::resolve_macros 2021-05-18 17:51:02 +02:00
rainy-me
e0b01f34bb Add pub mod option for UnlinkedFile 2021-05-18 08:11:07 +09:00
alcroito
1f7d2a6c22 Add new LSP extension for workspace symbol lookup
The new extension allows filtering of workspace symbool lookup
results by search scope or search kind.

Filtering can be configured in 3 different ways:

 - The '#' or '*' markers can be added inline with the symbol lookup
   query.

   The '#' marker means symbols should be looked up in the current
   workspace and any dependencies. If not specified, only current
   workspace is considered.

   The '*' marker means all kinds of symbols should be looked up
   (types, functions, etc). If not specified, only type symbols are
   returned.

 - Each LSP request can take an optional search_scope or search_kind
   argument query parameter.

 - Finally there are 2 global config options that can be set for all
   requests served by the active RA instance.

Add support for setting the global config options to the VSCode
extension.
The extension does not use the per-request way, but it's useful for
other IDEs.

The latest version of VSCode filters out the inline markers, so
currently the only reasonable way to use the new functionality is
via the global config.
2021-05-18 00:40:30 +02:00
Jamie Cunliffe
74f8fe7763 Extract function assist will add async if required
The extract function assist will check for an AWAIT_EXPR in the body
and if found, will add async to the generated function.
2021-05-17 18:17:29 +01:00
Aleksey Kladov
459b0332d3 internal: use more evocative test folder name 2021-05-17 19:01:54 +03:00
Aleksey Kladov
41510f437e minor: adjust config name 2021-05-17 18:37:06 +03:00
bors[bot]
f9d4a9eaee
Merge #8795
8795: Allow semantic tokens for strings to be disabled r=matklad a=djrenren

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

Pretty straightforward change, but open to any suggestions if there's a more recommended testing strategy than what I went with.

Co-authored-by: John Renner <john@jrenner.net>
2021-05-17 14:41:56 +00:00
bors[bot]
6aac6bcc74
Merge #8858
8858: Ignore macro import from `extern crate self` r=jonas-schievink a=ivan770

Closes #8834

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2021-05-17 10:16:05 +00:00
Aleksey Kladov
75a0123614 fix: don't add extra whitespace around fields
closes #8785
2021-05-17 12:45:01 +03:00
ivan770
999217374f
Added cov mark 2021-05-17 11:37:24 +02:00
Aleksey Kladov
21918c6f5e minor: add missing tests 2021-05-17 12:37:22 +03:00
Aleksey Kladov
fa7fc0e5cb internal: scalable module structure for fixits 2021-05-17 12:04:17 +03:00
Aleksey Kladov
db8fbb99ce minor: extract fix to file 2021-05-17 11:40:34 +03:00
bors[bot]
b82458818d
Merge #8845
8845: Generate the impl block via generate_trait_impl_text_from_impl r=Veykril a=hi-rustin

Try to close https://github.com/rust-analyzer/rust-analyzer/issues/8827

Co-authored-by: hi-rustin <rustin.liu@gmail.com>
2021-05-16 19:32:40 +00:00
ivan770
a79b54ef73
Fix #8834 2021-05-16 20:05:52 +02:00
bors[bot]
ef6df1d994
Merge #8853
8853: Tag Self in impls as a TypeAlias r=matklad a=Veykril

bors r+
Fixes #4398

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-16 17:35:40 +00:00
Aleksey Kladov
1859df37fd internal: use mutable syntax trees when filling fields 2021-05-16 18:10:56 +03:00
Lukas Wirth
90230e882d Tag Self in impls as a TypeAlias 2021-05-16 15:12:58 +02:00
Aleksey Kladov
9df0a23368 internal: use standard test style 2021-05-16 15:14:57 +03:00
Aleksey Kladov
e4a7b44e55 internal: use mutable trees when filling match arms 2021-05-16 15:10:18 +03:00
Aleksey Kladov
4e142757e1 minor: use uniform names 2021-05-16 14:18:49 +03:00
bors[bot]
a57bd59f35
Merge #8813
8813: Get some more array lengths! r=lf- a=lf-

This is built on #8799 and thus contains its changes. I'll rebase it onto master when that one gets merged. It adds support for r-a understanding the length of:

* `let a: [u8; 2] = ...`
* `let a = b"aaa"`
* `let a = [0u8; 4]`

I have added support for getting the values of byte strings, which was not previously there. I am least confident in the correctness of this part and it probably needs some more tests, as we currently have only one test that exercised that part (!).

Fixes #2922.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-16 01:53:12 +00:00
Jade
de0ed9860d Address final feedback
* rename ConstExtension->ConstExt
* refactor a manual construction of a Const
2021-05-15 18:51:18 -07:00
bors[bot]
92abc56bc9
Merge #8848
8848: Attach comments to ast::Impl r=Veykril a=Veykril

bors r+
Fixes #8847

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-15 15:32:54 +00:00
Lukas Wirth
4b5b54279a Attach comments to ast::Impl 2021-05-15 17:32:28 +02:00
Lukas Wirth
3da52d2e93 simplify 2021-05-15 17:22:39 +02:00
hi-rustin
f5ea2a2ab0 Remove attrs 2021-05-15 21:12:06 +08:00
hi-rustin
696a8bf870 Address comments and add more tests
Fix tests

Fmt code
2021-05-15 20:44:45 +08:00
hi-rustin
3f0222565d Generate the impl block via generate_trait_impl_text 2021-05-15 11:29:33 +08:00
Lukas Wirth
5b247780d4 simplify 2021-05-15 01:09:53 +02:00
bors[bot]
e5e6c363dc
Merge #8840
8840: fix: false positive "Missing match arm" when a tuple pattern is shorter than scrutinee type. r=Veykril a=iDawer

![Screenshot_20210515_003035](https://user-images.githubusercontent.com/7803845/118320023-2bcb7380-b4eb-11eb-9de6-d8762f981dc2.jpg)
Match checking diagnostic shouldn't fire when there is type mismatches.

rust-analyzer fd109fb58 2021-05-10 dev

(This is part of the preparation for https://github.com/rust-analyzer/rust-analyzer/pull/8717)

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-05-14 19:57:52 +00:00
Dawer
2abb4c99fe Fix false positive "Missing match arm". 2021-05-15 00:18:59 +05:00
bors[bot]
260bcd942b
Merge #8839
8839: minor: more useful bench r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-14 17:24:39 +00:00
Aleksey Kladov
ee1c23c78c minor: more useful bench 2021-05-14 20:23:29 +03:00
bors[bot]
e7b8e6fbca
Merge #8819
8819: Use package root as `cargo check` working directory r=matklad a=bcully

Cargo commands are affected by the `.cargo/config` files above
their working directory. If cargo is invoked from above the directory
holding `Cargo.toml`, it may not pick up important settings like
registry replacements, causing it to behave differently or even fail.

Most cargo invocations are currently setting their working directories
to the directory containing `Cargo.toml`, but a couple of paths remain
in which cargo is invoked from the default workspace root instead.

This change fixes that, resolving some cargo check failures that I
experienced in a multi-root workspace in which packages used different
registries.

Co-authored-by: Brendan Cully <brendan@cully.org>
2021-05-14 17:15:21 +00:00
Aleksey Kladov
883dd1568f internal: use more mutable APIs 2021-05-14 20:00:35 +03:00
Aleksey Kladov
6c21d04307 internal: use standard style for tests 2021-05-14 18:53:53 +03:00
Aleksey Kladov
cea589b3b5 internal: rewrite assoc item manipulaion to use mutable trees 2021-05-14 18:47:08 +03:00
Aleksey Kladov
73123a7550 internal: remove SyntaxRewriter 2021-05-14 16:40:11 +03:00
Aleksey Kladov
873717190d internal: remove more of the SyntaxRewriter 2021-05-14 16:28:59 +03:00
Aleksey Kladov
0650f77dd9 internal: remove one more immutable tree 2021-05-14 16:19:27 +03:00
hi-rustin
765ccf2eca Address comments 2021-05-14 17:47:16 +08:00
Jade
78d6b88f21 Add more tests, refactor array lengths/consteval work
Fix #2922: add unknown length as a condition for a type having unknown.

Incorporate reviews:

* Extract some of the const evaluation workings into functions
* Add fixmes on the hacks
* Add tests for impls on specific array lengths (these work!!! 😁)
* Add tests for const generics (indeed we don't support it yet)
2021-05-14 01:39:28 -07:00
hi-rustin
b98c119ba6 Apply async semantic token modifier to async/await keywords
Only async semantic token modifier
2021-05-14 10:47:00 +08:00
bors[bot]
9803a9a148
Merge #8830
8830: feat: Implement bulitin macro `concat_idents` r=edwin0cheng a=edwin0cheng

cc  #8828

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-05-13 22:44:34 +00:00
Edwin Cheng
bbc151ef32 Implement concat_idents 2021-05-14 06:42:10 +08:00
bors[bot]
9c8c72b7c4
Merge #8822
8822: minor: Cleanup imports r=Veykril a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-13 20:38:56 +00:00
bors[bot]
1552fdd3bc
Merge #8814
8814: fix: Keep doc comments and outer attrs on "Move module to file" assist r=Veykril a=Jesse-Bakker

Fixes #8804


Co-authored-by: Jesse Bakker <github@jessebakker.com>
2021-05-13 17:37:52 +00:00
bors[bot]
908cd23f81
Merge #8820
8820: fix: Return absolute paths in find_path if crate start is ambiguous r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-13 16:48:11 +00:00
bors[bot]
c9c9b4e9ed
Merge #8823
8823: Enable OPTION::ENABLE_TASKLISTS in pulldown_cmark r=Veykril a=Veykril

Closes #8821

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-13 16:41:25 +00:00
mixio
0cb5443455
Corrected minor typo on line 20 2021-05-13 18:29:48 +02:00
Lukas Wirth
07fe9a890d Enable OPTION::ENABLE_TASKLISTS in pulldown_cmark 2021-05-13 15:09:46 +02:00
Aleksey Kladov
ad0648dc95 Cleanup imports 2021-05-13 13:44:47 +03:00
Jesse Bakker
8c95b205a2 fix: Keep doc comments and outer attrs on "Move module to file" assist 2021-05-13 07:51:00 +02:00
Jade
32c600664e Test lowering byte strings some more 2021-05-12 21:22:46 -07:00
Jade
e666589e63 Add support for lengths in array repeats, if they are literals
Now we will get the type of `[0u8; 4]`.
2021-05-12 21:22:46 -07:00
Jade
73023c0299 Support length for ByteStrings
I am not confident that my added byte string parsing is right.
2021-05-12 21:22:46 -07:00
Jade
8b147624ff Add lowering of array lengths in types
Now e.g.

```rust
fn a(b: [u8; 2]) {
}
```

will know about the length of b.
2021-05-12 21:22:46 -07:00
Brendan Cully
c4664609ed Use package root as cargo check working directory
Cargo commands are affected by the `.cargo/config` files above
their working directory. If cargo is invoked from above the directory
holding `Cargo.toml`, it may not pick up important settings like
registry replacements, causing it to behave differently or even fail.

Most cargo invocations are currently setting their working directories
to the directory containing `Cargo.toml`, but a couple of paths remain
in which cargo is invoked from the default workspace root instead.

This change fixes that, resolving some cargo check failures that I
experienced in a multi-root workspace in which packages used different
registries.
2021-05-12 19:50:52 -07:00
Lukas Wirth
69e0b10150 Return absolute paths in find_path if crate start is ambiguous 2021-05-13 02:53:32 +02:00
bors[bot]
312f1fe20a
Merge #8799
8799: Add basic support for array lengths in types r=flodiebold a=lf-

This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?

Co-authored-by: Jade <software@lfcode.ca>
2021-05-12 14:49:43 +00:00
bors[bot]
1c927d2f8e
Merge #8802
8802: Keep comments and attrs when extracting struct from enum variant r=Veykril a=DropDemBits

Fixes #6730

Still unsure if existing visibilities of fields should be forced to pub (which is what was previously done), or if it's okay to keep it in the extracted struct.

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2021-05-12 14:42:01 +00:00
Jonas Schievink
a272cdfecd Fix build script dependencies 2021-05-12 14:48:26 +02:00
Jonas Schievink
e78221bc58 Remove delimiters from proc macro input 2021-05-12 01:01:51 +02:00
Jonas Schievink
c868414dcd Revert "Strip delimiter from fn-like proc macro input"
This reverts commit bda68e2332.
2021-05-12 00:57:41 +02:00
bors[bot]
c6e2ba43bb
Merge #8806
8806: fix: Strip delimiter from fn-like macro invocations r=jonas-schievink a=jonas-schievink

This broke in https://github.com/rust-analyzer/rust-analyzer/pull/8796 (again), the fix is easy though

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-11 22:27:50 +00:00
Jonas Schievink
bda68e2332 Strip delimiter from fn-like proc macro input 2021-05-12 00:27:16 +02:00
Jade
f28c053c67 address review by @eddyb 2021-05-11 15:18:45 -07:00
Jonas Schievink
23cd6d0d56 Move dot invocation to rust-analyzer crate 2021-05-12 00:14:59 +02:00
Jonas Schievink
32560839d9 Use Cargo target name as crate name 2021-05-11 23:34:56 +02:00
bors[bot]
da80dfc022
Merge #8398
8398: Fix inference with conditionally compiled tails r=flodiebold a=DJMcNab

Fixes #8378

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2021-05-11 19:01:39 +00:00
bors[bot]
e290891dd7
Merge #8801
8801: feat: Allow viewing the crate graph in a webview r=jonas-schievink a=jonas-schievink

This uses `dot` to render the crate graph as an SVD file, and displays it in a VS Code panel. For simple crate graphs, it works quite well:

![screenshot-2021-05-11-16:19:32](https://user-images.githubusercontent.com/1786438/117831361-c4a48980-b274-11eb-9276-240cdf6919aa.png)

Unfortunately, on rust-analyzer itself (and most medium-sized dependency graphs), `dot` runs for around a minute and then produces this mess:

![screenshot-2021-05-11-16:41:37](https://user-images.githubusercontent.com/1786438/117834831-c754ae00-b277-11eb-850b-138495dbeba8.png)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-11 18:02:31 +00:00
Jonas Schievink
d1aa6bbe75 Better node label/shapes 2021-05-11 19:50:01 +02:00
bors[bot]
6afd9b2b8d
Merge #8796
8796: internal: rewrite `#[derive]` removal to be based on AST (take 2) r=jonas-schievink a=jonas-schievink

Second attempt of https://github.com/rust-analyzer/rust-analyzer/pull/8443, this uses syntactical attribute offsets in `hir_expand`, and changes `attr.rs` to make those easy to derive.

This will make it easy to add similar attribute removal for attribute macros, unblocking them.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-11 17:47:45 +00:00
Jonas Schievink
5b3af25121 Only include workspace crates 2021-05-11 19:17:43 +02:00
DropDemBits
7fefac4bdc
Keep comments and attrs when extracting struct from enum variant 2021-05-11 11:07:47 -04:00
Jonas Schievink
9e6d9baf2e
Update crates/ide/src/view_crate_graph.rs
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-05-11 16:42:27 +02:00
Jonas Schievink
435c422963 Distinguish crates with identical name 2021-05-11 16:36:00 +02:00
Jonas Schievink
a85a2c4d15 Allow viewing the crate graph in a webview 2021-05-11 16:15:31 +02:00
bors[bot]
9fa9d166d8
Merge #8800
8800: feat: Make "pull assignments up" assist work in more cases r=Jesse-Bakker a=Jesse-Bakker

Fixes #8771

Co-authored-by: Jesse Bakker <github@jessebakker.com>
2021-05-11 13:14:55 +00:00
Jesse Bakker
5f37e34406 Make "pull assignments up" assist work in more cases 2021-05-11 15:14:23 +02:00