Commit graph

31764 commits

Author SHA1 Message Date
Laurențiu Nicola
525c1ceaf0 Use macos-13 runners and bump MACOSX_DEPLOYMENT_TARGET 2024-10-08 13:00:58 +03:00
bors
2b750da1a1 Auto merge of #18255 - ChayimFriedman2:stack-overflow, r=HKalbasi
Use external stack in borrowck DFS

Because damnit, it can crash r-a. Why do people make this stupid DFSes anyway (I get it, it's easier until it blows).

Fixes #18223 (who thought DFS will be the problem).
2024-10-06 21:23:00 +00:00
Chayim Refael Friedman
13f853464c Use external stack in borrowck DFS
Because damnit, it can crash r-a. Why do people make this stupid DFSes anyway (I get it, it's easier until it blows).
2024-10-06 23:48:16 +03:00
bors
5982d9c420 Auto merge of #18227 - davidbarsky:davidbarsky/push-lmntvwvznyyx, r=davidbarsky
internal: add json `tracing` Layer for profiling startup

On `buck2/integrations/rust-project`, this results in the following being printed:

```json
{"name":"discover_command","elapsed_ms":18703}
{"name":"parallel_prime_caches","elapsed_ms":0}
{"name":"vfs_load","elapsed_ms":5895}
{"name":"vfs_load","elapsed_ms":547}
{"name":"parallel_prime_caches","elapsed_ms":23}
{"name":"parallel_prime_caches","elapsed_ms":84}
{"name":"parallel_prime_caches","elapsed_ms":5819}
```
2024-10-04 17:59:02 +00:00
David Barsky
56c10ca981 internal: add JSON formatting for hprof 2024-10-04 11:26:15 -04:00
bors
510f72e12c Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykril
internal: Filter out opaque tokens in some IDE feature macro descensions
2024-10-04 10:26:04 +00:00
Lukas Wirth
24d65bb7cf internal: Filter out opaque tokens in some of IDE feature macro descensions 2024-10-04 11:53:12 +02:00
bors
e1a76671af Auto merge of #18219 - Veykril:veykril/push-ytnzuvtoswqz, r=Veykril
fix: Fix bootstrap error message being incorrect

precedence ...
2024-10-01 10:36:27 +00:00
Lukas Wirth
ac4edbf9dc fix: Fix bootstrap error message being incorrect 2024-10-01 12:33:53 +02:00
bors
417ee6f04a Auto merge of #18206 - ShoyuVanilla:issue-18187, r=Veykril
Fix: Handle block exprs as modules when finding their parents

Fixes #18187
2024-10-01 05:32:31 +00:00
Shoyu Vanilla
e09c2a08d7 Fix: Handle block exprs as modules when finding their parents 2024-10-01 14:05:15 +09:00
bors
28830ff2f1 Auto merge of #18195 - davidbarsky:davidbarsky/push-xkqnsyksmzqv, r=Veykril
internal: remove `Default` from OpQueue

`@Wilfred` and I were talking about `OpQueue` and we identified one symptom of its (relative) weirdness is that `last_op_result` returns a `T::default()`; not `Option<&T>`, which means it's not possible to distinguish between "the `OpQueue` hasn't run yet" and "the OpQueue ran, but didn't produce a result". This branch fixes that.
2024-09-30 14:20:11 +00:00
David Barsky
fc6eb66450 internal: remove Default from OpQueue 2024-09-30 10:12:52 -04:00
bors
ac8509a74b Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykril
fix: Fix resolution of label inside macro

When working on Something Else (TM) (I left a hint in the commits :P), I noticed to my surprise that labels inside macros are not resolved. This led to a discovery of *two* unrelated bugs, which are hereby fixed in two commits.
2024-09-30 13:09:54 +00:00
Chayim Refael Friedman
cd7cbddaf6 When resolving labels in break and continue for the IDE, do not resolve them textually, instead reuse the results of HIR lowering
This fixes a bug where labels inside macros were not resolved, but more importantly this prepares us to a future where we have hygiene, and textual equivalence isn't enough to resolve identifiers.
2024-09-30 15:13:45 +03:00
bors
dfe6d503b8 Auto merge of #18167 - SomeoneToIgnore:fat-completions, r=Veykril
internal: Send less data during `textDocument/completion` if possible

Similar to https://github.com/rust-lang/rust-analyzer/pull/15522, stops sending extra data during `textDocument/completion` if that data was set in the client completions resolve capabilities, and sends those only during `completionItem/resolve` requests.
Currently, rust-analyzer sends back all fields (including potentially huge docs) for every completion item which might get large.

Same as the other one, this PR aims to keep the changes minimal and does not remove extra computations for such fields — instead, it just filters them out before sending to the client.

The PR omits primitive, boolean and integer, types such as `deprecated`, `preselect`, `insertTextFormat`, `insertTextMode`, etc.  AND `additionalTextEdits` — this one looks very dangerous to compute for each completion item (as the spec says we ought to if there's no corresponding resolve capabilities provided) due to the diff computations and the fact that this code had been in the resolution for some time.
It would be good to resolve this lazily too, please let me know if it's ok to do.

When tested with Zed which only defines `documentation` and `additionalTextEdits` in its client completion resolve capabilities, rust-analyzer starts to send almost 3 times less characters:

Request:
```json
{"jsonrpc":"2.0","id":104,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs"},"position":{"line":90,"character":14},"context":{"triggerKind":1}}}
```

<img width="1338" alt="image" src="https://github.com/user-attachments/assets/104f19b5-7095-4fc1-b008-5d829623b2e2">

Before: 381944 characters
[before.json](https://github.com/user-attachments/files/17092385/before.json)

After: 140503 characters
[after.json](https://github.com/user-attachments/files/17092386/after.json)

After Zed's [patch](https://github.com/zed-industries/zed/pull/18212) to enable all resolving possible: 84452 characters
[after-after.json](https://github.com/user-attachments/files/17092755/after-after.json)
2024-09-30 08:36:54 +00:00
bors
7b60339273 Auto merge of #18207 - mbwilding:master, r=Veykril
fix: Ambiguity with CamelCase diagnostic messages, align with rustc warnings

Fixed diagnostic messages so they say UpperCamelCase rather than CamelCase, as it is ambiguous.
Usually I'd call it PascalCase, but in the code base it is called UpperCamelCase so I left it with that naming choice.

`rustc` says `upper camel case` also when the case is wrong
```
warning: trait `testThing` should have an upper camel case name
 --> src/main.rs:5:7
  |
5 | trait testThing {
  |       ^^^^^^^^^ help: convert the identifier to upper camel case: `TestThing`
  |
  = note: `#[warn(non_camel_case_types)]` on by default
```

This is in line with the UPPER_SNAKE_CASE diagnostic messages.
546339a7be/crates/hir-ty/src/diagnostics/decl_check.rs (L60)
546339a7be/crates/ide-diagnostics/src/handlers/incorrect_case.rs (L535)
2024-09-30 08:22:29 +00:00
bors
ceee056af6 Auto merge of #18085 - ChayimFriedman2:gate-test, r=Veykril
feat: Provide an config option to not set `cfg(test)`

Fixes #17957.
2024-09-30 06:32:20 +00:00
Chayim Refael Friedman
4a06675e9c Gate #[test] expansion under cfg(test).
This will mean users opting to not activate `cfg(test)` will lose IDE experience on them, which is quite unfortunate, but this is unavoidable if we want to avoid false positives on e.g. diagnostics. The real fix is to provide IDE experience even for cfg'ed out code, but this is out of scope for this PR.
2024-09-30 00:12:45 +03:00
Chayim Refael Friedman
4ea09dd9f6 Provide an config option to not set cfg(test) 2024-09-30 00:12:45 +03:00
bors
822644d97d Auto merge of #18205 - noahmbright:object_safety, r=HKalbasi
Rename object_safety

First PR here (yay!), so I read some of the getting started docs. There are a couple references to `handlers.rs`, which as far as I can tell has been refactored into `handlers/*.rs`. I made some tweaks to that in one commit. There is one fixme about a function called `to_lsp_runnable`, which I can't find anywhere at all. I can update that if I get some more info there.

Otherwise I changed references to object safety, is object safe, etc., trying to match case/style as I went. There was one case I found where there's a trait from somewhere else called `is_object_safe`, which I found defined in my cargo registry. I didn't touch that for now, just marked it with a fixme
2024-09-29 20:20:26 +00:00
Chayim Refael Friedman
9798cf81de When glueing together tokens from macros, merge their spans 2024-09-29 22:58:15 +03:00
bors
792e79566d Auto merge of #18208 - davidbarsky:davidbarsky/push-qkwkmttnukqt, r=lnicola
internal: allow overriding proc macro server in analysis-stats

Needed this argument in order to profile the proc macro expansion server (c.f., [this Zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/.60macro_rules!.60-based.20macros.20for.20derives.2Fattributes/near/473466794)). I also took the opportunity to change the phrasing for `--proc-macro-srv`.

Ran with `samply record ~/.cargo/bin/rust-analyzer analysis-stats --proc-macro-srv /Users/dbarsky/.cargo/bin/rust-analyzer-proc-macro-srv --parallel .` on rust-analyzer itself.
2024-09-29 17:54:20 +00:00
David Barsky
931b1c32c9 internal: allow overriding proc macro server in analysis-stats 2024-09-29 12:09:16 -04:00
Noah Bright
4255cae1bb Rename object_safety to dyn_compatibility
Up to a trait implemented by another package, linking to
$CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
2024-09-29 07:26:45 -04:00
Matthew Wilding
60219d0b11
Fix ambiguity with CamelCase diagnostic messages 2024-09-29 16:35:37 +08:00
Noah Bright
01aaa53ef2 Update handlers.rs to handlers/requests.rs 2024-09-28 06:17:22 -04:00
bors
546339a7be Auto merge of #18192 - darichey:read-buildfile-into-vfs, r=Veykril
Include buildfiles in VFS

We subscribe to `textDocument/didSave` for `filesToWatch`, but the VFS doesn't contain those files. Before https://github.com/rust-lang/rust-analyzer/pull/18105, this would bring down the server. Now, it's only a benign error logged:
```
ERROR notification handler failed handler=textDocument/didSave error=file not found: /foo/bar/TARGETS
```
It's benign, because we will also receive a `workspace/didChangeWatchedFiles` for the file which will invalidate and load it.

Explicitly include the buildfiles in the VFS to prevent the handler from erroring.
2024-09-27 19:39:35 +00:00
bors
68f3e4d636 Auto merge of #18204 - ChrisDenton:cc, r=lnicola
Update cc to 1.1.22

This version of `cc` contains [a fix](https://github.com/rust-lang/cc-rs/releases/tag/cc-v1.1.22) to prevent spurious rebuilds. Hopefully this should help avoid the CI issues rustc has been having.
2024-09-27 17:57:14 +00:00
Chris Denton
c4103bdf59
Update cc to 1.1.22 2024-09-27 17:50:06 +00:00
bors
62649a57be Auto merge of #17923 - basvandriel:feature/build-before-restart-debug, r=Veykril
Building before a debugging session was restarted

# Background
Resolves #17901. It adds support for rebuilding after debugging a test was restarted. This means the test doesn't have to be aborted and manually re-ran again.

# How this is tested
First, all the Visual Studio Code extensions are loaded into an Extension Host window. Then, a sample test like below was ran and restarted to see if it was correctly rebuild.

```rust
#[test]
fn test_x() {
    assert_eq!("1.1.1", "1.1.0");
}
```
2024-09-27 11:06:21 +00:00
bors
233b1ac14e Auto merge of #18196 - DropDemBits:sed-syntax-factory, r=Veykril
internal: Add `SyntaxFactory` to ease generating nodes with syntax mappings

Part of [#​15710](https://github.com/rust-lang/rust-analyzer/issues/15710)

Instead of requiring passing a `&mut SyntaxEditor` to every make constructor to generate mappings, we instead wrap that logic in `SyntaxFactory`, and afterwards add all the mappings to the `SyntaxEditor`.

Includes an example of using `SyntaxEditor` & `SyntaxFactory` in the `extract_variable` assist.
2024-09-27 05:44:11 +00:00
bors
c482421316 Auto merge of #18197 - alibektas:buggy_flycheck_message, r=Veykril
minor: Stricter requirements for package wide flycheck

Require the existence of a target and `check_workspace` to be false to restart package-wide flycheck. Fixes #18194 , #18104
2024-09-27 05:14:35 +00:00
Ali Bektas
aeed8f89a3 minor: Require both the existence of a target and check_workspace to be false to restart package-wide flycheck 2024-09-27 02:40:53 +02:00
DropDemBits
f9ad9a0bb6
minor: Use SyntaxEditor in extract_variable 2024-09-26 16:29:16 -04:00
DropDemBits
05b48e4005
internal: Add SyntaxFactory to ease generating nodes with syntax mappings 2024-09-26 16:28:48 -04:00
bors
c88ea11832 Auto merge of #18193 - Wilfred:startup_error, r=lnicola
fix: Don't report a startup error when a discover command is configured

Previously, r-a would show an error if both fetch_workspaces_queue and discover_workspace_queue were empty. We're in this state at startup, so users would see an error if they'd configured
discover_workspace_config.

Instead, allow the fetch_workspaces_queue to have zero items if discover_workspace_config is set.

Whilst we're here, prefer "failed to fetch" over "failed to discover", so the error message better reflects what this function is doing.
2024-09-26 18:56:08 +00:00
Wilfred Hughes
f498184cbb fix: Don't report a startup error when a discover command is configured
Previously, r-a would show an error if both fetch_workspaces_queue and
discover_workspace_queue were empty. We're in this state at startup,
so users would see an error if they'd configured
discover_workspace_config.

Instead, allow the fetch_workspaces_queue to have zero items if
discover_workspace_config is set.

Whilst we're here, prefer "failed to fetch" over "failed to discover",
so the error message better reflects what this function is doing.
2024-09-26 14:33:30 -04:00
David Richey
85ca217765 Include buildfiles in vfs 2024-09-26 12:54:55 -04:00
bors
af9a658864 Auto merge of #18188 - darichey:msrv, r=lnicola
Require rust 1.81

rust-analyzer doesn't build on 1.80 because we use `#[expect(lint)]`:
```
error[E0658]: the `#[expect]` attribute is an experimental feature
  --> crates/hir-expand/src/prettify_macro_expansion_.rs:11:1
   |
11 | #[expect(deprecated)]
   | ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #54503 <https://github.com/rust-lang/rust/issues/54503> for more information
```
2024-09-26 10:54:00 +00:00
David Richey
0536f18db2 Require rust 1.81 2024-09-25 17:02:17 -04:00
bors
88fad4983e Auto merge of #18180 - kpreid:search, r=davidbarsky
feat: Index workspace symbols at startup rather than on the first symbol search.

This will eliminate potential many-second delays when performing the first search, at the price of making cache priming (“Indexing N/M” in the VS Code status bar) take a little longer in total. Hopefully this additional time is insignificant because a typical session will involve at least one symbol search.

Further improvement would be to do this as a separate parallel task (which will be beneficial if the workspace contains a small number of large crates), but that would require significant additional refactoring of the progress-reporting mechanism to understand multiple tasks per crate. Happy to tackle that in this PR if desired, but I thought I'd propose the minimal change first.
2024-09-25 17:14:39 +00:00
bors
df478ea93c Auto merge of #18181 - davidbarsky:davidbarsky/push-nzstpumovmmx, r=davidbarsky
internal: add tracing to project discovery and VFS loading

With `"env RA_PROFILE=vfs_load|parallel_prime_caches|discover_command>500`, this results in the following output:

```
21888ms discover_command
11627ms vfs_load @ total = 701
1503ms vfs_load @ total = 701
30211ms parallel_prime_caches
```

As a followup, I'd like to make hprof emit the information above as JSON.
2024-09-25 16:48:05 +00:00
Kevin Reid
a050c5de9b Prime caches for symbol search too. 2024-09-25 09:41:09 -07:00
David Barsky
338003f30e internal: add tracing to project discovery and VFS loading 2024-09-25 10:10:25 -04:00
Bas van Driel
b4f278b463
Changes for debug restarting 2024-09-25 15:02:36 +02:00
bors
7ab2c171bf Auto merge of #18183 - lnicola:sync-from-rust, r=lnicola
internal: Sync from downstream
2024-09-25 06:41:56 +00:00
bors
82b2d07f6a Auto merge of #18184 - Veykril:veykril/push-wsqsyxynttps, r=Veykril
fix: Pass all-targets for build scripts in more cli commands

Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
2024-09-25 06:27:31 +00:00
Laurențiu Nicola
f4bcae32fe Run rustfmt 2024-09-25 09:26:15 +03:00
Lukas Wirth
10ada02019 Pass all-targets for build scripts in more cli commands
Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
2024-09-25 08:23:09 +02:00