aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
Commit message (Collapse)AuthorAgeFilesLines
* Add name resolution query for block expressionsJonas Schievink2021-01-216-36/+198
|
* Treat BlockExpr as a potential module originJonas Schievink2021-01-202-2/+11
|
* DefMap: hide remaining crate-visible fieldsJonas Schievink2021-01-204-11/+23
|
* Merge #7359bors[bot]2021-01-202-26/+35
|\ | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Create a mapping from blocks to inner itemsJonas Schievink2021-01-202-26/+35
| |
* | Make public DefMap fields privateJonas Schievink2021-01-205-14/+22
| |
* | Show const params in completionsLukas Wirth2021-01-191-9/+16
|/
* Merge #7336bors[bot]2021-01-189-36/+32
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | 7336: Rename `CrateDefMap` to `DefMap` r=matklad a=jonas-schievink I propose handling local items by computing a `DefMap` for every block expression, using the regular (early) name resolution algorithm. The result of that will be a `DefMap` that has a reference to the parent `DefMap`, which is either the one computed for the containing block expression, or the crate's root `DefMap`. Name resolution will fall back to a name in the parent `DefMap` if it cannot be resolved in the inner block. The `DefMap`s computed for block expressions will go through a separate query that can be garbage-collected much more aggressively, since these `DefMap`s should be cheap to compute and are never part of a crate's public API. The first step towards that is to make `CrateDefMap` not specific to crates anymore, hence this rename (if this plans sounds reasonable). cc https://github.com/rust-analyzer/rust-analyzer/issues/7325 and https://github.com/rust-analyzer/rust-analyzer/issues/1165 Co-authored-by: Jonas Schievink <[email protected]>
| * Rename `CrateDefMap` to `DefMap`Jonas Schievink2021-01-189-36/+32
| |
| |
| \
*-. \ Merge #7297 #7338bors[bot]2021-01-181-0/+66
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7297: Propose trait associated items and autoimport traits on completion r=matklad a=SomeoneToIgnore ![trait_imports](https://user-images.githubusercontent.com/2690773/104819998-6faeb480-583a-11eb-8b45-b7351b51b90e.gif) Closes #7248 7338: Parse `impl const Trait` r=Veykril a=Veykril Closes #7313 bors r+ Co-authored-by: Kirill Bulatov <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
| * | Add flyimport completion for trait assoc itemsKirill Bulatov2021-01-161-0/+66
| | |
* | | Merge #7326bors[bot]2021-01-181-1/+1
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | 7326: Use `is_ident` when converting Path to an Identifier r=edwin0cheng a=kevaundray Co-authored-by: Kevaundray Wedderburn <[email protected]>
| * | cargo fmtKevaundray Wedderburn2021-01-181-1/+1
| | |
| * | use `is_ident` methodKevaundray Wedderburn2021-01-181-2/+2
| | |
* | | Merge #7327bors[bot]2021-01-181-9/+1
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7327: Remove `item_tree::Expr` r=jonas-schievink a=jonas-schievink It's empty and unused bors r+ Co-authored-by: Jonas Schievink <[email protected]>
| * | | Remove `item_tree::Expr`Jonas Schievink2021-01-181-9/+1
| | | | | | | | | | | | | | | | It's empty and unused
* | | | Add `MacroType` syntaxJonas Schievink2021-01-181-0/+2
|/ / /
* | | :arrow_up: arenaAleksey Kladov2021-01-171-1/+1
| | |
* | | Use ‘index’ terminology for arena consistentlyAramis Razzaghipour2021-01-174-7/+7
| | |
* | | Merge #7276bors[bot]2021-01-177-7/+7
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7276: Remove map module from la-arena public API r=lnicola a=arzg It’s unlikely that more items will be added to the module, so it’s simpler for users if `ArenaMap` is re-exported and the module made private. This doesn’t compile for the same reason that #7275 doesn’t: > This pull request doesn’t compile because dependencies on la-arena go through crates.io, so existing dependencies on the crate are referencing an old version. As such, this PR will only compile once a new la-arena version has been published. Co-authored-by: Aramis Razzaghipour <[email protected]>
| * | | Remove map module from la-arena public APIAramis Razzaghipour2021-01-157-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | It’s unlikely that more items will be added to the module, so it’s simpler for users if `ArenaMap` is re-exported and the module made private.
* | | | Merge #7304bors[bot]2021-01-171-1/+1
|\ \ \ \ | |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * | | Depend on local copy of la-arena instead of crates.io’sAramis Razzaghipour2021-01-171-1/+1
| |/ /
* | | Handle self/super/crate in PathSegment as NameRefLukas Wirth2021-01-151-1/+1
| | |
* | | Add support for yiled keywordDaiki Ihara2021-01-152-1/+8
|/ /
* | prepare to publish el libro de arenaAleksey Kladov2021-01-1415-15/+15
| |
* | Merge #7110bors[bot]2021-01-143-4/+10
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7110: Deduplicate macros when offering completion r=matklad a=AdnoC Closes https://github.com/rust-analyzer/rust-analyzer/issues/7081 When iterating over the names within the `hir_def::resolver::Scope` for a module, track what macros are in the `hir_def::item_scope::ItemScope::legacy_macros` collection for the module. When iterating over names from the prelude, do not proccess the name if it had been in the `legacy_macros` collection. This is implemented with a `FxHashSet` in the `Scope::process_names` function that is populated when iterating over `legacy_macros` and checked when iterating over the prelude. Alternative implementation could instead query the `legacy_macros` `FxHashMap` directly when processing names in the prelude. Also, I'd like to add a test for this, but I'm not sure where it could be added. Co-authored-by: AdnoC <[email protected]>
| * | we can have one less call to name.clone()AdnoC2020-12-311-2/+3
| | |
| * | deduplicate macro completions from legacy macros and preludeAdnoC2020-12-313-4/+9
| | |
* | | Fixed typos in code commentsVincent Esche2021-01-094-8/+8
| | |
* | | Merge #7145bors[bot]2021-01-081-1/+1
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * | | Proper handling $crate Take 2Edwin Cheng2021-01-071-1/+1
| | | |
* | | | Add fix to wrap return expression in SomePhil Ellison2021-01-071-0/+1
| | | |
* | | | Change <|> to $0 - RebaseKevaundray Wedderburn2021-01-073-41/+41
| |_|/ |/| |
* | | Emit diagnostics for unresolved item-level macrosJonas Schievink2021-01-051-1/+32
| | |
* | | Merge #7168bors[bot]2021-01-051-1/+1
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7168: Rename expr -> tail_expr r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * | | Rename expr -> tail_exprAleksey Kladov2021-01-051-1/+1
| | | |
* | | | Merge #7140bors[bot]2021-01-052-113/+177
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7140: Store trait associated items in fst r=matklad a=SomeoneToIgnore Store imported traits' associated function/methods and constants into `ImportMap.fst` and pefrorm the imports search on them. This is a first step towards trait autoimport during completion functionality, the way I see it, after this PR, only a few major things are left to be done: * store all traits' assoc items into fst, not only the ones in scope, as we do now. Any code pointers on how to do this are welcome 😄 * adjust a few modules in completions crate (`dot.rs`, `qualified_path.rs` at least) to query the import map, reusing the `import_assets` logic heavily == With the current import and autoimport implementations, it looks like for a single query, we're either interested in either associated items lookup or in all other `fst` contents lookup, but never both simultaneously. I would rather not split `fst` in two but add another `Query` parameter to separate those, but let me know if you have any ideas. Co-authored-by: Kirill Bulatov <[email protected]>
| * | | Move the test markKirill Bulatov2021-01-051-2/+4
| | | |
| * | | Small helpersKirill Bulatov2021-01-041-0/+4
| | | |
| * | | Code review fixesKirill Bulatov2021-01-041-30/+30
| | | |
| * | | Do not collect trait type aliasesKirill Bulatov2021-01-041-5/+6
| | | |
| * | | SimplifyKirill Bulatov2021-01-042-27/+37
| | | |
| * | | Properly check assoc items lookupKirill Bulatov2021-01-042-46/+73
| | | |
| * | | Add associated data into fstKirill Bulatov2021-01-041-49/+45
| | | |
| * | | Add a basic test for the trait fuzzy importKirill Bulatov2021-01-041-0/+24
| | | |
* | | | Introduce new queries to computeDaniel Frampton2021-01-052-12/+55
|/ / / | | | | | | | | | | | | | | | | | | | | | 1) the set of attributes for all variants of an enum, and 2) the set of attributes for all fields of a variant. This avoids the current n^2 behavior when rendering completion for variants, which prevents completion for enums with large numbers of variants.
* | | Merge #7113bors[bot]2021-01-031-0/+4
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7113: Manual updates r=matklad a=tekul Add some details on how to build the manual and some clarification on how to deal with "proc macro2 warnings. For context, this arose from [this question](https://users.rust-lang.org/t/how-to-disable-rust-analyzer-proc-macro-warnings-in-neovim/53150) on users.rust-lang.org. Co-authored-by: Luke Taylor <[email protected]>
| * | | Expand doc on dealing with "proc macro not expanded"Luke Taylor2021-01-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Added the error message to the doc for the UnresolvedProcMacro diagnostic, explaining that either enabling the procMacro setting or disabling this diagnostic should make the warnings go away.
* | | | Upgrade expect-test to 1.1Jesse Bakker2021-01-031-1/+1
| |/ / |/| |