Commit Graph

12036 Commits

Author SHA1 Message Date
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
rezural
baa060a994 output to log file if RA_LOG_FILE is defined in environment 2021-06-21 09:33:57 +10:00
Florian Diebold
a1120b6879 Fix benchmark_include_macro 2021-06-20 19:37:45 +02:00
Florian Diebold
78419779f1 More cleanups, use check for display_source_code tests 2021-06-20 19:12:06 +02:00
Florian Diebold
0219b145ea Clean up coercion tests 2021-06-20 19:12:06 +02:00
Florian Diebold
d340f28a81 test_utils: Make overlapping annotations possible 2021-06-20 19:12:06 +02:00
Florian Diebold
04fbdce426 Unify check_mismatches and check_types 2021-06-20 19:12:06 +02:00
Florian Diebold
679bb21633 Add coverage mark for block local impls 2021-06-20 19:12:06 +02:00
Aleksey Kladov
9a3eae8755 fix: don't add duplicate & during completion 2021-06-20 19:37:58 +03:00
bors[bot]
f1097c2d26
Merge #9344
9344: fix: rename works when invoked on a reference r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-20 14:08:19 +00:00
Aleksey Kladov
cbb1979c19 fix: rename works when invoked on a reference 2021-06-20 17:07:55 +03:00
bors[bot]
3843bd02a0
Merge #9328
9328: internal: Update deps r=lnicola a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2021-06-20 03:22:13 +00:00
Lukas Wirth
2113c46797 Cleanup insert_use tests 2021-06-19 22:33:29 +02:00
bors[bot]
c2aa7782d6
Merge #9338
9338: minor: use minicore r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-19 09:18:34 +00:00
Aleksey Kladov
7df6852b6e minor: use minicore 2021-06-19 12:03:59 +03:00
Jade
8b77e2692c Implement a config override for the default #[cfg(test)] in cargo crates
Fixes crates which vanish when the 'test' cfg atom is set.

Fix #7243.
Fix #9203.
Fix #7225.
2021-06-19 01:09:19 -07:00
Jade
1f6abb7fba Fix libcore not being included in rust-lang/rust module tree
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.

This puts in a slight hack that checks for the crate name "core" and
turns off `#[cfg(test)]`.
2021-06-19 01:09:19 -07:00
Lukas Wirth
344cb5e76a Don't insert imports outside of cfg attributed items 2021-06-18 23:56:43 +02:00
bors[bot]
d9666ce509
Merge #9334
9334: feat: Allow to disable import insertion on single path glob imports r=Veykril a=Veykril

On by default as I feel like this is something the majority would prefer.

Closes #8490

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-18 21:23:22 +00:00
Lukas Wirth
2ee090faaf Allow to disable import insertion on single path glob imports 2021-06-18 23:11:56 +02:00
Aleksey Kladov
3762cc7465 minor: use minicore 2021-06-18 23:59:47 +03:00
Aleksey Kladov
90da9fc9b3 minor: use minicore 2021-06-18 23:48:18 +03:00
Aleksey Kladov
a9623f3165 minor: use minicore 2021-06-18 23:38:19 +03:00
Aleksey Kladov
cc73abf72c minor: use minicore 2021-06-18 23:33:01 +03:00
Aleksey Kladov
181184a350 minor: use minicore 2021-06-18 23:28:37 +03:00
Aleksey Kladov
89a0e58393 internal: use minicore deref more 2021-06-18 22:47:02 +03:00
Aleksey Kladov
991919e71f internal: add index to minicore 2021-06-18 22:37:34 +03:00
Aleksey Kladov
73b3ee664e minor: use minicore 2021-06-18 22:25:35 +03:00
Aleksey Kladov
2e4df27132 minor: use minicore 2021-06-18 22:25:35 +03:00
Aleksey Kladov
15c4b3fa7f internal: add Copy to minicore 2021-06-18 22:10:52 +03:00
kjeremy
e0e694620c Update test 2021-06-18 14:36:12 -04:00
bors[bot]
0657812bc2
Merge #9321
9321: Inline generics in const and function trait completions r=Veykril a=RDambrosio016

This PR does a couple of things:
- moves path_transform from ide_assists to ide_db to be shared by both assists and completions
- when completing a const or a function for a trait, it will "inline" any generics in those associated items instead 
of leaving the generic's name. For example:
```rust
trait Foo<T> {
    const BAR: T;
    fn foo() -> T;
}
struct Bar;

impl Foo<u32> for Bar {
    // autocompletes to this
    fn foo() -> u32;

    // and not this (old)
    fn foo() -> T;

    // also works for associated consts and where clauses
    const BAR: u32 = /* */
}
```

Currently this does not work for const generics, because `PathTransform` does not seem to account for them. If this should work on const generics too, `PathTransform` will need to be changed. However, it is uncommon to implement a trait only for a single const value, so this isnt a huge concern.

Co-authored-by: rdambrosio <rdambrosio016@gmail.com>
2021-06-18 16:47:58 +00:00
rdambrosio
b3e5c648e0 Lift ast -> hir out of the for_each 2021-06-18 12:42:13 -04:00
Laurențiu Nicola
6b1f0057f2 Avoid string allocation 2021-06-18 14:46:18 +03:00
Laurențiu Nicola
e3ce88f6f2 Minor clippy perf fixes 2021-06-18 14:40:51 +03:00
rdambrosio
23e3354ae0 Remove extra whitespace 2021-06-18 02:14:00 -04:00
rdambrosio
8e08b86304 Feat: inline generics in const and func trait completions 2021-06-17 19:54:28 -04:00
bors[bot]
0d863ccea9
Merge #9313
9313: fix: Don't complete keywords in attributes inside expressions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-17 22:30:30 +00:00
Aleksey Kladov
66673eae2b internal: retire famous_defs_fixture
This is now done declaratively via `minicore`.
2021-06-18 00:42:32 +03:00
Aleksey Kladov
89c2dff58a minor: simplify 2021-06-18 00:36:25 +03:00
Aleksey Kladov
ebb591a570 internal: add derive and ord support to minicore 2021-06-18 00:30:22 +03:00
Lukas Wirth
c1bf1f88ad Complete repr attribute parameters 2021-06-17 21:15:49 +02:00
Aleksey Kladov
ca99aaa053 internal: add From to minicore 2021-06-17 21:04:12 +03:00
Aleksey Kladov
82c7afc703 minor: dead code 2021-06-17 20:51:34 +03:00
Aleksey Kladov
08c220ab2c internal: add default to minicore 2021-06-17 20:49:49 +03:00
bors[bot]
ce926aebc4
Merge #9315
9315: Nest all the or-patterns! r=Veykril a=Veykril

`cargo +nightly clippy --fix -Z unstable-options --allow-dirty -- -A clippy::all -D clippy::unnested_or_patterns`

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-17 16:22:32 +00:00
Lukas Wirth
02d25ab60d Fix parser tests for 1.53 2021-06-17 18:09:44 +02:00
Lukas Wirth
b6cb6d5abe simplify 2021-06-17 17:58:26 +02:00
Lukas Wirth
95c8c65139 Nest all the or-patterns! 2021-06-17 17:37:14 +02:00
Lukas Wirth
2ac03ef1d6 Don't complete keywords in attributes inside expressions 2021-06-17 16:02:51 +02:00
Lukas Wirth
2a48b53220 Correct completions in items tests 2021-06-17 15:43:21 +02:00
Lukas Wirth
a9a77671f2 Move item specific completion tests 2021-06-17 15:32:34 +02:00
Lukas Wirth
9df848c580 Less filtering in completion tests 2021-06-17 15:10:25 +02:00
bors[bot]
c82a9141ab
Merge #9310
9310: internal: Refine and test UseTree completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-17 12:01:43 +00:00
Lukas Wirth
9353f36516 Fix incorrect completions in empty braced use statement 2021-06-17 13:59:31 +02:00
Lukas Wirth
2225db2eb4 Refine self, super and crate completion in use paths 2021-06-17 13:56:55 +02:00
Lukas Wirth
e14f5cfff0 Move out and rewrite UseTree completion tests 2021-06-17 13:13:12 +02:00
bors[bot]
3b58d8f785
Merge #9308
9308: fix: Create modules in correct directory for nested modules in move_module assist r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-17 10:10:25 +00:00
Lukas Wirth
cd5f4121e3 Create modules in correct directory for nested modules in move_module assist 2021-06-17 12:09:28 +02:00
Aleksey Kladov
ac35645455 internal: remove dead code 2021-06-17 11:42:43 +03:00
Aleksey Kladov
a43bba760e internal: switch some tests to minicore 2021-06-17 11:41:36 +03:00
Aleksey Kladov
c42cdff3d2 internal: minimize minicore
We want to keep minicore small, so let's split out iterator adapters and
sources into a separate `iterators` region, and use them only when
needed.
2021-06-17 11:28:44 +03:00
Aleksey Kladov
9b3aa591cd internal: switch some tests to minicore 2021-06-17 11:18:37 +03:00
bors[bot]
7b4f5c0262
Merge #9304
9304: internal: cleanup tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-16 20:28:23 +00:00
Aleksey Kladov
35772256f8 internal: cleanup tests 2021-06-16 23:27:46 +03:00