Commit graph

90 commits

Author SHA1 Message Date
Aleksey Kladov
181590412e add more counts 2021-01-27 12:16:24 +03:00
Laurențiu Nicola
4e92681aba Disallow non-boolean literals in concat! 2021-01-25 13:31:03 +02:00
Laurențiu Nicola
ee8c678870 Unquote strings and handle boolean literals in concat! 2021-01-25 13:02:57 +02:00
Phil Ellison
8c7ccdc29d Identify methods using functions ids rather than string names 2021-01-23 07:40:25 +00:00
bors[bot]
e62533c3ec
Merge #7359
7359: ItemTree: store a mapping from blocks to inner items r=jonas-schievink a=jonas-schievink

To do name resolution within block expressions, we need to know which inner items are located inside each block expression. This adds such a mapping to `ItemTree`, replacing the previous one, which was seemingly unused other than to access all the inner items.

This also assigns `AstId`s to block expressions, which is needed to store the mapping in salsa.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-01-20 16:09:22 +00:00
Aleksey Kladov
46b4f89c92 . 2021-01-20 01:56:11 +03:00
Aleksey Kladov
cd21b0e9c1 ⬆️ rowan 2021-01-19 22:11:42 +03:00
Jonas Schievink
52fe50a97b Record FileAstIds for block expressiosn
Every block expression may contain inner items, so we need to be able
to refer to any block expression and use it as a salsa key.
2021-01-19 19:49:19 +01:00
Jonas Schievink
2d799cf5e0 shrink_to_fit TokenMap's backing storage 2021-01-18 18:40:06 +01:00
bors[bot]
9eb37fbdeb
Merge #7292
7292: Swap assert_eq_text\!(expected, actual) r=matklad a=u5surf

Fixes #7283 

Swap assert_eq_text parameters in the order (expected, actual)

Co-authored-by: yugo-horie <u5.horie@gmail.com>
2021-01-18 10:12:54 +00:00
Aleksey Kladov
1c8feac01f ⬆️ arena 2021-01-17 11:43:04 +03:00
bors[bot]
f5f011ba71
Merge #7304
7304: Depend on local copy of la-arena instead of crates.io’s r=lnicola a=arzg

This addresses [this comment](https://github.com/rust-analyzer/rust-analyzer/pull/7276#issuecomment-760909936). #7275 and #7276 should start compiling if this is merged.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-01-17 07:05:44 +00:00
Aramis Razzaghipour
709034d123
Depend on local copy of la-arena instead of crates.io’s 2021-01-17 17:52:57 +11:00
Aleksey Kladov
b38414c7f4 When building an item-tree, keep fewer nodes in memory 2021-01-16 23:07:28 +03:00
yugo-horie
f273995a25 Swap assert_eq_text\!(expected, actual) 2021-01-16 13:30:26 +09:00
Aleksey Kladov
6dbba4d75d Remove useless wrapper 2021-01-15 20:15:33 +03:00
Aleksey Kladov
4c4e54ac8a prepare to publish el libro de arena 2021-01-14 19:06:02 +03:00
Vincent Esche
21f8239ac8 Fixed typos in code comments 2021-01-09 15:41:29 +01:00
bors[bot]
1a29934c37
Merge #7145
7145: Proper handling $crate Take 2 [DO NOT MERGE] r=edwin0cheng a=edwin0cheng

Similar to previous PR (#7133) , but improved the following things :

1. Instead of storing the whole `ExpansionInfo`, we store a similar but stripped version `HygieneInfo`.
2. Instread of storing the `SyntaxNode` (because every token we are interested are IDENT), we store the `TextRange` only.
3. Because of 2, we now can put it in Salsa.
4. And most important improvement: Instead of computing the whole frames every single time, we compute it recursively through salsa: (Such that in the best scenario, we only need to compute the first layer of frame)

```rust
        let def_site = db.hygiene_frame(info.def.file_id);
        let call_site = db.hygiene_frame(info.arg.file_id);

        HygieneFrame { expansion: Some(info), local_inner, krate, call_site, def_site }
```

The overall speed compared to previous PR is much faster (65s vs 45s) :
```
[WITH old PR]
Database loaded 644.86ms, 284mi
Crates in this dir: 36
Total modules found: 576
Total declarations: 11153
Total functions: 8715
Item Collection: 15.78s, 91562mi
Total expressions: 240721
Expressions of unknown type: 2635 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 865
Inference: 49.84s, 250747mi
Total: 65.62s, 342310mi
rust-analyzer -q analysis-stats .  66.72s user 0.57s system 99% cpu 1:07.40 total

[WITH this PR]
Database loaded 665.83ms, 284mi
Crates in this dir: 36
Total modules found: 577
Total declarations: 11188
Total functions: 8743
Item Collection: 15.28s, 84919mi
Total expressions: 241229
Expressions of unknown type: 2637 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 868
Inference: 30.15s, 135293mi
Total: 45.43s, 220213mi   
rust-analyzer -q analysis-stats .  46.26s user 0.74s system 99% cpu 47.294 total
```

*HOWEVER*,  it is still a perf regression (35s vs 45s):
```
[WITHOUT this PR]
Database loaded 657.42ms, 284mi
Crates in this dir: 36
Total modules found: 577
Total declarations: 11177
Total functions: 8735
Item Collection: 12.87s, 72407mi
Total expressions: 239380
Expressions of unknown type: 2643 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 868
Inference: 22.88s, 97889mi
Total: 35.74s, 170297mi
rust-analyzer -q analysis-stats .  36.71s user 0.63s system 99% cpu 37.498 total
```



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-08 03:57:11 +00:00
Phil Ellison
b2dbe6e43a Add fix to wrap return expression in Some 2021-01-07 19:01:33 +00:00
Kevaundray Wedderburn
72b9a4fbd3 Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
Edwin Cheng
76f2b9d2ef Proper handling $crate Take 2 2021-01-07 13:08:32 +08:00
Edwin Cheng
af3d75ad2e Refactor TokenBuffer for reduc cloning 2021-01-05 02:00:46 +08:00
Jonas Schievink
85cc3cfec9
Revert "Proper handling $crate and local_inner_macros" 2021-01-03 11:47:57 +01:00
Edwin Cheng
26b9c793f1 Fixed nested eager macro bug 2021-01-03 17:56:59 +08:00
bors[bot]
a88d4f8c72
Merge #7133
7133: Proper handling $crate and local_inner_macros r=jonas-schievink a=edwin0cheng

This PR introduces `HygineFrames` to store the macro definition/call site hierarchy in hyginee and when resolving `local_inner_macros` and `$crate`, we use the token to look up the corresponding frame and return the correct value.

See also: https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies

fixe #6890 and  #6788

r? @jonas-schievink 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-02 17:42:45 +00:00
Edwin Cheng
3545289603 Use arena instead of vec 2021-01-02 22:48:22 +08:00
Edwin Cheng
63e330f402 Fix infer error of macro invocation in array expr 2021-01-02 22:06:59 +08:00
Edwin Cheng
fe5340d970 Introduce HygieneFrames for proper token hyginee 2021-01-02 20:39:57 +08:00
Edwin Cheng
74a557857b Fix == in in format causes mismatched-arg-count 2020-12-31 17:59:29 +08:00
Jonas Schievink
70877428a8 Pass crate environment to proc macros 2020-12-27 15:29:47 +01:00
Jonas Schievink
26f604b907 Store invocation site for eager macros 2020-12-22 15:02:03 +01:00
Jonas Schievink
ea5cc8d07a More accurate #[derive] parsing
This now allows full paths to the derive macro
2020-12-19 01:10:56 +01:00
Jonas Schievink
08de1b4fa5 Implement RawAttr::filter 2020-12-18 18:58:42 +01:00
Lukas Wirth
dd496223f5 Node-ify lifetimes 2020-12-16 14:16:09 +01:00
Jonas Schievink
b238ddd21a Make macro def krate mandatory
Refactors builtin derive support to go through proper name resolution
2020-12-15 20:33:05 +01:00
Jonas Schievink
c31c3246a8 Basic support for decl macros 2.0 2020-12-15 18:43:34 +01:00
Jonas Schievink
c1cb595382 Move to upstream macro_rules! model 2020-12-15 15:37:37 +01:00
bors[bot]
39aae835fd
Merge #6886
6886: Expand statements for macros in lowering r=matklad a=edwin0cheng

Fixes #6811

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-15 12:41:07 +00:00
Edwin Cheng
1f4da7098c Remove obsolete comment 2020-12-15 17:25:59 +08:00
lf-
090a59970d Resolve macro-error diagnostics on asm & llvm_asm
We currently stub these out as returning unit.

This fixes spurious RA diagnostics in the following:
```rust
unsafe { asm!(""); llvm_asm!(""); }
```
2020-12-15 01:06:53 -08:00
Edwin Cheng
a68ff269a9 Expand statements for mbe in lowering 2020-12-15 14:39:15 +08:00
Jonas Schievink
81820fe52c Implement module_path!() 2020-12-14 16:38:53 +01:00
Lukas Wirth
11f8664182 Add Lifetimes to the HIR 2020-12-12 00:56:52 +01:00
Jonas Schievink
829d9d36eb Use decimal notation 2020-12-10 18:03:37 +01:00
Jonas Schievink
19508b474f Double the macro token limit 2020-12-10 17:51:39 +01:00
Jonas Schievink
614e5a2272 Improve macro limit error and move to const 2020-12-10 17:50:56 +01:00
Jonas Schievink
948832d10b format_args: handle key-value arguments 2020-12-10 13:46:47 +01:00
Aleksey Kladov
6e24321e45 Introduce anchored_path
They allow to represent paths like `#[path = "C:\path.rs"] mod foo;`
in a lossless cross-platform & network-transparent way.
2020-12-09 19:07:05 +03:00
Jonas Schievink
bb28aef918 Fix concat! with integer literals 2020-12-08 20:06:41 +01:00