From 66b489f42f682bddd01e8e1a5207a8337f44a79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sat, 20 Jun 2026 16:10:53 +0200 Subject: [PATCH 01/42] Update syntax of try build delegation in bors --- src/doc/rustc-dev-guide/src/tests/ci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/tests/ci.md b/src/doc/rustc-dev-guide/src/tests/ci.md index 8f06d69d8cffe..31c6949d85d6c 100644 --- a/src/doc/rustc-dev-guide/src/tests/ci.md +++ b/src/doc/rustc-dev-guide/src/tests/ci.md @@ -209,7 +209,7 @@ to help make the perf comparison as fair as possible. > > 3. Run the prescribed try jobs with `@bors try`. As aforementioned, this > requires the user to either (1) have `try` permissions or (2) be delegated -> with `try` permissions by `@bors delegate=try` by someone who has `try` +> with `try` permissions by `@bors delegate try` by someone who has `try` > permissions. > > Note that this is usually easier to do than manually edit [`jobs.yml`]. From 35990d1bd15a3a10efca261cfef4d1ef00b5188c Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 22 Jun 2026 14:24:53 +0200 Subject: [PATCH 02/42] do not use title case for section names --- src/doc/rustc-dev-guide/src/compiler-debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index a07b418c64d4d..f9766706ad133 100644 --- a/src/doc/rustc-dev-guide/src/compiler-debugging.md +++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md @@ -248,7 +248,7 @@ You can then look at the PR to get more context on *why* it was changed. [bisect]: https://github.com/rust-lang/cargo-bisect-rustc [bisect-tutorial]: https://rust-lang.github.io/cargo-bisect-rustc/tutorial.html -## Downloading Artifacts from Rust's CI +## Downloading artifacts from Rust's CI The [rustup-toolchain-install-master][rtim] tool by kennytm can be used to download the artifacts produced by Rust's CI for a specific SHA1 -- this From 616c9f81997cf2e04fea6806bdc31543a8759714 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 22 Jun 2026 14:27:11 +0200 Subject: [PATCH 03/42] do not use title case for section names (part 2) --- src/doc/rustc-dev-guide/src/compiler-debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index a07b418c64d4d..2a4365ba669ef 100644 --- a/src/doc/rustc-dev-guide/src/compiler-debugging.md +++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md @@ -236,7 +236,7 @@ The compiler uses the [`tracing`] crate for logging. For details, see [the chapter on tracing](./tracing.md). -## Narrowing (Bisecting) Regressions +## Narrowing (bisecting) regressions The [cargo-bisect-rustc][bisect] tool can be used as a quick and easy way to find exactly which PR caused a change in `rustc` behavior. From 35df79520149487c33bca0c2c14aab0c0c8fd1d6 Mon Sep 17 00:00:00 2001 From: joboet Date: Mon, 22 Jun 2026 17:20:41 +0200 Subject: [PATCH 04/42] std: allocate less memory in `current_exe` for OpenBSD --- library/std/src/lib.rs | 1 + library/std/src/sys/paths/unix.rs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c9e884d89c85e..ed71db1209358 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -287,6 +287,7 @@ #![feature(doc_masked)] #![feature(doc_notable_trait)] #![feature(dropck_eyepatch)] +#![feature(exact_div)] #![feature(f16)] #![feature(f128)] #![feature(ffi_const)] diff --git a/library/std/src/sys/paths/unix.rs b/library/std/src/sys/paths/unix.rs index e0b1aafda6eb0..02b2890dcb90c 100644 --- a/library/std/src/sys/paths/unix.rs +++ b/library/std/src/sys/paths/unix.rs @@ -234,11 +234,20 @@ pub fn current_exe() -> io::Result { unsafe { let mut mib = [libc::CTL_KERN, libc::KERN_PROC_ARGS, libc::getpid(), libc::KERN_PROC_ARGV]; let mib = mib.as_mut_ptr(); - let mut argv_len = 0; - cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_len, ptr::null_mut(), 0))?; - let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize); - cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_len, ptr::null_mut(), 0))?; - argv.set_len(argv_len as usize); + + // Determine the required size (in bytes) for the argument array ... + let mut argv_size = 0; + cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_size, ptr::null_mut(), 0))?; + + // ... allocate a buffer for it ... + let argc = argv_size.div_exact(size_of::<*const libc::c_char>()).unwrap(); + let mut argv = Vec::<*const libc::c_char>::with_capacity(argc); + + // ... and retrieve the argument array. + cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_size, ptr::null_mut(), 0))?; + let argc = argv_size.div_exact(size_of::<*const libc::c_char>()).unwrap(); + argv.set_len(argc); + if argv[0].is_null() { return Err(io::const_error!(io::ErrorKind::Uncategorized, "no current exe available")); } From db9b6a1d7d868086f3cab2afa37040a20f2bfe31 Mon Sep 17 00:00:00 2001 From: joboet Date: Thu, 25 Jun 2026 14:48:59 +0200 Subject: [PATCH 05/42] std: program names starting with a dot may not be path-like --- library/std/src/sys/paths/unix.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/paths/unix.rs b/library/std/src/sys/paths/unix.rs index 02b2890dcb90c..3f3fca5dcf8be 100644 --- a/library/std/src/sys/paths/unix.rs +++ b/library/std/src/sys/paths/unix.rs @@ -252,9 +252,13 @@ pub fn current_exe() -> io::Result { return Err(io::const_error!(io::ErrorKind::Uncategorized, "no current exe available")); } let argv0 = CStr::from_ptr(argv[0]).to_bytes(); - if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') { + if argv0.iter().any(|b| *b == b'/') { + // The program name is path-like, so try to canonicalize it. crate::fs::canonicalize(OsStr::from_bytes(argv0)) } else { + // The program was probably found in the PATH. Instead of trying to + // find it again (which might not succeed if PATH has changed), just + // return the program name – this function is best-effort anyway. Ok(PathBuf::from(OsStr::from_bytes(argv0))) } } From 4928ea5384ba03ed9560890408938f76190199f2 Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 29 Jun 2026 05:50:11 +0000 Subject: [PATCH 06/42] Prepare for merging from rust-lang/rust This updates the rust-version file to 7fb284d9037fa54f6a9b24261c82b394472cbfd7. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index a05eac34eb1e9..f930573748e28 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -8c75e93c5c7671c29f3e8c096b7acf56822ed23a +7fb284d9037fa54f6a9b24261c82b394472cbfd7 From 9af8904a21515948826ea28aa65f1421b13aa756 Mon Sep 17 00:00:00 2001 From: Fallible <118682743+fallible-algebra@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:54:29 +0100 Subject: [PATCH 07/42] Add well-formedness chapter --- src/doc/rustc-dev-guide/src/SUMMARY.md | 1 + .../src/analysis/well-formed.md | 293 ++++++++++++++++++ .../rustc-dev-guide/src/appendix/glossary.md | 1 + 3 files changed, 295 insertions(+) create mode 100644 src/doc/rustc-dev-guide/src/analysis/well-formed.md diff --git a/src/doc/rustc-dev-guide/src/SUMMARY.md b/src/doc/rustc-dev-guide/src/SUMMARY.md index 9a9861186011d..9b59170de4d05 100644 --- a/src/doc/rustc-dev-guide/src/SUMMARY.md +++ b/src/doc/rustc-dev-guide/src/SUMMARY.md @@ -191,6 +191,7 @@ - [Sharing the trait solver with rust-analyzer](./solve/sharing-crates-with-rust-analyzer.md) - [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md) - [Having separate `Trait` and `Projection` bounds](./traits/separate-projection-bounds.md) +- [Well-Formedness](./analysis/well-formed.md) - [Variance](./variance.md) - [Coherence checking](./coherence.md) - [HIR Type checking](./hir-typeck/summary.md) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md new file mode 100644 index 0000000000000..49c9509fea466 --- /dev/null +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -0,0 +1,293 @@ +# Well-Formedness + +## What is Well-Formedness? + +"Well-formed" means "correctly built."[^wf-history] Something is _well-formed_ when its structure follows rules. When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. + +## Well-Formedness in Rust + +To check that something is well-formed is to perform a "Well-formedness check." + +In the Rust compiler there are two different forms of well-formedness checking: + +- **Type-Level Term**[^terms][^terms-abbreviated] well-formedness check. + - Also called "Term well-formedness" or "Term well-formedness checking." + - Not a distinct analysis stage, this gets performed throughout analysis. +- **Item**[^items] well-formedness check (item-wfck.) + - "Item-wfck" will often wind up requiring Terms be well-formed, but skips some areas. + - Inner "Terms" can (incorrectly) get normalized first. + - More coherent as a stage in the compiler than "term well-formedness" (which is performed in many places.) + +See: [What Well-Formedness Isn't](#what-well-formedness-isnt). + +## Well-Formedness of Type-Level Terms + +Term well-formedness checking begins with building a list of things that need to be true for a term to be well-formed. We call these "Obligations"[^obligations]. + +Type-Level Terms are considered Well-Formed when their associated obligations are satisfied by the trait solver. + +### Obligations for Well-Formedness + +Specific obligations are things like `String: Clone`, `A: usize`, or `::Item: Debug`. + +On this page we show the split between obligations and terms/items as: + +```rust,ignore + +--- + +``` + +Here is an example of a well-formed type-level term: + +```rust,ignore +Vec +--- +// Obligations to fulfill +Vec where T: Sized +// Trait solver says `String: Sized` is true, so this is well-formed. +Vec where String: Sized +``` + +When we compute the obligations for `Vec`, we'll find that `Vec` generates the obligation `T: Sized`. We substitute `T` with `String` in `Vec`, so we find the obligation `String: Sized` which the trait solver will determine to be satisfied. + +The following **is not** well-formed: + +```rust,ignore +Vec +--- +// Obligations to fulfill +Vec where T: Sized +// Trait solver says `str: Sized` is not true, so this is not well-formed. +Vec where str: Sized +``` + +The above computes the obligation `T: Sized`, like before, but we substitute `T` for `str` in the instance of `Vec` finding the obligation `str: sized`. This obligation will be determined by the trait solver to be _unsatisfied_. + +#### Determining Obligations + +In the compiler, obligations of terms are found through the [`obligations`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/wf/fn.obligations.html) function in the [term well-formedness module](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/wf/index.html). + +#### Other Obligations + +Obligations are more than just trait and const generic bounds, but we've only mentioned these specific obligations so far as they are what we care about when we do "well-formedness checking" of terms. See: [`PredicateKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.PredicateKind.html) and [`ClauseKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.ClauseKind.html) for a full list of obligations. + +### We Don't Need Normalization (Yet) + +[Normalization](../normalization.md) is the process of resolving [type aliases](../normalization.md#aliases) into their underlying type. + +A type alias is considered well-formed if its where clauses are satisfied. The underlying type undergoes well-formedness checking at most definition and instantiation sites, but there are exceptions. + +### Const Generic Arguments + +Term well-formedness is responsible for getting "type checking" obligations of const generic terms[^tyck-const-generics]. Let's look at the following use of const generics: + +```rust,ignore +fn use_const_generics() { /* ... */ } +// call site +use_const_generics::<6>(); +--- +// call site wfck obligations +const 6: usize +``` + +The call site will provide us with the obligation `6: usize` during well-formedness checking. This obligation will be passed off to the trait solver just like any trait-style obligation, as the trait solver has more responsibilities than its name suggests. + +## Well-Formedness of Items + +Items are, generally speaking, "Things that get defined." Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. + +```rust,ignore +// The `Vec` is checked during item wfck +fn foo(_: Vec) { + // The `Vec<[u8]>` is not handled by item wfck as it's not in the signature + let _: Vec<[u8]> +} +--- +Vec: Sized // Generated +Vec<[u8]>: Sized // Not done at item-wfck. Done elsewhere. +``` + +Item-wfck has more responsibilities than only collecting the obligations of its internal type-level terms and passing them to the trait solver. We do not talk about all of these here, but they can be found at the individual `check_*` functions in [**the item-wfck module**](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/check/wfcheck/index.html). + + + +### Global and Trivial Bounds + + + +Trait bounds are a common Obligation. Global and Trivial trait bounds are kinds of trait bounds where we already have enough information to determine if they are true or false. Item-wfck is responsible for finding and checking these bounds. + +- **Global bounds** are, in the old solver, post-normalization bounds that don't contain any generic parameters (likeΒ `` or `'a`) or bound variables (like `for<'b>`). +- **Trivial bounds** are bounds that do not need further normalization to determine if they're well-formed or not. + +Consider the following function definition: + +```rust,ignore +fn apartment_complex(block: T, name: String) where String: Clone { /* ... */ } +--- +String: Clone // Trivial & Global bound! There's no aliases to resolve. +// There could be bligations on T but we don't care about them here. +``` + +This produces a trait bound obligation `String: Clone` that is _Global_ (no generic parameters) and _Trivial_ (didn't require normalization to be well-formedness checked). The trait solver doesn't need to be given any additional information for it to be able to make a judgment on the well-formedness of `String: Clone`. + +False trivial bounds are simply trivial bounds that do not hold. The following is a basic example: + +```rust,ignore +fn apartment_simple(block: T, name: String) where String: Copy { /* ... */ } +--- +String: Copy // Trivial bound again, but this one is false! +``` + +Here we have a trivial bound that does not hold, because `String` is not `Copy`. + +#### Trivial Bounds Are Not Always Global + +Trivial Bounds are not a subset of Global Bounds. A trivial bound that isn't Global is `for<'a> String: Clone` (trivially true, has a bound variable) or `&'a str: Copy` (trivially false, has a generic parameter). + +#### Item-Wfck and Trivial/Global Bounds + + + +When checking items are well-formed we will check that there are no trivially false global bounds. + +## When We Don't Fully Do Well-Formedness Checking + +Well-formedness checking is not a coherent "stage" of type checking. There are many areas where well-formedness checking is performed, and some areas where we skip over well-formedness checking due to limitations in what kinds of analysis we can currently perform. Ideally, we would never skip or defer well-formedness checking. + +### We (Sometimes) Need Normalization + +There are places where normalization of an Item happens before its Terms have gone through well-formedness checking. This is considered problematic as doing so allows some terms to [bypass term well-formedness checking entirely](https://github.com/rust-lang/rust/issues/100041). + +### Trait Objects + +We do not require the where clauses of trait objects to be well-formed when determining if that trait object is well-formed. These where clauses are proven when coercing into a trait object, but this remains a hole in well-formedness checking. + +As an example, the following will compile because we don't have a point where we're constructing the trait object from a concrete type: + +```rust,ignore +trait Trait +where + for<'a> [u8]: Sized {} + +fn foo(_: &dyn Trait) {} +--- +// This doesn't end up being generated, because it happens within a trait object. +[u8]: Sized +``` + +The above should not compile because `[u8]: Sized`, but this won't be checked until actual use: + +```rust +trait Trait +where + for<'a> [u8]: Sized {} + +fn foo(_: &dyn Trait) {} + +// We still need to specify the bound here, otherwise `[u8]: Sized` _is_ +// checked as an obligation. +impl Trait for u8 where for<'a> [u8]: Sized {} + +fn main() { + // No matter what we do, this boundary between concrete type and trait + // object will produce the obligation `[u8]: Sized`, which will fail when + // handed over to the trait solver. + let object: Box = Box::new(42u8); + foo(&object); +} +``` + +This exception does not apply to Const Generic Arguments in trait objects: + +```rust,ignore +trait Trait {} +fn foo(_: &dyn Trait) {} +--- +const N: usize +const B: bool +N = B // Substitution +const B: usize + bool +``` + +The above doesn't compile, unlike the previous example we gave. We're doing _some_ well-formedness checking here when it comes to the const generic arguments. + +### Binders / Higher-Ranked Types + +Binders / Higher-Ranked Types reduce the amount well-formedness checking we do on a term, leaving well-formedness checking to when the bound is instantiated: + +```rust,ignore +let _: for<'a> fn(Vec<[&'a ()]>); +--- +// This doesn't end up being generated, because it happens within a HRB +[&'a ()]: Sized // slices aren't sized, this would fail! +``` + +Specifically, obligations involving variables from binders (`for<'a>`) are only checked when the binder is instantiated. Some things are stilled checked under the `for<'a>`, but we still skip a lot of things. + +A lot of unsoundness surrounds this behavior. See: [#25860](https://github.com/rust-lang/rust/issues/25860), [#84591](https://github.com/rust-lang/rust/issues/84591). + +Let's consider the following: + +```rust,ignore +for<'a, 'b> fn(&'a &'b ()) +``` + +The above HRB implies `'b: 'a` (a lifetime bound), rather than two completely separate lifetimes. This is normal lifetime behavior, but during well-formedness checking we cannot prove that this bound is generally true[^horrible], so we skip it. + +### Free Type Aliases + +The right-hand side of Free Type Aliases[^fta] is not fully checked to be well-formed at the definition site, only the types of const generic arguments in the RHS are checked. + +The following free type alias passes type checking, at time of writing: + +```rust,ignore +type WorksButShouldNot = Vec; +--- +// This should fail! But we skip the RHS of free type aliases +str: Sized // Not generated +``` + +This shouldn't work, as both `T: Sized`, `str: Sized` are implied by `Vec`. This "passes" item-wfck because the RHS of a free type alias doesn't go through well-formedness checking _until it's used_. Item-wfck is **deferred until use** for this specific case. + +For Const Generics we still do a small amount of well-formedness checking at the definition site of a free type alias. This is consistent with our current special-casing of const generic well-formedness checking when we skip over things like where bounds. + +This means that the following, despite being of a similar form to the above example, fails as it should: + +```rust,ignore +pub struct Consty; +type Alias = Consty<42>; +--- +// This *is* generated as an obligation, so this (correctly) fails. +42: bool // This is generated! +``` + + + +## "Well-Formed" or "Wellformed"? + +Prefer "well-formed" over "wellformed," as this is consistent with logic literature. This also gets abbreviated to WF in other parts of the dev guide / docs. + +## Informal Usage + +In conversation, contributors may refer to something as "well-formed" and not necessarily mean what we cover here because "well-formedness" is a general phrase associated with the correctness of formal structures. This isn't necessarily in error, but it should be looked out for. + +## What Well-Formedness Isn't + +Well-formedness checking is not "number of parameters" or "parameter type" checking[^kind-checking]. Neither term well-formedness checking nor item-wfck is concerned with if a type with 2 parameters has 1 or 3 types applied to it (assuming no defaults), or if a const generic parameter has a type applied to it. These kinds of problems will get handled during HIR-ty Lowering[^hir-ty-lower], not wfck. + +Well-formedness doesn't check or validate lifetimes, this is handled in [MIR](../borrow-check.md). + +Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as it does in logic. The term has a history of general use in a mathematical context of "follows a given set of rules." In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). + +[^obligations]: These get referred to as Obligations, Requirements, or Constraints in the documentation. Preferred term is "obligations", as this matches the suffix of the type and the names of relevant functions. In future, this may be superseded by the new solver's term "Goal." +[^wf-history]: In linguistics this is "grammatically correct," in logic it is "syntactically correct," and in casual mathematician use it can be read as a more general "follows the rules we set for this domain." +[^horrible]: Instead, this bound is checked during "MIR borrowck" when the lifetimes are instantiated. +[^fta]: Type aliases not associated with anything, i.e. a module-level `type Alias = Vec;`. +[^items]: "Definition" style things in rust, See the [glossary](../appendix/glossary.md). +[^terms]: AKA Type expressions and subexpressions in the general sense, not a specific struct or enum in the rust compiler. See the [glossary](../appendix/glossary.md). +[^terms-abbreviated]: Abbreviated as "Terms" on this page in some areas. +[^kind-checking]: AKA "kind checking", as we might see in languages like Haskell. +[^hir-ty-lower]: +[^tyck-const-generics]: \ No newline at end of file diff --git a/src/doc/rustc-dev-guide/src/appendix/glossary.md b/src/doc/rustc-dev-guide/src/appendix/glossary.md index 30959f4b39e6f..527da87b7b7e1 100644 --- a/src/doc/rustc-dev-guide/src/appendix/glossary.md +++ b/src/doc/rustc-dev-guide/src/appendix/glossary.md @@ -102,6 +102,7 @@ Term | Meaning trans πŸ‘Ž | Short for _translation_, the code to translate MIR into LLVM IR. **Renamed to** [codegen](#codegen). `Ty` | The internal representation of a type. ([see more](../ty.md)) `TyCtxt` | The data structure often referred to as [`tcx`](#tcx) in code which provides access to session data and the query system. +Type-Level Term | An expression at the type level, such as a Type or Const Generic. UFCS πŸ‘Ž | Short for _universal function call syntax_, this is an unambiguous syntax for calling a method. **Term no longer in use!** Prefer _fully-qualified path / syntax_. ([see more](../hir-typeck/summary.md), [see the reference](https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls)) uninhabited type | A type which has _no_ values. This is not the same as a ZST, which has exactly 1 value. An example of an uninhabited type is `enum Foo {}`, which has no variants, and so, can never be created. The compiler can treat code that deals with uninhabited types as dead code, since there is no such value to be manipulated. `!` (the never type) is an uninhabited type. Uninhabited types are also called _empty types_. upvar | A variable captured by a closure from outside the closure. From 6bf1cd9b2c2ad1a0d50ed9173ad211c31013c389 Mon Sep 17 00:00:00 2001 From: Kiran Shila Date: Tue, 23 Jun 2026 12:43:41 -0700 Subject: [PATCH 08/42] update autodiff install docs for nix --- .../src/autodiff/installation.md | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/autodiff/installation.md b/src/doc/rustc-dev-guide/src/autodiff/installation.md index 7247efd46a380..4176763a7bd62 100644 --- a/src/doc/rustc-dev-guide/src/autodiff/installation.md +++ b/src/doc/rustc-dev-guide/src/autodiff/installation.md @@ -18,30 +18,30 @@ Please run: rustup +nightly component add enzyme ``` -## Installation guide for Nix user. +## Installation guide for Nix + +On [Nix], you can declare a nightly Rust toolchain with the Enzyme component using the [oxalica rust-overlay]. + +For example: + +```nix +rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + extensions = [ "enzyme" ]; +}) +``` + +Alternatively, you can create a [toolchain file] that declares the Enzyme component such as + +```toml +[toolchain] +channel = "nightly-2026-06-23" +components = [ "enzyme" ] +``` + +and consume it in the overlay -This setup was recommended by a nix and autodiff user. -It uses [`Overlay`]. -Please verify for yourself if you are comfortable using that repository. -In that case you might use the following nix configuration to get a rustc that supports `std::autodiff`. ```nix -{ - enzymeLib = pkgs.fetchzip { - url = "https://ci-artifacts.rust-lang.org/rustc-builds/ec818fda361ca216eb186f5cf45131bd9c776bb4/enzyme-nightly-x86_64-unknown-linux-gnu.tar.xz"; - sha256 = "sha256-Rnrop44vzS+qmYNaRoMNNMFyAc3YsMnwdNGYMXpZ5VY="; - }; - - rustToolchain = pkgs.symlinkJoin { - name = "rust-with-enzyme"; - paths = [pkgs.rust-bin.nightly.latest.default]; - nativeBuildInputs = [pkgs.makeWrapper]; - postBuild = '' - libdir=$out/lib/rustlib/x86_64-unknown-linux-gnu/lib - cp ${enzymeLib}/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so $libdir/ - wrapProgram $out/bin/rustc --add-flags "--sysroot $out" - ''; - }; -} +rust-bin.fromRustupToolchainFile ./rust-toolchain.toml ``` ## Build instructions @@ -135,4 +135,6 @@ This will build Enzyme, and you can find it in `Enzyme/enzyme/build/lib/ Date: Wed, 1 Jul 2026 04:39:15 +0200 Subject: [PATCH 09/42] Fix typo in best-practices.md --- src/doc/rustc-dev-guide/src/tests/best-practices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/tests/best-practices.md b/src/doc/rustc-dev-guide/src/tests/best-practices.md index b6daffa6683c0..c0230c6717473 100644 --- a/src/doc/rustc-dev-guide/src/tests/best-practices.md +++ b/src/doc/rustc-dev-guide/src/tests/best-practices.md @@ -171,7 +171,7 @@ place. If a test suite can randomly spuriously fail due to flaky tests, did the whole test suite pass or did I just get lucky/unlucky? -- Flaky tests can randomly fail in full CI, wasting previous full CI resources. +- Flaky tests can randomly fail in full CI, wasting precious full CI resources. ## Compiletest directives From a4eba1dae50971b11bbdad7bbe65de3275b2a5a3 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 1 Jul 2026 09:12:53 +0200 Subject: [PATCH 10/42] make more simple --- src/doc/rustc-dev-guide/src/tests/best-practices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/tests/best-practices.md b/src/doc/rustc-dev-guide/src/tests/best-practices.md index c0230c6717473..d1378a849a9d4 100644 --- a/src/doc/rustc-dev-guide/src/tests/best-practices.md +++ b/src/doc/rustc-dev-guide/src/tests/best-practices.md @@ -171,7 +171,7 @@ place. If a test suite can randomly spuriously fail due to flaky tests, did the whole test suite pass or did I just get lucky/unlucky? -- Flaky tests can randomly fail in full CI, wasting precious full CI resources. +- Flaky tests can randomly fail in full CI, wasting precious resources. ## Compiletest directives From 866e997d6e9929b07cb06a98608e6ce6075f0d06 Mon Sep 17 00:00:00 2001 From: danieljofficial Date: Tue, 16 Jun 2026 21:13:47 +0100 Subject: [PATCH 11/42] move a few tests out of tests/ui/issues --- .../generic-fn-items-in-array-literal.rs} | 0 .../issue-33241.rs => dst/tuple-with-unsized-tail-field.rs} | 0 .../issue-35988.rs => enum/unsized-field-in-enum-variant.rs} | 0 .../unsized-field-in-enum-variant.stderr} | 0 .../multibyte-char-in-diagnostic-source-line.rs} | 0 .../multibyte-char-in-diagnostic-source-line.stderr} | 0 .../auxiliary/unstable-crate-import-gated-in-2018-edition.rs} | 0 .../unstable-crate-import-gated-in-2018-edition.rs} | 0 .../unstable-crate-import-gated-in-2018-edition.stderr} | 0 .../issue-3556.rs => fmt/format-enum-with-recursive-variant.rs} | 0 .../issue-43431.rs => fn_traits/fn-trait-ufcs-call-in-impl.rs} | 0 .../fn-trait-ufcs-call-in-impl.stderr} | 0 .../issue-45510.rs => fn_traits/overloaded-fnonce-resolution.rs} | 0 .../parenthesized-fn-trait-in-qualified-path.rs} | 0 .../parenthesized-fn-trait-in-qualified-path.stderr} | 0 .../accept-lifetime-list-empty-or-trailing-comma.rs} | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-43923.rs => coercion/generic-fn-items-in-array-literal.rs} (100%) rename tests/ui/{issues/issue-33241.rs => dst/tuple-with-unsized-tail-field.rs} (100%) rename tests/ui/{issues/issue-35988.rs => enum/unsized-field-in-enum-variant.rs} (100%) rename tests/ui/{issues/issue-35988.stderr => enum/unsized-field-in-enum-variant.stderr} (100%) rename tests/ui/{issues/issue-44023.rs => error-emitter/multibyte-char-in-diagnostic-source-line.rs} (100%) rename tests/ui/{issues/issue-44023.stderr => error-emitter/multibyte-char-in-diagnostic-source-line.stderr} (100%) rename tests/ui/{issues/auxiliary/issue-52489.rs => feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs} (100%) rename tests/ui/{issues/issue-52489.rs => feature-gates/unstable-crate-import-gated-in-2018-edition.rs} (100%) rename tests/ui/{issues/issue-52489.stderr => feature-gates/unstable-crate-import-gated-in-2018-edition.stderr} (100%) rename tests/ui/{issues/issue-3556.rs => fmt/format-enum-with-recursive-variant.rs} (100%) rename tests/ui/{issues/issue-43431.rs => fn_traits/fn-trait-ufcs-call-in-impl.rs} (100%) rename tests/ui/{issues/issue-43431.stderr => fn_traits/fn-trait-ufcs-call-in-impl.stderr} (100%) rename tests/ui/{issues/issue-45510.rs => fn_traits/overloaded-fnonce-resolution.rs} (100%) rename tests/ui/{issues/issue-39687.rs => fn_traits/parenthesized-fn-trait-in-qualified-path.rs} (100%) rename tests/ui/{issues/issue-39687.stderr => fn_traits/parenthesized-fn-trait-in-qualified-path.stderr} (100%) rename tests/ui/{issues/issue-37733.rs => parser/accept-lifetime-list-empty-or-trailing-comma.rs} (100%) diff --git a/tests/ui/issues/issue-43923.rs b/tests/ui/coercion/generic-fn-items-in-array-literal.rs similarity index 100% rename from tests/ui/issues/issue-43923.rs rename to tests/ui/coercion/generic-fn-items-in-array-literal.rs diff --git a/tests/ui/issues/issue-33241.rs b/tests/ui/dst/tuple-with-unsized-tail-field.rs similarity index 100% rename from tests/ui/issues/issue-33241.rs rename to tests/ui/dst/tuple-with-unsized-tail-field.rs diff --git a/tests/ui/issues/issue-35988.rs b/tests/ui/enum/unsized-field-in-enum-variant.rs similarity index 100% rename from tests/ui/issues/issue-35988.rs rename to tests/ui/enum/unsized-field-in-enum-variant.rs diff --git a/tests/ui/issues/issue-35988.stderr b/tests/ui/enum/unsized-field-in-enum-variant.stderr similarity index 100% rename from tests/ui/issues/issue-35988.stderr rename to tests/ui/enum/unsized-field-in-enum-variant.stderr diff --git a/tests/ui/issues/issue-44023.rs b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs similarity index 100% rename from tests/ui/issues/issue-44023.rs rename to tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs diff --git a/tests/ui/issues/issue-44023.stderr b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr similarity index 100% rename from tests/ui/issues/issue-44023.stderr rename to tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr diff --git a/tests/ui/issues/auxiliary/issue-52489.rs b/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-52489.rs rename to tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs diff --git a/tests/ui/issues/issue-52489.rs b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs similarity index 100% rename from tests/ui/issues/issue-52489.rs rename to tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs diff --git a/tests/ui/issues/issue-52489.stderr b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr similarity index 100% rename from tests/ui/issues/issue-52489.stderr rename to tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr diff --git a/tests/ui/issues/issue-3556.rs b/tests/ui/fmt/format-enum-with-recursive-variant.rs similarity index 100% rename from tests/ui/issues/issue-3556.rs rename to tests/ui/fmt/format-enum-with-recursive-variant.rs diff --git a/tests/ui/issues/issue-43431.rs b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs similarity index 100% rename from tests/ui/issues/issue-43431.rs rename to tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs diff --git a/tests/ui/issues/issue-43431.stderr b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr similarity index 100% rename from tests/ui/issues/issue-43431.stderr rename to tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr diff --git a/tests/ui/issues/issue-45510.rs b/tests/ui/fn_traits/overloaded-fnonce-resolution.rs similarity index 100% rename from tests/ui/issues/issue-45510.rs rename to tests/ui/fn_traits/overloaded-fnonce-resolution.rs diff --git a/tests/ui/issues/issue-39687.rs b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs similarity index 100% rename from tests/ui/issues/issue-39687.rs rename to tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs diff --git a/tests/ui/issues/issue-39687.stderr b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr similarity index 100% rename from tests/ui/issues/issue-39687.stderr rename to tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr diff --git a/tests/ui/issues/issue-37733.rs b/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs similarity index 100% rename from tests/ui/issues/issue-37733.rs rename to tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs From 2c0fe5bc4204f24c75273284976ee7e1e0324d5e Mon Sep 17 00:00:00 2001 From: danieljofficial Date: Wed, 1 Jul 2026 18:31:47 +0100 Subject: [PATCH 12/42] add links and bless --- tests/ui/coercion/generic-fn-items-in-array-literal.rs | 1 + tests/ui/dst/tuple-with-unsized-tail-field.rs | 1 + tests/ui/enum/unsized-field-in-enum-variant.rs | 1 + tests/ui/enum/unsized-field-in-enum-variant.stderr | 2 +- .../multibyte-char-in-diagnostic-source-line.rs | 1 + .../multibyte-char-in-diagnostic-source-line.stderr | 2 +- .../unstable-crate-import-gated-in-2018-edition.rs | 3 ++- .../unstable-crate-import-gated-in-2018-edition.rs | 9 +++++---- .../unstable-crate-import-gated-in-2018-edition.stderr | 10 +++++----- tests/ui/fmt/format-enum-with-recursive-variant.rs | 1 + tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs | 1 + tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr | 2 +- tests/ui/fn_traits/overloaded-fnonce-resolution.rs | 1 + .../parenthesized-fn-trait-in-qualified-path.rs | 1 + .../parenthesized-fn-trait-in-qualified-path.stderr | 2 +- .../accept-lifetime-list-empty-or-trailing-comma.rs | 1 + 16 files changed, 25 insertions(+), 14 deletions(-) diff --git a/tests/ui/coercion/generic-fn-items-in-array-literal.rs b/tests/ui/coercion/generic-fn-items-in-array-literal.rs index 4cd46b6ca6025..cbc5d391ed1fe 100644 --- a/tests/ui/coercion/generic-fn-items-in-array-literal.rs +++ b/tests/ui/coercion/generic-fn-items-in-array-literal.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/dst/tuple-with-unsized-tail-field.rs b/tests/ui/dst/tuple-with-unsized-tail-field.rs index 1c497876a90da..db81106f0422b 100644 --- a/tests/ui/dst/tuple-with-unsized-tail-field.rs +++ b/tests/ui/dst/tuple-with-unsized-tail-field.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ check-pass use std::fmt; diff --git a/tests/ui/enum/unsized-field-in-enum-variant.rs b/tests/ui/enum/unsized-field-in-enum-variant.rs index 5cf2f8e5212d1..a2640e1ba5b13 100644 --- a/tests/ui/enum/unsized-field-in-enum-variant.rs +++ b/tests/ui/enum/unsized-field-in-enum-variant.rs @@ -1,3 +1,4 @@ +//! Regression test for enum E { V([Box]), //~^ ERROR the size for values of type diff --git a/tests/ui/enum/unsized-field-in-enum-variant.stderr b/tests/ui/enum/unsized-field-in-enum-variant.stderr index 4a674b010ea62..7ea40614da22d 100644 --- a/tests/ui/enum/unsized-field-in-enum-variant.stderr +++ b/tests/ui/enum/unsized-field-in-enum-variant.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[Box]` cannot be known at compilation time - --> $DIR/issue-35988.rs:2:7 + --> $DIR/unsized-field-in-enum-variant.rs:3:7 | LL | V([Box]), | ^^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs index e4320b7dac592..4b1843bb5fb0f 100644 --- a/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs +++ b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs @@ -1,3 +1,4 @@ +//! Regression test for pub fn main () {} fn αƒ‘αƒαƒ­αƒ›αƒ”αƒšαƒαƒ“_αƒ’αƒ”αƒ›αƒ αƒ˜αƒ”αƒšαƒ˜_αƒ‘αƒαƒ“αƒ˜αƒšαƒ˜ ( ) -> isize { //~ ERROR mismatched types diff --git a/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr index 8554154fba515..9ced2d882b8f6 100644 --- a/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr +++ b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-44023.rs:3:36 + --> $DIR/multibyte-char-in-diagnostic-source-line.rs:4:36 | LL | fn αƒ‘αƒαƒ­αƒ›αƒ”αƒšαƒαƒ“_αƒ’αƒ”αƒ›αƒ αƒ˜αƒ”αƒšαƒ˜_αƒ‘αƒαƒ“αƒ˜αƒšαƒ˜ ( ) -> isize { | ------------------------ ^^^^^ expected `isize`, found `()` diff --git a/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs b/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs index f53bf7db52536..f725a948d6aec 100644 --- a/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs +++ b/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate for regression test of #![crate_type = "lib"] -#![unstable(feature = "issue_52489_unstable", issue = "none")] +#![unstable(feature = "unstable_crate_import_gated_in_2018_edition", issue = "none")] #![feature(staged_api)] diff --git a/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs index c1e1cb41c76d6..9e2036357ff63 100644 --- a/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs +++ b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs @@ -1,8 +1,9 @@ +//! Regression test for //@ edition:2018 -//@ aux-build:issue-52489.rs -//@ compile-flags:--extern issue_52489 +//@ aux-build:unstable-crate-import-gated-in-2018-edition.rs +//@ compile-flags: --extern unstable_crate_import_gated_in_2018_edition -use issue_52489; -//~^ ERROR use of unstable library feature `issue_52489_unstable` +use unstable_crate_import_gated_in_2018_edition; +//~^ ERROR use of unstable library feature `unstable_crate_import_gated_in_2018_edition` fn main() {} diff --git a/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr index 8e5b87b7f0fd2..d9ef6c01ca0ab 100644 --- a/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr +++ b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr @@ -1,10 +1,10 @@ -error[E0658]: use of unstable library feature `issue_52489_unstable` - --> $DIR/issue-52489.rs:5:5 +error[E0658]: use of unstable library feature `unstable_crate_import_gated_in_2018_edition` + --> $DIR/unstable-crate-import-gated-in-2018-edition.rs:6:5 | -LL | use issue_52489; - | ^^^^^^^^^^^ +LL | use unstable_crate_import_gated_in_2018_edition; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: add `#![feature(issue_52489_unstable)]` to the crate attributes to enable + = help: add `#![feature(unstable_crate_import_gated_in_2018_edition)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 1 previous error diff --git a/tests/ui/fmt/format-enum-with-recursive-variant.rs b/tests/ui/fmt/format-enum-with-recursive-variant.rs index 72fd46e0a4a1c..9ea7c4d91a6c2 100644 --- a/tests/ui/fmt/format-enum-with-recursive-variant.rs +++ b/tests/ui/fmt/format-enum-with-recursive-variant.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs index 0286336910e10..8ccf231215689 100644 --- a/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs +++ b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs @@ -1,3 +1,4 @@ +//! Regression test for #![feature(fn_traits)] trait CallSingle { diff --git a/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr index 27a720408e4b7..33dbbfd7ac077 100644 --- a/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr +++ b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr @@ -1,5 +1,5 @@ error[E0229]: associated item constraints are not allowed here - --> $DIR/issue-43431.rs:9:27 + --> $DIR/fn-trait-ufcs-call-in-impl.rs:10:27 | LL | B>::call(self, (a,)) | ^ associated item constraint not allowed here diff --git a/tests/ui/fn_traits/overloaded-fnonce-resolution.rs b/tests/ui/fn_traits/overloaded-fnonce-resolution.rs index d73218a385924..0f7a8649fd627 100644 --- a/tests/ui/fn_traits/overloaded-fnonce-resolution.rs +++ b/tests/ui/fn_traits/overloaded-fnonce-resolution.rs @@ -1,3 +1,4 @@ +//! Regression test for // Test overloaded resolution of fn_traits. //@ run-pass diff --git a/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs index 58f981b63d11d..479b23ac30542 100644 --- a/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs +++ b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs @@ -1,3 +1,4 @@ +//! Regression test for #![feature(fn_traits)] fn main() { diff --git a/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr index 87e5fdc2d8f22..b863561f02855 100644 --- a/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr +++ b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr @@ -1,5 +1,5 @@ error[E0229]: associated item constraints are not allowed here - --> $DIR/issue-39687.rs:4:14 + --> $DIR/parenthesized-fn-trait-in-qualified-path.rs:5:14 | LL | ::call; | ^^^^ associated item constraint not allowed here diff --git a/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs b/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs index fff42e9fc3c99..3bac134f39682 100644 --- a/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs +++ b/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ build-pass #![allow(dead_code)] type A = for<> fn(); From 34df03318044542c2b3c45b6d706bdb567c92136 Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Fri, 3 Jul 2026 14:54:45 +0300 Subject: [PATCH 13/42] Update `FIXME(static_mut_refs)` comments update `FIXME(static_mut_refs)` comment to say: use raw pointers instead of references. --- library/std/src/sync/mod.rs | 2 +- library/std/src/sys/alloc/vexos.rs | 2 +- library/std/src/sys/alloc/xous.rs | 2 +- library/std/tests/thread_local/tests.rs | 2 +- src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed | 2 +- src/tools/clippy/tests/ui/redundant_static_lifetimes.rs | 2 +- src/tools/clippy/tests/ui/useless_conversion.fixed | 2 +- src/tools/clippy/tests/ui/useless_conversion.rs | 2 +- src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs | 2 +- .../miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs | 2 +- src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs | 2 +- src/tools/miri/tests/pass-dep/libc/libc-pipe.rs | 2 +- src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs | 2 +- src/tools/miri/tests/pass/atomic.rs | 2 +- src/tools/miri/tests/pass/static_memory_modification.rs | 2 +- src/tools/miri/tests/pass/static_mut.rs | 2 +- src/tools/miri/tests/pass/tls/tls_static.rs | 2 +- tests/ui/abi/statics/static-mut-foreign.rs | 2 +- tests/ui/array-slice-vec/slice-panic-1.rs | 2 +- tests/ui/array-slice-vec/slice-panic-2.rs | 2 +- tests/ui/array-slice-vec/slice.rs | 2 +- tests/ui/async-await/issues/issue-67611-static-mut-refs.rs | 2 +- tests/ui/binding/order-drop-with-match.rs | 2 +- tests/ui/binding/ref-pattern-drop-behavior-8860.rs | 2 +- tests/ui/consts/static-mut-refs.rs | 2 +- tests/ui/coroutine/static-mut-reference-across-yield.rs | 2 +- tests/ui/drop/conditional-drop-10734.rs | 2 +- tests/ui/drop/destructor-run-for-expression-4734.rs | 2 +- tests/ui/drop/destructor-run-for-let-ignore-6892.rs | 2 +- tests/ui/drop/drop-count-assertion-16151.rs | 2 +- tests/ui/drop/drop-struct-as-object.rs | 2 +- tests/ui/drop/generic-drop-trait-bound-15858.rs | 2 +- tests/ui/drop/issue-23338-ensure-param-drop-order.rs | 2 +- tests/ui/drop/issue-23611-enum-swap-in-drop.rs | 2 +- tests/ui/drop/issue-48962.rs | 2 +- tests/ui/drop/repeat-drop.rs | 2 +- tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs | 2 +- tests/ui/drop/static-issue-17302.rs | 2 +- tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs | 2 +- .../functional-struct-update-respects-privacy.rs | 2 +- tests/ui/linkage-attr/link-section-placement.rs | 2 +- tests/ui/linkage-attr/linkage-attr-mutable-static.rs | 2 +- tests/ui/lto/lto-still-runs-thread-dtors.rs | 2 +- tests/ui/methods/method-self-arg-trait.rs | 2 +- tests/ui/methods/method-self-arg.rs | 2 +- tests/ui/mir/mir_early_return_scope.rs | 2 +- tests/ui/nll/issue-69114-static-mut-ty.rs | 2 +- tests/ui/numbers-arithmetic/shift-near-oflo.rs | 2 +- tests/ui/self/where-for-self.rs | 2 +- tests/ui/thread-local/thread-local-issue-37508.rs | 2 +- tests/ui/traits/impl.rs | 2 +- tests/ui/union/union-drop-assign.rs | 2 +- tests/ui/union/union-drop.rs | 2 +- 53 files changed, 53 insertions(+), 53 deletions(-) diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index 439b5b09a5ac0..1c3b6d01ed9d8 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -9,7 +9,7 @@ //! Consider the following code, operating on some global static variables: //! //! ```rust -//! // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +//! // FIXME(static_mut_refs): use raw pointers instead of references //! #![allow(static_mut_refs)] //! //! static mut A: u32 = 0; diff --git a/library/std/src/sys/alloc/vexos.rs b/library/std/src/sys/alloc/vexos.rs index c1fb6896a89ae..5ccf6625ed626 100644 --- a/library/std/src/sys/alloc/vexos.rs +++ b/library/std/src/sys/alloc/vexos.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use crate::alloc::{GlobalAlloc, Layout, System}; diff --git a/library/std/src/sys/alloc/xous.rs b/library/std/src/sys/alloc/xous.rs index c7f973b802791..af2dcabc1a23b 100644 --- a/library/std/src/sys/alloc/xous.rs +++ b/library/std/src/sys/alloc/xous.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use crate::alloc::{GlobalAlloc, Layout, System}; diff --git a/library/std/tests/thread_local/tests.rs b/library/std/tests/thread_local/tests.rs index 633bab38eb4db..1a25d91e43bc0 100644 --- a/library/std/tests/thread_local/tests.rs +++ b/library/std/tests/thread_local/tests.rs @@ -110,7 +110,7 @@ fn smoke_dtor() { #[test] fn circular() { - // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint + // FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] struct S1(&'static LocalKey>>, &'static LocalKey>>); diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed b/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed index 86c6ca17eb20e..0a898032459f6 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed @@ -1,5 +1,5 @@ #![allow(unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #[derive(Debug)] diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs b/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs index 6fefe6c232d2f..fa45eff0f2626 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs @@ -1,5 +1,5 @@ #![allow(unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #[derive(Debug)] diff --git a/src/tools/clippy/tests/ui/useless_conversion.fixed b/src/tools/clippy/tests/ui/useless_conversion.fixed index a22df7013f988..d74ea54354fdd 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.fixed +++ b/src/tools/clippy/tests/ui/useless_conversion.fixed @@ -1,7 +1,7 @@ #![deny(clippy::useless_conversion)] #![allow(clippy::into_iter_on_ref)] #![allow(clippy::needless_ifs, clippy::unnecessary_wraps, unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ops::ControlFlow; diff --git a/src/tools/clippy/tests/ui/useless_conversion.rs b/src/tools/clippy/tests/ui/useless_conversion.rs index 1f170cf87ac58..5d7d180635771 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.rs +++ b/src/tools/clippy/tests/ui/useless_conversion.rs @@ -1,7 +1,7 @@ #![deny(clippy::useless_conversion)] #![allow(clippy::into_iter_on_ref)] #![allow(clippy::needless_ifs, clippy::unnecessary_wraps, unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ops::ControlFlow; diff --git a/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs b/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs index 5b7a2b7039d80..2e45af9e28880 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs @@ -1,7 +1,7 @@ //@only-target: linux android //@compile-flags: -Zmiri-disable-isolation -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem::MaybeUninit; diff --git a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs index df42780021610..6ec4b6e48bc3f 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs @@ -5,7 +5,7 @@ //! the fallback path in `guard::key::enable`, which uses a *single* pthread_key //! to manage a thread-local list of dtors to call. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::{mem, ptr}; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs b/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs index e753983344bd4..d84ce42922886 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs @@ -3,7 +3,7 @@ //@compile-flags: -Zmiri-deterministic-concurrency //@run-native -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::{io, thread}; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs b/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs index 12b5ae5666cfd..de278c190b589 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs @@ -69,7 +69,7 @@ fn test_pipe_threaded() { thread2.join().unwrap(); } -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #[allow(static_mut_refs)] fn test_race() { static mut VAL: u8 = 0; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs b/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs index f994dc28a9349..bcfa52211dd9b 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs @@ -3,7 +3,7 @@ //@compile-flags: -Zmiri-deterministic-concurrency //@run-native -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/src/tools/miri/tests/pass/atomic.rs b/src/tools/miri/tests/pass/atomic.rs index 842f036b0615a..0b7fff69d8ce2 100644 --- a/src/tools/miri/tests/pass/atomic.rs +++ b/src/tools/miri/tests/pass/atomic.rs @@ -3,7 +3,7 @@ //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::sync::atomic::Ordering::*; diff --git a/src/tools/miri/tests/pass/static_memory_modification.rs b/src/tools/miri/tests/pass/static_memory_modification.rs index 1900250bf4f8f..f55f2a251930e 100644 --- a/src/tools/miri/tests/pass/static_memory_modification.rs +++ b/src/tools/miri/tests/pass/static_memory_modification.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/tools/miri/tests/pass/static_mut.rs b/src/tools/miri/tests/pass/static_mut.rs index f88c7a16e6dd7..005ec5f9dfcb4 100644 --- a/src/tools/miri/tests/pass/static_mut.rs +++ b/src/tools/miri/tests/pass/static_mut.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ptr::addr_of; diff --git a/src/tools/miri/tests/pass/tls/tls_static.rs b/src/tools/miri/tests/pass/tls/tls_static.rs index 600ecea334e13..dfc13720b4c8d 100644 --- a/src/tools/miri/tests/pass/tls/tls_static.rs +++ b/src/tools/miri/tests/pass/tls/tls_static.rs @@ -8,7 +8,7 @@ //! dereferencing the pointer on `t2` resolves to `t1`'s thread-local. In this //! test, we also check that thread-locals act as per-thread statics. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![feature(thread_local)] diff --git a/tests/ui/abi/statics/static-mut-foreign.rs b/tests/ui/abi/statics/static-mut-foreign.rs index 40cd57637e6cd..f79400e7a6df8 100644 --- a/tests/ui/abi/statics/static-mut-foreign.rs +++ b/tests/ui/abi/statics/static-mut-foreign.rs @@ -3,7 +3,7 @@ // statics cannot. This ensures that there's some form of error if this is // attempted. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ffi::c_int; diff --git a/tests/ui/array-slice-vec/slice-panic-1.rs b/tests/ui/array-slice-vec/slice-panic-1.rs index d7c1098fa2bda..60680c367a671 100644 --- a/tests/ui/array-slice-vec/slice-panic-1.rs +++ b/tests/ui/array-slice-vec/slice-panic-1.rs @@ -5,7 +5,7 @@ // Test that if a slicing expr[..] fails, the correct cleanups happen. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/tests/ui/array-slice-vec/slice-panic-2.rs b/tests/ui/array-slice-vec/slice-panic-2.rs index 157e716a95d49..e5ba045248da2 100644 --- a/tests/ui/array-slice-vec/slice-panic-2.rs +++ b/tests/ui/array-slice-vec/slice-panic-2.rs @@ -5,7 +5,7 @@ // Test that if a slicing expr[..] fails, the correct cleanups happen. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/tests/ui/array-slice-vec/slice.rs b/tests/ui/array-slice-vec/slice.rs index ad5db7a2102b4..b94a8e029f778 100644 --- a/tests/ui/array-slice-vec/slice.rs +++ b/tests/ui/array-slice-vec/slice.rs @@ -3,7 +3,7 @@ // Test slicing sugar. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] extern crate core; diff --git a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs index 04958352d3f2e..9f0869a3a0b43 100644 --- a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs +++ b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs @@ -1,7 +1,7 @@ //@ build-pass //@ edition:2018 -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/binding/order-drop-with-match.rs b/tests/ui/binding/order-drop-with-match.rs index cd0ff73cf12da..db91ead4e0f85 100644 --- a/tests/ui/binding/order-drop-with-match.rs +++ b/tests/ui/binding/order-drop-with-match.rs @@ -5,7 +5,7 @@ // in ORDER matching up to when it ran. // Correct order is: matched, inner, outer -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut ORDER: [usize; 3] = [0, 0, 0]; diff --git a/tests/ui/binding/ref-pattern-drop-behavior-8860.rs b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs index 1a67caf021cf7..bcb3ca2800396 100644 --- a/tests/ui/binding/ref-pattern-drop-behavior-8860.rs +++ b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs @@ -1,6 +1,6 @@ // https://github.com/rust-lang/rust/issues/8860 //@ run-pass -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![allow(dead_code)] diff --git a/tests/ui/consts/static-mut-refs.rs b/tests/ui/consts/static-mut-refs.rs index c0d0bb613325c..8eab90d0673e3 100644 --- a/tests/ui/consts/static-mut-refs.rs +++ b/tests/ui/consts/static-mut-refs.rs @@ -1,7 +1,7 @@ //@ run-pass #![allow(dead_code)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Checks that mutable static items can have mutable slices and other references diff --git a/tests/ui/coroutine/static-mut-reference-across-yield.rs b/tests/ui/coroutine/static-mut-reference-across-yield.rs index d45d6e6428b9c..b7a77e4b95b69 100644 --- a/tests/ui/coroutine/static-mut-reference-across-yield.rs +++ b/tests/ui/coroutine/static-mut-reference-across-yield.rs @@ -1,7 +1,7 @@ //@ build-pass #![feature(coroutines, stmt_expr_attributes)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/drop/conditional-drop-10734.rs b/tests/ui/drop/conditional-drop-10734.rs index 25f492bf9e087..3ac9239fe20fd 100644 --- a/tests/ui/drop/conditional-drop-10734.rs +++ b/tests/ui/drop/conditional-drop-10734.rs @@ -3,7 +3,7 @@ //@ run-pass #![allow(non_upper_case_globals)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut drop_count: usize = 0; diff --git a/tests/ui/drop/destructor-run-for-expression-4734.rs b/tests/ui/drop/destructor-run-for-expression-4734.rs index 57971ee5ef76e..15d676409738e 100644 --- a/tests/ui/drop/destructor-run-for-expression-4734.rs +++ b/tests/ui/drop/destructor-run-for-expression-4734.rs @@ -4,7 +4,7 @@ // Ensures that destructors are run for expressions of the form "e;" where // `e` is a type which requires a destructor. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![allow(path_statements)] diff --git a/tests/ui/drop/destructor-run-for-let-ignore-6892.rs b/tests/ui/drop/destructor-run-for-let-ignore-6892.rs index 0fcf133c2b188..643eac466845a 100644 --- a/tests/ui/drop/destructor-run-for-let-ignore-6892.rs +++ b/tests/ui/drop/destructor-run-for-let-ignore-6892.rs @@ -4,7 +4,7 @@ // Ensures that destructors are run for expressions of the form "let _ = e;" // where `e` is a type which requires a destructor. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] struct Foo; diff --git a/tests/ui/drop/drop-count-assertion-16151.rs b/tests/ui/drop/drop-count-assertion-16151.rs index ede6bc23e733a..0e49708609ba7 100644 --- a/tests/ui/drop/drop-count-assertion-16151.rs +++ b/tests/ui/drop/drop-count-assertion-16151.rs @@ -1,7 +1,7 @@ // https://github.com/rust-lang/rust/issues/16151 //@ run-pass -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem; diff --git a/tests/ui/drop/drop-struct-as-object.rs b/tests/ui/drop/drop-struct-as-object.rs index 46633bd70751f..0f407e4fffb04 100644 --- a/tests/ui/drop/drop-struct-as-object.rs +++ b/tests/ui/drop/drop-struct-as-object.rs @@ -5,7 +5,7 @@ // Test that destructor on a struct runs successfully after the struct // is boxed and converted to an object. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut value: usize = 0; diff --git a/tests/ui/drop/generic-drop-trait-bound-15858.rs b/tests/ui/drop/generic-drop-trait-bound-15858.rs index 682604d17d864..237cef50ef55d 100644 --- a/tests/ui/drop/generic-drop-trait-bound-15858.rs +++ b/tests/ui/drop/generic-drop-trait-bound-15858.rs @@ -1,7 +1,7 @@ //! Regression test for https://github.com/rust-lang/rust/issues/15858 //@ run-pass -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut DROP_RAN: bool = false; diff --git a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs index 54a9d3324b9e6..cdfc3ee889eae 100644 --- a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs +++ b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(non_upper_case_globals)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // This test is ensuring that parameters are indeed dropped after diff --git a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs index 208c6e2ada3d0..253c3c3c7f98a 100644 --- a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs +++ b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(non_upper_case_globals)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Issue 23611: this test is ensuring that, for an instance `X` of the diff --git a/tests/ui/drop/issue-48962.rs b/tests/ui/drop/issue-48962.rs index 98d3af49ac1ec..5ecc54c5a27b1 100644 --- a/tests/ui/drop/issue-48962.rs +++ b/tests/ui/drop/issue-48962.rs @@ -1,7 +1,7 @@ //@ run-pass #![allow(unused_must_use)] // Test that we are able to reinitialize box with moved referent -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut ORDER: [usize; 3] = [0, 0, 0]; diff --git a/tests/ui/drop/repeat-drop.rs b/tests/ui/drop/repeat-drop.rs index 7488d9113b0af..1b10e6e553b80 100644 --- a/tests/ui/drop/repeat-drop.rs +++ b/tests/ui/drop/repeat-drop.rs @@ -3,7 +3,7 @@ #![allow(dropping_references, dropping_copy_types)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut CHECK: usize = 0; diff --git a/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs index ecc862ec7be6b..449a4728963d9 100644 --- a/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs +++ b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs @@ -2,7 +2,7 @@ //@ run-pass -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem; diff --git a/tests/ui/drop/static-issue-17302.rs b/tests/ui/drop/static-issue-17302.rs index 060f5564efdae..ef13da6ec6547 100644 --- a/tests/ui/drop/static-issue-17302.rs +++ b/tests/ui/drop/static-issue-17302.rs @@ -1,6 +1,6 @@ //@ run-pass -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut DROPPED: [bool; 2] = [false, false]; diff --git a/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs b/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs index 57e8b2286497c..ac6eb209a9211 100644 --- a/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs +++ b/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs @@ -2,7 +2,7 @@ // This test verifies that temporaries created for `while`'s and `if` // conditions are dropped after the condition is evaluated. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] struct Temporary; diff --git a/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs b/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs index a05d20ffbd280..e90cf3f9e4cc1 100644 --- a/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs +++ b/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs @@ -3,7 +3,7 @@ // The `foo` module attempts to maintains an invariant that each `S` // has a unique `u64` id. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use self::foo::S; diff --git a/tests/ui/linkage-attr/link-section-placement.rs b/tests/ui/linkage-attr/link-section-placement.rs index 299ad31d82d0d..b1b88e911861f 100644 --- a/tests/ui/linkage-attr/link-section-placement.rs +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -3,7 +3,7 @@ //@ run-pass #![feature(cfg_target_object_format)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![allow(non_upper_case_globals)] diff --git a/tests/ui/linkage-attr/linkage-attr-mutable-static.rs b/tests/ui/linkage-attr/linkage-attr-mutable-static.rs index cc93f61e28f37..09f7d65f97e4d 100644 --- a/tests/ui/linkage-attr/linkage-attr-mutable-static.rs +++ b/tests/ui/linkage-attr/linkage-attr-mutable-static.rs @@ -2,7 +2,7 @@ //! them at runtime, so deny mutable statics with #[linkage]. #![feature(linkage)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] fn main() { diff --git a/tests/ui/lto/lto-still-runs-thread-dtors.rs b/tests/ui/lto/lto-still-runs-thread-dtors.rs index 9a97677773cca..780e8eb844faf 100644 --- a/tests/ui/lto/lto-still-runs-thread-dtors.rs +++ b/tests/ui/lto/lto-still-runs-thread-dtors.rs @@ -4,7 +4,7 @@ //@ needs-threads //@ ignore-backends: gcc -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/tests/ui/methods/method-self-arg-trait.rs b/tests/ui/methods/method-self-arg-trait.rs index ccffe02328bbf..7b945fc3c38a4 100644 --- a/tests/ui/methods/method-self-arg-trait.rs +++ b/tests/ui/methods/method-self-arg-trait.rs @@ -1,7 +1,7 @@ //@ run-pass // Test method calls with self as an argument -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut COUNT: u64 = 1; diff --git a/tests/ui/methods/method-self-arg.rs b/tests/ui/methods/method-self-arg.rs index 2e058ee1077c6..e54b47b3b645f 100644 --- a/tests/ui/methods/method-self-arg.rs +++ b/tests/ui/methods/method-self-arg.rs @@ -1,7 +1,7 @@ //@ run-pass // Test method calls with self as an argument -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut COUNT: usize = 1; diff --git a/tests/ui/mir/mir_early_return_scope.rs b/tests/ui/mir/mir_early_return_scope.rs index 42f1cc50d15da..7e550c3ef5dff 100644 --- a/tests/ui/mir/mir_early_return_scope.rs +++ b/tests/ui/mir/mir_early_return_scope.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(unused_variables)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut DROP: bool = false; diff --git a/tests/ui/nll/issue-69114-static-mut-ty.rs b/tests/ui/nll/issue-69114-static-mut-ty.rs index 95c787488c08e..dd5fe3c6ff26b 100644 --- a/tests/ui/nll/issue-69114-static-mut-ty.rs +++ b/tests/ui/nll/issue-69114-static-mut-ty.rs @@ -1,6 +1,6 @@ // Check that borrowck ensures that `static mut` items have the expected type. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static FOO: u8 = 42; diff --git a/tests/ui/numbers-arithmetic/shift-near-oflo.rs b/tests/ui/numbers-arithmetic/shift-near-oflo.rs index 97227bd843f07..714ff6e86fd5a 100644 --- a/tests/ui/numbers-arithmetic/shift-near-oflo.rs +++ b/tests/ui/numbers-arithmetic/shift-near-oflo.rs @@ -1,7 +1,7 @@ //@ run-pass //@ compile-flags: -C debug-assertions -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Check that we do *not* overflow on a number of edge cases. diff --git a/tests/ui/self/where-for-self.rs b/tests/ui/self/where-for-self.rs index d31bb1f22c4ce..d874cbd5bcdde 100644 --- a/tests/ui/self/where-for-self.rs +++ b/tests/ui/self/where-for-self.rs @@ -2,7 +2,7 @@ // Test that we can quantify lifetimes outside a constraint (i.e., including // the self type) in a where clause. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut COUNT: u32 = 1; diff --git a/tests/ui/thread-local/thread-local-issue-37508.rs b/tests/ui/thread-local/thread-local-issue-37508.rs index 34c3945345184..ef7670af3d384 100644 --- a/tests/ui/thread-local/thread-local-issue-37508.rs +++ b/tests/ui/thread-local/thread-local-issue-37508.rs @@ -4,7 +4,7 @@ // // Regression test for issue #37508 -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![no_main] diff --git a/tests/ui/traits/impl.rs b/tests/ui/traits/impl.rs index b45935fd86a41..8858db8fad26e 100644 --- a/tests/ui/traits/impl.rs +++ b/tests/ui/traits/impl.rs @@ -3,7 +3,7 @@ //@ aux-build:traitimpl.rs -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] extern crate traitimpl; diff --git a/tests/ui/union/union-drop-assign.rs b/tests/ui/union/union-drop-assign.rs index 451fb14eddf93..710a6f6205e01 100644 --- a/tests/ui/union/union-drop-assign.rs +++ b/tests/ui/union/union-drop-assign.rs @@ -3,7 +3,7 @@ // Drop works for union itself. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem::ManuallyDrop; diff --git a/tests/ui/union/union-drop.rs b/tests/ui/union/union-drop.rs index 6f6d5c1416534..9a2911599dfe2 100644 --- a/tests/ui/union/union-drop.rs +++ b/tests/ui/union/union-drop.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(unused_variables)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Drop works for union itself. From 9016189942ef529c95622d9fad909577a3936386 Mon Sep 17 00:00:00 2001 From: zedddie Date: Fri, 3 Jul 2026 23:37:02 +0200 Subject: [PATCH 14/42] move batch --- .../unconstrained-lifetime-in-projection.rs} | 0 .../unconstrained-lifetime-in-projection.stderr} | 0 .../index-self-with-arithmetic-on-self-item.rs} | 0 .../issue-2989.rs => codegen/bitvec-to-bools-opt-miscompile.rs} | 0 .../bitvec-to-bools-opt-miscompile.stderr} | 0 .../issue-30081.rs => codegen/box-deref-segfault-misopt.rs} | 0 .../issue-29948.rs => drop/move-closure-drop-on-unwind.rs} | 0 .../issue-30018-panic.rs => drop/panic-during-slice-init.rs} | 0 .../issue-29668.rs => privacy/fn-returns-unnameable-type.rs} | 0 .../issue-3021-b.rs => resolve/impl-method-cant-capture-env.rs} | 0 .../impl-method-cant-capture-env.stderr} | 0 .../{issue-3021.rs => impl-trait-for-type-cant-capture-env.rs} | 0 ...ue-3021.stderr => impl-trait-for-type-cant-capture-env.stderr} | 0 .../resolve/{issue-3021-c.rs => outer-generic-in-trait-method.rs} | 0 .../{issue-3021-c.stderr => outer-generic-in-trait-method.stderr} | 0 .../issue-3021-d.rs => resolve/trait-impl-cant-capture-env.rs} | 0 .../trait-impl-cant-capture-env.stderr} | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-29861.rs => associated-types/unconstrained-lifetime-in-projection.rs} (100%) rename tests/ui/{issues/issue-29861.stderr => associated-types/unconstrained-lifetime-in-projection.stderr} (100%) rename tests/ui/{issues/issue-29743.rs => borrowck/index-self-with-arithmetic-on-self-item.rs} (100%) rename tests/ui/{issues/issue-2989.rs => codegen/bitvec-to-bools-opt-miscompile.rs} (100%) rename tests/ui/{issues/issue-2989.stderr => codegen/bitvec-to-bools-opt-miscompile.stderr} (100%) rename tests/ui/{issues/issue-30081.rs => codegen/box-deref-segfault-misopt.rs} (100%) rename tests/ui/{issues/issue-29948.rs => drop/move-closure-drop-on-unwind.rs} (100%) rename tests/ui/{issues/issue-30018-panic.rs => drop/panic-during-slice-init.rs} (100%) rename tests/ui/{issues/issue-29668.rs => privacy/fn-returns-unnameable-type.rs} (100%) rename tests/ui/{issues/issue-3021-b.rs => resolve/impl-method-cant-capture-env.rs} (100%) rename tests/ui/{issues/issue-3021-b.stderr => resolve/impl-method-cant-capture-env.stderr} (100%) rename tests/ui/resolve/{issue-3021.rs => impl-trait-for-type-cant-capture-env.rs} (100%) rename tests/ui/resolve/{issue-3021.stderr => impl-trait-for-type-cant-capture-env.stderr} (100%) rename tests/ui/resolve/{issue-3021-c.rs => outer-generic-in-trait-method.rs} (100%) rename tests/ui/resolve/{issue-3021-c.stderr => outer-generic-in-trait-method.stderr} (100%) rename tests/ui/{issues/issue-3021-d.rs => resolve/trait-impl-cant-capture-env.rs} (100%) rename tests/ui/{issues/issue-3021-d.stderr => resolve/trait-impl-cant-capture-env.stderr} (100%) diff --git a/tests/ui/issues/issue-29861.rs b/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs similarity index 100% rename from tests/ui/issues/issue-29861.rs rename to tests/ui/associated-types/unconstrained-lifetime-in-projection.rs diff --git a/tests/ui/issues/issue-29861.stderr b/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr similarity index 100% rename from tests/ui/issues/issue-29861.stderr rename to tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr diff --git a/tests/ui/issues/issue-29743.rs b/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs similarity index 100% rename from tests/ui/issues/issue-29743.rs rename to tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs diff --git a/tests/ui/issues/issue-2989.rs b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs similarity index 100% rename from tests/ui/issues/issue-2989.rs rename to tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs diff --git a/tests/ui/issues/issue-2989.stderr b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr similarity index 100% rename from tests/ui/issues/issue-2989.stderr rename to tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr diff --git a/tests/ui/issues/issue-30081.rs b/tests/ui/codegen/box-deref-segfault-misopt.rs similarity index 100% rename from tests/ui/issues/issue-30081.rs rename to tests/ui/codegen/box-deref-segfault-misopt.rs diff --git a/tests/ui/issues/issue-29948.rs b/tests/ui/drop/move-closure-drop-on-unwind.rs similarity index 100% rename from tests/ui/issues/issue-29948.rs rename to tests/ui/drop/move-closure-drop-on-unwind.rs diff --git a/tests/ui/issues/issue-30018-panic.rs b/tests/ui/drop/panic-during-slice-init.rs similarity index 100% rename from tests/ui/issues/issue-30018-panic.rs rename to tests/ui/drop/panic-during-slice-init.rs diff --git a/tests/ui/issues/issue-29668.rs b/tests/ui/privacy/fn-returns-unnameable-type.rs similarity index 100% rename from tests/ui/issues/issue-29668.rs rename to tests/ui/privacy/fn-returns-unnameable-type.rs diff --git a/tests/ui/issues/issue-3021-b.rs b/tests/ui/resolve/impl-method-cant-capture-env.rs similarity index 100% rename from tests/ui/issues/issue-3021-b.rs rename to tests/ui/resolve/impl-method-cant-capture-env.rs diff --git a/tests/ui/issues/issue-3021-b.stderr b/tests/ui/resolve/impl-method-cant-capture-env.stderr similarity index 100% rename from tests/ui/issues/issue-3021-b.stderr rename to tests/ui/resolve/impl-method-cant-capture-env.stderr diff --git a/tests/ui/resolve/issue-3021.rs b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs similarity index 100% rename from tests/ui/resolve/issue-3021.rs rename to tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs diff --git a/tests/ui/resolve/issue-3021.stderr b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr similarity index 100% rename from tests/ui/resolve/issue-3021.stderr rename to tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr diff --git a/tests/ui/resolve/issue-3021-c.rs b/tests/ui/resolve/outer-generic-in-trait-method.rs similarity index 100% rename from tests/ui/resolve/issue-3021-c.rs rename to tests/ui/resolve/outer-generic-in-trait-method.rs diff --git a/tests/ui/resolve/issue-3021-c.stderr b/tests/ui/resolve/outer-generic-in-trait-method.stderr similarity index 100% rename from tests/ui/resolve/issue-3021-c.stderr rename to tests/ui/resolve/outer-generic-in-trait-method.stderr diff --git a/tests/ui/issues/issue-3021-d.rs b/tests/ui/resolve/trait-impl-cant-capture-env.rs similarity index 100% rename from tests/ui/issues/issue-3021-d.rs rename to tests/ui/resolve/trait-impl-cant-capture-env.rs diff --git a/tests/ui/issues/issue-3021-d.stderr b/tests/ui/resolve/trait-impl-cant-capture-env.stderr similarity index 100% rename from tests/ui/issues/issue-3021-d.stderr rename to tests/ui/resolve/trait-impl-cant-capture-env.stderr From 0c42d9225a4bb7e33289a2cdad69eb7ac9f9b7d5 Mon Sep 17 00:00:00 2001 From: zedddie Date: Fri, 3 Jul 2026 23:37:29 +0200 Subject: [PATCH 15/42] bless batch --- src/tools/tidy/src/issues.txt | 2 -- .../unconstrained-lifetime-in-projection.rs | 4 ++++ .../unconstrained-lifetime-in-projection.stderr | 4 ++-- .../index-self-with-arithmetic-on-self-item.rs | 3 +++ tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs | 2 ++ tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr | 2 +- tests/ui/codegen/box-deref-segfault-misopt.rs | 3 ++- tests/ui/drop/move-closure-drop-on-unwind.rs | 4 ++++ tests/ui/drop/panic-during-slice-init.rs | 10 +++++----- tests/ui/privacy/fn-returns-unnameable-type.rs | 3 ++- tests/ui/resolve/impl-method-cant-capture-env.rs | 3 +++ tests/ui/resolve/impl-method-cant-capture-env.stderr | 2 +- .../ui/resolve/impl-trait-for-type-cant-capture-env.rs | 3 +++ .../impl-trait-for-type-cant-capture-env.stderr | 2 +- tests/ui/resolve/outer-generic-in-trait-method.rs | 3 +++ tests/ui/resolve/outer-generic-in-trait-method.stderr | 4 ++-- tests/ui/resolve/trait-impl-cant-capture-env.rs | 3 +++ tests/ui/resolve/trait-impl-cant-capture-env.stderr | 4 ++-- 18 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index db6008da59b34..bb251a6823ac6 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -2324,8 +2324,6 @@ ui/resolve/issue-2356.rs ui/resolve/issue-23716.rs ui/resolve/issue-24968.rs ui/resolve/issue-26545.rs -ui/resolve/issue-3021-c.rs -ui/resolve/issue-3021.rs ui/resolve/issue-30535.rs ui/resolve/issue-3099-a.rs ui/resolve/issue-3099-b.rs diff --git a/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs b/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs index 875c168185feb..bee7d521c30f8 100644 --- a/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs +++ b/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs @@ -1,3 +1,7 @@ +//! Regression test for . +//! Unconstrained lifetimes in associated type were wrongly allowed when +//! occurred in projection. + pub trait MakeRef<'a> { type Ref; } diff --git a/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr b/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr index a25cbf0515d84..0847fa652c55a 100644 --- a/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr +++ b/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr @@ -1,11 +1,11 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-29861.rs:11:6 + --> $DIR/unconstrained-lifetime-in-projection.rs:15:6 | LL | impl<'a, T: 'a> MakeRef2 for T { | ^^ unconstrained lifetime parameter error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-29861.rs:16:43 + --> $DIR/unconstrained-lifetime-in-projection.rs:20:43 | LL | fn foo() -> ::Ref2 { &String::from("foo") } | ^^^^^^^^^^^^^^^^^^^ -- borrow later used here diff --git a/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs b/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs index 8e522a7482190..3987e782af27b 100644 --- a/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs +++ b/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Test borrowck doesn't complain about using arithmetic with self item +//! as index. //@ check-pass fn main() { diff --git a/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs index fc35d1906368f..9611cd5485b60 100644 --- a/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs +++ b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs @@ -1,4 +1,6 @@ +//! Regression test for . //@ run-pass + #![allow(non_camel_case_types)] trait methods { //~ WARN trait `methods` is never used diff --git a/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr index 500ace8f2753e..3eb03d3740fcd 100644 --- a/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr +++ b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr @@ -1,5 +1,5 @@ warning: trait `methods` is never used - --> $DIR/issue-2989.rs:4:7 + --> $DIR/bitvec-to-bools-opt-miscompile.rs:6:7 | LL | trait methods { | ^^^^^^^ diff --git a/tests/ui/codegen/box-deref-segfault-misopt.rs b/tests/ui/codegen/box-deref-segfault-misopt.rs index 538e89f224697..f764db35e8c29 100644 --- a/tests/ui/codegen/box-deref-segfault-misopt.rs +++ b/tests/ui/codegen/box-deref-segfault-misopt.rs @@ -1,5 +1,6 @@ +//! Regression test for . +//! Misoptimization caused this to segfault. //@ run-pass -// This used to segfault #30081 pub enum Instruction { Increment(i8), diff --git a/tests/ui/drop/move-closure-drop-on-unwind.rs b/tests/ui/drop/move-closure-drop-on-unwind.rs index 77a3885da042a..ad110c1de01c8 100644 --- a/tests/ui/drop/move-closure-drop-on-unwind.rs +++ b/tests/ui/drop/move-closure-drop-on-unwind.rs @@ -1,3 +1,7 @@ +//! Regression test for . +//! Test `FnOnce` impl closure's value gets properly dropped +//! (during unwind as well). + //@ run-pass //@ needs-unwind //@ ignore-backends: gcc diff --git a/tests/ui/drop/panic-during-slice-init.rs b/tests/ui/drop/panic-during-slice-init.rs index 09b832bb59d02..ddf1e01dd8e7a 100644 --- a/tests/ui/drop/panic-during-slice-init.rs +++ b/tests/ui/drop/panic-during-slice-init.rs @@ -1,9 +1,9 @@ -//@ run-pass -// Regression test for Issue #30018. This is very similar to the -// original reported test, except that the panic is wrapped in a -// spawned thread to isolate the expected error result from the -// SIGTRAP injected by the drop-flag consistency checking. +//! Regression test for . +//! This is very similar to the original reported test, except that the +//! panic is wrapped in a spawned thread to isolate the expected error +//! result from the SIGTRAP injected by the drop-flag consistency checking. +//@ run-pass //@ needs-unwind //@ needs-threads //@ ignore-backends: gcc diff --git a/tests/ui/privacy/fn-returns-unnameable-type.rs b/tests/ui/privacy/fn-returns-unnameable-type.rs index 76b9429329631..1e4474cfafefa 100644 --- a/tests/ui/privacy/fn-returns-unnameable-type.rs +++ b/tests/ui/privacy/fn-returns-unnameable-type.rs @@ -1,5 +1,6 @@ +//! Regression test for . +//! Test functions can return unnameable types. //@ run-pass -// Functions can return unnameable types mod m1 { mod m2 { diff --git a/tests/ui/resolve/impl-method-cant-capture-env.rs b/tests/ui/resolve/impl-method-cant-capture-env.rs index f1630afe1730e..57ef5b83e2ccb 100644 --- a/tests/ui/resolve/impl-method-cant-capture-env.rs +++ b/tests/ui/resolve/impl-method-cant-capture-env.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Ensure upvars from fn cannot be used in impl method block body. + fn siphash(k0 : u64) { struct SipHash { diff --git a/tests/ui/resolve/impl-method-cant-capture-env.stderr b/tests/ui/resolve/impl-method-cant-capture-env.stderr index 48777fec0a3ff..360598dee5827 100644 --- a/tests/ui/resolve/impl-method-cant-capture-env.stderr +++ b/tests/ui/resolve/impl-method-cant-capture-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021-b.rs:9:22 + --> $DIR/impl-method-cant-capture-env.rs:12:22 | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ diff --git a/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs index a672261f8d681..29c4ca07c22f2 100644 --- a/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs +++ b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Test accessing upvars in impl trait for type method is forbidden. + trait SipHash { fn reset(&self); } diff --git a/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr index 5dc4f9542fee5..2c25f6b1b8954 100644 --- a/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr +++ b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021.rs:12:22 + --> $DIR/impl-trait-for-type-cant-capture-env.rs:15:22 | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ diff --git a/tests/ui/resolve/outer-generic-in-trait-method.rs b/tests/ui/resolve/outer-generic-in-trait-method.rs index bd21d1244235d..a31062f480463 100644 --- a/tests/ui/resolve/outer-generic-in-trait-method.rs +++ b/tests/ui/resolve/outer-generic-in-trait-method.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Test we can't use outer generic param in trait method defined in fn body. + fn siphash() { trait U { diff --git a/tests/ui/resolve/outer-generic-in-trait-method.stderr b/tests/ui/resolve/outer-generic-in-trait-method.stderr index d521d4f4a73ae..f85b9623a52f3 100644 --- a/tests/ui/resolve/outer-generic-in-trait-method.stderr +++ b/tests/ui/resolve/outer-generic-in-trait-method.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-3021-c.rs:4:24 + --> $DIR/outer-generic-in-trait-method.rs:7:24 | LL | fn siphash() { | - type parameter from outer item @@ -16,7 +16,7 @@ LL | trait U { | +++ error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-3021-c.rs:4:30 + --> $DIR/outer-generic-in-trait-method.rs:7:30 | LL | fn siphash() { | - type parameter from outer item diff --git a/tests/ui/resolve/trait-impl-cant-capture-env.rs b/tests/ui/resolve/trait-impl-cant-capture-env.rs index 1fb0002b2fc73..751e49f9863c9 100644 --- a/tests/ui/resolve/trait-impl-cant-capture-env.rs +++ b/tests/ui/resolve/trait-impl-cant-capture-env.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Ensure upvars from fn cannot be used in impl method block body. + trait SipHash { fn result(&self) -> u64; fn reset(&self); diff --git a/tests/ui/resolve/trait-impl-cant-capture-env.stderr b/tests/ui/resolve/trait-impl-cant-capture-env.stderr index 39e6e8c43e944..3c80960a235cb 100644 --- a/tests/ui/resolve/trait-impl-cant-capture-env.stderr +++ b/tests/ui/resolve/trait-impl-cant-capture-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021-d.rs:21:23 + --> $DIR/trait-impl-cant-capture-env.rs:24:23 | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ @@ -7,7 +7,7 @@ LL | self.v0 = k0 ^ 0x736f6d6570736575; = help: use the `|| { ... }` closure form instead error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021-d.rs:22:23 + --> $DIR/trait-impl-cant-capture-env.rs:25:23 | LL | self.v1 = k1 ^ 0x646f72616e646f6d; | ^^ From ba53d1b1cca6ea33ac96e3f99ab15f5de8580cf4 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 3 Jul 2026 13:36:47 +1000 Subject: [PATCH 16/42] Add some more AST size assertions --- compiler/rustc_ast/src/ast.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index bd5ce5d18b839..8a2a707b5ad2f 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -4391,27 +4391,37 @@ mod size_asserts { // tidy-alphabetical-start static_assert_size!(AssocItem, 80); static_assert_size!(AssocItemKind, 16); + static_assert_size!(AttrKind, 16); static_assert_size!(Attribute, 32); static_assert_size!(Block, 32); static_assert_size!(Expr, 72); static_assert_size!(ExprKind, 40); static_assert_size!(Fn, 192); + static_assert_size!(FnDecl, 24); + static_assert_size!(FnHeader, 76); + static_assert_size!(FnSig, 96); static_assert_size!(ForeignItem, 80); static_assert_size!(ForeignItemKind, 16); static_assert_size!(GenericArg, 24); + static_assert_size!(GenericArgs, 40); static_assert_size!(GenericBound, 88); + static_assert_size!(GenericParam, 96); static_assert_size!(Generics, 40); static_assert_size!(Impl, 80); static_assert_size!(Item, 152); static_assert_size!(ItemKind, 88); + static_assert_size!(Lifetime, 16); static_assert_size!(LitKind, 24); static_assert_size!(Local, 96); + static_assert_size!(MetaItem, 88); + static_assert_size!(MetaItemKind, 40); static_assert_size!(MetaItemLit, 40); static_assert_size!(Param, 40); static_assert_size!(Pat, 80); static_assert_size!(PatKind, 56); static_assert_size!(Path, 24); static_assert_size!(PathSegment, 24); + static_assert_size!(QSelf, 24); static_assert_size!(Stmt, 32); static_assert_size!(StmtKind, 16); static_assert_size!(TraitImplHeader, 72); From b14e429dfb352c04e5e328315a9056c429d7540a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 3 Jul 2026 13:07:47 +1000 Subject: [PATCH 17/42] Use `ThinVec` in `Expr::OffsetOf` Because we use `ThinVec` rather than `Vec` almost everywhere else in the AST. --- compiler/rustc_ast/src/ast.rs | 2 +- compiler/rustc_ast/src/visit.rs | 1 + compiler/rustc_parse/src/parser/expr.rs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 8a2a707b5ad2f..fff4d8e7ea799 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1868,7 +1868,7 @@ pub enum ExprKind { /// /// Usually not written directly in user code but /// indirectly via the macro `core::mem::offset_of!(...)`. - OffsetOf(Box, Vec), + OffsetOf(Box, ThinVec), /// A macro invocation; pre-expansion. MacCall(Box), diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 1e96d1d52f7eb..8b96bbde82215 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -386,6 +386,7 @@ macro_rules! common_visitor_and_walkers { impl_visitable_list!(<$($lt)? $($mut)?> ThinVec, ThinVec, + ThinVec, ThinVec<(Ident, Option)>, ThinVec<(NodeId, Path)>, ThinVec, diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 60a94345c5325..df1877b82cb93 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1154,8 +1154,8 @@ impl<'a> Parser<'a> { /// Parse the field access used in offset_of, matched by `$(e:expr)+`. /// Currently returns a list of idents. However, it should be possible in /// future to also do array indices, which might be arbitrary expressions. - pub(crate) fn parse_floating_field_access(&mut self) -> PResult<'a, Vec> { - let mut fields = Vec::new(); + pub(crate) fn parse_floating_field_access(&mut self) -> PResult<'a, ThinVec> { + let mut fields = ThinVec::new(); let mut trailing_dot = None; loop { From 3a0a97727d174905858f88d06eba9d651a46f8eb Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 3 Jul 2026 13:24:25 +1000 Subject: [PATCH 18/42] Use `ThinVec` in `GenericBounds` Because we use `ThinVec` rather than `Vec` almost everywhere else in the AST. --- compiler/rustc_ast/src/ast.rs | 6 +++--- compiler/rustc_ast/src/visit.rs | 1 + compiler/rustc_builtin_macros/src/deriving/debug.rs | 2 +- .../rustc_builtin_macros/src/deriving/generic/mod.rs | 6 +++--- compiler/rustc_parse/src/parser/generics.rs | 12 ++++++------ compiler/rustc_parse/src/parser/item.rs | 5 +++-- compiler/rustc_parse/src/parser/ty.rs | 8 ++++---- compiler/rustc_resolve/src/late/diagnostics.rs | 4 ++-- tests/ui/stats/input-stats.stderr | 8 ++++---- 9 files changed, 27 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index fff4d8e7ea799..3e1fff594040e 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -407,7 +407,7 @@ impl GenericBound { } } -pub type GenericBounds = Vec; +pub type GenericBounds = ThinVec; /// Specifies the enforced ordering for generic parameters. In the future, /// if we wanted to relax this order, we could override `PartialEq` and @@ -1534,7 +1534,7 @@ impl Expr { let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) else { return None; }; - TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None) + TyKind::TraitObject(thin_vec![lhs, rhs], TraitObjectSyntax::None) } ExprKind::Underscore => TyKind::Infer, @@ -4405,7 +4405,7 @@ mod size_asserts { static_assert_size!(GenericArg, 24); static_assert_size!(GenericArgs, 40); static_assert_size!(GenericBound, 88); - static_assert_size!(GenericParam, 96); + static_assert_size!(GenericParam, 80); static_assert_size!(Generics, 40); static_assert_size!(Impl, 80); static_assert_size!(Item, 152); diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 8b96bbde82215..fb4e76321d150 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -386,6 +386,7 @@ macro_rules! common_visitor_and_walkers { impl_visitable_list!(<$($lt)? $($mut)?> ThinVec, ThinVec, + ThinVec, ThinVec, ThinVec<(Ident, Option)>, ThinVec<(NodeId, Path)>, diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs index 004b13bcc333d..2436800d0099d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/debug.rs +++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs @@ -167,7 +167,7 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> let ty_dyn_debug = cx.ty( span, ast::TyKind::TraitObject( - vec![cx.trait_bound(path_debug, false)], + thin_vec![cx.trait_bound(path_debug, false)], ast::TraitObjectSyntax::Dyn, ), ); diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index ff6b15b173ed1..1577db640502c 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -617,7 +617,7 @@ impl<'a> TraitDef<'a> { ident, generics: Generics::default(), after_where_clause: ast::WhereClause::default(), - bounds: Vec::new(), + bounds: ThinVec::new(), ty: Some(type_def.to_ty(cx, self.span, type_ident, generics)), })), tokens: None, @@ -639,7 +639,7 @@ impl<'a> TraitDef<'a> { // Extra restrictions on the generics parameters to the // type being derived upon. let span = param.ident.span.with_ctxt(ctxt); - let bounds: Vec<_> = self + let bounds: ThinVec<_> = self .additional_bounds .iter() .map(|p| { @@ -723,7 +723,7 @@ impl<'a> TraitDef<'a> { { continue; } - let mut bounds: Vec<_> = self + let mut bounds: ThinVec<_> = self .additional_bounds .iter() .map(|p| { diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index e2df607fd0f86..506607f57191d 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -26,7 +26,7 @@ impl<'a> Parser<'a> { /// BOUND = LT_BOUND (e.g., `'a`) /// ``` fn parse_lt_param_bounds(&mut self) -> GenericBounds { - let mut lifetimes = Vec::new(); + let mut lifetimes = ThinVec::new(); while self.check_lifetime() { lifetimes.push(ast::GenericBound::Outlives(self.expect_lifetime())); @@ -86,7 +86,7 @@ impl<'a> Parser<'a> { } self.parse_generic_bounds()? } else { - Vec::new() + ThinVec::new() }; let default = if self.eat(exp!(Eq)) { Some(self.parse_ty()?) } else { None }; @@ -125,7 +125,7 @@ impl<'a> Parser<'a> { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, - bounds: Vec::new(), + bounds: ThinVec::new(), kind: GenericParamKind::Const { ty, span, default: None }, is_placeholder: false, colon_span: None, @@ -148,7 +148,7 @@ impl<'a> Parser<'a> { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, - bounds: Vec::new(), + bounds: ThinVec::new(), kind: GenericParamKind::Const { ty, span, default }, is_placeholder: false, colon_span: None, @@ -189,7 +189,7 @@ impl<'a> Parser<'a> { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, - bounds: Vec::new(), + bounds: ThinVec::new(), kind: GenericParamKind::Const { ty, span, default }, is_placeholder: false, colon_span: None, @@ -225,7 +225,7 @@ impl<'a> Parser<'a> { let (colon_span, bounds) = if this.eat(exp!(Colon)) { (Some(this.prev_token.span), this.parse_lt_param_bounds()) } else { - (None, Vec::new()) + (None, ThinVec::new()) }; if this.check_noexpect(&token::Eq) && this.look_ahead(1, |t| t.is_lifetime()) { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 16fed9c6c273b..6f5c4c874d83b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1135,7 +1135,7 @@ impl<'a> Parser<'a> { // Parse optional colon and supertrait bounds. let had_colon = self.eat(exp!(Colon)); let span_at_colon = self.prev_token.span; - let bounds = if had_colon { self.parse_generic_bounds()? } else { Vec::new() }; + let bounds = if had_colon { self.parse_generic_bounds()? } else { ThinVec::new() }; let span_before_eq = self.prev_token.span; if self.eat(exp!(Eq)) { @@ -1253,7 +1253,8 @@ impl<'a> Parser<'a> { let mut generics = self.parse_generics()?; // Parse optional colon and param bounds. - let bounds = if self.eat(exp!(Colon)) { self.parse_generic_bounds()? } else { Vec::new() }; + let bounds = + if self.eat(exp!(Colon)) { self.parse_generic_bounds()? } else { ThinVec::new() }; generics.where_clause = self.parse_where_clause()?; let ty = if self.eat(exp!(Eq)) { Some(self.parse_ty()?) } else { None }; diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 8a881c6f8b568..9c873711e2f87 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -576,7 +576,7 @@ impl<'a> Parser<'a> { lo.to(self.prev_token.span), parens, ); - let bounds = vec![GenericBound::Trait(poly_trait_ref)]; + let bounds = thin_vec![GenericBound::Trait(poly_trait_ref)]; self.parse_remaining_bounds(bounds, parse_plus) } @@ -1080,7 +1080,7 @@ impl<'a> Parser<'a> { /// Only if `allow_plus` this parses a `+`-separated list of bounds (trailing `+` is admitted). /// Otherwise, this only parses a single bound or none. fn parse_generic_bounds_common(&mut self, allow_plus: AllowPlus) -> PResult<'a, GenericBounds> { - let mut bounds = Vec::new(); + let mut bounds = ThinVec::new(); // In addition to looping while we find generic bounds: // We continue even if we find a keyword. This is necessary for error recovery on, @@ -1432,7 +1432,7 @@ impl<'a> Parser<'a> { // Someone has written something like `&dyn (Trait + Other)`. The correct code // would be `&(dyn Trait + Other)` if self.token.is_like_plus() && leading_token.is_keyword(kw::Dyn) { - let bounds = vec![]; + let bounds = thin_vec![]; self.parse_remaining_bounds(bounds, true)?; self.expect(exp!(CloseParen))?; self.dcx().emit_err(errors::IncorrectParensTraitBounds { @@ -1617,7 +1617,7 @@ impl<'a> Parser<'a> { id: lt.id, ident: lt.ident, attrs: ast::AttrVec::new(), - bounds: Vec::new(), + bounds: ThinVec::new(), is_placeholder: false, kind: ast::GenericParamKind::Lifetime, colon_span: None, diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 8c5c7f5b2d76d..668278f13d9cf 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -28,7 +28,7 @@ use rustc_session::{Session, lint}; use rustc_span::edit_distance::{edit_distance, find_best_match_for_name}; use rustc_span::edition::Edition; use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym}; -use thin_vec::ThinVec; +use thin_vec::{ThinVec, thin_vec}; use tracing::debug; use super::NoConstantGenericsReason; @@ -4522,7 +4522,7 @@ fn mk_where_bound_predicate( let new_where_bound_predicate = ast::WhereBoundPredicate { bound_generic_params: ThinVec::new(), bounded_ty: Box::new(ty.clone()), - bounds: vec![ast::GenericBound::Trait(ast::PolyTraitRef { + bounds: thin_vec![ast::GenericBound::Trait(ast::PolyTraitRef { bound_generic_params: ThinVec::new(), modifiers: ast::TraitBoundModifiers::NONE, trait_ref: ast::TraitRef { diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index b4d8277a46c00..f4c6808431687 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -27,7 +27,7 @@ ast-stats Pat 560 (NN.N%) 7 80 ast-stats - Struct 80 (NN.N%) 1 ast-stats - Wild 80 (NN.N%) 1 ast-stats - Ident 400 (NN.N%) 5 -ast-stats GenericParam 480 (NN.N%) 5 96 +ast-stats GenericParam 400 (NN.N%) 5 80 ast-stats GenericBound 352 (NN.N%) 4 88 ast-stats - Trait 352 (NN.N%) 4 ast-stats AssocItem 320 (NN.N%) 4 80 @@ -50,14 +50,14 @@ ast-stats Local 96 (NN.N%) 1 96 ast-stats Arm 96 (NN.N%) 2 48 ast-stats ForeignItem 80 (NN.N%) 1 80 ast-stats - Fn 80 (NN.N%) 1 -ast-stats WherePredicate 72 (NN.N%) 1 72 -ast-stats - BoundPredicate 72 (NN.N%) 1 +ast-stats WherePredicate 56 (NN.N%) 1 56 +ast-stats - BoundPredicate 56 (NN.N%) 1 ast-stats ExprField 48 (NN.N%) 1 48 ast-stats GenericArgs 40 (NN.N%) 1 40 ast-stats - AngleBracketed 40 (NN.N%) 1 ast-stats Crate 40 (NN.N%) 1 40 ast-stats ---------------------------------------------------------------- -ast-stats Total 7_624 127 +ast-stats Total 7_528 127 ast-stats ================================================================ hir-stats ================================================================ hir-stats HIR STATS: input_stats From 27935a6a54a417dfea0c6b2f79c28ea255c67df0 Mon Sep 17 00:00:00 2001 From: Sylvester Kpei Date: Fri, 3 Jul 2026 19:47:41 -0700 Subject: [PATCH 19/42] Fix incorrect tracking issue link for read_le/read_be The unstable attribute on Read::read_le and Read::read_be pointed to the implementation PR rather than the tracking issue, so the docs on doc.rust-lang.org linked to the wrong page. --- library/std/src/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index dc623a3e82c2c..6396be588c0ff 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1294,7 +1294,7 @@ pub trait Read { /// Ok(()) /// } /// ``` - #[unstable(feature = "read_le", issue = "156983")] + #[unstable(feature = "read_le", issue = "156984")] #[inline] fn read_le(&mut self) -> Result where @@ -1327,7 +1327,7 @@ pub trait Read { /// Ok(()) /// } /// ``` - #[unstable(feature = "read_le", issue = "156983")] + #[unstable(feature = "read_le", issue = "156984")] #[inline] fn read_be(&mut self) -> Result where From 4c7acb4cf835e84f1fb486d3d865f565d3722884 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sat, 4 Jul 2026 14:40:58 +0900 Subject: [PATCH 20/42] add rustdoc-ui regression for non-ident doc auto_cfg values --- tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs | 7 +++++++ tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs create mode 100644 tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr diff --git a/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs new file mode 100644 index 0000000000000..213a804b8b63e --- /dev/null +++ b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs @@ -0,0 +1,7 @@ +// Regression test for https://github.com/rust-lang/rust/issues/158744. + +#![feature(doc_cfg)] + +#[doc(auto_cfg(hide(a, values(::b))))] +//~^ ERROR malformed `doc` attribute input +fn f() {} diff --git a/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr new file mode 100644 index 0000000000000..8c08c5ed4226d --- /dev/null +++ b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr @@ -0,0 +1,11 @@ +error[E0565]: malformed `doc` attribute input + --> $DIR/doc-auto-cfg-values-non-ident.rs:5:1 + | +LL | #[doc(auto_cfg(hide(a, values(::b))))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^^ + | | + | expected a valid identifier here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0565`. From 86960f5e13eb93f3793c39a523dbdfe76d32f849 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sat, 4 Jul 2026 14:41:21 +0900 Subject: [PATCH 21/42] handle non-ident doc auto_cfg values without panicking --- compiler/rustc_attr_parsing/src/attributes/doc.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 23eef6334ccee..9b03792057b33 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -348,8 +348,11 @@ impl DocParser { // If it's a list, then only `any()` and `none()` are allowed and they must not // contain any item. MetaItemOrLitParser::MetaItemParser(sub_item) => { - if let Some(ident) = sub_item.ident() - && [sym::any, sym::none].contains(&ident.name) + let Some(ident) = sub_item.ident() else { + cx.adcx().expected_identifier(sub_item.path().span()); + continue; + }; + if [sym::any, sym::none].contains(&ident.name) && let ArgParser::List(list) = sub_item.args() && list.mixed().count() == 0 { @@ -371,9 +374,7 @@ impl DocParser { } else { cx.emit_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - DocAutoCfgHideShowUnexpectedItem { - attr_name: sub_item.ident().unwrap().name, - }, + DocAutoCfgHideShowUnexpectedItem { attr_name: ident.name }, sub_item.span(), ); } From c341ff552bdc30be78db9603e0519819561865bc Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 10:59:05 +0200 Subject: [PATCH 22/42] sembr src/analysis/well-formed.md --- .../src/analysis/well-formed.md | 88 +++++++++++++------ 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md index 49c9509fea466..464ffce817369 100644 --- a/src/doc/rustc-dev-guide/src/analysis/well-formed.md +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -2,7 +2,8 @@ ## What is Well-Formedness? -"Well-formed" means "correctly built."[^wf-history] Something is _well-formed_ when its structure follows rules. When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. +"Well-formed" means "correctly built."[^wf-history] Something is _well-formed_ when its structure follows rules. +When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. ## Well-Formedness in Rust @@ -12,7 +13,7 @@ In the Rust compiler there are two different forms of well-formedness checking: - **Type-Level Term**[^terms][^terms-abbreviated] well-formedness check. - Also called "Term well-formedness" or "Term well-formedness checking." - - Not a distinct analysis stage, this gets performed throughout analysis. + - Not a distinct analysis stage, this gets performed throughout analysis. - **Item**[^items] well-formedness check (item-wfck.) - "Item-wfck" will often wind up requiring Terms be well-formed, but skips some areas. - Inner "Terms" can (incorrectly) get normalized first. @@ -22,7 +23,8 @@ See: [What Well-Formedness Isn't](#what-well-formedness-isnt). ## Well-Formedness of Type-Level Terms -Term well-formedness checking begins with building a list of things that need to be true for a term to be well-formed. We call these "Obligations"[^obligations]. +Term well-formedness checking begins with building a list of things that need to be true for a term to be well-formed. +We call these "Obligations"[^obligations]. Type-Level Terms are considered Well-Formed when their associated obligations are satisfied by the trait solver. @@ -49,7 +51,8 @@ Vec where T: Sized Vec where String: Sized ``` -When we compute the obligations for `Vec`, we'll find that `Vec` generates the obligation `T: Sized`. We substitute `T` with `String` in `Vec`, so we find the obligation `String: Sized` which the trait solver will determine to be satisfied. +When we compute the obligations for `Vec`, we'll find that `Vec` generates the obligation `T: Sized`. +We substitute `T` with `String` in `Vec`, so we find the obligation `String: Sized` which the trait solver will determine to be satisfied. The following **is not** well-formed: @@ -62,7 +65,8 @@ Vec where T: Sized Vec where str: Sized ``` -The above computes the obligation `T: Sized`, like before, but we substitute `T` for `str` in the instance of `Vec` finding the obligation `str: sized`. This obligation will be determined by the trait solver to be _unsatisfied_. +The above computes the obligation `T: Sized`, like before, but we substitute `T` for `str` in the instance of `Vec` finding the obligation `str: sized`. +This obligation will be determined by the trait solver to be _unsatisfied_. #### Determining Obligations @@ -70,17 +74,20 @@ In the compiler, obligations of terms are found through the [`obligations`](http #### Other Obligations -Obligations are more than just trait and const generic bounds, but we've only mentioned these specific obligations so far as they are what we care about when we do "well-formedness checking" of terms. See: [`PredicateKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.PredicateKind.html) and [`ClauseKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.ClauseKind.html) for a full list of obligations. +Obligations are more than just trait and const generic bounds, but we've only mentioned these specific obligations so far as they are what we care about when we do "well-formedness checking" of terms. +See: [`PredicateKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.PredicateKind.html) and [`ClauseKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.ClauseKind.html) for a full list of obligations. ### We Don't Need Normalization (Yet) -[Normalization](../normalization.md) is the process of resolving [type aliases](../normalization.md#aliases) into their underlying type. +[Normalization](../normalization.md) is the process of resolving [type aliases](../normalization.md#aliases) into their underlying type. -A type alias is considered well-formed if its where clauses are satisfied. The underlying type undergoes well-formedness checking at most definition and instantiation sites, but there are exceptions. +A type alias is considered well-formed if its where clauses are satisfied. +The underlying type undergoes well-formedness checking at most definition and instantiation sites, but there are exceptions. ### Const Generic Arguments -Term well-formedness is responsible for getting "type checking" obligations of const generic terms[^tyck-const-generics]. Let's look at the following use of const generics: +Term well-formedness is responsible for getting "type checking" obligations of const generic terms[^tyck-const-generics]. +Let's look at the following use of const generics: ```rust,ignore fn use_const_generics() { /* ... */ } @@ -91,7 +98,8 @@ use_const_generics::<6>(); const 6: usize ``` -The call site will provide us with the obligation `6: usize` during well-formedness checking. This obligation will be passed off to the trait solver just like any trait-style obligation, as the trait solver has more responsibilities than its name suggests. +The call site will provide us with the obligation `6: usize` during well-formedness checking. +This obligation will be passed off to the trait solver just like any trait-style obligation, as the trait solver has more responsibilities than its name suggests. ## Well-Formedness of Items @@ -108,7 +116,8 @@ Vec: Sized // Generated Vec<[u8]>: Sized // Not done at item-wfck. Done elsewhere. ``` -Item-wfck has more responsibilities than only collecting the obligations of its internal type-level terms and passing them to the trait solver. We do not talk about all of these here, but they can be found at the individual `check_*` functions in [**the item-wfck module**](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/check/wfcheck/index.html). +Item-wfck has more responsibilities than only collecting the obligations of its internal type-level terms and passing them to the trait solver. +We do not talk about all of these here, but they can be found at the individual `check_*` functions in [**the item-wfck module**](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/check/wfcheck/index.html). @@ -116,7 +125,9 @@ Item-wfck has more responsibilities than only collecting the obligations of its -Trait bounds are a common Obligation. Global and Trivial trait bounds are kinds of trait bounds where we already have enough information to determine if they are true or false. Item-wfck is responsible for finding and checking these bounds. +Trait bounds are a common Obligation. +Global and Trivial trait bounds are kinds of trait bounds where we already have enough information to determine if they are true or false. +Item-wfck is responsible for finding and checking these bounds. - **Global bounds** are, in the old solver, post-normalization bounds that don't contain any generic parameters (likeΒ `` or `'a`) or bound variables (like `for<'b>`). - **Trivial bounds** are bounds that do not need further normalization to determine if they're well-formed or not. @@ -130,9 +141,11 @@ String: Clone // Trivial & Global bound! There's no aliases to resolve. // There could be bligations on T but we don't care about them here. ``` -This produces a trait bound obligation `String: Clone` that is _Global_ (no generic parameters) and _Trivial_ (didn't require normalization to be well-formedness checked). The trait solver doesn't need to be given any additional information for it to be able to make a judgment on the well-formedness of `String: Clone`. +This produces a trait bound obligation `String: Clone` that is _Global_ (no generic parameters) and _Trivial_ (didn't require normalization to be well-formedness checked). +The trait solver doesn't need to be given any additional information for it to be able to make a judgment on the well-formedness of `String: Clone`. -False trivial bounds are simply trivial bounds that do not hold. The following is a basic example: +False trivial bounds are simply trivial bounds that do not hold. +The following is a basic example: ```rust,ignore fn apartment_simple(block: T, name: String) where String: Copy { /* ... */ } @@ -144,7 +157,8 @@ Here we have a trivial bound that does not hold, because `String` is not `Copy`. #### Trivial Bounds Are Not Always Global -Trivial Bounds are not a subset of Global Bounds. A trivial bound that isn't Global is `for<'a> String: Clone` (trivially true, has a bound variable) or `&'a str: Copy` (trivially false, has a generic parameter). +Trivial Bounds are not a subset of Global Bounds. +A trivial bound that isn't Global is `for<'a> String: Clone` (trivially true, has a bound variable) or `&'a str: Copy` (trivially false, has a generic parameter). #### Item-Wfck and Trivial/Global Bounds @@ -154,15 +168,19 @@ When checking items are well-formed we will check that there are no trivially fa ## When We Don't Fully Do Well-Formedness Checking -Well-formedness checking is not a coherent "stage" of type checking. There are many areas where well-formedness checking is performed, and some areas where we skip over well-formedness checking due to limitations in what kinds of analysis we can currently perform. Ideally, we would never skip or defer well-formedness checking. +Well-formedness checking is not a coherent "stage" of type checking. +There are many areas where well-formedness checking is performed, and some areas where we skip over well-formedness checking due to limitations in what kinds of analysis we can currently perform. +Ideally, we would never skip or defer well-formedness checking. ### We (Sometimes) Need Normalization -There are places where normalization of an Item happens before its Terms have gone through well-formedness checking. This is considered problematic as doing so allows some terms to [bypass term well-formedness checking entirely](https://github.com/rust-lang/rust/issues/100041). +There are places where normalization of an Item happens before its Terms have gone through well-formedness checking. +This is considered problematic as doing so allows some terms to [bypass term well-formedness checking entirely](https://github.com/rust-lang/rust/issues/100041). ### Trait Objects -We do not require the where clauses of trait objects to be well-formed when determining if that trait object is well-formed. These where clauses are proven when coercing into a trait object, but this remains a hole in well-formedness checking. +We do not require the where clauses of trait objects to be well-formed when determining if that trait object is well-formed. +These where clauses are proven when coercing into a trait object, but this remains a hole in well-formedness checking. As an example, the following will compile because we don't have a point where we're constructing the trait object from a concrete type: @@ -211,7 +229,8 @@ N = B // Substitution const B: usize + bool ``` -The above doesn't compile, unlike the previous example we gave. We're doing _some_ well-formedness checking here when it comes to the const generic arguments. +The above doesn't compile, unlike the previous example we gave. +We're doing _some_ well-formedness checking here when it comes to the const generic arguments. ### Binders / Higher-Ranked Types @@ -224,9 +243,11 @@ let _: for<'a> fn(Vec<[&'a ()]>); [&'a ()]: Sized // slices aren't sized, this would fail! ``` -Specifically, obligations involving variables from binders (`for<'a>`) are only checked when the binder is instantiated. Some things are stilled checked under the `for<'a>`, but we still skip a lot of things. +Specifically, obligations involving variables from binders (`for<'a>`) are only checked when the binder is instantiated. +Some things are stilled checked under the `for<'a>`, but we still skip a lot of things. -A lot of unsoundness surrounds this behavior. See: [#25860](https://github.com/rust-lang/rust/issues/25860), [#84591](https://github.com/rust-lang/rust/issues/84591). +A lot of unsoundness surrounds this behavior. +See: [#25860](https://github.com/rust-lang/rust/issues/25860), [#84591](https://github.com/rust-lang/rust/issues/84591). Let's consider the following: @@ -234,7 +255,8 @@ Let's consider the following: for<'a, 'b> fn(&'a &'b ()) ``` -The above HRB implies `'b: 'a` (a lifetime bound), rather than two completely separate lifetimes. This is normal lifetime behavior, but during well-formedness checking we cannot prove that this bound is generally true[^horrible], so we skip it. +The above HRB implies `'b: 'a` (a lifetime bound), rather than two completely separate lifetimes. +This is normal lifetime behavior, but during well-formedness checking we cannot prove that this bound is generally true[^horrible], so we skip it. ### Free Type Aliases @@ -249,9 +271,12 @@ type WorksButShouldNot = Vec; str: Sized // Not generated ``` -This shouldn't work, as both `T: Sized`, `str: Sized` are implied by `Vec`. This "passes" item-wfck because the RHS of a free type alias doesn't go through well-formedness checking _until it's used_. Item-wfck is **deferred until use** for this specific case. +This shouldn't work, as both `T: Sized`, `str: Sized` are implied by `Vec`. +This "passes" item-wfck because the RHS of a free type alias doesn't go through well-formedness checking _until it's used_. +Item-wfck is **deferred until use** for this specific case. -For Const Generics we still do a small amount of well-formedness checking at the definition site of a free type alias. This is consistent with our current special-casing of const generic well-formedness checking when we skip over things like where bounds. +For Const Generics we still do a small amount of well-formedness checking at the definition site of a free type alias. +This is consistent with our current special-casing of const generic well-formedness checking when we skip over things like where bounds. This means that the following, despite being of a similar form to the above example, fails as it should: @@ -267,19 +292,24 @@ type Alias = Consty<42>; ## "Well-Formed" or "Wellformed"? -Prefer "well-formed" over "wellformed," as this is consistent with logic literature. This also gets abbreviated to WF in other parts of the dev guide / docs. +Prefer "well-formed" over "wellformed," as this is consistent with logic literature. +This also gets abbreviated to WF in other parts of the dev guide / docs. ## Informal Usage -In conversation, contributors may refer to something as "well-formed" and not necessarily mean what we cover here because "well-formedness" is a general phrase associated with the correctness of formal structures. This isn't necessarily in error, but it should be looked out for. +In conversation, contributors may refer to something as "well-formed" and not necessarily mean what we cover here because "well-formedness" is a general phrase associated with the correctness of formal structures. +This isn't necessarily in error, but it should be looked out for. ## What Well-Formedness Isn't -Well-formedness checking is not "number of parameters" or "parameter type" checking[^kind-checking]. Neither term well-formedness checking nor item-wfck is concerned with if a type with 2 parameters has 1 or 3 types applied to it (assuming no defaults), or if a const generic parameter has a type applied to it. These kinds of problems will get handled during HIR-ty Lowering[^hir-ty-lower], not wfck. +Well-formedness checking is not "number of parameters" or "parameter type" checking[^kind-checking]. +Neither term well-formedness checking nor item-wfck is concerned with if a type with 2 parameters has 1 or 3 types applied to it (assuming no defaults), or if a const generic parameter has a type applied to it. +These kinds of problems will get handled during HIR-ty Lowering[^hir-ty-lower], not wfck. Well-formedness doesn't check or validate lifetimes, this is handled in [MIR](../borrow-check.md). -Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as it does in logic. The term has a history of general use in a mathematical context of "follows a given set of rules." In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). +Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as it does in logic. +The term has a history of general use in a mathematical context of "follows a given set of rules." In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). [^obligations]: These get referred to as Obligations, Requirements, or Constraints in the documentation. Preferred term is "obligations", as this matches the suffix of the type and the names of relevant functions. In future, this may be superseded by the new solver's term "Goal." [^wf-history]: In linguistics this is "grammatically correct," in logic it is "syntactically correct," and in casual mathematician use it can be read as a more general "follows the rules we set for this domain." @@ -290,4 +320,4 @@ Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as i [^terms-abbreviated]: Abbreviated as "Terms" on this page in some areas. [^kind-checking]: AKA "kind checking", as we might see in languages like Haskell. [^hir-ty-lower]: -[^tyck-const-generics]: \ No newline at end of file +[^tyck-const-generics]: From ccec2e040b53fb9e84e7604095e97a4c3ac397df Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 11:07:58 +0200 Subject: [PATCH 23/42] fix misplaced quotes --- .../src/analysis/well-formed.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md index 464ffce817369..b50063072d71a 100644 --- a/src/doc/rustc-dev-guide/src/analysis/well-formed.md +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -2,17 +2,17 @@ ## What is Well-Formedness? -"Well-formed" means "correctly built."[^wf-history] Something is _well-formed_ when its structure follows rules. +"Well-formed" means "correctly built"[^wf-history]. Something is _well-formed_ when its structure follows rules. When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. ## Well-Formedness in Rust -To check that something is well-formed is to perform a "Well-formedness check." +To check that something is well-formed is to perform a "Well-formedness check". In the Rust compiler there are two different forms of well-formedness checking: - **Type-Level Term**[^terms][^terms-abbreviated] well-formedness check. - - Also called "Term well-formedness" or "Term well-formedness checking." + - Also called "Term well-formedness" or "Term well-formedness checking". - Not a distinct analysis stage, this gets performed throughout analysis. - **Item**[^items] well-formedness check (item-wfck.) - "Item-wfck" will often wind up requiring Terms be well-formed, but skips some areas. @@ -103,7 +103,7 @@ This obligation will be passed off to the trait solver just like any trait-style ## Well-Formedness of Items -Items are, generally speaking, "Things that get defined." Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. +Items are, generally speaking, "Things that get defined". Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. ```rust,ignore // The `Vec` is checked during item wfck @@ -186,7 +186,7 @@ As an example, the following will compile because we don't have a point where we ```rust,ignore trait Trait -where +where for<'a> [u8]: Sized {} fn foo(_: &dyn Trait) {} @@ -199,13 +199,13 @@ The above should not compile because `[u8]: Sized`, but this won't be checked un ```rust trait Trait -where +where for<'a> [u8]: Sized {} - + fn foo(_: &dyn Trait) {} // We still need to specify the bound here, otherwise `[u8]: Sized` _is_ -// checked as an obligation. +// checked as an obligation. impl Trait for u8 where for<'a> [u8]: Sized {} fn main() { @@ -226,7 +226,7 @@ fn foo(_: &dyn Trait) {} const N: usize const B: bool N = B // Substitution -const B: usize + bool +const B: usize + bool ``` The above doesn't compile, unlike the previous example we gave. @@ -292,7 +292,7 @@ type Alias = Consty<42>; ## "Well-Formed" or "Wellformed"? -Prefer "well-formed" over "wellformed," as this is consistent with logic literature. +Prefer "well-formed" over "wellformed", as this is consistent with logic literature. This also gets abbreviated to WF in other parts of the dev guide / docs. ## Informal Usage @@ -309,10 +309,10 @@ These kinds of problems will get handled during HIR-ty Lowering[^hir-ty-lower], Well-formedness doesn't check or validate lifetimes, this is handled in [MIR](../borrow-check.md). Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as it does in logic. -The term has a history of general use in a mathematical context of "follows a given set of rules." In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). +The term has a history of general use in a mathematical context of "follows a given set of rules". In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). -[^obligations]: These get referred to as Obligations, Requirements, or Constraints in the documentation. Preferred term is "obligations", as this matches the suffix of the type and the names of relevant functions. In future, this may be superseded by the new solver's term "Goal." -[^wf-history]: In linguistics this is "grammatically correct," in logic it is "syntactically correct," and in casual mathematician use it can be read as a more general "follows the rules we set for this domain." +[^obligations]: These get referred to as Obligations, Requirements, or Constraints in the documentation. Preferred term is "obligations", as this matches the suffix of the type and the names of relevant functions. In future, this may be superseded by the new solver's term "Goal". +[^wf-history]: In linguistics this is "grammatically correct", in logic it is "syntactically correct", and in casual mathematician use it can be read as a more general "follows the rules we set for this domain". [^horrible]: Instead, this bound is checked during "MIR borrowck" when the lifetimes are instantiated. [^fta]: Type aliases not associated with anything, i.e. a module-level `type Alias = Vec;`. [^items]: "Definition" style things in rust, See the [glossary](../appendix/glossary.md). From eefd538c162aed470cf456a8d3e51c5d900a0ca7 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 11:08:08 +0200 Subject: [PATCH 24/42] sembr src/analysis/well-formed.md --- src/doc/rustc-dev-guide/src/analysis/well-formed.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md index b50063072d71a..dc938f22fbe01 100644 --- a/src/doc/rustc-dev-guide/src/analysis/well-formed.md +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -2,7 +2,8 @@ ## What is Well-Formedness? -"Well-formed" means "correctly built"[^wf-history]. Something is _well-formed_ when its structure follows rules. +"Well-formed" means "correctly built"[^wf-history]. +Something is _well-formed_ when its structure follows rules. When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. ## Well-Formedness in Rust @@ -103,7 +104,8 @@ This obligation will be passed off to the trait solver just like any trait-style ## Well-Formedness of Items -Items are, generally speaking, "Things that get defined". Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. +Items are, generally speaking, "Things that get defined". +Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. ```rust,ignore // The `Vec` is checked during item wfck @@ -309,7 +311,8 @@ These kinds of problems will get handled during HIR-ty Lowering[^hir-ty-lower], Well-formedness doesn't check or validate lifetimes, this is handled in [MIR](../borrow-check.md). Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as it does in logic. -The term has a history of general use in a mathematical context of "follows a given set of rules". In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). +The term has a history of general use in a mathematical context of "follows a given set of rules". +In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). [^obligations]: These get referred to as Obligations, Requirements, or Constraints in the documentation. Preferred term is "obligations", as this matches the suffix of the type and the names of relevant functions. In future, this may be superseded by the new solver's term "Goal". [^wf-history]: In linguistics this is "grammatically correct", in logic it is "syntactically correct", and in casual mathematician use it can be read as a more general "follows the rules we set for this domain". From 6b77786795d9e0d6c37c95e83ec3d76a448351f9 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 11:23:00 +0200 Subject: [PATCH 25/42] use sentence case --- src/doc/rustc-dev-guide/src/SUMMARY.md | 2 +- .../src/analysis/well-formed.md | 44 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/SUMMARY.md b/src/doc/rustc-dev-guide/src/SUMMARY.md index 6b17426e165ef..bf2de84575d69 100644 --- a/src/doc/rustc-dev-guide/src/SUMMARY.md +++ b/src/doc/rustc-dev-guide/src/SUMMARY.md @@ -193,7 +193,7 @@ - [Sharing the trait solver with rust-analyzer](./solve/sharing-crates-with-rust-analyzer.md) - [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md) - [Having separate `Trait` and `Projection` bounds](./traits/separate-projection-bounds.md) -- [Well-Formedness](./analysis/well-formed.md) +- [Well-formedness](./analysis/well-formed.md) - [Variance](./variance.md) - [Coherence checking](./coherence.md) - [HIR Type checking](./hir-typeck/summary.md) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md index dc938f22fbe01..df60aa2ec59b7 100644 --- a/src/doc/rustc-dev-guide/src/analysis/well-formed.md +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -1,12 +1,12 @@ -# Well-Formedness +# Well-formedness -## What is Well-Formedness? +## What is well-formedness? "Well-formed" means "correctly built"[^wf-history]. Something is _well-formed_ when its structure follows rules. When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. -## Well-Formedness in Rust +## Well-formedness in Rust To check that something is well-formed is to perform a "Well-formedness check". @@ -22,14 +22,14 @@ In the Rust compiler there are two different forms of well-formedness checking: See: [What Well-Formedness Isn't](#what-well-formedness-isnt). -## Well-Formedness of Type-Level Terms +## Well-formedness of type-level terms Term well-formedness checking begins with building a list of things that need to be true for a term to be well-formed. We call these "Obligations"[^obligations]. -Type-Level Terms are considered Well-Formed when their associated obligations are satisfied by the trait solver. +Type-Level Terms are considered well-formed when their associated obligations are satisfied by the trait solver. -### Obligations for Well-Formedness +### Obligations for well-formedness Specific obligations are things like `String: Clone`, `A: usize`, or `::Item: Debug`. @@ -69,23 +69,23 @@ Vec where str: Sized The above computes the obligation `T: Sized`, like before, but we substitute `T` for `str` in the instance of `Vec` finding the obligation `str: sized`. This obligation will be determined by the trait solver to be _unsatisfied_. -#### Determining Obligations +#### Determining obligations In the compiler, obligations of terms are found through the [`obligations`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/wf/fn.obligations.html) function in the [term well-formedness module](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/wf/index.html). -#### Other Obligations +#### Other obligations Obligations are more than just trait and const generic bounds, but we've only mentioned these specific obligations so far as they are what we care about when we do "well-formedness checking" of terms. See: [`PredicateKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.PredicateKind.html) and [`ClauseKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.ClauseKind.html) for a full list of obligations. -### We Don't Need Normalization (Yet) +### We don't need normalization (yet) [Normalization](../normalization.md) is the process of resolving [type aliases](../normalization.md#aliases) into their underlying type. A type alias is considered well-formed if its where clauses are satisfied. The underlying type undergoes well-formedness checking at most definition and instantiation sites, but there are exceptions. -### Const Generic Arguments +### Const generic arguments Term well-formedness is responsible for getting "type checking" obligations of const generic terms[^tyck-const-generics]. Let's look at the following use of const generics: @@ -102,7 +102,7 @@ const 6: usize The call site will provide us with the obligation `6: usize` during well-formedness checking. This obligation will be passed off to the trait solver just like any trait-style obligation, as the trait solver has more responsibilities than its name suggests. -## Well-Formedness of Items +## Well-formedness of items Items are, generally speaking, "Things that get defined". Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. @@ -123,7 +123,7 @@ We do not talk about all of these here, but they can be found at the individual -### Global and Trivial Bounds +### Global and trivial bounds @@ -157,29 +157,29 @@ String: Copy // Trivial bound again, but this one is false! Here we have a trivial bound that does not hold, because `String` is not `Copy`. -#### Trivial Bounds Are Not Always Global +#### Trivial bounds are not always global Trivial Bounds are not a subset of Global Bounds. A trivial bound that isn't Global is `for<'a> String: Clone` (trivially true, has a bound variable) or `&'a str: Copy` (trivially false, has a generic parameter). -#### Item-Wfck and Trivial/Global Bounds +#### Item-wfck and trivial/global bounds When checking items are well-formed we will check that there are no trivially false global bounds. -## When We Don't Fully Do Well-Formedness Checking +## When we don't fully do well-formedness checking Well-formedness checking is not a coherent "stage" of type checking. There are many areas where well-formedness checking is performed, and some areas where we skip over well-formedness checking due to limitations in what kinds of analysis we can currently perform. Ideally, we would never skip or defer well-formedness checking. -### We (Sometimes) Need Normalization +### We (sometimes) need normalization There are places where normalization of an Item happens before its Terms have gone through well-formedness checking. This is considered problematic as doing so allows some terms to [bypass term well-formedness checking entirely](https://github.com/rust-lang/rust/issues/100041). -### Trait Objects +### Trait objects We do not require the where clauses of trait objects to be well-formed when determining if that trait object is well-formed. These where clauses are proven when coercing into a trait object, but this remains a hole in well-formedness checking. @@ -234,7 +234,7 @@ const B: usize + bool The above doesn't compile, unlike the previous example we gave. We're doing _some_ well-formedness checking here when it comes to the const generic arguments. -### Binders / Higher-Ranked Types +### Binders / higher-ranked types Binders / Higher-Ranked Types reduce the amount well-formedness checking we do on a term, leaving well-formedness checking to when the bound is instantiated: @@ -260,7 +260,7 @@ for<'a, 'b> fn(&'a &'b ()) The above HRB implies `'b: 'a` (a lifetime bound), rather than two completely separate lifetimes. This is normal lifetime behavior, but during well-formedness checking we cannot prove that this bound is generally true[^horrible], so we skip it. -### Free Type Aliases +### Free type aliases The right-hand side of Free Type Aliases[^fta] is not fully checked to be well-formed at the definition site, only the types of const generic arguments in the RHS are checked. @@ -292,17 +292,17 @@ type Alias = Consty<42>; -## "Well-Formed" or "Wellformed"? +## "well-formed" or "wellformed"? Prefer "well-formed" over "wellformed", as this is consistent with logic literature. This also gets abbreviated to WF in other parts of the dev guide / docs. -## Informal Usage +## Informal usage In conversation, contributors may refer to something as "well-formed" and not necessarily mean what we cover here because "well-formedness" is a general phrase associated with the correctness of formal structures. This isn't necessarily in error, but it should be looked out for. -## What Well-Formedness Isn't +## What well-formedness isn't Well-formedness checking is not "number of parameters" or "parameter type" checking[^kind-checking]. Neither term well-formedness checking nor item-wfck is concerned with if a type with 2 parameters has 1 or 3 types applied to it (assuming no defaults), or if a const generic parameter has a type applied to it. From 2452d9d8f0224787c8408727581c7794906be7f2 Mon Sep 17 00:00:00 2001 From: krishna3554 Date: Sat, 4 Jul 2026 00:11:25 +0530 Subject: [PATCH 26/42] Update date-check markers for July 2026 --- src/doc/rustc-dev-guide/src/contributing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index 4e292c5476d1c..0c1feb3f48b3f 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -444,20 +444,20 @@ Just a few things to keep in mind: For the action to pick the date, add a special annotation before specifying the date: ```md - Nov 2025 + Jul 2026 ``` Example: ```md - As of Nov 2025, the foo did the bar. + As of Jul 2026, the foo did the bar. ``` For cases where the date should not be part of the visible rendered output, use the following instead: ```md - + ``` - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide From 5ba2f10884f4874043d98d8300fc9bc4eb394aa4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 11:59:13 +0200 Subject: [PATCH 27/42] less words --- src/doc/rustc-dev-guide/src/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index 4e292c5476d1c..0bfacb017f27c 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -425,7 +425,7 @@ Just a few things to keep in mind: - When contributing text to the guide, please contextualize the information with some time period and/or a reason so that the reader knows how much to trust the information. - Aim to provide a reasonable amount of context, possibly including but not limited to: + Aim to provide a reasonable amount of context, and consider including: - A reason for why the text may be out of date other than "change", as change is a constant across the project. From bae7fbab10e0e7dfba0c9ab8648d395a582fd471 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:10:34 +0200 Subject: [PATCH 28/42] new mdbook now gives this for free Should of been in 6f0ae3e918b9d6bb09761e7d9f4119f387f14675 --- src/doc/rustc-dev-guide/src/contributing.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index 0bfacb017f27c..be0b76af34159 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -464,10 +464,6 @@ Just a few things to keep in mind: further explanation for the change process or a way to verify that the information is not outdated. -- If a text grows rather long (more than a few page scrolls) or complicated (more than four - subsections), it might benefit from having a Table of Contents at the beginning, - which you can auto-generate by including the `` marker at the top. - #### ⚠️ Note: Where to contribute `rustc-dev-guide` changes For detailed information about where to contribute rustc-dev-guide changes and the benefits of doing so, From 769c5bd5a6afd6b4317c5762bb5d6f0e2d821e30 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:20:16 +0200 Subject: [PATCH 29/42] document accepted practice --- src/doc/rustc-dev-guide/src/contributing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index be0b76af34159..c0d44518e9013 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -464,6 +464,10 @@ Just a few things to keep in mind: further explanation for the change process or a way to verify that the information is not outdated. +- Use sentence case for chapter and sections titles. + +- Use dashes (`-`) to separate words file names. + #### ⚠️ Note: Where to contribute `rustc-dev-guide` changes For detailed information about where to contribute rustc-dev-guide changes and the benefits of doing so, From dd200bae9258960d720d19316505cae30fefd6d3 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:39:56 +0200 Subject: [PATCH 30/42] use local --- src/doc/rustc-dev-guide/src/analysis/well-formed.md | 2 +- src/doc/rustc-dev-guide/src/contributing.md | 2 +- src/doc/rustc-dev-guide/src/offload/installation.md | 2 +- .../rustc-dev-guide/src/traits/separate-projection-bounds.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md index df60aa2ec59b7..4a2450a480ed2 100644 --- a/src/doc/rustc-dev-guide/src/analysis/well-formed.md +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -323,4 +323,4 @@ In Rust, our original usage was closer to "this thing is internally consistent" [^terms-abbreviated]: Abbreviated as "Terms" on this page in some areas. [^kind-checking]: AKA "kind checking", as we might see in languages like Haskell. [^hir-ty-lower]: -[^tyck-const-generics]: +[^tyck-const-generics]: #checking-types-of-const-arguments diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index c0d44518e9013..546ce55bda2e5 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -257,7 +257,7 @@ In particular, we don't recommend running the full `./x test` suite locally, since it takes a very long time to execute. See the [Testing with CI] chapter for using Rust's CI to test your changes. -[Testing with CI]: https://rustc-dev-guide.rust-lang.org/tests/ci.html#testing-with-ci +[Testing with CI]: tests/ci.md#testing-with-ci ### r+ diff --git a/src/doc/rustc-dev-guide/src/offload/installation.md b/src/doc/rustc-dev-guide/src/offload/installation.md index 4b67f31cd3c28..ab8e7984d5b4a 100644 --- a/src/doc/rustc-dev-guide/src/offload/installation.md +++ b/src/doc/rustc-dev-guide/src/offload/installation.md @@ -44,7 +44,7 @@ Run this test script for offload-specific tests: ./x test --stage 1 tests/codegen-llvm/gpu_offload ``` -For testing the CI locally, you may use the commands outlined in [Testing with Docker](https://rustc-dev-guide.rust-lang.org/tests/docker.html): +For testing the CI locally, you may use the commands outlined in [Testing with Docker](../tests/docker.md): ```console cargo run --manifest-path src/ci/citool/Cargo.toml run-local dist-x86_64-linux ``` diff --git a/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md b/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md index 144e27316cbb4..94a0d752c945b 100644 --- a/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md +++ b/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md @@ -8,7 +8,7 @@ The way we prove `Projection` bounds directly relies on proving the correspondin It feels like it might make more sense to just have a single implementation which checks whether a trait is implemented and returns (a way to compute) its associated types. This is unfortunately quite difficult, as we may use a different candidate for norm than for the corresponding trait bound. -See [alias-bound vs where-bound](https://rustc-dev-guide.rust-lang.org/solve/candidate-preference.html#we-always-consider-aliasbound-candidates) and [global where-bound vs impl](https://rustc-dev-guide.rust-lang.org/solve/candidate-preference.html#we-prefer-global-where-bounds-over-impls). +See [alias-bound vs where-bound](../solve/candidate-preference.md#we-always-consider-aliasbound-candidates) and [global where-bound vs impl](../solve/candidate-preference.md#we-prefer-global-where-bounds-over-impls). There are also some other subtle reasons for why we can't do so. The most stupid is that for rigid aliases; From 4132d73e54b2f6894d2d12f9f4e6752706b5719e Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:47:55 +0200 Subject: [PATCH 31/42] sembr src/building/bootstrapping/debugging-bootstrap.md --- .../bootstrapping/debugging-bootstrap.md | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md index 93b11c0690a92..da7c07cb23c52 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md @@ -1,12 +1,15 @@ # Debugging bootstrap -There are two main ways of debugging (and profiling bootstrap). The first is through println logging, and the second is through the `tracing` feature. +There are two main ways of debugging (and profiling bootstrap). +The first is through println logging, and the second is through the `tracing` feature. ## `println` logging -Bootstrap has extensive unstructured logging. Most of it is gated behind the `--verbose` flag (pass `-vv` for even more detail). +Bootstrap has extensive unstructured logging. +Most of it is gated behind the `--verbose` flag (pass `-vv` for even more detail). -If you want to see verbose output of executed Cargo commands and other kinds of detailed logs, pass `-v` or `-vv` when invoking bootstrap. Note that the logs are unstructured and may be overwhelming. +If you want to see verbose output of executed Cargo commands and other kinds of detailed logs, pass `-v` or `-vv` when invoking bootstrap. +Note that the logs are unstructured and may be overwhelming. ``` $ ./x dist rustc --dry-run -vv @@ -27,7 +30,8 @@ Bootstrap has a conditional `tracing` feature, which provides the following feat - It generates a command execution summary, which shows which commands were executed, how many of their executions were cached, and what commands were the slowest to run. - The generated `command-stats.txt` file is in a simple human-readable format. -The structured logs will be written to standard error output (`stderr`), while the other outputs will be stored in files in the `/bootstrap-trace/` directory. For convenience, bootstrap will also create a symlink to the latest generated trace output directory at `/bootstrap-trace/latest`. +The structured logs will be written to standard error output (`stderr`), while the other outputs will be stored in files in the `/bootstrap-trace/` directory. +For convenience, bootstrap will also create a symlink to the latest generated trace output directory at `/bootstrap-trace/latest`. > Note that if you execute bootstrap with `--dry-run`, the tracing output directory might change. Bootstrap will always print a path where the tracing output files were stored at the end of its execution. @@ -73,18 +77,24 @@ Build completed successfully in 0:00:00 #### Controlling tracing output -The environment variable `BOOTSTRAP_TRACING` accepts a [`tracing_subscriber` filter][tracing-env-filter]. If you set `BOOTSTRAP_TRACING=trace`, you will enable all logs, but that can be overwhelming. You can thus use the filter to reduce the amount of data logged. +The environment variable `BOOTSTRAP_TRACING` accepts a [`tracing_subscriber` filter][tracing-env-filter]. +If you set `BOOTSTRAP_TRACING=trace`, you will enable all logs, but that can be overwhelming. +You can thus use the filter to reduce the amount of data logged. There are two orthogonal ways to control which kind of tracing logs you want: 1. You can specify the log **level**, e.g. `debug` or `trace`. - If you select a level, all events/spans with an equal or higher priority level will be shown. 2. You can also control the log **target**, e.g. `bootstrap` or `bootstrap::core::config` or a custom target like `CONFIG_HANDLING` or `STEP`. - - Custom targets are used to limit what kinds of spans you are interested in, as the `BOOTSTRAP_TRACING=trace` output can be quite verbose. Currently, you can use the following custom targets: + - Custom targets are used to limit what kinds of spans you are interested in, as the `BOOTSTRAP_TRACING=trace` output can be quite verbose. + Currently, you can use the following custom targets: - `CONFIG_HANDLING`: show spans related to config handling. - - `STEP`: show all executed steps. Executed commands have `info` event level. - - `COMMAND`: show all executed commands. Executed commands have `trace` event level. - - `IO`: show performed I/O operations. Executed commands have `trace` event level. + - `STEP`: show all executed steps. + Executed commands have `info` event level. + - `COMMAND`: show all executed commands. + Executed commands have `trace` event level. + - `IO`: show performed I/O operations. + Executed commands have `trace` event level. - Note that many I/O are currently not being traced. You can of course combine them (custom target logs are typically gated behind `TRACE` log level additionally): @@ -100,14 +110,15 @@ Note that the level that you specify using `BOOTSTRAP_TRACING` also has an effec ##### FIXME(#96176): specific tracing for `compiler()` vs `compiler_for()` The additional targets `COMPILER` and `COMPILER_FOR` are used to help trace what -`builder.compiler()` and `builder.compiler_for()` does. They should be removed -if [#96176][cleanup-compiler-for] is resolved. +`builder.compiler()` and `builder.compiler_for()` does. +They should be removed if [#96176][cleanup-compiler-for] is resolved. [cleanup-compiler-for]: https://github.com/rust-lang/rust/issues/96176 ### Using `tracing` in bootstrap -Both `tracing::*` macros and the `tracing::instrument` proc-macro attribute need to be gated behind `tracing` feature. Examples: +Both `tracing::*` macros and the `tracing::instrument` proc-macro attribute need to be gated behind `tracing` feature. +Examples: ```rs #[cfg(feature = "tracing")] From d8954e6586b989beaa49a715d0144366e27b2139 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:49:45 +0200 Subject: [PATCH 32/42] sembr src/building/bootstrapping/intro.md --- .../src/building/bootstrapping/intro.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md index 7f53097824cc9..307455595d4ba 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md @@ -1,14 +1,13 @@ # Bootstrapping the compiler [*Bootstrapping*][boot] is the process of using a compiler to compile itself. -More accurately, it means using an older compiler to compile a newer version -of the same compiler. +More accurately, it means using an older compiler to compile a newer version of the same compiler. This raises a chicken-and-egg paradox: where did the first compiler come from? -It must have been written in a different language. In Rust's case it was -[written in OCaml][ocaml-compiler]. However, it was abandoned long ago, and the -only way to build a modern version of rustc is with a slightly less modern -version. +It must have been written in a different language. +In Rust's case it was [written in OCaml][ocaml-compiler]. +However, it was abandoned long ago, and the +only way to build a modern version of rustc is with a slightly less modern version. This is exactly how `x.py` works: it downloads the current beta release of rustc, then uses it to compile the new compiler. @@ -17,8 +16,7 @@ In this section, we give a high-level overview of [what Bootstrap does](./what-bootstrapping-does.md), followed by a high-level introduction to [how Bootstrap does it](./how-bootstrap-does-it.md). -Additionally, see [debugging bootstrap](./debugging-bootstrap.md) to learn -about debugging methods. +Additionally, see [debugging bootstrap](./debugging-bootstrap.md) to learn about debugging methods. [boot]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) [ocaml-compiler]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot From 3b40dd01db62d03ea5420b8036c3714635b33ad6 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:52:42 +0200 Subject: [PATCH 33/42] indirection --- .../rustc-dev-guide/src/building/bootstrapping/intro.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md index 307455595d4ba..e4704a10e0a78 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md @@ -1,11 +1,11 @@ # Bootstrapping the compiler -[*Bootstrapping*][boot] is the process of using a compiler to compile itself. +[*Bootstrapping*] is the process of using a compiler to compile itself. More accurately, it means using an older compiler to compile a newer version of the same compiler. This raises a chicken-and-egg paradox: where did the first compiler come from? It must have been written in a different language. -In Rust's case it was [written in OCaml][ocaml-compiler]. +In Rust's case it was [written in OCaml]. However, it was abandoned long ago, and the only way to build a modern version of rustc is with a slightly less modern version. @@ -18,5 +18,5 @@ introduction to [how Bootstrap does it](./how-bootstrap-does-it.md). Additionally, see [debugging bootstrap](./debugging-bootstrap.md) to learn about debugging methods. -[boot]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) -[ocaml-compiler]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot +[*Bootstrapping*]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) +[written in OCaml]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot From 02b4d2bbec5d1434abcaf242764048527b5e786b Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:53:16 +0200 Subject: [PATCH 34/42] sembr src/building/bootstrapping/how-bootstrap-does-it.md --- .../bootstrapping/how-bootstrap-does-it.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md index 4d301b3abae1a..63c154d25d22f 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md @@ -1,14 +1,16 @@ # How Bootstrap does it The core concept in Bootstrap is a build [`Step`], which are chained together -by [`Builder::ensure`]. [`Builder::ensure`] takes a [`Step`] as input, and runs -the [`Step`] if and only if it has not already been run. Let's take a closer -look at [`Step`]. +by [`Builder::ensure`]. +[`Builder::ensure`] takes a [`Step`] as input, and runs +the [`Step`] if and only if it has not already been run. +Let's take a closer look at [`Step`]. ## Synopsis of [`Step`] A [`Step`] represents a granular collection of actions involved in the process -of producing some artifact. It can be thought of like a rule in Makefiles. +of producing some artifact. +It can be thought of like a rule in Makefiles. The [`Step`] trait is defined as: ```rs,no_run @@ -30,8 +32,8 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { - `run` is the function that is responsible for doing the work. [`Builder::ensure`] invokes `run`. - `should_run` is the command-line interface, which determines if an invocation - such as `x build foo` should run a given [`Step`]. In a "default" context - where no paths are provided, then `make_run` is called directly. + such as `x build foo` should run a given [`Step`]. + In a "default" context where no paths are provided, then `make_run` is called directly. - `make_run` is invoked only for things directly asked via the CLI and not for steps which are dependencies of other steps. From 3ca83eba7aa278fb504629e02fbea02f3c17dcc7 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:54:06 +0200 Subject: [PATCH 35/42] sembr src/building/bootstrapping/bootstrap-in-dependencies.md --- .../src/building/bootstrapping/bootstrap-in-dependencies.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md index 68c5c2386bd5e..03772f4a580df 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md @@ -1,6 +1,7 @@ # `cfg(bootstrap)` in compiler dependencies -The rust compiler uses some external crates that can run into cyclic dependencies with the compiler itself: the compiler needs an updated crate to build, but the crate needs an updated compiler. This page describes how `#[cfg(bootstrap)]` can be used to break this cycle. +The rust compiler uses some external crates that can run into cyclic dependencies with the compiler itself: the compiler needs an updated crate to build, but the crate needs an updated compiler. +This page describes how `#[cfg(bootstrap)]` can be used to break this cycle. ## Enabling `#[cfg(bootstrap)]` @@ -50,4 +51,5 @@ For `compiler-builtins` this meant a version bump, in other cases it may be a gi ### Step 4: remove the old behavior from the compiler ([#139753](https://github.com/rust-lang/rust/pull/139753)) -The updated crate can now be used. In this example that meant that the old behavior could be removed. +The updated crate can now be used. +In this example that meant that the old behavior could be removed. From ecb36ae3834cf06e6f0ebd501a5875885e472789 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:54:59 +0200 Subject: [PATCH 36/42] capitalise --- .../src/building/bootstrapping/bootstrap-in-dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md index 03772f4a580df..35a0d5d9302bc 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md @@ -1,6 +1,6 @@ # `cfg(bootstrap)` in compiler dependencies -The rust compiler uses some external crates that can run into cyclic dependencies with the compiler itself: the compiler needs an updated crate to build, but the crate needs an updated compiler. +The Rust compiler uses some external crates that can run into cyclic dependencies with the compiler itself: the compiler needs an updated crate to build, but the crate needs an updated compiler. This page describes how `#[cfg(bootstrap)]` can be used to break this cycle. ## Enabling `#[cfg(bootstrap)]` From 41462bbdd202e04019131f47c7b3409b68f1b6b6 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:55:16 +0200 Subject: [PATCH 37/42] overlong --- .../src/building/bootstrapping/bootstrap-in-dependencies.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md index 35a0d5d9302bc..2780fc36709e6 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md @@ -1,6 +1,7 @@ # `cfg(bootstrap)` in compiler dependencies -The Rust compiler uses some external crates that can run into cyclic dependencies with the compiler itself: the compiler needs an updated crate to build, but the crate needs an updated compiler. +The Rust compiler uses some external crates that can run into cyclic dependencies with the compiler itself: +the compiler needs an updated crate to build, but the crate needs an updated compiler. This page describes how `#[cfg(bootstrap)]` can be used to break this cycle. ## Enabling `#[cfg(bootstrap)]` From b593a46b0eaa48c30a642adf9a69101a83476f03 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 4 Jul 2026 12:55:46 +0200 Subject: [PATCH 38/42] missing pause --- .../src/building/bootstrapping/bootstrap-in-dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md index 2780fc36709e6..33697e1690f21 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/bootstrap-in-dependencies.md @@ -40,7 +40,7 @@ As a concrete example we'll use a change where the `#[naked]` attribute was made ### Step 1: accept the new behavior in the compiler ([#139797](https://github.com/rust-lang/rust/pull/139797)) -In this example it is possible to accept both the old and new behavior at the same time by disabling an error. +In this example, it is possible to accept both the old and new behavior at the same time by disabling an error. ### Step 2: update the crate ([#821](https://github.com/rust-lang/compiler-builtins/pull/821)) From b570ebd37eb81fd8dff1b2e4651609d766043597 Mon Sep 17 00:00:00 2001 From: "Tim (Theemathas Chirananthavat)" Date: Sat, 4 Jul 2026 17:54:11 +0700 Subject: [PATCH 39/42] Weaken guarantee for `From for RangeInclusive` As per https://github.com/rust-lang/rust/pull/155114#issuecomment-4845403701, this `From` impl no longer guarantees panicking for exhausted iterators. Instead, it only guarantees that the conversion will either panic or produce an empty range. This is done so that we can optimize the implementation of `legacy::RangeInclusive` in a way such that we cannot check if it has been exhausted in a generic context without a `Step` and/or `PartialOrd` bound. --- library/core/src/range.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/library/core/src/range.rs b/library/core/src/range.rs index fb7a51a779f6d..74d1cfde034eb 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -402,7 +402,8 @@ const impl From> for RangeInclusive { /// /// # Panics /// - /// Panics if the legacy range iterator has been exhausted. + /// If the legacy range iterator has been exhausted, + /// this function will either panic or return an empty range. /// /// # Examples /// @@ -419,19 +420,16 @@ const impl From> for RangeInclusive { /// assert_eq!((empty.start, empty.last), (0, 0)); /// ``` /// - /// ```should_panic + /// ``` /// use core::range::legacy; /// use core::range::RangeInclusive; + /// use std::panic::catch_unwind; /// /// let mut exhausted: legacy::RangeInclusive = 0..=0; /// exhausted.next(); - /// # if exhausted.is_empty() { - /// # // assert!s don't work correctly in `should_panic` doctests since you - /// # // can't assert the panic message. Skip the rest of the test instead, - /// # // so that the expected panic doesn't happen and the test fails. - /// assert!(exhausted.is_empty()); - /// let _ = RangeInclusive::from(exhausted); // this panics - /// # } + /// let result = catch_unwind(|| RangeInclusive::from(exhausted)); + /// // The `from` call either panicked or returned an empty range. + /// assert!(result.is_err() || result.is_ok_and(|range| range.is_empty())); /// ``` #[inline] fn from(value: legacy::RangeInclusive) -> Self { From 99b3d11ca82ee34592df68d8a0ec6575db800418 Mon Sep 17 00:00:00 2001 From: ArshLabs Date: Sat, 4 Jul 2026 17:02:49 +0530 Subject: [PATCH 40/42] library: expand HashSet extract_if coverage --- library/std/src/collections/hash/set/tests.rs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/library/std/src/collections/hash/set/tests.rs b/library/std/src/collections/hash/set/tests.rs index d7bbc7bdc6a5b..5dfc02935c112 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -418,14 +418,32 @@ fn test_retain() { } #[test] -fn test_extract_if() { - let mut x: HashSet<_> = [1].iter().copied().collect(); - let mut y: HashSet<_> = [1].iter().copied().collect(); - - x.extract_if(|_| true).for_each(drop); - y.extract_if(|_| false).for_each(drop); - assert_eq!(x.len(), 0); - assert_eq!(y.len(), 1); +fn test_extract_if_empty() { + let mut set: HashSet = HashSet::new(); + let extracted: Vec<_> = + set.extract_if(|_| unreachable!("there's nothing to decide on")).collect(); + + assert!(extracted.is_empty()); + assert!(set.is_empty()); +} + +#[test] +fn test_extract_if_consuming_nothing() { + let mut set: HashSet<_> = (0..3).collect(); + let extracted: Vec<_> = set.extract_if(|_| false).collect(); + + assert!(extracted.is_empty()); + assert_eq!(set, HashSet::from([0, 1, 2])); +} + +#[test] +fn test_extract_if_consuming_all() { + let mut set: HashSet<_> = (0..3).collect(); + let mut extracted: Vec<_> = set.extract_if(|_| true).collect(); + extracted.sort_unstable(); + + assert_eq!(extracted, vec![0, 1, 2]); + assert!(set.is_empty()); } #[test] From d0c3225dc776dc3d94da0942ccf94d30742a87de Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sat, 4 Jul 2026 16:15:08 +0300 Subject: [PATCH 41/42] bootstrap: only encode RUSTFLAGS when a flag contains a space Bootstrap now passes rustc and rustdoc flags via CARGO_ENCODED_RUSTFLAGS and CARGO_ENCODED_RUSTDOCFLAGS, whose values use \x1f to separate flags. That control character renders as \u{1f} when a failing command is debug-printed, so the printed command can't be copy-pasted. Prefer the plain, space-separated RUSTFLAGS/RUSTDOCFLAGS form, which is equivalent whenever no flag value contains a space, and only fall back to the encoded form when a flag value does contain a space. --- src/bootstrap/src/core/builder/cargo.rs | 44 +++++++++++++++++++------ src/bootstrap/src/core/builder/tests.rs | 23 +++++++++++++ 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 72094373b5719..87fe911715fce 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -78,6 +78,26 @@ impl Rustflags { } } +/// Picks the environment variable and value to pass a set of [`Rustflags`] to cargo. +/// +/// `flags` is the `\x1f`-separated string built by [`Rustflags`]. We prefer the plain, +/// space-separated form (`RUSTFLAGS`/`RUSTDOCFLAGS`) so the command stays readable and +/// copy-pasteable in bootstrap's debug output, and only fall back to the `CARGO_ENCODED_*` form +/// (which keeps the `\x1f` separators) when a flag value contains a space that the plain, +/// whitespace-split form can't represent. See . +pub(super) fn flags_env( + plain: &'static str, + encoded: &'static str, + flags: &str, +) -> (&'static str, String) { + // A space can only appear inside a flag value, since the separators are `\x1f`. + if flags.contains(' ') { + (encoded, flags.to_string()) + } else { + (plain, flags.replace('\x1f', " ")) + } +} + /// Flags that are passed to the `rustc` shim binary. These flags will only be applied when /// compiling host code, i.e. when `--target` is unset. #[derive(Debug, Default)] @@ -465,21 +485,25 @@ impl From for BootstrapCommand { cargo.command.args(cargo.args); - // Always unset the plain RUSTFLAGS/RUSTDOCFLAGS so that downstream - // tools (e.g. build.rs scripts) see only the encoded form. Any flags - // from the caller's environment have already been folded into the - // Rustflags struct via `propagate_cargo_env`. + // Unset any inherited flag variables (plain and encoded) so cargo uses only the flags + // bootstrap sets below. Flags from the caller's environment have already been folded into + // the Rustflags struct via `propagate_cargo_env`. This also matters because we may set the + // plain form below, which cargo ignores when `CARGO_ENCODED_RUSTFLAGS` is also present. cargo.command.env_remove("RUSTFLAGS"); + cargo.command.env_remove("CARGO_ENCODED_RUSTFLAGS"); cargo.command.env_remove("RUSTDOCFLAGS"); + cargo.command.env_remove("CARGO_ENCODED_RUSTDOCFLAGS"); - let rustflags = &cargo.rustflags.0; - if !rustflags.is_empty() { - cargo.command.env("CARGO_ENCODED_RUSTFLAGS", rustflags); + if !cargo.rustflags.0.is_empty() { + let (var, value) = + flags_env("RUSTFLAGS", "CARGO_ENCODED_RUSTFLAGS", &cargo.rustflags.0); + cargo.command.env(var, value); } - let rustdocflags = &cargo.rustdocflags.0; - if !rustdocflags.is_empty() { - cargo.command.env("CARGO_ENCODED_RUSTDOCFLAGS", rustdocflags); + if !cargo.rustdocflags.0.is_empty() { + let (var, value) = + flags_env("RUSTDOCFLAGS", "CARGO_ENCODED_RUSTDOCFLAGS", &cargo.rustdocflags.0); + cargo.command.env(var, value); } let encoded_hostflags = cargo.hostflags.encode(); diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 176a61b15c988..62ba7d79b13df 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -3349,3 +3349,26 @@ fn render_compiler(compiler: Compiler, config: &RenderConfig) -> String { fn host_target() -> String { get_host_target().to_string() } + +#[test] +fn flags_env_prefers_plain_form_without_spaces() { + use super::cargo::flags_env; + + // No flag value contains a space, so use the readable, copy-pasteable plain form + // rather than the `\x1f`-separated encoded form (rust-lang/rust#158749). + assert_eq!( + flags_env("RUSTFLAGS", "CARGO_ENCODED_RUSTFLAGS", "--cfg=foo\u{1f}-Cdebuginfo=0"), + ("RUSTFLAGS", "--cfg=foo -Cdebuginfo=0".to_string()), + ); + + // A flag value contains a space (e.g. an `-L` path), which the whitespace-split plain + // form can't represent, so keep the encoded form. + assert_eq!( + flags_env( + "RUSTFLAGS", + "CARGO_ENCODED_RUSTFLAGS", + "-Clink-arg=-L/opt/my libs\u{1f}--cfg=foo" + ), + ("CARGO_ENCODED_RUSTFLAGS", "-Clink-arg=-L/opt/my libs\u{1f}--cfg=foo".to_string()), + ); +} From 835045eeeb56422c0e9258f80944a335bb773e4e Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Sat, 4 Jul 2026 18:17:23 +0000 Subject: [PATCH 42/42] hook intrinsic-test into aarch64-gnu --- src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile b/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile index 87bfc0766fbd9..220dbaeebd430 100644 --- a/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile +++ b/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile @@ -26,4 +26,5 @@ ENV RUST_CONFIGURE_ARGS="--build=aarch64-unknown-linux-gnu \ --enable-profiler \ --enable-compiler-docs" ENV SCRIPT="python3 ../x.py --stage 2 test && \ - python3 ../x.py --stage 2 test src/tools/cargo" + python3 ../x.py --stage 2 test src/tools/cargo && \ + python3 ../x.py --stage 2 test library/stdarch/crates/intrinsic-test"