Commit graph

51518 commits

Author SHA1 Message Date
bjorn3
2a280130db Allow passing primary spans to SharedEmitter 2025-11-21 14:37:10 +00:00
bjorn3
bba5f7f72b Remove unused pop_span_label method 2025-11-21 14:16:12 +00:00
bjorn3
7f7b3488c0 Introduce InlineAsmError type 2025-11-21 14:16:12 +00:00
Stuart Cook
db505171a3
Rollup merge of #149160 - maxdexh:fix-instrinsic-unifying-coercion-ice, r=Kivooeo,BoxyUwU
Check for intrinsic to fn ptr casts in unified coercions

Fixes rust-lang/rust#149143 by ensuring that when coercing multiple expressions to a unified type, the same "intrinsic to fn ptr" check is applied as for other coercions.
2025-11-21 14:44:44 +11:00
Stuart Cook
be1e129bd2
Rollup merge of #148990 - Zalathar:print-kind, r=WaffleLapkin
Exhaustively specify names and stability of `--print` values

While trying to add a new unstable `--print` kind for use by compiletest, I found that the relevant code is quite awkward to work with, for a few reasons:

- It's spread across various parts of a multi-thousand-line source file.
- All newly-added `PrintKind` values are automatically treated as *stable*, unless they are explicitly marked as unstable in a helper function far away.
- Parsing `--print` values relies on a separate table of name/value mappings, but there's no exhaustiveness check for that table.

This PR therefore:
- Extracts the relevant code into its own `print_request` submodule.
- Uses a macro-rules derive to obtain an exhaustive list of values.
- Uses exhaustive matches to associate a name and stability status with each `PrintKind` value.

---

The first commit moves code to a separate module; the second commit contains actual changes.

There should be no change to compiler output.
2025-11-21 14:44:42 +11:00
Zalathar
9c7e7ccd25 Exhaustively specify names and stability of --print values 2025-11-21 11:35:07 +11:00
Zalathar
c81d22d506 Extract module rustc_session::config::print_request 2025-11-21 11:29:10 +11:00
Max Dexheimer
ebf1c38aa6 Check for intrinsic to fn ptr casts in unified coercions
Ensures that when coercing multiple expressions to a
unified type, the same "intrinsic to fn ptr" check is applied as for
other coercions.
2025-11-21 00:01:21 +01:00
Matthias Krüger
83e37a9be3
Rollup merge of #149144 - lapla-cogito:ice_149083, r=oli-obk
Reject `async fn` in `const impl` during AST validation

closes rust-lang/rust#149083

Fixes the ICE when using `async fn` inside `const impl` blocks by adding AST validation.

Currently, inherent `impl`s does not perform any checks to verify whether it contains `async fn` declarations. In this PR, I have modified the `visit_assoc_item` function to call `check_async_fn_in_const_trait_or_impl` within the `TraitOrImpl::Impl` case to handle this requirement. Additionally, this change has introduced three possible contexts for the corresponding error messages, so I have updated to properly distinguish between these different contexts when generating messages.

r? oli-obk
2025-11-20 20:11:47 +01:00
Matthias Krüger
6b1bdacffe
Rollup merge of #149139 - 12101111:ohos-host-tools, r=nnethercote
Enable host tools for aarch64-unknown-linux-ohos

![7dd6b50e474ee5fd14fd0bffda522874](https://github.com/user-attachments/assets/9b718630-a8a8-426c-ab54-5d767d605091)
2025-11-20 20:11:47 +01:00
Matthias Krüger
710720a827
Rollup merge of #149033 - ZuseZ4:autodiff-rlib, r=bjorn3
autodiff rlib handling

As I learned recently, we now apparently support rlib builds already in some cases.
With the last hint from saethlin this seems to now cover all cases. To be sure I'll add a few more testcases before I mark it as ready.

Once this PR lands, we should to the best of my knowledge, support autodiff in almost code locations, only vtable/dyn ptr remain unsupported for now.

r? ghost

closes: https://github.com/rust-lang/rust/issues/148856
closes: https://github.com/rust-lang/rust/issues/137520
2025-11-20 20:11:42 +01:00
lapla
c108451faf
Reject async fn in const impl during AST validation 2025-11-21 00:02:58 +09:00
12101111
1e14a5dc73
Enable host tools for aarch64-unknown-linux-ohos 2025-11-20 19:22:01 +08:00
Matthias Krüger
7198d31e4b
Rollup merge of #149041 - folkertdev:sparc64-mips64-ignore-unsized, r=bjorn3
ignore unsized types in mips64 and sparc64 callconvs

Non-rustic calling conventions should not make up an ABI for unsized types (cc https://github.com/rust-lang/rust/pull/148302). The vast majority of our callconv implementations already ignore unsized types, `sparc64` and `mips64` I guess were missed.

r? `````@bjorn3`````
2025-11-20 11:15:53 +01:00
Matthias Krüger
34b3c9dd4d
Rollup merge of #148261 - aDotInTheVoid:no-sync-for-smir, r=celinval
rustc_public: Make Id types !Send / !Sync

These types are Id's to a table stored in TLS, so using them from another tread will either panic, or give wrong results.

Therefor, I've added a ~~`ReferencesTls`~~`ThreadLocalIndex`  marker type, which ensures types arn't `Send`/`Sync`.

This is a breaking change for users of the `rustc_public` crate.

~~It also changes how `DefId` and similar are `Serialize`d. It would be possible to preserve the old behavior if that's needed, but I couldn't see any tests for these.~~ EDIT: Not anymore: https://github.com/rust-lang/rust/pull/148261#discussion_r2476111612

Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/channel/320896-project-stable-mir/topic/WDYM.20.22should.20not.20.20be.20shared.20across.20threads.22/with/547374171
2025-11-20 11:15:52 +01:00
Matthias Krüger
422b83aeee
Rollup merge of #147173 - androm3da:bcain/hexagon_qurt, r=davidtwco,tgross35
Add support for hexagon-unknown-qurt target

MCP: https://github.com/rust-lang/compiler-team/issues/919
Fixes https://github.com/rust-lang/rust/issues/148982.
2025-11-20 11:15:51 +01:00
bors
683dd08db5 Auto merge of #89917 - davidtwco:issue-60705-stabilize-rust-symbol-mangling-scheme, r=wesleywiser
sess: default to v0 symbol mangling on nightly

cc rust-lang/rust#60705 rust-lang/compiler-team#938

Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain `.` characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and `_`.

Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers).

This pull request changes the default symbol mangling scheme from the legacy scheme to the new Rust mangling scheme on nightly.

The following pull requests implemented v0 mangling in rustc (if I'm missing any, let me know):

- rust-lang/rust#57967
- rust-lang/rust#63559
- rust-lang/rust#75675
- rust-lang/rust#77452
- rust-lang/rust#77554
- rust-lang/rust#83767
- rust-lang/rust#87194
- rust-lang/rust#87789

Rust's symbol mangling scheme has support in the following external tools:

- `binutils`/`gdb` (GNU `libiberty`)
    - [[PATCH] Move rust_{is_mangled,demangle_sym} to a private libiberty header.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-June/523011.html) committed as 979526c9ce
    - [[PATCH] Simplify and generalize rust-demangle's unescaping logic.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-August/527835.html) committed as 42bf58bb13
    - [[PATCH] Remove some restrictions from rust-demangle.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-September/530445.html) committed as e1cb00db67
    - [[PATCH] Refactor rust-demangle to be independent of C++ demangling.
](https://gcc.gnu.org/pipermail/gcc-patches/2019-November/533719.html) ([original submission](https://gcc.gnu.org/pipermail/gcc-patches/2019-October/532388.html)) committed as 32fc3719e0
    - [[PATCH] Support the new ("v0") mangling scheme in rust-demangle.
](https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558905.html) ([original submission](https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542012.html)) committed as 84096498a7
- `lldb`/`llvm-objdump`/`llvm-nm`/`llvm-symbolizer`/`llvm-cxxfilt`/etc
  - 7310403e3c
  - c8c2b4629f
  - 0a2d4f3f24
- Linux `perf`
- `valgrind`
  - [Update demangler to support Rust v0 name mangling.](https://bugs.kde.org/show_bug.cgi?id=431306)

https://github.com/rust-lang/rust/pull/85530#issuecomment-857855379 contains a summary of the most recent crater run of the v0 mangling, and the remaining issues from that were fixed by rust-lang/rust#87194 (confirmed by follow-up crater run, https://github.com/rust-lang/rust/pull/85530#issuecomment-883679416).

`@rustbot` label +T-compiler
r? `@michaelwoerister`
2025-11-20 04:26:30 +00:00
Alona Enraght-Moony
e7b84604cb rustc_public: Make Id types !Send / !Sync
These types are Id's to a table stored in TLS, so using them from
another tread will either panic, or give wrong results.

Therefor, I've added a `ThreadLocalIndex` marker type, which ensures types
arn't `Send`/`Sync`.

This is a breaking change for users of the `rustc_public` crate.

Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/channel/320896-project-stable-mir/topic/WDYM.20.22should.20not.20.20be.20shared.20across.20threads.22/with/547374171
2025-11-19 19:46:18 +00:00
bors
07bdbaedc6 Auto merge of #149054 - oli-obk:min-encode, r=fee1-dead
Avoid encoding non-constness or non-asyncness in metadata

r? `@fee1-dead`

Let's see if we can get any benefit (even just metadata size) from not encoding the common case.

Inspired by https://github.com/rust-lang/rust/pull/148434#discussion_r2491732811
2025-11-19 12:06:14 +00:00
David Wood
ff00110543
sess: default to v0 symbol mangling
Rust's current mangling scheme depends on compiler internals; loses
information about generic parameters (and other things) which makes for
a worse experience when using external tools that need to interact with
Rust symbol names; is inconsistent; and can contain `.` characters
which aren't universally supported. Therefore, Rust has defined its own
symbol mangling scheme which is defined in terms of the Rust language,
not the compiler implementation; encodes information about generic
parameters in a reversible way; has a consistent definition; and
generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and
`_`.

Support for the new Rust symbol mangling scheme has been added to
upstream tools that will need to interact with Rust symbols (e.g.
debuggers).

This commit changes the default symbol mangling scheme from the legacy
scheme to the new Rust mangling scheme.

Signed-off-by: David Wood <david.wood@huawei.com>
2025-11-19 11:55:09 +00:00
Matthias Krüger
2cc5bf7b6a
Rollup merge of #147421 - Kivooeo:ice-fix51621, r=chenyukang
Add check if span is from macro expansion

The same thing I did in https://github.com/rust-lang/rust/pull/147416, actually the same bug but in another place, I'm not really sure how this method is good for fixing such ICEs, but, it does work and not conflicting with any existing tests, so I guess, it's fine

Fixes https://github.com/rust-lang/rust/issues/147408

r? compiler
2025-11-19 09:48:06 +01:00
Matthias Krüger
847c422cea
Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead
recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher

closes rust-lang/rust#147147

~The suggestion span is wrong, but I'm not sure how to find the right one.~ fixed

I'm relatively new to the diagnostics ecosystem, so I'm not sure if `span_help` is the right choice. `span_suggestion_*` might be better, but the output from `x test` looks weird in that case.
2025-11-19 09:48:05 +01:00
Manuel Drehwald
0dfdb6c3da rlib handling 2025-11-19 00:17:37 -05:00
bors
6159a44067 Auto merge of #148434 - oli-obk:inherent-const-impl, r=fee1-dead
Inherent const impl

Some constifications are annoying because we need to repeat `T: Trait` bounds from an impl block on the individual constified `const fn`s as `T: [const] Trait`. We've brainstormed solutions before, and one would be to have separate `const impl` blocks or sth. However the final syntax will look, I decided to just impl this syntax and either have sth nice on nightly to work with or at least move the discussion along.

Also interacts with the discussion around `impl const Trait for Type` vs `const impl Trait for Type`, as we may want to use the latter to keep inherent and trait impls in sync (unless we come up with even another scheme).

* [ ] rustdoc + tests
* [ ] macro stability /regression tests

r? `@fee1-dead`

cc `@traviscross` `@rust-lang/project-const-traits`
2025-11-19 02:23:56 +00:00
bors
7c2c3c0ded Auto merge of #149063 - matthiaskrgr:rollup-6z23izv, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#147887 (Improve the documentation of atomic::fence)
 - rust-lang/rust#148281 (repr(transparent) check: do not compute check_unsuited more than once)
 - rust-lang/rust#148484 (Fix suggestion for the `cfg!` macro)
 - rust-lang/rust#149057 (`rust-analyzer` subtree update)
 - rust-lang/rust#149061 (debug-assert FixedSizeEncoding invariant)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-18 21:59:27 +00:00
Oli Scherer
b41c2a2870 Forbid const fn within const impls 2025-11-18 16:00:18 +00:00
Oli Scherer
ababa26251 Collect const_conditions for inherent impls 2025-11-18 16:00:18 +00:00
Oli Scherer
939afab37e Treat inherent methods in const impl blocks as const 2025-11-18 16:00:18 +00:00
Oli Scherer
00157d4a3d Allow inherent const impl blocks 2025-11-18 16:00:18 +00:00
Matthias Krüger
ceb33e9a3a
Rollup merge of #149061 - jdonszelmann:fixed-size-encoding-assert, r=oli-obk
debug-assert FixedSizeEncoding invariant

Something like this? It asserts during encoding that for that type, decoding 0 would give the default.
Preferably, I'd either somehow statically/in const assert it once, instead of every time, but I see no easy way to do so. It'd require us to iterate all types that implement the trait or something. Let me know what you think

No types currently violate this invariant.

r? `@oli-obk`
2025-11-18 16:52:13 +01:00
Matthias Krüger
642300e339
Rollup merge of #148484 - JonathanBrouwer:wip_attr_style, r=jdonszelmann
Fix suggestion for the `cfg!` macro

r? `@jdonszelmann`
2025-11-18 16:52:11 +01:00
Matthias Krüger
280a6c5304
Rollup merge of #148281 - RalfJung:repr-transparent-check, r=nnethercote
repr(transparent) check: do not compute check_unsuited more than once

`field_infos` is an iterator that we execute multiple times. However, we usually ignore the `unsuited` field -- we only need it in the last iteration. So move the computation of that field to that iteration to avoid computing it multiple times. Computing `unsuited` involves a recursive traversal over the types of all non-trivial fields, so there can be non-trivial amounts of work here.

(I benchmarked this in https://github.com/rust-lang/rust/pull/148243 and saw no changes, probably because we don't have a benchmark with many repr(transparent) types. But still, computing this each time just seemed silly.)
2025-11-18 16:52:10 +01:00
Jana Dönszelmann
d1bcf2ec84
debug-assert FixedSizeEncoding invariant 2025-11-18 15:59:04 +01:00
bors
3d461af2a2 Auto merge of #149059 - GuillaumeGomez:rollup-s6m2mmy, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#148970 (std: sys: fs: uefi: Implement stat)
 - rust-lang/rust#149020 (flush_delayed: add note about stashed diagnostics)
 - rust-lang/rust#149026 (Add test for href of reexported enum variant)
 - rust-lang/rust#149049 (compiletest: Use JSON "binary-format" to decide `//@ only-elf` and `//@ ignore-elf`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-18 14:07:46 +00:00
Guillaume Gomez
abf6d307ae
Rollup merge of #149020 - RalfJung:flush_delayed, r=nnethercote
flush_delayed: add note about stashed diagnostics

r? `@nnethercote`
Is `emit_stashed_diagnostics` the right advice to give? The other option seems to be to call `finish_diagnostics`. That's what I ended up doing (for now) in https://github.com/rust-lang/miri/pull/4702 because it best matches what happens during normal compilation.
2025-11-18 14:14:39 +01:00
Ralf Jung
c23182eb24 repr(transparent) check: do not compute check_unsuited more than once 2025-11-18 13:53:35 +01:00
Oli Scherer
357fd66c04 Avoid encoding non-constness or non-asyncness in metadata 2025-11-18 10:12:13 +00:00
Oli Scherer
2a36d33930 Give all impls a constness 2025-11-18 09:20:21 +00:00
Oli Scherer
08c391ca09 Temporarily allow const impl and impl const at the same time to migrate 2025-11-18 09:20:21 +00:00
Oli Scherer
a16ff533b9 Refactor impl block frontmatter checking in the parser 2025-11-18 09:20:21 +00:00
Camille Gillot
63a7712552 Simplify implementation. 2025-11-18 00:10:03 +00:00
Camille Gillot
12e91cf814 Honor allow_internal_unstable for const intrinsics. 2025-11-18 00:10:03 +00:00
Camille Gillot
72444372ae Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
Folkert de Vries
bbf7dc0ddf
ignore unsized types in mips64 and sparc64 callconvs 2025-11-17 22:47:59 +01:00
Matthias Krüger
6b8f2c7938
Rollup merge of #149016 - Zalathar:let-this-self, r=Kivooeo
Document the `let this = self;` idiom used in MIR building

In `rustc_mir_build` there are a few `Builder` methods that start with `let this = self;`, so that subsequent code can uniformly refer to the builder as `this`, instead of having to choose between `self` at the top level or `this` when nested in closures that need to borrow the builder.

There is some existing documentation of the idiom in `expr_into_dest`:

69d4d5fc0e/compiler/rustc_mir_build/src/builder/expr/into.rs (L32-L35)

But that documentation is brief and hard to find, especially if one is unaware that such documentation even exists.

---

This PR therefore adds a longer explanation of the `let this = self;` idiom in the module documentation for `rustc_mir_build::builder`, and makes that documentation easier to find by adding a searchable tag (“LET_THIS_SELF”) to the documentation and to each occurrence of the idiom.
2025-11-17 18:07:34 +01:00
Matthias Krüger
0e0dac2efc
Rollup merge of #148865 - lcnr:gat-inference-hack, r=BoxyUwU
move GAT inference prevention hack

The structure of `fn assemble_and_merge_candidates` is quite messy and the differences between `Host` and `NormalizesTo` goals is large enough that we should split them entirely. Intend to change this for https://github.com/rust-lang/trait-system-refactor-initiative/issues/245 by mentoring someone: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/ask.20for.20help/near/554696331. Think it's still fine to merge this PR without that larger change.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/256

r? `@BoxyUwU`
2025-11-17 18:07:33 +01:00
Matthias Krüger
3bc1eaa66a
Rollup merge of #148698 - tiif:const_query_cycle, r=BoxyUwU
Fix query cycle when encounter unevaluated const

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/249

In this PR, the environment is dropped when evaluating const that does not have any generic parameter to fix the query cycle.
2025-11-17 18:07:33 +01:00
Jeremy Smart
754a82d87c
recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher 2025-11-17 11:56:21 -05:00
Ralf Jung
bad7d36c33 flush_delayed: add note about stashed diagnostics 2025-11-17 12:09:57 +01:00
bors
cc328c1238 Auto merge of #149013 - Zalathar:rollup-io1ddhc, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#148505 (add larger test for `proc_macro` `FromStr` implementations)
 - rust-lang/rust#148752 (Constify `ManuallyDrop::take`)
 - rust-lang/rust#148757 (Constify `mem::take`)
 - rust-lang/rust#148855 (Error if an autodiff user does not set lto=fat)
 - rust-lang/rust#148912 (add note to `lines` docs about empty str behavior)
 - rust-lang/rust#148958 (Run codegen tests on a 32-bit target in PR CI)
 - rust-lang/rust#148994 (Abi compatibility test cleanup)
 - rust-lang/rust#148999 (Tweak Motor OS linker preset, fix `remote-test-server` for Motor OS)
 - rust-lang/rust#149004 (compiletest: Avoid race condition in file deletion)
 - rust-lang/rust#149008 (triagebot: remove jsha from notifications for rustdoc HTML)
 - rust-lang/rust#149010 (compiletest: Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-17 07:49:48 +00:00