Commit Graph

343 Commits

Author SHA1 Message Date
Lukas Wirth
2e124d15fb fix: Fix expand_macro always expanding the first listed derive 2022-02-22 12:32:27 +01:00
Lukas Wirth
8db88df758 simplify and document 2022-02-22 10:45:29 +01:00
Lukas Wirth
94e59c9c56 Simplify 2022-02-22 10:20:45 +01:00
Lukas Wirth
f13c98034b Make replace_derive_with_manual_impl work again 2022-02-22 10:20:44 +01:00
Lukas Wirth
be3168dabe Fix expand_macro not working for derive attributes 2022-02-22 10:20:44 +01:00
Lukas Wirth
7b89d5ede2 internal: Expand the derive attribute into a pseudo expansion 2022-02-22 10:20:40 +01:00
Lukas Wirth
1505b6a9b4 internal: Split unresolve proc-macro error out of mbe 2022-02-22 10:08:00 +01:00
Chayim Refael Friedman
13ac5c3491 Fix various IDE features
As a side benefit, we got `let` guard support for `move_guard` for free.
2022-02-21 08:34:35 +02:00
Lukas Wirth
035bedc28b internal: Remove name fields from MacroCallKind 2022-02-21 00:02:10 +01:00
Lukas Wirth
fbe787ee10 internal: Wrap MacroCallKind::Attr attr_args field in an Arc 2022-02-20 22:53:04 +01:00
bors[bot]
7a17fb9c43
Merge #11444
11444: feat: Fix up syntax errors in attribute macro inputs to make completion work more often r=flodiebold a=flodiebold

This implements the "fix up syntax nodes" workaround mentioned in #11014. It isn't much more than a proof of concept; I have only implemented a few cases, but it already helps quite a bit.

Some notes:
 - I'm not super happy about how much the fixup procedure needs to interact with the syntax node -> token tree conversion code (e.g. needing to share the token map). This could maybe be simplified with some refactoring of that code.
 - It would maybe be nice to have the fixup procedure reuse or share information with the parser, though I'm not really sure how much that would actually help.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-12 12:48:46 +00:00
Lukas Wirth
1c77f36311 internal: Make ascend_call_token iterative instead of recursive 2022-02-11 22:21:35 +01:00
Florian Diebold
ccb789b94a Format again 2022-02-09 17:52:15 +01:00
Florian Diebold
577f70cc9c Reduce visibility 2022-02-09 17:43:37 +01:00
Florian Diebold
dfd2cef0d0 Add back an assertion 2022-02-09 16:36:45 +01:00
Florian Diebold
63fd643d72 Various fixes 2022-02-09 16:30:10 +01:00
Florian Diebold
bdb7ae5dd0 Rename syntax_node_to_token_tree_censored 2022-02-09 13:45:31 +01:00
Florian Diebold
ecf3cff4a6 Replace expressions with errors in them 2022-02-09 11:58:52 +01:00
Florian Diebold
1a5aa84e9f Track synthetic tokens, to be able to remove them again later 2022-02-08 18:13:18 +01:00
Florian Diebold
1b5cd03a37 Actually check in fixup.rs 2022-02-07 20:30:28 +01:00
Florian Diebold
c3601e9860 Reverse fixups 2022-02-07 19:53:39 +01:00
Florian Diebold
cff209f152 WIP: Actually fix up syntax errors in attribute macro input 2022-02-07 18:12:51 +01:00
Lukas Wirth
ec677e35d0 Simplify 2022-02-04 02:50:33 +01:00
Lukas Wirth
2ad71f1350 Shrink mbe::ExpandError and mbe::ParseError 2022-02-03 17:25:24 +01:00
Lukas Wirth
45ff51ba22 Make more precise range macro upmapping 2022-01-31 15:53:44 +01:00
Lukas Wirth
5fd3688018 Fix token ascension single token check being inverted 2022-01-31 13:26:09 +01:00
Lukas Wirth
cc04cfc982 Reduce allocations in attribute collection 2022-01-30 22:18:32 +01:00
Maybe Waffle
6d18c5b69d feat: Honor recursion limit configuration
This patch makes RA understand `#![recursion_limit = "N"]` annotations.

- `crate_limits` query is moved to `DefDatabase`
- `DefMap` now has `recursion_limit: Option<u32>` field
2022-01-28 11:31:59 +03:00
Jonas Schievink
6c0fcb5b5d More correct $crate handling in eager macros 2022-01-27 16:57:53 +01:00
Jonas Schievink
35e5c3b3f9 Fix resolution of eager macro contents 2022-01-26 18:31:07 +01:00
Jonas Schievink
5088926ec3 Make syntax bridge fully infallible 2022-01-24 17:27:39 +01:00
Laurențiu Nicola
09fb755432 Bump hashbrown 2022-01-21 19:44:03 +02:00
Jonas Schievink
e5ed43b1dc Remove redundant Option from eager macro fns 2022-01-21 12:58:06 +01:00
Lukas Wirth
f1cb5ed9b0 fix: Properly cache files in Semantics when ascending macros 2022-01-14 11:07:53 +01:00
bors[bot]
5a711d4f3a
Merge #11210
11210: feat: Deprioritize ops methods in completion r=Veykril a=Veykril

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



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-11 09:39:12 +00:00
Lukas Wirth
ca0633c808 feat: Deprioritize ops methods in completion 2022-01-11 09:26:53 +01:00
Jonas Schievink
3dd5e273b6 Shrink diagnostic spans for errors inside macros 2022-01-08 15:40:42 +01:00
bors[bot]
41a0e95d61
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4 fix: Fix attribute stripping ignoring doc comments 2022-01-07 18:51:10 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Lukas Wirth
ca4baa6e55 Use FileAstId<ast::Adt> in nameres where appropriate instead 2022-01-07 14:20:27 +01:00
Benjamin Coenen
336c899a07 add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
Aleksey Kladov
174c439c56 minor: drop dead code 2022-01-02 19:03:38 +03:00
Ariel Davis
d4262f4af8 Migrate to SyntaxNodePtr in new rowan 2021-12-29 23:48:53 -08:00
Aleksey Kladov
afffa096f6 add TopEntryPoint 2021-12-28 17:00:55 +03:00
Lukas Wirth
8e084132f8 internal: Do less work in hir::Semantics 2021-12-21 13:38:58 +01:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05: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]
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