Commit graph

8565 commits

Author SHA1 Message Date
Lukas Wirth
d86863aeb4 Rewrite algo::diff to support insertion and deletion 2020-10-22 09:51:11 +02:00
Jeremy Kolb
f64f569483 Update crates
This brings in a number of new dependencies though.
2020-10-20 17:36:02 -04:00
Benjamin Coenen
aa031e91f4 add completions for clippy lint in attributes
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-20 21:29:31 +02:00
bors[bot]
c00339509d
Merge #6256
6256: Assist: replace string with char r=bnjjj a=bnjjj

close #6252 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2020-10-20 19:03:25 +00:00
Coenen Benjamin
9883435e4e
Update crates/assists/src/handlers/replace_string_with_char.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-20 20:07:39 +02:00
bors[bot]
989de9e309
Merge #6172
6172: Add qualify path assist r=matklad a=Veykril

This implements a `qualify_path` assist which works quite similar to the `auto_import` assist but instead of adding imports to the file it well, qualifies the path. This PR also moves out the `AutoImportAssets` struct and functions from `auto_import` into a utils submodule as most of this is now shared between `auto_import` and `qualify_path`.

Changes made to `AutoImportAssets` are solely in its `search_for_imports` function which now takes a prefixed parameter to discern between using `find_use_path_prefixed` and `find_use_path` as the former is the required behavior by `auto_import` and the latter by this assist.

For missing imported traits instead of importing this will qualify the path with a trait cast as in:
```rust
test_mod::TestStruct::TEST_CONST<|>
```
becomes
```rust
<test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST
```

and for trait methods ideally it would do the following:
```rust
let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od()
```
becomes
```rust
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method(&test_struct)
```

Fixes #4124.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-20 17:03:19 +00:00
bors[bot]
20d369a826
Merge #6299
6299: Diagnose items that are #[cfg]d out r=jonas-schievink a=jonas-schievink

This emits a hint-level diagnostic with `Unnecessary` tag to "gray out" any items whose `#[cfg]` attributes remove the item before name resolution.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-10-20 16:35:05 +00:00
Jonas Schievink
74ac83a5ac Fixup botched rename 2020-10-20 18:29:47 +02:00
Jonas Schievink
3fa04f35d2 More detailed message 2020-10-20 18:23:55 +02:00
Jonas Schievink
4cb3cf352f Rename UnconfiguredCode -> InactiveCode 2020-10-20 18:22:31 +02:00
Aleksey Kladov
a3a8ad8bc4 Don't rely on display names in inlay_hints 2020-10-20 18:14:14 +02:00
Jonas Schievink
80d2741401 Add a (hint) diagnostic for unconfigured items 2020-10-20 17:53:04 +02:00
Jonas Schievink
a54e481646 Simplify diagnostic construction, add unused field 2020-10-20 17:53:04 +02:00
Aleksey Kladov
f753c3ecd2 Support Display name in project.json 2020-10-20 17:13:15 +02:00
Aleksey Kladov
3b1a648539 More type safety around names 2020-10-20 17:09:03 +02:00
Aleksey Kladov
a85c4280bf Introduce CrateDisplayName 2020-10-20 16:00:51 +02:00
Benjamin Coenen
c22c039578 Assist: replace string with char
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-20 15:57:50 +02:00
Aleksey Kladov
af4e75533f Rename declaration_name -> display_name
Declaration names sounds like a name of declaration -- something you
can use for analysis. It empathically isn't, and is just a label
displayed in various UI. It's important not to confuse the two, least
we accidentally mix semantics with UI (I believe, there's already a
case of this in the FamousDefs at least).
2020-10-20 15:38:11 +02:00
bors[bot]
be762ccccd
Merge #6294
6294: Add a hacky remidy for #6038 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-20 10:36:28 +00:00
Aleksey Kladov
7a21e9302e Add a hacky remidy for #6038
The proper fix I think is:

* move rust-lang/rust library crates to a separate workspace
* when packaging rust-src component, vendor sources of external deps
2020-10-20 12:34:39 +02:00
Igor Aleksanov
2a20e7795c Add descriptions for diagnostics parseable by xtask 2020-10-19 20:55:16 +03:00
Aleksey Kladov
4fbb602b2d Minor, rename feature 2020-10-19 15:53:48 +02:00
Aleksey Kladov
8421115354 Try to fix publishing
This errro specifically:

Updating crates.io index
	 error: failed to select a version for the requirement `ra_ap_stdx = "^0.0.0"`
	 candidate versions found which didn't match: 0.0.20
	 location searched: /home/runner/work/rust-analyzer/rust-analyzer/crates/stdx
	 required by package `ra_ap_completion v0.0.20 (/home/runner/work/rust-analyzer/rust-analyzer/crates/completion)`
	 error: unable to update Cargo.lock
	 Error: Process completed with exit code 1.
2020-10-19 15:18:28 +02:00
Aleksey Kladov
604caedeb2 Change visibility works for type aliases 2020-10-18 17:04:12 +02:00
Igor Aleksanov
9e7c952bbd Extract call_info and completion into separate crates 2020-10-18 13:09:00 +03:00
Aleksey Kladov
6c7769a2e3 update deps 2020-10-18 01:53:01 +02:00
Aleksey Kladov
13451d3dc4 Complete methods when receiver is a macro 2020-10-17 23:43:13 +02:00
Aleksey Kladov
4fe4c30436 Improve readability 2020-10-17 23:35:21 +02:00
Igor Aleksanov
99c435939c Scan all ancestors for the impl trait block check 2020-10-17 11:17:58 +03:00
Igor Aleksanov
6f573bd84f Allow hints after 'fn' keyword if it's an impl trait block 2020-10-17 11:03:07 +03:00
Igor Aleksanov
8f303daf45 Add test for new pattern functions 2020-10-17 10:56:00 +03:00
Igor Aleksanov
6ae4c70a0a Improve test_no_completions_required test 2020-10-17 10:47:35 +03:00
Igor Aleksanov
70157f07d9 Remove redundant completions 2020-10-17 10:27:59 +03:00
Benjamin Coenen
62192cede3 replace_string_with_char #6252
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-16 20:21:16 +02:00
Lukas Wirth
1d612a6ec4 De-duplicate add_group callsite in qualify_path 2020-10-16 16:04:00 +02:00
bors[bot]
1af6275f20
Merge #6246
6246: Follow symlinks when walking project trees r=lnicola a=dfoxfranke

Fixes #3691.

~~WIP pending further testing~~:

- [X] Verify that symlinked files get indexed.
- [x] Verify that files in symlinked directories get indexed.
- [x] Verify that inotify events are properly received and handled when the target of a symlink resides outside the project tree.

Co-authored-by: Daniel Fox Franke <dfoxfranke@gmail.com>
2020-10-16 12:53:10 +00:00
Daniel Fox Franke
e821aa842b Follow symlinks when walking project trees
Fixes #3691
2020-10-15 14:22:36 -04:00
bors[bot]
0d45802d67
Merge #6220
6220: implement binary operator overloading type inference r=flodiebold a=ruabmbua

Extend type inference of *binary operator expression*, by adding support for operator overloads.

Before this merge request, the type inference of binary expressions could only resolve operations done on built-in primitive types. This merge requests adds a code path, which is executed in case the built-in inference could not get any results. It resolves the proper operator overload trait in *core::ops* via lang items, and then resolves the associated *Output* type.

```rust
struct V2([f32; 2]);

#[lang = "add"]
pub trait Add<Rhs = Self> {
    /// The resulting type after applying the `+` operator.
    type Output;

    /// Performs the `+` operation.
    #[must_use]
    fn add(self, rhs: Rhs) -> Self::Output;
}

impl Add<V2> for V2 {
    type Output = V2;

    fn add(self, rhs: V2) -> V2 {
        let x = self.0[0] + rhs.0[0];
        let y = self.0[1] + rhs.0[1];
        V2([x, y])
    }
}

fn test() {
    let va = V2([0.0, 1.0]);
    let vb = V2([0.0, 1.0]);

    let r = va + vb; // This infers to V2 now
}
```

There is a problem with operator overloads, which do not explicitly set the *Rhs* type parameter in the respective impl block. 

**Example:**

```rust
impl Add for V2 {
    type Output = V2;

    fn add(self, rhs: V2) -> V2 {
        let x = self.0[0] + rhs.0[0];
        let y = self.0[1] + rhs.0[1];
        V2([x, y])
    }
}
```

In this case, the trait solver does not realize, that the *Rhs* type parameter is actually self in the context of the impl block. This stops type inference in its tracks, and it can not resolve the associated *Output* type.

I guess we can still merge this back, because it increases the amount of resolved types, and does not regress anything (in the tests).

Somewhat blocked by https://github.com/rust-analyzer/rust-analyzer/issues/5685
Resolves  https://github.com/rust-analyzer/rust-analyzer/issues/5544

Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
2020-10-15 18:02:27 +00:00
Lukas Wirth
bc11475a2a Properly qualify trait methods in qualify_path assist 2020-10-15 18:31:33 +02:00
Aleksey Kladov
c5868a4879 Clarify the names one more time 2020-10-15 17:38:51 +02:00
Aleksey Kladov
56e67e3a39 More idiomatic classification API 2020-10-15 17:38:17 +02:00
Aleksey Kladov
f9c1336873 More clarifications 2020-10-15 17:37:55 +02:00
Aleksey Kladov
bc287b8f9b Unconfuse expression and pattern field init shorthands 2020-10-15 17:37:36 +02:00
Aleksey Kladov
fa3c449d8f Clarify NameClass names a bit 2020-10-15 17:37:36 +02:00
bors[bot]
7fadc78ebb
Merge #6242
6242: Diagnost shorthand in patterns r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-15 15:11:36 +00:00
Aleksey Kladov
3086fb2ef4 Move field_shorthand to a separate module 2020-10-15 17:10:06 +02:00
Aleksey Kladov
1022672af0 Diagnose shorthand in patterns as well 2020-10-15 17:03:52 +02:00
Aleksey Kladov
e9903a91cd flatten 2020-10-15 16:51:55 +02:00
Aleksey Kladov
c8cbd398e4 Prepare for pat_field_shorthand 2020-10-15 16:48:25 +02:00
bors[bot]
8090799aa2
Merge #6234
6234: Fix hover over field pattern shorthand r=matklad a=Vlad-Shcherbina

Instead of the information about the field, it now shows the information
about the local.

Fixes #6146

Co-authored-by: Vlad Shcherbina <vlad.shcherbina@gmail.com>
2020-10-15 13:09:27 +00:00