Commit Graph

27973 Commits

Author SHA1 Message Date
roife
5c9ce7b11f test: add tests for keeping attrs in assist 'generate_delegate_trait' 2024-03-06 15:32:49 +08:00
roife
faea7fca01 fix: keep attrs for assist 'generate_delegate_trait' 2024-03-06 15:32:26 +08:00
bors
767d5d3eab Auto merge of #16662 - HKalbasi:test-explorer, r=HKalbasi
Add test explorer

This PR implements the vscode testing api similar to #14589, this time using a set of lsp extensions in order to make it useful for clients other than vscode, and make the vscode client side logic simpler (its now around ~100 line of TS code)

Fix #3601
2024-03-05 20:50:26 +00:00
hkalbasi
44be2432f5 Add test explorer 2024-03-06 00:05:29 +03:30
bors
916914418a Auto merge of #16763 - regexident:param-accessors, r=Veykril
Add `fn index()` and `fn parent_fn()` accessors for `hir::Param`/`hir::SelfParam`

(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to access a `hir::Param`'s/`hir::SelfParam`'s index and parent function)
2024-03-05 15:12:18 +00:00
Vincent Esche
bf141310f8 Add fn index() accessor for hir::Param 2024-03-05 16:02:22 +01:00
Vincent Esche
1afeea85ff Add fn parent_fn() accessors for hir::Param & hir::SelfParam 2024-03-05 16:01:01 +01:00
Wyatt Herkamp
6027eae51e Fix Tests + Fix Warnings 2024-03-05 08:34:52 -05:00
Wyatt Herkamp
b45cfe15b5 Added quickfix for unresolved field. 2024-03-05 08:07:21 -05:00
bors
223238d9e7 Auto merge of #16759 - roife:fix-goto-def-for-constants-in-range-pattern, r=Veykril
fix: goto-definition for constants inside range pattern

Fix #15653.

This PR addresses the issue where it was not possible to navigate to constants in range patterns, specifically including two major changes:

1. Previously, both the `start` and `end` fields in `Pat::Range` were of type `LiteralOrConst`. When performing `goto-definition` on constants inside range patterns, r-a would use `resolve_bind_pat_to_const` to find their definitions. However, because the content of a `Const` is not `Pat` but `Path`, it was not stored in the `source_map`, so `resolve_bind_pat_to_const` would returns `None`. This PR changes them to `Const(PatId)`, so that during the lowering process, they are considered as a `pat`, allowing their definitions to be found later through `resolve_bind_pat_to_const`.

2. The process related to range patterns in MIR-lowering has been modified to correctly handle the above changes.
2024-03-05 12:35:03 +00:00
bors
7c786ed96f Auto merge of #16761 - Young-Flash:ignore_hidden, r=Veykril
minor: remove `ignore-hidden = false`

run `typos` locally and get
```txt
error: `ND` should be `AND`
  --> ./.git/objects/20/a90c507b0c92883b10c29447a56d30bf9e8d57:1:515
  |
1 | xM�{L�a�Cʒ��2�DG$�Q�+1�M.[��9o��z/��<ou�Tn�ICn��˺g�VG�BFmg�j5˵�:2�p�z�����w�ۃ]�V�˼��>>���T$�
                                                                                                Đ��bgJ博3�gzr�ꝛQ�p��x����� u���"Ui"�gw��f�;�>�;���d��0�~�nvx>���+u��;c\��~�T,Ԏ�ԁ��惵���>�[����B�L8R` ��8V� ��~��lrN~��>�s�Y�Z�p"�T�mFA܁�KJ[�b�Ko���>^��Y�
                     c��7�r��0�>{Wl��ꉔ����#��E��L���#�ehm�fiA�h��9#E�������W�(\�h���`���Ca� ��H��� ;qp������:(.i���{*>�"���%���=;4O/ =�:�EZ�gD�)m��������A��ϋ��c�I���e�"��8�[r�%�}CY����=p[F�D,G��d��،��}ms��^��^�.�UC�ND
  |
```
we should ignore `.git`
2024-03-05 12:20:56 +00:00
Young-Flash
b06726bebe remove ignore-hidden = false 2024-03-05 20:16:32 +08:00
roife
9cc3a9cfc2 fix: formatting 2024-03-05 19:55:31 +08:00
Lukas Wirth
d21f88883b Remove some unnecessary cloning in method_resolution 2024-03-05 12:39:27 +01:00
Lukas Wirth
593156a357 Re-use InferenceTable by snapshotting in method resolution 2024-03-05 12:39:27 +01:00
roife
16995ceda9 test: add tests for constants inside range pattern 2024-03-05 19:31:20 +08:00
roife
96a7c6ae3c fix: mir for range pattern 2024-03-05 19:31:20 +08:00
roife
ece18fecfa fix: resolve sub-patterns inside range pattern 2024-03-05 19:31:20 +08:00
bors
2898c4217d Auto merge of #16758 - Veykril:cargo-lock, r=Veykril
Update Cargo.lock
2024-03-05 11:17:42 +00:00
Lukas Wirth
00a6cc0664 Update Cargo.lock 2024-03-05 12:16:19 +01:00
bors
676455f911 Auto merge of #16757 - Veykril:style-lints, r=Veykril
fix: Put style lints behind disabled-by-default config

Fixes https://github.com/rust-lang/rust-analyzer/issues/16542
Fixes https://github.com/rust-lang/rust-analyzer/issues/16725
cc https://github.com/rust-lang/rust-analyzer/issues/16628

Our diagnostic infra is not yet setup for those kinds of diagnostics
2024-03-05 10:45:05 +00:00
Lukas Wirth
8844640c6f fix: Put style lints behind disabled-by-default config 2024-03-05 11:43:23 +01:00
bors
124d5ff966 Auto merge of #16756 - Veykril:hover-trait, r=Veykril
internal: Adjust a few things for trait assoc item hovers

https://github.com/rust-lang/rust-analyzer/pull/15938 (minor turned major wrt diff because of test changes)
2024-03-05 10:16:04 +00:00
Lukas Wirth
b20e467373 internal: Adjust a few things for trait assoc item hovers 2024-03-05 11:06:36 +01:00
Lukas Wirth
6b48133e9a Prefer cargo proxies when setting RUSTUP_TOOLCHAIN 2024-03-05 10:44:17 +01:00
Lukas Wirth
c310aee8d6 For toolchain binaries ue the full path found in $PATH 2024-03-05 10:17:09 +01:00
Lukas Wirth
fe0daa7be3 Revert "prioritise rustup sysroots over system ones"
This reverts commit 9f1d4aa4b9.
2024-03-05 09:37:25 +01:00
bors
ce3216e0ae Auto merge of #15938 - Young-Flash:display_trait_item_when_hover, r=Veykril
feat: add hover display for trait assoc items

This PR enable preview assoc items when hover on `trait`

![image](https://github.com/rust-lang/rust-analyzer/assets/71162630/d9c3949c-33cf-4a32-aa97-3af46b28033a)

inspired by https://github.com/rust-lang/rust-analyzer/pull/15847
2024-03-05 08:26:53 +00:00
bors
0c2e9feaee Auto merge of #16752 - Lindronics:destructure-struct-binding, r=Veykril
fix: Don't destructure struct with no public fields

Unfortunately I missed this case in #16638.

If a struct only has private members, the assist should not be applicable. Though valid syntax exists (`Foo { .. }`), it isn't particularly useful. Since this case applies to a lot of common types (`Arc`, `Vec`, ...), it probably makes the most sense to hide the action.

As a side effect, this also disables the action for unit structs, where it also isn't particularly useful. I'd be open to changing it though if you think it makes more sense to keep it.

This also fixes the `make::record_pat_field_list` function to produce valid syntax if the field list is empty, as it is used in other places too.

## Current behaviour
```rust
// In crate `other_crate`
pub struct Foo { bar: i32 }

// In current crate
fn do_something(foo: other_crate::Foo) {}

// Becomes
fn do_something(other_crate::Foo { , .. }: other_crate::Foo) {}
```

## Fixed behaviour
Assist should not be applicable in this case anymore.
2024-03-05 08:03:13 +00:00
bors
58e10c7d17 Auto merge of #16753 - rust-lang:dependabot/cargo/mio-0.8.11, r=lnicola
minor: Bump mio from 0.8.5 to 0.8.11

Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.5 to 0.8.11.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md">mio's changelog</a>.</em></p>
<blockquote>
<h1>0.8.11</h1>
<ul>
<li>Fix receiving IOCP events after deregistering a Windows named pipe
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1760">tokio-rs/mio#1760</a>, backport pr:
<a href="https://redirect.github.com/tokio-rs/mio/pull/1761">tokio-rs/mio#1761</a>).</li>
</ul>
<h1>0.8.10</h1>
<h2>Added</h2>
<ul>
<li>Solaris support
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1724">tokio-rs/mio#1724</a>).</li>
</ul>
<h1>0.8.9</h1>
<h2>Added</h2>
<ul>
<li>ESP-IDF framework support
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1692">tokio-rs/mio#1692</a>).</li>
<li>AIX operating system support
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1704">tokio-rs/mio#1704</a>).</li>
<li>Vita support
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1721">tokio-rs/mio#1721</a>).</li>
<li><code>{UnixListener,UnixStream}:bind_addr</code>
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1630">tokio-rs/mio#1630</a>).</li>
<li><code>mio_unsupported_force_poll_poll</code> and <code>mio_unsupported_force_waker_pipe</code>
<strong>unsupported</strong> configuration flags to force a specific poll or waker
implementation
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1684">tokio-rs/mio#1684</a>,
<a href="https://redirect.github.com/tokio-rs/mio/pull/1685">tokio-rs/mio#1685</a>,
<a href="https://redirect.github.com/tokio-rs/mio/pull/1692">tokio-rs/mio#1692</a>).</li>
</ul>
<h2>Fixed</h2>
<ul>
<li>The <code>pipe(2)</code> based waker (swapped file descriptors)
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1722">tokio-rs/mio#1722</a>).</li>
<li>The duplicate waker check to work correctly with cloned <code>Registry</code>s.
(<a href="https://redirect.github.com/tokio-rs/mio/pull/1706">tokio-rs/mio#1706</a>).</li>
</ul>
<h1>0.8.8</h1>
<h2>Fixed</h2>
<ul>
<li>Fix compilation on WASI (<a href="https://redirect.github.com/tokio-rs/mio/pull/1676">tokio-rs/mio#1676</a>).</li>
</ul>
<h1>0.8.7</h1>
<h2>Added</h2>
<ul>
<li>Add/fix support for tvOS and watchOS, Mio should now build for tvOS and</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="0328bdef90"><code>0328bde</code></a> Release v0.8.11</li>
<li><a href="7084498512"><code>7084498</code></a> Fix warnings</li>
<li><a href="90d4fe00df"><code>90d4fe0</code></a> named-pipes: fix receiving IOCP events after deregister</li>
<li><a href="c710a307f8"><code>c710a30</code></a> Add v0.8.x to the CI</li>
<li><a href="c29e21c244"><code>c29e21c</code></a> Release v0.8.10</li>
<li><a href="f6a20da1c8"><code>f6a20da</code></a> Add Solaris operating system support (<a href="https://redirect.github.com/tokio-rs/mio/issues/1724">#1724</a>)</li>
<li><a href="e80c3b21b5"><code>e80c3b2</code></a> Release v0.8.9</li>
<li><a href="862786bbbf"><code>862786b</code></a> Fix importing of IoSourceState</li>
<li><a href="40348728e4"><code>4034872</code></a> Add support for vita target</li>
<li><a href="8eb4010a92"><code>8eb4010</code></a> Fix receiver and sender fd in pipe based waker</li>
<li>Additional commits viewable in <a href="https://github.com/tokio-rs/mio/compare/v0.8.5...v0.8.11">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=mio&package-manager=cargo&previous-version=0.8.5&new-version=0.8.11)](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` show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- ``@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)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/rust-lang/rust-analyzer/network/alerts).

</details>
2024-03-05 06:27:47 +00:00
Nicholas Nethercote
49c0b33862 Change message type in bug functions.
From `impl Into<DiagnosticMessage>` to `impl Into<Cow<'static, str>>`.

Because these functions don't produce user-facing output and we don't
want their strings to be translated.
2024-03-05 17:11:42 +11:00
Niklas Lindorfer
2a4ba4295b
fix: hide destructure_struct_binding assist if no public fields 2024-03-04 21:50:01 +00:00
dependabot[bot]
ac641a19e7
Bump mio from 0.8.5 to 0.8.11
Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.5 to 0.8.11.
- [Release notes](https://github.com/tokio-rs/mio/releases)
- [Changelog](https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/mio/compare/v0.8.5...v0.8.11)

---
updated-dependencies:
- dependency-name: mio
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-04 21:40:57 +00:00
bors
9f14343f9e Auto merge of #16751 - Veykril:codegen, r=Veykril
internal: Move diagnostics docs generation and lint definition generation into xtask/codegen
2024-03-04 16:50:18 +00:00
Lukas Wirth
b9dbb8afd9 Regenerate lints table 2024-03-04 17:42:18 +01:00
Lukas Wirth
76463eee48 Move lint definition generation into xtask/codegen 2024-03-04 17:14:14 +01:00
Lukas Wirth
0964374274 Move diagnostics docs generation into xtask/codegen 2024-03-04 17:14:14 +01:00
bors
4e8cbf36a8 Auto merge of #16708 - Veykril:codegen, r=Veykril
internal: Move ide-assists codegen tests into an xtask codegen command
2024-03-04 15:50:39 +00:00
bors
00879b1c57 Auto merge of #16750 - Veykril:unnecessary-else, r=Veykril
minor: Mark remove_unnecessary_else as experimental

cc https://github.com/rust-lang/rust-analyzer/issues/16566#issuecomment-1976492762 https://github.com/rust-lang/rust-analyzer/issues/16628

There seem to be some leftover issues with this, additionally its a style lint so it's not too nice to see for some people. We should flesh out our diagnostics stuff before adding more style lints I think
2024-03-04 15:37:52 +00:00
Lukas Wirth
6e802a0b56 minor: Mark remove_unnecessary_else as experimental 2024-03-04 16:35:33 +01:00
bors
a7e9f12bf7 Auto merge of #16748 - Veykril:on-demand-validation-err, r=Veykril
internal: Compute syntax validation errors on demand

The LRU cache causes us to re-parse trees quite often, yet we don't use the validation errors at all. With this we push calculating them off to the caller who is interested in them.
2024-03-04 11:19:16 +00:00
Lukas Wirth
c3c9f5ffe1 internal: Compute syntax validation errors on demand 2024-03-04 12:06:15 +01:00
bors
99a1b8f7a8 Auto merge of #16747 - Veykril:cleanup, r=Veykril
internal: Clean some stuff up

Just a bunch of small refactorings, mainly from browsing through `hir-def`
2024-03-04 10:30:17 +00:00
Lukas Wirth
4303e741de Cleanup 2024-03-04 11:10:06 +01:00
bors
2074cc28de Auto merge of #16722 - mo8it:allocations, r=Veykril
Avoid some allocations

I went on a small `.clone()` hunting tour :D
2024-03-04 09:17:23 +00:00
bors
d8feb908be Auto merge of #16703 - regexident:sema-ast-to-hir, r=Veykril
Add more methods for resolving definitions from AST to their corresponding HIR types

In order to be able to add these methods with consistent naming I had to also rename two existing methods that would otherwise be conflicting/confusing:

`Semantics::to_module_def(&self, file: FileId) -> Option<Module>` (before)
`Semantics::file_to_module_def(&self, file: FileId) -> Option<Module>` (after)

`Semantics::to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (before)
`Semantics::file_to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (after)

(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving its exprs/stmts/items to their HIR equivalents)
2024-03-04 09:02:32 +00:00
bors
0b7d4cc6ff Auto merge of #16690 - roife:fix-issue-16471, r=Veykril
fix: use 4 spaces for indentation in macro expansion

Partial fix for #16471.

In the previous code, the indentation produced by macro expansion was set to 2 spaces. This PR modifies it to 4 spaces for the sake of consistency.
2024-03-04 08:49:51 +00:00
bors
518cfe8cb7 Auto merge of #16723 - norskeld:constants-autocomplete, r=Veykril
fix: autocomplete constants inside format strings

Hi! This PR adds autocompletion for constants (including statics) inside format strings and closes #16608.

I'm not sure about adding the `constants` field to the `CompletionContext`. It kinda makes sense, since it's in line with the `locals` field, and this way everything looks a bit cleaner, but at the same time does it really need to be there?

Anyway, let me know if anything should/can be changed. :)
2024-03-04 08:36:39 +00:00
bors
d444acdb19 Auto merge of #16719 - lnicola:native-debug, r=lnicola
fix: Add basic support for Native Debug

Native Debug doesn't work very well and passing command-line arguments is nasty (https://github.com/rust-lang/rust-analyzer/issues/9815), but I guess it's a start.

Closes #9815
2024-03-04 08:16:01 +00:00
bors
037924c4d8 Auto merge of #16740 - lnicola:sync-from-rust, r=lnicola
internal: sync from downstream
2024-03-03 11:50:46 +00:00