Commit Graph

1603 Commits

Author SHA1 Message Date
Jake Heinz
bcc99091f3 hacky fix for cancelling 2022-01-14 10:30:51 +00:00
Jake Heinz
6c5504a617 one last bit of cleanup 2022-01-14 10:10:47 +00:00
Jake Heinz
c3f30ae4f0 removed scoped threads, cleanup 2022-01-14 10:06:28 +00:00
Jake Heinz
f83c0166be cleanup + detect num cpus 2022-01-14 09:48:59 +00:00
Jake Heinz
0b0bfc6fdd cleanup 2022-01-14 09:36:03 +00:00
Jake Heinz
c8aa2f6a61 use index map 2022-01-14 09:35:41 +00:00
Jake Heinz
5f0c1aa2de make progress callback dyn 2022-01-14 09:33:40 +00:00
Jake Heinz
2b0d8a86a2 fix warnings 2022-01-14 09:25:45 +00:00
Jake Heinz
343b0ccfb9 simplify 2022-01-14 09:21:25 +00:00
Jake Heinz
3168148cc6 ide: parallel prime caches 2022-01-14 09:16:35 +00:00
Jonas Schievink
09219e10f1 Mostly restore hir API boundary 2022-01-12 19:56:47 +01:00
Lukas Wirth
b32f611b6e fix: Fix outline modules spilling inner doc injections into their parent 2022-01-08 14:54:31 +01:00
Lukas Wirth
6746ba5839 Record attribute calls on assoc items in TraitData and ImplData 2022-01-08 10:45:12 +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
Laurențiu Nicola
e14d9208f5 Move pretty-printing test out of assist 2022-01-06 16:38:25 +02:00
Lukas Wirth
dc135cc076 internal: Support registered tools and attributes in ide layer 2022-01-06 14:56:50 +01:00
Jonas Platte
c90c88b083
Always put a space after impl in macro pretty-printing
… regardless of whether the next symbol is punctuation or not.
2022-01-06 11:33:08 +01:00
bors[bot]
ac3ea3e81c
Merge #11112
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi

cc #8655 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-04 21:51:37 +00:00
hkalbasi
75c2acae6e Evaluate constants in array repeat expression 2022-01-05 01:17:01 +03:30
Lukas Wirth
c5a9985fc5 Remove lossy Definition::from_token/Definition::from_node methods 2022-01-04 18:29:53 +01:00
bors[bot]
68bc12c3b8
Merge #11157
11157: internal: Remove `SemanticScope::speculative_resolve_as_mac` r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-04 16:49:47 +00:00
Lukas Wirth
19f1ff5c70 give resolve_derive_ident a more robust api 2022-01-03 16:00:45 +01:00
bors[bot]
8e9ccbf97a
Merge #11177
11177: internal: dont descend into comments r=Veykril a=jhgg

fixes #11176

Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-01-03 02:03:03 +00:00
Jake Heinz
04decd5e6b internal: dont descend into comments 2022-01-03 01:53:58 +00:00
bors[bot]
abbc7e3a0e
Merge #11088
11088: closes #10446 hide type inlay hints r=Veykril a=Heinenen

Passes tests as described in #10446
Works for all happy cases, there may be some cases that I forgot as I am not that familiar with Rust and r-a (yet).

Co-authored-by: Heinenen <th.m.heinen@gmail.com>
2022-01-03 00:51:08 +00:00
Lukas Wirth
087122ad1a fix: Fix highlighting hack for self-params 2022-01-03 01:32:03 +01:00
Lukas Wirth
6b7b09d329 internal: Record unresolved derive invocations in hir 2022-01-02 23:44:23 +01:00
Lukas Wirth
762a3b3030 Fix tool module classification not working correctly 2022-01-02 23:14:18 +01:00
Lukas Wirth
19d894cdec minor: Cleanup syntax highlighting 2022-01-02 22:23:05 +01:00
Lukas Wirth
22160c418b fix NameRefClass misclassifying proc-macros 2022-01-02 19:20:10 +01:00
Lukas Wirth
9eed85b171 fix syntactic highlighting for macros 2022-01-02 19:10:23 +01:00
Lukas Wirth
3a525c831f internal: Handle macro calls better in highlighting 2022-01-02 19:10:10 +01:00
Aleksey Kladov
d846afdeef check top level entry point invariants 2022-01-02 18:41:32 +03:00
Benjamin Coenen
df6fa50f92 feat(diagnostics): add new config to fill default expression
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-12-31 16:29:08 +01:00
hkalbasi
e6139cf47b show values of constants in hover 2021-12-23 17:53:46 +03:30
Heinenen
05abfc77f5 hide type inlay hints 2021-12-23 12:56:38 +01:00
Heinenen
d7dfe93fc3 hide type inlay hints for enum variant constructors and tuple struct constructors 2021-12-23 12:56:38 +01:00
Lukas Wirth
85ed5a3182 Make hover test not relient on minicore structure 2021-12-22 02:36:31 +01:00
Lukas Wirth
40d5c58a80 Fully render const item completions from hir 2021-12-21 16:35:51 +01:00
bors[bot]
d3aa2579cc
Merge #11069
11069: fix: Partially fix `ide_db::search` for crate roots r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10007
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-20 16:50:35 +00:00
Lukas Wirth
5206946674 fix: Partially fix ide_db::search for crate roots 2021-12-20 17:48:47 +01:00
bors[bot]
f46731a230
Merge #11028
11028: Bump MSRV (1.57) r=Veykril a=iDawer

This bumps MSRV on all crates to 1.57 except `la-arena`

#10986 requires >=1.57 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
rainy-me
67cc6c1e16 feat: treat fn keyword inside function pointer type as primitive 2021-12-19 01:51:51 +09:00
Laurențiu Nicola
8ad7c0439c Remove needless clones 2021-12-17 17:35:10 +02:00
Lukas Wirth
d3e538638a fix: Don't duplicate attribute completions 2021-12-17 15:22:53 +01:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
Lukas Wirth
04a7fbbddb Move out doc-links tests into a separate module 2021-12-14 12:10:43 +01:00
zhoufan
c3ad945d9b fixes broken tests 2021-12-14 15:57:58 +08:00
bors[bot]
3f550d2e38
Merge #11000
11000: fix: insert whitespaces into assoc items for assist when macro generated r=Veykril a=Veykril

This is obviously only a temporary hack which still produces ugly looking items, but as long as the syntax is valid one can at least have rustfmt fix the formatting again. 
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6588
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-13 15:43:12 +00:00
Lukas Wirth
749eeef3e7 fix: insert whitespaces into assoc items for assist when macro generated 2021-12-13 16:35:32 +01:00
Lukas Wirth
328419534d Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01:00
bors[bot]
4f04d8477a
Merge #10965
10965: minor: Remove dead assists-related function r=Veykril a=lnicola

Unless I'm missing something, `assists_with_fixes` seems to be always used and ends up in the same code path.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-11 15:06:52 +00:00
bors[bot]
d03397fe11
Merge #10978
10978: internal: Only prime direct dependencies of the workspace crates r=jonas-schievink a=lnicola

This reduces the number of primed crates on `self` from 177 to 105.

```text
# baseline
  86521 me   20   0 2939M  562M 14320 S  0.0  0.9  0:07.10   37 rust-analyzer

# pr
  99947 me   20   0 2935M  549M 14424 S  0.0  0.9  0:07.10   37 rust-analyzer
```

The RAM usage seems to vary a lot, so I'm not sure the improvement shown above is real.

We also drop the topological sorting, although it might still make sense to do the dependencies before the workspace crates. But since it's only used to make the progress reporting a bit more fine, it probably doesn't matter too much.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-10 22:31:55 +00:00
Lukas Wirth
c81aa68afe Don't show trait flyimports for impl trait and placeholders 2021-12-10 19:18:21 +01:00
Laurențiu Nicola
d012a20f25 Only prime direct dependencies of the workspace crates 2021-12-10 16:24:07 +02:00
Laurențiu Nicola
f5968cfc84 Remove dead assists-related function 2021-12-08 16:55:25 +02:00
bors[bot]
b7afb6fc6c
Merge #10958
10958: internal: add "Shuffle Crate Graph" command r=jonas-schievink a=jonas-schievink

May be useful for debugging issues like https://github.com/rust-analyzer/rust-analyzer/issues/10084

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2021-12-07 15:44:05 +00:00
Jonas Schievink
deb5c1426d internal: add "Shuffle Crate Graph" command 2021-12-07 16:37:19 +01:00
Lukas Wirth
f781e599cc Adjust incorrect runnable tests 2021-12-07 15:42:54 +01:00
Lukas Wirth
e09d410dcd Simplify 2021-12-07 15:06:56 +01:00
Lukas Wirth
b66f181bc0 Fix some TryToNav impls not upmapping ranges out of macros 2021-12-07 15:02:22 +01:00
Lukas Wirth
9b4ca77572 fix: Add highlighting hack back for unresolved attributes 2021-12-05 11:59:07 +01:00
bors[bot]
6434ada19e
Merge #10930
10930: fix: Fix self keyword not being tagged as such in highlighting properly r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10575
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-04 18:08:11 +00:00
Lukas Wirth
b35a50cb10 fix: Fix self keyword not being tagged as such in highlighting properly 2021-12-04 19:07:18 +01:00
bors[bot]
372a7cf981
Merge #10929
10929: internal: Split up macro/attribute semantic tokens a bit more r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-04 17:33:16 +00:00
Lukas Wirth
3472105ad9 Update semantic token docs 2021-12-04 18:23:25 +01:00
Lukas Wirth
e4f2d0e3a8 Introduce SymbolKind::Derive 2021-12-04 18:18:09 +01:00
Lukas Wirth
642c1eb720 Introduce SymbolKind::Attribute 2021-12-04 18:01:22 +01:00
Laurențiu Nicola
b7368d34a6 Bump pulldown-cmark-to-cmark 2021-12-04 15:21:04 +02:00
bors[bot]
3f3289df2a
Merge #10915
10915: feat: Resolve builtin-attr and tools in ide layer r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-03 19:28:36 +00:00
Lukas Wirth
8da850b6d5 Improve hover message for inert attributes 2021-12-03 20:28:15 +01:00
Lukas Wirth
d174158abc Rename things: Tool -> ToolModule 2021-12-03 17:15:19 +01:00
Lukas Wirth
70b8331fd5 Basic hover for builtin-attr and tool modules 2021-12-03 17:10:56 +01:00
Lukas Wirth
db559e5049 Simplify 2021-12-03 17:07:06 +01:00
Lukas Wirth
d1677f3286 Remove syntax highlighting hack for builtin attrs 2021-12-03 16:54:34 +01:00
Lukas Wirth
e58af219a4 feat: Resolve builtin-attr and tools in ide layer 2021-12-03 16:32:17 +01:00
bors[bot]
b68cd6eda2
Merge #10891
10891: fix: emit trait names in moniker identifier r=Veykril a=tjdevries

Hi,

Not sure if this is the best fix for the problem, but I noticed that functions that part of a trait are not namespaced with the trait name, so this could lead to problems if you had a function and a trait-function both defined in the same module.

Thanks!

TJ

Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
2021-12-02 11:21:59 +00:00
TJ DeVries
6870bfd099 fixup: include more information for impls 2021-12-02 00:04:03 -05:00
TJ DeVries
d50f18fb65 fixup: properly handle all associated items 2021-12-01 11:43:52 -05:00
Jake Heinz
30b0464ed8 add a fixme: 2021-12-01 12:26:27 +00:00
Jake Heinz
ba92bb1ed9 simplify 2021-12-01 12:25:08 +00:00
Jake Heinz
d2480ecb9f ide: hack to make self not unresolved reference in async trait wrapped impl's 2021-12-01 12:17:20 +00:00
Jake Heinz
b357569d0f add test 2021-12-01 10:28:18 +00:00
TJ DeVries
09c7e22ec2 fix: emit trait names in moniker identifier 2021-11-30 11:16:11 -05:00
bors[bot]
2d0db312b5
Merge #10872
10872: ide_db: build symbol index from crate def map r=Veykril a=jhgg

fixes #4842, #10764

Is this looking correct? 👀 

- [x] build the symbol index based upon the CrateDefMap for the given crate in `crate_symbols`
   - [x] make it multi threaded again, and figure out how to cache each moduleid's symbol index in salsa.
   - [x] NavigationTarget for names in macros is wrong, need to figure out how to compute a text range in the original file id?
   - [x] cleanup some duped code
   - [x] collect macros from `ItemScope.declared_macros()` into symbol index.
        - [x] store declared macros in `ItemScope` so we can figure out where macros were defined for the index.  
   - [x] do something about `SymbolIndex::for_files` - ideally it should use the new module symbol index stuff. 
       - [x] delete `source_file_to_file_symbols` & co...
           - [x] figure out what to do about `library_symbols` 
           - [x] maybe... speed up the new `library_symbols` - the new impl is probably much slower, and definitely much less parallel. **deciding to do nothing here, we can optimize later if necerssary.** 
   - [x] fix failing test: `navigation_target::tests::test_nav_for_symbol` - notably the crate def map doesn't seem to find declarations inside function. 
       - [x] now a bunch of other tests are failing around auto_import & qualify_path handlers. :(
           - [x] need to assoc items in traits and impls
 

Co-authored-by: Jake Heinz <jh@discordapp.com>
2021-11-30 14:07:39 +00:00
Jake Heinz
b0c7ff39b8 remove one need for semantics 2021-11-30 04:50:09 +00:00
bors[bot]
393cbd0982
Merge #10841
10841: Emit moniker in lsif r=Veykril a=HKalbasi

fix #10559 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
Co-authored-by: HKalbasi <45197576+HKalbasi@users.noreply.github.com>
2021-11-29 11:13:39 +00:00
Jake Heinz
1280887561 do something with library_symbols 2021-11-29 09:36:00 +00:00
hkalbasi
df261c10b9 remove duplicate data from CrateOrigin 2021-11-29 11:10:39 +03:30
Jake Heinz
8307d38dc1 cleanups 2021-11-28 00:42:42 +00:00
Lukas Wirth
76022bfd60 fix: Show parameter hints unconditionally for logical not expressions 2021-11-27 19:14:36 +01:00
Jake Heinz
e033d8c2a2 make navigation target go to original file location 2021-11-27 13:48:50 +00:00
Jake Heinz
a1030b07ab use Semantics::parse_or_expand in another place 2021-11-27 11:55:03 +00:00
Jake Heinz
0447be7589 wip 2021-11-27 11:25:05 +00:00
Jake Heinz
dca8f612d0 ide: fix expansion for 'as _' 2021-11-27 02:22:21 +00:00
Lukas Wirth
4bf75c5d6e fix: Prioritize tuple fields in highlight_related 2021-11-25 16:34:40 +01:00
Lukas Wirth
f3b25a6fc8 Disable string highlight injection for macros changing string literals 2021-11-23 22:13:10 +01:00
hkalbasi
30ed7fac27 Emit moniker in lsif 2021-11-22 21:29:05 +03:30
Lukas Wirth
ec07bb98f8 fix: Omit generic defaults for types in hover messages 2021-11-22 18:27:03 +01:00
Lukas Wirth
64cb09ddea Add to macro testing infra to emit token map ids 2021-11-22 16:51:09 +01:00
Lukas Wirth
77f08d0fc3 Split parts of ide_db::call_info off into ide 2021-11-22 13:23:34 +01:00
Lukas Wirth
54b2de45e1 Unnest ide::display::navigation_target module 2021-11-22 13:04:28 +01:00
Jake Heinz
7cbc6ae920 ide: hover omits unnamed where preds 2021-11-20 11:45:12 +00:00
bors[bot]
a60e009b48
Merge #10806
10806: fix: inlay param hint hiding heurstic is case unsensitive r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-19 11:46:49 +00:00
Lukas Wirth
cd290b427c fix: inlay param hint hiding heurstic is case unsensitive 2021-11-19 12:46:17 +01:00
Jake Heinz
c28dc00b39 ide: dedupe or merge hover actions 2021-11-19 05:36:07 +00:00
bors[bot]
cfa26c3ac3
Merge #10798
10798: ide: show go to for function hover return type r=Veykril a=jhgg

I've found myself wanting this...  adds to the hover quick go-to for a function's return type:

![image](https://user-images.githubusercontent.com/5489149/142375722-4a385216-494b-45a4-be1c-59664213b8d6.png)

This is particularly useful when you are hovering over a function in a long chain, like:

```rust
foo.bar().b$0az().some_trait_fn();
```

where `baz`'s return type is not immediately obvious, but the chain is not long enough to trigger chain inlay hints... 

i guess I could just select `foo.bar().baz()` too to get the types too... 

Co-authored-by: Jake Heinz <jh@discordapp.com>
2021-11-18 09:56:44 +00:00
Jake Heinz
876f44b3ea ide: show go to for function hover return type 2021-11-18 08:00:22 +00:00
Jake Heinz
e8d0989606 ide: display static values in hover 2021-11-18 06:00:51 +00:00
bors[bot]
64a73dcfba
Merge #10785
10785: ide: show const value in hover r=jhgg a=jhgg

fixes #10783

I think my original attempt was incorrect, because it looks like `HirDisplay` is used in more places than just the hover.  

So, I've attempted it again in 312eafe, this time specifically just rendering the value in `hover::render`

pictoral:

![image](https://user-images.githubusercontent.com/5489149/142163890-b6aa2ab4-7bd0-4dd3-b35d-5eaa83fffb7f.png)


Co-authored-by: Jake Heinz <jh@discordapp.com>
Co-authored-by: Jake <jh@discordapp.com>
2021-11-18 04:17:16 +00:00
Jake Heinz
aef8882254 more complicated const test 2021-11-18 04:15:02 +00:00
Lukas Wirth
91bbc55eed Check for derive attributes by item path, not derive identifier 2021-11-17 20:46:57 +01:00
Jake Heinz
312eafe916 maybe this is better?? 2021-11-17 07:02:49 +00:00
Jake Heinz
4fbc4b9356 hir: show const value in hover 2021-11-17 05:49:27 +00:00
Lukas Wirth
366499c3be Do not use reference search in runnables::related_tests 2021-11-16 21:32:02 +01:00
Lukas Wirth
0ff380fe17 Simplify 2021-11-16 21:26:34 +01:00
Lukas Wirth
b57289c4cb Skip test/bench attr expansion in resolution instead of collection 2021-11-16 20:23:56 +01:00
Lukas Wirth
92f7db447c minor: Lift out FxIndex{Map/Set} types into ide_db 2021-11-16 12:15:47 +01:00
Lukas Wirth
d2513deb62 fix: Reimplement mapping out of test/bench attributes for runnables 2021-11-16 11:51:24 +01:00
Jake Heinz
520ff62f4e flip the default 2021-11-13 23:39:34 +00:00
Jake Heinz
d3d768de0d inlay hints: add the option to always show constructor inlay hints 2021-11-13 23:12:29 +00:00
Lukas Wirth
2d7f5891f7 Remove faulty logic for ascending test attributes for runnables 2021-11-11 18:47:24 +01:00
Lukas Wirth
a510021065 Replace some more ide usages of ModuleDef with Definition 2021-11-11 18:20:54 +01:00
Jonas Schievink
acbe8bc7ac Prime a more reasonable set of crates 2021-11-11 14:44:12 +01:00
Lukas Wirth
7776aad166 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
Lukas Wirth
26419c0379 Fix proc-macro attributes being shadowed by their functions in IDE layer 2021-11-08 14:49:50 +01:00
bors[bot]
10782bbb39
Merge #10685
10685: fix: Enable markdown tables r=Veykril a=Veykril

Should fix https://github.com/rust-analyzer/rust-analyzer/issues/10655
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 11:25:17 +00:00
Lukas Wirth
439a8194b0 Replace more Name::to_string usages with Name::to_smol_str 2021-11-04 18:12:05 +01:00
Lukas Wirth
4d4574f5b6 Enable markdown tables 2021-11-04 17:36:58 +01:00
bors[bot]
962be38004
Merge #10645
10645: fix: make `rename` multi-token mapping aware r=Veykril a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Anatol Ulrich <45840+spookyvision@users.noreply.github.com>
2021-11-04 16:31:16 +00:00
bors[bot]
c96481e25f
Merge #10691
10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-11-04 05:52:05 +00:00
Laurențiu Nicola
139bf9b4e1 Use array into_iter in more places 2021-11-04 07:51:20 +02:00
Anatol Ulrich
83927e08a8
Update crates/ide/src/rename.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 15:44:32 +01:00
Lukas Wirth
52f5af7165 Expose version string of crates fom HIR 2021-11-03 15:40:06 +01:00
Anatol Ulrich
9bce4d6696 accept identical Indels when merging; add rename test case 2021-11-02 21:38:38 +01:00
Lukas Wirth
7fdbdc4ab2 Enable auto-import and qualify-path in derive attributes 2021-10-28 18:40:38 +02:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02:00
Anatol Ulrich
1ac35532c4 remove TODO comment 2021-10-27 17:26:38 +02:00
Anatol Ulrich
df9fb9b159 re-introduce always! 2021-10-27 17:25:42 +02:00
Anatol Ulrich
28c73f8374 unwrap-- 2021-10-27 17:23:23 +02:00
Anatol Ulrich
4a1a5ff54e fix logic error: alias detection was too lenient 2021-10-27 17:20:12 +02:00
Anatol Ulrich
6cd15c296d wip 2021-10-27 15:40:49 +02:00
Anatol Ulrich
8d3ac328ee remove resolved TODO questions 2021-10-27 15:40:30 +02:00
Anatol Ulrich
f244ed6a1a doxx 2021-10-27 04:46:02 +02:00
Anatol Ulrich
2e0610e64e one down 2021-10-27 04:42:58 +02:00
Anatol Ulrich
95199ac30b make imports less odd 2021-10-27 04:36:32 +02:00
Anatol Ulrich
6decfceae1 WIP: fix: make rename multi-token mapping aware 2021-10-27 04:31:14 +02:00
bors[bot]
a3830dfd3b
Merge #10641
10641: fix: make `expand_macro` multi-token mapping aware r=spookyvision a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
Co-authored-by: Anatol Ulrich <45840+spookyvision@users.noreply.github.com>
2021-10-26 18:18:22 +00:00
Anatol Ulrich
b42093915a
Update crates/ide/src/expand_macro.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-26 20:17:47 +02:00
Anatol Ulrich
e6913be47b fix test 2021-10-26 20:15:25 +02:00
Anatol Ulrich
04f2eb0fba wording 2021-10-26 20:10:09 +02:00
Anatol Ulrich
3f82989153 fix: make expand_macro multi-token mapping aware 2021-10-26 20:09:14 +02:00
bors[bot]
c48730cb72
Merge #10639 #10640
10639: fix: make `goto_declaration` multi-token mapping aware r=Veykril a=spookyvision



10640: assume valid identifier r=Veykril a=spookyvision

improve https://github.com/rust-analyzer/rust-analyzer/pull/10637/ by always returning `Some(potentially_empty_vec)` instead of `None` in the empty case

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-10-26 17:51:33 +00:00
Anatol Ulrich
53be26df50 assume valid identifier 2021-10-26 19:33:50 +02:00
Anatol Ulrich
d8ed15b6a6 fix: make goto_declaration multi-token mapping aware 2021-10-26 19:31:49 +02:00
Anatol Ulrich
c69879423e fix imports 2021-10-26 12:34:40 +02:00
Anatol Ulrich
686f8fbea3 simplify 2021-10-26 12:21:18 +02:00
Anatol Ulrich
2490807ca5 fix: make goto_type_definition multi-token mapping aware 2021-10-25 23:43:58 +02:00
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00
bors[bot]
6877240fdf
Merge #10563
10563: feat: Make "Generate getter" assist use semantic info r=agluszak a=agluszak

This PR makes "Generate getter" assist use semantic info instead of dealing with types encoded as strings.
Getters for types which are:
- `Copy` no longer return references
- `AsRef<str>` (i.e. `String`) return `&str` (instead of `&String`)
- `AsRef<[T]>` (i.e. `Vec<T>`) return `&[T]` (instead of `&Vec<T>`)
- `AsRef<T>` (i.e. `Box<T>`) return `&T` (instead of `&Box<T>`)
- `Option<T>` return `Option<&T>` (instead of `&Option<T>`)
- `Result<T, E>` return `Result<&T, &E>` (instead of `&Result<T, E>`)

String, Vec, Box and Option were previously handled as special cases.

Closes #10295


Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2021-10-20 21:02:46 +00:00
Lukas Wirth
8ed86fc25d Fix standard library doclinks not going to the correct page 2021-10-20 16:36:01 +02:00
Andrzej Głuszak
98676efdc5 Semantic getter 2021-10-17 16:33:14 +02:00
Milo
5a93457c1b revert 2021-10-16 14:13:43 +01:00
Milo
35e5daacc3 more clippy fixes 2021-10-16 12:32:55 +01:00
Milo
35de195c41 a few clippy fixes 2021-10-14 19:57:21 +01:00
bors[bot]
8619058d3d
Merge #10538
10538: fix: matching brace should prefer brace on cursor's right r=Veykril a=codgician

I observed a brace matching issue with the following Rust code:

```rust
let x = (1 + (2 + 3)) * 4;
```

In a situation like `<|>(1 + (2 + 3)) * 4`, the cursor will go to `(1 + (2 + 3)<|>) * 4`, and if user tries to match bracket again it will go like  `(1 + <|>(2 + 3)) * 4` while logically the expected result should be `<|>(1 + (2 + 3)) * 4`. This behavior exists in both line cursor style and block cursor style.

This PR fixes this by letting `matching_brace` prefer the brace to cursor's right when the cursor lies between multiple consecutive braces. It **does NOT** fix #1942 but could be related. Please review.


Co-authored-by: codgician <15964984+codgician@users.noreply.github.com>
2021-10-14 11:50:14 +00:00
codgician
7e68db3670 Matching brace prefers brace on cursor's right 2021-10-14 14:15:56 +08:00
bors[bot]
f185d1c533
Merge #10423
10423: Internal: refactor for mdbook plugin r=Veykril a=HKalbasi

This PR is for upstreaming changes that I made for mdbook plugin. Changes are adding inlay hints to `StaticIndex` and changing some functions for working around privacy of crates.

Aside this, is it okay if I bring the plugin in tree? It is a simple binary crate. I feel it will better maintained here and become resistant to api changes.

Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-10-12 18:35:03 +00:00
Mirko Rainer
eccfa1645b Saw a FIXME comment and decided to fix it.
This renames `descend_into_macros` to  `descend_into_macros_single` and `descend_into_macros_many` into `descend_into_macros`.
 However, this does not touch a function in `SemanticsImpl` of same name.
2021-10-12 11:52:31 -04:00
hamidreza kalbasi
0f49c97e93 internal changes for mdbook 2021-10-12 11:54:00 +03:30
bors[bot]
64ca0f63bf
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa

## Why

Delete clones for efficiency

## What

- I erased unnecessary clones


Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:17:52 +00:00
k-nasa
b50cb5c261 Remove neesless clone 2021-10-10 10:50:51 +09:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
bors[bot]
fd3f4c50da
Merge #10467
10467: Optimize CodeLens for references/impls r=Veykril a=ericsampson

Don't do unnecessary work.
Followup to #10447 . cc `@Veykril` 

Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-06 21:47:22 +00:00
Eric Sampson
efca421c43 Refactor to eliminate a vector allocation. 2021-10-06 16:43:37 -05:00
bors[bot]
f30b62b751
Merge #10479
10479: fix: fix "index out of bounds" panic in name resolution r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10084
Closes https://github.com/rust-analyzer/rust-analyzer/issues/9163

This is really just a salsa update to a version that removes the problematic code (see https://github.com/rust-analyzer/rust-analyzer/issues/10084#issuecomment-934445711)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-06 20:54:27 +00:00
Jonas Schievink
cda9668289 Update salsa 2021-10-06 22:42:54 +02:00
Eric Sampson
0d77be67f7 Don't do work and then throw it away. 2021-10-06 01:16:31 -05:00
bors[bot]
5ff992465e
Merge #10447
10447: Add enum variant references CodeLens. r=Veykril a=ericsampson



Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-05 22:03:23 +00:00
Eric Sampson
6d05b07f7d Refactor according to PR comments to remove allocations. 2021-10-05 15:42:45 -05:00
bors[bot]
c409cf0e26
Merge #10458
10458: feat: Implement custom user snippets r=Veykril a=Veykril

![Y24dX7fOWX](https://user-images.githubusercontent.com/3757771/136059454-ceccfc2c-2c90-46da-8ad1-bac9c2e83ec1.gif)

Allows us to address the following issues:
    - `.arc / .rc / .pin, similar to .box?` https://github.com/rust-analyzer/rust-analyzer/issues/7033
    - `Add unsafe snippet` https://github.com/rust-analyzer/rust-analyzer/issues/10392, would allow users to have this without the diagnostic)
    - `.ok() postfix snippet is annoying` https://github.com/rust-analyzer/rust-analyzer/issues/9636, allows us to get rid of the `ok` postfix and similar ones
    - `Postfix vec completion` https://github.com/rust-analyzer/rust-analyzer/issues/7773

cc https://github.com/rust-analyzer/rust-analyzer/issues/772

Zulipd discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Custom.20Postfix.20snippets

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-05 16:41:11 +00:00
Lukas Wirth
77cbf4adbc Bring the implementation closer to VSCode snippet definitions 2021-10-05 17:18:40 +02:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
Eric Sampson
160a7b097a initialize vector to required size. 2021-10-04 16:14:01 -05:00
Lukas Wirth
454ecd167c Make multiple import edits work for completions 2021-10-04 21:44:33 +02:00
Lukas Wirth
046c85ef0c Add custom non-postfix snippets 2021-10-04 19:22:41 +02:00
Lukas Wirth
88f213eadd Initial implementation of custom postfix snippets 2021-10-04 17:49:21 +02:00
Eric Sampson
5df6259996 tweak variable names. 2021-10-04 02:42:13 -05:00
Eric Sampson
a0bb31587e Add enum variant references CodeLens. 2021-10-04 02:18:31 -05:00
bors[bot]
10eaa5a0af
Merge #10441
10441: feat: Hide type inlay hints for constructors r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/3022
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 13:35:47 +00:00
Lukas Wirth
a31bc668f5 Hide generic constructors if appropriate 2021-10-03 15:35:26 +02:00
Lukas Wirth
992b4648d9 feat: Hide type inlay hints for constructors 2021-10-03 14:53:18 +02:00
bors[bot]
ebe6c38a44
Merge #10438
10438: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 11:06:06 +00:00
Lukas Wirth
0943c4be8b minor: Simplify 2021-10-03 13:05:42 +02:00
Lukas Wirth
86e5406539 Fix rename trying to edit the same range multiple times 2021-10-02 18:50:21 +02:00
Aleksey Kladov
12103b16de internal: untangle usages of ReferenceCategory somewhat
Not everything that can be read or write is a reference, let's try to
use more precise types.
2021-10-02 13:02:06 +03:00
Aleksey Kladov
46eb03d99a internal: use naming that matches intended use-case 2021-10-02 12:18:18 +03:00
nathan.whitaker
a3661b3900 Add whitespace b/w lifetime and mut in expansion 2021-10-01 15:29:26 -04:00
Cassandra McCarthy
d5cf9f4add
docs: add note about vscode-vim in on_enter
I found myself search for this, so building off of #3013 and #3308, I
hope this note is useful.
2021-10-01 14:12:32 -04:00
bors[bot]
0646d5cf9e
Merge #10413
10413: fix: Fix format highlighting with `concat!` and `unreachable!` r=jonas-schievink a=jonas-schievink

Last item in https://github.com/rust-analyzer/rust-analyzer/issues/10394, closes https://github.com/rust-analyzer/rust-analyzer/issues/10394

Also documents why/how `is_format_string` even works, since I found that nontrivial.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-01 11:31:32 +00:00
Jonas Schievink
3bc0d89ade Fix format highlighting with concat! 2021-10-01 13:28:05 +02:00
bors[bot]
47c079a037
Merge #10403
10403: feat: Add semantic token modifier for crate root r=Veykril a=lhvy

Resolves #9073

I managed to implement crate root highlighting for crates mentioned specifically by name (e.g. `serde` in `use serde::Serialize;`), but not for crates referred to with `crate` or `super`. How could I implement this?

> P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks!

Co-authored-by: lhvy <me@lhvy.dev>
2021-10-01 11:18:52 +00:00
lhvy
dbb02370a4
Add semantic token modifier for crate root 2021-10-01 20:52:13 +10:00
Jonas Schievink
cca6ee5757 Expand asm! to format_args! 2021-10-01 12:33:18 +02:00
Lukas Wirth
c5ceaefa09 Restructure syntax element highlighting 2021-09-30 21:44:56 +02:00
Lukas Wirth
a33939565d Simplify 2021-09-30 19:12:37 +02:00
bors[bot]
529b7a4167
Merge #10398
10398: Give defaultLibrary semantic token modifier to items from standard library r=Veykril a=lhvy

Fixes #8999, fixes #2155

`builtInCrates` could be an alternate name to `defaultLibrary`, which one is better?

> P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks!

Co-authored-by: lhvy <me@lhvy.dev>
Co-authored-by: Lucas <me@lhvy.dev>
2021-09-30 16:10:23 +00:00
lhvy
0b2ba8be68
Fix builtin_crates return type change 2021-10-01 02:05:00 +10:00
lhvy
64cbdf6d55
Add comment 2021-10-01 01:58:11 +10:00
Jonas Schievink
4465685878 Work around tidy check 2021-09-30 17:32:18 +02:00
lhvy
2b3baa8503
Give defaultLibrary semantic token modifier to items from standard library 2021-10-01 01:19:24 +10:00
Jonas Schievink
b994469a13 Add const_format_args! builtin macro, fix highlighting 2021-09-30 17:16:39 +02:00
Jonas Schievink
b8437f71b6 Less hacky assert! expansion 2021-09-30 16:30:26 +02:00
Jonas Schievink
368c5f6023 Fix format string highlighting in panic! 2021-09-30 15:53:47 +02:00
bors[bot]
ee12b0f173
Merge #10181
10181: Begining of lsif r=HKalbasi a=HKalbasi

This PR adds a `lsif` command to cli, which can be used as `rust-analyzer lsif /path/to/project > dump.lsif`. It now generates a valid, but pretty useless lsif (only supports folding ranges). The propose of this PR is to discussing about the structure of lsif generator, before starting anything serious.

cc `@matklad` #8696 #3098


Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-29 13:13:03 +00:00
hamidreza kalbasi
5bd0f50111 remove glob import and cancellables 2021-09-29 16:25:10 +03:30
Lukas Wirth
b6ed91a6de Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
Aleksey Kladov
2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00
Lukas Wirth
151afdfe5c Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
hamidreza kalbasi
7377120fee add some tests 2021-09-26 12:48:53 +03:30
hamidreza kalbasi
48bebeaa32 support goto definition and find references 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
f2775ac2e9 reuse hover results with resultset 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
e803bd25c4 add hover 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
5163201847 use utf16 instead of utf8 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
557210a688 Begining of lsif 2021-09-26 10:04:02 +03:30
Lukas Wirth
e60f3d265f Split the hover module up 2021-09-23 20:36:15 +02:00
Lukas Wirth
22c6f0a8a5 Support goto_def for intra-doc-links in macro invocations 2021-09-23 19:17:29 +02:00
Lukas Wirth
d99adc5738 Make hover work for intra doc links in macro invocations 2021-09-23 17:32:39 +02:00
Lukas Wirth
42eb4efb5b Cleanup 2021-09-23 16:28:03 +02:00
bors[bot]
8a82e6c492
Merge #10284
10284: internal: definition based hover functions r=Veykril a=HKalbasi

This is part of #10181 but since it is blocked and `hover.rs` is moving quickly so will cause conflicts, I submitted this PR.

This PR extract some parts of `hover` to `find_definition` (maybe this need to be moved to some other file?) and `hover_for_definition`, with those functions I will be able to calculate definition of every token, and calculate hover (and probably other queries) for each definition only once.

Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-22 15:23:23 +00:00
hamidreza kalbasi
589c1dfa04 move function to defs.rs 2021-09-22 18:35:54 +03:30
hamidreza kalbasi
18e6b508dd remove dead code 2021-09-22 11:44:23 +03:30
hamidreza kalbasi
569ac5bee1 use find_definition in go to 2021-09-22 11:37:26 +03:30
hamidreza kalbasi
887b7ddc37 fix derive hover in macro 2021-09-21 19:55:57 +04:30
Lukas Wirth
ba84b91e78 Add a mirror function-like proc-macro expander for tests 2021-09-21 14:55:54 +02:00
hamidreza kalbasi
0777698f29 internal: definition based hover functions 2021-09-19 16:15:44 +04:30
Lukas Wirth
6465868449 Make inlay hints work in attributed items 2021-09-18 13:19:29 +02:00
Lukas Wirth
11a17c803f Add multi-token mapping test for goto_definition 2021-09-18 12:00:12 +02:00
zhoufan
227450f9b9 do comment handling on the original token 2021-09-18 08:22:57 +08:00
zhoufan
ea3535cefc fix: multi-token mapping aware goto definition 2021-09-16 09:44:22 +08:00
bors[bot]
959c7ef563
Merge #10250
10250: internal: Improve call_hierarchy and incoming/outgoing_calls r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-16 00:26:32 +00:00
Lukas Wirth
d777eddf0d Improve call_hierarchy and incoming/outgoing_calls 2021-09-16 02:25:02 +02:00
bors[bot]
4c9eef7ede
Merge #10233
10233: fix: add multi-token mapping support to hovers r=Veykril a=spookyvision

implement #10070 in [`hover`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/hover.rs)

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-09-15 16:36:33 +00:00
Anatol Ulrich
45090e4f4b add multi-token mappings for hover 2021-09-15 18:05:53 +02:00
Anatol Ulrich
b251a30819 # This is a combination of 3 commits.
# This is the 1st commit message:

add multi-token mappings for hover

# The commit message #2 will be skipped:

# make fallback an Option instead of vec

# The commit message #3 will be skipped:

# fix indentation
2021-09-15 18:04:45 +02:00
Lukas Wirth
33cdc21832 Don't highlight unsafe traits as unsafe in safe impls 2021-09-15 15:46:45 +02:00