51056 Commits

Author SHA1 Message Date
bjorn3
5a8ffa4bef Skip codegen_crate call in check mode 2025-10-24 10:25:13 +00:00
bors
8aab621cd5 Auto merge of #148043 - lqd:revert-146121, r=wesleywiser
Revert "fix: Filter suggestion parts that match existing code"

As requested by `@wesleywiser` in https://github.com/rust-lang/rust/issues/147973#issuecomment-3437393773 this is a revert of https://github.com/rust-lang/rust/pull/146121 due to the handful of diagnostics ICEs that have been since reported, and found in the beta crater run.

This should thus also be backported to beta so the ICEs don't make it to next week's stable.

Works around (after backport)
- https://github.com/rust-lang/rust/issues/146261
- https://github.com/rust-lang/rust/issues/146706
- https://github.com/rust-lang/rust/issues/146834 but I didn't add a test for this allowed-by-default lint
- as well as the crater run regressions from https://github.com/rust-lang/rust/issues/147973 of which I only added the MCVE as a test.

The proper fix would likely be https://github.com/rust-lang/rust/pull/147849 but it's still currently at the MCP stage. In the meantime, this PR would still emit the same overlapping suggestions, but still use a debug-assert...

r? `@wesleywiser`
2025-10-24 09:50:35 +00:00
Stuart Cook
7141a0f634 Rollup merge of #148054 - nnethercote:chain, r=saethlin
Streamline iterator chaining when computing successors.

There are numerous unnecessary `into_iter` calls.

Also add a comment explaining why the code looks like this, because it's non-obvious at first glance.

r? `@saethlin`
2025-10-24 14:53:48 +11:00
Camille GILLOT
b67453fccd Stop passing resolver disambiguator state to AST lowering. 2025-10-24 02:41:52 +00:00
Camille Gillot
ed85b96bb5 Insert assignment after Retag. 2025-10-24 02:41:51 +00:00
Camille Gillot
a15ef42488 Only load pin field once. 2025-10-24 02:41:50 +00:00
Nicholas Nethercote
3d951598b2 Streamline iterator chaining when computing successors.
There are numerous unnecessary `into_iter` calls.

Also add a comment explaining why the code looks like this, because it's
non-obvious at first glance.
2025-10-24 08:41:39 +11:00
Augie Fackler
e3e342a90b rustc_codegen_llvm: adapt for LLVM 22 change to pass masked intrinsic alignment as an attribute
This was a bit more invasive than I had kind of hoped. An alternate
approach would be to add an extra call_intrinsic_with_attrs() that would
have the new-in-this-change signature for call_intrinsic, but this felt
about equivalent and made it a little easier to audit the relevant
callsites of call_intrinsic().
2025-10-23 17:23:01 -04:00
Rémy Rakic
a2b48332ba Revert "Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkov"
This reverts commit 99317ef14d, reversing
changes made to 9cd272dc85.
2025-10-23 18:18:35 +00:00
bors
6501e64fcb Auto merge of #147486 - petrochenkov:optpriv, r=lcnr
privacy: Introduce some caching to type visiting in `DefIdVisitorSkeleton`

The caching fixes compilation speed issues in special cases like https://github.com/rust-lang/rust/issues/145741, without introducing too much overhead in general cases.

I tried to cache more, but it caused regressions from the caching overhead, like it can be seen from benchmark runs below.

Inspired by https://github.com/rust-lang/rust/pull/146128.
Closes https://github.com/rust-lang/rust/issues/145741.
2025-10-23 14:30:10 +00:00
bors
469357eb48 Auto merge of #148014 - jhpratt:rollup-aglren3, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#134316 (Add `String::replace_first` and `String::replace_last`)
 - rust-lang/rust#147713 (Retire ast::TyAliasWhereClauses.)
 - rust-lang/rust#148011 (Revert constification of `AsRef for Cow` due to inference failure )

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-23 08:17:05 +00:00
Jacob Pratt
0185feb7db Rollup merge of #147713 - cjgillot:where-cfg, r=fmease
Retire ast::TyAliasWhereClauses.

`ast::TyAliasWhereClauses` is a tentative to avoid forgetting predicates when manipulating the AST.
It is incompatible with `cfg` attributes on where clauses.

This PR uses a regular `WhereClause` for the "second" clause.

Fixes https://github.com/rust-lang/rust/issues/138010
cc https://github.com/rust-lang/rust/pull/138037
2025-10-23 01:22:06 -04:00
bors
4b3ba5844e Auto merge of #147793 - cjgillot:no-null-op, r=scottmcm,oli-obk
Replace NullOp::SizeOf and NullOp::AlignOf by lang items.

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

Fixes https://github.com/rust-lang/rust/issues/119729
Keeps https://github.com/rust-lang/rust/issues/136175 as it involves `offset_of!` which this PR does not touch.

r? `@ghost`
2025-10-23 05:09:25 +00:00
bors
7838ce1a3a Auto merge of #148012 - Zalathar:rollup-ed6cnn8, r=Zalathar
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#115501 (Add new inherit_handles flag to CommandExt trait)
 - rust-lang/rust#146629 (std: reorganize the UNIX-internal `weak` module)
 - rust-lang/rust#147762 (feat(rustdoc): `--emit=depinfo` output to stdout via `-`)
 - rust-lang/rust#148001 (fix: Don't add diff symbol to unchanged lines)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-23 02:01:36 +00:00
Stuart Cook
2f7e07bb4a Rollup merge of #148001 - Muscraft:fix-diff-symbol-unchanged-lines, r=fmease
fix: Don't add diff symbol to unchanged lines

When rendering a "multi-line" suggestion with the [`Diff`](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L3078)) format, `rustc` uses a [diff symbol](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L3017-L3022)) for
[any line that has a highlight part](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L2705-L2713)). This includes highlight parts that are highlighting nothing, i.e., a span of `0..0`. This leads `rustc` to add a diff symbol unnecessarily to lines that have no changes and are not highlighted. This PR makes it so that `rustc` will not add a diff symbol to lines that contain no changes/highlights.

Note: This PR is part of my ongoing effort to have `rustc` use `annotate-snippets` for rendering. This change will make it so that `rustc` and `annotate-snippets` will match in this case.
2025-10-23 12:06:32 +11:00
Stuart Cook
b397b6b5b7 Rollup merge of #147762 - weihanglo:rustdoc-depinfo-stdout, r=fmease
feat(rustdoc): `--emit=depinfo` output to stdout via `-`

rustdoc's `--emit=depinfo` flag now supports using `-` to write the output to stdout,
aligning with rustc's behavior.

This will fix <https://github.com/rust-lang/rust/issues/147649>.

### How to review

* The first commit demonstrates that `rustdoc --emit=depinfo=-` hasn't yet supported emitting to stdout.
* The second implements it and the diff shows how the behavior changes.
2025-10-23 12:06:32 +11:00
Camille Gillot
15c91bf308 Retire ast::TyAliasWhereClauses. 2025-10-23 00:40:01 +00:00
Camille Gillot
5dfbf67f94 Replace NullOp::SizeOf and NullOp::AlignOf by lang items. 2025-10-23 00:38:28 +00:00
bors
6244effd03 Auto merge of #147810 - bjorn3:lto_refactors6, r=wesleywiser
Split LTO out of the main codegen coordinator event loop into a separate event loop on the same thread

This will make it easier to in the future move all this code to link_binary.

Follow up to https://github.com/rust-lang/rust/pull/146209
Part of https://github.com/rust-lang/compiler-team/issues/908
2025-10-22 22:50:15 +00:00
Scott Schafer
c7f014ddc6 fix: Don't add diff symbol to unchanged lines 2025-10-22 15:30:57 -06:00
Jonathan Brouwer
24502dd2d2 Improve suggestions for cfg_attr
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-22 21:57:13 +02:00
Jonathan Brouwer
9735524533 Add AcceptContext::suggestions
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-22 21:43:50 +02:00
bors
1d23d06800 Auto merge of #147997 - jhpratt:rollup-nupruru, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#145617 (docs(style): Specify the frontmatter style)
 - rust-lang/rust#147830 (Reword unstable fingerprints ICE to ask for reproduction)
 - rust-lang/rust#147988 (Remove unused field `style` from `AttributeKind::CrateName`)
 - rust-lang/rust#147990 (Fix invalid jump to def link generated on derive attributes)
 - rust-lang/rust#147991 ([rustdoc] Check `doc(cfg())` even of private/hidden items)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-22 19:38:56 +00:00
Jacob Pratt
c047a7e861 Rollup merge of #147988 - JonathanBrouwer:unused_field_crate_name, r=jdonszelmann
Remove unused field `style` from `AttributeKind::CrateName`

r? `@jdonszelmann`
2025-10-22 13:20:23 -04:00
Jacob Pratt
6353350d14 Rollup merge of #147830 - Noratrieb:reword-unstable-fingerprint-ice, r=jackh726
Reword unstable fingerprints ICE to ask for reproduction

When the unstable fingerprints error was added, Rust was on fire, and we needed a quick way for people to sort of understand what's going on, follow the tracking issue, and leave some information without overwhelming the issue tracker and focusing on getting their code working.

This is what motivated the previous message. It called this a "known issue", provided help on how to fix it, and only secondarily asked for a bug report.

This is no longer true. These days incremental compilation is fairly solid and these issues are supposed to be rare, we expect *none* of them to exist (but obviously know that's not true). As such, it's time to reword this message.

Recently someone mentioned how they didn't bother reporting this issue because it said that it was a "known issue", and I only got awareness of their problem because they complained about all the rustc-ice files hanging around their directories (https://github.com/rust-lang/rust/issues/147825#issuecomment-3417297842). This is not at all what we want, we want reports from people, ideally with a reproduction.

To get this, I reworded the error. It now explicitly asks for a reproduction (and explaining what that means) and no longer calls it a "known issue". It also does not link to the tracking issue anymore, because I don't think this tracking issue is useful. It should probably be closed.

I still mention the workaround, but explicitly call it a "workaround". People should report a reproduction and only *then* use the workaround.
2025-10-22 13:20:23 -04:00
bors
dc1feabef2 Auto merge of #147207 - Muscraft:anstyle-anstream, r=davidtwco
refactor: Move to anstream + anstyle for styling

`rustc` uses [`termcolor`](https://crates.io/crates/termcolor) for styling and writing, while `annotate-snippets` uses [`anstyle`](https://crates.io/crates/anstyle) for styling and currently writes directly to a `String`. When rendering directly to a terminal, there isn't/shouldn't be any differences. Still, there are differences in the escape sequences, which leads to slightly different output in JSON and SVG tests. As part of my work to have `rustc` use `annotate-snippets`, and to reduce the test differences between the two, I switched `rustc` to use `anstlye` and [`anstream`](https://crates.io/crates/anstream) for styling and writing.

The first commit migrates to `anstyle` and `anstream` and notably does not change the output. This is because it includes extra formatting to ensure that `anstyle` + `anstream` match the current output exactly. Most of this code is unnecessary, as it adds redundant resets or uses 256-color (8-bit) when it could be using 4-bit color. The subsequent commits remove this extra formatting while maintaining the correct output when rendered.

[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/annotate-snippets.20hurdles)
2025-10-22 16:22:51 +00:00
Vadim Petrochenkov
f9464f827b privacy: Introduce some caching to type visiting in DefIdVisitorSkeleton 2025-10-22 17:31:12 +03:00
Vadim Petrochenkov
156499e561 privacy: Avoid some unnecessary mutability 2025-10-22 17:06:07 +03:00
Jonathan Brouwer
ebd3220b20 Remove unused field style from AttributeKind::CrateName
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-22 15:45:59 +02:00
bors
4d94478977 Auto merge of #147826 - Muscraft:update-typos, r=Noratrieb
Update typos

I saw that `typos` was a few versions out of date and figured it would be a good idea to update it. Upgrading to `1.38.1` adds the [July](https://github.com/crate-ci/typos/issues/1331), [August](https://github.com/crate-ci/typos/issues/1345), and [September](https://github.com/crate-ci/typos/issues/1370) dictionary updates. As part of this change, I also sorted the configuration file.
2025-10-22 13:11:47 +00:00
bors
f5e2df741b Auto merge of #147687 - cjgillot:noshallow-init-box, r=nnethercote
Forbid ShallowInitBox after box deref elaboration.

MIR currently contains a `ShallowInitBox` rvalue. Its principal usage is to allow for in-place initialization of boxes. Having it is necessary for drop elaboration to be correct with that in-place initialization.

As part of analysis->runtime MIR lowering, we canonicalize deref of boxes to use the stored raw pointer. But we did not perform the same change to the construction of the box.

This PR replaces `ShallowInitBox` by the pointer manipulation it represents.

Alternatives:
- fully remove `ShallowInitBox` and implement `Box` in-place initialization differently;
- remove the `ElaborateBoxDeref` pass and keep dereferencing `Box` in runtime MIR.
2025-10-22 09:53:50 +00:00
Matthias Krüger
e132d2d8a5 Rollup merge of #147948 - aeubanks:summarylist, r=durin42
PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+

https://github.com/llvm/llvm-project/pull/164355 makes SummaryList private and provides a getter method.

`@rustbot` label llvm-main
2025-10-22 07:12:12 +02:00
Matthias Krüger
aa64f568b4 Rollup merge of #147768 - chenyukang:yukang-refactor-report-method-error, r=nnethercote
Code refactoring on hir report_no_match_method_error

While working on rust-lang/rust#147753, I found `report_no_match_method_error` now is too long for maintain, 1200 lines of code now:
57ef8d642d/compiler/rustc_hir_typeck/src/method/suggest.rs (L589-L1736)

this PR try to refactor it.

I tried my best to group most related code into same places, but the logic here is still very complex, there are some variables across different functions, maybe we need more work to make it better understand.

Maybe we could add a tidy check to avoid long spaghetti code.

r? `@nnethercote`
2025-10-22 07:12:10 +02:00
Matthias Krüger
f6d324fb8d Rollup merge of #142339 - oli-obk:not-null-pattern-types, r=BoxyUwU
Add NonNull pattern types

These are the final piece missing for

* https://github.com/rust-lang/rust/pull/136006

We cannot use the previous scheme of using an integer range for raw pointers, as we're not just changing the layout of raw pointers anymore, but also the type representation. And we can't represent "any provenance or NonZero<usize>" natively as patterns. So I created a new `!null` pattern. Since this is all unstable representation stuff for replacing rustc_layout_scalar_range_start with pattern types, the divergence from normal patterns is fine, especially since T-lang seems interested in exploring general negation patterns

r? `@BoxyUwU`
2025-10-22 07:12:09 +02:00
yukang
38e8066575 add UnsatisfiedPredicate type alias 2025-10-22 09:51:58 +08:00
Camille Gillot
0156eaf0d1 Introduce indexvec macro. 2025-10-22 00:52:52 +00:00
Camille Gillot
51275e82c9 Elaborate ShallowInitBox too. 2025-10-22 00:52:52 +00:00
yukang
92d5196d7a code refactoring on report_no_match_method_error 2025-10-22 08:45:29 +08:00
bors
96fe3c31c2 Auto merge of #147022 - Zalathar:no-args, r=wesleywiser
Remove current code for embedding command-line args in PDB

The compiler currently has code that will obtain a list of quoted command-line arguments, and pass it through to TargetMachine creation, so that the command-line args can be embedded in PDB output.

This PR removes that code, due to subtle concerns that might not have been apparent when it was originally added.

---

Those concerns include:
- The entire command-line quoting process is repeated every time a target-machine-factory is created. In incremental builds this typically occurs 500+ times, instead of happening only once. The repeated quoting constitutes a large chunk of instructions executed in the `large-workspace` benchmark.
  - See https://github.com/rust-lang/rust/pull/146804#issuecomment-3317322958 for an example of the perf consequences of skipping all that work.
  - This overhead occurs even when building for targets or configurations that don't emit PDB output.
- Command-line arguments are obtained in a way that completely bypasses the query system, which is a problem for the integrity of incremental compilation.
  - Fixing this alone is likely to inhibit incremental rebuilds for most or all CGUs, even in builds that don't emit PDB output.
- Command-line arguments and the executable path are obtained in a way that completely bypasses the compiler's path-remapping system, which is a reproducibility hazard.
  - https://github.com/rust-lang/rust/issues/128842

---

Relevant PRs:
- https://github.com/rust-lang/rust/pull/113492
- https://github.com/rust-lang/rust/pull/130446
- https://github.com/rust-lang/rust/pull/131805
- https://github.com/rust-lang/rust/pull/146700
- https://github.com/rust-lang/rust/pull/146973

Zulip thread:
- https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Some.20PDB.20info.20bypasses.20the.20query.20system.20and.20path.20remapping/with/541432211

---

According to rust-lang/rust#96475, one of the big motivations for embedding the command-line arguments was to enable tools like Live++. [It appears that Live++ doesn't actually support Rust yet](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/embeded.20compiler.20args.20and.20--remap-path-prefix/near/523800010), so it's possible that there aren't any existing workflows for this removal to break.

In the future, there could be a case for reintroducing some or all of this functionality, guarded behind an opt-in flag so that it doesn't cause problems for other users. But as it stands, the current implementation puts a disproportionate burden on other users and on compiler maintainers.
2025-10-22 00:21:08 +00:00
Arthur Eubanks
1e8054669c format 2025-10-21 22:29:48 +00:00
Arthur Eubanks
875cc36b17 actually compile 2025-10-21 22:21:50 +00:00
Arthur Eubanks
f38839a874 format 2025-10-21 21:35:23 +00:00
bors
37ec98f5d3 Auto merge of #146725 - lcnr:eager-instantiate-binder, r=BoxyUwU
`-Znext-solver` instantiate predicate binder without recanonicalizing goal

This strengthens the leak check to match the old trait solver. The new trait solver now also instantiates higher ranked goals in the same scope as candidate selection, so the leak check in each candidate detects placeholder errors involving this higher ranked goal.

E.g. let's look at tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.rs
```rust
trait Trait<T, U> {}
impl<'a> Trait<&'a str, &'a str> for () {}
impl<'a> Trait<&'a str, String> for () {}
fn impls_trait<T: for<'a> Trait<&'a str, U>, U>() {}

fn main() {
    impls_trait::<(), _>();
}
```
Here proving `(): for<'a> Trait<&'a str, ?u>` via `impl<'a> Trait<&'a str, &'a str> for ()` equates `?u` with `&'!a str` which results in a leak check error as `?u` cannot name `'a`. If this leak check error happens while considering candidates we drop the first impl and infer `?u` to `String`. If not, this remains ambiguous.

This behavior is a bit iffy, see the FCP proposal in rust-lang/rust#119820 for more details on why this current behavior is somewhat undesirable. However, considering placeholders from higher-ranked goals for candidate selection does allow more code to compile and a lot of the code *feels like it should compile*. **This caused us to revert the change of rust-lang/rust#119820 in rust-lang/rust#127568.**

I originally expected that we can avoid breakage with the new solver differently here, e.g. by considering OR-region constraints. However, doing so is a significant change and I don't have a great idea for how that should work. Matching the old solver behavior for now should not make this cleaner approach any more difficult in the future, so let's just go with what actually allows us to stabilize the new solver for now.

This PR changing the new solver to match the behavior of the old one wrt the leak check. As the new solver is already used by default in coherence, this allows more code to compile, see `tests/ui/higher-ranked/leak-check/leak-check-in-selection-7-coherence.rs`:
```rust
struct W<T, U>(T, U);

trait Trait<T> {}
// using this impl results in a higher-ranked region error.
impl<'a> Trait<W<&'a str, &'a str>> for () {}
impl<'a> Trait<W<&'a str, String>> for () {}

trait NotString {}
impl NotString for &str {}
impl NotString for u32 {}

trait Overlap<U> {}
impl<T: for<'a> Trait<W<&'a str, U>>, U> Overlap<U> for T {}
impl<U: NotString> Overlap<U> for () {}

fn main() {}
```

This behavior is quite arbitrary and not something I expect users to rely on in practice, however, it should still go through an FCP imo.

r? `@BoxyUwU` originally implemented by `@compiler-errors` in https://github.com/rust-lang/rust/pull/136997. Closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/120.
2025-10-21 21:09:46 +00:00
Arthur Eubanks
fc7c4be59a PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+
https://github.com/llvm/llvm-project/pull/164355 makes SummaryList private and provides a getter method.

@rustbot label llvm-main
2025-10-21 20:58:27 +00:00
Cameron Steffen
6d61dadfab Reuse expr_needs_parens 2025-10-21 10:05:35 -05:00
Cameron Steffen
3bdf45f7db Mark range expr with desugaring 2025-10-21 10:04:34 -05:00
Cameron Steffen
3f4da0db4a Use inner span ctxt when lowering paren
The need for this arose when encountering range expressions surrounded
by parenthesis, where we want the span desugaring mark to be preserved.
2025-10-21 09:59:28 -05:00
bors
869fb4679f Auto merge of #147723 - ChayimFriedman2:ns-types, r=BoxyUwU
Make `UnevaluatedConst` have a specific ID type in the new solver

For the benefit of rust-analyzer.

r? types
2025-10-21 14:43:26 +00:00
bors
19abae728e Auto merge of #147922 - Kivooeo:dead-link, r=petrochenkov
Remove broken link

Idk if this link is any important but it does not work anymore so...
2025-10-21 11:33:23 +00:00
Oli Scherer
375899c940 Allow unsizing pattern types with pointer base 2025-10-21 11:22:51 +00:00