]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix Immovable generator syntax (static ||) not recognized #11448
bellau [Sat, 12 Feb 2022 14:17:10 +0000 (15:17 +0100)]
Fix  Immovable generator syntax (static ||) not recognized #11448

2 years agoMerge #11453
bors[bot] [Fri, 11 Feb 2022 21:21:57 +0000 (21:21 +0000)]
Merge #11453

11453: internal: Make `ascend_call_token` iterative instead of recursive r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agointernal: Make `ascend_call_token` iterative instead of recursive
Lukas Wirth [Fri, 11 Feb 2022 21:12:16 +0000 (22:12 +0100)]
internal: Make `ascend_call_token` iterative instead of recursive

2 years agoMerge #11441
bors[bot] [Wed, 9 Feb 2022 07:24:33 +0000 (07:24 +0000)]
Merge #11441

11441: minor: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump lsp-types
Laurențiu Nicola [Wed, 9 Feb 2022 07:22:25 +0000 (09:22 +0200)]
Bump lsp-types

2 years agoRevert "Revert "Bump dashmap""
Laurențiu Nicola [Wed, 9 Feb 2022 07:19:57 +0000 (09:19 +0200)]
Revert "Revert "Bump dashmap""

This reverts commit 39674cd35054f4905691bb0c3d1eca7b97063aa7.

2 years agoBump deps
Laurențiu Nicola [Wed, 9 Feb 2022 07:14:55 +0000 (09:14 +0200)]
Bump deps

2 years agoMerge #11437
bors[bot] [Tue, 8 Feb 2022 23:30:50 +0000 (23:30 +0000)]
Merge #11437

11437: [ide_completion] render if a function is async/const/unsafe in completion details r=Veykril a=jhgg

this change renders in the autocomplete detail, whether a function is async/const/unsafe.

i found myself wanting to know this information at a glance, so now it renders here:

![image](https://user-images.githubusercontent.com/5489149/153089518-5419afe4-b2c6-4be8-80f7-585f5c514ff2.png)

Co-authored-by: Jake Heinz <jh@discordapp.com>
2 years agoMerge #11436
bors[bot] [Tue, 8 Feb 2022 23:19:07 +0000 (23:19 +0000)]
Merge #11436

11436: fix: renaming modules does not change references by super r=Veykril a=TheDoctor314

Fixes #11289.

Co-authored-by: TheDoctor314 <64731940+TheDoctor314@users.noreply.github.com>
2 years ago[ide_completion] render if a function is async/const/unsafe in completion details
Jake Heinz [Tue, 8 Feb 2022 22:48:34 +0000 (22:48 +0000)]
[ide_completion] render if a function is async/const/unsafe in completion details

2 years agoFix renaming super keyword
TheDoctor314 [Tue, 8 Feb 2022 15:58:32 +0000 (21:28 +0530)]
Fix renaming super keyword

2 years agoAdd test
TheDoctor314 [Tue, 8 Feb 2022 15:49:14 +0000 (21:19 +0530)]
Add test

The rename function should not change any path segments that refer to a
module by super.

2 years agoMerge #11427
bors[bot] [Mon, 7 Feb 2022 07:51:13 +0000 (07:51 +0000)]
Merge #11427

11427: add missing snake case attribute, update hash r=lnicola a=HansAuger

Fix for #11414

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agoadd missing snake case attribute, update hash
Moritz Vetter [Mon, 7 Feb 2022 03:57:20 +0000 (04:57 +0100)]
add missing snake case attribute, update hash

2 years agoMerge #11416
bors[bot] [Sun, 6 Feb 2022 14:42:01 +0000 (14:42 +0000)]
Merge #11416

11416: Fix eslint language server not working r=Veykril a=jackos

Allows the language server for eslint to work inside VS Code.

Before change:
![image](https://user-images.githubusercontent.com/77730378/152661637-c5d90678-39dc-4018-b884-fc4b6135368e.png)

After change:
![image](https://user-images.githubusercontent.com/77730378/152661647-164c0655-aa6a-4c50-b49d-49cda112d149.png)

Co-authored-by: Jack Clayton <jackclayto@gmail.com>
2 years agoMerge #11420
bors[bot] [Sun, 6 Feb 2022 14:28:27 +0000 (14:28 +0000)]
Merge #11420

11420: fix two vulneabilities (moderate: 1, high: 1) by running npm audit r=lnicola a=HansAuger

Again me getting familiar with the code base :D

I noticed npm warning about two vulnerabilities
```
markdown-it  <12.3.2
Severity: moderate
Uncontrolled Resource Consumption in markdown-it - https://github.com/advisories/GHSA-6vfc-qv3f-vr6c
fix available via `npm audit fix`
node_modules/markdown-it
  vsce  1.26.0 - 2.6.3
  Depends on vulnerable versions of markdown-it
  node_modules/vsce

simple-get  3.0.0 - 3.1.0
Severity: high
Exposure of Sensitive Information in simple-get - https://github.com/advisories/GHSA-wpg7-2c88-r8xv
fix available via `npm audit fix`
node_modules/simple-get
```

So I thought why not run `npm audit fix`

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agofix two vulneabilities (moderate: 1, high: 1) by running npm audit
Moritz Vetter [Sun, 6 Feb 2022 14:23:48 +0000 (15:23 +0100)]
fix two vulneabilities (moderate: 1, high: 1) by running npm audit

2 years agoMerge #11418
bors[bot] [Sun, 6 Feb 2022 08:54:34 +0000 (08:54 +0000)]
Merge #11418

11418: fix: Update dependency, fix Markdown references r=Veykril a=HansAuger

Stumbled across this accidentally while familiarizing myself with the code base.

Update `pulldown-cmark-to-cmark` Fix for #11008

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agoBump pulldown-cmark-to-cmark, adjust usages and fix test
Moritz Vetter [Sun, 6 Feb 2022 08:04:06 +0000 (09:04 +0100)]
Bump pulldown-cmark-to-cmark, adjust usages and fix test

2 years agoFix eslint errors
Jack Clayton [Sat, 5 Feb 2022 22:52:51 +0000 (06:52 +0800)]
Fix eslint errors

2 years agoMerge #11415
bors[bot] [Sat, 5 Feb 2022 14:21:40 +0000 (14:21 +0000)]
Merge #11415

11415: Downgrade `dashmap` and bump `thread_local` r=lnicola a=lnicola

Closes #11341

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump thread_local
Laurențiu Nicola [Sat, 5 Feb 2022 14:19:08 +0000 (16:19 +0200)]
Bump thread_local

2 years agoUpdate lockfile
Laurențiu Nicola [Sat, 5 Feb 2022 14:17:12 +0000 (16:17 +0200)]
Update lockfile

2 years agoRevert "Bump dashmap"
Laurențiu Nicola [Sat, 5 Feb 2022 14:15:56 +0000 (16:15 +0200)]
Revert "Bump dashmap"

This reverts commit 485f318b70bdc40bd71fa46748cc7053a5b8fd8a.

2 years agoMerge #11412
bors[bot] [Sat, 5 Feb 2022 11:54:07 +0000 (11:54 +0000)]
Merge #11412

11412: fix: Include `fn`/`type`/`const` keyword in trait impl completion item source ranges r=Veykril a=The0x539

Fixes #11301

If the user has typed, say, `fn de` while implementing `Default`, or `type Ta` when implementing `Deref`, then the resulting completion suggestion will replace the entire "line", which, on its own, is fine.
However, the use of `ctx.source_range()` in this code was meant that `source_range` field of the `CompletionItem` covers only the identifier and not the preceding keyword.

Over in `rust_analyzer::to_proto::completion_item`, this caused the LSP completion response to be broken up into a text edit that replaces `de` with `fn default() -> Self {` and then an entry in `additional_text_edits` to remove the extra `fn`.
I'm pretty sure that using the field like that is (slightly) out of [spec](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#completionItem):
> Edits must not overlap [...] with the main edit
> Additional text edits should be used to change text **unrelated to the current cursor position**

VS Code supports `additionalTextEdits` in such a way that this doesn't seem like a problem, so has gone largely unnoticed.
The various LSP clients I've tried, however, do not, and as a result this bug has been haunting me for ages.

Co-authored-by: The0x539 <the0x539@gmail.com>
2 years agoFix trait impl completion ranges
The0x539 [Sat, 5 Feb 2022 01:55:55 +0000 (19:55 -0600)]
Fix trait impl completion ranges

2 years agoMerge #11411
bors[bot] [Fri, 4 Feb 2022 13:36:34 +0000 (13:36 +0000)]
Merge #11411

11411: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Fri, 4 Feb 2022 01:50:33 +0000 (02:50 +0100)]
Simplify

2 years agoMerge #11406
bors[bot] [Thu, 3 Feb 2022 20:11:18 +0000 (20:11 +0000)]
Merge #11406

11406: Update install notes for bundled servers r=stanciuadrian a=lnicola

r? `@stanciuadrian`

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoUpdate install notes
Laurențiu Nicola [Thu, 3 Feb 2022 19:54:23 +0000 (21:54 +0200)]
Update install notes

2 years agoMerge #11403
bors[bot] [Thu, 3 Feb 2022 16:30:01 +0000 (16:30 +0000)]
Merge #11403

11403: internal: Shrink `mbe::ExpandError` and `mbe::ParseError` r=Veykril a=Veykril

Also fixes https://github.com/rust-analyzer/rust-analyzer/issues/10051, as we no longer emit an empty diagnostic in some expansion cases which seems to trip up vscode for some reason. Using `compile_error!("")` will still trigger the vscode bug.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoShrink `mbe::ExpandError` and `mbe::ParseError`
Lukas Wirth [Thu, 3 Feb 2022 16:25:24 +0000 (17:25 +0100)]
Shrink `mbe::ExpandError` and `mbe::ParseError`

2 years agoMerge #11402
bors[bot] [Thu, 3 Feb 2022 16:02:51 +0000 (16:02 +0000)]
Merge #11402

11402: fix: Fix vis restriction path completions always using the parent module r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix vis restriction path completions always using the parent module
Lukas Wirth [Thu, 3 Feb 2022 16:02:12 +0000 (17:02 +0100)]
fix: Fix vis restriction path completions always using the parent module

2 years agoMerge #11401
bors[bot] [Thu, 3 Feb 2022 15:38:45 +0000 (15:38 +0000)]
Merge #11401

11401: Sort completion calls lexicographically r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoAdd abi string completions
Lukas Wirth [Thu, 3 Feb 2022 15:29:23 +0000 (16:29 +0100)]
Add abi string completions

2 years agoSort completion calls lexicographically
Lukas Wirth [Thu, 3 Feb 2022 15:05:21 +0000 (16:05 +0100)]
Sort completion calls lexicographically

2 years agoMerge #11397
bors[bot] [Thu, 3 Feb 2022 15:01:08 +0000 (15:01 +0000)]
Merge #11397

11397: internal: Refactor completion module split r=Veykril a=Veykril

Currently our completion infra is split into several modules, each trying to do completions for something specific. This "something" is rather unstructured as it stands now, we have a module for `flyimporting path` completions, `unqualified` and `qualified path` completions, modules for `pattern position` completions that only try to complete extra things for patterns that aren't done in the path modules, `attribute` completions that again only try to add builtin attribute completions without adding the normal path completions and a bunch of other special "entity" completions like lifetimes, method call/field access, function param cloning, ... which serve a more specific purpose than the previous listed ones.

As is evident, the former mentioned ones have some decent overlap which requires extra filtering in them so that they don't collide with each other duplicating a bunch of completions(which we had happen in the past at times).

Now this overlap mostly happens with path completions(and keyword completions as well in some sense) which gives me the feeling that having `qualified` and `unqualified` path completions be separate from the rest gives us more troubles than benefits in the long run.
So this is an attempt at changing this structure to instead still go by rough entity for special cases, but when it comes to paths we instead do the module split on the "path kinds"/"locations"(think pattern, type, expr position etc) that exist. This goes hand in hand with the test refactoring I have done that moved tests to "location oriented" modules as well as the `CompletionContext` refactoring that actually already started splitting the context up for path kinds.

This PR moves some path completions out of the `qualified` and `unqualified` path modules namely attribute, visibility, use and pattern paths.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Wed, 2 Feb 2022 17:18:08 +0000 (18:18 +0100)]
Simplify

2 years agoMove path completions for patterns into pattern module
Lukas Wirth [Wed, 2 Feb 2022 17:09:30 +0000 (18:09 +0100)]
Move path completions for patterns into pattern module

2 years agoCleanup PathCompletionContext qualifier handling
Lukas Wirth [Wed, 2 Feb 2022 15:01:46 +0000 (16:01 +0100)]
Cleanup PathCompletionContext qualifier handling

2 years agoAdd missing test for use completions
Lukas Wirth [Wed, 2 Feb 2022 14:28:23 +0000 (15:28 +0100)]
Add missing test for use completions

2 years agoAdd completion module tailored towards visibility modifiers
Lukas Wirth [Wed, 2 Feb 2022 14:14:43 +0000 (15:14 +0100)]
Add completion module tailored towards visibility modifiers

2 years agoAdd completion module tailored towards use trees
Lukas Wirth [Wed, 2 Feb 2022 14:03:46 +0000 (15:03 +0100)]
Add completion module tailored towards use trees

2 years agoMove attribute path completions into attribute completion module
Lukas Wirth [Wed, 2 Feb 2022 12:35:46 +0000 (13:35 +0100)]
Move attribute path completions into attribute completion module

2 years agoMerge #11399
bors[bot] [Thu, 3 Feb 2022 12:21:18 +0000 (12:21 +0000)]
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>
2 years agoFix assoc type shorthand from method bounds
Florian Diebold [Thu, 3 Feb 2022 11:43:15 +0000 (12:43 +0100)]
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).

2 years agoMerge #11394
bors[bot] [Wed, 2 Feb 2022 11:42:40 +0000 (11:42 +0000)]
Merge #11394

11394: feat: Deprioritize completions of private but editable definitions r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoFix test fixture
Lukas Wirth [Wed, 2 Feb 2022 11:42:13 +0000 (12:42 +0100)]
Fix test fixture

2 years agoMerge #11395
bors[bot] [Wed, 2 Feb 2022 11:20:38 +0000 (11:20 +0000)]
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>
2 years agofix: Fix and re-enable format string completions
Lukas Wirth [Wed, 2 Feb 2022 11:20:10 +0000 (12:20 +0100)]
fix: Fix and re-enable format string completions

2 years agoCleanup `Completions` api a bit
Lukas Wirth [Wed, 2 Feb 2022 11:05:21 +0000 (12:05 +0100)]
Cleanup `Completions` api a bit

2 years agoFix generate_function assist trying to use name-ref like keywords for names
Lukas Wirth [Wed, 2 Feb 2022 10:37:24 +0000 (11:37 +0100)]
Fix generate_function assist trying to use name-ref like keywords for names

2 years agofeat: Deprioritize completions of private but editable definitions
Lukas Wirth [Wed, 2 Feb 2022 01:05:49 +0000 (02:05 +0100)]
feat: Deprioritize completions of private but editable definitions

2 years agoMerge #11322
bors[bot] [Tue, 1 Feb 2022 23:05:28 +0000 (23:05 +0000)]
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>
2 years agoMerge #11393
bors[bot] [Tue, 1 Feb 2022 22:48:34 +0000 (22:48 +0000)]
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>
2 years agorollup match
Jeroen Vannevel [Tue, 1 Feb 2022 22:38:37 +0000 (22:38 +0000)]
rollup match

2 years agofix: Complete functions and methods from block level impls
Lukas Wirth [Tue, 1 Feb 2022 22:29:40 +0000 (23:29 +0100)]
fix: Complete functions and methods from block level impls

2 years agoMerge #11391
bors[bot] [Tue, 1 Feb 2022 12:35:52 +0000 (12:35 +0000)]
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>
2 years agominor: Add some debug traces for cfg fetching
Lukas Wirth [Tue, 1 Feb 2022 12:32:09 +0000 (13:32 +0100)]
minor: Add some debug traces for cfg fetching

2 years agoMerge #11390
bors[bot] [Tue, 1 Feb 2022 11:34:40 +0000 (11:34 +0000)]
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>
2 years agoDeprioritize ops function completions for non-method calls
Lukas Wirth [Tue, 1 Feb 2022 11:33:55 +0000 (12:33 +0100)]
Deprioritize ops function completions for non-method calls

2 years agobetter comparison
Jeroen Vannevel [Tue, 1 Feb 2022 09:00:30 +0000 (09:00 +0000)]
better comparison

2 years agoremoved redundant test
Jeroen Vannevel [Tue, 1 Feb 2022 00:38:33 +0000 (00:38 +0000)]
removed redundant test

2 years agoadded FIXME
Jeroen Vannevel [Tue, 1 Feb 2022 00:37:48 +0000 (00:37 +0000)]
added FIXME

2 years agodon't tear body
Jeroen Vannevel [Tue, 1 Feb 2022 00:36:50 +0000 (00:36 +0000)]
don't tear body

2 years agono longer support comments on their own
Jeroen Vannevel [Tue, 1 Feb 2022 00:21:35 +0000 (00:21 +0000)]
no longer support comments on their own

2 years agoMerge #11388
bors[bot] [Mon, 31 Jan 2022 16:03:23 +0000 (16:03 +0000)]
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>
2 years agofix: Fix proc-macro server not using the supplied span in Ident::new
Lukas Wirth [Mon, 31 Jan 2022 15:56:33 +0000 (16:56 +0100)]
fix: Fix proc-macro server not using the supplied span in Ident::new

2 years agoMerge #11291
bors[bot] [Mon, 31 Jan 2022 15:22:42 +0000 (15:22 +0000)]
Merge #11291

11291: internal: Make more precise range macro upmapping r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMake more precise range macro upmapping
Lukas Wirth [Mon, 31 Jan 2022 12:56:14 +0000 (13:56 +0100)]
Make more precise range macro upmapping

2 years agoFix token ascension single token check being inverted
Lukas Wirth [Mon, 31 Jan 2022 12:10:53 +0000 (13:10 +0100)]
Fix token ascension single token check being inverted

2 years agoMerge #11182
bors[bot] [Mon, 31 Jan 2022 11:16:22 +0000 (11:16 +0000)]
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>
2 years agoMerge #11384
bors[bot] [Mon, 31 Jan 2022 11:05:40 +0000 (11:05 +0000)]
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>
2 years agoComplete local fn and closure params from surrounding locals scope
Lukas Wirth [Mon, 31 Jan 2022 10:56:42 +0000 (11:56 +0100)]
Complete local fn and closure params from surrounding locals scope

2 years agoMerge #11382
bors[bot] [Sun, 30 Jan 2022 22:08:25 +0000 (22:08 +0000)]
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>
2 years agoFix cfg_attr invalidating derive identifier IDE functionality
Lukas Wirth [Sun, 30 Jan 2022 21:46:05 +0000 (22:46 +0100)]
Fix cfg_attr invalidating derive identifier IDE functionality

2 years agoReduce allocations in attribute collection
Lukas Wirth [Sun, 30 Jan 2022 21:18:32 +0000 (22:18 +0100)]
Reduce allocations in attribute collection

2 years agoMerge #11377
bors[bot] [Sun, 30 Jan 2022 13:23:47 +0000 (13:23 +0000)]
Merge #11377

11377: Update README.md r=flodiebold a=flodiebold

I'm not currently sponsored anymore.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoUpdate README.md
Florian Diebold [Sun, 30 Jan 2022 13:21:52 +0000 (14:21 +0100)]
Update README.md

I'm not currently sponsored anymore.

2 years agoMerge #11356
bors[bot] [Sun, 30 Jan 2022 08:05:55 +0000 (08:05 +0000)]
Merge #11356

11356: Rollback env vars changed by a proc macro r=vlad20012 a=vlad20012

Fixes #11355

Co-authored-by: vlad20012 <beskvlad@gmail.com>
2 years agoMerge #11367
bors[bot] [Fri, 28 Jan 2022 15:31:52 +0000 (15:31 +0000)]
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>
2 years agoUse `compare_exchange_weak` in `limit::Limit::check`
Maybe Waffle [Fri, 28 Jan 2022 15:19:35 +0000 (18:19 +0300)]
Use `compare_exchange_weak` in `limit::Limit::check`

2 years agoMerge #11365
bors[bot] [Fri, 28 Jan 2022 13:21:24 +0000 (13:21 +0000)]
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>
2 years agoAdd a way to disable dll copying for users of proc_macro_srv library
vlad20012 [Fri, 28 Jan 2022 13:18:25 +0000 (16:18 +0300)]
Add a way to disable dll copying for users of proc_macro_srv library

2 years agoMerge #11360
bors[bot] [Fri, 28 Jan 2022 10:58:21 +0000 (10:58 +0000)]
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>
2 years agoRollback env vars changed by a proc macro
vlad20012 [Thu, 27 Jan 2022 18:34:18 +0000 (21:34 +0300)]
Rollback env vars changed by a proc macro

2 years agofeat: Honor recursion limit configuration
Maybe Waffle [Thu, 27 Jan 2022 22:23:09 +0000 (01:23 +0300)]
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

2 years agoUse `crate_limits` query in macro expansion
Maybe Waffle [Thu, 27 Jan 2022 20:53:49 +0000 (23:53 +0300)]
Use `crate_limits` query in macro expansion

2 years agoAdd `crate_limits` query to `SourceDatabase`
Maybe Waffle [Thu, 27 Jan 2022 20:34:33 +0000 (23:34 +0300)]
Add `crate_limits` query to `SourceDatabase`

This allows fetching crate limits like `recursion_limit`. The
implementation is currently dummy and just returns the defaults.

Future work: Use this query instead of the hardcoded constant.

Future work: Actually implement this query by parsing
`#![recursion_limit = N]` attribute.

2 years agoMerge #11288
bors[bot] [Thu, 27 Jan 2022 22:26:34 +0000 (22:26 +0000)]
Merge #11288

11288: Support <code> blocks from Rust docs in vscode hover r=oandrew a=oandrew

Set `"supportHtml": true` to support rendering `<code>` blocks in hovers.

e.g.  https://github.com/rust-lang/rust/blob/1bd4fdc943513e1004f498bbf289279c9784fc6f/library/std/src/fs.rs#L109

Co-authored-by: Andrew Onyshchuk <andryk.rv@gmail.com>
2 years agoSupport <code> blocks from Rust docs
Andrew Onyshchuk [Fri, 14 Jan 2022 23:20:35 +0000 (15:20 -0800)]
Support <code> blocks from Rust docs

2 years agoMerge #11353
bors[bot] [Thu, 27 Jan 2022 18:09:08 +0000 (18:09 +0000)]
Merge #11353

11353: Set current working directory for procedural macros r=vlad20012 a=vlad20012

Fixes #11079

Co-authored-by: vlad20012 <beskvlad@gmail.com>
2 years agoMerge #11354
bors[bot] [Thu, 27 Jan 2022 15:59:18 +0000 (15:59 +0000)]
Merge #11354

11354: fix: More correct `$crate` handling in eager macros r=jonas-schievink a=jonas-schievink

Fixes a few of the additional bugs in https://github.com/rust-analyzer/rust-analyzer/issues/10300, but not yet that issue itself.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoMore correct `$crate` handling in eager macros
Jonas Schievink [Thu, 27 Jan 2022 15:57:53 +0000 (16:57 +0100)]
More correct `$crate` handling in eager macros

2 years agoSet current working directory for procedural macros
vlad20012 [Thu, 27 Jan 2022 12:54:06 +0000 (15:54 +0300)]
Set current working directory for procedural macros

2 years agoMerge #11348
bors[bot] [Wed, 26 Jan 2022 18:11:47 +0000 (18:11 +0000)]
Merge #11348

11348: fix: Fix merge commit check for git 2.35 r=jonas-schievink a=jonas-schievink

git 2.35 introduces a [change in behavior](https://github.com/git/git/blob/89bece5c8c96f0b962cfc89e63f82d603fd60bed/Documentation/RelNotes/2.35.0.txt#L330-L333) that breaks this check.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoFix merge commit check for git 2.35
Jonas Schievink [Wed, 26 Jan 2022 18:10:39 +0000 (19:10 +0100)]
Fix merge commit check for git 2.35

2 years agoMerge #11347
bors[bot] [Wed, 26 Jan 2022 17:35:51 +0000 (17:35 +0000)]
Merge #11347

11347: fix: Fix resolution of eager macro contents r=jonas-schievink a=jonas-schievink

Eager macros resolve and expand any contained macro invocations before they are expanded. The logic for this was previously pretty broken: any nameres failure would be reported as a generic macro expansion error, so this didn't work correctly with the fixed-point resolution loop. This manifested as spurious errors whenever a non-legacy macro was used in an eager macro (that means *any* path with more than one segment).

After an intense staring contest with the abyss, this PR fixes the basic logic, but some bugs still remain (particularly around `$crate`). As a side-effect, this PR moves `ModPath` into `hir_expand`.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoFix resolution of eager macro contents
Jonas Schievink [Wed, 26 Jan 2022 17:31:07 +0000 (18:31 +0100)]
Fix resolution of eager macro contents