about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-04-21Rollup merge of #140118 - tamird:cstr-cleanup, r=joboetChris Denton-12/+10
{B,C}Str: minor cleanup (hopefully) uncontroversial bits extracted from #139994.
2025-04-21Rollup merge of #140111 - jogru0:redundant_pattern, r=compiler-errorsChris Denton-2/+2
cleanup redundant pattern instances Just two small code cleanups.
2025-04-21Rollup merge of #140107 - tshepang:rdg-push, r=jieyouxuChris Denton-7/+8
rustc-dev-guide subtree update r? ``@ghost``
2025-04-21Rollup merge of #140076 - aDotInTheVoid:jsondocline, r=GuillaumeGomezChris Denton-1/+2
jsondocck: Require command is at start of line In one place we use `///``@``` instead of `//``@`.`` The test-runner allowed it, but it probably shouldn't. Ran into by ``@lolbinarycat`` in https://github.com/rust-lang/rust/pull/132748#issuecomment-2816469322: ``` error: unknown disambiguator `?(` ##[error] --> /checkout/tests/rustdoc-json/fns/return_type_alias.rs:3:25 | 3 | ///@ set foo = "$.index[?(``@.name=='Foo')].id"`` | ^^ | ``` Maybe it's also worth erroring on this like we added in #137103 r? ``@GuillaumeGomez``
2025-04-21Rollup merge of #140074 - aDotInTheVoid:auto-test, r=GuillaumeGomezChris Denton-2/+4
rustdoc-json: Improve test for auto-trait impls The TODO is fixable now due-to #138763. While I was here I realized there's probably a a few more things we should also test. r? ```@GuillaumeGomez```
2025-04-21Rollup merge of #140052 - GuillaumeGomez:fix-140026, r=nnethercoteChris Denton-1/+30
Fix error when an intra doc link is trying to resolve an empty associated item Fixes https://github.com/rust-lang/rust/issues/140026. Assigning ```@nnethercote``` since they're the one who wrote the initial change. I updated rustdoc code instead of compiler's because I think it makes more sense that the caller ensures on their side that the name they're looking for isn't empty. r? ```@nnethercote```
2025-04-21Rollup merge of #140047 - matthiaskrgr:clo, r=compiler-errorsChris Denton-7/+5
remove a couple clones
2025-04-21Rollup merge of #140036 - jieyouxu:ui-cleanup-4, r=compiler-errorsChris Denton-33/+76
Advent of `tests/ui` (misc cleanups and improvements) [4/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of #133895. ### Review advice - Best reviewed commit-by-commit. - I can squash commits before merge, commits are separate to make it easier to review.
2025-04-21Rollup merge of #139795 - jethrogb:jb/sgx-linkage-comments, r=joboetChris Denton-6/+14
Clarify why SGX code specifies linkage/symbol names for certain statics Specifying linkage/symbol name is solely to ensure a single instance between the `std` crate and its unit tests. Also update the symbol names as items have moved around a bit. The actual name isn't that important, it just needs to be unique. But for debugging it can be useful for it to point to the right place.
2025-04-21Rollup merge of #139711 - thaliaarchi:hermit-args, r=jhprattChris Denton-40/+9
Hermit: Unify `std::env::args` with Unix The only differences between these implementations of `std::env::args` are that Unix uses relaxed ordering, but Hermit uses acquire/release, and Unix truncates `argv` at the first null pointer, but Hermit doesn't. Since Hermit aims for Unix compatibility, unify it with Unix. The atomic orderings were established in https://github.com/rust-lang/rust/pull/74006 (cc `@euclio)` for Unix and https://github.com/rust-lang/rust/pull/100579 (cc `@joboet)` for Hermit and, before those, they used mutexes and non-atomic statics. I think the difference in orderings is simply from them being changed at different times. The commented explanation for using acquire/release for Hermit is “to broadcast writes by the OS”. I'm not experienced enough with atomics to accurately judge, but I think acquire/release is stronger than needed. Either way, they should match. Truncating at the first null pointer seems desirable, though I don't know whether it is necessary in practice on Hermit. cc `@mkroening` `@stlankes` for Hermit
2025-04-21Rollup merge of #134213 - folkertdev:stabilize-naked-functions, ↵Chris Denton-294/+165
r=tgross35,Amanieu,traviscross Stabilize `naked_functions` tracking issue: https://github.com/rust-lang/rust/issues/90957 request for stabilization on tracking issue: https://github.com/rust-lang/rust/issues/90957#issuecomment-2539270352 reference PR: https://github.com/rust-lang/reference/pull/1689 # Request for Stabilization Two years later, we're ready to try this again. Even though this issue is already marked as having passed FCP, given the amount of time that has passed and the changes in implementation strategy, we should follow the process again. ## Summary The `naked_functions` feature has two main parts: the `#[naked]` function attribute, and the `naked_asm!` macro. An example of a naked function: ```rust const THREE: usize = 3; #[naked] pub extern "sysv64" fn add_n(number: usize) -> usize { // SAFETY: the validity of the used registers // is guaranteed according to the "sysv64" ABI unsafe { core::arch::naked_asm!( "add rdi, {}", "mov rax, rdi", "ret", const THREE, ) } } ``` When the `#[naked]` attribute is applied to a function, the compiler won't emit a [function prologue](https://en.wikipedia.org/wiki/Function_prologue_and_epilogue) or epilogue when generating code for this function. This attribute is analogous to [`__attribute__((naked))`](https://developer.arm.com/documentation/100067/0608/Compiler-specific-Function--Variable--and-Type-Attributes/--attribute----naked---function-attribute) in C. The use of this feature allows the programmer to have precise control over the assembly that is generated for a given function. The body of a naked function must consist of a single `naked_asm!` invocation, a heavily restricted variant of the `asm!` macro: the only legal operands are `const` and `sym`, and the only legal options are `raw` and `att_syntax`. In lieu of specifying operands, the `naked_asm!` within a naked function relies on the function's calling convention to determine the validity of registers. ## Documentation The Rust Reference: https://github.com/rust-lang/reference/pull/1689 (Previous PR: https://github.com/rust-lang/reference/pull/1153) ## Tests * [tests/run-make/naked-symbol-visiblity](https://github.com/rust-lang/rust/tree/master/tests/codegen/naked-fn) verifies that `pub`, `#[no_mangle]` and `#[linkage = "..."]` work correctly for naked functions * [tests/codegen/naked-fn](https://github.com/rust-lang/rust/tree/master/tests/codegen/naked-fn) has tests for function alignment, use of generics, and validates the exact assembly output on linux, macos, windows and thumb * [tests/ui/asm/naked-*](https://github.com/rust-lang/rust/tree/master/tests/ui/asm) tests for incompatible attributes, generating errors around incorrect use of `naked_asm!`, etc ## Interaction with other (unstable) features ### [fn_align](https://github.com/rust-lang/rust/issues/82232) Combining `#[naked]` with `#[repr(align(N))]` works well, and is tested e.g. here - https://github.com/rust-lang/rust/blob/master/tests/codegen/naked-fn/aligned.rs - https://github.com/rust-lang/rust/blob/master/tests/codegen/naked-fn/min-function-alignment.rs It's tested extensively because we do need to explicitly support the `repr(align)` attribute (and make sure we e.g. don't mistake powers of two for number of bytes). ## History This feature was originally proposed in [RFC 1201](https://github.com/rust-lang/rfcs/pull/1201), filed on 2015-07-10 and accepted on 2016-03-21. Support for this feature was added in [#32410](https://github.com/rust-lang/rust/pull/32410), landing on 2016-03-23. Development languished for several years as it was realized that the semantics given in RFC 1201 were insufficiently specific. To address this, a minimal subset of naked functions was specified by [RFC 2972](https://github.com/rust-lang/rfcs/pull/2972), filed on 2020-08-07 and accepted on 2021-11-16. Prior to the acceptance of RFC 2972, all of the stricter behavior specified by RFC 2972 was implemented as a series of warn-by-default lints that would trigger on existing uses of the `naked` attribute; these lints became hard errors in [#93153](https://github.com/rust-lang/rust/pull/93153) on 2022-01-22. As a result, today RFC 2972 has completely superseded RFC 1201 in describing the semantics of the `naked` attribute. More recently, the `naked_asm!` macro was added to replace the earlier use of a heavily restricted `asm!` invocation. The `naked_asm!` name is clearer in error messages, and provides a place for documenting the specific requirements of inline assembly in naked functions. The implementation strategy was changed to emitting a global assembly block. In effect, an extern function ```rust extern "C" fn foo() { core::arch::naked_asm!("ret") } ``` is emitted as something similar to ```rust core::arch::global_asm!( "foo:", "ret" ); extern "C" { fn foo(); } ``` The codegen approach was chosen over the llvm naked function attribute because: - the rust compiler can guarantee the behavior (no sneaky additional instructions, no inlining, etc.) - behavior is the same on all backends (llvm, cranelift, gcc, etc) Finally, there is now an allow list of compatible attributes on naked functions, so that e.g. `#[inline]` is rejected with an error. The `#[target_feature]` attribute on naked functions was later made separately unstable, because implementing it is complex and we did not want to block naked functions themselves on how target features work on them. See also https://github.com/rust-lang/rust/issues/138568. relevant PRs for these recent changes - https://github.com/rust-lang/rust/pull/127853 - https://github.com/rust-lang/rust/pull/128651 - https://github.com/rust-lang/rust/pull/128004 - https://github.com/rust-lang/rust/pull/138570 - ### Various historical notes #### `noreturn` [RFC 2972](https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md) mentions that naked functions > must have a body which contains only a single asm!() statement which: > iii. must contain the noreturn option. Instead of `asm!`, the current implementation mandates that the body contain a single `naked_asm!` statement. The `naked_asm!` macro is a heavily restricted version of the `asm!` macro, making it easier to talk about and document the rules of assembly in naked functions and give dedicated error messages. For `naked_asm!`, the behavior of the `asm!`'s `noreturn` option is implicit. The `noreturn` option means that it is UB for control flow to fall through the end of the assembly block. With `asm!`, this option is usually used for blocks that diverge (and thus have no return and can be typed as `!`). With `naked_asm!`, the intent is different: usually naked funtions do return, but they must do so from within the assembly block. The `noreturn` option was used so that the compiler would not itself also insert a `ret` instruction at the very end. #### padding / `ud2` A `naked_asm!` block that violates the safety assumption that control flow must not fall through the end of the assembly block is UB. Because no return instruction is emitted, whatever bytes follow the naked function will be executed, resulting in truly undefined behavior. There has been discussion whether rustc should emit an invalid instruction (e.g. `ud2` on x86) after the `naked_asm!` block to at least fail early in the case of an invalid `naked_asm!`. It was however decided that it is more useful to guarantee that `#[naked]` functions NEVER contain any instructions besides those in the `naked_asm!` block. # unresolved questions None r? ``@Amanieu`` I've validated the tests on x86_64 and aarch64
2025-04-21Replace colon with parentheses, add missing periodTamir Duberstein-1/+1
2025-04-21cleanup redundant pattern instancesJonathan Gruner-2/+2
2025-04-21Auto merge of #139727 - rust-lang:cargo_update, r=Mark-Simulacrumbors-38/+38
Weekly `cargo update` Automation to keep dependencies in `Cargo.lock` current. The following is the output from `cargo update`: ```txt compiler & tools dependencies: Locking 11 packages to latest compatible versions Updating bstr v1.11.3 -> v1.12.0 Updating clap v4.5.35 -> v4.5.36 Updating clap_builder v4.5.35 -> v4.5.36 Updating crossbeam-channel v0.5.14 -> v0.5.15 Updating jiff v0.2.5 -> v0.2.6 Updating jiff-static v0.2.5 -> v0.2.6 Updating jsonpath-rust v1.0.0 -> v1.0.1 Updating linux-raw-sys v0.9.3 -> v0.9.4 Updating miniz_oxide v0.8.7 -> v0.8.8 Updating self_cell v1.1.0 -> v1.2.0 Updating winnow v0.7.4 -> v0.7.6 note: pass `--verbose` to see 38 unchanged dependencies behind latest library dependencies: Locking 1 package to latest compatible version Updating miniz_oxide v0.8.7 -> v0.8.8 note: pass `--verbose` to see 4 unchanged dependencies behind latest rustbook dependencies: Locking 9 packages to latest compatible versions Updating bstr v1.11.3 -> v1.12.0 Updating cc v1.2.18 -> v1.2.19 Updating clap v4.5.35 -> v4.5.36 Updating clap_builder v4.5.35 -> v4.5.36 Updating jiff v0.2.5 -> v0.2.6 Updating jiff-static v0.2.5 -> v0.2.6 Updating linux-raw-sys v0.9.3 -> v0.9.4 Updating miniz_oxide v0.8.7 -> v0.8.8 Updating winnow v0.7.4 -> v0.7.6 ```
2025-04-21Merge pull request #2349 from rust-lang/rustc-pullTshepang Mbambo-2492/+3929
Rustc pull update
2025-04-21Merge from rustcThe rustc-dev-guide Cronjob Bot-2491/+3928
2025-04-21Preparing for merge from rustcThe rustc-dev-guide Cronjob Bot-1/+1
2025-04-20Auto merge of #140079 - ChrisDenton:rollup-2h5cg94, r=ChrisDentonbors-598/+898
Rollup of 5 pull requests Successful merges: - #137953 (simd intrinsics with mask: accept unsigned integer masks, and fix some of the errors) - #139990 (transmutability: remove NFA intermediate representation) - #140044 (rustc-dev-guide subtree update) - #140051 (Switch exploit mitigations to mdbook footnotes) - #140054 (docs: fix typo change from inconstants to invariants) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-20remove a couple clonesMatthias Krüger-7/+5
2025-04-20Auto merge of #140083 - ChrisDenton:rollup-o0xjy0y, r=ChrisDentonbors-211/+185
Rollup of 5 pull requests Successful merges: - #138870 (Add target-specific NaN payloads for the missing tier 2 targets) - #139028 (Make target maintainers more easily pingable) - #140063 (Remove stray newline from post-merge report) - #140067 (Remove (now unused) #[rustc_macro_edition_2021] attribute) - #140068 (replace broken links armv7-rtems-eabihf.md) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-20Rollup merge of #140068 - detrina:master, r=NoratriebChris Denton-2/+2
replace broken links armv7-rtems-eabihf.md Hi team , i found broken link in `src/doc/rustc/src/platform-support/armv7-rtems-eabihf.md` and replace thanks
2025-04-20Rollup merge of #140067 - m-ou-se:remove-macro-2021-hack, r=UrgauChris Denton-40/+1
Remove (now unused) #[rustc_macro_edition_2021] attribute Now that https://github.com/rust-lang/rust/pull/139114 has been merged, we no longer need the temporary hack (`#[rustc_macro_edition_2021]`) that we introduced in https://github.com/rust-lang/rust/pull/138717. Time to remove it.
2025-04-20Rollup merge of #140063 - Kobzol:ci-report-fix-newline, r=jieyouxuChris Denton-1/+1
Remove stray newline from post-merge report [Oops](https://github.com/rust-lang/rust/pull/140043#issuecomment-2816999352) :) r? jieyouxu
2025-04-20Rollup merge of #139028 - Noratrieb:ping-pong, r=RalfJungChris Denton-165/+176
Make target maintainers more easily pingable Put them all on the same line with just their GitHub handles to make it very easy to copy and paste (with ctrl-shift-v!!!) the names. We have no use for email, so I removed all the emails, we don't care about people's full names either. This is a pretty big PR with lots of changes. I may have gotten one or two wrong, who knows. I went over it fairly aggressively, removing all information I deemed unnecessary. > [!Caution] > When copying these usernames, use **ctrl-shift-v** to avoid pasting them as links r? RalfJung you indirectly asked for this :) (anyone is welcome to review)
2025-04-20Rollup merge of #138870 - beetrees:tier-2-nans, r=RalfJungChris Denton-3/+5
Add target-specific NaN payloads for the missing tier 2 targets This PR adds target-specific NaN payloads for the remaining tier 2 targets: - `arm64ec`: This target is a mix of `x86_64` and `aarch64`, meaning as they both have no extra payloads `arm64ec` also has no extra payloads. - `loongarch64`: Per [LoongArch Reference Manual - Volume 1: Basic Architecture](https://github.com/loongson/LoongArch-Documentation/releases/download/2023.04.20/LoongArch-Vol1-v1.10-EN.pdf) section 3.1.1.3, LoongArch does quieting NaN propagation with the Rust preferred NaN as its default NaN, meaning it has no extra payloads. - `nvptx64`: Per [PTX ISA documentation](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions) section 9.7.3 (and section 9.7.4 for `f16`), all payloads are possible. The documentation explicitly states that `f16` and `f32` operations result in an unspecified NaN payload, while for `f64` it states "NaN payloads are supported" without specifying how or what payload will be generated if there are no input NaNs. - `powerpc` and `powerpc64`: Per [Power Instruction Set Architecture](https://files.openpower.foundation/s/9izgC5Rogi5Ywmm/download/OPF_PowerISA_v3.1C.pdf) Book I section 4.3.2, PowerPC does quieting NaN propagation with the Rust preferred NaN being generated if no there are no input NaNs, meaning it has no extra payloads. - `s390x`: Per [IBM z/Architecture Principles of Operation](https://www.vm.ibm.com/library/other/22783213.pdf#page=965) page 9-3, s390x does quieting NaN propagation with the Rust's preferred NaN as its default NaN, meaning it has no extra payloads. Tracking issue: #128288 cc ``@RalfJung`` ``@rustbot`` label +T-lang Also cc relevant target maintainers of tier 2 targets: - `arm64ec`: ``@dpaoliello`` - `loongarch64`: ``@heiher`` ``@xiangzhai`` ``@zhaixiaojuan`` ``@xen0n`` - `nvptx64`: ``@RDambrosio016`` ``@kjetilkjeka`` - `powerpc`: the only documented maintainer is ``@BKPepe`` for the tier 3 `powerpc-unknown-linux-muslspe`. - `powerpc64`: ``@daltenty`` ``@gilamn5tr`` ``@Gelbpunkt`` ``@famfo`` ``@neuschaefer`` - `s390x`: ``@uweigand`` ``@cuviper``
2025-04-20Make target maintainers more easily pingableNoratrieb-165/+176
Put them all on the same line with just their GitHub handles to make it very easy to copy and paste (with ctrl-shift-v!!!) the names. We have no use for email, so I removed all the emails, we don't care about people's full names either. Co-authored-by: Thalia Archibald <thalia@archibald.dev>
2025-04-20Rollup merge of #140054 - c-git:patch-1, r=joboetChris Denton-1/+1
docs: fix typo change from inconstants to invariants
2025-04-20Rollup merge of #140051 - ehuss:exploit-footnotes, r=jieyouxuChris Denton-43/+22
Switch exploit mitigations to mdbook footnotes This updates the exploit mitigations chapter in the rustc book to use the footnote feature of mdbook instead of manually implementing footnotes with HTML.
2025-04-20Rollup merge of #140044 - tshepang:rdg-push, r=jieyouxuChris Denton-111/+517
rustc-dev-guide subtree update r? ``@ghost``
2025-04-20Rollup merge of #139990 - jswrenn:no-nfas, r=tmiaskoChris Denton-295/+239
transmutability: remove NFA intermediate representation Prior to this commit, the transmutability analysis used an intermediate NFA representation of type layout. We then determinized this representation into a DFA, upon which we ran the core transmutability analysis. Unfortunately, determinizing NFAs is expensive. In this commit, we avoid NFAs entirely by observing that Rust `union`s are the only source of nondeterminism and that it is comparatively cheap to compute the DFA union of DFAs. We also implement Graphviz DOT debug formatting of DFAs. Fixes rust-lang/project-safe-transmute#23 Fixes rust-lang/project-safe-transmute#24 r? ``@compiler-errors``
2025-04-20Rollup merge of #137953 - RalfJung:simd-intrinsic-masks, r=WaffleLapkinChris Denton-148/+119
simd intrinsics with mask: accept unsigned integer masks, and fix some of the errors It's not clear at all why the mask would have to be signed, it is anyway interpreted bitwise. The backend should just make sure that works no matter the surface-level type; our LLVM backend already does this correctly. The note of "the mask may be widened, which only has the correct behavior for signed integers" explains... nothing? Why can't the code do the widening correctly? If necessary, just cast to the signed type first... Also while we are at it, fix the errors. For simd_masked_load/store, the errors talked about the "third argument" but they meant the first argument (the mask is the first argument there). They also used the wrong type for `expected_element`. I have extremely low confidence in the GCC part of this PR. See [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/257879-project-portable-simd/topic/On.20the.20sign.20of.20masks)
2025-04-20jsondocck: Require command is at start of lineAlona Enraght-Moony-1/+2
2025-04-20rustdoc-json: Improve test for auto-trait implsAlona Enraght-Moony-2/+4
2025-04-20simd intrinsics with mask: accept unsigned integer masksRalf Jung-148/+119
2025-04-20Update links armv7-rtems-eabihf.mdDevkuni-2/+2
2025-04-20stabilize `naked_functions`Folkert de Vries-294/+165
2025-04-20Remove #[rustc_macro_edition_2021].Mara Bos-40/+1
It was only temporarily used by pin!(), which no longer needs it.
2025-04-20Remove stray newline from post-merge reportJakub Beránek-1/+1
2025-04-20transmutability: remove NFA intermediate representationJack Wrenn-295/+239
Prior to this commit, the transmutability analysis used an intermediate NFA representation of type layout. We then determinized this representation into a DFA, upon which we ran the core transmutability analysis. Unfortunately, determinizing NFAs is expensive. In this commit, we avoid NFAs entirely by observing that Rust `union`s are the only source of nondeterminism and that it is comparatively cheap to compute the DFA union of DFAs. We also implement Graphviz DOT debug formatting of DFAs. Fixes rust-lang/project-safe-transmute#23 Fixes rust-lang/project-safe-transmute#24
2025-04-20Auto merge of #140043 - ChrisDenton:rollup-vwf0s9j, r=ChrisDentonbors-1576/+2813
Rollup of 8 pull requests Successful merges: - #138934 (support config extensions) - #139091 (Rewrite on_unimplemented format string parser.) - #139753 (Make `#[naked]` an unsafe attribute) - #139762 (Don't assemble non-env/bound candidates if projection is rigid) - #139834 (Don't canonicalize crate paths) - #139868 (Move `pal::env` to `std::sys::env_consts`) - #139978 (Add citool command for generating a test dashboard) - #139995 (Clean UI tests 4 of n) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-19docs: fix typo change from inconstants to invariantsOnè-1/+1
2025-04-19Auto merge of #140053 - ChrisDenton:rollup-tt00skl, r=ChrisDentonbors-149/+363
Rollup of 7 pull requests Successful merges: - #139042 (Do not remove trivial `SwitchInt` in analysis MIR) - #139533 (add next_index to Enumerate) - #139843 (Setup editor file associations for non-rs extensions) - #140000 (skip llvm-config in autodiff check builds, when its unavailable) - #140008 (Improve `clean_maybe_renamed_item` function code a bit) - #140024 (Remove early exits from JumpThreading.) - #140039 (Add option for stable backport poll) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-19Rollup merge of #140039 - apiraino:add-option-for-stable-backport-poll, ↵Chris Denton-0/+1
r=aDotInTheVoid Add option for stable backport poll When creating polls on Zulip about stable backport ("Do we approve the backport of `#12345`"?), stable backports should have the option of "approving, but only is a dot release is planned" (this is a hint to t-release about how the team think important - or not - is backporting some patch). Discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/stable-nominated.3A.20.23139328/near/510037866)[#t-rustdoc > stable-nominated: #139328 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/stable-nominated.3A.20.23139328/near/510037866) r? `@aDotInTheVoid` (feel free to adjust the wording!)
2025-04-19Rollup merge of #140024 - cjgillot:continue-jumping, r=compiler-errorsChris Denton-71/+64
Remove early exits from JumpThreading. This removes early exits from https://github.com/rust-lang/rust/pull/131203 as I asked during review. The correctness of the backtracking is `mutated_statement` clearing all relevant conditions. If `process_statement` fails to insert a new condition, for instance by const-eval failure, `mutated_statement` still removes the obsolete conditions from the state. r? `@compiler-errors`
2025-04-19Rollup merge of #140008 - GuillaumeGomez:cleanup-clean_maybe_renamed_item, ↵Chris Denton-14/+33
r=nnethercote Improve `clean_maybe_renamed_item` function code a bit Follow-up of #139846. This is what I tried to say in there: the `name` variable can be unwrapped in most cases so better do it directly once and for all if possible and move the cases where it's not possible above. r? `@nnethercote`
2025-04-19Rollup merge of #140000 - EnzymeAD:autodiff-check-builds, r=onur-ozkanChris Denton-2/+1
skip llvm-config in autodiff check builds, when its unavailable As you suggested, this indeed fixes `./x.py check` builds when autodiff is enabled. r? ```@onur-ozkan``` closes #139936 Tracking: - https://github.com/rust-lang/rust/issues/124509
2025-04-19Rollup merge of #139843 - thaliaarchi:editor-file-associations, ↵Chris Denton-11/+23
r=Mark-Simulacrum Setup editor file associations for non-rs extensions .gitattributes lists `*.fixed`, `*.pp`, and `*.mir` as file extensions which should be treated as Rust source code. Do the same for VS Code and Zed. This only does syntax highlighting, which is appropriate, as MIR isn't really Rust code. At the same time, consistently order `rust-analyzer.linkedProjects` between editors. For some reason, Eglot didn't include `library/Cargo.toml`. I have tested this with VS Code and Zed. I have not implemented it for Emacs/Eglot or Helix.
2025-04-19Rollup merge of #139533 - jogru0:130711, r=Mark-SimulacrumChris Denton-0/+44
add next_index to Enumerate Proposal: https://github.com/rust-lang/libs-team/issues/435 Tracking Issue: #130711 This basically just reopens #130682 but squashed and with the new function and the feature gate renamed to `next_index.` There are two questions I have already: - Shouldn't we add test coverage for that? I'm happy to provide some, but I might need a pointer to where these test would be. - Maybe I could actually also add a doctest? - For now, I just renamed the feature name in the unstable attribute to `next_index`, as well, so it matches the new name of the function. Is that okay? And can I just do that and use any string, or is there a sealed list of features defined somewhere where I also need to change the name?
2025-04-19Rollup merge of #139042 - compiler-errors:do-not-optimize-switchint, r=saethlinChris Denton-51/+197
Do not remove trivial `SwitchInt` in analysis MIR This PR ensures that we don't prematurely remove trivial `SwitchInt` terminators which affects both the borrow-checking and runtime semantics (i.e. UB) of the code. Previously the `SimplifyCfg` optimization was removing `SwitchInt` terminators when they was "trivial", i.e. when all arms branched to the same basic block, even if that `SwitchInt` terminator had the side-effect of reading an operand which (for example) may not be initialized or may point to an invalid place in memory. This behavior is unlike all other optimizations, which are only applied after "analysis" (i.e. borrow-checking) is finished, and which Miri disables to make sure the compiler doesn't silently remove UB. Fixing this code "breaks" (i.e. unmasks) code that used to borrow-check but no longer does, like: ```rust fn foo() { let x; let (0 | _) = x; } ``` This match expression should perform a read because `_` does not shadow the `0` literal pattern, and the compiler should have to read the match scrutinee to compare it to 0. I've checked that this behavior does not actually manifest in practice via a crater run which came back clean: https://github.com/rust-lang/rust/pull/139042#issuecomment-2767436367 As a side-note, it may be tempting to suggest that this is actually a good thing or that we should preserve this behavior. If we wanted to make this work (i.e. trivially optimize out reads from matches that are redundant like `0 | _`), then we should be enabling this behavior *after* fixing this. However, I think it's kinda unprincipled, and for example other variations of the code don't even work today, e.g.: ```rust fn foo() { let x; let (0.. | _) = x; } ```
2025-04-19Switch exploit mitigations to mdbook footnotesEric Huss-43/+22
This updates the exploit mitigations chapter in the rustc book to use the footnote feature of mdbook instead of manually implementing footnotes with HTML.