about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-09-30Auto merge of #147143 - estebank:verbose-ret-type, r=fee1-deadbors-2/+2
Make replacement suggestion `_` in type verbose ``` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/in-signature.rs:6:21 | LL | fn arr_fn() -> [u8; _] { | ^ not allowed in type signatures | help: replace with the correct return type | LL - fn arr_fn() -> [u8; _] { LL + fn arr_fn() -> [u8; 3] { | ```
2025-09-29Rollup merge of #147152 - lcnr:instantiate-pre-sized-check, r=BoxyUwUJacob Pratt-131/+95
builtin `Fn`-trait impls: instantiate binder before the return type `Sized` check fixes - https://github.com/rust-lang/trait-system-refactor-initiative/issues/220 - https://github.com/rust-lang/trait-system-refactor-initiative/issues/204 r? `@BoxyUwU`
2025-09-29Rollup merge of #146457 - alexcrichton:wasm-no-exn-instructions, r=bjorn3Jacob Pratt-8/+30
Skip cleanups on unsupported targets This commit is an update to the `AbortUnwindingCalls` MIR pass in the compiler. Specifically a new boolean is added for "can this target possibly unwind" and if that's `false` then terminators are all adjusted to be unreachable/not present. The end result is that this fixes rust-lang/rust#140293 for wasm targets. The motivation for this PR is that currently on WebAssembly targets the usage of the `C-unwind` ABI can lead LLVM to either (a) emit exception-handling instructions or (b) hit a LLVM-ICE-style codegen error. WebAssembly as a base instruction set does not support unwinding at all, and a later proposal to WebAssembly, the exception-handling proposal, was what enabled this. This means that the current intent of WebAssembly targets is that they maintain the baseline of "don't emit exception-handling instructions unless enabled". The commit here is intended to restore this behavior by skipping these instructions even when `C-unwind` is present. Exception-handling is a relatively tricky and also murky topic in WebAssembly, however. There are two sets of instructions LLVM can emit for WebAssembly exceptions, Rust's Emscripten target supports exceptions, WASI targets do not, the LLVM flags to enable this are not always obvious, and additionally this all touches on "changing exception-handling behavior should be a target-level concern, not a feature". Effectively WebAssembly's exception-handling integration into Rust is not finalized at this time. The best idea at this time is that a parallel set of targets will eventually be added which support exceptions, but it's not clear if/when to do this. In the meantime the goal is to keep existing targets working while still enabling experimentation with exception-handling with `-Zbuild-std` and various permutations of LLVM flags. To that extent this commit does not blanket disable these landing pads and cleanup routines for WebAssembly but instead checks to see if panic=unwind is enabled or if `+exception-handling` is enabled. Tests are updated here as well to account for this where, by default, using a `C-unwind` ABI won't affect Rust codegen at all. If `+exception-handling` is enabled, however, then Rust codegen will look like native platforms where exceptions are caught and the program aborts. More-or-less I've done my best to keep exceptions working on wasm where it's possible to have them work, but turned them off where they're not supposed to be emitted. Closes rust-lang/rust#140293
2025-09-29Rollup merge of #147150 - nikic:alloc-shim-attributes, r=bjorn3Matthias Krüger-4/+26
Emit allocator attributes for allocator shim This emits the same attributes we place on allocator declarations on the definitions in the allocator shim as well. This complements https://github.com/rust-lang/rust/pull/146766, which added the attribute for `#[global_allocator]` definitions. Emitting the attributes on the definitions ensures that they cannot be lost of the allocator shim participates in LTO. See https://github.com/rust-lang/rust/issues/145995 for context, though that one was about `#[global_allocator]`. I'm not sure whether this can occur with the allocator shim as well or not, but better safe than sorry. I'm not sure whether there is any good way to test this, as the allocator shim is not part of `--emit=llvm-ir`. I've verified this locally by inspecting the bitcode produced by `-C save-temps`. r? ``@bjorn3``
2025-09-29Rollup merge of #147131 - cjgillot:patch-branches, r=davidtwcoMatthias Krüger-12/+37
Use MirPatch in simplify_branches. This allows to avoid clearing the CFG cache if we don't perform any change. r? ``@ghost`` for perf
2025-09-29Rollup merge of #147040 - joshtriplett:mbe-fix-comments, r=petrochenkovMatthias Krüger-7/+4
mbe: macro_check: Fix function comments referencing non-existent parameters Several functions had comments referencing a non-existent `valid` parameter. Remove those. The `guar` parameter that handles errors is already documented. In the process, remove another duplicate reference to an already-documented parameter (`binders`).
2025-09-29Auto merge of #146376 - durin42:dwo-specify-path, r=davidtwcobors-1/+15
debuginfo: add an unstable flag to write split DWARF to an explicit directory Bazel requires knowledge of outputs from actions at analysis time, including file or directory name. In order to work around the lack of predictable output name for dwo files, we group the dwo files in a subdirectory of --out-dir as a post-processing step before returning control to bazel. Unfortunately some debugging workflows rely on directly opening the dwo file rather than loading the merged dwp file, and our trick of moving the files breaks those users. We can't just hardlink the file or copy it, because with remote build execution we wouldn't end up with the un-moved file copied back to the developer's workstation. As a fix, we add this unstable flag that causes dwo files to be written to a build-system-controllable location, which then lets bazel hoover up the dwo files, but the objects also have the correct path for the dwo files. r? `@davidtwco`
2025-09-29cleanup `try_evaluate_added_goals`lcnr-14/+5
2025-09-29Fn-trait goals, eagerly instantiate binderlcnr-117/+90
to avoid overflow from proving `for<'a> opaque<'a>: Sized`
2025-09-29Auto merge of #147151 - Zalathar:rollup-w81rn0j, r=Zalatharbors-50/+59
Rollup of 5 pull requests Successful merges: - rust-lang/rust#146653 (improve diagnostics for empty attributes) - rust-lang/rust#146987 (impl Ord for params and use unstable sort) - rust-lang/rust#147101 (Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library ) - rust-lang/rust#147123 (Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`) - rust-lang/rust#147149 (add joboet to library review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-29Rollup merge of #147123 - DJMcNab:doc_cfg_merge_version, r=fmeaseStuart Cook-2/+2
Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide` Tracking issue: https://github.com/rust-lang/rust/issues/43781 The `doc_auto_cfg` and `doc_cfg_hide` features were removed in a recent nightly (by https://github.com/rust-lang/rust/pull/138907). I believe that the rustc version numbers at which the features were declared to be removed were incorrect, however, and should both be "1.92" (±1). As evidence in favour of this, the error we get from using this was: ```text error[E0557]: feature has been removed --> src/lib.rs:22:29 | 22 | #![cfg_attr(docsrs, feature(doc_auto_cfg))] | ^^^^^^^^^^^^ feature has been removed | = note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/138907> for more information = note: merged into `doc_cfg` ``` Note especially the "removed in 1.58" claim. Further evidence is found in the comment further up this file: https://github.com/rust-lang/rust/blob/4ffeda10e10d4fa0c8edbd0dd9642d8ae7d3e66e/compiler/rustc_feature/src/removed.rs#L49-L53 I've chosen 1.92 as that was the milestone which https://github.com/rust-lang/rust/pull/138907 was added to. cc `@GuillaumeGomez`
2025-09-29Rollup merge of #147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmannStuart Cook-31/+17
Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library Now that rust-lang/rust#137122 has landed, we can replace stuff that looks like: ```rust let a: &[T]; let b: &[T]; let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b) ``` with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path. Also dogfooded `Iterator::eq_by` (cc rust-lang/rust#64295 ) while I'm at it. First commit (4d1b6fad230f8a5ccceccc7562eadc4ea50059da) should be very straightforward to review, second one (049a4606cb3906787aedf508ee8eea09c2bb3b9a) is slightly more creative, but IMHO a nice cleanup.
2025-09-29Rollup merge of #146987 - hkBst:sort-params-1, r=nnethercoteStuart Cook-2/+2
impl Ord for params and use unstable sort AFAICT we are only sorting to find duplicates, so unstable sort should work fine, and maybe is a tiny bit faster?
2025-09-29Rollup merge of #146653 - jdonszelmann:empty-attr-diags, r=nnethercoteStuart Cook-15/+38
improve diagnostics for empty attributes Adds a note about them not having any effect. This was previously done for `feature` attributes but no other attributes. In [converting the `feature` parser](https://github.com/rust-lang/rust/pull/146652) I removed that note. This PR adds it back in and makes it so all attributes benefit from it. Not blocked on rust-lang/rust#146652, either can merge first
2025-09-29Emit allocator attributes for allocator shimNikita Popov-4/+26
This emits the same attributes we place on allocator declarations (and allocator definitions using `#[global_allocator]`) on the definitions in the allocator shim as well, making sure that the attributes are not lost if the allocator shim participates in LTO.
2025-09-29Fix removed version of `doc_auto_cfg`, `doc_cfg_hide`Daniel McNab-2/+2
2025-09-29Auto merge of #147145 - Zalathar:rollup-s7kcs3w, r=Zalatharbors-176/+169
Rollup of 3 pull requests Successful merges: - rust-lang/rust#147100 (tests: Remove ignore-android directive for fixed issue) - rust-lang/rust#147116 (compiler: remove AbiAlign inside TargetDataLayout) - rust-lang/rust#147134 (remove explicit deref of AbiAlign for most methods) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-29Rollup merge of #147134 - workingjubilee:remove-explicit-abialign-deref, ↵Stuart Cook-56/+54
r=Zalathar remove explicit deref of AbiAlign for most methods Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
2025-09-29Rollup merge of #147116 - workingjubilee:remove-tdl-abialign, r=ZalatharStuart Cook-120/+115
compiler: remove AbiAlign inside TargetDataLayout AbiAlign is a thin wrapper around Align, extant mostly because we used to track a separate quasi-notion of alignment that was never a real notion of alignment and removing all of it at once was too churny. This PR maintains AbiAlign usage in public API and most of the compiler, but direct access of these fields for TargetDataLayout is now in terms of Align only.
2025-09-29Use `Iterator::eq` and (dogfood) `eq_by` in compiler and libraryYotam Ofek-31/+17
2025-09-29Make replacement suggestion `_` in type verboseEsteban Küber-2/+2
``` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/in-signature.rs:6:21 | LL | fn arr_fn() -> [u8; _] { | ^ not allowed in type signatures | help: replace with the correct return type | LL - fn arr_fn() -> [u8; _] { LL + fn arr_fn() -> [u8; 3] { | ```
2025-09-29Rollup merge of #147127 - antoyo:fix/gcc-linker-plugin, r=bjorn3Stuart Cook-4/+47
Add a leading dash to linker plugin arguments in the gcc codegen Fix rust-lang/rust#130583 r? ``@bjorn3``
2025-09-29Rollup merge of #147092 - cjgillot:late-validate-mir, r=compiler-errorsStuart Cook-12/+14
Do not compute optimized MIR if code does not type-check. Since https://github.com/rust-lang/rust/pull/128612, we compute optimized MIR when `-Zvalidate-mir` is present. This is done as part of required analyses, even if type-checking fails. This causes ICEs, as most of the mir-opt pipeline expects well-formed code. Fixes rust-lang/rust#129095 Fixes rust-lang/rust#134174 Fixes rust-lang/rust#134654 Fixes rust-lang/rust#135570 Fixes rust-lang/rust#136381 Fixes rust-lang/rust#137468 Fixes rust-lang/rust#144491 Fixes rust-lang/rust#147011 This does not fix issue rust-lang/rust#137190, as it ICEs without `-Zvalidate-mir`. r? ``@compiler-errors``
2025-09-29Rollup merge of #133477 - estebank:issue-133343, r=davidtwcoStuart Cook-33/+105
Detect tuple structs that are unconstructable due to re-export When a tuple-struct is re-exported that has inaccessible fields at the `use` scope, the type's constructor cannot be accessed through that re-export. We now account for this case and extend the resulting resolution error. We also check if the constructor would be accessible directly, not through the re-export, and if so, we suggest using the full path instead. ``` error[E0423]: cannot initialize a tuple struct which contains private fields --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:33 | LL | let crate::Foo(x) = crate::Foo(42); | ^^^^^^^^^^ | note: the type is accessed through this re-export, but the type's constructor is not visible in this import's scope due to private fields --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:3:9 | LL | pub use my_mod::Foo; | ^^^^^^^^^^^ help: the type can be constructed directly, because its fields are available from the current scope | LL | let crate::Foo(x) = crate::my_mod::Foo(42); | ~~~~~~~~~~~~~~~~~~ ``` Fix #133343.
2025-09-28remove explicit deref of AbiAlign for most methodsJubilee Young-56/+54
Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
2025-09-28Detect unconstructable re-exported tuple structsEsteban Küber-33/+105
When a tuple-struct is re-exported that has inaccessible fields at the `use` scope, the type's constructor cannot be accessed through that re-export. We now account for this case and extend the resulting resolution error. We also check if the constructor would be accessible directly, not through the re-export, and if so, we suggest using the full path instead. ``` error[E0423]: cannot initialize a tuple struct which contains private fields --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:33 | LL | let crate::Foo(x) = crate::Foo(42); | ^^^^^^^^^^ | note: the type is accessed through this re-export, but the type's constructor is not visible in this import's scope due to private fields --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:3:9 | LL | pub use my_mod::Foo; | ^^^^^^^^^^^ help: the type can be constructed directly, because its fields are available from the current scope | LL | let crate::Foo(x) = crate::my_mod::Foo(42); | ~~~~~~~~~~~~~~~~~~ ``` Fix #133343.
2025-09-28Use MirPatch in simplify_branches.Camille Gillot-12/+37
2025-09-28Add a leading dash to linker plugin arguments in the gcc codegenAntoni Boucher-4/+47
2025-09-28Rollup merge of #147113 - heiher:src-analysis-lsx, r=lqdMatthias Krüger-3/+107
Reland "Add LSX accelerated implementation for source file analysis" This patch introduces an LSX-optimized version of `analyze_source_file` for the `loongarch64` target. Similar to existing SSE2 implementation for x86, this version: - Processes 16-byte chunks at a time using LSX vector intrinsics. - Quickly identifies newlines in ASCII-only chunks. - Falls back to the generic implementation when multi-byte UTF-8 characters are detected or in the tail portion. Reland rust-lang/rust#145963 r? ``@lqd``
2025-09-28Rollup merge of #144197 - KMJ-007:type-tree, r=ZuseZ4Matthias Krüger-13/+618
TypeTree support in autodiff # TypeTrees for Autodiff ## What are TypeTrees? Memory layout descriptors for Enzyme. Tell Enzyme exactly how types are structured in memory so it can compute derivatives efficiently. ## Structure ```rust TypeTree(Vec<Type>) Type { offset: isize, // byte offset (-1 = everywhere) size: usize, // size in bytes kind: Kind, // Float, Integer, Pointer, etc. child: TypeTree // nested structure } ``` ## Example: `fn compute(x: &f32, data: &[f32]) -> f32` **Input 0: `x: &f32`** ```rust TypeTree(vec![Type { offset: -1, size: 8, kind: Pointer, child: TypeTree(vec![Type { offset: -1, size: 4, kind: Float, child: TypeTree::new() }]) }]) ``` **Input 1: `data: &[f32]`** ```rust TypeTree(vec![Type { offset: -1, size: 8, kind: Pointer, child: TypeTree(vec![Type { offset: -1, size: 4, kind: Float, // -1 = all elements child: TypeTree::new() }]) }]) ``` **Output: `f32`** ```rust TypeTree(vec![Type { offset: -1, size: 4, kind: Float, child: TypeTree::new() }]) ``` ## Why Needed? - Enzyme can't deduce complex type layouts from LLVM IR - Prevents slow memory pattern analysis - Enables correct derivative computation for nested structures - Tells Enzyme which bytes are differentiable vs metadata ## What Enzyme Does With This Information: Without TypeTrees (current state): ```llvm ; Enzyme sees generic LLVM IR: define float ``@distance(ptr*`` %p1, ptr* %p2) { ; Has to guess what these pointers point to ; Slow analysis of all memory operations ; May miss optimization opportunities } ``` With TypeTrees (our implementation): ```llvm define "enzyme_type"="{[]:Float@float}" float ``@distance(`` ptr "enzyme_type"="{[]:Pointer}" %p1, ptr "enzyme_type"="{[]:Pointer}" %p2 ) { ; Enzyme knows exact type layout ; Can generate efficient derivative code directly } ``` # TypeTrees - Offset and -1 Explained ## Type Structure ```rust Type { offset: isize, // WHERE this type starts size: usize, // HOW BIG this type is kind: Kind, // WHAT KIND of data (Float, Int, Pointer) child: TypeTree // WHAT'S INSIDE (for pointers/containers) } ``` ## Offset Values ### Regular Offset (0, 4, 8, etc.) **Specific byte position within a structure** ```rust struct Point { x: f32, // offset 0, size 4 y: f32, // offset 4, size 4 id: i32, // offset 8, size 4 } ``` TypeTree for `&Point` (internal representation): ```rust TypeTree(vec![ Type { offset: 0, size: 4, kind: Float }, // x at byte 0 Type { offset: 4, size: 4, kind: Float }, // y at byte 4 Type { offset: 8, size: 4, kind: Integer } // id at byte 8 ]) ``` Generates LLVM: ```llvm "enzyme_type"="{[]:Float@float}" ``` ### Offset -1 (Special: "Everywhere") **Means "this pattern repeats for ALL elements"** #### Example 1: Array `[f32; 100]` ```rust TypeTree(vec![Type { offset: -1, // ALL positions size: 4, // each f32 is 4 bytes kind: Float, // every element is float }]) ``` Instead of listing 100 separate Types with offsets `0,4,8,12...396` #### Example 2: Slice `&[i32]` ```rust // Pointer to slice data TypeTree(vec![Type { offset: -1, size: 8, kind: Pointer, child: TypeTree(vec![Type { offset: -1, // ALL slice elements size: 4, // each i32 is 4 bytes kind: Integer }]) }]) ``` #### Example 3: Mixed Structure ```rust struct Container { header: i64, // offset 0 data: [f32; 1000], // offset 8, but elements use -1 } ``` ```rust TypeTree(vec![ Type { offset: 0, size: 8, kind: Integer }, // header Type { offset: 8, size: 4000, kind: Pointer, child: TypeTree(vec![Type { offset: -1, size: 4, kind: Float // ALL array elements }]) } ]) ```
2025-09-28Rollup merge of #141469 - Kivooeo:remove-usnsafegate, r=compiler-errorsMatthias Krüger-0/+15
Allow `&raw [mut | const]` for union field in safe code fixes rust-lang/rust#141264 r? ``@Veykril`` Unresolved questions: - [x] Any edge cases? - [x] How this works with rust-analyzer (because all I've did is prevent compiler from emitting error in `&raw` context) (rust-lang/rust-analyzer#19867) - [x] Should we allow `addr_of!` and `addr_of_mut!` as well? In current version they both (`&raw` and `addr_of!`) are allowed (They are the same) - [x] Is chain of union fields is a safe? (Yes)
2025-09-28Do not validate MIR if code does not type-check.Camille Gillot-12/+14
2025-09-28Rollup merge of #147066 - SimonSapin:macro_attr-tracking, r=lqdMatthias Krüger-1/+1
Fix tracking issue number for feature(macro_attr) The ability to define an attribute macro with `macro_rules!` is tracked at https://github.com/rust-lang/rust/issues/143547, not https://github.com/rust-lang/rust/issues/83527
2025-09-28Rollup merge of #147061 - lcnr:provisional-cache-woops, r=BoxyUwUMatthias Krüger-56/+118
fix rebasing cycle heads when not reaching a fixpoint fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/232 annoyingly subtle, imagine the following proof tree - A (no cycle head usages, final result Y) - *ignored* B (depends on A with provisional result X) - A (cycle, provisional result X) - B (using the cache entry here incorrectly assumes A has final result X) r? ``@BoxyUwU``
2025-09-28Rollup merge of #146763 - Zalathar:di-builder, r=jdonszelmannMatthias Krüger-133/+102
cg_llvm: Replace some DIBuilder wrappers with LLVM-C API bindings (part 5) - Part of rust-lang/rust#134001 - Follow-up to rust-lang/rust#146673 --- This is another batch of LLVMDIBuilder binding migrations, replacing some our own LLVMRust bindings with bindings to upstream LLVM-C APIs. Some of these are a little more complex than most of the previous migrations, because they split one LLVMRust binding into multiple LLVM bindings, but nothing too fancy. This appears to be the last of the low-hanging fruit. As noted in https://github.com/rust-lang/rust/issues/134001#issuecomment-2524979268, the remaining bindings are difficult or impossible to migrate at present.
2025-09-28Rollup merge of #146745 - helldawg:master, r=workingjubileeMatthias Krüger-4/+4
Clarified error note for usize range matching Fixes rust-lang/rust#146476 This is kinda rough, but it gets the point across a little better and stays short.
2025-09-27compiler: remove AbiAlign inside TargetDataLayoutJubilee Young-120/+115
This maintains AbiAlign usage in public API and most of the compiler, but direct access of these fields is now in terms of Align only.
2025-09-28Add LSX accelerated implementation for source file analysisWANG Rui-3/+107
This patch introduces an LSX-optimized version of `analyze_source_file` for the `loongarch64` target. Similar to existing SSE2 implementation for x86, this version: - Processes 16-byte chunks at a time using LSX vector intrinsics. - Quickly identifies newlines in ASCII-only chunks. - Falls back to the generic implementation when multi-byte UTF-8 characters are detected or in the tail portion.
2025-09-27Rollup merge of #147075 - Lysxia:no-panic-def-path-hash, r=petrochenkovMatthias Krüger-9/+10
Make `def_path_hash_to_def_id` not panic when passed an invalid hash I'm using this function in a third-party application (Creusot) to access private items (by reverse engineering their hash). This works in the happy path, but it panics when an item does not exist. There is no way to hack it downstream because the hook `def_path_hash_to_def_id_extern` must always return a `DefId` and its implementation uses `def_path_hash_to_def_index` which is internal and which is where the panic happens.
2025-09-27Rollup merge of #147050 - durin42:llvm-22-pgo-options-args, r=cuviperMatthias Krüger-0/+18
PassWrapper: update for new PGOOptions args in LLVM 22 This changed in upstream change https://github.com/llvm/llvm-project/commit/a5569b4bd7f8d2696f962e4edaa5179895228e42. ``@rustbot`` label llvm-main
2025-09-27Rollup merge of #146037 - aapoalas:reborrow-lang-experiment, r=tmandryMatthias Krüger-0/+2
Introduce CoerceShared lang item and trait, and basic Reborrow tests Part of rust-lang/rust#145612: This introduces the `CoerceShared` trait which is the `Reborrow` equivalent of a `&mut T` -> `&T` coercion. The trait has a `Target` GAT which makes this (currently) unique in the `core/src/marker.rs`; I'm not sure if this can be considered problematic. Maybe this is not the way such things should be done at the marker trait level? Or maybe it is fine. Improtantly, this PR introduces a battery of basic `Reborrow` and `CoerceShared` tests. These test the very basics of the feature; custom marker types intended to have exclusive semantics (`Custom<'a>(PhantomData<&'a mut ()>)`), custom exclusive reference wrappers, and standard library exclusive reference wrappers (`Pin<&mut T>` and `Option<&mut T>`). None of these of course work since the implementation for `Reborrow` and `CoerceShared` is entirely missing, but this is the first step towards making these work. Future PRs will introduce more tests, such as "recursive" reborrowing (ie. reborrowing structs that contain multiple reborrowable fields) and checks around the lifetime semantics of reborrowing ie. that a reborrow produces a new type with the same lifetime as the original.
2025-09-27improve empty attribute diagnosticJana Dönszelmann-15/+38
2025-09-27Auto merge of #138907 - GuillaumeGomez:rfc-3631, ↵bors-25/+93
r=fmease,camelid,Manishearth,lolbinarycat Implement RFC 3631: add rustdoc doc_cfg features Implementation of https://github.com/rust-lang/rfcs/pull/3631. This implementation actually resulted in a lot of simplifications: * All `cfg` computation is now done in one place: `propagate_doc_cfg.rs`. Because (trait) `impl`s are not retrieved at the same time as the other items, we cannot perform this computation in the clean process, it needs to be after. * Because there is `cfg` inheritance, we can keep track of them in one place (in `propagate_doc_cfg.rs`), meaning we don't need to copy an item's attributes to its children anymore. Only exception: impl items. For them we clone only `cfg` attributes. * `propagate_doc_cfg.rs` is also now much simpler, much less need to keep track of parents, since everything we need is handled by the new `CfgInfo` type. * I also suspect that `Cfg::simplify_with` could either be removed or at least used directly into `propagate_doc_cfg.rs` when we compute `cfg`s. Considering how big the PR already is, I'll do it in a follow-up. I didn't remove the `doc_cfg*` features in this PR because some dependencies used in `rustc` (like `stdarch`) are using it, so we need to have a nightly released with this PR before I can switch to the new feature. r? ghost
2025-09-27Auto merge of #146829 - cjgillot:jump-threading-loop-dominator, r=dianqkbors-17/+25
JumpThreading: Avoid computing dominators to identify loop headers. JumpThreading tries to avoid threading through loop headers to avoid creating irreducible CFGs. However, computing dominators is expensive, and accounts up to 20 % of the runtime of the JumpThreading pass for some cases like serde. This PR proposes to approximate according to the post-order traversal order. We define a "maybe" loop header as a block which is visited after its predecessor in post-order.
2025-09-27Remove `doc_auto_cfg` feature as wellGuillaume Gomez-2/+2
2025-09-27Improve code and fix typoGuillaume Gomez-36/+17
2025-09-27Apply first review round suggestionsGuillaume Gomez-2/+5
2025-09-27Remove `doc_cfg_hide` featureGuillaume Gomez-3/+0
2025-09-27Improve code and better check `doc(cfg(...))` attributesGuillaume Gomez-3/+24
2025-09-27Add code documentation, improve code and improve error messageGuillaume Gomez-7/+4