Commit graph

311266 commits

Author SHA1 Message Date
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
bors
d2f887349f Auto merge of #149073 - weihanglo:update-cargo, r=weihanglo
Update cargo submodule

13 commits in 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f..5c0343317ce45d2ec17ecf41eaa473a02d73e29c
2025-11-12 15:56:06 +0000 to 2025-11-18 19:05:44 +0000
- feat: emit a warning when both `package.publish` and `--index` are specified (rust-lang/cargo#16268)
- docs(cargo-yank): clarify yank behavior with leaked credentials (rust-lang/cargo#16274)
- feat(generate-lockfile): Add unstable --publish-time flag  (rust-lang/cargo#16265)
- Do not lock the artifact-dir for check builds (rust-lang/cargo#16230)
- fix(fingerprint): force update mtime of cargo-check artifacts (rust-lang/cargo#16262)
- fix(manifest): Point out when a key belongs to config (rust-lang/cargo#16256)
- Use raw false during cfg test (rust-lang/cargo#16261)
- Suppress metadata warnings for non–crates.io publishable packages (rust-lang/cargo#16241)
- feat(tree): Support long forms for --format variables (rust-lang/cargo#16204)
- fix(config): Fallback to non-canonical path for workspace-path-hash (rust-lang/cargo#16248)
- fix: update mtime for generated files after unpacking (rust-lang/cargo#16250)
- feat(cli): Add support for completing `--config` values in Bash (rust-lang/cargo#16245)
- feat: Add a typos CI job (rust-lang/cargo#16122)
2025-11-19 21:34:16 +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
bors
140044cffa Auto merge of #149085 - matthiaskrgr:rollup-f8ia15e, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#147171 (recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher)
 - rust-lang/rust#147421 (Add check if span is from macro expansion)
 - rust-lang/rust#147521 (Make SIMD intrinsics available in `const`-contexts)
 - rust-lang/rust#148201 (Start documenting autodiff activities)
 - rust-lang/rust#148797 (feat: Add `bit_width` for unsigned `NonZero<T>`)
 - rust-lang/rust#148798 (Match <OsString as Debug>::fmt to that of str)
 - rust-lang/rust#149082 (autodiff: update formating, improve examples for the unstable-book)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-19 08:54:07 +00:00
Matthias Krüger
fd88e61fc9
Rollup merge of #149082 - ZuseZ4:autodiff-unstable-book-fmt, r=chenyukang
autodiff: update formating, improve examples for the unstable-book

r? compiler
2025-11-19 09:48:11 +01:00
Matthias Krüger
48fa9138c3
Rollup merge of #148798 - tamird:esc-single-quote, r=Amanieu
Match <OsString as Debug>::fmt to that of str

Fixes rust-lang/rust#114583.
2025-11-19 09:48:10 +01:00
Matthias Krüger
8b7479003b
Rollup merge of #148797 - sorairolake:feature/non-zero-uint-bit-width, r=scottmcm
feat: Add `bit_width` for unsigned `NonZero<T>`

- Tracking issue: rust-lang/rust#142326

This pull request adds a method to the unsigned `NonZero<T>` that return the minimum number of bits required to represent a value.

This can be achieved by using the `get` method and the methods added in rust-lang/rust#142328, but I think adding the `NonZero::bit_width` method is useful because it accomplishes the same thing a little more succinctly.
2025-11-19 09:48:09 +01:00
Matthias Krüger
3732c3c068
Rollup merge of #148201 - ZuseZ4:autodiff-activity-docs, r=oli-obk
Start documenting autodiff activities

Some initial documentation of the autodiff macros and usage examples
2025-11-19 09:48:08 +01:00
Matthias Krüger
714f1cea15
Rollup merge of #147521 - sayantn:simd-const-intrinsics, r=madsmtm
Make SIMD intrinsics available in `const`-contexts

successor to rust-lang/rust#146568, this PR actually makes the SIMD intrinsics `const`, and modifies the tests to test the const-eval implementations

r? `@tgross35` ig (although feel free to reassign, this is not anything targeted really)
2025-11-19 09:48:07 +01: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
0b2e02f135 autodiff: update formating, improve examples for the unstable-book 2025-11-19 03:05:45 -05:00
bors
a591113c0a Auto merge of #149037 - alexcrichton:update-wasi-sdk, r=jieyouxu
Update wasm-related dependencies in CI

* Update to wasi-sdk-29 released today
* Update to Wasmtime 38.0.4 which was released a week or so ago

This is the same as rust-lang/rust#148611, except with wasi-sdk-29 to fixup some issues found in wasi-sdk-28.
2025-11-19 05:35:29 +00: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
Weihang Lo
96d760c748
Update cargo submodule 2025-11-18 19:35:43 -05: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
Alex Crichton
4c6e41cb53 Update wasm-related dependencies in CI
* Update to wasi-sdk-29 released today
* Update to Wasmtime 38.0.4 which was released a week or so ago
2025-11-18 10:52:19 -08:00
Shun Sakai
a25950dec6 feat: Change return type of NonZero::bit_width
Return `NonZero<u32>` instead of `u32`.
2025-11-19 03:17:38 +09: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
5d243031e2
Rollup merge of #149057 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to afcfe141ae.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2025-11-18 16:52:12 +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
Matthias Krüger
e6d08c6521
Rollup merge of #147887 - matthieu-m:task/lib-core-sync-atomic-fence-doc-improvement, r=Mark-Simulacrum
Improve the documentation of atomic::fence

Attempt to "fix" two flaws of the current documentation:

1. The over-emphasis of fence - fence synchronization, relegating atomic - fence and fence - atomic synchronization to second fiddle.
2. The lack of explanation as to how to properly perform atomic - fence and fence - atomic synchronization.

It does so by first making it clear that there are 3 different ways to use an atomic fence, then presenting a full example for each usecase, noting the particular position of the fence with regard to the atomic operation, and rounding up with generic notes.
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
6120f0d54b
Rollup merge of #149049 - Zalathar:only-elf, r=clubby789
compiletest: Use JSON "binary-format" to decide `//@ only-elf` and `//@ ignore-elf`

Some tests only apply to ELF targets, or want to enable different test revisions for ELF and non-ELF targets. So compiletest supports the `//@ only-elf` and `//@ ignore-elf` directives to make that possible.

Historically, deciding whether the current target is an ELF target relied on a handful of ad-hoc string comparisons against the target tuple.

However, nowadays compiletest has access to the output of `--print=all-target-specs-json`, and that JSON output specifies the binary format of each target, making it much easier to determine whether a target is ELF or not.
2025-11-18 14:14:40 +01:00
Guillaume Gomez
1fd16b19fc
Rollup merge of #149026 - GuillaumeGomez:test-for-reexported-variant, r=lolbinarycat
Add test for href of reexported enum variant

Working on https://github.com/rust-lang/rust/issues/148648 and realized that we actually didn't test for enum variants reexports, so here we are.

I also think I'll do rust-lang/rust#148648 at the same time as https://github.com/rust-lang/rust/issues/148547.

r? `@lolbinarycat`
2025-11-18 14:14:39 +01: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
Guillaume Gomez
ff262bcb29
Rollup merge of #148970 - Ayush1325:uefi-fs-stat, r=joboet
std: sys: fs: uefi: Implement stat

- Implement std::fs::metadata function.
- Tested on qemu ovmf
2025-11-18 14:14:38 +01:00
Ralf Jung
c23182eb24 repr(transparent) check: do not compute check_unsuited more than once 2025-11-18 13:53:35 +01:00
Laurențiu Nicola
6da4a35359 Fix elided lifetime 2025-11-18 14:06:52 +02:00
Guillaume Gomez
8642d82ff5 Add test for href of reexported enum variant 2025-11-18 12:23:32 +01:00
Guillaume Gomez
2a1bd47a4a Move tests/rustdoc/import_trait_associated_functions.rs into the reexport folder 2025-11-18 12:23:32 +01:00
Laurențiu Nicola
24d2ab5e6b
Merge pull request #21054 from lnicola/ungrammar-unused-import
minor: Drop unused `ungrammar` import
2025-11-18 11:21:18 +00:00
Laurențiu Nicola
116af5b861 Drop unused ungrammar import 2025-11-18 13:12:03 +02:00
bors
f9e7961506 Auto merge of #148151 - cjgillot:no-offset-of, r=scottmcm
Replace OffsetOf by an actual sum of calls to intrinsic.

This PR changes the way we compute the value of the `offset_of!` macro in MIR. The current implementation uses a dedicated MIR rvalue.

This PR proposes to replace it by an inline constant which sums calls to a new intrinsic `offset_of(variant index, field index)`. The desugaring is done at THIR building time, easier that doing it on MIR.

The new intrinsic is only meant to be used by const-eval. LLVM codegen will refuse to generate code for it.

We replace:
```rust
a = offset_of!(T, Variant1.Field1.Variant2.Field2);
```

By:
```rust
a = const {constant#n};

{constant#n}: usize = {
    _1 = offset_of::<T>(index of Variant1, index of Field1);
    _2 = offset_of::<U>(index of Variant2, index of Field2); // Where T::Variant1::Field1 has type U
    _0 = _1 + _2
}
```

The second commit modifies intrinsic const checking to take `allow_internal_unstable` into account. The new intrinsic should only be called from stable `offset_of!` macro. The intrinsic itself is unstable, const-unstable, but `rustc_intrinsic_const_stable_indirect`.

Fixes rust-lang/rust#123959
Fixes rust-lang/rust#125680
Fixes rust-lang/rust#129425
Fixes rust-lang/rust#136175

r? `@ghost`
2025-11-18 10:55:59 +00:00
Oli Scherer
357fd66c04 Avoid encoding non-constness or non-asyncness in metadata 2025-11-18 10:12:13 +00:00
Ayush Singh
6106760f31
std: sys: fs: uefi: Implement stat
- Implement std::fs::metadata function.
- Tested on qemu ovmf

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-11-18 15:11:08 +05:30
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
bors
c1995621a4 Auto merge of #148803 - jsgf:rust-annotate-default, r=Kobzol
Build with -Zannotate-moves by default (non-stage-0 only)

Build rustc and tools with -Zannotate-moves by default, both to exercise the feature and because could be useful for doing performance measurement on rustc and its tools. This has no effect on generated code, it just adds extra debug info in
the form of some new inlined functions.

This also adds bootstrap.toml config options
```
# rust.annotate-moves = true
# rust.annotate-moves-size-limit = 65
```
to allow this to be controlled locally.

This is only added for stage 1 and later. Stage 0 (the bootstrap compiler) doesn't yet support -Zannotate-moves.
2025-11-18 07:42:43 +00:00
bors
217cb73577 Auto merge of #149040 - RustyYato:patch-2, r=Kivooeo
Update RustyYato's email

I no longer use the old email address
2025-11-18 04:30:45 +00:00
Zalathar
7560717231 Use JSON "binary-format" to decide //@ only-elf and //@ ignore-elf 2025-11-18 14:08:51 +11:00
Zalathar
d835b7c009 Add some tests for //@ ignore-elf and //@ only-elf 2025-11-18 13:35:19 +11:00