Commit Graph

7953 Commits

Author SHA1 Message Date
Kirill Bulatov
a61f2445cb Less stubs 2020-08-11 15:09:08 +03:00
Kirill Bulatov
21e5224484 Custom ranges for missing fields 2020-08-11 15:09:08 +03:00
Kirill Bulatov
26e102a567 Separate diagnostics and diagnostics fix ranges 2020-08-11 15:09:08 +03:00
bors[bot]
e0de247520
Merge #5708
5708: Use Hygiene in completion r=jonas-schievink a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-08-11 10:30:39 +00:00
bors[bot]
ef20dfc78d
Merge #5707
5707: Address some FIXMEs for ra_assists r=jonas-schievink a=JmPotato

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: JmPotato <ghzpotato@gmail.com>
2020-08-11 10:22:57 +00:00
JmPotato
6ef019bd46 Revert some FIXMEs
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-11 17:19:02 +08:00
JmPotato
7fbc9afca4 Typo fix
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-11 16:50:45 +08:00
Laurențiu Nicola
fc01c7846d Use Hygiene in completion 2020-08-11 10:09:50 +03:00
JmPotato
b69dfddb57 Remove redundant dependencies
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-11 14:35:15 +08:00
JmPotato
ace75f9590 Typo fix
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-11 12:09:11 +08:00
JmPotato
dc6e1e0dac Address some FIXMEs
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-11 10:55:26 +08:00
Veetaha
4f386afb16 Log the command flycheck runs to debug misconfigurations
Without this users have no clue why flycheck fails to run.
This is what is printed to the output channel:
```
[ERROR rust_analyzer::main_loop] cargo check failed: Cargo watcher failed,the command produced no valid metadata (exit code: ExitStatus(ExitStatus(25856)))
```

I stumbled with this figuring out that rust-analyzer adds `--all-features` which is not intended
for some crates in the workspace (e.g. they have mutually-exclusive features.
Having the command rust-analyzer ran should help a lot
2020-08-11 03:12:09 +03:00
Jeremy Kolb
cf6d14cee7 Return InvalidRequest if Shutdown has been requested
From the LSP 3.16 spec: "If a server receives requests after a shutdown request those requests should error with InvalidRequest."
2020-08-10 11:03:08 -04:00
Igor Aleksanov
d180b8bbe8 Revert boxing for large enum variant 2020-08-10 15:50:27 +03:00
Paul Daniel Faria
72baf1acdd Remove unused import left behind after rebasing 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
2199d0cda9 Fix type names broken by rebase, redo expected test because of rebase 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
61dff939f9 Move unsafe semantics methods into SemanticsImpl and reference them in Semantics 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
39fdd41df4 Return bool from is_unsafe_method_call and cleanup usages 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
a6af0272f7 Move semantic logic into Semantics, fix missing tag for safe amp operator, using functional methods rather than clunky inline closure 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
87cb09365c Remove merge backup 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
55633f3404 Fix rebase errors 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
08182aa9fa Move unsafe packed ref logic to Semantics, use Attrs::by_key to simplify repr attr lookup 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
c5cc24cb31 Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
aca3d6c57e Deduplicate unsafe method call into a single function 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
d5f11e530d Unsafe borrow of packed fields: account for borrow through ref binding, auto ref function calls 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
38440d53d8 Cleanup repr check, fix packed repr check and test 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
c9e670b875 Update FIXME comment to be more useful 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
4a4b1f48ef Limit scope of unsafe to & instead of all ref exprs, add test showing missing support for autoref behavior 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
fd30134cf8 Remove token tree from ReprKind::Other variant, expose ReprKind higher, remove debug println. 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
263f9a7f23 Add tracking of packed repr, use it to highlight unsafe refs
Taking a reference to a misaligned field on a packed struct is an
unsafe operation. Highlight that behavior. Currently, the misaligned
part isn't tracked, so this highlight is a bit too aggressive.
2020-08-10 08:44:54 -04:00
Igor Aleksanov
6344a7f362 Fix clippy warnings 2020-08-10 15:05:01 +03:00
JmPotato
958b91c1e8 Better codes
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-10 17:51:45 +08:00
JmPotato
4d9c8821e5 Show const body in short_label
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-10 14:02:40 +08:00
bors[bot]
7a03f05eac
Merge #5692
5692: Add support for extern crate r=jonas-schievink a=Nashenas88

This adds syntax highlighting, hover and goto def functionality for extern crate.

Fixes #5690 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-09 23:16:58 +00:00
Paul Daniel Faria
bf9b4578bb Remove Option<...> from result of Crate::root_module
There doesn't seem to be any need for it, and removing it simplies
several paths of code that depend on it.
2020-08-09 18:52:19 -04:00
bors[bot]
b1cb4ac13d
Merge #5693
5693: Fix no inlay hints / unresolved tokens until manual edit to refresh r=jonas-schievink a=Veetaha

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

Now we return ContentModified during the workspace loading. This signifies the language
client to retry the operation (i.e. the client will
continue polling the server while it returns ContentModified).
I believe that there might be cases of overly big projects where the backoff
logic we have setup in `sendRequestWithRetry` (which we use for inlay hints)
might bail too early (currently the largest retry standby time is 10 seconds).
However, I've tried on one of my project with 500+ dependencies and it is still enough.

Here are the examples before/after the change (the gifs are quite lengthy because they show testing rather large cargo workspace).

<details>
<summary>Before</summary>

Here you can see that the client receives empty array of inlay hints and does nothing more.
Same applies to semantic tokens. The client receives unresolved tokens and does nothing more.
The user needs to do a manual edit to refresh the editor.

![prev-demo](https://user-images.githubusercontent.com/36276403/89717721-e4471280-d9c1-11ea-89ce-7dc3e83d9768.gif)

</details>

<details>
<summary>After</summary>

Here the server returns ContentModified, so the client periodically retries the requests and eventually receives the wellformed response.

![new-demo](https://user-images.githubusercontent.com/36276403/89717725-eb6e2080-d9c1-11ea-84c9-796bb2b22cec.gif)

</details>

Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-08-09 22:39:10 +00:00
Veetaha
dbe7ede2ee Let shutdown request to pass through when status == Loading 2020-08-10 00:49:53 +03:00
bors[bot]
9995e79cce
Merge #5414
5414: Fix test code lens r=jonas-schievink a=avrong

Closes #5217

The implementation is quite similar to #4821. Maybe we should somehow deal with duplicated code.

Also, both of these requests introduce some unclear behavior. I'm not sure how to process this, therefore asking for advice. Examples are below.
<img width="286" alt="image" src="https://user-images.githubusercontent.com/6342851/87713209-83595f80-c7b2-11ea-8c0f-a12e7571e7df.png">

Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
2020-08-09 21:23:20 +00:00
JmPotato
3f2bc813d3 format in to_proto::markup_content
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-09 21:33:14 +08:00
Veetaha
e43811c164 Fix no inlay hints / unresolved tokens until manual edit
No we return ContentModified during the workspace loading. This signifies the language
client to retry the operation (i.e. the client will
continue polling the server while it returns ContentModified).
I believe that there might be cases of overly big projects where the backoff
logic we have setup in `sendRequestWithRetry` (which we use for inlay hints)
might bail too early (currently the largest retry standby time is 10 seconds).
However, I've tried on one of my project with 500+ dependencies and it is still enough.
2020-08-08 21:53:38 +03:00
Paul Daniel Faria
6cde0b1aa0 Add support for extern crate
This adds syntax highlighting, hover and goto def
functionality for extern crate
2020-08-08 14:14:18 -04:00
bors[bot]
8a57afe5a4
Merge #5684
5684: Semantic highlighting for unsafe union field access r=jonas-schievink a=Nashenas88

This change adds support for unions in inference and lowering, then extends on that to add the unsafe semantic modifier on field access only. The `is_possibly_unsafe` function in `syntax_highlighting.rs` could be extended to support fns and static muts so that their definitions are not highlighted as unsafe, but only their usage.

Also, each commit of this PR updates the tests. By reviewing the files by commit, it's easy to see how the changes in the code affected the tests.

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-08 16:45:37 +00:00
Paul Daniel Faria
be935b2b56 Apply unsafe semantic highlighting to union field access 2020-08-08 11:29:56 -04:00
Paul Daniel Faria
3bf033e548 Add support for unions in inference and lowering 2020-08-08 11:29:56 -04:00
Paul Daniel Faria
a39d503ef3 Add additional checks for union inference tests 2020-08-08 11:29:50 -04:00
Veetaha
b1ec08e3ff Remove clone 2020-08-08 17:42:50 +03:00
bors[bot]
7a02cc8845
Merge #5679
5679: Account for static mut in missing unsafe diagnostic r=jonas-schievink a=Nashenas88

Accessing or modifying a static mut is an unsafe operation. The "missing unsafe" diagnostic now tracks this.

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-07 12:26:23 +00:00
bors[bot]
911ef38b24
Merge #5678
5678: Static mut unsafe semantic highlighting r=jonas-schievink a=Nashenas88

This marks static mutable names as unsafe, since accessing or modifying a static mut is an unsafe operation.

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-07 12:20:13 +00:00
bors[bot]
ae1197accd
Merge #5674
5674: Update chalk r=matklad a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-08-07 10:32:06 +00:00
Paul Daniel Faria
a6532905a9 Add test for unsafe union field access highlighting 2020-08-06 21:15:31 -04:00
Paul Daniel Faria
f089690a21 Account for static mut in missing unsafe diagnostic 2020-08-06 20:55:29 -04:00
Paul Daniel Faria
8e657f663d Mark static mutable names as unsafe 2020-08-06 20:07:42 -04:00
Paul Daniel Faria
6be528da0d Add test for accessing static mut 2020-08-06 19:58:37 -04:00
Jeremy Kolb
4591bd458d Update chalk 2020-08-05 22:24:23 -04:00
bors[bot]
f1d507270c
Merge #5526
5526: Handle semantic token deltas r=kjeremy a=kjeremy

This basically takes the naive approach where we always compute the tokens but save space sending over the wire which apparently solves some GC problems with vscode.

This is waiting for https://github.com/gluon-lang/lsp-types/pull/174 to be merged. I am also unsure of the best way to stash the tokens into `DocumentData` in a safe manner.

Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-08-06 01:44:38 +00:00
Jeremy Kolb
195111d769 Address PR comments 2020-08-05 21:35:35 -04:00
bors[bot]
2cb079ba9a
Merge #5672
5672: align names in make

 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-05 22:29:27 +00:00
bors[bot]
ed4687f698
Merge #5639
5639: SSR: Allow `self` in patterns. r=jonas-schievink a=davidlattimore

It's now consistent with other variables in that if the pattern references self, only the `self` in scope where the rule is invoked will be accepted. Since `self` doesn't work the same as other paths, this is implemented by restricting the search to just the current function. Prior to this change (since path resolution was implemented), having self in a pattern would just result in no matches.

Co-authored-by: David Lattimore <dml@google.com>
2020-08-05 22:07:35 +00:00
David Lattimore
3eea41a68c Use SyntaxNode.ancestors instead of a loop 2020-08-06 07:36:03 +10:00
Aleksey Kladov
09d3b7d7a2 align names in make 2020-08-05 19:37:26 +02:00
bors[bot]
5ebf92cd0e
Merge #5648
5648: Add expand glob import assist r=jonas-schievink a=unexge

closes https://github.com/rust-analyzer/rust-analyzer/issues/5557

Co-authored-by: unexge <unexge@gmail.com>
2020-08-05 17:05:07 +00:00
bors[bot]
32246b91c2
Merge #5664
5664: Fix renamed self module. r=jonas-schievink a=Nashenas88

Fixes #5663 

Now `inner_mod` below is properly marked as a `module`.
```rust
use crate::inner::{self as inner_mod};
mod inner {}
```

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-05 16:56:39 +00:00
Aleksey Kladov
edd4a83ee3 Use salsa's purge to account for all memory 2020-08-05 15:28:20 +02:00
Aleksey Kladov
ffe4a5e114 Fix relative path handling for custom rustfmt
`current_dir` and relative paths to executables works differently on
unix and windows (unix behavior does not make sense), see:

17e30e83a1/src/lib.rs (L295-L324)

The original motivation to set cwd was to make rustfmt read the
correct rustfmt.toml, but that was future proofing, rather than a bug
fix.

So, let's just remove this and see if breaks or fixes more use-cases.

If support for per-file config is needed, we could use `--config-path`
flag.
2020-08-05 13:20:36 +02:00
unexge
6cb090345e Pattern match on slice elements instead of using .first().unwrap() 2020-08-05 13:25:26 +03:00
unexge
5214b4cdba Look for trait methods in expand glob import assist 2020-08-05 11:29:00 +03:00
Paul Daniel Faria
4e2e3543c7 When resolving a rename, fallback to the name higher in the use tree if the path segment is self 2020-08-04 09:28:40 -04:00
Paul Daniel Faria
cc3eb85311 Add test showing unresolved module rename 2020-08-04 09:26:38 -04:00
bors[bot]
af6e9a7eb3
Merge #5658
5658: do not add to `pub use` in assists that insert a use statement r=jonas-schievink a=jbr

closes #5657 , see issue for rationale

Initially I wrote a version of this that changed the signature of `insert_use_statement` to take an `Option<VisibilityKind>` and only add to use statements with the same visibility, but that didn't make sense for any of the current uses of `insert_use_statement` (they all expected private visibility).

Co-authored-by: Jacob Rothstein <hi@jbr.me>
2020-08-04 12:47:11 +00:00
Michael Lazear
2e72e74dbd Revert "Restore line index micro-optimization"
This reverts commit 83a87fcd11.
2020-08-03 13:35:32 -07:00
Jacob Rothstein
03a61134f2
do not add to pub use statements 2020-08-03 12:17:05 -07:00
bors[bot]
33e53d4721
Merge #5653
5653: Fold trait declarations r=SomeoneToIgnore a=lnicola

Fixes #5652

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-08-03 17:25:26 +00:00
Laurențiu Nicola
f1bbc776c0 Fold trait declarations 2020-08-03 15:45:39 +03:00
bors[bot]
f17d2d1289
Merge #5628
5628: Rename test modules r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-08-03 11:47:56 +00:00
unexge
bdb97756ca Simplify find_mod_path with use of node.ancestors 2020-08-03 13:04:20 +03:00
unexge
544322e66a Generate doctest 2020-08-02 23:07:56 +03:00
unexge
a05a2ab1bb Rename ast::UseItem to ast::Use 2020-08-02 23:07:36 +03:00
unexge
edd79a6b1c Add expand glob import assist 2020-08-02 22:56:54 +03:00
Aleksei Trifonov
85d5ed3675 Fix test code lens 2020-08-02 13:53:34 +03:00
bors[bot]
e4d0f19b01
Merge #5638
5638: Simplify argument parsing r=matklad a=lnicola

and use `Display` when printing errors.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-08-01 16:47:51 +00:00
Laurențiu Nicola
562491b16b Simplify argument parsing 2020-08-01 19:31:14 +03:00
Aleksey Kladov
bff8dd0949 Update grammar 2020-08-01 13:47:19 +02:00
David Lattimore
6bbeffc8c5 SSR: Allow self in patterns.
It's now consistent with other variables in that if the pattern
references self, only the `self` in scope where the rule is invoked will
be accepted. Since `self` doesn't work the same as other paths, this is
implemented by restricting the search to just the current function.
Prior to this change (since path resolution was implemented), having
self in a pattern would just result in no matches.
2020-08-01 17:41:42 +10:00
David Lattimore
21d2cebcf1 SSR: Matching trait associated constants, types and functions
This fixes matching of things like `HashMap::default()` by resolving
`HashMap` instead of `default` (which resolves to `Default::default`).

Same for associated constants and types that are part of a trait
implementation.

However, we still don't support matching calls to trait methods.
2020-08-01 12:55:26 +10:00
kjeremy
fcfd7cb1e3 Handle semantic token deltas 2020-07-31 20:57:53 -04:00
Aleksey Kladov
8cf19847dd Finish rename 2020-07-31 22:04:12 +02:00
Aleksey Kladov
b9c6aa9ec9 Unify naming of tuple fields 2020-07-31 22:04:12 +02:00
Aleksey Kladov
22d295ceaa Rename DotDotPat -> RestPat 2020-07-31 21:45:29 +02:00
Aleksey Kladov
af53d5f4b0 Rename 2020-07-31 20:23:52 +02:00
Aleksey Kladov
81359af733 Simplify trait gramamr 2020-07-31 20:22:20 +02:00
Aleksey Kladov
9818108798 Rename BindPat -> IdentPat 2020-07-31 20:12:10 +02:00
Aleksey Kladov
6791eb9685 Rename PalceholderPat -> WildcardPat 2020-07-31 20:07:21 +02:00
Aleksey Kladov
d7f75db90d Reorder 2020-07-31 20:04:40 +02:00
Aleksey Kladov
14cb96ec0e Allign RecordPat with RecordExpr 2020-07-31 20:00:48 +02:00
Aleksey Kladov
572f1c08b6 Minor gramamr reorder 2020-07-31 19:49:26 +02:00
bors[bot]
5cade89d73
Merge #5630
5630: Remove dead code r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-31 16:56:57 +00:00
Aleksey Kladov
45e6052406 Remove dead code 2020-07-31 18:53:10 +02:00
Aleksey Kladov
c1c97b2896 Fix leading colon 2020-07-31 18:49:42 +02:00
Aleksey Kladov
ddf08daddf Fix const arguments grammar 2020-07-31 18:46:07 +02:00
Aleksey Kladov
040b4c800d Fix GenericArgs grammar 2020-07-31 18:41:37 +02:00