Commit Graph

311252 Commits

Author SHA1 Message Date
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
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
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 https://github.com/rust-lang/rust-analyzer/commit/afcfe141aec0fd7a7a16ddbec07f2e76aa5ea0e0.

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
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
Camille Gillot e7991602ed Add THIR building test. 2025-11-18 00:32:51 +00:00
Camille Gillot aeb9332b28 Complete doc. 2025-11-18 00:10:04 +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
bors fb505a7985 Auto merge of #149039 - matthiaskrgr:rollup-9vt1ady, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#147077 (std: move `kernel_copy` to `sys`)
 - rust-lang/rust#149030 (doc: fix `strict_provenance_lints` tracking issue link)
 - rust-lang/rust#149031 (Update books)
 - rust-lang/rust#149034 (update my email in mailmap)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-17 21:38:07 +00:00
RustyYato 261c37b788 Update RustyYato's email
I no longer use the old email address
2025-11-17 15:04:57 -06:00
Matthias Krüger d810867750 Rollup merge of #149034 - mati865:mailmap, r=clubby789
update my email in mailmap
2025-11-17 21:48:00 +01:00
Matthias Krüger f51efa1de9 Rollup merge of #149031 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

61 commits in f660f341887c8bbcd6c24fbfdf5d2a262f523965..f78ab89d7545ac17780e6a367055cc089f4cd2ec
2025-11-10 03:30:48 UTC to 2025-01-22 16:19:58 UTC

- Merge 3rd ed to main (rust-lang/book#4567)
- Fix typo in section 17.2 (rust-lang/book#4456)
- Chapter 19 from tech review (rust-lang/book#4446)
- Chapter 18 from tech review (rust-lang/book#4445)
- Chapter 16 from tech review (rust-lang/book#4438)
- WIP ch 17 edits after tech review (rust-lang/book#4319)
- Chapter 15 from tech review (rust-lang/book#4433)
- Chapter 14 from tech review (rust-lang/book#4423)
- Chapter 13 from tech review (rust-lang/book#4421)
- Chapter 12 from tech review (rust-lang/book#4410)
- Chapter 11 from tech review (rust-lang/book#4391)
- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)
- Chapter 6 from tech review (rust-lang/book#4370)
- Chapter 5 from tech review (rust-lang/book#4359)
- Chapter 4 from tech review (rust-lang/book#4358)
- Chapter 3 from tech review (rust-lang/book#4353)
- Ch01+ch02 after tech review (rust-lang/book#4329)
- Ch. 21: call out Chrome multiple-connections issue (rust-lang/book#4297)
- Ch. 16: refactor 16-6 to using listing component (rust-lang/book#4295)
- Ch. 01: Show how to work offline (rust-lang/book#4294)
- Ch. 07: Clarify sentences about `pub use` (rust-lang/book#4293)
- Ch. 02: Consistent ordering of `use` statements (rust-lang/book#4292)
- Anchors on listings (rust-lang/book#4271)
- Ch. 17: another tweak to how we phrase things about sections (rust-lang/book#4288)
- Ch. 20: correct listing number (rust-lang/book#4287)
- Ch. 10.3: clarify language detail (rust-lang/book#4284)
- Ch. 17: minor typos and link reference (rust-lang/book#4286)
- Ch. 9: correctly demonstrate privacy with module (rust-lang/book#4282)
- Ch. 18: correct discussion of delegation in `Post` methods (rust-lang/book#4281)
- Ch. 20: tell folks to see the Reference for more ABI info (rust-lang/book#4165)
- Ch 10.1 minor clarifications (rust-lang/book#4256)
- Clarified the misunderstanding b/w crates, module, items (rust-lang/book#4232)
- Ferris: always show, even when it’s small (rust-lang/book#4280)
- Ch. 17: mention `use std::pin::{Pin, pin};` on introduction (rust-lang/book#4279)
- Persist printing error, NOT ErrorKind (rust-lang/book#4259)
- Typo: "2" should be "2 seconds" (rust-lang/book#4263)
- Ch. 17: fix tiny example consistency issue (rust-lang/book#4270)
- Bump ring from 0.17.8 to 0.17.13 in /listings/ch17-async-await/listing-17-02 (rust-lang/book#4261)
- Bump ring from 0.17.8 to 0.17.14 in /packages/trpl (rust-lang/book#4273)
- 2024 Print Edition: updates to Word docs and more fixes to Markdown text (rust-lang/book#4272)
- Ch. 10: Make social media discussion generic. (rust-lang/book#4249)
- Another Ch. 17 -> 18 fix (rust-lang/book#4247)
- Ch. 05: further tweak to wording about `user1` availability (rust-lang/book#4246)
- Ch. 02: Fix rand version mistake (from testing) (rust-lang/book#4245)
- Ch. 19: Correct the discussion of `fn` type and closures (rust-lang/book#4244)
- Edition maintenance: scripting the updates for future work (rust-lang/book#4243)
- Ch. 17: fresh-eyes edits (rust-lang/book#4242)
- Ch. 17: drop lifetime not required in 2024 Edition (rust-lang/book#4212)
- Appendix B, Operators: Replace “member access” with “field access” and “method call”. (rust-lang/book#4240)
- Update to Rust 1.85 and 2024 Edition! (rust-lang/book#4241)
- Chapter 1: fix 'four things' now that spacing is not emphasized (rust-lang/book#4239)
- Fix typos in chapter 17 (rust-lang/book#4238)
- NoStarch backports (rust-lang/book#4224)
- Fix example for `cargo fix` (rust-lang/book#4226)
- Add missing word in ch17-04-streams.md (rust-lang/book#4218)
- Fix typo in ch5.3 and in CONTRIBUTING.md (rust-lang/book#4216)
- chore: reformat src with dprint (rust-lang/book#4211)
- Redirects: get rid of the weird gap in Ch. 20 sections! (rust-lang/book#4209)

## rust-lang/edition-guide

1 commits in 5c621253d8f2a5a4adb64a6365905db67dffe3a2..9cf5443d632673c4d41edad5e8ed8be86eeb3b8f
2025-11-15 21:51:11 UTC to 2025-11-15 21:51:11 UTC

- Link to 1.56.0 and 1.85.0 blog posts (rust-lang/edition-guide#380)

## rust-lang/nomicon

4 commits in 60f0b30d8ec1c9eb5c2582f2ec55f1094b0f8c42..0fe83ab28985b99aba36a1f0dbde3e08286fefda
2025-11-15 00:03:14 UTC to 2025-11-05 20:56:09 UTC

- Fix grammar in ffi.md (rust-lang/nomicon#510)
- Add CITATION.cff (rust-lang/nomicon#507)
- Use the newest Layout::array size checks for vec-alloc (rust-lang/nomicon#508)
- review comment: dropck analysis is *not* trivial (rust-lang/nomicon#498)

## rust-lang/reference

6 commits in e122eefff3fef362eb7e0c08fb7ffbf5f9461905..f9f1d2a4149f02582aec2f8fcdfa5b596193b4e2
2025-11-16 15:23:27 UTC to 2025-11-09 15:04:53 UTC

- add 'system' to variadic ABIs (rust-lang/reference#2069)
- Guarantee the binary representation of `isize` explicitly (rust-lang/reference#2064)
- Update `no_implicit_prelude` to use the attribute template (rust-lang/reference#1914)
- Update `no_std` to use the attribute template (rust-lang/reference#1913)
- const_eval.md: be more clear where link leads to (rust-lang/reference#2083)
- specify s390x target features (rust-lang/reference#1972)

## rust-lang/rust-by-example

1 commits in 160e6bbca70b0c01aa4de88d19db7fc5ff8447c3..f944161716230641605b5e3733e1c81f10047fd4
2025-11-05 12:46:38 UTC to 2025-11-05 12:46:38 UTC

- Revise `Path` type documentation for clarity (rust-lang/rust-by-example#1972)
2025-11-17 21:48:00 +01:00
Matthias Krüger 4c59f6d87f Rollup merge of #149030 - mkroening:doc-strict_provenance_lints, r=RalfJung
doc: fix `strict_provenance_lints` tracking issue link

This PR is a follow-up on https://github.com/rust-lang/rust/commit/56ee492a6e7a917b2b3f888e33dd52a13d3ecb64 and fixes the link to the `strict_provenance_lints` tracking issue.

I am not sure whether we should touch this line too:

https://github.com/rust-lang/rust/blob/66bc5a43e55eae14a2ec70b11004c88072fe7f02/compiler/rustc_lint_defs/src/builtin.rs#L2537

r? `@RalfJung`
2025-11-17 21:47:59 +01:00
Matthias Krüger c3af6292ec Rollup merge of #147077 - joboet:mov_kernel_copy_sys, r=ibraheemdev
std: move `kernel_copy` to `sys`

Part of rust-lang/rust#117276.

The current organisation of the `kernel_copy` mechanism used to specialise `io::copy` on Linux necessitated circular links between the `io::copy` module and the implementation in `sys::pal::unix::kernel_copy`, as well as presenting an exception to the tidy PAL rule that forbids OS-based `#[cfg]`s outside of `sys` and `os`.

This PR fixes this by moving `kernel_copy` to `sys` (as per rust-lang/rust#117276) and returning a `CopyState` from that function specifying whether `io::copy` should use its fallback. The `kernel_copy` function on other platforms just unconditionally returns `CopyState::Fallback`.
2025-11-17 21:47:58 +01:00
Jeremy Fitzhardinge 972498c728 Build with -Zannotate-moves by default
Build rustc and tools with -Zannotate-moves by default. Adds toml config
options to set the annotation size limit.

This has no measurable effect on output binary size or compile time.
2025-11-17 11:01:21 -08:00