35474 Commits

Author SHA1 Message Date
Lukas Wirth
a1f548bce2
Merge pull request #20156 from Veykril/push-knkzxuxkzoyx
Restructure proc-macro loading erros, differentiate hard error property on kind
2025-07-03 07:40:17 +00:00
Lukas Wirth
e54759083a Restructure proc-macro loading erros, differentiate hard error property on kind 2025-07-03 09:28:53 +02:00
Lukas Wirth
422a777143
Merge pull request #20151 from ChayimFriedman2/keyword-hover-link
fix: Remove keyword prefixes (`macro@` or `macro `) from links in the docs only if the link target is inferred
2025-07-03 06:27:39 +00:00
Chayim Refael Friedman
3d88c1e647 Remove keyword prefixes (macro@ or macro ) from links in the docs only if the link target is inferred
That is, do it for `[macro foo]`, but not for `[macro foo](macro foo)`.
2025-07-03 00:41:47 +03:00
наб
b58b54bb4b
awhile -> a while where appropriate 2025-07-02 20:17:29 +02:00
bors
f60a7feb4e Auto merge of #143214 - camsteffen:remove-let-chains-feature, r=est31
Remove let_chains unstable feature

Per https://github.com/rust-lang/rust/issues/53667#issuecomment-3016742982 (but then I also noticed rust-lang/rust#140722)

This replaces the feature gate with a parser error that says let chains require 2024.

A lot of tests were using the unstable feature. I either added edition:2024 to the test or split out the parts that require 2024.
2025-07-02 17:18:47 +00:00
Shoyu Vanilla
224b84f843 fix: Honor rust-analyzer.cargo.noDeps option when fetching sysroot metadata 2025-07-03 00:16:05 +09:00
A4-Tacks
edcfa4afa1
Fix AsMut::as_mut name 2025-07-02 21:55:55 +08:00
bors
79f2fee4ac Auto merge of #142978 - Kobzol:query-hit, r=oli-obk
Add new self-profiling event to cheaply aggregate query cache hit counts

Self-profile can record various types of things, some of them are not enabled, like query cache hits. Rustc currently records cache hits as "instant" measureme events, which records the thread ID, current timestamp, and constructs an individual event for each such cache hit. This is incredibly expensive, in a small hello world benchmark that just depends on serde, it makes compilation with nightly go from ~3s (with `-Zself-profile`) to ~15s (with `-Zself-profile -Zself-profile-events=default,query-cache-hit`).

We'd like to add query cache hits to rustc-perf (https://github.com/rust-lang/rustc-perf/pull/2168), but there we only need the actualy cache hit counts, not the timestamp/thread ID metadata associated with it.

This PR adds a new `query-cache-hit-count` event. Instead of generating individual instant events, it simply aggregates cache hit counts per *query invocation* (so a combination of a query and its arguments, if I understand it correctly) using an atomic counter. At the end of the compilation session, these counts are then dumped to the self-profile log using integer events (in a similar fashion as how we record artifact sizes). I suppose that we could dedup the query invocations in rustc directly, but I don't think it's really required. In local experiments with the hello world + serde case, the query invocation records generated ~30 KiB more data in the self-profile, which was ~10% increase in this case.

With this PR, the overhead of `-Zself-profile` seems to be the same as before, at least on my machine, so I also enabled query cache hit counts by default when self profiling is enabled.

We should also modify `analyzeme`, specifically [this](https://github.com/rust-lang/measureme/blob/master/analyzeme/src/analysis.rs#L139), and make it load the integer events with query cache hit counts. I can do that as a follow-up, it's not required to be done in sync with this PR, and it doesn't require changes in rustc.

CC `@cjgillot`

r? `@oli-obk`
2025-07-02 11:41:14 +00:00
Laurențiu Nicola
11d45c8813
Merge pull request #20137 from Hmikihiro/migrate-wrap_unwrap_cfg_attr-assist-to-syntaxeditor
Migrate `wrap_unwrap_cfg_attr` Assist to use `SyntaxEditor`
2025-07-02 05:24:36 +00:00
Hayashi Mikihiro
0b7ad9cd0f Migrate wrap_unwrap_cfg_attr assist to use SyntaxEditor
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-07-02 01:18:22 +09:00
bors
967bca2aba Auto merge of #142030 - oli-obk:wfck-less-hir, r=compiler-errors
Start moving wf checking away from HIR

I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better.

I think I am reaching a blocker because we normally need to provide good spans to `ObligationCause`, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the `ObligationCauseCode` (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the `ObligationCause` entirely (leaving it to some variants of `ObligationCauseCode` to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks.

Especially b862d8828e is interesting here, because I think it improves spans in all cases
2025-07-01 14:59:58 +00:00
Laurențiu Nicola
aa16885e62
Merge pull request #20136 from Hmikihiro/migrate-toggle_macro_delimiter
Migrate `toggle_macro_delimiter` Assist to use `SyntaxEditor`
2025-07-01 13:53:02 +00:00
Hayashi Mikihiro
3af0f4f6be Migrate toggle_macro_delimiter assist to SyntaxEditor
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-07-01 22:40:31 +09:00
bors
7b460a52ab Auto merge of #143013 - bjorn3:split_exported_symbols, r=oli-obk
Split exported_symbols for generic and non-generic symbols

This reduces metadata decoder overhead during the monomorphization collector.
2025-07-01 11:53:02 +00:00
Laurențiu Nicola
cb52f4c3c9
Merge pull request #20135 from Hmikihiro/migrate-promote_local_to_const-assist-tosyntaxeditor
Migrate `promote_local_to_const` Assist to `SyntaxEditor`
2025-07-01 11:23:23 +00:00
Hayashi Mikihiro
a423b7c7cc Migrate promote_local_to_const Assist to SyntaxEditor
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-07-01 20:11:52 +09:00
Laurențiu Nicola
ce2c0c968a
Merge pull request #20134 from Hmikihiro/migrate-replace_is_method_with_if_let_method-to-SyntaxFactory
Migrate `replace_is_method_with_if_let_method` Assist to use `SyntaxFactory`
2025-07-01 10:39:30 +00:00
Hayashi Mikihiro
fcc81a38b3 remove if-let chains
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-07-01 18:38:50 +09:00
bors
fa41067304 Auto merge of #142921 - JonathanBrouwer:rustc_attributes_parser, r=oli-obk
Port `#[rustc_layout_scalar_valid_range_start/end]` to the new attrib…

Ports `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

r? `@jdonszelmann`
2025-07-01 08:33:00 +00:00
Hayashi Mikihiro
f6a247dc57 Migrate replace_is_method_with_if_let_method Assist to use SyntaxFactory
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-07-01 17:19:16 +09:00
A4-Tacks
cb000ad313
Add AsMut Borrow BorrowMut to minicore and famous_defs 2025-07-01 15:26:45 +08:00
bors
ad98950970 Auto merge of #141875 - nnethercote:ByteSymbol, r=petrochenkov
Introduce `ByteSymbol`

It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once.

The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`.

`Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings.
2025-07-01 02:22:42 +00:00
bors
53291632cf Auto merge of #143254 - matthiaskrgr:rollup-7x8bxek, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#143019 (Ensure -V --verbose processes both codegen_backend and codegen-backend)
 - rust-lang/rust#143140 (give Pointer::into_parts a more scary name and offer a safer alternative)
 - rust-lang/rust#143175 (Make combining LLD with external LLVM config a hard error)
 - rust-lang/rust#143180 (Use `tracing-forest` instead of `tracing-tree` for bootstrap tracing)
 - rust-lang/rust#143223 (Improve macro stats printing)
 - rust-lang/rust#143228 (Handle build scripts better in `-Zmacro-stats` output.)
 - rust-lang/rust#143229 ([COMPILETEST-UNTANGLE 1/N] Move some some early config checks to the lib and move the compiletest binary)
 - rust-lang/rust#143246 (Subtree update of `rust-analyzer`)
 - rust-lang/rust#143248 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-30 22:36:52 +00:00
Matthias Krüger
0ab5c6a964
Rollup merge of #143248 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

2 commits in 8a6d44e45b7b564eeb6bae30507e1fbac439d72d..ef1ce8f87a8b18feb1b6a9cf9a4939a79bde6795
2025-06-28 18:06:08 UTC to 2025-06-26 23:08:19 UTC

- Chapter 14 from tech review (rust-lang/book#4423)
- Chapter 13 from tech review (rust-lang/book#4421)

## rust-embedded/book

1 commits in 10fa1e084365f23f24ad0000df541923385b73b6..41f688a598a5022b749e23d37f3c524f6a0b28e1
2025-06-27 07:21:31 UTC to 2025-06-27 07:21:31 UTC

- Fix incorrect type for semihosted stdout stream rust-lang/rust#394 (rust-embedded/book#395)

## rust-lang/reference

4 commits in 50fc1628f36563958399123829c73755fa7a8421..e9fc99f107840813916f62e16b3f6d9556e1f2d8
2025-06-28 20:00:14 UTC to 2025-06-24 19:02:48 UTC

- fix: swap places for 2 words in associated-items.md sentence. (rust-lang/reference#1871)
- Add new temporary lifetime extension rule (rust-lang/reference#1813)
- Fix smart punctuation inside grammar terminals (rust-lang/reference#1869)
- Fix placement of codegen link definitions (rust-lang/reference#1868)

## rust-lang/rust-by-example

1 commits in 05c7d8bae65f23a1837430c5a19be129d414f5ec..288b4e4948add43f387cad35adc7b1c54ca6fe12
2025-06-25 12:35:59 UTC to 2025-06-25 12:35:59 UTC

- allow easy fixes (rust-lang/rust-by-example#1941)
2025-06-30 20:49:45 +02:00
Matthias Krüger
57b390d8a0
Rollup merge of #143246 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? ``@ghost``
2025-06-30 20:49:44 +02:00
Laurențiu Nicola
eaf37e2c98
Merge pull request #20128 from lnicola/sync-from-rust
Sync from downstream
2025-06-30 15:11:33 +00:00
Laurențiu Nicola
07e1072932 Merge from rust-lang/rust 2025-06-30 17:42:03 +03:00
Laurențiu Nicola
02434fda4d Preparing for merge from rust-lang/rust 2025-06-30 17:41:18 +03:00
Young-Flash
d94a832264 test: add test case for func with multiline param list 2025-06-30 17:36:16 +08:00
Young-Flash
5ae67747f5 internal: add FoldKind::Function 2025-06-30 17:36:16 +08:00
Young-Flash
8ac661eaa9 feat: support folding multiline arg list & fn body in one folding range 2025-06-30 17:34:02 +08:00
Lukas Wirth
c5a1078578
Merge pull request #20124 from zachs18/patch-1
Remove last use of `rustc_pattern_analysis::Captures`
2025-06-30 05:32:04 +00:00
zachs18
0eb3ee8eb1
Remove last use of rustc_pat_analysis::Captures
It's not necessary anymore due to Rust 2024 lifetime capture rules.
2025-06-29 22:36:53 -05:00
bors
f4728fc613 Auto merge of #142802 - compiler-errors:dedup-analyses, r=lcnr
Collapse Analysis|Borrowck|PostBorrowckAnalysis when there are no opaques

r? lcnr
2025-06-29 19:12:29 +00:00
Chayim Refael Friedman
6df12139bc
Merge pull request #20122 from chenyukang/yukang-fix-remove-parens
Remove unnecessary parens in closure
2025-06-30
2025-06-29 15:14:31 +00:00
yukang
d8b424cb4c Remove unnecessary parens in closure 2025-06-29 19:28:48 +08:00
Lukas Wirth
7c3de9df36
Merge pull request #20121 from Veykril/push-vkkuutpsuypq
Do not append `--compile-time-deps` to overwritten build script commands
2025-06-29 07:18:59 +00:00
Lukas Wirth
f055cbce1a Do not append --compile-time-deps to overwritten build script commands 2025-06-29 09:07:55 +02:00
bors
88d4ce161e Auto merge of #142625 - cjgillot:inline-nocycle, r=oli-obk
Only compute recursive callees once.

Inlining MIR in a cyclic call graph may create query cycles, which are ICEs. The current implementation `mir_callgraph_reachable(inlining_candidate, being_optimized)` checks if calling `inlining_candidate` may cycle back to `being_optimized` that we are currently inlining into.

This PR replaces this device with query `mir_callgraph_cyclic(being_optimized)` which searches the call graph for all cycles going back to `being_optimized`, and returns the set of functions involved in those cycles.

This is a tradeoff:
- in the current implementation, we perform more walks, but shallower;
- in this new implementation, we perform fewer walks, but exhaust the graph.

I'd have liked to compute this using some kind of SCC, but generic parameters make resolution path-dependent, so usual graph algorithms do not apply.
2025-06-28 19:11:42 +00:00
bors
23aa85e1c6 Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlin
Insert checks for enum discriminants when debug assertions are enabled

Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```

An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.

This check is similar to Miri's capabilities of checking for valid construction of enum values.

This PR is inspired by saethlin@'s PR
https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments!

I also pair-programmed large parts of this together with vabr-g@.

r? `@saethlin`
2025-06-28 10:25:00 +00:00
Lukas Wirth
13ffda70eb
Merge pull request #20118 from Veykril/push-nolsxzxmykls
ci: Fix up release workflow
2025-06-28 09:54:42 +00:00
Lukas Wirth
968d2467a8 ci: Fix up release workflow 2025-06-28 11:35:55 +02:00
Lukas Wirth
6d465579f9
Merge pull request #20116 from Veykril/push-uypnmlyvotlm
ci: Cancel workflow only after the main matrix has finished
2025-06-28 07:39:35 +00:00
Lukas Wirth
944355c456 ci: Cancel workflow only after the main matrix has finished 2025-06-28 09:28:26 +02:00
bors
7cb1248c0a Auto merge of #142893 - Mark-Simulacrum:no-const-collect, r=oli-obk
Stop collecting unmentioned constants

This avoids generating useless dead LLVM IR. This appears to have regressed and/or been introduced in rust-lang/rust#53821 (unfortunately a very large PR - I don't see any direct discussion there of this particular change), but as far as I can tell is at least no longer necessary -- or we lack test coverage -- because none of our UI tests indicate diagnostics regressions. The adjusted codegen-units test has comments explicitly noting that these items should *not* be collected ("These are not referenced, so they do not produce mono-items").

I noticed this while looking at libcore LLVM IR we generate, which contained dead code references to the NOOP Waker item, which is never used inside libcore. Producing LLVM IR for it during libcore's compilation, only for that IR to get deleted by LLVM as unused, isn't useful. Note that the IR is generally all marked internal, too.
2025-06-27 12:57:05 +00:00
Lukas Wirth
54c87d8753 Workaround missing none group support in builtin macros 2025-06-27 12:06:23 +02:00
Hayashi Mikihiro
a78cf7596c use placeholder_snippet
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-06-27 18:49:08 +09:00
Hayashi Mikihiro
cd4fadb4ea use name_generator
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-06-27 18:48:39 +09:00
Lukas Wirth
5b852da4c3
Merge pull request #20110 from ChayimFriedman2/ambiguous-float
fix: Fix completion in when typing `integer.|`
2025-06-27 05:42:09 +00:00