Commit Graph

10604 Commits

Author SHA1 Message Date
vsrs
b91fa7494e Fix Run lens. 2020-06-06 15:12:17 +03:00
bors[bot]
a609336d72
Merge #4765
4765: Fix type parameter defaults r=matklad a=flodiebold

They should not be applied in expression or pattern contexts, unless there are other explicitly given type args.

(The existing tests about this were actually wrong.)

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-06 10:56:59 +00:00
Florian Diebold
a4a4a1854e Fix type parameter defaults
They should not be applied in expression or pattern contexts, unless there are
other explicitly given type args.
2020-06-05 20:09:13 +02:00
bors[bot]
02f7b5d7ab
Merge #4761
4761: Upgrade Chalk to published version r=matklad a=flodiebold

CC @pksunkara 

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-05 16:05:06 +00:00
bors[bot]
2a3ab7f3b4
Merge #4689
4689: Implement return position impl trait / opaque type support r=matklad a=flodiebold

This is working, but I'm not that happy with how the lowering works. We might need an additional representation between `TypeRef` and `Ty` where names are resolved and `impl Trait` bounds are separated out, but things like inference variables don't exist and `impl Trait` is always represented the same way.

Also note that this doesn't implement correct handling of RPIT *inside* the function (which involves turning the `impl Trait`s into variables and creating obligations for them). That intermediate representation might help there as well.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-05 15:46:28 +00:00
Florian Diebold
0d2328f3ea Review fixes 2020-06-05 17:41:58 +02:00
bors[bot]
f133159ec0
Merge #4760
4760: Minimize FileLoader interface r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-05 15:23:22 +00:00
Aleksey Kladov
bbb40d7463 Minimize FileLoader interface 2020-06-05 17:22:56 +02:00
bors[bot]
4029628f15
Merge #4729 #4748
4729: Hover actions r=matklad a=vsrs

This PR adds a `hoverActions` LSP extension and a `Go to Implementations` action as an example:
![hover_actions_impl](https://user-images.githubusercontent.com/62505555/83335732-6d9de280-a2b7-11ea-8cc3-75253d062fe0.gif)



4748: Add an `ImportMap` and use it to resolve item paths in `find_path` r=matklad a=jonas-schievink

Removes the "go faster" queries I added in https://github.com/rust-analyzer/rust-analyzer/pull/4501 and https://github.com/rust-analyzer/rust-analyzer/pull/4506. I've checked this PR on the rustc code base and the assists are still fast.

This should fix https://github.com/rust-analyzer/rust-analyzer/issues/4515.

Note that this does introduce a change in behavior: We now always refer to items defined in external crates using paths through the external crate. Previously we could also use a local path (if for example the extern crate was reexported locally), as seen in the changed test. If that is undesired I can fix that, but the test didn't say why the previous behavior would be preferable.

Co-authored-by: vsrs <vit@conrlab.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-05 15:14:35 +00:00
Florian Diebold
02962b374e Implement return position impl trait / opaque type support
This is working, but I'm not that happy with how the lowering works. We might
need an additional representation between `TypeRef` and `Ty` where names are
resolved and `impl Trait` bounds are separated out, but things like inference
variables don't exist and `impl Trait` is always represented the same
way.

Also note that this doesn't implement correct handling of RPIT *inside* the
function (which involves turning the `impl Trait`s into variables and creating
obligations for them). That intermediate representation might help there as
well.
2020-06-05 17:08:27 +02:00
Florian Diebold
69854f7795 Upgrade Chalk to published version 2020-06-05 17:06:07 +02:00
bors[bot]
9c52f527a1
Merge #4758
4758: Actually test include!(concant!(env!())); r=matklad a=matklad

It triggered index-based goto definition before :-(



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-05 13:51:35 +00:00
Aleksey Kladov
c9a41bd92d Actually test include!(concant!(env!()));
It triggered index-based goto definition before :-(
2020-06-05 15:49:12 +02:00
bors[bot]
54d6bd5c00
Merge #4757
4757: Update inotify r=matklad a=matklad

https://github.com/rust-analyzer/rust-analyzer/issues/4224#issuecomment-639328191



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-05 13:34:44 +00:00
Aleksey Kladov
d103d4b071 Update inotify
https://github.com/rust-analyzer/rust-analyzer/issues/4224#issuecomment-639328191
2020-06-05 15:33:55 +02:00
bors[bot]
d06df2c3e7
Merge #4756
4756: Cleanup resolution of file paths r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-05 13:15:31 +00:00
Aleksey Kladov
cb9d9040f7 Cleanup test 2020-06-05 15:14:47 +02:00
Aleksey Kladov
bba374bab2 More direct signature for resolve_path 2020-06-05 15:07:30 +02:00
Aleksey Kladov
e63c00f100 Rename resolve_relative_path -> resolve_path
For things like `concant!(env!("OUT_DIR"))`, we need to support abs paths
2020-06-05 14:58:30 +02:00
vsrs
bd9d7b6ad8 Remove hover actions heavy tests. 2020-06-05 15:26:46 +03:00
vsrs
78c9223b7b Remove hover contents marking as trusted.
Hover contents might be extracted from raw
doc comments and need some validation.
2020-06-05 15:25:01 +03:00
Jonas Schievink
bc2d172995 Clarify when we visit modules multiple times 2020-06-05 14:24:51 +02:00
bors[bot]
f98d057218
Merge #4755
4755: Inlay Hints: more directly account for self param r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-05 12:01:10 +00:00
vsrs
0fe43a124b Add capabilities tests. 2020-06-05 15:00:31 +03:00
vsrs
e35418ceb9 Apply suggestions from @kjeremy review 2020-06-05 15:00:31 +03:00
vsrs
92cfc0f2a1 Add enum hover action test. 2020-06-05 15:00:31 +03:00
vsrs
5d0c1aa162 Rebase on the latest master. 2020-06-05 15:00:30 +03:00
vsrs
b147e6eb95 Code formatting 2020-06-05 15:00:30 +03:00
vsrs
da7ec4b339 Add hover actions LSP extension documentation. 2020-06-05 15:00:28 +03:00
vsrs
7d0dd17b09 Add hover actions as LSP extension 2020-06-05 14:59:26 +03:00
Aleksey Kladov
522d24a607 Inlay Hints: more directly account for self param 2020-06-05 13:58:52 +02:00
Jonas Schievink
2fb3d87bf7 impl Debug for ImportMap 2020-06-05 13:36:19 +02:00
Mikhail Rakhmanov
5dda995538 Fix review comments 2020-06-05 13:17:17 +02:00
Jonas Schievink
8395396782 Reorder imports 2020-06-05 13:15:16 +02:00
Jonas Schievink
5f23f8ca44 Make find_path_inner private again 2020-06-05 13:11:53 +02:00
Jonas Schievink
f085e592fe Measure memory usage of ImportMap 2020-06-05 13:10:43 +02:00
Jonas Schievink
86fbd8cc2b defining_crate -> krate 2020-06-05 13:05:19 +02:00
Jonas Schievink
e0e9c6d1a4 Fix wrong comment 2020-06-05 13:04:35 +02:00
Mikhail Rakhmanov
74c3e7a1ad Remove unnecessary return 2020-06-05 11:45:41 +02:00
bors[bot]
913a623281
Merge #4750
4750: introduce_named_lifetime assist wasn't applicable when type parameter r=matklad a=jbalint

followed anonymous lifetime token

(fixes #4684)

Co-authored-by: Jess Balint <jbalint@gmail.com>
2020-06-05 07:56:11 +00:00
Jess Balint
921306757b introduce_named_lifetime assist wasn't applicable when type parameter
followed anonymous lifetime token

(fixes #4684)
2020-06-04 17:31:21 -05:00
bors[bot]
e66c7b3a45
Merge #4737
4737: Parse default unsafe & default const r=matklad a=Avi-D-coder

Closes: #4718 #4264

Co-authored-by: Avi Dessauer <avi.the.coder@gmail.com>
2020-06-04 17:51:03 +00:00
Jonas Schievink
3c496f7fa7 Use ImportMap in find_path, remove old queries 2020-06-04 19:33:01 +02:00
Jonas Schievink
d08c63cb9e Add an ImportMap 2020-06-04 19:33:01 +02:00
Avi Dessauer
c4fd463981 Move default const test out of line 2020-06-04 13:06:57 -04:00
Avi Dessauer
3ec2dcfc0d Address review 2020-06-04 13:00:21 -04:00
bors[bot]
c19496f845
Merge #4740
4740: Remove unneeded "./" prefix affecting error messages r=kjeremy a=dtolnay

I noticed this in the error in the commit message of https://github.com/rust-analyzer/rust-analyzer/pull/4739.

Before:

```console
error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/./src/bin/main.rs:99:16
   |
99 |     connection.initialize_finish(initialize_id, initialize_result)?;
   |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
```

After:

```console
error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/src/bin/main.rs:99:16
   |
99 |     connection.initialize_finish(initialize_id, initialize_result)?;
   |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
```

```diff
-   --> crates/rust-analyzer/./src/bin/main.rs:99:16
+   --> crates/rust-analyzer/src/bin/main.rs:99:16
```

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-06-04 13:04:24 +00:00
bors[bot]
a1ca1e7598
Merge #4739
4739: Declare required lsp-server dependency of rust-analyzer crate r=jonas-schievink a=dtolnay

My codebase already depended on lsp-server and introducing a dependency on rust-analyzer failed at first because it assumes some functions that were first present in lsp-server 0.3.2.

Without this change:

```console
error[E0599]: no method named `initialize_start` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/./src/bin/main.rs:83:57
   |
83 |     let (initialize_id, initialize_params) = connection.initialize_start()?;
   |                                                         ^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`

error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/./src/bin/main.rs:99:16
   |
99 |     connection.initialize_finish(initialize_id, initialize_result)?;
   |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
```

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-06-04 10:45:06 +00:00
bors[bot]
06638ff848
Merge #4741
4741: Fix type inference failure when built with log/kv_unstable r=flodiebold a=dtolnay

This code is broken by an `impl From<kv::Error> for fmt::Error` in the log crate when building in a codebase that has the log/kv_unstable feature enabled.

```console
$ cargo check --manifest-path crates/ra_hir_def/Cargo.toml
    Checking ra_hir_def v0.1.0
    Finished dev [unoptimized] target(s) in 0.75s

$ cargo check --manifest-path crates/ra_hir_def/Cargo.toml --features log/kv_unstable
    Checking ra_hir_def v0.1.0
error[E0282]: type annotations needed for the closure `fn(&str) -> std::result::Result<(), _>`
   --> crates/ra_hir_def/src/path.rs:278:17
    |
278 |                 f.write_str("::")?;
    |                 ^^^^^^^^^^^^^^^^^^ cannot infer type
    |
help: give this closure an explicit return type without `_` placeholders
    |
276 |         let mut add_segment = |s| -> std::result::Result<(), _> {
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

https://github.com/rust-lang/log/issues/397

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-06-04 08:09:56 +00:00
Mikhail Rakhmanov
b0c8a2be7b Remove AsName import 2020-06-04 10:03:44 +02:00