rust/crates/hir_def/src
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
..
body Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
item_tree Don't look at attributes when lowering to ItemTree 2020-12-18 20:37:26 +01:00
nameres Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
path Proper handling $crate Take 2 2021-01-07 13:08:32 +08:00
adt.rs Refactor attributes API to allow handling cfg_attr 2020-12-18 02:24:14 +01:00
attr.rs Introduce new queries to compute 2021-01-04 20:37:50 -08:00
body.rs Track labels in the HIR 2020-12-24 12:49:40 +01:00
builtin_attr.rs Add upstream commit to builtin_attr.rs 2020-12-11 19:12:06 +01:00
builtin_type.rs
child_by_source.rs
data.rs Refactor attributes API to allow handling cfg_attr 2020-12-18 02:24:14 +01:00
db.rs Introduce new queries to compute 2021-01-04 20:37:50 -08:00
diagnostics.rs Expand doc on dealing with "proc macro not expanded" 2021-01-01 18:47:54 +00:00
dyn_map.rs
expr.rs Merge #7021 2020-12-24 12:04:28 +00:00
find_path.rs Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
generics.rs Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
import_map.rs Move the test mark 2021-01-05 14:03:58 +02:00
item_scope.rs Simplify 2021-01-04 17:44:27 +02:00
item_tree.rs Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
keys.rs Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
lang_item.rs Remove module_lang_items 2020-12-17 00:26:01 +01:00
lib.rs Impl HasAttrs for GenericParam 2021-01-02 00:44:59 +01:00
nameres.rs Remove some unneeded string allocations 2020-12-31 10:13:14 +01:00
path.rs Add fix to wrap return expression in Some 2021-01-07 19:01:33 +00:00
per_ns.rs
resolver.rs Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
src.rs Change HasChildSource::ChildId assoc item to generic param 2020-12-15 18:21:01 +01:00
test_db.rs Introduce anchored_path 2020-12-09 19:07:05 +03:00
trace.rs
type_ref.rs Node-ify lifetimes 2020-12-16 14:16:09 +01:00
visibility.rs