Commit graph

31798 commits

Author SHA1 Message Date
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
bors
1eb4bba6fb Auto merge of #128321 - BatmanAoD:catch-unwind-doc-update, r=Mark-Simulacrum
Update `catch_unwind` doc comments for `c_unwind`

Updates `catch_unwind` doc comments to indicate that catching a foreign exception _will no longer_ be UB. Instead, there are two possible behaviors, though it is not specified which one an implementation will choose.

Nominated for t-lang to confirm that they are okay with making such a promise based on t-opsem FCP, or whether they would like to be included in the FCP.

Related: https://github.com/rust-lang/rust/issues/74990, https://github.com/rust-lang/rust/issues/115285, https://github.com/rust-lang/reference/pull/1226
2024-09-29 05:54:47 +00:00
bors
cb80b2ec2b Auto merge of #123778 - jhorstmann:optimize-upper-lower-auto-vectorization, r=the8472
Improve autovectorization of to_lowercase / to_uppercase functions

Refactor the code in the `convert_while_ascii` helper function to make it more suitable for auto-vectorization and also process the full ascii prefix of the string. The generic case conversion logic will only be invoked starting from the first non-ascii character.

The runtime on a microbenchmark with a small ascii-only input decreases from ~55ns to ~18ns per iteration. The new implementation also reduces the amount of unsafe code and encapsulates all unsafe inside the helper function.

Fixes #123712
2024-09-28 23:56:37 +00: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
bors
1e9bf5c693 Auto merge of #130329 - khuey:reorder-constant-spills, r=davidtwco
Reorder stack spills so that constants come later.

Currently constants are "pulled forward" and have their stack spills emitted first. This confuses LLVM as to where to place breakpoints at function entry, and results in argument values being wrong in the debugger. It's straightforward to avoid emitting the stack spills for constants until arguments/etc have been introduced in debug_introduce_locals, so do that.

Example LLVM IR (irrelevant IR elided):
Before:
```
define internal void `@_ZN11rust_1289457binding17h2c78f956ba4bd2c3E(i64` %a, i64 %b, double %c) unnamed_addr #0 !dbg !178 { start:
  %c.dbg.spill = alloca [8 x i8], align 8
  %b.dbg.spill = alloca [8 x i8], align 8
  %a.dbg.spill = alloca [8 x i8], align 8
  %x.dbg.spill = alloca [4 x i8], align 4
  store i32 0, ptr %x.dbg.spill, align 4, !dbg !192            ; LLVM places breakpoint here.
    #dbg_declare(ptr %x.dbg.spill, !190, !DIExpression(), !192)
  store i64 %a, ptr %a.dbg.spill, align 8
    #dbg_declare(ptr %a.dbg.spill, !187, !DIExpression(), !193)
  store i64 %b, ptr %b.dbg.spill, align 8
    #dbg_declare(ptr %b.dbg.spill, !188, !DIExpression(), !194)
  store double %c, ptr %c.dbg.spill, align 8
    #dbg_declare(ptr %c.dbg.spill, !189, !DIExpression(), !195)
  ret void, !dbg !196
}
```
After:
```
define internal void `@_ZN11rust_1289457binding17h2c78f956ba4bd2c3E(i64` %a, i64 %b, double %c) unnamed_addr #0 !dbg !178 { start:
  %x.dbg.spill = alloca [4 x i8], align 4
  %c.dbg.spill = alloca [8 x i8], align 8
  %b.dbg.spill = alloca [8 x i8], align 8
  %a.dbg.spill = alloca [8 x i8], align 8
  store i64 %a, ptr %a.dbg.spill, align 8
    #dbg_declare(ptr %a.dbg.spill, !187, !DIExpression(), !192)
  store i64 %b, ptr %b.dbg.spill, align 8
    #dbg_declare(ptr %b.dbg.spill, !188, !DIExpression(), !193)
  store double %c, ptr %c.dbg.spill, align 8
    #dbg_declare(ptr %c.dbg.spill, !189, !DIExpression(), !194)
  store i32 0, ptr %x.dbg.spill, align 4, !dbg !195            ; LLVM places breakpoint here.
    #dbg_declare(ptr %x.dbg.spill, !190, !DIExpression(), !195)
  ret void, !dbg !196
}
```
Note in particular the position of the "LLVM places breakpoint here" comment relative to the stack spills for the function arguments. LLVM assumes that the first instruction with with a debug location is the end of the prologue. As LLVM does not currently offer front ends any direct control over the placement of the prologue end reordering the IR is the only mechanism available to fix argument values at function entry in the presence of MIR optimizations like SingleUseConsts. Fixes #128945

r? `@michaelwoerister`
2024-09-26 02:37:52 +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
bors
a6d21174de Auto merge of #130812 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-09-25 14:09:47 +00:00
Bas van Driel
b4f278b463
Changes for debug restarting 2024-09-25 15:02:36 +02:00
Laurențiu Nicola
f84aa5de4a Add missing rustc_private 2024-09-25 10:56:37 +03: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
Laurențiu Nicola
6c24765cd4 Add more LayoutError variants 2024-09-25 09:15:11 +03:00
Laurențiu Nicola
d0c3ef0ae4 Bump rustc crates 2024-09-25 09:05:38 +03:00
Laurențiu Nicola
37f7190b3e Merge from rust-lang/rust 2024-09-25 09:00:53 +03:00
Laurențiu Nicola
d62a3e74fe Preparing for merge from rust-lang/rust 2024-09-25 09:00:31 +03:00
bors
34842bc6ab Auto merge of #129587 - Voultapher:opt-for-size-variants-of-sort-impls, r=cuviper
Add `optimize_for_size` variants for stable and unstable sort as well as select_nth_unstable

- Stable sort uses a simple merge-sort that re-uses the existing - rather gnarly - merge function.
- Unstable sort jumps directly to the branchless heapsort fallback.
- select_nth_unstable jumps directly to the median_of_medians fallback, which is augmented with a custom tiny smallsort and partition impl.

Some code is duplicated but de-duplication would bring it's own problems. For example `swap_if_less` is critical for performance, if the sorting networks don't inline it perf drops drastically, however `#[inline(always)]` is also a poor fit, if the provided comparison function is huge, it gives the compiler an out to only instantiate `swap_if_less` once and call it. Another aspect that would suffer when making `swap_if_less` pub, is having to cfg out dozens of functions in in smallsort module.

Part of https://github.com/rust-lang/rust/issues/125612

r​? `@Kobzol`
2024-09-24 18:48:08 +00:00
bors
2f55a91552 Auto merge of #18164 - ShoyuVanilla:use-as-alias, r=Veykril
fix: Temporary fix for `remove_unused_imports` not handling import aliases correctly

Fixes #18129
2024-09-24 15:22:57 +00:00
Shoyu Vanilla
d4de84f58a fix: Temporary fix for remove_unused_imports not handling import aliases correctly 2024-09-24 23:48:04 +09:00
bors
af6b99c159 Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikic
llvm: replace some deprecated functions

`LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`.
Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-24 12:07:48 +00:00
bors
e775dd6c70 Auto merge of #18166 - ChayimFriedman2:dollar-crate-root, r=Veykril
fix: Fix a bug in span map merge, and add explanations of how span maps are stored

Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`.

The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.

Fixes #18163.
2024-09-24 11:01:05 +00:00
bors
f30d4ea9c0 Auto merge of #18161 - ChayimFriedman2:postfix-mut, r=Veykril
fix: Better support references in consuming postfix completions

Fixes #18155.
2024-09-24 10:46:48 +00:00
bors
a159b370ba Auto merge of #18160 - ChayimFriedman2:fix-18138, r=Veykril
fix: Fix name resolution when an import is resolved to some namespace and then later in the algorithm another namespace is added

The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it.

This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully.

That PR is also why IDE features did work: the import at the end was resolved correctly, so IDE features that re-resolved the macro path resolved it correctly.

I was concerned about the performance of this, but this doesn't seem to regress `analysis-stats .`, so I guess it's fine to land this. I have no idea about the incremental perf however and I don't know how to measure that, although when typing in `zbus` (including creating a new function, which should recompute the def map) completion was fast enough.

I didn't check what rustc does, so maybe it does something more performant, like keeping track of only possibly problematic imports.

Fixes #18138.
Probably fixes #17630.
2024-09-24 10:32:28 +00:00
bors
b6b56d2abe Auto merge of #18157 - davidbarsky:davidbarsky/respect-disabling-proc-macros-in-analysis-stats, r=Veykril
analysis-stats: respect `--disable-proc-macros` flag

I noticed that this flag wasn't being respected by `analysis-stats` when profiling proc macro expansion, so here's a small fix.
2024-09-24 10:17:56 +00:00
bors
b4eff8971d Auto merge of #18123 - jhgg:fix-ambigius-package-cargo-check, r=Veykril
fix: fix ambigious package name in flycheck

fixes #18121
2024-09-24 10:03:41 +00:00
bors
7eb10bda57 Auto merge of #18175 - Wilfred:completion_marker, r=Veykril
internal: Make COMPLETION_MARKER more explicitly r-a

If a user ever sees the completion marker, it's confusing to see text about IntelliJ. Use a string that's more explicitly about completion for rust-analyzer.
2024-09-24 09:49:25 +00:00
bors
dfee4c8690 Auto merge of #18162 - ChayimFriedman2:gat-object-safe, r=Veykril
fix: Consider lifetime GATs object unsafe

Fixes #18156.
2024-09-24 08:14:00 +00:00
bors
f7ca65ff56 Auto merge of #130620 - onur-ozkan:update-make-prepare, r=Kobzol
remove workaround for make prepare and use dry-run build instead

Removes an annoying hard-coded logic.

try-job: x86_64-msvc
2024-09-23 22:19:24 +00:00
Wilfred Hughes
d95ad12c9c internal: Make COMPLETION_MARKER more explicitly r-a
If a user ever sees the completion marker, it's confusing to see text
about IntelliJ. Use a string that's more explicitly about completion
for rust-analyzer.
2024-09-23 17:04:04 -04:00