Commit graph

11481 commits

Author SHA1 Message Date
Jonas Schievink
4a84c3fb21 Fix unresolved attribute fallback again 2021-05-19 22:08:34 +02:00
bors[bot]
49922cb2c3
Merge #8885 #8887
8885: internal: greatly simplify eager macro representation r=jonas-schievink a=jonas-schievink

- Share structures with lazy macros, make both use `MacroCallLoc`.
- Remove `intern_eager_expansion`, `EagerCallLoc`, `EagerMacroId`, and *many* matches on `MacroCallId`.
- Make a lot of FIXMEs obsolete since the code no longer distinguishes between eager and lazy macros.
- Add `EagerCallInfo`, which is `Some` for calls to eager macros and holds the argument or expansion result and the included file.

8887: fix: fix derive collection after unresolved attribute fallback r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/pull/8882#issuecomment-844379170

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-19 19:07:05 +00:00
Jonas Schievink
274d813cff Fix derive collection after unresolved attribute fallback 2021-05-19 21:05:58 +02:00
bors[bot]
2d76b176c0
Merge #8884
8884: fix: add_explicit_type produces invalid code on `@` patterns r=Veykril a=iDawer

In
```rust
let name @ () = ();
```
 an explicit type should be inserted after the pattern, not just after the name.
`let` statement defined as `LetStmt = Attr* 'let' Pat (':' Type)? '=' initializer:Expr ';'`

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-05-19 18:30:36 +00:00
Dawer
5c5fedb945 add_explicit_type respects @ patterns 2021-05-19 23:27:51 +05:00
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
Jade
dc63fea427 Add basic support for array lengths in types
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?
2021-05-11 05:25:19 -07:00
Jonas Schievink
8ea9d939d2 Rewrite #[derive] removal to be based on AST 2021-05-10 22:54:17 +02:00
John Renner
7ae3967e57 Formatting and docs 2021-05-10 13:34:09 -07:00
bors[bot]
77f0c92fd8
Merge #8794
8794: Give MergeBehaviour variants better names r=Veykril a=Veykril

I never really liked the variant names I gave this enum from the beginning and then I found out about rustfmt's `imports_granularity` config:

> imports_granularity
>
> How imports should be grouped into use statements. Imports will be merged or split to the configured level of granularity.
> 
>     Default value: Preserve
>     Possible values: Preserve, Crate, Module, Item
>     Stable: No

I personally prefer using `crate` over `full` and `module` over last, they seem more descriptive. Keeping these similar between tooling also seems like a good plus point to me.

We might even wanna take over the entire enum at some point if we have a `format/cleanup imports` assists in the future which would probably want to also have the `preserve` and `item` options.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-10 20:10:59 +00:00
Lukas Wirth
59c2efe4b6 Update docs 2021-05-10 22:10:12 +02:00
John Renner
c3ba1f14fa Allow semantic tokens for strings to be disabled 2021-05-10 13:09:38 -07:00
Jonas Schievink
da08198bc9 Rewrite attr.rs to allow using syntax-based indices 2021-05-10 21:50:42 +02:00
Lukas Wirth
6a8d47e7f0 Give MergeBehaviour variants better names 2021-05-10 21:14:59 +02:00
mixio
aa9002c68a
Corrected 2 typos on line 83 2021-05-10 20:05:32 +02:00
Jonas Schievink
a87bec5148 Move AttrId back into hir_def 2021-05-10 16:35:06 +02:00
Jonas Schievink
e718c6b3e8 feat: auto-indent use tree lists 2021-05-10 15:10:56 +02:00
Aleksey Kladov
bf26e13cd2 simplify 2021-05-10 15:25:56 +03:00
Jonas Schievink
64f97fb2ad feat: auto-insert } when typing { in use item 2021-05-09 22:12:58 +02:00
bors[bot]
75a5c0a534
Merge #8783
8783: internal: introduce `ast::make::ext` module with common shortcuts r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 16:56:02 +00:00
Aleksey Kladov
4f3c0adc5a internal: introduce ast::make::ext module with common shortcuts
There's a tension between keeping a well-architectured minimal
orthogonal set of constructs, and providing convenience functions.
Relieve this pressure by introducing an dedicated module for
non-orthogonal shortcuts.

This is inspired by the django.shortcuts module which serves a similar
purpose architecturally.
2021-05-09 19:55:43 +03:00
bors[bot]
2fe329db48
Merge #8782
8782: internal: fix make API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 16:23:03 +00:00
Aleksey Kladov
680a0d54e4 internal: fix make API 2021-05-09 19:22:33 +03:00
bors[bot]
a3b034938e
Merge #8781
8781: internal: rewrite **Repalce impl Trait** assist to mutable syntax trees r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-09 15:55:42 +00:00
Aleksey Kladov
5342800147 internal: rewrite **Repalce impl Trait** assist to mutable syntax trees 2021-05-09 18:20:37 +03:00
Aleksey Kladov
984d20aad8 cleanups 2021-05-09 18:01:54 +03:00
Aleksey Kladov
d9c9f6dc2c cleanups 2021-05-09 17:58:03 +03:00
Aleksey Kladov
edeb492782 minor: fix test style 2021-05-09 17:47:02 +03:00
Aleksey Kladov
5637ce4250 fix: join lines doesn't add space before closing quote 2021-05-09 17:46:41 +03:00
bors[bot]
0900beeaa2
Merge #8776
8776: fix: fix unnecessary recomputations due to macros r=jonas-schievink a=jonas-schievink

This computes a macro's fragment kind eagerly (when the calling file is still available in parsed form) and stores it in the `MacroCallLoc`. This means that during expansion we no longer have to reparse the file containing the macro call, avoiding the unnecessary salsa dependencies (https://github.com/rust-analyzer/rust-analyzer/pull/8746#issuecomment-834776349).

Marking as draft until I manage to find a test for this problem, since for some reason `typing_inside_a_function_should_not_invalidate_expansions` does not catch this (which might indicate that I misunderstand the problem).

I've manually confirmed that this fixes the issue described in https://github.com/rust-analyzer/rust-analyzer/pull/8746#issuecomment-834776349:

```
    7ms - parse_query @ FileId(179)
   12ms - SourceBinder::to_module_def
       12ms - crate_def_map:wait
            5ms - item_tree_query (1 calls)
            7ms - ???
```

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-09 14:40:49 +00:00
Jonas Schievink
fd5a1d1765 Test that none of the macros are reparsed 2021-05-09 16:39:47 +02:00
Aleksey Kladov
e0da3da0d9 fix: join lines doesn't add space before closing quote 2021-05-09 17:19:18 +03:00
bors[bot]
b43921cddd
Merge #8777
8777: Escape characters in builtin macros correctly r=edwin0cheng a=edwin0cheng

Fixes #8749

It is the same bug in #8560 but in our `quote!` macro. 

Because the "\" are adding exponentially in #8749 case, so the text is eat up all the memory. 

bors r+



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-05-09 12:01:35 +00:00
Edwin Cheng
01ce37c805 Escape characters in builtin macros correctly 2021-05-09 19:57:29 +08:00
bors[bot]
6c0cdc5f55
Merge #8774
8774: feat: Honor `.cargo/config.toml` r=matklad a=Veykril

![f1Gup1aiAn](https://user-images.githubusercontent.com/3757771/117545448-1dcaae00-b026-11eb-977a-0f35a5e3f2e0.gif)

Implements `cargo/.config` build target and cfg access by using unstable cargo options:

- `cargo config get` to read the target triple out of the config to pass to `cargo metadata` --filter-platform
- `cargo rustc --print` to read out the `rustc_cfgs`, this causes us to honor `rustflags` and the like.

If those commands fail, due to not having a nightly toolchain present for example, they will fall back to invoking rustc directly as we currently do.

I personally think it should be fine to use these unstable options as they are unlikely to change(even if they did it shouldn't be a problem due to the fallback) and don't burden the user if they do not have a nightly toolchain at hand since we fall back to the previous behaviour.

cc #8741
Closes #6604, Closes #5904, Closes #8430, Closes #8480

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-09 10:33:31 +00:00
Jonas Schievink
9cf8d325a2 Precompute macro fragment kind 2021-05-09 01:36:06 +02:00
bors[bot]
cf4d4f646b
Merge #8773
8773: fix: Correctly support SelfType when searching for usages r=Veykril a=Veykril

Fixes #7443

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-08 22:09:03 +00:00
Lukas Wirth
b7e6537935 Use RUSTC_BOOTSTRAP=1 instead of +nightly when discovering rust_cfgs throughs cargo 2021-05-09 00:07:04 +02:00
Lukas Wirth
3a346412cf Don't handle Self as a usage for TraitDefs 2021-05-08 23:35:18 +02:00
bors[bot]
6cd11bbbc2
Merge #8775
8775: Add `=` to pattern recovery r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-08 21:14:47 +00:00
Lukas Wirth
174f043c8d Add = to pattern recovery 2021-05-08 23:14:08 +02:00
Lukas Wirth
04717b9bd2 Fix builtintype def_to_ty 2021-05-08 22:43:26 +02:00
Lukas Wirth
41f470fea8 Correctly support SelfType when searching for usages 2021-05-08 22:34:55 +02:00
Aleksey Kladov
8a7904127d minor: remove dead code 2021-05-08 23:28:36 +03:00
Aleksey Kladov
1ee12b5db1 feat: add "mentoring instructions" test for pull up assist 2021-05-08 23:19:08 +03:00
Aleksey Kladov
1755b57e1a internal: pull_assignment_up uses mutable trees 2021-05-08 23:11:42 +03:00
Aleksey Kladov
e603090961 minor: add missing test 2021-05-08 20:40:07 +03:00
Aleksey Kladov
880ddddfe6 dead code 2021-05-08 20:02:48 +03:00
Lukas Wirth
8989fb8315 Discover rustc_cfg through unstable cargo options 2021-05-08 18:17:18 +02:00
Aleksey Kladov
7ab4fd7628 internal: remove one more usage of SyntaxRewriter 2021-05-08 15:45:17 +03:00
Aleksey Kladov
1fdc9d8e9e internal: remove one more syntax rewriter 2021-05-08 14:47:14 +03:00
Aleksey Kladov
f015429c82 internal: add rust-analyzer version to panic context 2021-05-08 14:14:06 +03:00
Aleksey Kladov
53f7149d45 internal: expose cfg attrs from hir::Crate 2021-05-07 23:50:24 +03:00
John Renner
4059112b4e Use package renaming so source doesn't say tikv 2021-05-07 12:41:07 -07:00
John Renner
d8a9b450a6 Switch from jemalloc to tikv-jemalloc 2021-05-07 12:17:37 -07:00
bors[bot]
1ec82d4bdf
Merge #8751
8751: minor: standard snippet r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-07 18:47:05 +00:00
Aleksey Kladov
189f785749 minor: standard snippet 2021-05-07 21:46:25 +03:00
Jonas Schievink
e2b664e9fd fix: use raw idents in make::name{_ref} with keywords 2021-05-07 17:22:54 +02:00
bors[bot]
a8da2ca3a1
Merge #8745
8745: Support goto_type_definition for types r=matklad a=Veykril

I'm unsure if the approach of lowering an `ast::Type` to a `hir::Type` is a good idea, it seems fine to me at least.
Fixes #2882

Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-06 22:28:35 +00:00
bors[bot]
0ee945e289
Merge #8280
8280: Borrow text of immutable syntax node r=iDawer a=iDawer

In https://github.com/rust-analyzer/rowan/pull/101 `rowan::SyntaxNode::green` returns `Cow<'_, GreenNodeData>`. It returns borrow of green node of immutable syntax tree node.
Using this we can return borrowed text from `ast::Name::text`.

~~However now it allocates in case of mutable syntax trees.~~ (see next comment)

The idea comes from https://github.com/rust-analyzer/rowan/pull/100#issuecomment-809330325

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-05-06 22:19:52 +00:00
Jonas Schievink
20ae41c1a1 Reuse database in LowerCtx 2021-05-06 23:23:50 +02:00
Aleksey Kladov
c4f9cb9b53 Update crates/hir_def/src/nameres/tests/incremental.rs
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-06 20:00:43 +02:00
Aleksey Kladov
548e5a5c29 internal: add failing incremental test 2021-05-06 20:00:11 +02:00
Jonas Schievink
976a3226fe Don't store call-site text offsets in hygiene info 2021-05-06 19:59:54 +02:00
Kirill Bulatov
607d8a2f61 Small macro fix 2021-05-06 20:12:30 +03:00
Aleksey Kladov
6a16ec52aa internal: use API stabilized in 1.52 2021-05-06 20:12:15 +03:00
Lukas Tobias Wirth
d97a4b8e49 Support goto_type_definition for types 2021-05-06 17:05:49 +02:00
Edwin Cheng
1fb20e3231 Simplify 2021-05-06 22:39:51 +08:00
Jesse Bakker
10254b5d95 Fix: Do not overwrite comments and attrs in trait impl completion 2021-05-06 16:16:38 +02:00
Dawer
90a5dca0a2 Fix build 2021-05-06 10:22:51 +05:00
Dawer
0a156c80af Hide implementation details of TokenText 2021-05-06 10:07:06 +05:00
Dawer
d9b4ac8128 Clean up 2021-05-06 10:07:06 +05:00
Dawer
d7e169fe55 Borrow text from nodes of immutable syntax trees 2021-05-06 10:07:06 +05:00
Dawer
dc4fa504ea Adapt to a new rowan borrowing node API. 2021-05-06 10:06:52 +05:00
Dawer
52143f389f Update to rowan 0.13.0-pre.5 2021-05-06 10:04:39 +05:00
bors[bot]
c3596371d8
Merge #8674
8674: fix for #8664: Emit folding ranges for multi-line where clauses r=matklad a=m5tfi

#8664 

I added a test that assert folding multi-line where clauses while leaving single lined one. Please, let me know if the code needs further improvements.

Co-authored-by: m5tfi <72708423+m5tfi@users.noreply.github.com>
2021-05-05 21:14:12 +00:00
Lukas Tobias Wirth
3f796fea9f simplify 2021-05-05 22:55:12 +02:00
m5tfi
c2cf34db90 remove unneeded visited_where_clauses 2021-05-05 06:28:41 +02:00
Lukas Tobias Wirth
d26fb188c1 Add some cov marks for qualified_path completion 2021-05-04 22:35:37 +02:00
Aleksey Kladov
1ea4dae596 Document expansion queries 2021-05-04 22:41:46 +03:00
Aleksey Kladov
3f6980e4e1 simplify macro expansion code
Using `Option` arguments such that you always pass `None` or `Some` at
the call site is a code smell.
2021-05-04 22:41:46 +03:00
Aleksey Kladov
95dc8ef265 make illegal states unrepresentable
only declarative macros have def-site token map
2021-05-04 22:41:43 +03:00
Aleksey Kladov
7d9ea39de6 Cleanups 2021-05-04 22:40:59 +03:00
bors[bot]
010e4c8fe0
Merge #8731
8731: Complete enum variants through type aliases r=Veykril a=Veykril

Fixes #8730
bors r+

Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-04 19:05:19 +00:00
Lukas Tobias Wirth
8b94bf7b2d Complete enum variants through type aliases 2021-05-04 21:04:19 +02:00
bors[bot]
e17748e4b2
Merge #8727
8727: minor: use standard import style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 17:37:09 +00:00
Aleksey Kladov
2e97dbcbb8 minor: use standard import style 2021-05-04 20:36:48 +03:00
bors[bot]
5e87f84211
Merge #8726
8726: internal: reduce visibility r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 17:29:55 +00:00
Aleksey Kladov
87f827bfaf internal: reduce visibility 2021-05-04 20:29:30 +03:00
bors[bot]
871bc1cd08
Merge #8725
8725: internal: env var to toggle slow benches r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 15:31:10 +00:00
Aleksey Kladov
a1f42ef8ad internal: env var to toggle slow benches 2021-05-04 18:21:36 +03:00
Aleksey Kladov
16f7c3ea91 minor: unconfuse myself about macro def vs macro rules 2021-05-04 18:20:10 +03:00
bors[bot]
a231da9d24
Merge #8720
8720: internal: add integrated completion benchmark r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 12:14:56 +00:00
Aleksey Kladov
b2f040fc9a internal: add integrated completion benchmark 2021-05-04 15:14:33 +03:00
bors[bot]
d9f1b5fc7c
Merge #8719
8719: Fix block comment intra doc link injection ranges r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-04 12:00:30 +00:00
Lukas Tobias Wirth
5a78d96d0e Fix block comment intra doc link injection ranges 2021-05-04 13:51:57 +02:00
bors[bot]
6d812efcd9
Merge #8711
8711: Only resolve selected assist r=matklad a=SomeoneToIgnore

Part of https://github.com/rust-analyzer/rust-analyzer/issues/8700

Now resolves only the assist that was selected out of the list, while before the whole assist list was resolved despite a single popup selection.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-05-04 11:51:09 +00:00
Aleksey Kladov
41f8ae7daa More searchable name 2021-05-04 10:23:47 +03:00
bors[bot]
0323045631
Merge #8714
8714: internal: remove one more usage of the rewriter r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 07:07:06 +00:00
Aleksey Kladov
ae6b9c25ed internal: remove one more usage of the rewriter 2021-05-04 09:42:20 +03:00
memoryruins
27ba1dd8e3 Replace memmap to memmap2 in proc_macro_api 2021-05-03 20:20:47 -04:00