Rollup of 7 pull requests - #161672
Conversation
Example
---
```rust
const _: &str = env!("PATH",);
```
**Before this PR**
```
/* expand error: expected string literal */
```
**After this PR**
```rust
const _: &str = "/usr/bin:/bin";
```
This is basically the most optimized (memory-wise) storage possible, found after multiple measurements. The price we pay for this ultra-extra optimization is a bunch of unsafe, encapsulated in `tt/src/storage.rs`. Since macros and therefore token trees are so common in Rust code, I think this is worth it. Some stats: - On rust-analyzer itself, memory usage is reduced by 30mb. rust-analyzer doesn't use macros a lot and the previous optimization already took the most, but when considering that *all* token trees in r-a now consumes only about 40mb, this is still surprising. - On buck2, ~143mb is saved. - On omicron, ~436mb is saved, and this is after the previous optimization already ripped 880mb! It is only using ~180mb for token trees now, in total! The basic idea is to use a variable-length encoding into a bytes array. Multiple measurements were done in order to determine the most common forms of token trees along with their frequencies, and to find the best encoding. In addition, we also now sort the compressed spans by their frequencies (in a descending order), so that even if a `TopSubtree` has more than 2^4 unique compressed spans, we will still use the more efficient encoding for the biggest number of spans possible. This is made possible by the fact that unlike the previous encoding, now we don't force one span encoding for all tokens (or in fact even for the two spans in one subtree).
fix: don't error on tail comma for some macro
Addresses the FIXME in `hir-ty/src/infer/op.rs` inside
`infer_user_unop`, which previously silently discarded operator method
resolution failures for `!x` and `-x` expressions.
When the operand's type does not implement `std::ops::Not` (for `!`) or
`std::ops::Neg` (for `-`), rust-analyzer now reports the same E0600
error that rustc produces:
cannot apply unary operator `!` to type `Question`
Wired through the standard inference diagnostic pipeline: new
`InferenceDiagnostic::UnaryOperatorCannotBeApplied` variant in hir-ty,
matching `UnaryOperatorCannotBeApplied` struct plus conversion in hir,
and a handler in ide-diagnostics using
`DiagnosticCode::RustcHardError("E0600")`.
Filtering for unresolved / error-typed operands is done in
`resolve_diagnostics()` (crates/hir-ty/src/infer/unify.rs) alongside
the existing `references_non_lt_error()` filter chain for other
diagnostics that carry a type. This keeps `infer_user_unop` free of
callsite guards and lets the natural inference pipeline suppress
spurious reports on incomplete code and on macro expansions that
infer to `{unknown}`.
The `unary_ops` region of `test-utils/src/minicore.rs` also gains
builtin `Not` and `Neg` impls, mirroring how `add_impl!` provides them
in the `add` region. Without these, the diagnostic test fixture would
incorrectly flag `!true`, `!0i32` and similar builtin uses as errors,
because `lookup_op_method` would find no impl in the minicore fixture
even though real `core` has one. With the impls present, primitives
resolve normally and only genuinely unsupported operators trigger the
diagnostic. This also lets us correctly report `-1u32` as E0600, since
real `core` does not implement `Neg` for unsigned integers.
Because the new `not_impl!` / `neg_impl!` blocks live in a nested
`region:builtin_impls` inside `region:unary_ops`, the new tests opt
into both flags via `//- minicore: unary_ops, builtin_impls`. The
existing `legacy_const_generics` test in `mismatched_arg_count` uses
`-1i32` / `-1i8` inline and now needs the same directive so that
`core::ops::Neg` is in scope for its operands.
Minicore `region:eq` and `region:float_consts` now depend on
`unary_ops, builtin_impls` so their smoke tests resolve `Not`/`Neg`
without per-callsite guards. The `Clone for [T; 1]` impl inside
`region:builtin_impls` uses `self[0]`, so it is scoped to a nested
`region:index` and only compiles when `index` is also enabled.
The `UnaryOp::Deref` case is left unchanged; it is already handled by
the `CannotBeDereferenced` diagnostic (E0614) and `infer_user_unop` is
never called for `Deref`.
Part of rust-lang/rust-analyzer#22140.
This updates the rust-version file to 2c39ff4.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@2c39ff4 Filtered ref: rust-lang/rust-analyzer@3b5a9a7 Upstream diff: rust-lang/rust@7fb284d...2c39ff4 This merge was created using https://github.com/rust-lang/josh-sync.
Rustc pull update
internal: Download all artifacts in a single step
internal: Drop `zigbuild` support
minor: Drop duplicate function
internal: Split VSIX publishing into different jobs and skip duplicates
…-defined fix: emit E0600 when unary `!`/`-` is applied to unsupported type
minor: skip iter excludes 'into_iter' method
Label operands were inferred with `infer_expr`, which demands the block's
type be equal to `()`. A block that diverges has type `!`, so code like
`label { break; }` inside a loop reported a false `expected (), found !`.
Follow rustc's handling in `check_expr_asm` and only demand a supertype
when the block does not diverge, saving and restoring `diverges` around
it.
…verges fix: allow `asm!` label blocks to diverge
This updates the rust-version file to f7d782a.
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@f7d782a Filtered ref: rust-lang/rust-analyzer@0417161 Upstream diff: rust-lang/rust@2c39ff4...f7d782a This merge was created using https://github.com/rust-lang/josh-sync.
Rustc pull update
minor: Fix 1.98.0 Clippy and rustfmt
This comment has been minimized.
This comment has been minimized.
Rollup of 7 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple-1 try-job: aarch64-apple-2 try-job: x86_64-mingw-1 try-job: i686-msvc-1 try-job: i686-msvc-2
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing ac62df9 (parent) -> 0a3fa2a (this PR) Test differencesShow 92 test diffsStage 0
Stage 1
Stage 2
Additionally, 14 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 0a3fa2af35783dcd1b4206a85fe7811297eea0bf --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (0a3fa2a): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (primary 2.4%, secondary 5.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 475.143s -> 469.763s (-1.13%) |
|
📌 Perf builds for each rolled up PR:
parent commit: ac62df9b49 In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
|
@rust-timer triage 6660a6a bae36a2 Regression is most likely noise but this is a good excuse to play with the triage command and find the improvement |
#160132 6660a6a make
|
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
5.1% | [5.1%, 5.1%] | 1 |
| Improvements ✅ (primary) |
-4.5% | [-4.5%, -4.5%] | 1 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | -4.5% | [-4.5%, -4.5%] | 1 |
Cycles
Results (primary -2.1%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-2.1% | [-2.1%, -2.1%] | 1 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | -2.1% | [-2.1%, -2.1%] | 1 |
Binary size
Results (primary -0.1%, secondary -0.1%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-0.1% | [-0.2%, -0.0%] | 80 |
| Improvements ✅ (secondary) |
-0.1% | [-0.2%, -0.0%] | 66 |
| All ❌✅ (primary) | -0.1% | [-0.2%, -0.0%] | 80 |
#161637 bae36a2 Clarify token cursor behaviour
Instruction count
This perf run didn't have relevant results for this metric.
Max RSS (memory usage)
This perf run didn't have relevant results for this metric.
Cycles
Results (primary 2.2%, secondary -2.2%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
2.2% | [2.2%, 2.2%] | 1 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-2.2% | [-2.2%, -2.2%] | 1 |
| All ❌✅ (primary) | 2.2% | [2.2%, 2.2%] | 1 |
Binary size
This perf run didn't have relevant results for this metric.
|
@rust-timer triage 75ee367 9e0ad9e |
#160705 75ee367 Remove
|
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-0.2% | [-0.3%, -0.2%] | 4 |
| Improvements ✅ (secondary) |
-0.2% | [-0.4%, -0.1%] | 11 |
| All ❌✅ (primary) | -0.2% | [-0.3%, -0.2%] | 4 |
Max RSS (memory usage)
Results (primary 3.0%, secondary -4.3%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
3.0% | [3.0%, 3.0%] | 1 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-4.3% | [-4.3%, -4.3%] | 1 |
| All ❌✅ (primary) | 3.0% | [3.0%, 3.0%] | 1 |
Cycles
Results (primary -2.3%, secondary 2.9%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
2.9% | [2.4%, 3.4%] | 2 |
| Improvements ✅ (primary) |
-2.3% | [-2.3%, -2.3%] | 1 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | -2.3% | [-2.3%, -2.3%] | 1 |
Binary size
This perf run didn't have relevant results for this metric.
#161648 9e0ad9e rust-analyzer subtree update
Instruction count
This perf run didn't have relevant results for this metric.
Max RSS (memory usage)
This perf run didn't have relevant results for this metric.
Cycles
Results (primary 1.8%, secondary 14.2%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
4.0% | [2.8%, 5.1%] | 2 |
| Regressions ❌ (secondary) |
22.8% | [21.7%, 23.8%] | 2 |
| Improvements ✅ (primary) |
-2.5% | [-2.5%, -2.5%] | 1 |
| Improvements ✅ (secondary) |
-3.0% | [-3.0%, -3.0%] | 1 |
| All ❌✅ (primary) | 1.8% | [-2.5%, 5.1%] | 3 |
Binary size
This perf run didn't have relevant results for this metric.
Successful merges:
rust-analyzersubtree update #161648 (rust-analyzersubtree update)pad_i32ofPassMode::castan integer #160132 (makepad_i32ofPassMode::castan integer)From<!> for T*reservation* impl #160705 (RemoveFrom<!> for Treservation impl)BuildtoSession#161600 (bootstrap: RenameBuildtoSession)r? @ghost
Create a similar rollup