Commit Graph

15800 Commits

Author SHA1 Message Date
Amos Wenger
39db9cdb7d Use std::panic::resume_unwind 2022-07-21 21:35:15 +02:00
Amos Wenger
48bcc229bf Move interner methods to Symbol, return SmolStr directly since it's ref-counted 2022-07-21 21:32:46 +02:00
Amos Wenger
246947b779 Fix raw ident handling (a little) 2022-07-21 19:13:44 +02:00
Amos Wenger
941416a1d6 Add test for idents incl. raw idents 2022-07-21 18:48:19 +02:00
Amos Wenger
9cf99a9c71 Stringify literals create client-side properly 2022-07-21 18:44:41 +02:00
Amos Wenger
36d825fd5d Add test for literals created client-side 2022-07-21 18:29:28 +02:00
Amos Wenger
32ee097580 Run proc macro expansion in a separate thread (for the thread-local interner) 2022-07-21 18:11:50 +02:00
Amos Wenger
05d8f5fee7 Use a thread-local for the symbol interner (1/2) 2022-07-21 14:57:09 +02:00
Amos Wenger
30769598a4 Move version string to RustcInfo, read '.rustc' section only once 2022-07-21 13:57:36 +02:00
Amos Wenger
bbaf4daca0 Pass tidy checks 2022-07-21 13:37:41 +02:00
Amos Wenger
fdddd83224 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.
2022-07-21 13:13:25 +02:00
bors
84a6fac37a Auto merge of #12841 - Veykril:query-fix, r=Veykril
fix: Fix `trait_impls_in_deps_query` being called directly instead of as a query

Fixes the inlay hint performance regression introdcuced by https://github.com/rust-analyzer/rust-analyzer/issues/12549
2022-07-21 08:23:19 +00:00
Lukas Wirth
cfad882745 fix: Fix trait_impls_in_deps_query being called directly instead of as a query 2022-07-21 10:23:07 +02:00
Lukas Wirth
5f9a5825e0 Use ItemTree for crate root attr_query collection 2022-07-21 09:23:30 +02:00
Lukas Wirth
1aadd9da92 internal: Use itemtree for variant and field attribute collection 2022-07-21 08:48:13 +02:00
Lukas Wirth
10c7ee7068 Simplify 2022-07-21 08:48:09 +02:00
bors
2f6c39005c Auto merge of #12827 - Veykril:be-lazy, r=Veykril
internal: Construct fewer `AstIdMap`s in lowering
2022-07-21 00:11:18 +00:00
Lukas Wirth
7bd2e305d6 Simplify 2022-07-21 02:06:26 +02:00
Lukas Wirth
c83f14a44a Remove AstIdMap from Expander as it is seldom needed 2022-07-21 02:01:07 +02:00
Amos Wenger
480f555334 implement literal_from_str (poorly) 2022-07-20 19:23:25 +02:00
Amos Wenger
d25b61030e Add literal/ident conversion, tests pass 2022-07-20 19:18:39 +02:00
Amos Wenger
191db9fed4 stub missing APIs 2022-07-20 19:18:39 +02:00
Amos Wenger
00bc060ba3 Fix imports, delete removed interfaces 2022-07-20 19:18:39 +02:00
Amos Wenger
e009cdc8d9 Move token_stream to separate module 2022-07-20 19:18:39 +02:00
Amos Wenger
315b0a7254 Add sysroot-abi feature, copy 1.64 ABI fo rnow 2022-07-20 19:18:39 +02:00
bors
fa883cb647 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.
2022-07-20 16:04:23 +00:00
Amos Wenger
dcd52ec327 Add PROC_MACRO_TEST_TOOLCHAIN environment variable
This allows overriding the toolchain used to run `proc-macro-srv` tests.
2022-07-20 17:43:45 +02:00
bors
cd2c2406c0 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
2022-07-20 15:33:19 +00:00
Amos Wenger
844aa8b53e
Update crates/proc-macro-test/build.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2022-07-20 16:56:30 +02:00
Amos Wenger
9a8efe235f
Update crates/proc-macro-test/build.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2022-07-20 16:56:25 +02:00
Amos Wenger
f5042947ce 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.
2022-07-20 16:43:40 +02:00
Amos Wenger
898898df89 Don't copy the Cargo.lock 2022-07-20 16:30:08 +02:00
Amos Wenger
4375cf365e proc-macro-test build script: wipe before, be more verbose 2022-07-20 16:22:48 +02:00
Amos Wenger
a88e088fa7 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)
2022-07-20 16:16:29 +02:00
bors
bd4439fafa 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
2022-07-20 14:02:49 +00:00
Amos Wenger
244f29b1e7 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.
2022-07-20 15:58:57 +02:00
Amos Wenger
d5b1ae66c2 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"
2022-07-20 15:57:14 +02:00
Amos Wenger
c520408731 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.
2022-07-20 15:49:40 +02:00
Amos Wenger
ade31ad757 Rename proc macro server from 'Rustc' to 'RustAnalyzer' 2022-07-20 15:40:23 +02:00
Ryo Yoshida
7e0bd377c2
fix: don't replace default members' body 2022-07-20 22:30:16 +09:00
Lukas Wirth
e507807837 internal: Don't eagerly construct AstIdMaps 2022-07-20 15:12:00 +02:00
Amos Wenger
7e285e1ef5 Run cargo fmt 2022-07-20 15:06:15 +02:00
Amos Wenger
8318035726 Fix last few warnings manually 2022-07-20 15:05:02 +02:00
Amos Wenger
816f7fe12a Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
Amos Wenger
23d25a3094 Enable extra warnings required by rust-lang/rust 2022-07-20 15:00:17 +02:00
bors
0ded8e734f Auto merge of #12825 - Veykril:trait-assoc-search, r=Veykril
fix: Fix search for associated trait items being inconsistent
2022-07-20 12:00:14 +00:00
Lukas Wirth
bb4bfae422 fix: Fix search for associated trait items being inconsistent 2022-07-20 13:59:31 +02:00
bors
f3e9b38e26 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?).
2022-07-20 10:51:31 +00:00
Ryo Yoshida
cfc52adc65
Add comments 2022-07-20 19:11:14 +09:00
Lukas Wirth
d73b0d5fc6 Don't filter flychecks by package member status 2022-07-20 11:52:44 +02:00
Lukas Wirth
25391e6d44 Only clear diagnostics of workspaces who have been flychecked 2022-07-20 11:49:36 +02:00
bors
84544134f6 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.
2022-07-20 06:29:06 +00:00
Michael Chisolm
1c32fcfeb4
Fix generated PartialEq::ne 2022-07-20 00:26:50 -04:00
bors
0e7135615f 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
2022-07-20 00:17:09 +00:00
TopGunSnake
6df414faa2 Inverted the match logic to skip comments, attribute macros, and whitespace before the appropriate keywords. 2022-07-19 18:08:05 -05:00
bors
30c4db10ab 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
2022-07-19 22:36:08 +00:00
Amos Wenger
1b416473a3 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
2022-07-19 13:00:45 +02:00
bors
88515b981d Auto merge of #12809 - lnicola:empty-diagnostics, r=lnicola
fix: Work around Code bug with empty diagnostics

Closes #11404
2022-07-19 05:08:47 +00:00
Laurențiu Nicola
474f5eafc7 Work around Code bug with empty diagnostics 2022-07-19 07:45:31 +03:00
TopGunSnake
09da74a35d Added case for const 2022-07-18 20:48:01 -05:00
TopGunSnake
3cb78ffa82 Cleaned up trailing whitespace for tidy::files_are_tidy 2022-07-18 20:29:13 -05:00
TopGunSnake
3203cb124e Added coverage for trait, mod, impl, and enum cases. 2022-07-18 20:17:42 -05:00
TopGunSnake
27b65ec91d Add test case and token finder to address 12790 2022-07-18 19:55:33 -05:00
bors
567a5e9ef7 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.
2022-07-18 22:19:52 +00:00
Dorian Scheidt
ffb6b23c75 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
2022-07-18 16:44:04 -05:00
Lukas Wirth
a63b5d3c84 feat: Only flycheck workspace that belongs to saved file 2022-07-18 20:30:58 +02:00
bors
dc05192e11 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
2022-07-18 17:28:43 +00:00
Lukas Wirth
d17a5ef8e1 Add simple support for completion item details 2022-07-18 19:27:54 +02:00
bors
fac6a64656 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).
2022-07-18 16:41:26 +00:00
bors
22e53f1d33 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
2022-07-18 16:29:23 +00:00
Lukas Wirth
38c11bea21 Move convert_to_def_in_trait into ide-db 2022-07-18 18:28:02 +02:00
Jonas Schievink
ec1142c0d0 Improve file watcher config 2022-07-18 17:50:56 +02:00
Jonas Schievink
188c0e424c
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.
2022-07-18 17:44:53 +02:00
hi-rustin
15016bc09f Find original as node before compute ref match
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-18 23:24:19 +08:00
Jonas Schievink
5ad981ba67 Remove outdated proc macro ABIs 2022-07-18 14:58:50 +02:00
bors
e2eaa99ca1 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
2022-07-18 12:42:05 +00:00
Milo Mirate
be30c4daf4 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.
2022-07-18 08:38:14 -04:00
Jonas Schievink
6cb0746f82 Support the 1.64 nightly proc macro ABI 2022-07-18 14:31:21 +02:00
harpsword
b5aa3b389e fix: “Generate constant” ignores the path prefix of the identifier 2022-07-18 08:36:10 +08:00
Hasan Ali
ea19e70304 Fix extract variable assist for subexpression in mutable borrow 2022-07-17 22:42:03 +01:00
Artur Sinila
d9336a496c
fix: un-inline ConstScalarOrPath::from_expr_opt 2022-07-17 20:35:34 +03:00
bors
db6a85d358 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
2022-07-17 17:17:39 +00:00
Artur Sinila
83177a7cfe
fix: address suggestions 2022-07-17 18:22:11 +03:00
Artur Sinila
15f73008f8
refactor: inline some variables 2022-07-17 14:55:21 +03:00
iDawer
a0fd58bbbe Check for local IDs belong to same definition 2022-07-17 11:43:08 +05:00
Artur Sinila
a96f0aa7cd
feat: support negative const generic parameters
* feat: support `bool` & `char` const generics
2022-07-17 04:18:53 +03:00
Artur Sinila
b9b42e8670
tests: add hover tests for const generics 2022-07-17 02:13:09 +03:00
bors
766c5f0861 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).
2022-07-16 16:45:26 +00:00
bors
01d251789f 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
2022-07-16 16:36:57 +00:00
bors
ac526e029a 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.
2022-07-16 16:28:41 +00:00
Florian Diebold
0a4065d12d 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
2022-07-16 13:03:32 +02:00
bors
96481b7786 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
2022-07-16 10:28:52 +00:00
Lukas Wirth
b96f8f18b0 fix: Improve self param completion applicability 2022-07-16 12:28:41 +02:00
bors
d3796adeaa Auto merge of #12772 - Veykril:nameres, r=Veykril
internal: Remove allocation in DefCollector::reseed_with_unresolved_attribute
2022-07-16 09:50:22 +00:00
bors
2e9d5b59a6 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
2022-07-16 09:29:20 +00:00
Lukas Wirth
25090f0e6d internal: Remove allocation in DefCollector::reseed_with_unresolved_attribute 2022-07-16 11:17:15 +02:00
Lukas Wirth
7ff6c36716 fix: Don't show qualified path completions for private items 2022-07-15 13:30:43 +02:00
bors
029184d977 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
2022-07-14 20:57:22 +00:00
Lukas Wirth
6b823b0234 fix: Fix imports being inserted before doc comments in inline modules 2022-07-14 22:56:56 +02:00
bors
073b3253c1 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!
2022-07-14 14:29:37 +00:00
bors
fbba1d7acb 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
2022-07-14 14:21:16 +00:00
bors
5af3ef527c 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
2022-07-14 11:53:29 +00:00
feniljain
4cbde4ed8f fix(completion): super:: completion at crate root and module depth
aware
2022-07-14 17:07:43 +05:30
Dorian Scheidt
796641b5d8 Make search for applicable generics more precise 2022-07-13 14:54:17 -05:00
Dorian Scheidt
075ab03851 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.
2022-07-13 14:54:10 -05:00
soruh
a5ad4de111 add tests 2022-07-13 16:16:48 +02:00
bors
fc47ce53c8 Auto merge of #12696 - hi-rustin:rustin-patch-fix, r=Veykril
Add str_ref_to_string fix

close https://github.com/rust-lang/rust-analyzer/issues/11383
When type mismatch is `&str` -> `String` try to fix it.
2022-07-13 09:57:51 +00:00
bors
84a6bc99ad Auto merge of #12742 - TonalidadeHidrica:fix-obsolete-config-keys, r=Veykril
Fix obsolete config keys

The config keys were drastically reorganized by #12010, but the docs don't reflect the updates, causing inconsistency and confusion.  I checked for such obsolete configuration keys and updated to the new one.  For reproducibility, I attach a small shell script that I used to examine the old keys.  Now the script only detects `cargoExtraArgs` and `overrideCargo`, which originates from other type definition in the code but not from the configuration.

<details><summary>script</summary>

```bash
echo "allowMergingIntoGlobImports
exprFillDefault
importEnforceGranularity
importGranularity
importMergeBehavior
importMergeBehaviour
importGroup
importPrefix
warmup
loadOutDirsFromCheck
runBuildScripts
runBuildScriptsCommand
useRustcWrapperForBuildScripts
enableExperimental
procAttrMacros
breakPoints
exitPoints
yieldPoints
linksInHover
linksInHover
gotoTypeDef
chainingHints
closureReturnTypeHints
hideNamedConstructorHints
parameterHints
reborrowHints
typeHints
lruCapacity
cargoExtraArgs
overrideCargo
rustcSource
enableRangeFormatting
assist\.allowMergingIntoGlobImports
assist\.exprFillDefault
assist\.importEnforceGranularity
assist\.importGranularity
assist\.importMergeBehavior
assist\.importMergeBehaviour
assist\.importGroup
assist\.importPrefix
primeCaches\.enable
cache\.warmup
cargo\.loadOutDirsFromCheck
cargo\.runBuildScripts
cargo\.runBuildScriptsCommand
cargo\.useRustcWrapperForBuildScripts
completion\.snippets
diagnostics\.enableExperimental
experimental\.procAttrMacros
highlighting\.strings
highlightRelated\.breakPoints
highlightRelated\.exitPoints
highlightRelated\.yieldPoints
highlightRelated\.references
hover\.documentation
hover\.linksInHover
hoverActions\.linksInHover
hoverActions\.debug
hoverActions\.enable
hoverActions\.gotoTypeDef
hoverActions\.implementations
hoverActions\.references
hoverActions\.run
inlayHints\.chainingHints
inlayHints\.closureReturnTypeHints
inlayHints\.hideNamedConstructorHints
inlayHints\.parameterHints
inlayHints\.reborrowHints
inlayHints\.typeHints
lruCapacity
runnables\.cargoExtraArgs
runnables\.overrideCargo
rustcSource
rustfmt\.enableRangeFormatting
allFeatures
addCallArgumentSnippets
addCallParenthesis
callInfo\.full
cargo\.allFeatures
checkOnSave\.allFeatures
completion\.addCallArgumentSnippets
completion\.addCallParenthesis" | while read -r pattern
do
  rg '\b'$pattern'\b([^.]|$)' . -g "!crates/rust-analyzer/src/config/patch_old_style.rs" -g "!editors/code/src/config.ts" -g "!a.sh" --no-heading --color=always --line-number
done

exit

excluded
# debug
# enable
# run
# implementations
# references
# documentation
# references
# snippets
# strings
# full
```

</details>
2022-07-13 09:46:26 +00:00
Jonas Schievink
ebfbb314c0 Update 1.63 proc macro ABI to match rustc 2022-07-12 15:19:31 +02:00
Jonas Schievink
df66eb74ab Implement ignore and index metavar expression 2022-07-11 18:31:42 +02:00
hi-rustin
d9ab7f21e4 Fix typos
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-11 21:42:05 +08:00
TonalidadeHidrica
e3bde579c4 Fix obsolete completion.snippets config 2022-07-11 17:00:40 +09:00
TonalidadeHidrica
dfcbed09d3 Fix obsolete enableRangeFormatting config 2022-07-11 16:52:35 +09:00
TonalidadeHidrica
f0649f2c19 Fix rustcSource -> rustc_source
This only fixes the comments in the internal source,
     which is not mandatory at all
2022-07-11 16:50:20 +09:00
TonalidadeHidrica
eaebead296 Fix config keys regarding imports in docs 2022-07-11 15:43:25 +09:00
harpsword
4b3164f129 fix: ignore renames for crate root 2022-07-10 10:45:03 +08:00
hi-rustin
638abba05c Fix test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-09 11:42:19 +08:00
Dorian Scheidt
21062f9201 fix: Improve suggested names for extracted variables
When extracting a field expression, if RA was unable to resolve the type of the
field, we would previously fall back to using "var_name" as the variable name.

Now, when the `Expr` being extracted matches a `FieldExpr`, we can use the
`NameRef`'s ident token as a fallback option.

fixes #10035
2022-07-08 18:35:04 -05:00
Dorian Scheidt
603b6fcc68 fix: Extract Function misses locals used in closures
This change fixes #12705.

In `FunctionBody::analyze`, we need to search any `ClosureExpr`s we encounter
for any `NameRef`s, to ensure they aren't missed.
2022-07-08 09:52:01 -05:00
bors
c419aa9775 Auto merge of #12719 - davidlattimore:format-args-no-unsafe, r=jonas-schievink
Remove unnecessary unsafe from format_args expansion
2022-07-08 14:10:19 +00:00
bors
7181a39d4c Auto merge of #12676 - DorianListens:dscheidt/extract-fun-trait-impl, r=jonas-schievink
fix: Extract function from trait impl

This change fixes #10036, "Extract to function assist implements nonexistent
trait methods".

When we detect that the extraction is coming from within a trait impl, and that
a `self` param will be necessary, we adjust which `SyntaxNode` to `insert_after`,
and create a new empty `impl` block for the newly extracted function.
2022-07-08 14:01:36 +00:00
Jonas Schievink
6c6ae965ba Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
David Lattimore
6f819e30e4 Remove unnecessary unsafe from format_args expansion 2022-07-08 14:56:18 +10:00
bors
c296e77767 Auto merge of #12695 - xuhongxu96:fix-12140, r=jonas-schievink
Complete type param/associated type in trait generic arg per arg index

- Fix #12140
- Also fix tidy check does not work for marks in multiline
2022-07-06 23:58:52 +00:00
Hongxu Xu
3248601a03 fix default type param value position 2022-07-07 07:28:55 +08:00
Jonas Schievink
d2fd137252 Use SmallVec to slightly shrink ModPath size 2022-07-06 19:49:05 +02:00
Hongxu Xu
0360ed53cf check arg_idx >= n_params only if arg_idx >= n_required_params 2022-07-07 00:54:46 +08:00
Hongxu Xu
75fb3de310 Handle generic args per arg index
Add more test cases for generic args
2022-07-07 00:45:22 +08:00
Hongxu Xu
0f2eba54db Show only assoc type args in the correct arg pos 2022-07-06 22:58:27 +08:00
hi-rustin
b9ba9fab5a Add str_ref_to_string fix
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-05 22:47:18 +08:00
Hongxu Xu
441e659aa1 Complete associated type only in trait generic arg
Fix tidy check does not work for marks in multiline
2022-07-05 21:48:28 +08:00
hi-rustin
0d9737ac1c Fix project root assert
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-05 21:18:00 +08:00
Lukas Wirth
976d07e53e fix: Fix unresolved proc macro diagnostics pointing to macro expansions 2022-07-05 12:46:09 +02:00
bors
6edf624cbe Auto merge of #12690 - Veykril:inert-attrs, r=Veykril
internal: Update inert attribute list
2022-07-05 09:55:55 +00:00
Lukas Wirth
383ee6af5e internal: Update inert attribute list 2022-07-05 11:54:46 +02:00
Lukas Wirth
db49ac8734 internal: Record all macro definitions in ItemScope 2022-07-05 11:28:47 +02:00
Florian Diebold
ccf854bc2e Improve documentation for buildScripts.overrideCommand / checkOnSave.overrideCommand 2022-07-04 18:51:18 +02:00
bors
75b22326da Auto merge of #12681 - lnicola:bump-deps, r=lnicola
Bump deps
2022-07-03 07:25:03 +00:00
Laurențiu Nicola
78beb4c444 Bump chalk 2022-07-03 10:22:10 +03:00
Laurențiu Nicola
e05e6c60a7 Bump object 2022-07-03 10:14:48 +03:00
Laurențiu Nicola
5381811368 Bump tracing-subscriber 2022-07-03 10:12:58 +03:00
Laurențiu Nicola
9e7ca80c82 Bump cargo_metadata 2022-07-03 10:09:35 +03:00
Laurențiu Nicola
6669f388a2 Bump indexmap 2022-07-03 10:09:35 +03:00
Laurențiu Nicola
791f2a0bec Bump smallvec 2022-07-03 10:09:35 +03:00
Laurențiu Nicola
e6fcb23445 Bump either 2022-07-03 10:09:35 +03:00
Laurențiu Nicola
c7c314d462 Bump quote 2022-07-03 10:09:35 +03:00
Laurențiu Nicola
212f84ab46 Bump crossbeam-channel 2022-07-03 09:56:58 +03:00
Dorian Scheidt
e3940003a2 fix: Extract function from trait impl
This change fixes #10036, "Extract to function assist implements nonexistent
trait methods".

When we detect that the extraction is coming from within a trait impl, and that
a `self` param will be necessary, we adjust which `SyntaxNode` to `insert_after`,
and create a new empty `impl` block for the newly extracted function.
2022-07-02 15:00:02 -05:00
Dorian Scheidt
0039d6f731 fix: Extract Function produces duplicate fn names
This change fixes issue #10037, in more or less the most naive fashion
possible.

We continue to start with the hardcoded default of "fun_name", and now append a
counter to the end of it if that name is already in scope.

In the future, we can probably apply more heuristics here to wind up with more
useful names by default, but for now this resolves the immediate problem.
2022-07-02 14:24:41 -05:00
Ryo Yoshida
649e1f54cf
fix: report type mismatch on identifier in destructuring assignments 2022-07-03 03:29:15 +09:00
Ryo Yoshida
afdbd6cce2
fix: infer lhs first on ordinary assignment expressions 2022-07-03 03:29:02 +09:00
bors
d101439c77 Auto merge of #12627 - yue4u:fix/struct-variant-patterns, r=Veykril
fix: complete enum variants as patterns in pattern path

close #12593
2022-07-02 17:18:24 +00:00
a-kenji
f2963cf8ff fix: typos in hir-ty 2022-07-02 17:19:06 +02:00
bors
d4b79ad77b Auto merge of #12678 - Veykril:flyimport, r=Veykril
fix: Trigger flyimport completions in item lists again

Fixes https://github.com/rust-lang/rust-analyzer/issues/12656
2022-07-02 14:20:36 +00:00
Lukas Wirth
cd42b20ce3 fix: Trigger flyimport completions in item lists again 2022-07-02 16:20:26 +02:00
yue4u
ea7ea7079c fix: escape for enum variant 2022-07-02 23:17:29 +09:00
yue4u
622b516c74 fix: variants rendering in pattern path 2022-07-02 20:31:24 +09:00
Florian Diebold
9a12d0d6f2 Fix case of ignored/broken proc macro 2022-07-01 19:00:07 +02:00
Florian Diebold
e71519572c Add tests for #12669 2022-07-01 19:00:07 +02:00
bors
994f3cf74d Auto merge of #12636 - xuhongxu96:fix-12148, r=Veykril
complete raw identifier with "r#" prefix

Fix #12148

Escape Names and Paths used in `insert_text`/`insert_snippet` while rendering the completion items.
2022-07-01 14:55:51 +00:00
bors
ed44fe52e4 Auto merge of #12668 - Veykril:mac-source-map, r=Veykril
fix: Simplify macro statement expansion handling

I only meant to fix https://github.com/rust-lang/rust-analyzer/issues/12644 but that somehow turned into a rewrite of the statement handling ... at least this fixes a few more issues in the IDE layer now
2022-07-01 14:46:48 +00:00
Lukas Wirth
e5e5a0932d Fix blocks not considering stmt without semi as tails 2022-07-01 16:25:52 +02:00
Lukas Wirth
8e764a8bb1 fix: Fix attribute macros on assoc items being discarded with disabled proc macros 2022-07-01 16:21:21 +02:00
Lukas Wirth
58d5c69a63 Fix Expr::MacroStmts using wrong scopes 2022-07-01 15:34:29 +02:00
Lukas Wirth
9165e3b381 Update hir-ty test outputs 2022-07-01 15:21:55 +02:00
Lukas Wirth
531e152390 fix: Simplify macro statement expansion handling 2022-07-01 14:49:30 +02:00
bors
f8c416e1b9 Auto merge of #12650 - lowr:fix/12591, r=lnicola
fix: improve whitespace insertion in pretty printer

Fixes #12591

The `=>` token in the macro_rules! should be parsed as one fat arrow, but it ["requires a lot of changes in r-a"](143cc528b1), so I left it for the larger refactoring in the future and put a FIXME note.
2022-07-01 08:32:04 +00:00
Lukas Wirth
ddddca8717 fix: Fix flycheck sending cancel progress with no running process 2022-06-30 22:58:57 +02:00
bors
642084093a Auto merge of #12634 - iDawer:match-check.witnesses, r=flodiebold
feat: Show witnesses of non-exhaustiveness in `missing-match-arm` diagnostic

Shamelessly copied from rustc. Thus reporting format is same.

This extends public api  `hir::diagnostics::MissingMatchArms` with `uncovered_patterns: String` field. It does not expose data for implementing a quick fix yet.

-----
Worth to note: current implementation does not give a comprehensive list of missing patterns. Also mentioned in [paper](http://moscova.inria.fr/~maranget/papers/warn/warn.pdf):

> One may think that algorithm I should make an additional effort to provide more
> non-matching values, by systematically computing recursive calls on specialized
> matrices when possible, and by returning a list of all pattern vectors returned by
> recursive calls. We can first observe that it is not possible in general to supply the
> users with all non-matching values, since the signature of integers is (potentially)
> infinite.
2022-06-30 14:51:58 +00:00
iDawer
e417992674 Add static assertions for some unreachble paths 2022-06-30 18:36:05 +05:00
iDawer
461c0cc07a Correct wording 2022-06-30 17:19:03 +05:00
bors
7f9c054686 Auto merge of #12626 - CuriousCorrelation:fix/empty-reasons, r=flodiebold
fix: trailing ':' on empty inactive reasons

## Description
Fixes trailing ':' even when there is no explanation. e.g.
``` sh
code is inactive due to #[cfg] directives:
```
## Issue
Fixes: #12615
2022-06-30 10:19:21 +00:00
bors
2ff505ab48 Auto merge of #12428 - lowr:experimental/destructuring-assignment, r=flodiebold
feat: implement destructuring assignment

This is an attempt to implement destructuring assignments, or more specifically, type inference for [assignee expressions](https://doc.rust-lang.org/reference/expressions.html#place-expressions-and-value-expressions).

I'm not sure if this is the right approach, so I don't even expect this to be merged (hence the branch name 😉) but rather want to propose one direction we could choose. I don't mind getting merged if this is good enough though!

Some notes on the implementation choices:

- Assignee expressions are **not** desugared on HIR level unlike rustc, but are inferred directly along with other expressions. This matches the processing of other syntaxes that are desugared in rustc but not in r-a. I find this reasonable because r-a only needs to infer types and it's easier to relate AST nodes and HIR nodes, so I followed it.
- Assignee expressions obviously resemble patterns, so type inference for each kind of pattern and its corresponding assignee expressions share a significant amount of logic. I tried to reuse the type inference functions for patterns by introducing `PatLike` trait which generalizes assignee expressions and patterns.
  - This is not the most elegant solution I suspect (and I really don't like the name of the trait!), but it's cleaner and the change is smaller than other ways I experimented, like making the functions generic without such trait, or making them take `Either<ExprId, PatId>` in place of `PatId`.

in case this is merged:
Closes #11532
Closes #11839
Closes #12322
2022-06-30 09:14:12 +00:00
Ryo Yoshida
36d2b43dfd
fix: improve whitespace insertion in pretty printer 2022-06-28 20:44:55 +09:00
Florian Diebold
8b3ec12aac fix: Report proc macro errors in expressions correctly as well
They didn't have a krate before, resulting in the generic "proc macro
not found" error.

Also improve error messages a bit more.
2022-06-28 10:43:22 +02:00
Ryo Yoshida
80cc0ef1bc
Fix typo 2022-06-27 23:20:26 +09:00
Ryo Yoshida
393a18b8ce
fix: escape receiver texts in format string completion 2022-06-27 23:20:23 +09:00
Ryo Yoshida
491e6eaf9e
fix: escape ${receiver} when completing with custom snippets 2022-06-27 23:20:17 +09:00
bors
9eaf96c9ea Auto merge of #12643 - Veykril:macro-compl, r=Veykril
fix: Fix completions for locals not working properly inside macro calls
2022-06-27 12:40:46 +00:00
Lukas Wirth
bdbffdd463 fix: Fix completions for locals not working properly inside macro calls 2022-06-27 14:39:44 +02:00
bors
4c3954682d Auto merge of #12635 - antogilbert:tgt_feat, r=Veykril
Correct target_feature completion

I changed the `target_feature` to match the description given in #12616.
2022-06-27 12:28:36 +00:00
Manas
7f1fac7c26 fix: deduplicate cfg completions
cfg completions are duplicated if they are set with multiple values.
This patch deduplicates them.
2022-06-27 16:17:06 +05:30
Antonello Palazzi
bef89e95e7 Udate unit tests 2022-06-27 09:04:42 +01:00
bitgaoshu
dcb4837b2d WellFormed -> Holds 2022-06-26 23:09:06 +08:00
bitgaoshu
408fa148b9 add test for item same name 2022-06-26 22:48:26 +08:00
buffet
45b896002a Fix typo in build.rs 2022-06-26 10:09:45 +00:00
Hongxu Xu
f536766efb complete raw identifier with "r#" prefix 2022-06-26 14:45:30 +08:00
Antonello Palazzi
e4e2a46773 Correct target_feature completion 2022-06-26 00:50:41 +01:00
iDawer
fb6278e750 Reduce intermediate allocations while printing witnesses 2022-06-25 20:08:00 +05:00
bitgaoshu
0dbc091fee add test for suggest_name 2022-06-25 17:33:27 +08:00
bitgaoshu
82c1b313bc restore sth 2022-06-25 10:25:56 +08:00
bors
5bb123d970 Auto merge of #12520 - Veykril:flycheck-cancel, r=Veykril
internal: Bring back JodChild into flychecking for cancellation

cc https://github.com/rust-lang/rust-analyzer/pull/10517/files#r895241975
2022-06-24 17:42:00 +00:00
bitgaoshu
e3b1303c4f fix test in resolve_proc_macro: Foo is Owner 2022-06-25 01:02:39 +08:00
bitgaoshu
900b4208fd rename "trait_def" to "def_in_trait" 2022-06-24 23:04:35 +08:00
bitgaoshu
353829fc4e highlight: trait path 2022-06-24 23:04:35 +08:00
bitgaoshu
9ea8d5806d fix test in qualify_method: stay in trait path 2022-06-24 23:04:35 +08:00
bors
401a71d1d7 Auto merge of #12629 - flodiebold:proc-macro-error-improvement, r=Veykril
fix: Improve proc macro errors a bit

Distinguish between
 - there is no build data (for some reason?)
 - there is build data, but the cargo package didn't build a proc macro dylib
 - there is a proc macro dylib, but it didn't contain the proc macro we expected
 - the name did not resolve to any macro (this is now an
 unresolved_macro_call even for attributes)

I changed the handling of disabled attribute macro expansion to
immediately ignore the macro and report an unresolved_proc_macro,
because otherwise they would now result in loud unresolved_macro_call
errors. I hope this doesn't break anything.

Also try to improve error ranges for unresolved_macro_call / macro_error
by reusing the code for unresolved_proc_macro. It's not perfect but
probably better than before.
2022-06-24 12:27:59 +00:00
Florian Diebold
45fd5e697f Improve comments 2022-06-24 14:19:18 +02:00
Florian Diebold
c80c34867f Improve proc macro errors a bit
Distinguish between
 - there is no build data (for some reason?)
 - there is build data, but the cargo package didn't build a proc macro dylib
 - there is a proc macro dylib, but it didn't contain the proc macro we expected
 - the name did not resolve to any macro (this is now an
 unresolved_macro_call even for attributes)

I changed the handling of disabled attribute macro expansion to
immediately ignore the macro and report an unresolved_proc_macro,
because otherwise they would now result in loud unresolved_macro_call
errors. I hope this doesn't break anything.

Also try to improve error ranges for unresolved_macro_call / macro_error
by reusing the code for unresolved_proc_macro. It's not perfect but
probably better than before.
2022-06-24 13:45:19 +02:00
bitgaoshu
9e6bff79f4 fix some test due to resolve to where trait m impl 2022-06-24 19:15:16 +08:00
bitgaoshu
6ecabe352a functions resolve to impl 2022-06-24 19:11:35 +08:00
bors
434e718b67 Auto merge of #12605 - erhuve:fix/determine-doc-link-type-at-start, r=erhuve
fix: doc_links link type - Determine link type at start (fixes #12601)

fixes #12601
Looked like autolink/inline mismatch happened because end_link_type was parsed from the Text/Code events.
I changed it to be determined from the Start event, which should hopefully remain accurate while staying true to the cases where link type may need to be changed, according to the comment
```
// normally link's type is determined by the type of link tag in the end event,
// however in some cases we want to change the link type, for example,
// `Shortcut` type doesn't make sense for url links
```
Hopefully this is the desired behavior?
![Untitled](https://user-images.githubusercontent.com/59463268/174696581-3b1140a5-cdf0-4eda-9a11-ec648e4e7d21.gif)
2022-06-23 23:15:33 +00:00
Raymond Luo
5107123f9a clarify comment and add autolink test case 2022-06-23 19:02:30 -04:00
bors
32b40ded0f Auto merge of #12628 - Veykril:simplify, r=Veykril
internal: Simplify
2022-06-23 18:13:08 +00:00
Lukas Wirth
2642f64570 internal: Simplify 2022-06-23 20:08:29 +02:00
CuriousCorrelation
e0c17e8777 fix: trailing ':' on empty inactive reasons
Fixes: #12615
2022-06-23 22:10:27 +05:30
yue4u
472ae16bfb fix: completes non exhaustive variant within the defining crate 2022-06-24 00:00:51 +09:00
Florian Diebold
36fadc4224 Fix unstable feature use 2022-06-23 16:05:59 +02:00
Florian Diebold
f410fdf6e3 Add two more tests 2022-06-23 14:49:05 +02:00
Florian Diebold
29f01cd9d2 Various cleanups
- remove Valid, it serves no purpose and just obscures the diff
 - rename some things
 - don't use is_valid_candidate when searching for impl, it's not necessary
2022-06-23 14:38:28 +02:00
bitgaoshu
1064c7513a reformat code 2022-06-23 14:01:22 +02:00
bitgaoshu
1ef5e14c2c goto where trait method impl 2022-06-23 14:01:22 +02:00
Raymond Luo
96ff235770 condense matches on autolink 2022-06-22 22:07:26 -04:00
soruh
817082cad6 add doc strings to use_trivial_contructor.rs 2022-06-22 16:49:50 +02:00
soruh
f9379df630 add use_trivial_contructor.rs 2022-06-22 16:34:01 +02:00
soruh
f780145c4a apply suggestions 2022-06-22 16:29:59 +02:00
Raymond Luo
b7e3f525bd handle autolink as edge case 2022-06-20 23:15:27 -04:00
Raymond Luo
c6f776c5f9 determine doc link type from start instead of text or code 2022-06-20 21:10:45 -04:00
bors
6fc5c3cd21 Auto merge of #12604 - Veykril:completions, r=Veykril
internal: Simplify some completions
2022-06-20 19:56:05 +00:00
Lukas Wirth
7a0774defa internal: Simplify some completions 2022-06-20 21:55:33 +02:00
bors
312ac83caf Auto merge of #12599 - flodiebold:no-test-deps, r=flodiebold
fix: Only apply `cfg(test)` for local crates

Don't analyze dependencies with `test`; this should fix various cases where crates use `cfg(not(test))` and so we didn't find things.

"Local" here currently means anything that's not from the registry, so anything inside the workspace, but also path dependencies. So this isn't perfect, and users might still need to use `rust-analyzer.cargo.unsetTest` for these in some cases.
2022-06-20 18:42:48 +00:00
Florian Diebold
07d78b67cb Fix test 2022-06-20 20:34:08 +02:00
Lukas Wirth
8b078986dc Reimplement auto-ref completions for fields 2022-06-20 20:22:51 +02:00
Florian Diebold
05ca0a2377 Refactor a bit 2022-06-20 20:21:30 +02:00
Lukas Wirth
46d22719fc Remove pattern rendering hack 2022-06-20 20:16:40 +02:00
Florian Diebold
98a58114a4 Only apply cfg(test) for local crates
Don't analyze dependencies with `test`; this should fix various cases
where crates use `cfg(not(test))` and so we didn't find things.

"Local" here currently means anything that's not from the registry, so
anything inside the workspace, but also path dependencies. So this isn't
perfect, and users might still need to use
`rust-analyzer.cargo.unsetTest` for these in some cases.
2022-06-20 20:10:25 +02:00
Lukas Wirth
06ee4d6222 fix: Fix auto-ref completions inserting into wrong locations 2022-06-20 18:59:57 +02:00
Lukas Wirth
1f028403cd fix: Don't trigger pattern completions when typing a wildcard pattern 2022-06-20 18:03:09 +02:00
Lukas Wirth
6e9c963348 internal: Lift out IdentContext from CompletionContext 2022-06-20 17:41:04 +02:00
Lukas Wirth
bcf10cde13 internal: Remove previous_token field from CompletionContext 2022-06-20 15:07:48 +02:00
Lukas Wirth
90483321ee Remove some usages of Completions::add_resolution 2022-06-20 14:47:30 +02:00
Lukas Wirth
7685245282 Even more completion context filtering 2022-06-20 14:23:46 +02:00
Lukas Wirth
ce5859e387 Lift out PathKind variant fields into structs 2022-06-20 13:29:13 +02:00
Lukas Wirth
5c69df93df Split remaining completion calls on the context kinds 2022-06-20 13:17:30 +02:00
iDawer
4ff9bedbed Display witnesses of non-exhaustive match
Reporting format follows rustc and shows at most three witnesses.
2022-06-20 15:48:09 +05:00
Lukas Wirth
013c6a3f75 fix: attribute macros not being properly diagnosed 2022-06-19 00:37:37 +02:00
bors
817f46bc6c Auto merge of #12580 - Veykril:completion, r=Veykril
internal: Move more things out of `CompletionContext::function_def` into more specific parts
2022-06-18 09:21:13 +00:00
Lukas Wirth
f271b18129 Consider walking up macro expansions when searching for surrounding entities in completion analysis 2022-06-18 11:19:36 +02:00
Lukas Wirth
c1446a2743 Move CompletionContext::impl_def into corresponding entities 2022-06-18 10:45:53 +02:00
Lukas Wirth
83e8f3ac30 Move CompletionContext::incomplete_let into PathKind::Expr 2022-06-18 10:19:04 +02:00
bors
7a87f810ca Auto merge of #12576 - harpsword:fold_range_non_block_match_arm, r=Veykril
feat: add fold range for multi line match arm list

fix: #11893
2022-06-18 08:10:31 +00:00
harpsword
3a78cc5e67 feat: add fold range for multi line match arm list 2022-06-18 16:05:56 +08:00
Lukas Wirth
7369e5120d Move CompletionContext::function_def into PathKind::Expr 2022-06-18 09:54:03 +02:00
Lukas Wirth
309ecdd71c internal: NameRefKind classification is not optional 2022-06-18 08:58:47 +02:00
Lukas Wirth
0665428b4e minor: Simplify 2022-06-18 01:15:08 +02:00
Lukas Wirth
173bb10a76 internal: Split flyimport into its 3 applicable contexts 2022-06-18 00:47:28 +02:00
Lukas Wirth
00fdb4a3d8 Only run completion functions if their corresponding context is active 2022-06-17 23:36:39 +02:00
Lukas Wirth
d97a8ee865 Remove superfluous early returns 2022-06-17 17:49:25 +02:00
Lukas Wirth
85b68b1f7d Inline PathQualifierCtx 2022-06-17 17:27:12 +02:00
Lukas Wirth
d6f161ffa9 internal: Collapse lift is_infer_qualifier into Qualified variant 2022-06-17 17:15:29 +02:00
Lukas Wirth
2f2ea77d88 Move existing_derives into PathKind::Derive 2022-06-17 16:56:21 +02:00
Lukas Wirth
531060f103 internal: Collapse completion ctx path qualifier and is_absolute_path into enum 2022-06-17 16:36:22 +02:00
Lukas Wirth
85363d18e8 Simplify 2022-06-17 16:22:51 +02:00
Lukas Wirth
f35a9a1dcc Split out tests 2022-06-17 15:19:09 +02:00
Lukas Wirth
a2537e591a Split completion context module into definitions and analysis parts 2022-06-17 15:16:20 +02:00
Lukas Wirth
f201a40492 Remove ImmediateLocation in favor of PathKind::Type 2022-06-17 15:09:48 +02:00
Lukas Wirth
6b246292ca Move more ImmediateLocation::TypeAnnotation into PathKind::Type 2022-06-17 11:31:36 +02:00
Lukas Wirth
6e07b17f69 Introduce NameRefKind for completions 2022-06-17 10:45:19 +02:00
Lukas Wirth
59799312e2 Send a DidCancel event when restarting flychecks 2022-06-16 15:25:50 +02:00
bors
7322a982f9 Auto merge of #12554 - XFFXFF:fix_11959, r=Veykril
fix: local items should not be completed in parent signature

fixes #11959

> We get a Bar completion for the following snippet which is wrong as the item is not visible in that position.
> ``` rust
> fn foo() -> $0 {
>    struct Bar;
> }
> ```

I investigated the problem and found that the scope of the cursor offset, also `CompletionContext.scope` is the body of the function
2022-06-16 12:48:33 +00:00
XFFXFF
6df969f5f4 the offset used for the completion cursor should always be relative to the original file and not to the marco file 2022-06-16 20:34:37 +08:00
bors
7ade4d49fc Auto merge of #12517 - xuhongxu96:master, r=Veykril
fix methods in pub trait generated by macro cannot be completed

Fix #12483

Check if the container is trait and inherit the visibility to associate items during collection.
2022-06-16 09:14:09 +00:00
XFFXFF
fbf8e12234 the scope of the return type is not the body of the function 2022-06-16 16:24:18 +08:00
Hongxu Xu
534d71a852 disable private editable in TEST_CONFIG by default
adjust test_visibility_filter test case
2022-06-16 08:52:57 +08:00
Jeremy Banks
c32f133236 fix: inserted imports must come after a shebang if present 2022-06-15 19:42:43 +00:00
Jeremy Banks
f32ad8362f add failing test: inserts_after_shebang 2022-06-15 19:42:43 +00:00
Lukas Wirth
bc1aa93e7e Polish 2022-06-15 18:35:48 +02:00
Lukas Wirth
1dd2c50298 Update test outputs 2022-06-15 18:07:37 +02:00
Lukas Wirth
0e41d15b82 Use the correct crates proc-macro loading error message 2022-06-15 18:06:33 +02:00
Lukas Wirth
1d34cdcac0 Diagnose unresolved attribute proc-macros 2022-06-15 17:34:13 +02:00
Lukas Wirth
7d51fc4640 Show proc-macro loading errors in unresolved-proc-macro diagnostics 2022-06-15 17:34:01 +02:00
bors
15c63c4119 Auto merge of #12541 - Veykril:vs-reload, r=Veykril
fix: Clear proc-macro changed flag when reloading workspace
2022-06-15 12:29:34 +00:00
Lukas Wirth
664a751f2b fix: Clear proc-macro changed flag when reloading workspace 2022-06-15 14:29:13 +02:00
soruh
f52f5fed11 replace TODO with FIXME 2022-06-15 03:16:59 +02:00
soruh
dd0981e3bc fix CI 2022-06-15 03:07:42 +02:00
soruh
6a28cccaee remove dbg 2022-06-15 03:00:43 +02:00
soruh
8cac16b62e cleanup 2022-06-15 02:59:32 +02:00
soruh
8e3bbaa57b instanciate_empty_structs 2022-06-15 02:41:28 +02:00
Hongxu Xu
549c810436 revert hir-def lib.rs 2022-06-15 07:48:34 +08:00
Hongxu Xu
8805a768d4 check if the container is trait and inherit the visibility 2022-06-15 07:47:06 +08:00
Hongxu Xu
070456838d remove inherit_visibility test case in item_tree 2022-06-14 23:24:48 +08:00
Hongxu Xu
ded412d56b implement inherited_visibility in collector 2022-06-14 23:23:15 +08:00
Hongxu Xu
3f60e71a12 remove inherited_visibility in lower.rs 2022-06-14 21:44:07 +08:00
Hongxu Xu
d7eebd9706 add test cases to complete fn generated by macro in pub trait 2022-06-14 21:41:09 +08:00
Lukas Wirth
325ceaef19 fix: Check for the correct proc-macro settings in missing proc-macro diagnostics 2022-06-14 11:00:06 +02:00
Lukas Wirth
6438ef9aa3 internal: Bring back JodChild into flychecking for cancellation 2022-06-13 13:51:10 +02:00
bors
7db73875ac Auto merge of #12519 - Veykril:hover-assoc, r=Veykril
feat: On assoc item name hover, render trait decl docs
2022-06-13 09:58:04 +00:00
Lukas Wirth
9b9c13fc40 feat: On assoc item name hover, render trait decl docs 2022-06-13 11:57:33 +02:00
bors
366bd7242e Auto merge of #12515 - Veykril:rustc-proc-macros, r=Veykril
fix: Pass the build data to rustc_private crates

With this all proc-macros should resolve in rustc now when setting up the build script running command properly.
2022-06-12 17:35:55 +00:00
Lukas Wirth
10e9f47dce fix: Pass the build data to rustc_private crates 2022-06-12 19:29:45 +02:00
Lukas Wirth
0e4eb647f6 More precise proc-macro errors 2022-06-12 18:44:46 +02:00
bors
4f2a67b26f Auto merge of #12513 - Veykril:ty-utils, r=Veykril
internal: Simplify `hir_ty::utils`
2022-06-12 14:08:08 +00:00
Lukas Wirth
9153f17382 internal: Simplify hir_ty::utils 2022-06-12 16:07:08 +02:00
bors
d513f657a3 Auto merge of #12509 - Veykril:ty-utils, r=Veykril
internal: Remove `Generics::type_iter` in favor of `Generics::iter`
2022-06-12 12:40:57 +00:00
Lukas Wirth
7a0ab1358c internal: Remove Generics::type_iter in favor of Generics::iter 2022-06-12 14:40:37 +02:00
bors
eacade27ce Auto merge of #12455 - bitgaoshu:fix_12441, r=flodiebold
fix: #12441 False-positive type-mismatch error with generic future

I think the reason is same with #11815.
add ```Sized``` bound for ```AsyncBlockTypeImplTrait```.
2022-06-12 09:01:00 +00:00
bors
604b1c8409 Auto merge of #12508 - Veykril:req-retry, r=Veykril
fix: Don't respond to cancelled requests when retrying them

Fixes https://github.com/rust-lang/rust-analyzer/issues/12482
2022-06-12 00:56:52 +00:00
Lukas Wirth
ad109f7f0a fix: Don't respond to cancelled requests when retrying them 2022-06-12 02:56:19 +02:00
bors
37b01f9f39 Auto merge of #12504 - rust-lang:Veykril-patch-1, r=Veykril
fix: Fix config patching for callable snippets

Closes https://github.com/rust-lang/rust-analyzer/issues/12498
2022-06-11 11:41:26 +00:00
Lukas Wirth
a7a1a83463
fix: Fix config patching for callable snippets 2022-06-11 13:41:06 +02:00