Commit Graph

20860 Commits

Author SHA1 Message Date
Lukas Wirth 9f5ee155c1 Move path completions for patterns into pattern module 2022-02-03 15:52:03 +01:00
Lukas Wirth 33fd2d7aef Cleanup PathCompletionContext qualifier handling 2022-02-03 15:52:03 +01:00
Lukas Wirth a3ad99649f Add missing test for use completions 2022-02-03 15:52:03 +01:00
Lukas Wirth 136dadac9a Add completion module tailored towards visibility modifiers 2022-02-03 15:52:03 +01:00
Lukas Wirth 661d721e20 Add completion module tailored towards use trees 2022-02-03 15:51:57 +01:00
Lukas Wirth 6940cca760 Move attribute path completions into attribute completion module 2022-02-03 15:50:14 +01:00
bors[bot] 46b5089bfa Merge #11399
11399: Fix assoc type shorthand from method bounds r=flodiebold a=flodiebold

In code like this:
```rust
impl<T> Option<T> {
    fn as_deref(&self) -> T::Target where T: Deref {}
}
```

when trying to resolve the associated type `T::Target`, we were only
looking at the bounds on the impl (where the type parameter is defined),
but the method can add additional bounds that can also be used to refer
to associated types. Hence, when resolving such an associated type, it's
not enough to just know the type parameter T, we also need to know
exactly where we are currently.

This fixes #11364 (beta apparently switched some bounds around).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-03 12:21:18 +00:00
Florian Diebold 4ed5fe1554 Fix assoc type shorthand from method bounds
In code like this:
```rust
impl<T> Option<T> {
    fn as_deref(&self) -> T::Target where T: Deref {}
}
```

when trying to resolve the associated type `T::Target`, we were only
looking at the bounds on the impl (where the type parameter is defined),
but the method can add additional bounds that can also be used to refer
to associated types. Hence, when resolving such an associated type, it's
not enough to just know the type parameter T, we also need to know
exactly where we are currently.

This fixes #11364 (beta apparently switched some bounds around).
2022-02-03 13:15:02 +01:00
bors[bot] 9cb6e3a190 Merge #11394
11394: feat: Deprioritize completions of private but editable definitions r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-02 11:42:40 +00:00
Lukas Wirth 2d77eb1e12 Fix test fixture 2022-02-02 12:42:13 +01:00
bors[bot] d20ff92747 Merge #11395
11395: fix: Fix and re-enable format string completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-02 11:20:38 +00:00
Lukas Wirth 6f974cf477 fix: Fix and re-enable format string completions 2022-02-02 12:20:10 +01:00
Lukas Wirth 7267749f6b Cleanup Completions api a bit 2022-02-02 12:19:43 +01:00
Lukas Wirth 70650897d8 Fix generate_function assist trying to use name-ref like keywords for names 2022-02-02 11:37:24 +01:00
Lukas Wirth 5c41f5d165 feat: Deprioritize completions of private but editable definitions 2022-02-02 02:05:49 +01:00
bors[bot] 34138379b5 Merge #11322
11322: Extract function also extracts comments r=Vannevelj a=Vannevelj

Fixes #9011

The difficulty I came across is that the original assist works from the concept of a `ast::StmtList`, a node, but that does not allow me to (easily) represent comments, which are tokens. To combat this, I do a whole bunch of roundtrips: from the `ast::StmtList` I retrieve the `NodeOrToken`s it encompasses. 

I then cast all `Node` ones back to a `Stmt` so I can apply indentation to it, after which it is again parsed as a `NodeOrToken`.

Lastly, I add a new `make::` api that accepts `NodeOrToken` rather than `StmtList` so we can write the comment tokens.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-02-01 23:05:28 +00:00
bors[bot] 498224af18 Merge #11393
11393: fix: Complete functions and methods from block level impls r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 22:48:34 +00:00
Jeroen Vannevel 493642ab3a rollup match 2022-02-01 22:38:37 +00:00
Lukas Wirth d7a544e69a fix: Complete functions and methods from block level impls 2022-02-01 23:29:40 +01:00
bors[bot] 5ee21fee9c Merge #11391
11391: minor: Add some debug traces for cfg fetching r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 12:35:52 +00:00
Lukas Wirth dbd5a70ea3 minor: Add some debug traces for cfg fetching 2022-02-01 13:35:34 +01:00
bors[bot] 9b88956bd5 Merge #11390
11390: fix: Deprioritize ops function completions for non-method calls r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 11:34:40 +00:00
Lukas Wirth fcdced115e Deprioritize ops function completions for non-method calls 2022-02-01 12:33:55 +01:00
Jeroen Vannevel 1811f6330b better comparison 2022-02-01 09:00:30 +00:00
Jeroen Vannevel b290285dd8 removed redundant test 2022-02-01 00:38:33 +00:00
Jeroen Vannevel 269153388a added FIXME 2022-02-01 00:37:48 +00:00
Jeroen Vannevel 51c50dd5ac don't tear body 2022-02-01 00:36:50 +00:00
Jeroen Vannevel e72ed9230a no longer support comments on their own 2022-02-01 00:21:35 +00:00
bors[bot] 4800c05a20 Merge #11388
11388: fix: Fix proc-macro server not using the supplied span in Ident::new r=Veykril a=Veykril

This makes the hack introduced by https://github.com/rust-analyzer/rust-analyzer/pull/10899 obsolete.

For async-trait specifically, (unfortunately, but technically correct) due to how async-trait works, the self local now renders white, as it now resolves to the `__self` local introduced by the attribute.

![Code_0Ezw6PJAbh](https://user-images.githubusercontent.com/3757771/151827812-c03b8fc7-7ecf-4959-804a-2680d8e61e8b.png)
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-31 16:03:23 +00:00
Lukas Wirth f6def3ccdf fix: Fix proc-macro server not using the supplied span in Ident::new 2022-01-31 17:02:57 +01:00
bors[bot] 1cc125fdd8 Merge #11291
11291: internal: Make more precise range macro upmapping r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-31 15:22:42 +00: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
bors[bot] 0808ade4e4 Merge #11182
11182: fix: don't panic on seeing an unexpected offset r=Veykril a=dimbleby

Intended as a fix, or at least a sticking plaster, for #11081.

I have arranged that [offset()](https://github.com/rust-analyzer/rust-analyzer/blob/1ba9a924d7b161c52e605e157ee16d582e4a8684/crates/ide_db/src/line_index.rs#L105-L107) returns `Option<TextSize>` instead of going out of bounds; other changes are the result of following the compiler after doing this.

Perhaps there's still an issue here - I suppose the server and client have gotten out of sync and that probably shouldn't happen in the first place?  I see that https://github.com/rust-analyzer/rust-analyzer/issues/10138#issuecomment-913727554 suggests what sounds like a more substantial fix which I think might be aimed in this direction.  So perhaps that one should be left open to cover such things?

Meanwhile, I hope that not-crashing is a good improvement: and I can confirm that it works out just fine in the repro I have at #11081.

Co-authored-by: David Hotham <david.hotham@metaswitch.com>
2022-01-31 11:16:22 +00:00
bors[bot] 66870ca0ed Merge #11384
11384: feat: Complete local fn and closure params from surrounding locals scope r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-31 11:05:40 +00:00
Lukas Wirth 6194092086 Complete local fn and closure params from surrounding locals scope 2022-01-31 11:56:42 +01:00
bors[bot] fd3942eb62 Merge #11382
11382: fix: Fix `cfg_attr` invalidating derive identifier IDE functionalities r=Veykril a=Veykril

Proper fix for https://github.com/rust-analyzer/rust-analyzer/issues/11298
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-30 22:08:25 +00:00
Lukas Wirth ddf7b70a0f Fix cfg_attr invalidating derive identifier IDE functionality 2022-01-30 22:47:16 +01:00
Lukas Wirth cc04cfc982 Reduce allocations in attribute collection 2022-01-30 22:18:32 +01:00
bors[bot] c08df0f1f5 Merge #11377
11377: Update README.md r=flodiebold a=flodiebold

I'm not currently sponsored anymore.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-01-30 13:23:47 +00:00
Florian Diebold b36c83032b Update README.md
I'm not currently sponsored anymore.
2022-01-30 14:21:52 +01:00
bors[bot] 6010431a0b Merge #11356
11356: Rollback env vars changed by a proc macro r=vlad20012 a=vlad20012

Fixes #11355

Co-authored-by: vlad20012 <beskvlad@gmail.com>
2022-01-30 08:05:55 +00:00
bors[bot] 6634eaf13a Merge #11367
11367: minor: Use `compare_exchange_weak` in `limit::Limit::check` r=lnicola a=WaffleLapkin

Not a big deal, but generally loops should use `_weak` version of `compare_exchange`.

Co-authored-by: Maybe Waffle <waffle.lapkin@gmail.com>
2022-01-28 15:31:52 +00:00
Maybe Waffle 78a3cefc45 Use compare_exchange_weak in limit::Limit::check 2022-01-28 18:19:35 +03:00
bors[bot] 4aadabc735 Merge #11365
11365: Add a way to disable dll copying for users of proc_macro_srv library r=lnicola a=vlad20012

We use `ra_ap_proc_macro_srv` library in IntelliJ Rust in order to expand proc macros. We need a way to disable [DLL copying to a temp dir on Windows](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/proc_macro_srv/src/dylib.rs#L166) behavior because it causes issues like https://github.com/intellij-rust/intellij-rust/issues/7709. Unlike RA, file locking is not an issue for IntelliJ Rust because we copy DLLs to a temp dir before calling the expander.

Co-authored-by: vlad20012 <beskvlad@gmail.com>
2022-01-28 13:21:24 +00:00
vlad20012 e277d5d64e Add a way to disable dll copying for users of proc_macro_srv library 2022-01-28 16:18:25 +03:00
bors[bot] cd6521e5de Merge #11360
11360: feat: Support `#![recursion_limit]` attribute r=Veykril a=WaffleLapkin

![Peek 2022-01-28 02-33](https://user-images.githubusercontent.com/38225716/151508617-ac802b53-f088-4cac-b260-2cd077f3d32c.gif)

Resolves #8640

`@matklad` thanks, for the instructions, they were very helpful :)

Co-authored-by: Maybe Waffle <waffle.lapkin@gmail.com>
2022-01-28 10:58:21 +00:00
vlad20012 e93386f6ce Rollback env vars changed by a proc macro 2022-01-28 13:43:29 +03: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
Maybe Waffle 81211f538c Use crate_limits query in macro expansion 2022-01-28 11:31:59 +03:00