Commit Graph

50967 Commits

Author SHA1 Message Date
Cameron Steffen
a45c6dd2c0 Remove AssignDesugar span 2025-10-28 11:18:58 -05:00
bors
23fced0fcc Auto merge of #146069 - camsteffen:range-desugar-span, r=SparrowLii
Mark desugared range expression spans with DesugaringKind::RangeExpr

This is a prerequisite to removing `QPath::LangItem` (rust-lang/rust#115178) because otherwise there would be no way to detect a range expression in the HIR.

There are some non-obvious Clippy changes so a Clippy team review would be good.
2025-10-27 02:50:35 +00:00
bors
b1b464d6f6 Auto merge of #147914 - petrochenkov:oosmc-used, r=fmease
resolve: When suppressing `out_of_scope_macro_calls` suppress `unused_imports` as well

Fixes the example from this comment - https://github.com/rust-lang/rust/issues/147823#issuecomment-3421770900.
Fixes https://github.com/rust-lang/rust/issues/148143.
2025-10-26 23:44:52 +00:00
bors
f37aa9955f Auto merge of #147890 - tmiasko:deduce-captures-none, r=cjgillot
Deduce captures(none) for a return place and parameters

Extend attribute deduction to determine whether parameters using
indirect pass mode might have their address captured. Similarly to
the deduction of `readonly` attribute this information facilitates
memcpy optimizations.
2025-10-26 20:37:03 +00:00
Stuart Cook
3bf838d790 Rollup merge of #148118 - saethlin:nullary-intrinsic-check-bug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls

In https://github.com/rust-lang/rust/issues/148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.

I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.

The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when https://github.com/rust-lang/rust/pull/147793 ported two more the paragraph wasn't added. I've added it.
2025-10-26 22:15:09 +11:00
Ben Kimock
7a0d9c8d5e Improve the ICE message for invalid nullary intrinsic calls 2025-10-25 21:32:27 -04:00
bors
cc63a0abde Auto merge of #148066 - lcnr:remove-perf-hack, r=BoxyUwU
remove a performance hack

This hack seems no longer used 🤔 nalgebra compiles without it.

Let's run perf to see whether it matters.

r? `@BoxyUwU`
2025-10-25 22:23:29 +00:00
Tomasz Miąsko
2a03a948b9 Deduce captures(none) for a return place and parameters
Extend attribute deduction to determine whether parameters using
indirect pass mode might have their address captured. Similarly to
the deduction of `readonly` attribute this information facilitates
memcpy optimizations.
2025-10-25 22:53:52 +02:00
bors
34f954f9b7 Auto merge of #148100 - matthiaskrgr:rollup-vrd4wy8, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#143361 (Stop passing resolver disambiguator state to AST lowering.)
 - rust-lang/rust#148000 (Improvements to attribute suggestions)
 - rust-lang/rust#148007 (chore: Update to the latest annotate-snippets)
 - rust-lang/rust#148088 (compiletest: Simplify passing arguments to spawned test threads)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-25 19:10:39 +00:00
bors
79966ae420 Auto merge of #147493 - cjgillot:single-pin, r=oli-obk
StateTransform: Only load pin field once.

The current implementation starts by transforming all instances of `_1` into `(*_1)`, and then traverses the body again to transform `(*_1)` into `(*(_1.0))`, and again for `Derefer`.

This PR changes the implementation to only traverse the body once. As `_1.0` cannot be not modified inside the body (we just changed its type!), we have no risk of loading from the wrong pointer.
2025-10-25 16:04:41 +00:00
Matthias Krüger
141c91091c Rollup merge of #148007 - Muscraft:annotate-snippets, r=jdonszelmann
chore: Update to the latest annotate-snippets

This PR updates `annotate-snippets` to the latest version and updates the adapter code[^1] so that `AnnotateSnippetEmitter`'s output matches `HumanEmitter`'s output. If anyone would like to see the differences[^2] between `AnnotateSnippetEmitter` and `HumanEmitter`, [I have a branch](https://github.com/Muscraft/rust/tree/annotate-snippets-default-renderer) where `AnnotateSnippetEmitter` is used in place of `HumanEmitter`.

[^1]: A lot of the adapter code changes are based on code for `HumanEmitter`.
[^2]: Some of the test differences will go away when rust-lang/rust#148001 and rust-lang/rust#148004 are merged.
2025-10-25 12:57:39 +02:00
Matthias Krüger
d182d8e874 Rollup merge of #148000 - JonathanBrouwer:wipnew2, r=jdonszelmann
Improvements to attribute suggestions

Changes in commit 1:
- Add `AcceptContext::suggestions`, which retrieves the suggestions for the currently parsing attribute
- This happens to fix a bug in the way `#[macro_export`]. Closes https://github.com/rust-lang/rust/pull/147987

Changes in commit 2:
- Add a check to the suggestions function so the suggestions for attributes in cfg_attr are nicer. Fixes https://github.com/rust-lang/rust/issues/147693

This is also part (but not all) of the changes needed to unblock https://github.com/rust-lang/rust/pull/147945

r? `@jdonszelmann`
2025-10-25 12:57:39 +02:00
Matthias Krüger
cee562c0b2 Rollup merge of #143361 - cjgillot:split-disambig, r=oli-obk
Stop passing resolver disambiguator state to AST lowering.

AST->HIR lowering can use a disjoint set of `DefPathData` as the resolver, so we don't need to pass the disambiguator state.

r? `@oli-obk`
2025-10-25 12:57:38 +02:00
bors
f435972085 Auto merge of #142712 - davidtwco:sized-hierarchy-missing-default-bounds, r=lcnr
hir_analysis: add missing sizedness bounds

Depends on rust-lang/rust#144064

Default sizedness bounds were not being added to `explicit_super_predicates_of` and `explicit_implied_predicates_of` which meant that a trait bound added to a associated type projection would be missing the implied predicate of the default sizedness supertrait of that trait.

An unexpected consequence of this change was that the check for multiple principals was now finding an additional `MetaSized` principal when eagerly expanding trait aliases - which is fixed by skipping `MetaSized` when elaborating trait aliases in lowering `dyn TraitAlias`.
2025-10-24 21:39:28 +00:00
Scott Schafer
354b9779bf chore: Update to the latest annotate-snippets 2025-10-24 12:50:19 -06:00
bors
2aaa62b89d Auto merge of #148018 - tardyp:lto_big_filesize_utf8, r=JonathanBrouwer
fix panic when rustc tries to reduce intermediate filenames len with utf8

The issue cannot be reproduced with the former testcase of creating external crates because rust refuses to use "external crate 28_找出字符串中第一个匹配项的下标" because it is not a valid indentifier (starts with number, and contain non ascii chars)

But still using 28_找出字符串中第一个匹配项的下标.rs as a filename is accepted by previous rustc releases So we consider it valid, and add an integration test for it to catch any regression on other code related to non ascii filenames.

Fix rust-lang/rust#147975
2025-10-24 18:23:10 +00:00
David Wood
82a4049844 hir_analysis: add missing sizedness bounds
Default sizedness bounds were not being added to
`explicit_super_predicates_of` and `explicit_implied_predicates_of`
which meant that a trait bound added to a associated type projection
would be missing the implied predicate of the default sizedness
supertrait of that trait.

An unexpected consequence of this change was that the check for multiple
principals was now finding an additional `MetaSized` principal when
eagerly expanding trait aliases. Instead of special-casing trait aliases
as different from traits and not adding a `MetaSized` supertrait to trait
aliases, filter out `MetaSized` when lowering `dyn Trait`.
2025-10-24 15:28:34 +01:00
Pierre Tardy
c6acffeb78 fix panic when rustc tries to reduce intermediate filenames length with multi byte chars
The issue cannot be reproduced with the former testcase of creating external crates because
rust refuses to use "external crate 28_找出字符串中第一个匹配项的下标"
because it is not a valid indentifier (starts with number, and contain non ascii chars)

But still using 28_找出字符串中第一个匹配项的下标.rs as a filename is accepted by previous rustc releases
So we consider it valid, and add an integration test for it to catch any regression on other code related to non ascii filenames.
2025-10-24 16:20:29 +02:00
lcnr
561e3cede2 gamer 2025-10-24 15:34:45 +02:00
bors
ab925646fa Auto merge of #147950 - durin42:llvm-22-intrinsics-changes, r=nikic
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().

Related LLVM change is llvm/llvm-project#163802.

`@rustbot` label llvm-main
2025-10-24 13:00:14 +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