]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoTry to detect musl distros in the Code extension
Laurențiu Nicola [Sat, 20 Feb 2021 16:39:26 +0000 (18:39 +0200)]
Try to detect musl distros in the Code extension

3 years agoMerge #7727
bors[bot] [Sat, 20 Feb 2021 15:31:59 +0000 (15:31 +0000)]
Merge #7727

7727: Remove documentation of obsolete extend selection command r=matklad a=lnicola

Closes #7454

This is available in LSP as `textDocument/selectionRange` and no longer exists as a stand-alone command, so we shouldn't mention it in the manual because it's confusing (it doesn't appear in `package.json`).

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoRemove documentation of obsolete extend selection command
Laurențiu Nicola [Sat, 20 Feb 2021 15:06:00 +0000 (17:06 +0200)]
Remove documentation of obsolete extend selection command

3 years agoMerge #7726
bors[bot] [Sat, 20 Feb 2021 14:18:34 +0000 (14:18 +0000)]
Merge #7726

7726: feat(completion): add doc(hidden) completion for attributes r=lnicola a=bnjjj

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
3 years agofeat(completion): add doc(hidden) completion for attributes
Benjamin Coenen [Sat, 20 Feb 2021 14:16:05 +0000 (15:16 +0100)]
feat(completion): add doc(hidden) completion for attributes

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
3 years agoMerge #7725
bors[bot] [Sat, 20 Feb 2021 14:07:19 +0000 (14:07 +0000)]
Merge #7725

7725: fix(assist): display where predicates when we want to generate impl r=lnicola a=bnjjj

close #7721

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
3 years agofix(assist): display where predicates when we want to generate impl
Benjamin Coenen [Sat, 20 Feb 2021 14:05:01 +0000 (15:05 +0100)]
fix(assist): display where predicates when we want to generate impl

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
3 years agoMerge #7724
bors[bot] [Sat, 20 Feb 2021 11:55:17 +0000 (11:55 +0000)]
Merge #7724

7724: Consider import prefix config settings during flyimports r=SomeoneToIgnore a=SomeoneToIgnore

Fixes #7666

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoConsider import prefix config settings during flyimports
Kirill Bulatov [Sat, 20 Feb 2021 11:53:50 +0000 (13:53 +0200)]
Consider import prefix config settings during flyimports

3 years agoMerge #7723
bors[bot] [Sat, 20 Feb 2021 11:03:15 +0000 (11:03 +0000)]
Merge #7723

7723: Fix typos r=lnicola a=azzamsa

I have checked all the documents inside `docs/` using `grammarly.com`.
There are many suggestions in each document (some of them are false positive). I choose to fix the typos only to avoid lengthy grammar discussions. I would like to suggest to the maintainers to take a look. It is worth it.

IMHO, it better to put the article into `grammarly.com` or `languagetool.org` before pushing :).

Co-authored-by: azzamsa <me@azzamsa.com>
3 years agoFix typos
azzamsa [Sat, 20 Feb 2021 10:53:19 +0000 (17:53 +0700)]
Fix typos

3 years agoMerge #7722
bors[bot] [Sat, 20 Feb 2021 10:49:12 +0000 (10:49 +0000)]
Merge #7722

7722: Fix incorrect missing field diagnostic with box patterns r=Veykril a=lnicola

Closes #7711

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoAdd test
Laurențiu Nicola [Sat, 20 Feb 2021 10:43:52 +0000 (12:43 +0200)]
Add test

3 years agoFix incorrect missing field diagnostic with box patterns
Laurențiu Nicola [Sat, 20 Feb 2021 10:36:17 +0000 (12:36 +0200)]
Fix incorrect missing field diagnostic with box patterns

3 years agoMerge #7707
bors[bot] [Wed, 17 Feb 2021 14:54:55 +0000 (14:54 +0000)]
Merge #7707

7707: rename completion -> ide_completion r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agorename completion -> ide_completion
Aleksey Kladov [Wed, 17 Feb 2021 14:53:31 +0000 (17:53 +0300)]
rename completion -> ide_completion

We don't have completion-related PRs in flight, so lets do it

3 years agoMerge #7706
bors[bot] [Wed, 17 Feb 2021 14:02:07 +0000 (14:02 +0000)]
Merge #7706

7706: Revert "Replace usage of ast::NameOrNameRef with ast::NameLike" r=Veykril a=Veykril

This reverts commit e1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoRevert "Replace usage of ast::NameOrNameRef with ast::NameLike"
Lukas Wirth [Wed, 17 Feb 2021 14:00:44 +0000 (15:00 +0100)]
Revert "Replace usage of ast::NameOrNameRef with ast::NameLike"

This reverts commit e1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979.

3 years agoMerge #7699
bors[bot] [Wed, 17 Feb 2021 13:45:27 +0000 (13:45 +0000)]
Merge #7699

7699: Implement ast::AstNode for NameLike and move it to node_ext r=matklad a=Veykril

With this `search`(and 2 other modules) don't necessarily go through 3 calls of `find_node_at_offset_with_descend` to find the correct node. Also makes the code that searches for NameLikes a bit easier on the eyes imo, though that can be fixed with just a helper function as well so its not that relevant.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7705
bors[bot] [Wed, 17 Feb 2021 13:17:15 +0000 (13:17 +0000)]
Merge #7705

7705: Show hover info of the definition of ConstReference patterns instead of its type r=Veykril a=Veykril

Closes #7671
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoShow hover info of the definition of ConstReference patterns instead of its type
Lukas Wirth [Wed, 17 Feb 2021 13:14:58 +0000 (14:14 +0100)]
Show hover info of the definition of ConstReference patterns instead of its type

3 years agoReplace usage of ast::NameOrNameRef with ast::NameLike
Lukas Wirth [Wed, 17 Feb 2021 13:02:34 +0000 (14:02 +0100)]
Replace usage of ast::NameOrNameRef with ast::NameLike

3 years agoMerge #7704
bors[bot] [Wed, 17 Feb 2021 11:58:35 +0000 (11:58 +0000)]
Merge #7704

7704: Avoid transmitting unchanged diagnostics r=matklad a=michalmuskala

Reading through the code for diagnostics and observing debug logs, I noticed
that diagnostics are transmitted after every change for every opened file,
even if they haven't changed (especially visible for files with no diagnostics).

This change avoids marking files as "changed" if diagnostics are the same to what
was already sent before. This will only work if diagnostics are always produced in
the same order, but from my limited testing it seems this is the case.

Co-authored-by: Michał Muskała <michal@muskala.eu>
3 years agoAvoid transmitting unchanged diagnostics
Michał Muskała [Wed, 17 Feb 2021 11:38:11 +0000 (12:38 +0100)]
Avoid transmitting unchanged diagnostics

Reading through the code for diagnostics and observing debug logs, I noticed
that diagnostics are transmitted after every change for every opened file,
even if they haven't changed (especially visible for files with no diagnostics).

This change avoids marking files as "changed" if diagnostics are the same to what
was already sent before. This will only work if diagnostics are always produced in
the same order, but from my limited testing it seems this is the case.

3 years agoMerge #7701
bors[bot] [Wed, 17 Feb 2021 09:43:13 +0000 (09:43 +0000)]
Merge #7701

7701: Remove semantic tokens workaround r=SomeoneToIgnore a=kjeremy

Let's try this again.

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoMerge #7703
bors[bot] [Wed, 17 Feb 2021 01:24:25 +0000 (01:24 +0000)]
Merge #7703

7703: Allow comments between newlines in chaining hints r=Veykril a=unratito

Currently, chaining hints are not generated if there are comments between newlines, which is a very common pattern:

```rust
let vec = (0..10)
    // Multiply by 2
    .map(|x| x * 2)
    // Add 3
    .map(|x| x + 3)
    .collect::<Vec<i32>>();
```

Besides, it seems a bit weird that this piece of code generates a chaining hint:

```rust
let vec = (0..10)

    .collect::<Vec<i32>>();
```

But this one doesn't:

```rust
let vec = (0..10)

    // This is a comment

    .collect::<Vec<i32>>();
```

Co-authored-by: Paco Soberón <unratito@gmail.com>
3 years agoMerge #7702
bors[bot] [Wed, 17 Feb 2021 01:02:21 +0000 (01:02 +0000)]
Merge #7702

7702: Remove use of deprecated `std::collections::Bound` r=Veykril a=bstrie

`std::collections::Bound` has been deprecated since Rust 1.26, but due to a bug (https://github.com/rust-lang/rust/issues/82080) it never triggered a visible deprecation warning. Fixing this is being done in https://github.com/rust-lang/rust/pull/82122 , but landing that requires rustc-analyzer to build without triggering any deprecation warnings (https://github.com/rust-lang-ci/rust/runs/1911884006#step:24:19361).

Co-authored-by: bstrie <865233+bstrie@users.noreply.github.com>
3 years agoRemove use of deprecated `std::collections::Bound`
bstrie [Tue, 16 Feb 2021 23:22:14 +0000 (18:22 -0500)]
Remove use of deprecated `std::collections::Bound`

3 years agoAllow comments between newlines in chaining hints
Paco Soberón [Tue, 16 Feb 2021 23:09:31 +0000 (00:09 +0100)]
Allow comments between newlines in chaining hints

3 years agoRemove Semantic Tokens flicker workaround
kjeremy [Tue, 16 Feb 2021 21:27:30 +0000 (16:27 -0500)]
Remove Semantic Tokens flicker workaround

https://github.com/microsoft/vscode-languageserver-node/issues/576 has been closed with
the latest vscode-languageclient release.

3 years agovscode-languageclient 7.1.0-next.2
kjeremy [Tue, 16 Feb 2021 21:23:37 +0000 (16:23 -0500)]
vscode-languageclient 7.1.0-next.2

3 years agoMerge #7700
bors[bot] [Tue, 16 Feb 2021 21:05:24 +0000 (21:05 +0000)]
Merge #7700

7700: Use npm 7.x package-lock.json r=lnicola a=kjeremy

Supposedly backwards compatible

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUse npm 7.x package-lock.json
kjeremy [Tue, 16 Feb 2021 20:48:27 +0000 (15:48 -0500)]
Use npm 7.x package-lock.json

3 years agoImplement ast::AstNode for NameLike and move it to node_ext
Lukas Wirth [Tue, 16 Feb 2021 18:27:08 +0000 (19:27 +0100)]
Implement ast::AstNode for NameLike and move it to node_ext

3 years agoMerge #7690
bors[bot] [Tue, 16 Feb 2021 18:24:28 +0000 (18:24 +0000)]
Merge #7690

7690: Extract `fn load_workspace(…)` from `fn load_cargo(…)` r=matklad a=regexident

Unfortunately in https://github.com/rust-analyzer/rust-analyzer/pull/7595 I forgot to `pub use` (rather than just `use`) the newly introduced `LoadCargoConfig`.

So this PR fixes this now.

It also:

- splits up `fn load_cargo` into a "workspace loading" and a "project loading" phase
- adds a `progress: &dyn Fn(String)` to allow third-parties to provide CLI progress updates, too

The motivation behind both of these is the fact that rust-analyzer currently does not support caching.
As such any third-party making use of `ra_ap_…` needs to providing a caching layer itself.
Unlike for rust-analyzer itself however a common use-pattern of third-parties is to analyze a specific target (`--lib`/`--bin <BIN>`/…) from a specific package (`--package`). The targets/packages of a crate can be obtained via `ProjectWorkspace::load(…)`, which currently is performed inside of `fn load_cargo`, effectively making the returned `ProjectWorkspace` inaccessible to the outer caller. With this information one can then provide early error handling via CLI (in case of ambiguities or invalid arguments, etc), instead of `fn load_cargo` failing with a possibly obscure error message. It also allows for annotating the persisted caches with its specific associated package/target selector and short-circuit quickly if a matching cache is found on disk, significantly cutting load times.

Before:

```rust
pub struct LoadCargoConfig {
    pub cargo_config: &CargoConfig,
    pub load_out_dirs_from_check: bool,
    pub with_proc_macro: bool,
}

pub fn load_cargo(
    root: &Path,
    config: &LoadCargoConfig
) -> Result<(AnalysisHost, vfs::Vfs)> {
    // ...
}
```

After:

```rust
pub fn load_workspace(
    root: &Path,
    config: &CargoConfig,
    progress: &dyn Fn(String),
) -> Result<ProjectWorkspace> {
        // ...
}

pub struct LoadCargoConfig {
    pub load_out_dirs_from_check: bool,
    pub with_proc_macro: bool,
}

pub fn load_cargo(
    ws: ProjectWorkspace,
    config: &LoadCargoConfig,
    progress: &dyn Fn(String),
) -> Result<(AnalysisHost, vfs::Vfs)> {
    // ...
}
```

Co-authored-by: Vincent Esche <regexident@gmail.com>
3 years agoMerge #7697
bors[bot] [Tue, 16 Feb 2021 17:50:35 +0000 (17:50 +0000)]
Merge #7697

7697: Use `cfg(target_arch)` instead of a Cargo feature r=jonas-schievink a=jonas-schievink

Not that WASM works right now anyways...

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoUse `cfg(target_arch)` instead of a Cargo feature
Jonas Schievink [Tue, 16 Feb 2021 17:50:06 +0000 (18:50 +0100)]
Use `cfg(target_arch)` instead of a Cargo feature

Not that WASM works right now anyways...

3 years agoMerge #7657
bors[bot] [Tue, 16 Feb 2021 16:34:22 +0000 (16:34 +0000)]
Merge #7657

7657: utf8 r=matklad a=matklad

- Prepare for utf-8 offsets
- reduce code duplication in tests
- Make utf8 default, implement utf16 in terms of it
- Make it easy to add additional context for offset conversion
- Implement utf8 offsets

closes #7453

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agodocument offsets
Aleksey Kladov [Sun, 14 Feb 2021 15:23:16 +0000 (18:23 +0300)]
document offsets

3 years agoMerge #7696
bors[bot] [Tue, 16 Feb 2021 16:17:36 +0000 (16:17 +0000)]
Merge #7696

7696: Fix a few clippy::perf warnings r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoFix bitrotted module name
Aleksey Kladov [Fri, 12 Feb 2021 22:28:48 +0000 (01:28 +0300)]
Fix bitrotted module name

3 years agoEnable offset-encoding capability
Aleksey Kladov [Fri, 12 Feb 2021 22:26:01 +0000 (01:26 +0300)]
Enable offset-encoding capability

3 years agoImplement utf8 offsets
Aleksey Kladov [Fri, 12 Feb 2021 21:55:27 +0000 (00:55 +0300)]
Implement utf8 offsets

3 years agoMake it easy to add additional context for offset conversion
Aleksey Kladov [Fri, 12 Feb 2021 21:44:28 +0000 (00:44 +0300)]
Make it easy to add additional context for offset conversion

3 years agoMake utf8 default, implement utf16 in terms of it
Aleksey Kladov [Fri, 12 Feb 2021 19:09:53 +0000 (22:09 +0300)]
Make utf8 default, implement utf16 in terms of it

3 years agoreduce code duplication in tests
Aleksey Kladov [Fri, 12 Feb 2021 18:31:32 +0000 (21:31 +0300)]
reduce code duplication in tests

3 years agoPrepare for utf-8 offsets
Aleksey Kladov [Fri, 12 Feb 2021 18:24:10 +0000 (21:24 +0300)]
Prepare for utf-8 offsets

3 years agoFix a few clippy::perf warnings
kjeremy [Tue, 16 Feb 2021 15:55:34 +0000 (10:55 -0500)]
Fix a few clippy::perf warnings

3 years agoSplit `pub fn cargo_load` into `pub fn load_workspace_at` and `pub fn load_workspace`
Vincent Esche [Mon, 15 Feb 2021 23:26:47 +0000 (00:26 +0100)]
Split `pub fn cargo_load` into `pub fn load_workspace_at` and `pub fn load_workspace`

3 years agoMerge #7695
bors[bot] [Tue, 16 Feb 2021 14:32:33 +0000 (14:32 +0000)]
Merge #7695

7695: Bump lsp-types r=matklad a=kjeremy

Nothing to see here...

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoBump lsp-types
kjeremy [Tue, 16 Feb 2021 14:21:07 +0000 (09:21 -0500)]
Bump lsp-types

3 years agoMerge #7687
bors[bot] [Tue, 16 Feb 2021 14:16:47 +0000 (14:16 +0000)]
Merge #7687

7687: Specialization for async traits r=matklad a=arnaudgolfouse

Fixes #7669.

Adapting the parser seemed to be all that was needed, but I am not very experienced with the codebase. Is this enough ?

Co-authored-by: Arnaud <arnaud.golfouse@laposte.net>
3 years agoMerge #7620
bors[bot] [Tue, 16 Feb 2021 14:01:09 +0000 (14:01 +0000)]
Merge #7620

7620: Support control flow in `extract_function` assist r=matklad a=cpud36

Support `return`ing from outer function, `break`ing and `continue`ing outer loops when extracting function.

# Example
Transforms
```rust
fn foo() -> i32 {
  let items = [1,2,3];
  let mut sum = 0;
  for &item in items {
    <|>if item == 42 {
      break;
    }<|>
    sum += item;
  }
  sum
}
```
Into
```rust
fn foo() -> i32 {
  let items = [1,2,3];
  let mut sum = 0;
  for &item in items {
    if fun_name(item) {
      break;
    }
    sum += item;
  }
  sum
}

fn fun_name(item: i32) -> bool {
  if item == 42 {
    return true;
  }
  false
}
```

![add_explicit_type_infer_type](https://user-images.githubusercontent.com/4218373/107544222-0fadf280-6bdb-11eb-9625-ed6194ba92c0.gif)

# Features

Supported variants
- break and function does not return => uses `bool` and plain if
- break and function does return => uses `Option<T>` and matches on it
- break with value and function does not return => uses `Option<T>` and if let
- break with value and function does return => uses `Result<T, U>` and matches on t
- same for `return` and `continue`(but we can't continue with value)

Assist does handle nested loops and nested items(like functions, modules, impls)

Try `expr?` operator is allowed together with `return Err(_)` and `return None`.
`return expr` is not allowed.

# Not supported
## Mixing `return` with `break` or `continue`
If we have e.g. a `return` and a `break` in the selected code, it is unclear what the produced code should look like.
We can try `Result<T, Option<U>>` or something like that, but it isn't idiomatic, nor it is established. Otherwise, implementation
is relatively simple.

## `break` with label
Not sure how to handle different labels for multiple `break`s.

[edit] implemented try `expr?`

Co-authored-by: Vladyslav Katasonov <cpud47@gmail.com>
3 years agoSpecialization for async traits
Arnaud [Mon, 15 Feb 2021 17:11:10 +0000 (18:11 +0100)]
Specialization for async traits

3 years agoMerge #7685
bors[bot] [Mon, 15 Feb 2021 14:50:49 +0000 (14:50 +0000)]
Merge #7685

7685: cargo update r=kjeremy a=kjeremy

Removes redundant redox_syscall

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agocargo update
kjeremy [Mon, 15 Feb 2021 14:49:36 +0000 (09:49 -0500)]
cargo update

3 years agoMerge #7684
bors[bot] [Mon, 15 Feb 2021 14:22:33 +0000 (14:22 +0000)]
Merge #7684

7684: Actually fix runnable order r=lnicola a=ivan770

Changes
![image](https://user-images.githubusercontent.com/14003886/107956771-51a6b200-6fa8-11eb-91aa-f4190d6a8ccd.png)
to
![image](https://user-images.githubusercontent.com/14003886/107956926-903c6c80-6fa8-11eb-8fb9-8bf7bb1879ac.png)

Sorry for missing this one in original PR. This was an issue before https://github.com/rust-analyzer/rust-analyzer/pull/7596/commits/ee049b256a7718fb346a7172a34f0fc324b3269b, and I fixed it, yet *somehow* order got reversed (to a logical one)

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
3 years agoActually fix runnable order
ivan770 [Mon, 15 Feb 2021 14:09:50 +0000 (16:09 +0200)]
Actually fix runnable order

3 years agoMerge #7661
bors[bot] [Sun, 14 Feb 2021 19:52:38 +0000 (19:52 +0000)]
Merge #7661

7661: Start LSP 3.17 support r=kjeremy a=kjeremy

Companion to https://github.com/gluon-lang/lsp-types/pull/199 which <strike>has not been merged yet</strike>  has been merged.

This doesn't opt into any 3.17 functionality yet.

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
3 years agoStart LSP 3.17 support
Jeremy Kolb [Sat, 13 Feb 2021 18:54:39 +0000 (13:54 -0500)]
Start LSP 3.17 support

3 years agoMerge #7678
bors[bot] [Sun, 14 Feb 2021 19:28:14 +0000 (19:28 +0000)]
Merge #7678

7678: Simplify find_crlf r=matklad a=michalmuskala

This is both simpler to read and compiles to better code: https://rust.godbolt.org/z/MxKodv

Co-authored-by: Michał Muskała <michal@muskala.eu>
3 years agoSimplify find_crlf
Michał Muskała [Sun, 14 Feb 2021 19:16:42 +0000 (20:16 +0100)]
Simplify find_crlf

This is both simpler to read and compiles to better code:
https://rust.godbolt.org/z/MxKodv

3 years agoMerge #7676
bors[bot] [Sun, 14 Feb 2021 16:40:44 +0000 (16:40 +0000)]
Merge #7676

7676: Make it clear which client-side commands we use r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMake it clear which client-side commands we use
Aleksey Kladov [Sun, 14 Feb 2021 16:36:44 +0000 (19:36 +0300)]
Make it clear which client-side commands we use

3 years agoMerge #7656
bors[bot] [Sun, 14 Feb 2021 16:17:03 +0000 (16:17 +0000)]
Merge #7656

7656: Implement constructor usage search for almost all items r=matklad a=Veykril

This PR moves the filering for enum constructors to the HIR, with this unprefixed variants as well as when the enum has been renamed via use will then still show up properly.
We now walk the ast of the `NameRef` up until we find a `PathExpr`(which also handles `CallExpr` for tuple-type structs and variants already) or a `RecordExpr`. For enum search we then take the `path` out of that expression and do a resolution on it to compare it with the definition enum.
With this PR we now support searching for all constructor literals, Unit-, Tuple- and Record-Structs, Unit-, Tuple- and Record-Variants as well as Unions.

There is one shortcoming due to how the search is triggered. Unit Variants constructors can't be searched as we have no position for it to kick off the search(since a comma doesn't have to exist for the last variant).

Closes #2549 though it doesn't implement it as outlined in the issue since the reference kind was removed recently, though I believe the approach taken here is better personally.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7643 #7663
bors[bot] [Sun, 14 Feb 2021 15:42:07 +0000 (15:42 +0000)]
Merge #7643 #7663

7643: Automatically detect the rustc-src directory (fixes #3517) r=matklad a=bnjbvr

If the configured rustcSource was not set, then try to automatically
detect a source for the sysroot rustc directory.

I wasn't sure how to do it in the case of the project.json file, though.

7663: Tolerate spaces in nix binary patching r=matklad a=CertainLach

If path to original file contains space (I.e on code insiders, where
default data directory is ~/Code - Insiders/), then there is syntax
error evaluating src arg.

Instead pass path as str, and coerce to path back in nix expression

Co-authored-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Yaroslav Bolyukin <iam@lach.pw>
3 years agoMerge #7668
bors[bot] [Sun, 14 Feb 2021 15:29:00 +0000 (15:29 +0000)]
Merge #7668

7668: Finalize rename infra rewrite r=matklad a=Veykril

This should be the final PR in regards to rewriting rename stuff, #4290.

It addresses 3 things:
- Currently renaming import aliases causes some undesired behavior(see #5198) which is why this PR causes us to just return an error if an attempt at renaming an alias is made for the time being. Though this only prevents it from happening when the alias import is renamed, so its not too helpful.
- Fixes #6898
- If we are inside a macro file simply rename the input name node as there isn't really a way to do any of the fancy shorthand renames and similar things as for that we would have to exactly know what the macro generates and what not.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDon't rename field record patterns directly
Lukas Wirth [Sat, 13 Feb 2021 22:35:04 +0000 (23:35 +0100)]
Don't rename field record patterns directly

3 years agoMerge #7667
bors[bot] [Sat, 13 Feb 2021 22:46:37 +0000 (22:46 +0000)]
Merge #7667

7667: strip type parameter defaults when generating impl generics r=Veykril a=jDomantas

Fixes #5666

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
3 years agostrip type parameter defaults when generating impl generics
Domantas Jadenkus [Sat, 13 Feb 2021 21:59:51 +0000 (23:59 +0200)]
strip type parameter defaults when generating impl generics

3 years agoMerge #7664
bors[bot] [Sat, 13 Feb 2021 21:37:35 +0000 (21:37 +0000)]
Merge #7664

7664: refactor impl generation in assists r=Veykril a=jDomantas

Follow-up to #7659: all impl generation in assists (at least what I found) is now done through `utils::{generate_impl_text, generate_trait_impl_text}`.

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
3 years agoMerge #7665
bors[bot] [Sat, 13 Feb 2021 21:12:49 +0000 (21:12 +0000)]
Merge #7665

7665: Don't classify attribute macros as their path unless it's a function with the proc_macro_attribute attribute r=Veykril a=Veykril

bors r+
Closes #6389

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDon't classify attribute macros as their path unless it's a function with the proc_ma...
Lukas Wirth [Sat, 13 Feb 2021 21:11:31 +0000 (22:11 +0100)]
Don't classify attribute macros as their path unless it's a function with the proc_macro_attribute attribute

3 years agocargo fmt
Domantas Jadenkus [Sat, 13 Feb 2021 20:51:48 +0000 (22:51 +0200)]
cargo fmt

3 years agouse generate_impl_text in replace_derive_with_manual_impl
Domantas Jadenkus [Sat, 13 Feb 2021 20:50:04 +0000 (22:50 +0200)]
use generate_impl_text in replace_derive_with_manual_impl

3 years agouse generate_impl_text in generate_impl
Domantas Jadenkus [Sat, 13 Feb 2021 20:38:52 +0000 (22:38 +0200)]
use generate_impl_text in generate_impl

3 years agoFallback to renaming input NameRef node for macros when inside macro
Lukas Wirth [Sat, 13 Feb 2021 20:41:04 +0000 (21:41 +0100)]
Fallback to renaming input NameRef node for macros when inside macro

3 years agouse generate_impl_text in generate_from_impl
Domantas Jadenkus [Sat, 13 Feb 2021 20:26:58 +0000 (22:26 +0200)]
use generate_impl_text in generate_from_impl

3 years agofix: tolerate spaces in nix binary patching
Yaroslav Bolyukin [Sat, 13 Feb 2021 20:11:00 +0000 (23:11 +0300)]
fix: tolerate spaces in nix binary patching

If path to original file contains space (I.e on code insiders, where
default data directory is ~/Code - Insiders/), then there is syntax
error evaluating src arg.

Instead pass path as str, and coerce to path back in nix expression

Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
3 years agoPrevent aliases from being renamed for now
Lukas Wirth [Sat, 13 Feb 2021 19:49:04 +0000 (20:49 +0100)]
Prevent aliases from being renamed for now

3 years agoexpose hir::Type::type_paramters
Vladyslav Katasonov [Sat, 13 Feb 2021 18:46:21 +0000 (21:46 +0300)]
expose hir::Type::type_paramters

Used to get E parameter from `Result<T, E>`

3 years agoallow try expr? with return None in extracted function
Vladyslav Katasonov [Wed, 10 Feb 2021 17:05:03 +0000 (20:05 +0300)]
allow try expr? with return None in extracted function

3 years agoallow try expr? when extacting function
Vladyslav Katasonov [Wed, 10 Feb 2021 16:26:42 +0000 (19:26 +0300)]
allow try expr? when extacting function

3 years agohandle return, break and continue when extracting function
Vladyslav Katasonov [Wed, 10 Feb 2021 02:50:03 +0000 (05:50 +0300)]
handle return, break and continue when extracting function

3 years agomigrate body span to {parent,text_range}
Vladyslav Katasonov [Tue, 9 Feb 2021 19:14:32 +0000 (22:14 +0300)]
migrate body span to {parent,text_range}

This simplifies api as we are not duplicating code from syntax crate

3 years agoMerge #7662
bors[bot] [Sat, 13 Feb 2021 18:59:52 +0000 (18:59 +0000)]
Merge #7662

7662: Group generate getter/setter assist r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoGroup generate getter/setter assist
Lukas Wirth [Sat, 13 Feb 2021 18:58:58 +0000 (19:58 +0100)]
Group generate getter/setter assist

3 years agoMerge #7596
bors[bot] [Sat, 13 Feb 2021 17:50:55 +0000 (17:50 +0000)]
Merge #7596

7596: Move CodeLens to ide crate r=ivan770 a=ivan770

Closes #7579

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
3 years agoRemove CodeLensResolveData mention from lsp-extensions.md
ivan770 [Sat, 13 Feb 2021 17:36:29 +0000 (19:36 +0200)]
Remove CodeLensResolveData mention from lsp-extensions.md

3 years agoAllow automatically detect the rustc-src directory (fixes #3517).
Benjamin Bouvier [Thu, 11 Feb 2021 16:34:56 +0000 (17:34 +0100)]
Allow automatically detect the rustc-src directory (fixes #3517).

If the configured rustcSource is set to "discover", try to automatically
detect a source from the sysroot rustc directory.

3 years agoMake annotations tests similar to those in runnables
ivan770 [Sat, 13 Feb 2021 17:18:13 +0000 (19:18 +0200)]
Make annotations tests similar to those in runnables

3 years agoOnly use HIR when searching for enum constructors, otherwise fall back to AST
Lukas Wirth [Sat, 13 Feb 2021 16:57:14 +0000 (17:57 +0100)]
Only use HIR when searching for enum constructors, otherwise fall back to AST

3 years agoMerge #7659
bors[bot] [Sat, 13 Feb 2021 15:56:17 +0000 (15:56 +0000)]
Merge #7659

7659: Improve "Generate From impl" r=Veykril a=jDomantas

* Allows any field type. Previously it was restricted to path types, but I don't see why it couldn't apply to all other types too. (the main reason for is PR is that I'm too lazy to write out `From<&'static str>` by hand 😄)
* More correct handling for generic enums - previously it wouldn't emit generic params on the impl.
* Also accepts variants with named field.

The impl generation code got mostly copy-pasted from generate_impl assist - please tell if there's an easy way to avoid this duplication.

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
3 years agoImprove runnable annotations order, fix incorrect ignore detection
ivan770 [Sat, 13 Feb 2021 13:47:53 +0000 (15:47 +0200)]
Improve runnable annotations order, fix incorrect ignore detection

3 years agocargo fmt
Domantas Jadenkus [Sat, 13 Feb 2021 13:34:40 +0000 (15:34 +0200)]
cargo fmt

3 years agoAdded annotation tests
ivan770 [Sat, 13 Feb 2021 13:27:04 +0000 (15:27 +0200)]
Added annotation tests

3 years agomake it work for record-style variants
Domantas Jadenkus [Sat, 13 Feb 2021 12:57:06 +0000 (14:57 +0200)]
make it work for record-style variants

3 years agoupdate doc
Domantas Jadenkus [Sat, 13 Feb 2021 12:46:41 +0000 (14:46 +0200)]
update doc

3 years agohandle generic enums
Domantas Jadenkus [Sat, 13 Feb 2021 12:46:28 +0000 (14:46 +0200)]
handle generic enums

3 years agoallow any field type
Domantas Jadenkus [Sat, 13 Feb 2021 12:29:26 +0000 (14:29 +0200)]
allow any field type