]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoAssert that sysroot ABI version matches exactly
Amos Wenger [Thu, 21 Jul 2022 11:13:24 +0000 (13:13 +0200)]
Assert that sysroot ABI version matches exactly

Otherwise, fall back to the multi ABI scheme, except in testing, where
it becomes a hard error.

This should make it possible to use a rustup-provided rust-analyzer with
proc macro dylibs compiled by older rustcs, and it'll also catch changes
to the format of `rustc --version` or the `.rustc` section that would
make them impossible to compare for equality.

23 months agoimplement literal_from_str (poorly)
Amos Wenger [Wed, 20 Jul 2022 17:23:25 +0000 (19:23 +0200)]
implement literal_from_str (poorly)

23 months agoAdd literal/ident conversion, tests pass
Amos Wenger [Wed, 20 Jul 2022 17:13:06 +0000 (19:13 +0200)]
Add literal/ident conversion, tests pass

23 months agostub missing APIs
Amos Wenger [Wed, 20 Jul 2022 16:43:59 +0000 (18:43 +0200)]
stub missing APIs

23 months agoFix imports, delete removed interfaces
Amos Wenger [Wed, 20 Jul 2022 16:36:10 +0000 (18:36 +0200)]
Fix imports, delete removed interfaces

23 months agoMove token_stream to separate module
Amos Wenger [Wed, 20 Jul 2022 16:32:27 +0000 (18:32 +0200)]
Move token_stream to separate module

23 months agoAdd sysroot-abi feature, copy 1.64 ABI fo rnow
Amos Wenger [Wed, 20 Jul 2022 16:27:58 +0000 (18:27 +0200)]
Add sysroot-abi feature, copy 1.64 ABI fo rnow

23 months agoAuto merge of #12834 - fasterthanlime:proc-macro-test-toolchain, r=Veykril
bors [Wed, 20 Jul 2022 16:04:23 +0000 (16:04 +0000)]
Auto merge of #12834 - fasterthanlime:proc-macro-test-toolchain, r=Veykril

Add PROC_MACRO_TEST_TOOLCHAIN environment variable

This allows overriding the toolchain used to run `proc-macro-srv` tests.

---

Sample usage.

Testing the current ABI (variable unset/empty):

```shell
amos@tails ~/bearcove/rust-analyzer/crates/proc-macro-srv proc-macro-test-toolchain*
❯ PROC_MACRO_TEST_TOOLCHAIN="" cargo test --quiet

running 16 tests
................
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
```

Testing an older ABI:

```shell
amos@tails ~/bearcove/rust-analyzer/crates/proc-macro-srv proc-macro-test-toolchain*
❯ PROC_MACRO_TEST_TOOLCHAIN="1.58" cargo test --quiet

running 16 tests
................
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
```

Testing current nightly ABI:

```shell
❯ rustc +nightly --version
rustc 1.64.0-nightly (f8588549c 2022-07-18)

❯ PROC_MACRO_TEST_TOOLCHAIN="nightly" cargo test --quiet

running 16 tests
................
test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
```

Testing future ABI (`rust-lang/rust` master):

```shell
amos@tails ~/bearcove/rust-analyzer/crates/proc-macro-srv proc-macro-test-toolchain
❯ PROC_MACRO_TEST_TOOLCHAIN="stage1" cargo test --quiet

running 16 tests
..........thread '<unnamed>' panicked at 'range end index 216221164920373249 out of range for slice of length 18', library/core/src/slice/index.rs:73:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
....F.
failures:

---- tests::test_fn_like_macro2 stdout ----
thread 'tests::test_fn_like_macro2' panicked at 'called `Result::unwrap()` on an `Err` value: "range end index 216221164920373249 out of range for slice of length 18"', crates/proc-macro-srv/src/tests/utils.rs:38:83
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    tests::test_fn_like_macro2

test result: FAILED. 15 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib
```

---

Tagging `@jonas-schievink:` this might be helpful when updating versioned ABIs later on.

23 months agoAdd PROC_MACRO_TEST_TOOLCHAIN environment variable
Amos Wenger [Wed, 20 Jul 2022 15:43:45 +0000 (17:43 +0200)]
Add PROC_MACRO_TEST_TOOLCHAIN environment variable

This allows overriding the toolchain used to run `proc-macro-srv` tests.

23 months agoAuto merge of #12833 - fasterthanlime:literal-tests, r=Veykril
bors [Wed, 20 Jul 2022 15:33:19 +0000 (15:33 +0000)]
Auto merge of #12833 - fasterthanlime:literal-tests, r=Veykril

Add proc-macro-srv integration test that clones literals

This exercises some of the upcoming proc_macro bridge changes. It should also pass for all supported ABIs, with the older-style bridge.

This changed is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

23 months agoAuto merge of #12831 - fasterthanlime:proc-macro-test-in-tmp-dir, r=fasterthanlime
bors [Wed, 20 Jul 2022 15:21:03 +0000 (15:21 +0000)]
Auto merge of #12831 - fasterthanlime:proc-macro-test-in-tmp-dir, r=fasterthanlime

Build proc-macro-test-impl out-of-tree

Building it in-place fails in rust CI because the source directory is read-only. This changes `proc-macro-test`'s build script to first
copy `imp` under `OUT_DIR` (which is read-write).

It also prints stdout/stderr for the nested cargo invocation, should it fail. (I've seen failures in rust CI that I couldn't explain, and
when they take 25 minutes to reproduce, you want to have that info)

This change is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

Maintainer impact: none.

23 months agoUpdate crates/proc-macro-test/build.rs
Amos Wenger [Wed, 20 Jul 2022 14:56:30 +0000 (16:56 +0200)]
Update crates/proc-macro-test/build.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
23 months agoUpdate crates/proc-macro-test/build.rs
Amos Wenger [Wed, 20 Jul 2022 14:56:25 +0000 (16:56 +0200)]
Update crates/proc-macro-test/build.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
23 months agoAdd proc-macro-srv integration test that clones literals
Amos Wenger [Wed, 20 Jul 2022 14:40:02 +0000 (16:40 +0200)]
Add proc-macro-srv integration test that clones literals

This exercises some of the upcoming proc_macro bridge changes. It
should also pass for all supported ABIs, with the older-style bridge.

23 months agoDon't copy the Cargo.lock
Amos Wenger [Wed, 20 Jul 2022 14:30:08 +0000 (16:30 +0200)]
Don't copy the Cargo.lock

23 months agoproc-macro-test build script: wipe before, be more verbose
Amos Wenger [Wed, 20 Jul 2022 14:22:48 +0000 (16:22 +0200)]
proc-macro-test build script: wipe before, be more verbose

23 months agoBuild proc-macro-test-impl out-of-tree
Amos Wenger [Wed, 20 Jul 2022 14:14:53 +0000 (16:14 +0200)]
Build proc-macro-test-impl out-of-tree

Building it in-place fails in rust CI because the source directory
is read-only. This changes `proc-macro-test`'s build script to first
copy `imp` under `OUT_DIR` (which is read-write).

It also prints stdout/stderr for the nested cargo invocation, should
it fail. (I've seen failures in rust CI that I couldn't explain, and
when they take 25 minutes to reproduce, you want to have that info)

23 months agoAuto merge of #12829 - fasterthanlime:in-rust-tree-feature, r=Veykril
bors [Wed, 20 Jul 2022 14:02:49 +0000 (14:02 +0000)]
Auto merge of #12829 - fasterthanlime:in-rust-tree-feature, r=Veykril

Remove `check_merge_commits` test

Due to the way "git subtree" works, the `check_merge_commits` test _will_ find merge commits and fail, so we simply skip it.

This changed is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

Maintainer impact: none

23 months agoRemove in-rust-tree feature
Amos Wenger [Wed, 20 Jul 2022 13:58:56 +0000 (15:58 +0200)]
Remove in-rust-tree feature

Since it's unused for now -it'll be re-introduced along with the
upcoming `proc-macro-srv/sysroot` feature.

23 months agoRemove check_merge_commits test altogether
Amos Wenger [Wed, 20 Jul 2022 13:57:13 +0000 (15:57 +0200)]
Remove check_merge_commits test altogether

Rationale: Merge commits will probably end up in
`rust-lang/rust-analyzer` when doing "rust=>ra" syncs anyway.

It could be changed to only check for merge commits in non-sync PRs,
but it's "probably not worth the hassle"

23 months agoAuto merge of #12828 - fasterthanlime:proc-macro-srv-naming, r=Veykril
bors [Wed, 20 Jul 2022 13:50:28 +0000 (13:50 +0000)]
Auto merge of #12828 - fasterthanlime:proc-macro-srv-naming, r=Veykril

Rename proc macro server from 'Rustc' to 'RustAnalyzer'

Related to:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

This is mostly a courtesy PR for the sake of rustc maintainers. When they looked at `proc-macro-srv`, they noticed the server was named `Rustc` — probably because of historical copy-paste. Only rustc's proc macro server should be named `Rustc`, ra's can be named `RustAnalyzer`.

Maintainer impact: There's no semantic changes in this PR, only naming. One test snapshot was updated since "proc macro server types" were used to test traits somewhere else and I renamed those too, why not.

23 months agoAllow merge commits when 'in-rust-tree' feature is enabled
Amos Wenger [Wed, 20 Jul 2022 13:49:40 +0000 (15:49 +0200)]
Allow merge commits when 'in-rust-tree' feature is enabled

This adds an `in-rust-tree` feature that will be enabled when
rust-analyzer is built from `rust-lang/rust`. Due to the way
"git subtree" works, that test _will_ find merge commits and
fail, so we simply skip it.

23 months agoRename proc macro server from 'Rustc' to 'RustAnalyzer'
Amos Wenger [Wed, 20 Jul 2022 13:40:23 +0000 (15:40 +0200)]
Rename proc macro server from 'Rustc' to 'RustAnalyzer'

23 months agoAuto merge of #12826 - fasterthanlime:in-tree-warnings, r=Veykril
bors [Wed, 20 Jul 2022 13:14:36 +0000 (13:14 +0000)]
Auto merge of #12826 - fasterthanlime:in-tree-warnings, r=Veykril

Enable (and fix) extra lint groups required for in-tree build

This enables 3 lint groups that are required to build rust-analyzer as an "in-tree" (git subtree) tool in `rust-lang/rust`, and fixes all relevant diagnostics.

This change is tracked in:

  * https://github.com/rust-lang/rust-analyzer/issues/12818

Maintainer impact: more warnings, should be easy enough to fix them (it's mostly looking out for "rust-2015-isms", the lint group is poorly named). If you forget some, they'll show up during a `ra=>rust` sync.

23 months agoRun cargo fmt
Amos Wenger [Wed, 20 Jul 2022 13:06:15 +0000 (15:06 +0200)]
Run cargo fmt

23 months agoFix last few warnings manually
Amos Wenger [Wed, 20 Jul 2022 13:05:02 +0000 (15:05 +0200)]
Fix last few warnings manually

23 months agoRun cargo fix --edition-idioms
Amos Wenger [Wed, 20 Jul 2022 13:02:08 +0000 (15:02 +0200)]
Run cargo fix --edition-idioms

23 months agoEnable extra warnings required by rust-lang/rust
Amos Wenger [Wed, 20 Jul 2022 12:59:42 +0000 (14:59 +0200)]
Enable extra warnings required by rust-lang/rust

23 months agoAuto merge of #12825 - Veykril:trait-assoc-search, r=Veykril
bors [Wed, 20 Jul 2022 12:00:14 +0000 (12:00 +0000)]
Auto merge of #12825 - Veykril:trait-assoc-search, r=Veykril

fix: Fix search for associated trait items being inconsistent

23 months agofix: Fix search for associated trait items being inconsistent
Lukas Wirth [Wed, 20 Jul 2022 11:59:31 +0000 (13:59 +0200)]
fix: Fix search for associated trait items being inconsistent

23 months agoAuto merge of #12646 - lowr:fix/11897, r=lowr
bors [Wed, 20 Jul 2022 10:51:31 +0000 (10:51 +0000)]
Auto merge of #12646 - lowr:fix/11897, r=lowr

fix: escape receiver texts in completion

This PR fixes #11897 by escaping '\\' and '$' in the text of the receiver position expression. See [here](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) for the specification of the snippet syntax (especially [this section](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#grammar) discusses escaping).

Although not all occurrences of '\\' and '$' have to be replaced, I chose to replace all as that's simpler and easier to understand. There *are* more clever ways to implement it, but I thought they were premature optimization for the time being (maybe I should put FIXME notes?).

23 months agoAdd comments
Ryo Yoshida [Wed, 20 Jul 2022 10:10:52 +0000 (19:10 +0900)]
Add comments

23 months agoAuto merge of #12811 - TopGunSnake:12790, r=Veykril
bors [Wed, 20 Jul 2022 06:29:06 +0000 (06:29 +0000)]
Auto merge of #12811 - TopGunSnake:12790, r=Veykril

fix: Insert `pub(crate)` after doc comments and attribute macros

Fixes #12790

Original behavior was to insert `pub(crate)` at the `first_child_or_token`, which for an item with a comment or attribute macro, would put the visibility marker before the comment or macro, instead of after.

This merge request alters the call to find the node with appropriate `SyntaxKind` in the `children_or_tokens`. It also adds a test case to the module to verify the behavior. Test case verifies function, module, records, enum, impl, trait, and type cases.

23 months agoAuto merge of #12821 - SpecialMike:fix-partial-eq-default, r=Veykril
bors [Wed, 20 Jul 2022 06:20:21 +0000 (06:20 +0000)]
Auto merge of #12821 - SpecialMike:fix-partial-eq-default, r=Veykril

fix: Correctly generate default `PartialEq::ne`

Fixes #12779

For the `Generate default members` assist on the `PartialEq` trait, the assist will now give the default implementation instead of generating a function.

23 months agoFix generated `PartialEq::ne`
Michael Chisolm [Wed, 20 Jul 2022 04:26:50 +0000 (00:26 -0400)]
Fix generated `PartialEq::ne`

23 months agoAuto merge of #12800 - hi-rustin:rustin-patch-issue-12717, r=hi-rustin
bors [Wed, 20 Jul 2022 00:17:09 +0000 (00:17 +0000)]
Auto merge of #12800 - hi-rustin:rustin-patch-issue-12717, r=hi-rustin

Find original as node before compute ref match

part of https://github.com/rust-lang/rust-analyzer/issues/12717

23 months agoInverted the match logic to skip comments, attribute macros, and whitespace before...
TopGunSnake [Tue, 19 Jul 2022 23:08:05 +0000 (18:08 -0500)]
Inverted the match logic to skip comments, attribute macros, and whitespace before the appropriate keywords.

23 months agoAuto merge of #12789 - DorianListens:dscheidt/unused-param-overlapping, r=DorianListens
bors [Tue, 19 Jul 2022 22:36:08 +0000 (22:36 +0000)]
Auto merge of #12789 - DorianListens:dscheidt/unused-param-overlapping, r=DorianListens

fix: Prevent panic in Remove Unused Parameter assist

Instead of calling `builder.delete` for every text range we find with
`process_usage`, we now ensure that the ranges do not overlap before removing
them. If a range is fully contained by a prior one, it is dropped.

fixes #12784

23 months agoAuto merge of #12817 - fasterthanlime:expect-test-1-4-0, r=lnicola
bors [Tue, 19 Jul 2022 11:04:42 +0000 (11:04 +0000)]
Auto merge of #12817 - fasterthanlime:expect-test-1-4-0, r=lnicola

Upgrade to expect-test@1.4.0, add CARGO_WORKSPACE_DIR env var

This should make ra's test suite runnable from within `rust-analyzer/rust`.

`@cuviper` ran into that when trying to run RA tests from rust CI: https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202

23 months agoAdd CARGO_WORKSPACE_DIR env var in `.cargo/config.toml`
Amos Wenger [Tue, 19 Jul 2022 11:02:16 +0000 (13:02 +0200)]
Add CARGO_WORKSPACE_DIR env var in `.cargo/config.toml`

As discussed in https://github.com/rust-analyzer/expect-test/issues/33

23 months agoUpgrade to expect-test@1.4.0
Amos Wenger [Tue, 19 Jul 2022 11:00:45 +0000 (13:00 +0200)]
Upgrade to expect-test@1.4.0

cf. https://github.com/rust-analyzer/expect-test/issues/33
cf. https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202

23 months agoAuto merge of #12809 - lnicola:empty-diagnostics, r=lnicola
bors [Tue, 19 Jul 2022 05:08:47 +0000 (05:08 +0000)]
Auto merge of #12809 - lnicola:empty-diagnostics, r=lnicola

fix: Work around Code bug with empty diagnostics

Closes #11404

23 months agoWork around Code bug with empty diagnostics
Laurențiu Nicola [Mon, 18 Jul 2022 19:21:24 +0000 (22:21 +0300)]
Work around Code bug with empty diagnostics

23 months agoAdded case for const
TopGunSnake [Tue, 19 Jul 2022 01:48:01 +0000 (20:48 -0500)]
Added case for const

23 months agoCleaned up trailing whitespace for tidy::files_are_tidy
TopGunSnake [Tue, 19 Jul 2022 01:29:13 +0000 (20:29 -0500)]
Cleaned up trailing whitespace for tidy::files_are_tidy

23 months agoAdded coverage for trait, mod, impl, and enum cases.
TopGunSnake [Tue, 19 Jul 2022 01:17:42 +0000 (20:17 -0500)]
Added coverage for trait, mod, impl, and enum cases.

23 months agoAdd test case and token finder to address 12790
TopGunSnake [Tue, 19 Jul 2022 00:55:33 +0000 (19:55 -0500)]
Add test case and token finder to address 12790

23 months agoAuto merge of #12796 - mmirate:patch-1, r=Veykril
bors [Mon, 18 Jul 2022 22:19:52 +0000 (22:19 +0000)]
Auto merge of #12796 - mmirate:patch-1, r=Veykril

chore: change str_ref_to_string to str_ref_to_owned

`ToString` is implemented by many different types than `&str`, and represents a serialization into string data. The fact that said data is returned as owned, is an implementation detail resulting from the lack of a parameter for a pre-allocated buffer.

If merely copying borrowed string data to owned string data is all that is desired, `ToOwned` is a much better choice, because if the user later refactors the code such that the input is no longer an `&str`, then they will get a compiler error instead of a mysterious runtime-behavioral change.

23 months agofix: Prevent panic in Remove Unused Parameter assist
Dorian Scheidt [Sun, 17 Jul 2022 21:45:10 +0000 (16:45 -0500)]
fix: Prevent panic in Remove Unused Parameter assist

Instead of calling `builder.delete` for every text range we find with
`process_usage`, we now ensure that the ranges do not overlap before removing
them. If a range is fully contained by a prior one, it is dropped.

fixes #12784

23 months agoAuto merge of #12807 - Veykril:completion-item-details, r=Veykril
bors [Mon, 18 Jul 2022 17:28:43 +0000 (17:28 +0000)]
Auto merge of #12807 - Veykril:completion-item-details, r=Veykril

Add simple support for completion item details

Supercedes https://github.com/rust-lang/rust-analyzer/pull/9891

This doesn't yet really implement anything new, it just adds the scaffolding for the protocol conversion

23 months agoAdd simple support for completion item details
Lukas Wirth [Mon, 18 Jul 2022 17:25:43 +0000 (19:25 +0200)]
Add simple support for completion item details

23 months agoAuto merge of #11819 - rust-lang:dependabot/npm_and_yarn/editors/code/minimist-1...
bors [Mon, 18 Jul 2022 17:03:36 +0000 (17:03 +0000)]
Auto merge of #11819 - rust-lang:dependabot/npm_and_yarn/editors/code/minimist-1.2.6, r=Veykril

Bump minimist from 1.2.5 to 1.2.6 in /editors/code

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/substack/minimist/commit/7efb22a518b53b06f5b02a1038a88bd6290c2846"><code>7efb22a</code></a> 1.2.6</li>
<li><a href="https://github.com/substack/minimist/commit/ef88b9325f77b5ee643ccfc97e2ebda577e4c4e2"><code>ef88b93</code></a> security notice for additional prototype pollution issue</li>
<li><a href="https://github.com/substack/minimist/commit/c2b981977fa834b223b408cfb860f933c9811e4d"><code>c2b9819</code></a> isConstructorOrProto adapted from PR</li>
<li><a href="https://github.com/substack/minimist/commit/bc8ecee43875261f4f17eb20b1243d3ed15e70eb"><code>bc8ecee</code></a> test from prototype pollution PR</li>
<li>See full diff in <a href="https://github.com/substack/minimist/compare/1.2.5...1.2.6">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=minimist&package-manager=npm_and_yarn&previous-version=1.2.5&new-version=1.2.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting ``@dependabot` rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- ``@dependabot` rebase` will rebase this PR
- ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it
- ``@dependabot` merge` will merge this PR after your CI passes on it
- ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it
- ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging
- ``@dependabot` reopen` will reopen this PR if it is closed
- ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- ``@dependabot` use these labels` will set the current labels as the default for future PRs for this repo and language
- ``@dependabot` use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- ``@dependabot` use these assignees` will set the current assignees as the default for future PRs for this repo and language
- ``@dependabot` use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/rust-analyzer/rust-analyzer/network/alerts).

</details>

23 months agoAuto merge of #12804 - jonas-schievink:config-watcher, r=Veykril
bors [Mon, 18 Jul 2022 16:41:26 +0000 (16:41 +0000)]
Auto merge of #12804 - jonas-schievink:config-watcher, r=Veykril

fix: make file watcher config a drop-down (and clarify the options)

Fixes https://github.com/rust-lang/rust-analyzer/issues/12794

Also renames "notify" to "server", since that's clearer ("notify" is still accepted for compatibility).

23 months agoAuto merge of #12549 - bitgaoshu:goto_where_trait_m_impl, r=Veykril
bors [Mon, 18 Jul 2022 16:29:23 +0000 (16:29 +0000)]
Auto merge of #12549 - bitgaoshu:goto_where_trait_m_impl, r=Veykril

feat: Go to implementation of trait methods

try goto where the trait method implies,  #4558

23 months agoMove `convert_to_def_in_trait` into `ide-db`
Lukas Wirth [Mon, 18 Jul 2022 16:23:50 +0000 (18:23 +0200)]
Move `convert_to_def_in_trait` into `ide-db`

23 months agoImprove file watcher config
Jonas Schievink [Mon, 18 Jul 2022 15:50:56 +0000 (17:50 +0200)]
Improve file watcher config

23 months agoAuto merge of #12802 - rust-lang:jonas-schievink-patch-1, r=jonas-schievink
bors [Mon, 18 Jul 2022 15:46:36 +0000 (15:46 +0000)]
Auto merge of #12802 - rust-lang:jonas-schievink-patch-1, r=jonas-schievink

minor: Remove macro ABI version from doc comment

It's hard to remember to keep this in sync, but since the file path already contains the version, this comment is pretty unnecessary.

23 months agoRemove macro ABI version from doc comment
Jonas Schievink [Mon, 18 Jul 2022 15:44:53 +0000 (17:44 +0200)]
Remove macro ABI version from doc comment

It's hard to remember to keep this in sync, but since the file path already contains the version, this comment is pretty unnecessary.

23 months agoFind original as node before compute ref match
hi-rustin [Mon, 18 Jul 2022 13:39:13 +0000 (21:39 +0800)]
Find original as node before compute ref match

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
23 months agoAuto merge of #12798 - jonas-schievink:trim-proc-macro-abis, r=jonas-schievink
bors [Mon, 18 Jul 2022 13:12:10 +0000 (13:12 +0000)]
Auto merge of #12798 - jonas-schievink:trim-proc-macro-abis, r=jonas-schievink

internal: Remove outdated proc macro ABIs

Drops support for 1.48 to 1.57. We still support 1.58+, which is 4 versions out of date, so that should be plenty.

23 months agoRemove outdated proc macro ABIs
Jonas Schievink [Mon, 18 Jul 2022 12:58:50 +0000 (14:58 +0200)]
Remove outdated proc macro ABIs

23 months agoAuto merge of #12788 - hasali19:extract-var-mut, r=jonas-schievink
bors [Mon, 18 Jul 2022 12:42:05 +0000 (12:42 +0000)]
Auto merge of #12788 - hasali19:extract-var-mut, r=jonas-schievink

Fix extract variable assist for subexpression in mutable borrow

This checks if the expression is in a mutable borrow and if so makes the extracted variable `mut`.

Closes #12786

23 months agochore: change str_ref_to_string to str_ref_to_owned
Milo Mirate [Mon, 18 Jul 2022 12:38:14 +0000 (08:38 -0400)]
chore: change str_ref_to_string to str_ref_to_owned

ToString is implemented by many different types than &str, and
represents a serialization into string data. The fact that said data is
returned as owned, is an implementation detail.

If merely copying borrowed string data to owned string data is all that
is desired, ToOwned is a much better choice, because if the user later
refactors the code such that the input is no longer an `&str`, then they
will get a compiler error instead of a mysterious change-in-behavior.

23 months agoAuto merge of #12795 - jonas-schievink:proc-macro-abi-1.64, r=jonas-schievink
bors [Mon, 18 Jul 2022 12:32:46 +0000 (12:32 +0000)]
Auto merge of #12795 - jonas-schievink:proc-macro-abi-1.64, r=jonas-schievink

feat: Support the 1.64 nightly proc macro ABI

Should resolve https://github.com/rust-lang/rust-analyzer/issues/12600

Not sure why I thought the Rust version was the same as on beta, that's never the case (but future nightly changes can break the ABI again).

23 months agoSupport the 1.64 nightly proc macro ABI
Jonas Schievink [Mon, 18 Jul 2022 12:31:21 +0000 (14:31 +0200)]
Support the 1.64 nightly proc macro ABI

23 months agoAuto merge of #12286 - harpsword:fix_generate_constant, r=Veykril
bors [Mon, 18 Jul 2022 10:24:53 +0000 (10:24 +0000)]
Auto merge of #12286 - harpsword:fix_generate_constant, r=Veykril

fix: “Generate constant” ignores the path prefix of the identifier

fix #12022

add abilities to generate constant with prefix path, even these mods in path are not exist.

## some examples

https://user-images.githubusercontent.com/10148927/168710096-59d5c594-0e4a-4ba7-bfb3-21c4b99409ea.mov

https://user-images.githubusercontent.com/10148927/168710111-cd6d3df4-58eb-4358-ae9e-791bfc408efa.mov

https://user-images.githubusercontent.com/10148927/168710115-601923b7-2164-4b9a-85a9-fbb4b29796a1.mov

https://user-images.githubusercontent.com/10148927/168710118-3d4bc9c1-758b-4e6f-9709-568fa920937d.mov

23 months agofix: “Generate constant” ignores the path prefix of the identifier
harpsword [Sun, 1 May 2022 09:08:09 +0000 (17:08 +0800)]
fix: “Generate constant” ignores the path prefix of the identifier

23 months agoFix extract variable assist for subexpression in mutable borrow
Hasan Ali [Sun, 17 Jul 2022 21:42:03 +0000 (22:42 +0100)]
Fix extract variable assist for subexpression in mutable borrow

23 months agoAuto merge of #12785 - Logarithmus:feature/fix-negative-const-generics, r=Veykril
bors [Sun, 17 Jul 2022 17:53:02 +0000 (17:53 +0000)]
Auto merge of #12785 - Logarithmus:feature/fix-negative-const-generics, r=Veykril

fix: un-inline `ConstScalarOrPath::from_expr_opt`

Sorry, but I missed these from #12778 `@flodiebold`

23 months agofix: un-inline `ConstScalarOrPath::from_expr_opt`
Artur Sinila [Sun, 17 Jul 2022 17:35:34 +0000 (20:35 +0300)]
fix: un-inline `ConstScalarOrPath::from_expr_opt`

23 months agoAuto merge of #12778 - Logarithmus:feature/fix-negative-const-generics, r=flodiebold
bors [Sun, 17 Jul 2022 17:17:39 +0000 (17:17 +0000)]
Auto merge of #12778 - Logarithmus:feature/fix-negative-const-generics, r=flodiebold

Support negative, `char` & `bool` const generics

Before:
![Before](https://user-images.githubusercontent.com/29541480/179379832-0c3b2a74-fef6-427e-b89f-7e31d9c37b3d.png)

After:
![After](https://user-images.githubusercontent.com/29541480/179379863-b62475dd-e7bf-41f2-b437-08dfe55951af.png)

I tried to implement stuff like `Const<{NUM1 + 3 + NUM2}>` by using already existing constant evaluation mechanism for ordinary constants, but turned out to be harder than I thought, maybe because I've never ever tinkered with compilers before

23 months agofix: address suggestions
Artur Sinila [Sun, 17 Jul 2022 15:22:11 +0000 (18:22 +0300)]
fix: address suggestions

23 months agorefactor: inline some variables
Artur Sinila [Sun, 17 Jul 2022 11:55:21 +0000 (14:55 +0300)]
refactor: inline some variables

23 months agoAuto merge of #12781 - iDawer:hir_display.stack_overflow, r=lnicola
bors [Sun, 17 Jul 2022 11:01:15 +0000 (11:01 +0000)]
Auto merge of #12781 - iDawer:hir_display.stack_overflow, r=lnicola

fix: Stack overflows and wrong type inference of associated type shorthands

This fixes `generic_predicates_for_param_query` comparing local IDs that belong to different definitions.

As the query is used in multiple places this fix affects various r-a features when an associated type shorthand and `impl Trait` involved. Notably inference, goto, completion, hover.

Fixes #12484

23 months agoCheck for local IDs belong to same definition
iDawer [Sun, 17 Jul 2022 06:41:17 +0000 (11:41 +0500)]
Check for local IDs belong to same definition

23 months agofeat: support negative const generic parameters
Artur Sinila [Sun, 17 Jul 2022 01:18:53 +0000 (04:18 +0300)]
feat: support negative const generic parameters

* feat: support `bool` & `char` const generics

23 months agotests: add hover tests for const generics
Artur Sinila [Wed, 13 Jul 2022 21:32:25 +0000 (00:32 +0300)]
tests: add hover tests for const generics

23 months agoAuto merge of #12689 - Veykril:macro-rec, r=Veykril
bors [Sat, 16 Jul 2022 16:45:26 +0000 (16:45 +0000)]
Auto merge of #12689 - Veykril:macro-rec, r=Veykril

internal: Record all macro definitions in ItemScope

Fixes https://github.com/rust-lang/rust-analyzer/issues/12100

Doesn't resolve the shadowing issues though, fixing those is gonna be really tricky I believe unless we can come up with a nice scheme to "order" item tree items (using syntax ranges and file ids would be a pain and also a bad idea since that'll require us to potentially reparse files in collection).

23 months agoAuto merge of #12539 - soruh:instanciate_empty_structs, r=Veykril
bors [Sat, 16 Jul 2022 16:36:57 +0000 (16:36 +0000)]
Auto merge of #12539 - soruh:instanciate_empty_structs, r=Veykril

Automatically instaciate trivially instaciable structs in "Generate new" and "Fill struct fields"

As proposed in #12535 this PR changes the "Generate new" and "Fill struct fields" assist/diagnostic to instanciate structs with no fields and enums with a single empty variant.

For example:
```rust
pub enum Bar {
    Bar {},
}
struct Foo<T> {
    a: usize,
    bar: Bar,
    _phantom: std::marker::PhantomData<T>,
}
impl<T> Foo<T> {
    /* generate new */

    fn random() -> Self {
        Self { /* Fill struct fields */ }
    }
}
```

was previously:
```rust
impl<T> Foo<T> {
    fn new(a: usize, bar: Bar, _phantom: std::marker::PhantomData<T>) -> Self {
        Self { a, bar, _phantom }
    }

    fn random() -> Self {
        Self {
            a: todo!(),
            bar: todo!(),
            _phantom: todo!(),
        }
    }
}
```

and is now:
```rust
impl<T> Foo<T> {
  fn new(a: usize) -> Self {
      Self {
          a,
          bar: Bar::Bar {},
          _phantom: std::marker::PhantomData
      }
  }

  fn random() -> Self {
      Self {
          a: todo!(),
          bar: Bar::Bar {},
          _phantom: std::marker::PhantomData,
      }
  }
}
```

I'd be happy about any suggestions.

## TODO
   - [x]  deduplicate `use_trivial_constructor` (unclear how to do as it's used in two separate crates)
   - [x]  write tests

Closes #12535

23 months agoAuto merge of #12712 - harpsword:fix-rename-crate-root, r=Veykril
bors [Sat, 16 Jul 2022 16:28:41 +0000 (16:28 +0000)]
Auto merge of #12712 - harpsword:fix-rename-crate-root, r=Veykril

fix: ignore renames for crate root

close #12684 . I just ignore renames for crate root in `rename_mod` func.

23 months agoAuto merge of #12775 - flodiebold:syntax-fixup-if, r=flodiebold
bors [Sat, 16 Jul 2022 11:05:19 +0000 (11:05 +0000)]
Auto merge of #12775 - flodiebold:syntax-fixup-if, r=flodiebold

fix: Improve syntax fixup a bit, handle incomplete `if`

- allow appending tokens after a token, not just a node
- allow inserting delimiters (and remove them again)
- fix up `if {}` and `if` without anything following

23 months agoImprove syntax fixup a bit, handle incomplete `if`
Florian Diebold [Sat, 16 Jul 2022 10:38:33 +0000 (12:38 +0200)]
Improve syntax fixup a bit, handle incomplete `if`

- allow appending tokens after a token, not just a node
- allow inserting delimiters (and remove them again)
- fix up `if {}` and `if` without anything following

23 months agoAuto merge of #12776 - matklad:nosu, r=matklad
bors [Sat, 16 Jul 2022 10:45:34 +0000 (10:45 +0000)]
Auto merge of #12776 - matklad:nosu, r=matklad

try fixing spurious CI failures on windows

It seems like it may be related to self-update? Anyways, I think we
should be disabling self-update on CI

23 months agotry fixing spurious CI failures on windows
Aleksey Kladov [Sat, 16 Jul 2022 10:42:28 +0000 (11:42 +0100)]
try fixing spurious CI failures on windows

It seems like it may be related to self-update? Anyways, I think we
should be disabling self-update on CI

23 months agoAuto merge of #12773 - Veykril:self-compl, r=Veykril
bors [Sat, 16 Jul 2022 10:28:52 +0000 (10:28 +0000)]
Auto merge of #12773 - Veykril:self-compl, r=Veykril

fix: Improve self param completion applicability

Fixes https://github.com/rust-lang/rust-analyzer/issues/9522

23 months agofix: Improve self param completion applicability
Lukas Wirth [Sat, 16 Jul 2022 10:17:31 +0000 (12:17 +0200)]
fix: Improve self param completion applicability

23 months agoAuto merge of #12772 - Veykril:nameres, r=Veykril
bors [Sat, 16 Jul 2022 09:50:22 +0000 (09:50 +0000)]
Auto merge of #12772 - Veykril:nameres, r=Veykril

internal: Remove allocation in DefCollector::reseed_with_unresolved_attribute

23 months agoAuto merge of #12766 - Veykril:completion-vis, r=Veykril
bors [Sat, 16 Jul 2022 09:29:20 +0000 (09:29 +0000)]
Auto merge of #12766 - Veykril:completion-vis, r=Veykril

fix: Don't show qualified path completions for private items

Fixes https://github.com/rust-lang/rust-analyzer/issues/12703

23 months agointernal: Remove allocation in DefCollector::reseed_with_unresolved_attribute
Lukas Wirth [Sat, 16 Jul 2022 09:17:15 +0000 (11:17 +0200)]
internal: Remove allocation in DefCollector::reseed_with_unresolved_attribute

23 months agoAuto merge of #12764 - matklad:rustupaction, r=lnicola
bors [Sat, 16 Jul 2022 05:28:32 +0000 (05:28 +0000)]
Auto merge of #12764 - matklad:rustupaction, r=lnicola

Remove deprecate action

https://old.reddit.com/r/rust/comments/vyx4oj/actionsrs_organization_became_unmaintained/

Looking at this holistically, I don't fully understand *why* we need an
action here? Seems like we can just use rustup? nowadays github runners
come with rustup pre-installed.

23 months agoRemove deprecate action
Aleksey Kladov [Thu, 14 Jul 2022 19:24:38 +0000 (20:24 +0100)]
Remove deprecate action

https://old.reddit.com/r/rust/comments/vyx4oj/actionsrs_organization_became_unmaintained/

Looking at this holistically, I don't fully understand *why* we need an
action here? Seems like we can just use rustup? nowadays github runners
come with rustup pre-installed.

23 months agoUpdate .github/workflows/release.yaml
Aleksey Kladov [Thu, 14 Jul 2022 19:56:37 +0000 (20:56 +0100)]
Update .github/workflows/release.yaml

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
23 months agoRemove deprecate action
Aleksey Kladov [Thu, 14 Jul 2022 19:24:38 +0000 (20:24 +0100)]
Remove deprecate action

https://old.reddit.com/r/rust/comments/vyx4oj/actionsrs_organization_became_unmaintained/

Looking at this holistically, I don't fully understand *why* we need an
action here? Seems like we can just use rustup? nowadays github runners
come with rustup pre-installed.

23 months agofix: Don't show qualified path completions for private items
Lukas Wirth [Thu, 14 Jul 2022 21:22:54 +0000 (23:22 +0200)]
fix: Don't show qualified path completions for private items

23 months agoAuto merge of #12765 - Veykril:import-insert-fix, r=Veykril
bors [Thu, 14 Jul 2022 20:57:22 +0000 (20:57 +0000)]
Auto merge of #12765 - Veykril:import-insert-fix, r=Veykril

fix: Fix imports being inserted before doc comments in inline modules

Fixes https://github.com/rust-lang/rust-analyzer/issues/12758

23 months agofix: Fix imports being inserted before doc comments in inline modules
Lukas Wirth [Thu, 14 Jul 2022 20:56:56 +0000 (22:56 +0200)]
fix: Fix imports being inserted before doc comments in inline modules

23 months agoAuto merge of #12556 - DorianListens:dscheidt/generic-extract, r=Veykril
bors [Thu, 14 Jul 2022 14:29:37 +0000 (14:29 +0000)]
Auto merge of #12556 - DorianListens:dscheidt/generic-extract, r=Veykril

fix: Support generics in extract_function assist

This change attempts to resolve issue #7636: Extract into Function does not
create a generic function with constraints when extracting generic code.

In `FunctionBody::analyze_container`, we now traverse the `ancestors` in search
of `AnyHasGenericParams`, and attach any `GenericParamList`s and `WhereClause`s
we find to the `ContainerInfo`.

Later, in `format_function`, we collect all the `GenericParam`s and
`WherePred`s from the container, and filter them to keep only types matching
`TypeParam`s used within the newly extracted function body or param list. We
can then include the new `GenericParamList` and `WhereClause` in the new
function definition.

This change only impacts `TypeParam`s. `LifetimeParam`s and `ConstParam`s are
out of scope for this change.

I've never contributed to this project before, but I did try to follow the style guide. I believe that this change represents an improvement over the status quo, but I think it's also fair to argue that it doesn't fully "fix" the linked issue. I'm totally open to merging this as is, or going further to try to make a more complete solution. Also: if there are other unit or integration tests I should add, please let me know where to look!

23 months agoAuto merge of #12691 - Veykril:proc-macro-diag, r=Veykril
bors [Thu, 14 Jul 2022 14:21:16 +0000 (14:21 +0000)]
Auto merge of #12691 - Veykril:proc-macro-diag, r=Veykril

fix: Fix unresolved proc macro diagnostics pointing to macro expansions

Fixes https://github.com/rust-lang/rust-analyzer/issues/12657

23 months agoAuto merge of #12735 - feniljain:fix-completions, r=feniljain
bors [Thu, 14 Jul 2022 11:53:29 +0000 (11:53 +0000)]
Auto merge of #12735 - feniljain:fix-completions, r=feniljain

fix(completion): `super::` completion at crate root and module depth aware

- should close #12439
- Suggest super according to the depth in tree

23 months agofix(completion): `super::` completion at crate root and module depth
feniljain [Sun, 10 Jul 2022 08:38:49 +0000 (14:08 +0530)]
fix(completion): `super::` completion at crate root and module depth
aware