Commit Graph

13686 Commits

Author SHA1 Message Date
bors[bot]
f0da9406bc
Merge #10803
10803: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-18 20:45:20 +00:00
Lukas Wirth
966cae384f minor: Simplify 2021-11-18 21:43:54 +01:00
bors[bot]
cfa26c3ac3
Merge #10798
10798: ide: show go to for function hover return type r=Veykril a=jhgg

I've found myself wanting this...  adds to the hover quick go-to for a function's return type:

![image](https://user-images.githubusercontent.com/5489149/142375722-4a385216-494b-45a4-be1c-59664213b8d6.png)

This is particularly useful when you are hovering over a function in a long chain, like:

```rust
foo.bar().b$0az().some_trait_fn();
```

where `baz`'s return type is not immediately obvious, but the chain is not long enough to trigger chain inlay hints... 

i guess I could just select `foo.bar().baz()` too to get the types too... 

Co-authored-by: Jake Heinz <jh@discordapp.com>
2021-11-18 09:56:44 +00:00
bors[bot]
bf8cf09967
Merge #10796
10796: ide: display static values in hover r=Veykril a=jhgg

Continuation from #10785 - does the same thing, but for `static`'s as well.

Co-authored-by: Jake Heinz <jh@discordapp.com>
2021-11-18 09:48:10 +00:00
bors[bot]
b844d453b2
Merge #10795
10795: Remove unwrap in doc path resolution r=Veykril a=udoprog

I keep hitting this constantly in my project, and I haven't dug very deep into the root cause. But seeing as the project otherwise compiles it appears to be something unsupported is being incorrectly parsed in rust-analyzer which for other cases is handled by returning `None`.

Co-authored-by: John-John Tedro <udoprog@tedro.se>
2021-11-18 09:40:59 +00:00
bors[bot]
8d24f0e60a
Merge #10794
10794: fix: parse the range pat inside the tuple pat r=lnicola a=XFFXFF

fixes #10784 

Co-authored-by: zhoufan <1247714429@qq.com>
2021-11-18 09:33:47 +00:00
Laurențiu Nicola
6196b928a4 Fix proc macro ABI version checks 2021-11-18 10:24:24 +02:00
Jake Heinz
876f44b3ea ide: show go to for function hover return type 2021-11-18 08:00:22 +00:00
Jake Heinz
e8d0989606 ide: display static values in hover 2021-11-18 06:00:51 +00:00
John-John Tedro
76e3feeeb5 Remove unwrap in doc path resolution 2021-11-18 05:20:53 +01:00
bors[bot]
64a73dcfba
Merge #10785
10785: ide: show const value in hover r=jhgg a=jhgg

fixes #10783

I think my original attempt was incorrect, because it looks like `HirDisplay` is used in more places than just the hover.  

So, I've attempted it again in 312eafe, this time specifically just rendering the value in `hover::render`

pictoral:

![image](https://user-images.githubusercontent.com/5489149/142163890-b6aa2ab4-7bd0-4dd3-b35d-5eaa83fffb7f.png)


Co-authored-by: Jake Heinz <jh@discordapp.com>
Co-authored-by: Jake <jh@discordapp.com>
2021-11-18 04:17:16 +00:00
Jake Heinz
aef8882254 more complicated const test 2021-11-18 04:15:02 +00:00
zhoufan
a539b5e693 fix: parse the range pat inside the tuple pat 2021-11-18 11:11:37 +08:00
Lukas Wirth
f72512f1c6 Simplify 2021-11-17 21:02:33 +01:00
Lukas Wirth
91bbc55eed Check for derive attributes by item path, not derive identifier 2021-11-17 20:46:57 +01:00
Jake
d5de7c21b2
Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-17 09:53:24 -08:00
bors[bot]
32f425d801
Merge #10787
10787: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-17 14:55:18 +00:00
Lukas Wirth
6e1ecaef4f Simplify 2021-11-17 15:54:38 +01:00
zhoufan
1f1682ee1e minor: remove duplicate calls 2021-11-17 18:16:25 +08:00
Jake Heinz
312eafe916 maybe this is better?? 2021-11-17 07:02:49 +00:00
Jake Heinz
4fbc4b9356 hir: show const value in hover 2021-11-17 05:49:27 +00:00
bors[bot]
add6cccd4c
Merge #10781
10781: internal: Do not use reference search in `runnables::related_tests` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-16 20:51:09 +00:00
bors[bot]
1c49667c56
Merge #10778
10778: internal: Skip test/bench attr expansion in resolution instead of collection r=Veykril a=Veykril

This way we skip any path resolving to the test and bench attributes instead of just the lone identifiers(which could very well point to non-builtin attributes).
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-16 20:33:58 +00:00
Lukas Wirth
366499c3be Do not use reference search in runnables::related_tests 2021-11-16 21:32:02 +01:00
Lukas Wirth
0ff380fe17 Simplify 2021-11-16 21:26:34 +01:00
Lukas Wirth
b57289c4cb Skip test/bench attr expansion in resolution instead of collection 2021-11-16 20:23:56 +01:00
bors[bot]
b88b01ecec
Merge #10775
10775: minor: Simplify r=lnicola a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-16 18:52:26 +00:00
Jonas Schievink
445280a1b1 Allow disabling perf access via RA_DISABLE_PERF 2021-11-16 19:42:19 +01:00
Lukas Wirth
f2f89618b7 minor: Simplify 2021-11-16 19:28:32 +01:00
bors[bot]
9f1e26c3f9
Merge #10776
10776: fix: Remove validation of `super` in use paths r=Veykril a=lnicola

Fixes #10770

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-11-16 18:18:47 +00:00
Laurențiu Nicola
b23bebebc0 Remove validation of super in use paths 2021-11-16 20:02:42 +02:00
bors[bot]
35ed853d84
Merge #10769
10769: Add proc macro ABI for rustc 1.58 r=lnicola a=alexjg

This fixes #10766.

I do have some concerns here. The proc macro server API has added three methods to `TokenStream` which I don't really know how to implement in `RustcServer`. Namely `expand_expr`, `before`, and `after`. You'll see that these are currently `unimplemented!` in `crates/proc_macro_server/src/abis/abi_1_58/rustc_server.rs`. I don't have the expertise to fill in the blanks here, it may be necessary to pull in someone who knows a bit more about the proc macro crate.

I think this will only be a problem when actually attempting to expand a macro, so this is probably strictly better than not including the updated ABI at all.

Co-authored-by: Alex Good <alex@memoryandthought.me>
2021-11-16 16:40:51 +00:00
Alex Good
abdb2acbe5
Add proc macro ABI for rustc 1.58 2021-11-16 14:14:08 +00:00
bors[bot]
6c7be6cd84
Merge #10734
10734: fix: add generic parameters in convert to manual impl assist r=Veykril a=TheDoctor314

Fixes #10041.

Co-authored-by: TheDoctor314 <64731940+TheDoctor314@users.noreply.github.com>
2021-11-16 11:27:11 +00:00
Lukas Wirth
92f7db447c minor: Lift out FxIndex{Map/Set} types into ide_db 2021-11-16 12:15:47 +01:00
Lukas Wirth
d2513deb62 fix: Reimplement mapping out of test/bench attributes for runnables 2021-11-16 11:51:24 +01:00
TheDoctor314
58a24de7d8 Fix impl_def_from_trait
Revert "Fix `impl_trait` function to emit correct ast"

This reverts commit 55a4813151.

Fix `impl_def_from_trait`

It now generates the correct `ast::Impl` using
`generate_trait_impl_text` and parses it to form the right node (copied
from the private fn 'make::ast_from_text').
2021-11-15 22:28:22 +05:30
bors[bot]
73668334f0
Merge #10767
10767: minor: Rename intern_macro -> intern_macro_call r=Veykril a=Veykril

We potentially want to intern macro definitions so the names would probably collide
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-14 15:26:58 +00:00
Lukas Wirth
5c0b895f69 Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
bors[bot]
4b9b714b5c
Merge #10759
10759: make `add_missing_match_arms` applicable at the end of the match r=Veykril a=rainy-me

close #10740

Co-authored-by: rainy-me <github@yue.coffee>
2021-11-14 12:05:17 +00:00
rainy-me
1f3da38d94 adjust test case and stop deleting newline 2021-11-14 20:56:28 +09:00
zhoufan
5666046ec9 fix: flyimport triggers on enum variant declarations 2021-11-14 12:16:21 +08:00
Jake Heinz
520ff62f4e flip the default 2021-11-13 23:39:34 +00:00
Jake Heinz
d3d768de0d inlay hints: add the option to always show constructor inlay hints 2021-11-13 23:12:29 +00:00
rainy-me
c9949c040c add missing match arms end of last arm 2021-11-14 02:32:10 +09:00
Wilfred Hughes
f6f6b3a7ad Allow the check command to terminate without output
Cargo will always output something on success:

```
$ cargo check --message-format=json
{"reason":"compiler-artifact", ... snipped ... }
{"reason":"build-finished","success":true}
```

However, rustc does not output anything on success:

```
$ rustc --error-format=json main.rs
$ echo $?
0
```

Restore the behaviour prior to #10517, where an exit code of 0 is
considered good even if nothing is written to stdout.

This enables custom overrideCommand values that use rustc rather than
cargo.
2021-11-12 11:43:20 -08:00
Lukas Wirth
2d7f5891f7 Remove faulty logic for ascending test attributes for runnables 2021-11-11 18:47:24 +01:00
Lukas Wirth
a510021065 Replace some more ide usages of ModuleDef with Definition 2021-11-11 18:20:54 +01:00
Jonas Schievink
acbe8bc7ac Prime a more reasonable set of crates 2021-11-11 14:44:12 +01:00
TheDoctor314
55a4813151 Fix impl_trait function to emit correct ast
`impl_trait` code copied from `generate_impl_text_inner` to properly
handle the bounds for the generic parameters.
2021-11-11 14:16:59 +05:30
TheDoctor314
e0e8d877c0 Add generic bounds in test 2021-11-11 14:16:29 +05:30
bors[bot]
3b3063fb2d
Merge #10741
10741: internal: Flatten Definition::ModuleDef variant r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-10 23:19:44 +00:00
Lukas Wirth
7776aad166 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
bors[bot]
1e8d1e84b2
Merge #10689
10689: Handle pub tuple fields in tuple structs r=Veykril a=adamrk

The current implementation will throw a parser error for tuple structs
that contain a pub tuple field. For example,
```rust
struct Foo(pub (u32, u32));
```
is valid Rust, but rust-analyzer will throw a parser error.  This is
because the parens after `pub` is treated as a visibility context.
Allowing a tuple type to follow `pub` in the special case when we are
defining fields in a tuple struct can fix the issue.

I guess this is a really minor case because there's not much reason
for having a tuple type within a struct tuple, but it is valid rust syntax...

Co-authored-by: Adam Bratschi-Kaye <ark.email@gmail.com>
2021-11-10 21:08:51 +00:00
Adam Bratschi-Kaye
0d54754ca7 Handle pub tuple fields in tuple structs
The current implementation will throw a parser error for tuple structs
that contain a pub tuple field. For example,
```rust
struct Foo(pub (u32, u32));
```
is valid Rust, but rust-analyzer will throw a parser error.  This is
because the parens after `pub` is treated as a visibility context.
Allowing a tuple type to follow `pub` in the special case when we are
defining fields in a tuple struct can fix the issue.
2021-11-10 21:29:50 +01:00
bors[bot]
e7244e899f
Merge #10739
10739: internal: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-10 17:27:24 +00:00
Lukas Wirth
dea973089c Simplify 2021-11-10 18:26:18 +01:00
bors[bot]
b2bce38bb4
Merge #10729
10729: Fix: Lookup impls in local def maps r=jonas-schievink a=XFFXFF

fixes #10676 

Co-authored-by: zhoufan <1247714429@qq.com>
2021-11-10 16:47:35 +00:00
bors[bot]
f724c84e7d
Merge #10738
10738: internal: Do not search through all three namespaces in `ItemScope::name_of` r=Veykril a=Veykril

Brings down `5ms - find_path_prefixed (46 calls)` to `1ms - find_path_prefixed (46 calls)` for me on the `integrated_completion_benchmark`.
Still `O(n)` but this should considerably cut down lookups nevertheless(as shown by the timings already).
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-10 15:12:05 +00:00
Lukas Wirth
3c8898b1b1 Do not search through all three namespaces in ItemScope::name_of 2021-11-10 16:08:40 +01:00
TheDoctor314
05b368f065 Add generic parameters for manual impl assist
The `impl_trait` function takes an optional `GenericParamList` to create
the trait impl.
2021-11-10 12:53:48 +05:30
TheDoctor314
4f93fa1213 Add failing tests for generic struct 2021-11-10 12:53:48 +05:30
bors[bot]
899610778b
Merge #10731
10731: fix: show the right check-command r=Veykril a=Florian-Schoenherr

Currenty r.a. only shows this:
![image](https://user-images.githubusercontent.com/65456722/140977478-e6bc8a45-7c25-4578-9406-fb34f1eb0792.png)
even if another command was specified

There might be a better way to do this, I tried.

Co-authored-by: Florian-Schoenherr <florian.schoenherr99@gmail.com>
2021-11-09 22:11:32 +00:00
Florian-Schoenherr
4fb76743ca fix: show the right check-command
Signed-off-by: Florian-Schoenherr <florian.schoenherr99@gmail.com>
2021-11-09 21:52:55 +01:00
Laurențiu Nicola
e98b072da7 Bump chalk 2021-11-09 20:05:04 +02:00
zhoufan
f00cd911bf lookup impls in local del maps 2021-11-09 18:14:02 +08:00
bors[bot]
3c786bd7fd
Merge #10726
10726: minor: Add some completion profile spans r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-08 18:42:10 +00:00
Lukas Wirth
ab657af5b7 Add some completion profile spans 2021-11-08 19:41:16 +01:00
Lukas Wirth
26419c0379 Fix proc-macro attributes being shadowed by their functions in IDE layer 2021-11-08 14:49:50 +01:00
bors[bot]
c5c11b87cc
Merge #10720
10720: fix: Don't ascribe types in pattern completion for param patterns twice r=Veykril a=Veykril

Fixes #10323
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-08 13:12:03 +00:00
Lukas Wirth
f7e8136923 Add test for current incorrect behaviour 2021-11-08 14:10:26 +01:00
bors[bot]
2c0f433fd2
Merge #10699
10699: internal: Make CompletionItem `label` and `lookup` fields `SmolStr`s r=Veykril a=Veykril

This replaces a bunch of String clones with SmolStr clones, though also makes a few parts a bit more expensive(mainly things involving `format!`ted strings as labels).


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-07 11:13:15 +00:00
bors[bot]
e4ce6c7468
Merge #10698
10698: implement multi-token mapping for ssr r=Veykril a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-11-07 11:02:39 +00:00
Laurențiu Nicola
d18a379c7b Bump deps 2021-11-06 17:40:38 +02:00
Lukas Wirth
7369360c15 Don't ascribe types in pattern completion for patterns twice 2021-11-05 18:39:36 +01:00
bors[bot]
726b4dd8bd
Merge #10704
10704: internal: Short-circuit `descend_into_macros_single` r=Veykril a=Veykril

There is no need to descend everything if all we are interested in is the first mapping.
This bring `descend_into_macros` timing in highlighting in `rust-analyzer/src/config.rs` from `154ms - descend_into_macros (2190 calls)` to `24ms - descend_into_macros (2190 calls)` since we use the single variant there(will regress once we want to highlight multiple namespaces again though).
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 15:06:37 +00:00
Lukas Wirth
4d768bede0 Short-circuit descend_into_macros_single 2021-11-05 16:03:45 +01:00
Lukas Wirth
addd93ed9a Don't search for root nodes unnecessarily 2021-11-05 15:52:10 +01:00
bors[bot]
274d9f90ae
Merge #10703
10703: internal: Don't check items for macro calls if they have no attributes r=Veykril a=Veykril

Turns out when highlighting we currently populate the Dynmaps of pretty much every item in a file, who would've known that would be so costly...
Shaves off 250 ms for the integrated benchmark on `rust-analyzer/src/config.rs`.

We are still looking at a heft `154ms - descend_into_macros (2190 calls)` but I feel like this is slowly nearing towards just call overhead.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 13:53:59 +00:00
Lukas Wirth
8dad1b9228 Don't check items for macro calls if they have no attributes 2021-11-05 14:50:10 +01:00
bors[bot]
d1e449e313
Merge #10701
10701: internal: Cache ast::MacroCalls to their expansions in Semantics::descend_into_macros_impl r=Veykril a=Veykril

Saves ~45ms when highlighting `rust-analyzer/src/config.rs` for me
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 13:26:56 +00:00
Lukas Wirth
af4d244462 Cache ast::MacroCalls to their expansions in Semantics::descend_into_macros_impl 2021-11-05 14:25:47 +01:00
Lukas Wirth
2f5afba9f8 Replace some String usages with SmolStr in completions 2021-11-05 12:30:39 +01:00
bors[bot]
10782bbb39
Merge #10685
10685: fix: Enable markdown tables r=Veykril a=Veykril

Should fix https://github.com/rust-analyzer/rust-analyzer/issues/10655
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 11:25:17 +00:00
Anatol Ulrich
69e666fdba maybe? 2021-11-04 22:01:59 +01:00
Lukas Wirth
439a8194b0 Replace more Name::to_string usages with Name::to_smol_str 2021-11-04 18:12:05 +01:00
Lukas Wirth
4d4574f5b6 Enable markdown tables 2021-11-04 17:36:58 +01:00
bors[bot]
962be38004
Merge #10645
10645: fix: make `rename` multi-token mapping aware r=Veykril a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Anatol Ulrich <45840+spookyvision@users.noreply.github.com>
2021-11-04 16:31:16 +00:00
bors[bot]
c96481e25f
Merge #10691
10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-11-04 05:52:05 +00:00
Laurențiu Nicola
139bf9b4e1 Use array into_iter in more places 2021-11-04 07:51:20 +02:00
bors[bot]
a8247685cf
Merge #10686
10686: internal: Add `Semantics::original_ast_node` for upmapping nodes out of macro files r=Veykril a=Veykril

Fixes trying to insert imports into macro expanded files which then do text edits on very wrong text ranges.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 20:23:14 +00:00
Lukas Wirth
96db0d8bdd Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
bors[bot]
9ee855bcc5
Merge #10680
10680: implement Literal::from_str r=jonas-schievink a=spookyvision

this apparently fixes RTIC 0.6's 
```rust
#[rtic::app]
mod app {}
```

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-11-03 16:19:42 +00:00
Anatol Ulrich
a6df2b16df implement Literal::from_str 2021-11-03 16:50:43 +01:00
bors[bot]
0bd2d234a2
Merge #10667
10667: internal: Expose version string of crates from HIR r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 14:50:39 +00:00
Anatol Ulrich
e8416bb644
Update crates/text_edit/src/lib.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 15:44:46 +01:00
Anatol Ulrich
83927e08a8
Update crates/ide/src/rename.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 15:44:32 +01:00
Lukas Wirth
52f5af7165 Expose version string of crates fom HIR 2021-11-03 15:40:06 +01:00
bors[bot]
53b5b2fdaa
Merge #10596
10596: internal: Set server status to warning when proc-macro sources change r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10027
![image](https://user-images.githubusercontent.com/3757771/138102552-208d3edf-a843-49e6-9f48-1e911f54a4ba.png)

It feels wrong using the database in this part of the code, but this was the only way to figure out whether a file belongs to a proc-macro that I could think of.


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 14:02:10 +00:00
Lukas Wirth
9025f51118 Add disjoint check back in TextEdit::union 2021-11-03 14:42:15 +01:00