Commit Graph

12108 Commits

Author SHA1 Message Date
bors[bot]
2f9645501c
Merge #9436
9436: minor: Add test for macro expanded test module in runnables r=Veykril a=Veykril

Expected this to fail as thats behaving incorrectly on current nightly but I think I fixed this accidentally with https://github.com/rust-analyzer/rust-analyzer/pull/9435
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-30 17:37:28 +00:00
Lukas Wirth
8d3a378de9 Add test for macro expanded test module in runnables 2021-06-30 19:35:58 +02:00
bors[bot]
3c42aefceb
Merge #9435
9435: fix: Don't add test runnables for outline modules in the wrong file r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-30 17:11:34 +00:00
Lukas Wirth
b8507ca98d Don't add test runnables for outline modules in the wrong file 2021-06-30 19:08:13 +02:00
kjeremy
bf7651886e Cargo update and pull in the new rowan
This brings in the new hashbrown for better compile times.
2021-06-30 10:03:31 -04:00
Jonas Schievink
b5a2289676 Remove unneeded shifted_in 2021-06-30 15:45:00 +02:00
Jonas Schievink
b502a10b1e update comment 2021-06-30 15:13:59 +02:00
Jonas Schievink
88a86d4ff9 Fix deduction of dyn Fn closure parameter types 2021-06-30 15:04:04 +02:00
Lukas Wirth
af739731db Implement TypeRef::ForLifetime 2021-06-30 01:34:54 +02:00
bors[bot]
11b9233fc4
Merge #9269
9269: Recreate status page r=lnicola a=Milo123459

I'm working on redesigning the status page.

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2021-06-29 19:53:19 +00:00
Milo
4d8fe6208e fix 2021-06-29 20:34:52 +01:00
Milo
d85fa40d58
Update crates/ide/src/status.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-06-29 20:32:33 +01:00
Laurențiu Nicola
f1f3d5cb84 Watch for Cargo.toml and .lock changes 2021-06-29 14:38:50 +03:00
bors[bot]
13cbe64a59
Merge #9423
9423: fix: Resolve attribute paths in attribute highlighting r=Veykril a=Veykril

Attributes have a new highlighting format now, whereas the `#[` `]` tokens are now tagged with `attribute.attribute` like before, but all other idents inside token trees are now `generic.attribute`. If a path in an attribute can't be resolved it will instead get the `builtinAttribute.attribute` tags now as highlighting doesn't know about builtins like `allow` yet, so we don't want to emit unresolved references.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-28 19:57:23 +00:00
Lukas Wirth
9a1b9b3c78 Resolve attribute paths in attribute highlighting 2021-06-28 21:53:17 +02:00
Jonas Schievink
3ebceb71e3 Handle ::{self} imports 2021-06-28 20:13:33 +02:00
Lukas Wirth
254e8f38d0 Record attributes in attr_query for proc-macros 2021-06-28 19:16:38 +02:00
Lukas Wirth
9957220dfe Fix NameRef::classify path resolution inside attributes 2021-06-28 19:07:23 +02:00
Milo
443d2164ef remove unneeded ifs 2021-06-28 17:52:57 +01:00
Milo
2e60908fde check if counts should be a thing 2021-06-28 17:50:24 +01:00
bors[bot]
9ef62b0ccd
Merge #9418
9418: internal: Include `self` in usage search for modules in their definition source r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-28 14:42:22 +00:00
Lukas Wirth
34c28c1bbc Include self in usage search for modules in their definition source 2021-06-28 16:41:35 +02:00
Milo
d1821e4b6e fix all reviews 2021-06-28 07:31:54 +01:00
Laurențiu Nicola
cc54d2bbc6 Avoid redundant clone 2021-06-28 09:28:31 +03:00
Lukas Wirth
3ce5c66ca1 Deduplicate ast expression walking logic 2021-06-27 01:11:57 +02:00
Aleksey Kladov
93e3659194 intenral: small improvements to compile time
AsRef-polymorphism has compile-time cost.
2021-06-25 23:51:54 +03:00
Aleksey Kladov
c27fdc75fa internal: add cloning macro fixture
Macro that deep clone the tokens but otherwise preserves source
locations and hygiene info is an interesting case for IDE support. Lets
have this, although we don't actively use it at the moment.
2021-06-25 23:37:55 +03:00
bors[bot]
2ac1ffc0f3
Merge #9400
9400: fix: Fix renaming associated trait items with colliding names r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-25 01:48:50 +00:00
Lukas Wirth
942eeb2f55 Fix renaming associated trait items with colliding names 2021-06-25 03:45:41 +02:00
bors[bot]
c8d0ca8080
Merge #9398
9398: minor: Complete `macro_use` attribute on modules r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-24 20:21:20 +00:00
Lukas Wirth
63b1394b70 Complete macro_use attribute on modules 2021-06-24 22:20:56 +02:00
bors[bot]
83fc0db7e2
Merge #9397
9397: fix: Fix break point highlighting not considering outer labels r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-24 19:15:59 +00:00
Lukas Wirth
67075b228e Fix break point highlighting not considering outer labels 2021-06-24 21:14:43 +02:00
bors[bot]
0f0dbdc7d1
Merge #9396
9396: feat: Highlight loop break points r=Veykril a=Veykril

![Code_HmWQMlioKr](https://user-images.githubusercontent.com/3757771/123318732-d47be280-d52f-11eb-8a9a-cb3f591d4195.png)
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-24 19:05:41 +00:00
Lukas Wirth
42efd211bc Highlight label value block tails 2021-06-24 21:01:37 +02:00
Lukas Wirth
543f925353 Highlight loop break points 2021-06-24 20:57:02 +02:00
bors[bot]
264716e827
Merge #9375
9375: feat: Highlight exit and yield points r=Veykril a=Veykril

![Code_YBHOCF3DbU](https://user-images.githubusercontent.com/3757771/123128986-e1270a80-d44b-11eb-9854-065459a2dd50.png)
![Code_YyMhqES0LX](https://user-images.githubusercontent.com/3757771/123128988-e1bfa100-d44b-11eb-9c81-6a6031aad740.png)

Fixes #4691
Fixes #9365

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-24 15:23:25 +00:00
Lukas Wirth
d77655e5c3 Refine tail exit point highlighting to highlight inner tails 2021-06-24 17:19:27 +02:00
Lukas Wirth
d049783b5d Simplify 2021-06-24 16:50:56 +02:00
Lukas Wirth
066bc4f3a4 Simplify 2021-06-24 01:32:56 +02:00
bors[bot]
b656751536
Merge #9380
9380: feat: Implement goto_declaration support r=matklad a=Veykril

This is just a simple implementation that falls back to `goto_definition` for everything but modules where it goes to the actual module declaration if possible.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-23 22:33:05 +00:00
Lukas Wirth
37d417868e move goto_declaration fall back into handlers 2021-06-24 00:26:08 +02:00
bors[bot]
85a59de39f
Merge #9353
9353: Include extra targets when the pkg_root is not the same as the target root. r=matklad a=rezural

Fixes #7715 

For example, if a sub-crate includes sets the path='../somewhere-else/lib.rs', the files will not be in pkg_root , but in the target root's parent.

It may actually be in root.parent().parent(), I'm not sure about that.

At the moment it is just a fix, are there any relevant tests that this could go in? I've got about 1 brain cell left... but im happy to add tests where appropriate.


Co-authored-by: rezural <rezural@protonmail.com>
2021-06-23 21:33:30 +00:00
bors[bot]
1deb1d3209
Merge #9390
9390: fix: Improve type bound completions r=Veykril a=Veykril

Closes #9389
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-23 17:14:37 +00:00
Lukas Wirth
85736f2dc9 Fix incorrect base fixture in ide_completion tests 2021-06-23 19:13:27 +02:00
Lukas Wirth
9abd28ac37 Restrict type bound completions to traits, modules and macros 2021-06-23 19:10:03 +02:00
Lukas Wirth
d4877ae992 Add predicate tests for ide_completions 2021-06-23 18:58:19 +02:00
Lukas Wirth
dc4876d33d Lift out base item fixture for ide_completion tests 2021-06-23 18:37:47 +02:00
Lukas Wirth
511ae17d07 Improve feature docs for highlight_related 2021-06-23 18:11:48 +02:00
Lukas Wirth
f283fce594 Mark (method-)calls with never type as exit points 2021-06-23 17:21:47 +02:00
Lukas Wirth
cc791538d6 Simplify 2021-06-23 17:05:00 +02:00
Lukas Wirth
12266d5e56 Strip leading whitespace from test ouput in references 2021-06-23 16:49:36 +02:00
Lukas Wirth
e406140f38 Implement exit point highlighting 2021-06-23 16:43:53 +02:00
Lukas Wirth
9a53f1033e Implement yield point highlighting 2021-06-23 16:16:32 +02:00
Lukas Wirth
14b66bb458 Rename 'document_highlight' to 'highlight_related' 2021-06-23 15:13:48 +02:00
Lukas Wirth
b26a8ecca1 Move document highlighting computation from rust-analyzer to ide 2021-06-23 15:02:49 +02:00
Aramis Razzaghipour
3e7472f76c
Add public semantic token modifier for public items 2021-06-23 09:40:04 +10:00
Jonas Schievink
c6669776e1 Rewrite convert_tokens to use an explicit stack 2021-06-23 00:21:11 +02:00
Jonas Schievink
6504c3c32a Move subtree collection out of TokenConvertor 2021-06-23 00:19:54 +02:00
Florian Diebold
c61fee6d55 Fix compilation on WASM
Fixes #9214.
Fixes #9210.
2021-06-22 22:01:06 +02:00
Lukas Wirth
5a74e93c33 Implement goto_declaration support 2021-06-22 20:49:07 +02:00
Aleksey Kladov
7be2d2f008 internal: remove one more accidentally quadratic code-path
Definition::visibility was implemented in a rather roundabout way -- by
asking the parent module about the effective visibility.

This is problematic for a couple of reasons:

* first, it doesn't work for local items
* second, asking module about visibility of a child is a linear
  operation (that's a problem in itself, tracked in #9378)

Instead, lets ask the declared visibility directly, we have all the code
for it, and need only to actually us it.
2021-06-22 21:26:07 +03:00
Aleksey Kladov
260a24d05e internal: count ItemScopes 2021-06-22 21:02:08 +03:00
Aleksey Kladov
4772cb6b30 minor: clarify naming 2021-06-22 20:56:52 +03:00
bors[bot]
16d83ccbe2
Merge #9374
9374: Update crates r=kjeremy a=kjeremy

Drops byteorder

Co-authored-by: kjeremy <kjeremy@gmail.com>
2021-06-22 17:24:57 +00:00
kjeremy
5b6e168928 Update crates 2021-06-22 13:18:48 -04:00
Lukas Wirth
f615efdfc3 Factor out pick_best_token ide pattern into ide_db 2021-06-22 17:50:15 +02:00
Aleksey Kladov
9526c198f6 intenral: dont export impl details 2021-06-22 16:53:53 +03:00
Aleksey Kladov
2860f25ef3 minor: extend source_to_def docs 2021-06-22 16:12:01 +03:00
Aleksey Kladov
bf9ce9e65c internal: document source_to_def and it's connection to Kotlin&Roslyn 2021-06-22 15:31:04 +03:00
bors[bot]
ff92afb4c1
Merge #9368
9368: fix: Prefer identifier tokens in expand_macro r=Veykril a=Veykril

Fixes #9366
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-22 10:06:34 +00:00
Lukas Wirth
b423c61ce6 Prefer identifier tokens in expand_macro 2021-06-22 12:03:51 +02:00
bors[bot]
e2ca2325f5
Merge #9367
9367: Document perf characteristic of to_node r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-22 08:46:01 +00:00
Aleksey Kladov
e611c6758c Document perf characteristic of to_node 2021-06-22 11:45:22 +03:00
rezural
f55b1d1e19 add extra include paths, if target's path is manually set in Cargo.toml to be 2021-06-22 08:59:57 +10:00
bors[bot]
37dc2dfada
Merge #9348
9348: output to log file if RA_LOG_FILE is defined in environment r=rezural a=rezural

This adds a check for RA_LOG_FILE, and logs to that if defined. It currently overrides flags.log_file. If this is undesirable, I will add a check.

Co-authored-by: rezural <rezural@protonmail.com>
2021-06-21 21:42:02 +00:00
bors[bot]
afe056eef1
Merge #9364
9364: Split hover actions config into its own config struct r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-21 20:00:56 +00:00
Lukas Wirth
65d683df36 Collapse documentation and markdown config settings into an enum 2021-06-21 21:57:01 +02:00
bors[bot]
d2b89ebb92
Merge #9363
9363: Set explicit target directory to avoid cargo deadlock r=jonas-schievink a=oxalica

Fix #9360 

r? @jonas-schievink 

Co-authored-by: oxalica <oxalicc@pm.me>
2021-06-21 19:48:02 +00:00
Lukas Wirth
99c95b8fa1 Split hover actions config into its own config struct 2021-06-21 21:47:54 +02:00
oxalica
d368b663bd
Set explicit target directory to avoid cargo deadlock 2021-06-22 03:34:32 +08:00
bors[bot]
8b3d93ee29
Merge #9362
9362: feature: massively improve performance for large files r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-21 18:04:57 +00:00
Aleksey Kladov
099b63e7c0 feature: massively improve performance for large files
This story begins in #8384, where we added a smart test for our syntax
highting, which run the algorithm on synthetic files of varying length
in order to guesstimate if the complexity is O(N^2) or O(N)-ish.

The test turned out to be pretty effective, and flagged #9031 as a
change that makes syntax highlighting accidentally quadratic. There was
much rejoicing, for the time being.

Then, lnicola asked an ominous question[1]: "Are we sure that the time
is linear right now?"

Of course it turned out that our sophisticated non-linearity detector
*was* broken, and that our syntax highlighting *was* quadratic.

Investigating that, many brave hearts dug deeper and deeper into the
guts of rust-analyzer, only to get lost in a maze of traits delegating
to traits delegating to macros.

Eventually, matklad managed to peel off all layers of abstraction one by
one, until almost nothing was left. In fact, the issue was discovered in
the very foundation of the rust-analyzer -- in the syntax trees.

Worse, it was not a new problem, but rather a well-know, well-understood
and event (almost) well-fixed (!) performance bug.

The problem lies within `SyntaxNodePtr` type -- a light-weight "address"
of a node in a syntax tree [3]. Such pointers are used by rust-analyzer all
other the place to record relationships between IR nodes and the
original syntax.

Internally, the pointer to a syntax node is represented by node's range.
To "dereference" the pointer, you traverse the syntax tree from the
root, looking for the node with the right range. The inner loop of this
search is finding a node's child whose range contains the specified
range. This inner loop was implemented by naive linear search over all
the children. For wide trees, dereferencing a single `SyntaxNodePtr` was
linear. The problem with wide trees though is that they contain a lot of
nodes! And dereferencing pointers to all the nodes is quadratic in the
size of the file!

The solution to this problem is to speed up the children search --
rather than doing a linear lookup, we can use binary search to locate
the child with the desired interval.

Doing this optimization was one of the motivations (or rather, side
effects) of #6857. That's why `rowan` grew the useful
`child_or_token_at_range` method which does exactly this binary search.

But looks like we've never actually switch to this method? Oups.

Lesson learned: do not leave broken windows in the fundamental infra.
Otherwise, you'll have to repeatedly re-investigate the issue, by
digging from the top of the Everest down to the foundation!

[1]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/.60syntax_highlighting_not_quadratic.60.20failure/near/240811501
[2]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Syntax.20highlighting.20is.20quadratic
[3]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Syntax.20highlighting.20is.20quadratic/near/243412392
2021-06-21 20:14:38 +03:00
Jamie Cunliffe
ae823aa23f Move features into potential_cfg_options 2021-06-21 17:54:05 +01:00
Jamie Cunliffe
284483b347 Improve completion of cfg attributes
The completion of cfg will look at the enabled cfg keys when
performing completion.

It will also look crate features when completing a feature cfg
option. A fixed list of known values for some cfg options are
provided.

For unknown keys it will look at the enabled values for that cfg key,
which means that completion will only show enabled options for those.
2021-06-21 17:47:00 +01:00
bors[bot]
56e61bdfea
Merge #9165
9165: Apply some clippy suggestions r=matklad a=clemenswasser



Co-authored-by: Clemens Wasser <clemens.wasser@gmail.com>
2021-06-21 15:11:21 +00:00
Clemens Wasser
47747cd412 Apply some clippy suggestions 2021-06-21 16:40:21 +02:00
bors[bot]
25bf451c84
Merge #9264
9264: feat: Make documentation on hover configurable r=Veykril a=Veykril

This also implements deprecation support for config options as this renames `hoverActions_linksInHover` to `hover_linksInHover`.

Fixes #9232

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-21 14:15:49 +00:00
Lukas Wirth
43098d99ae Remove deprecation support in config 2021-06-21 16:15:25 +02:00
bors[bot]
5567b8a632
Merge #9314
9314: Fix extract_function with await r=sasurau4 a=sasurau4

Fix #9287 

Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2021-06-21 13:59:29 +00:00
Daiki Ihara
873aa904f2 Fix var name 2021-06-21 22:47:39 +09:00
bors[bot]
b48aba0090
Merge #9227
9227: Add a config setting to disable the 'test' cfg in specified crates r=matklad a=lf-

If you are opening libcore from rust-lang/rust as opposed to e.g.
goto definition from some other crate which would use the sysroot
instance of libcore, a `#![cfg(not(test))]` would previously have made
all the code excluded from the module tree, breaking the editor
experience.

Core does not need to ever be edited with `#[cfg(test)]` enabled,
as the tests are in another crate.

This PR puts in a slight hack that checks for the crate name "core" and
turns off `#[cfg(test)]` for that crate.

Fixes #9203 
Fixes #9226 

Co-authored-by: Jade <software@lfcode.ca>
2021-06-21 13:41:27 +00:00
Jonas Schievink
9e306909db Update sysroot crates 2021-06-21 15:26:26 +02:00
bors[bot]
c69f762f26
Merge #9356
9356: internal: Move out and regroup more completion tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-21 13:15:12 +00:00
Lukas Wirth
0729913525 Various keyword completion fixes 2021-06-21 15:14:28 +02:00
Lukas Wirth
b9d85f55b7 Move out completion type position tests 2021-06-21 15:00:53 +02:00
Jonas Schievink
8d2a33da05 Don't insert } when typing { in string 2021-06-21 14:54:49 +02:00
Lukas Wirth
f835279b3a Move out completion pattern tests 2021-06-21 13:48:25 +02:00
Daiki Ihara
7a04f72220 Fix pointed out 2021-06-21 18:42:25 +09:00
Daiki Ihara
cd1ef8de18 Fix extract_function with await 2021-06-21 18:31:53 +09:00