Commit graph

20456 commits

Author SHA1 Message Date
bors[bot] db2a7087b9
Merge #10995
10995: internal: switch from trait-based TokenSource to simple struct of arrays r=matklad a=matklad

cc #10765 

The idea here is to try to simplify the interface as best as we can. The original trait-based approach is a bit over-engineered and hard to debug. Here, we replace callback with just data. The next PR in series will replace the output `TreeSink` trait with data as well. 


The biggest drawback here is that we now require to materialize all parser's input up-front. This is a bad fit for macro by example: when you parse `$e:expr`, you might consume only part of the input. However, today's trait-based solution doesn't really help -- we were already materializing the whole thing! So, let's keep it simple!

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-12-12 16:38:56 +00:00
Aleksey Kladov 3b5b988526 prettyfy 2021-12-12 19:36:14 +03:00
Aleksey Kladov 980dd56cdc consistency 2021-12-12 19:32:04 +03:00
Aleksey Kladov 6e4bb57014 simplify 2021-12-12 19:31:32 +03:00
Aleksey Kladov 57e6ef0bfb tighten up invariants 2021-12-12 19:22:37 +03:00
Aleksey Kladov 18d4737fb9 add cross-crate inlines 2021-12-12 19:17:04 +03:00
Aleksey Kladov 1055a6111a port mbe to soa tokens 2021-12-12 19:06:40 +03:00
Aleksey Kladov 965585748e more orthogonal interface 2021-12-12 18:38:49 +03:00
Aleksey Kladov 6ce587ba5a parser tests work 2021-12-12 18:31:05 +03:00
Aleksey Kladov 26bfd6023f Switch parser to use tokens 2021-12-12 16:54:09 +03:00
Aleksey Kladov d5ad0f3ca0 use eof token pattenr 2021-12-12 16:54:09 +03:00
Aleksey Kladov addfd8d9e8 start SOA parser interface 2021-12-12 16:54:09 +03:00
bors[bot] fc628cfc89
Merge #10993
10993: minor: Bump deps r=lnicola a=lnicola

Gets `coutme 2.0`.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-12 11:11:50 +00:00
Laurențiu Nicola 8782e8e704 Bump deps 2021-12-12 13:10:21 +02:00
bors[bot] 40159150aa
Merge #10951
10951: feat: assist to generate documentation templates r=Veykril a=numero-744

Closes #10878, #1915 and #4767

Full description is in #10878, better read [the tests](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R424) to understand what this feature does.

- [x] There is one remaining thing about non-`pub` functions, what do you think about it?
- [x] In this PR [empty examples are generated](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R99) for `trait` functions, but maybe no examples should be provided at all.
- [x] If there is already a documentation, add another one with a separator ([currently done](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R74)) or simply disable this assist?
- [x] I will check once more that the generated examples are correct (ie. they are easy to fill before that they are built and tested)

Comments appreciated 😄 

Co-authored-by: Côme ALLART <come.allart@etu.emse.fr>
2021-12-11 22:58:49 +00:00
Côme ALLART 0e89f2f346 feat: remove should_panic example generation 2021-12-11 22:46:54 +01:00
Côme ALLART 9e53db274b refactor: use hir to test if a value is returned 2021-12-11 20:52:14 +01:00
Côme ALLART 80a68685db refactor: use Itertools::intersperse 2021-12-11 20:41:23 +01:00
Côme ALLART 7266fdb5a4 refactor: use hir to compare returned and self types 2021-12-11 20:33:08 +01:00
bors[bot] 36a7c0e009
Merge #10988
10988: Fix expected type calculation in struct literal if followed by comma r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-12-11 17:51:02 +00:00
Florian Diebold d599f819e0 Fix expected type calculation in struct literal if followed by comma 2021-12-11 18:47:45 +01:00
bors[bot] 0eb6039e4e
Merge #10987
10987: fix: respect inner attributes for Structs and Enums r=lnicola a=rainy-me

fix: #10980 (the allow/deny issue is not fully resolved though.)

Co-authored-by: rainy-me <github@yue.coffee>
2021-12-11 17:20:14 +00:00
rainy-me a0c52794bd fix: lookup upwards for struct and enum 2021-12-12 01:23:27 +09:00
bors[bot] 4f04d8477a
Merge #10965
10965: minor: Remove dead assists-related function r=Veykril a=lnicola

Unless I'm missing something, `assists_with_fixes` seems to be always used and ends up in the same code path.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-11 15:06:52 +00:00
bors[bot] 48cd733c9e
Merge #10956 #10986
10956: minor: Bump deps r=Veykril a=lnicola

bors r+

10986: fix: Fix lint completions not working for unclosed attributes r=Veykril a=Veykril

Fixes #10682
Uses keywords and nested `TokenTree`s as a heuristic to figure out when to stop parsing in case the attribute is unclosed which should work pretty well as attributes are usually followed by either of those.
bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-11 14:58:07 +00:00
Lukas Wirth 0001a42570 fix: Fix lint completions not working for unclosed attributes 2021-12-11 15:55:25 +01:00
bors[bot] 9946def7e2
Merge #10877
10877: feat: make hightlighting linear r=matklad a=matklad

In https://youtu.be/qvIZZf5dmTE, we've noticed that AstIdMap does a
linear lookup when going from SyntaxNode to Id. This leads to
accidentally quadratic overall performance. Replace linear lookup with a
O(1) hashmap lookup.

Future work: don't duplicate `SyntaxNodePtr` in `AstIdMap` and switch to
"call site dependency injection" style storage (eg, store a
`HashSet<ErasedFileAstId>`).

See the explanation of the work here on YouTube :-)

As you can see from then benchmark results, this doesn't actually make analysis stats fastre. I am a bit mystified as to why this is happening to be honest. 

Baseline
```
Database loaded:     598.40ms, 304minstr, 118mb (metadata 390.57ms, 21minstr, 841kb; build 111.31ms, 8764kinstr, -214kb)
  crates: 39, mods: 824, decls: 18647, fns: 13910
Item Collection:     9.70s, 75ginstr, 377mb
  exprs: 382426, ??ty: 387 (0%), ?ty: 285 (0%), !ty: 145
Inference:           43.16s, 342ginstr, 641mb
Total:               52.86s, 417ginstr, 1018mb
```

This PR:
```
Database loaded:     626.34ms, 304minstr, 118mb (metadata 416.26ms, 21minstr, 841kb; build 113.67ms, 8750kinstr, -209kb)
  crates: 39, mods: 824, decls: 18647, fns: 13910
Item Collection:     10.16s, 75ginstr, 389mb
  exprs: 382426, ??ty: 387 (0%), ?ty: 285 (0%), !ty: 145
Inference:           44.51s, 342ginstr, 644mb
Total:               54.67s, 417ginstr, 1034mb
```

I think we probably should merge the first commit here, but not the second. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-12-11 14:49:29 +00:00
Aleksey Kladov 278e7c3311 more frugal map 2021-12-11 17:49:09 +03:00
bors[bot] 3137327182
Merge #10985
10985: minor: Remove unnecessary clones r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-11 14:32:29 +00:00
Lukas Wirth 03f6d92ae4 minor: Remove unnecessary clones 2021-12-11 15:27:36 +01:00
bors[bot] d97f2f6b9b
Merge #10976
10976: fix: Show case-insensitive exact matches instead of fuzzy flyimport for short paths r=Veykril a=Veykril

And raise the fuzzy trigger from 2 to 3 chars. This way we keep the ability of flyimporting short names like `Rc`.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6917
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-11 13:50:55 +00:00
Lukas Wirth 143a30aa51 Show case-insensitive exact matches instead of fuzzy flyimport for short paths 2021-12-11 14:47:11 +01:00
bors[bot] d03397fe11
Merge #10978
10978: internal: Only prime direct dependencies of the workspace crates r=jonas-schievink a=lnicola

This reduces the number of primed crates on `self` from 177 to 105.

```text
# baseline
  86521 me   20   0 2939M  562M 14320 S  0.0  0.9  0:07.10   37 rust-analyzer

# pr
  99947 me   20   0 2935M  549M 14424 S  0.0  0.9  0:07.10   37 rust-analyzer
```

The RAM usage seems to vary a lot, so I'm not sure the improvement shown above is real.

We also drop the topological sorting, although it might still make sense to do the dependencies before the workspace crates. But since it's only used to make the progress reporting a bit more fine, it probably doesn't matter too much.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-10 22:31:55 +00:00
bors[bot] 021d5821be
Merge #10981
10981: internal: Remove some allocations r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-10 19:02:51 +00:00
Lukas Wirth 1bbc255ec5 Remove some allocations 2021-12-10 20:01:24 +01:00
bors[bot] bcc720f22f
Merge #10979
10979: fix: Don't show trait flyimports for impl trait and placeholders r=Veykril a=Veykril

cc #8539
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-10 18:19:02 +00:00
Lukas Wirth c81aa68afe Don't show trait flyimports for impl trait and placeholders 2021-12-10 19:18:21 +01:00
Lukas Wirth a7fc2061ea Show enum completions for single variant enums in irrefutable patterns 2021-12-10 18:25:54 +01:00
Côme ALLART 9c0f9d02bf feat: trait fn: add panicking example only if default panicks 2021-12-10 15:53:43 +01:00
Laurențiu Nicola d012a20f25 Only prime direct dependencies of the workspace crates 2021-12-10 16:24:07 +02:00
bors[bot] bc8efca0c8
Merge #10977
10977: fix: fix `concat!` with captured expression r=jonas-schievink a=jonas-schievink

Adds another hack on top of https://github.com/rust-analyzer/rust-analyzer/pull/10623 to fix `concat!`.

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

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2021-12-10 14:19:51 +00:00
Jonas Schievink 95ddeaed8e Fix concat! with captured expression 2021-12-10 15:17:31 +01:00
Côme ALLART f5e0998402 refactor: use hir to check if fn in trait/impl 2021-12-10 15:16:04 +01:00
Côme ALLART c3d151ada6 fix: check correctly if function is exported 2021-12-10 14:42:31 +01:00
bors[bot] 2534b7db1a
Merge #10975
10975: internal: Shrink TraitImpls and InherentImpls HashMaps r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-09 17:41:01 +00:00
Lukas Wirth c469f8abcb internal: Shrink TraitImpls and InherentImpls HashMaps 2021-12-09 18:39:46 +01:00
bors[bot] 9eb5a96387
Merge #10974
10974: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-09 17:28:53 +00:00
Lukas Wirth e1a236d65e Simplify 2021-12-09 18:28:10 +01:00
Lukas Wirth f9c59d3752 Use known names instead of string literals 2021-12-09 18:13:15 +01:00
Lukas Wirth 067d87e8a9 Remove some allocs 2021-12-09 18:04:32 +01:00