Commit graph

427 commits

Author SHA1 Message Date
bors[bot]
3ff2aa6d09
Merge #7546
7546: Add newline between block and crate maps r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-02-03 17:25:06 +00:00
Jonas Schievink
6458f9107c Add newline between block and crate maps 2021-02-03 18:23:59 +01:00
Jonas Schievink
eda1cb7ceb Add a FIXME to ItemTree 2021-02-03 18:14:39 +01:00
Jonas Schievink
d4a22fc801 Update DefMap and block_def_map docs 2021-02-03 17:54:03 +01:00
Jonas Schievink
63744fe128 Test for name resolution with DefMap shortcut 2021-02-03 15:33:25 +01:00
Jonas Schievink
da57f5dc17 Shortcut block_def_map if there's no inner items
This previously didn't work, but apparently only because of the wonky
test setup
2021-02-03 15:33:25 +01:00
Jonas Schievink
7eff6705cc Use body lowering for block_def_map tests
Removes the hacky and buggy custom lowering code
2021-02-03 14:21:15 +01:00
Jonas Schievink
b7be2b1d3c Use block_def_map in body lowering 2021-02-03 14:21:15 +01:00
Jonas Schievink
5914f86d47 Fix resolution of crate paths from within blocks
They resolve to the crate root, not the DefMap's root module (which
can be a block)
2021-02-02 18:02:12 +01:00
Jonas Schievink
cd9659ffce Use the right DefMap when looking up modules 2021-02-02 12:36:38 +01:00
Jonas Schievink
7202ce6c96
Revert "Use block_def_map in body lowering" 2021-02-02 11:46:58 +01:00
Jonas Schievink
b4aa860cac Shortcut block_def_map if there's no inner items
This previously didn't work, but apparently only because of the wonky
test setup
2021-02-01 13:33:18 +01:00
Jonas Schievink
80ae583dc0 Use body lowering for block_def_map tests
Removes the hacky and buggy custom lowering code
2021-02-01 13:33:18 +01:00
Jonas Schievink
9cc7d57429 Use block_def_map in body lowering 2021-02-01 13:33:18 +01:00
bors[bot]
1a59f75cda
Merge #7503
7503: Return inner attributes of outline mod declarations in `attrs_query` r=jonas-schievink a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-31 20:13:28 +00:00
Lukas Wirth
999e020da2 Return inner attributes of outline mod declarations in attrs_query 2021-01-31 19:53:01 +01:00
Lukas Wirth
412f180d71 Honor #![macro_use] in mod source files 2021-01-31 19:33:02 +01:00
Jonas Schievink
090b2f0e50 Fix incorrect FileId and remove broken shortcut
Apparently we were using the crate's root file instead of the file
containing the block.
2021-01-28 19:33:00 +01:00
Jonas Schievink
7177045a67 block_def_map: add a few macro tests 2021-01-28 18:53:35 +01:00
Jonas Schievink
232b75394e Update original_module when ascending DefMaps 2021-01-28 18:27:27 +01:00
Jonas Schievink
2aebde6c0b ItemTree: Treat items in MacroStmts as top-level 2021-01-28 18:00:10 +01:00
Jonas Schievink
ad254f4c97 Fix legacy macro resolution in block expressions 2021-01-27 19:16:39 +01:00
Aleksey Kladov
181590412e add more counts 2021-01-27 12:16:24 +03:00
Jonas Schievink
08253d5473 Traverse parent DefMap for super paths 2021-01-25 19:15:39 +01:00
Jonas Schievink
98a88ebb9e Intern block locations and handle them in ModuleId 2021-01-25 19:02:05 +01:00
bors[bot]
2c735ed734
Merge #7426
7426: Create all `ModuleId`s through a `DefMap` method r=jonas-schievink a=jonas-schievink

`ModuleId` needs to be able to represent blocks, and only the
associated `DefMap` will know how to construct that `ModuleId`

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-01-25 14:22:24 +00:00
Jonas Schievink
5c241b0766 Create all ModuleIds through a DefMap method
`ModuleId` needs to be able to represent blocks, and only the
associated `DefMap` will know how to construct that `ModuleId`
2021-01-25 15:21:33 +01:00
Laurențiu Nicola
5ed5a542fb Derive Default on ItemTree 2021-01-25 14:12:53 +02:00
Phil Ellison
8c7ccdc29d Identify methods using functions ids rather than string names 2021-01-23 07:40:25 +00:00
bors[bot]
eab5db20ed
Merge #7391
7391: Fix error when using "extern crate self as" r=kazatsuyu a=kazatsuyu

Fix #6957

Co-authored-by: kazatsuyu <shirayama.kazatsuyu@gmail.com>
2021-01-23 04:04:09 +00:00
Jonas Schievink
3de8f57c51 Make ModuleId's krate field private 2021-01-22 18:09:55 +01:00
Jonas Schievink
ce29730bc7 Obtain ModuleId's DefMap through a method 2021-01-22 16:33:58 +01:00
kazatsuyu
90d6740e32 Add mark::check! and mark::hit! 2021-01-23 00:11:37 +09:00
kazatsuyu
0fb4544403 cargo fmt 2021-01-22 22:52:04 +09:00
kazatsuyu
e52589e3a7 Fix error when using "extern crate self as" 2021-01-22 22:28:45 +09:00
Daiki Ihara
f5b97e52c9 Fix broken link in intra-doc 2021-01-22 20:06:45 +09:00
Jonas Schievink
8916b0c6cb Remove unused field 2021-01-21 21:12:26 +01:00
Jonas Schievink
4d19607057 Add test for path resolution bug 2021-01-21 20:35:36 +01:00
Jonas Schievink
3f4f253028
Revert "Make use of block_def_map in body lowering" 2021-01-21 19:04:31 +01:00
bors[bot]
e76d8c1d9a
Merge #7378
7378: Include `countme` crate to count important data structures. r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-21 17:46:44 +00:00
Jonas Schievink
cdb0e25aaa Make use of block_def_map in body lowering
Removes the `local_scope` hack from `Expander` in favor of tracking the
`DefMap` in use during body lowering
2021-01-21 18:05:52 +01:00
Aleksey Kladov
e5c5c0a040 Include countme crate to count important data structures. 2021-01-21 19:30:52 +03:00
Jonas Schievink
d157a03e93 Remove unnecessary annotations from tests 2021-01-21 17:19:46 +01:00
Jonas Schievink
4e603b7947 Add test for nameres in nested blocks 2021-01-21 16:42:56 +01:00
Jonas Schievink
ec4a1dc297 Add test that merges inner and outer names 2021-01-21 16:23:50 +01:00
Jonas Schievink
d62c9c6c63 Fix lowering with multiple block expressions 2021-01-21 16:23:22 +01:00
Jonas Schievink
f8f44cfb9b Fall back to parent DefMaps when resolving paths 2021-01-21 15:24:15 +01:00
Jonas Schievink
896dfacfc4 Add name resolution query for block expressions 2021-01-21 15:22:17 +01:00
Jonas Schievink
82146737ac Treat BlockExpr as a potential module origin 2021-01-20 20:05:48 +01:00
Jonas Schievink
5f319ca7ee DefMap: hide remaining crate-visible fields 2021-01-20 18:17:48 +01: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
Jonas Schievink
0587b99fde Make public DefMap fields private 2021-01-20 15:41:18 +01:00
Jonas Schievink
c5ed2284b5 Create a mapping from blocks to inner items 2021-01-20 15:00:28 +01:00
Lukas Wirth
bed12833cc Show const params in completions 2021-01-19 20:06:39 +01:00
bors[bot]
0791c8e44c
Merge #7336
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 <jonasschievink@gmail.com>
2021-01-18 20:12:11 +00:00
bors[bot]
342bf41022
Merge #7297 #7338
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 <mail4score@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-18 19:40:11 +00:00
Jonas Schievink
57a82fb05b Rename CrateDefMap to DefMap 2021-01-18 20:18:05 +01:00
bors[bot]
fcc109e890
Merge #7326
7326: Use `is_ident` when converting Path to an Identifier r=edwin0cheng a=kevaundray



Co-authored-by: Kevaundray Wedderburn <kevtheappdev@gmail.com>
2021-01-18 17:40:11 +00:00
bors[bot]
6105dbfc2e
Merge #7327
7327: Remove `item_tree::Expr` r=jonas-schievink a=jonas-schievink

It's empty and unused

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-01-18 17:11:38 +00:00
Jonas Schievink
6f4f285f37 Remove item_tree::Expr
It's empty and unused
2021-01-18 18:05:40 +01:00
Kevaundray Wedderburn
da104bb0f5 cargo fmt 2021-01-18 16:58:29 +00:00
Jonas Schievink
872bf09381 Add MacroType syntax 2021-01-18 17:56:35 +01:00
Kevaundray Wedderburn
725c20e8c5 use is_ident method 2021-01-18 16:54:07 +00:00
Aleksey Kladov
1c8feac01f ⬆️ arena 2021-01-17 11:43:04 +03:00
Aramis Razzaghipour
1d103cf087
Use ‘index’ terminology for arena consistently 2021-01-17 18:38:08 +11:00
bors[bot]
3224ecea87
Merge #7276
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 <aramisnoah@gmail.com>
2021-01-17 07:20:36 +00: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
Kirill Bulatov
db335a1bbf Add flyimport completion for trait assoc items 2021-01-16 20:44:12 +02:00
Lukas Wirth
cb863390f2 Handle self/super/crate in PathSegment as NameRef 2021-01-15 19:21:23 +01:00
Daiki Ihara
85cd3524e2 Add support for yiled keyword 2021-01-15 23:35:17 +09:00
Aramis Razzaghipour
9b5ba090db
Remove map module from la-arena public API
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.
2021-01-15 11:14:04 +11:00
Aleksey Kladov
4c4e54ac8a prepare to publish el libro de arena 2021-01-14 19:06:02 +03:00
bors[bot]
184f4cbf5d
Merge #7110
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 <adam.r.cutler@gmail.com>
2021-01-14 10:00:46 +00: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
Jonas Schievink
3cb7c8b548 Emit diagnostics for unresolved item-level macros 2021-01-05 15:42:43 +01:00
bors[bot]
c8d3d5694b
Merge #7168
7168: Rename expr -> tail_expr r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-05 12:51:38 +00:00
Aleksey Kladov
f9707cde68 Rename expr -> tail_expr 2021-01-05 15:51:13 +03:00
bors[bot]
d7013a5934
Merge #7140
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 <mail4score@gmail.com>
2021-01-05 12:04:35 +00:00
Kirill Bulatov
543e950e30 Move the test mark 2021-01-05 14:03:58 +02:00
Daniel Frampton
f08109bd2d Introduce new queries to compute
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.
2021-01-04 20:37:50 -08:00
Kirill Bulatov
27b3b13824 Small helpers 2021-01-04 22:01:35 +02:00
Kirill Bulatov
ca42a52051 Code review fixes 2021-01-04 18:33:05 +02:00
Kirill Bulatov
ed1ef3ae13 Do not collect trait type aliases 2021-01-04 17:44:27 +02:00
Kirill Bulatov
8721574a85 Simplify 2021-01-04 17:44:27 +02:00
Kirill Bulatov
d27dea86b7 Properly check assoc items lookup 2021-01-04 17:44:27 +02:00
Kirill Bulatov
63d83fa385 Add associated data into fst 2021-01-04 17:44:27 +02:00
Kirill Bulatov
1bfc3a50c0 Add a basic test for the trait fuzzy import 2021-01-04 17:44:27 +02:00
bors[bot]
5b86ff3e91
Merge #7113
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 <tekul.hs@gmail.com>
2021-01-03 18:22:07 +00:00
Jesse Bakker
c7e0c7f43a Upgrade expect-test to 1.1 2021-01-03 14:43:29 +01:00
Jonas Schievink
85cc3cfec9
Revert "Proper handling $crate and local_inner_macros" 2021-01-03 11:47:57 +01:00
bors[bot]
3bf4cec799
Merge #7128
7128: Implement HasAttrs for GenericParam r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-03 08:49:59 +00:00
cynecx
3e9847f747 Use fully qualified Itertools::intersperse call to silence nightly warnings about a potential name collision due to recent libstd api additions 2021-01-02 20:58:53 +01: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
fe5340d970 Introduce HygieneFrames for proper token hyginee 2021-01-02 20:39:57 +08:00
Lukas Wirth
ec448ca4b3 Impl HasAttrs for GenericParam 2021-01-02 00:44:59 +01:00
Luke Taylor
10c9efc24b Expand doc on dealing with "proc macro not expanded"
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.
2021-01-01 18:47:54 +00:00
bors[bot]
0e5fe47153
Merge #7080
7080: Implement ConstParams for HIR r=Veykril a=Veykril

r? @flodiebold 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-01 13:45:10 +00:00
Lukas Wirth
0acdb73076 Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
AdnoC
cca0dfa79e we can have one less call to name.clone() 2020-12-31 13:46:13 -07:00
AdnoC
435c189c80 deduplicate macro completions from legacy macros and prelude 2020-12-31 13:41:49 -07:00
Lukas Wirth
816190c6f6 Remove some unneeded string allocations 2020-12-31 10:13:14 +01:00
kjeremy
dc1396eec7 Update crates 2020-12-30 10:39:50 -05:00
Aleksey Kladov
0c3be014ec Simplify 2020-12-30 13:38:37 +03:00
Laurențiu Nicola
42c24ff25f Avoid a couple of allocations 2020-12-29 14:35:49 +02:00
Kirill Bulatov
eecbb51cb3 Better display methods in expect tests 2020-12-28 16:13:37 +02:00
Kirill Bulatov
8600cf807e Add tests 2020-12-28 15:22:03 +02:00
Kirill Bulatov
e4c3f753d2 Add docs and optimisations 2020-12-28 15:09:39 +02:00
Kirill Bulatov
c4995cfbd5 Better query api and fuzzy search 2020-12-28 15:06:10 +02:00
Kirill Bulatov
0e48cd0c3c Draft the module exclusion in modules 2020-12-28 15:06:10 +02:00
Edwin Cheng
877c251bef Fixed old failed test due to new fixes 2020-12-28 20:08:50 +08:00
bors[bot]
06320015af
Merge #7021
7021: Track labels in the HIR r=matklad a=Veykril

Groundwork for #6966

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-24 12:04:28 +00:00
Lukas Wirth
262b9c3982 Track labels in the HIR 2020-12-24 12:49:40 +01:00
Lukas Wirth
a142beaf01 Implement const block inference 2020-12-23 12:24:24 +01:00
Lukas Wirth
0a780c0ab3 Implement const pat inference 2020-12-23 12:15:38 +01:00
bors[bot]
fd1fcf2c2e
Merge #7010
7010: Update ungrammar for const block patterns r=matklad a=Veykril

Fixes #6848

Adds const blocks and const block patterns to the AST and parses them.

Blocked on https://github.com/rust-analyzer/ungrammar/pull/17/, will merge that PR there once this one gets the OK so I can remove the local ungrammar dependency path and fix the Cargo.lock.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-23 10:37:30 +00:00
Aleksey Kladov
2c84c2d07a Don't think that /submod.rs is /mod.rs 2020-12-23 11:02:42 +03:00
Lukas Wirth
be7260485e Update ungrammar for const block patterns 2020-12-23 01:26:31 +01:00
bors[bot]
eefbae7ed4
Merge #6921
6921: Higher-ranked trait bounds for where clauses r=flodiebold a=Veykril

There is a slight problem with this which is also noted in a FIXME now but `LifetimeParameters` of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-20 11:47:01 +00:00
Jonas Schievink
218e88ab55 Add API for mapping Attr back to its syntax node 2020-12-19 15:15:02 +01:00
Jonas Schievink
a2062d1892 Make RawAttrs crate-private
There should be no need to use this from outside
2020-12-19 02:44:22 +01:00
Jonas Schievink
81ccf37d3b Remove Attrs::merge
Only the `RawAttrs` version of this is in use
2020-12-19 02:43:00 +01:00
Jonas Schievink
0ac75f8982 Remove resolved FIXME 2020-12-19 02:32:31 +01:00
Jonas Schievink
aa00d1acd6 fixture -> ra_fixture 2020-12-19 01:12:41 +01:00
Jonas Schievink
d5edd0e928 Test paths to derive macros 2020-12-19 01:11:33 +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
bors[bot]
38b108c20e
Merge #6935
6935: Don't look at attributes when lowering to ItemTree r=jonas-schievink a=jonas-schievink

Resolves 2 `cfg_attr` FIXMEs

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-18 19:38:07 +00:00
Jonas Schievink
77972e2001 Don't look at attributes when lowering to ItemTree
Resolves 2 `cfg_attr` FIXMEs
2020-12-18 20:37:26 +01:00
Jonas Schievink
aab9cc9cfb Hit a mark 2020-12-18 20:25:41 +01:00
Jonas Schievink
382ee2fa03 Add test 2020-12-18 20:01:02 +01:00
Jonas Schievink
d42d1d33f0 Fix parsing of active cfg_attr 2020-12-18 20:00:59 +01:00
Jonas Schievink
08de1b4fa5 Implement RawAttr::filter 2020-12-18 18:58:42 +01:00
Jonas Schievink
4f07d8dd58 Refactor attributes API to allow handling cfg_attr 2020-12-18 02:24:14 +01:00
Lukas Wirth
fa65d6ba85 Higher-ranked trait bounds for where clauses 2020-12-17 22:01:42 +01:00
Jonas Schievink
9231821c03 Make Attrs::from_attrs_owner private 2020-12-17 15:45:26 +01:00
Jonas Schievink
eaeabbb815 Add AttrDefId::krate
Access to the containing crate will be needed to handle `cfg_attr`
2020-12-17 14:29:29 +01:00
Jonas Schievink
21b68a328c Remove module_lang_items
It isn't used anywhere except in `crate_lang_items`. Remove it to
slightly reduce memory usage and simplify the code.
2020-12-17 00:26:01 +01:00
Jonas Schievink
28b5334580 Avoid querying attributes in item tree lowering
ItemTree is per-file, so there is no unique crate associated with it.
This means that it cannot know the active CfgOptions and thus couldn't
handle `cfg_attr`.

Prepare it for `cfg_attr`s by avoiding accessing attributes.
2020-12-16 23:42:03 +01:00
bors[bot]
067067a6c1
Merge #6896
6896: Node-ify lifetimes r=jonas-schievink a=Veykril

Let's see if this passes the tests 🤞 

Depends on https://github.com/rust-analyzer/ungrammar/pull/15

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-16 17:08:03 +00:00
bors[bot]
63bbdb31e5
Merge #6897
6897: Basic support for macros 2.0 r=jonas-schievink a=jonas-schievink

This adds support for (built-in-only) macros 2.0, and removes some hacks used for builtin derives, which are declared via macros 2.0 in libcore.

First steps for https://github.com/rust-analyzer/rust-analyzer/issues/2248.

Blocked on https://github.com/rust-analyzer/ungrammar/pull/16.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-12-16 16:52:46 +00: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
bors[bot]
eb9ba457b0
Merge #6879
6879: Change HasChildSource::ChildId assoc item to generic param r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-15 17:22:03 +00:00
Lukas Wirth
2c67a4abe4 Change HasChildSource::ChildId assoc item to generic param 2020-12-15 18:21:01 +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
a68ff269a9 Expand statements for mbe in lowering 2020-12-15 14:39:15 +08:00
Lukas Wirth
c6172f3f6d Add LifetimeParam resolving to Semantics 2020-12-14 16:04:28 +01:00
Lukas Wirth
ae8a802085 Ignore lifetime params in substitutions 2020-12-13 11:34:44 +01:00
bors[bot]
479d1f7eec
Merge #6818
6818: Add Lifetimes to the HIR r=matklad a=Veykril

This doesn't handle resolve yet as I don't know yet how that will be used. I'll get to that once I start moving the lifetime reference PR to the hir.

This also adds a new `hir` name type for lifetimes and labels, `hir::LifetimeName`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 14:35:38 +00:00
Lukas Wirth
11f8664182 Add Lifetimes to the HIR 2020-12-12 00:56:52 +01:00
Lukas Wirth
8ed8e4f25a Use Attrs::docs in NavigationTarget instead of DocCommentsOwner 2020-12-11 21:19:58 +01:00
bors[bot]
91bf15a2f5
Merge #6834
6834: Use Attrs::docs in runnables instead of DocCommentsOwner r=kjeremy a=Veykril

I figured that we should probably move as much of the doc usage to the HIR as possible hence this PR. If we should keep this AST-based feel free to close.

This change does have the nice(but not really useful as I doubt anyones gonna write doc tests like these) side effect that these two doc string snippets allow being run now.
![image](https://user-images.githubusercontent.com/3757771/101945607-bf241400-3bee-11eb-96ce-ccae80028b1f.png)
![image](https://user-images.githubusercontent.com/3757771/101946375-2e9a0380-3bef-11eb-9950-e35168fdd048.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-11 19:57:08 +00:00
Lukas Wirth
ac19a71459 Use Attrs::docs in runnables instead of DocCommentsOwner 2020-12-11 20:11:03 +01:00
Jonas Schievink
00c34b048e Add upstream commit to builtin_attr.rs 2020-12-11 19:12:06 +01:00
Jonas Schievink
253678ead2 Add builtin attributes for use in nameres 2020-12-11 14:04:33 +01:00
Jonas Schievink
d338513e95 Remove item tree tests
They were useful during initial development of the item tree, but
now just cause churn
2020-12-10 15:53:48 +01:00
Jonas Schievink
d82292e1ce Ignore extern items in incorrect-case check 2020-12-10 15:45:01 +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
bors[bot]
ef989880ff
Merge #6771
6771: Properly attach inner attributes in Attrs::new r=matklad a=Veykril

Properly attach inner and outer attributes to the things they actually belong to in the HIR. ~~I can add some tests for this if wanted once I know where to put them/how to test for this.~~ Put some tests into `hover.rs`.
 
So the following snippet
```rust
mod foo {
	//! Hello
}
```
now shows `Hello` on hover 🎉

Fixes #2148


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 13:16:39 +00:00
bors[bot]
cd83ded8ee
Merge #6774
6774: Increment recursion count in Expander only on success r=lnicola a=Veykril

Fixes #6764

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 11:35:18 +00:00
Lukas Wirth
ec415618df Properly decrement recursion count in Expander 2020-12-09 12:26:33 +01:00
Lukas Wirth
f8823e8cbc Properly fetch inner and outer docs on hir-level 2020-12-09 09:22:41 +01:00
Lukas Wirth
eac77997bf Properly fetch inner and outer attributes on hir-level 2020-12-08 23:21:20 +01:00
Jonas Schievink
306c6cbaac Use original_file_range in TestDB 2020-12-08 19:03:24 +01:00
Jonas Schievink
6c1d292569 Add test for $crate in builtin macros
Fixes #6716
2020-12-08 17:17:30 +01:00
Jonas Schievink
678c74430b Handle macros in TestDB::check_diagnostics 2020-12-08 17:16:18 +01:00
Lukas Wirth
2facd9517f Escape string literals in Attr::from_src 2020-12-08 13:47:58 +01:00
Lukas Wirth
7a338e5207 Replace Arc<[str]> with String in attr::Documentation 2020-12-07 21:55:00 +01:00
Lukas Wirth
b064f6da9e Keep doc attribute order 2020-12-07 20:38:28 +01:00
Lukas Wirth
efe86a42dc Remove raw pre and suffixes from string attr literals 2020-12-07 19:58:17 +01:00
Lukas Wirth
1caaa201fa Remove hir_def/docs.rs module 2020-12-07 19:58:17 +01:00
Lukas Wirth
b3652ef288 Remove documentation query 2020-12-07 19:58:17 +01:00
Lukas Wirth
93262c750e Don't insert blank lines between doc attributes 2020-12-07 16:10:46 +01:00
Jonas Schievink
957fb18799 Make compile_error! message match upstream rustc
It only consists of the argument passed to it
2020-12-03 19:07:37 +01:00
Jonas Schievink
3e6ffa5124 Fix proc macro token mapping 2020-12-03 18:38:05 +01:00
Jonas Schievink
883c8d177d Make compile_error! lazy and emit a diagnostic 2020-12-03 15:48:29 +01:00
Jonas Schievink
4634bfb332 Give better diagnostic if OUT_DIR is unset 2020-12-03 15:48:29 +01:00
Jonas Schievink
17542d08b4 Update/Fix tests 2020-12-03 15:48:29 +01:00
Jonas Schievink
a634243634 Propagate eager expansion errors 2020-12-03 15:48:29 +01:00
Jonas Schievink
f4866bb05c Test macro diagnostics in body lowering 2020-12-02 15:03:21 +01:00
bors[bot]
3e1fb112af
Merge #6698
6698: Attach macro expansion errors to the right file r=jonas-schievink a=jonas-schievink

Previously it attached them to the result of the macro expansion (or, if no result was produced, to the file containing the invocation). Always use the file containing the invocation.

This doesn't seem to have any observable difference, but seems better in theory.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-02 13:25:54 +00:00
Jonas Schievink
319fcd01ac Attach macro expansion errors to the right file 2020-12-02 14:23:51 +01:00
bors[bot]
14086e3118
Merge #6697
6697: Don't discard PathKind::Abs information in lower_use::convert_path r=matklad a=Veykril

Fixes #6694

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-02 12:16:19 +00:00
Lukas Wirth
7b456552b8 Don't discard PathKind::Abs information in lower_use::convert_path 2020-12-02 09:54:03 +01:00
Jonas Schievink
ea7b81fef9 Emit unresolved proc macro errors 2020-12-01 12:40:03 +01:00
Jonas Schievink
be50908a50 Emit macro diagnostics when lowering bodies 2020-11-30 20:26:35 +01:00
Jonas Schievink
d171838d63 More accurately place proc-macro diagnostic 2020-11-27 16:29:40 +01:00
Jonas Schievink
0432aa0ed7 Publish diagnostics for macro expansion errors 2020-11-27 13:50:22 +01:00
Jonas Schievink
519d870c11 Don't store SyntaxNodePtr in CrateDefMap
It is volatile across reparses and makes incrementality worse.
2020-11-26 17:29:09 +01:00
Jonas Schievink
74cb3e96a5 Test def map invalidation with #[cfg] below change 2020-11-26 17:28:00 +01:00
Kirill Bulatov
4baac238a8 Improve autoimports on completion speed
* Ignore modules eaferly
* Do less completion string rendering
2020-11-24 02:28:45 +02:00
Aleksey Kladov
5db789df9c Cleanup API 2020-11-06 22:52:42 +01:00
Aleksey Kladov
2b108133ac Don't stack overflow on circular modules
closes #6453
2020-11-04 15:31:35 +01:00
bors[bot]
8ad01d863b
Merge #6435
6435: Test Fixture ExplicitRoot + ModuleResolutionRelativePathOutsideRoot. r=matklad a=rickvanprim

Updates `module_resolution_relative_path_outside_root` test to check valid paths outside of the root, by moving the root to a subpath so that paths outside of it are possible.  If this would be more appropriate as a new test, or if the original check for an invalid path should be left, I'm happy to update.

Co-authored-by: James Leitch <rickvanprim@gmail.com>
2020-11-03 16:36:34 +00:00