Commit Graph

21001 Commits

Author SHA1 Message Date
Florian Diebold
30287e6051 Fix test 2022-02-08 20:44:46 +01:00
Florian Diebold
1a5aa84e9f Track synthetic tokens, to be able to remove them again later 2022-02-08 18:13:18 +01:00
TheDoctor314
10e7e18dc6 Fix renaming super keyword 2022-02-08 21:56:39 +05:30
TheDoctor314
add80bccfc Add test
The rename function should not change any path segments that refer to a
module by super.
2022-02-08 21:19:14 +05:30
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
79ebf618ec Simplify 2022-02-07 18:21:31 +01:00
Florian Diebold
86b968ba94 Add a check 2022-02-07 18:19:00 +01:00
Florian Diebold
b9c5d23f69 Simplify a bit 2022-02-07 18:17:28 +01:00
Florian Diebold
cff209f152 WIP: Actually fix up syntax errors in attribute macro input 2022-02-07 18:12:51 +01:00
Florian Diebold
212e82fd41 Add test for giving attribute proc macros valid syntax 2022-02-07 12:54:08 +01:00
bors[bot]
9b1978a3ed
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>
2022-02-07 07:51:13 +00:00
Moritz Vetter
482533ea9a add missing snake case attribute, update hash 2022-02-07 04:57:20 +01:00
Maybe Waffle
662dd7c27d Pass required features to cargo when using run action
When using `F1`->`Rust Analyzer: Run` action on an `example`, pass its
`required-features` to `cargo run`. This allows to run examples that
were otherwise impossible to run with RA.
2022-02-06 19:02:25 +03:00
bors[bot]
ba33054802
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>
2022-02-06 14:42:01 +00:00
bors[bot]
1dee488a68
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>
2022-02-06 14:28:27 +00:00
Moritz Vetter
9f6c206ea0 fix two vulneabilities (moderate: 1, high: 1) by running npm audit 2022-02-06 15:23:48 +01:00
bors[bot]
d2d137addd
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>
2022-02-06 08:54:34 +00:00
Moritz Vetter
ba2ef69c79 Bump pulldown-cmark-to-cmark, adjust usages and fix test 2022-02-06 09:04:06 +01:00
Jack Clayton
76ecf9a17d Fix eslint errors 2022-02-06 06:52:51 +08:00
bors[bot]
668947056a
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>
2022-02-05 14:21:40 +00:00
Laurențiu Nicola
d0f371c80b Bump thread_local 2022-02-05 16:19:08 +02:00
Laurențiu Nicola
145e88ddfe Update lockfile 2022-02-05 16:17:12 +02:00
Laurențiu Nicola
39674cd350 Revert "Bump dashmap"
This reverts commit 485f318b70.
2022-02-05 16:15:56 +02:00
bors[bot]
dd05d12055
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>
2022-02-05 11:54:07 +00:00
The0x539
1536fc040a Fix trait impl completion ranges 2022-02-04 19:55:55 -06:00
bors[bot]
0feafe8185
Merge #11411
11411: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-04 13:36:34 +00:00
Lukas Wirth
ec677e35d0 Simplify 2022-02-04 02:50:33 +01:00
bors[bot]
9597e55e9b
Merge #11406
11406: Update install notes for bundled servers r=stanciuadrian a=lnicola

r? `@stanciuadrian` 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-02-03 20:11:18 +00:00
Laurențiu Nicola
befaa874ac Update install notes 2022-02-03 21:54:23 +02:00
bors[bot]
6162d12890
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>
2022-02-03 16:30:01 +00:00
Lukas Wirth
2ad71f1350 Shrink mbe::ExpandError and mbe::ParseError 2022-02-03 17:25:24 +01:00
bors[bot]
6ef6fa019c
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>
2022-02-03 16:02:51 +00:00
Lukas Wirth
2310908df7 fix: Fix vis restriction path completions always using the parent module 2022-02-03 17:02:12 +01:00
bors[bot]
d6329f2171
Merge #11401
11401: Sort completion calls lexicographically r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 15:38:45 +00:00
Lukas Wirth
c83081879f Add abi string completions 2022-02-03 16:33:42 +01:00
Lukas Wirth
d3f3b6a87f Sort completion calls lexicographically 2022-02-03 16:05:21 +01:00
bors[bot]
5a7e11f5fb
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>
2022-02-03 15:01:08 +00:00
Lukas Wirth
7619c2afea Simplify 2022-02-03 16:00:49 +01:00
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