From 38ef5c1cdbd7861dbe26c256f232a1722967a065 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Tue, 16 Dec 2025 06:04:11 +0200 Subject: [PATCH 01/27] improve cg_gcc.md a little --- .../rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md b/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md index 7a1c5b9a98c03..9ed91550b2626 100644 --- a/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md +++ b/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md @@ -79,10 +79,10 @@ if there are no local changes to the GCC sources and the given host target is av ## Providing your own GCC -There are cases where you will want to provide yourself the `libgccjit.so` file. +There are cases where you will want to provide your own `libgccjit.so` file. One such case is when you want to cross-compile `rustc` to another target since GCC is not a multi-target compiler. To support this use case, there is the bootstrap option `gcc.libgccjit-libs-dir`. -This option override `gcc.download-ci-gcc`, meaning `libgccjit.so` won't be downloaded or built locally by bootstrap. +This option overrides `gcc.download-ci-gcc`, meaning `libgccjit.so` won't be downloaded or built locally by bootstrap. The directory structure of this directory is `//libgccjit.so`, for instance: ``` From a412446bb39f33c2ff614960cae02cf1e8b1821a Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Wed, 17 Dec 2025 07:22:03 +0000 Subject: [PATCH 02/27] Prepare for merging from rust-lang/rust This updates the rust-version file to 2dc30247c5d8293aaa31e1d7dae2ed2fde908ada. --- 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 71a84e2bda12c..7345c25066a82 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -cec70080fd441d16e9fb08a0d1d1a04c72d1ed25 +2dc30247c5d8293aaa31e1d7dae2ed2fde908ada From fd513105d8c6292e75db21e613375c13585a27cd Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 21:38:54 +0200 Subject: [PATCH 03/27] output of "git diff" is better, and is what I use mostly --- src/doc/rustc-dev-guide/ci/sembr/Cargo.lock | 26 -------------------- src/doc/rustc-dev-guide/ci/sembr/Cargo.toml | 1 - src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 17 ------------- 3 files changed, 44 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock b/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock index 077fa42d2e5b6..4defe49579f3b 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock +++ b/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock @@ -148,12 +148,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "globset" version = "0.4.18" @@ -167,15 +161,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash", -] - [[package]] name = "heck" version = "0.5.0" @@ -198,16 +183,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "imara-diff" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f01d462f766df78ab820dd06f5eb700233c51f0f4c2e846520eaf4ba6aa5c5c" -dependencies = [ - "hashbrown", - "memchr", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -295,7 +270,6 @@ dependencies = [ "anyhow", "clap", "ignore", - "imara-diff", "regex", ] diff --git a/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml b/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml index 00818e2b3c2df..46228ea479222 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml +++ b/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml @@ -5,7 +5,6 @@ edition = "2024" [dependencies] anyhow = "1" ignore = "0.4" -imara-diff = "0.2" [dependencies.regex] version = "1" diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 2539a9eadda34..c19f195418461 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -5,7 +5,6 @@ use std::{fs, process}; use anyhow::Result; use clap::Parser; use ignore::Walk; -use imara_diff::{Algorithm, BasicLineDiffPrinter, Diff, InternedInput, UnifiedDiffConfig}; use regex::Regex; #[derive(Parser)] @@ -18,8 +17,6 @@ struct Cli { /// Applies to lines that are to be split #[arg(long, default_value_t = 100)] line_length_limit: usize, - #[arg(long)] - show_diff: bool, } static REGEX_IGNORE_END: LazyLock = @@ -54,10 +51,6 @@ fn main() -> Result<()> { } else if cli.overwrite { fs::write(&path, new)?; made_compliant.push(path.clone()); - } else if cli.show_diff { - println!("{}:", path.display()); - show_diff(&old, &new); - println!("---"); } else { not_compliant.push(path.clone()); } @@ -76,16 +69,6 @@ fn main() -> Result<()> { Ok(()) } -fn show_diff(old: &str, new: &str) { - let input = InternedInput::new(old, new); - let mut diff = Diff::compute(Algorithm::Histogram, &input); - diff.postprocess_lines(&input); - let diff = diff - .unified_diff(&BasicLineDiffPrinter(&input.interner), UnifiedDiffConfig::default(), &input) - .to_string(); - print!("{diff}"); -} - fn display(header: &str, paths: &[PathBuf]) { println!("{header}:"); for element in paths { From 64c1e97f32cacc482ccb35cfe20813169ef8f913 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:40:38 +0200 Subject: [PATCH 04/27] place it all in just 2 unit tests --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 49 ++++++-------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index c19f195418461..aa34fbbb53f20 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -196,6 +196,9 @@ some code. block sentence with *italics* should not be ignored. truly. git log main.. compiler foo. bar. baz +o? whatever +r? @reviewer + r? @reviewer "; let expected = " # some. heading @@ -221,6 +224,10 @@ git log main.. compiler foo. bar. baz +o? +whatever +r? @reviewer + r? @reviewer "; assert_eq!(expected, comply(original)); } @@ -247,6 +254,12 @@ do not mess with code block chars leave the text alone ``` + + handle the + indented well + +[a target]: https://example.com +[another target]: https://example.com "; let expected = "\ do not split short sentences @@ -267,43 +280,11 @@ do not mess with code block chars leave the text alone ``` -"; - assert_eq!(expected, lengthen_lines(original, 50)); -} -#[test] -fn test_prettify_prefix_spaces() { - let original = "\ - do not split - short sentences -"; - let expected = "\ - do not split short sentences -"; - assert_eq!(expected, lengthen_lines(original, 50)); -} + handle the indented well -#[test] -fn test_prettify_ignore_link_targets() { - let original = "\ [a target]: https://example.com [another target]: https://example.com "; - assert_eq!(original, lengthen_lines(original, 100)); -} - -#[test] -fn test_sembr_question_mark() { - let original = " -o? whatever -r? @reviewer - r? @reviewer -"; - let expected = " -o? -whatever -r? @reviewer - r? @reviewer -"; - assert_eq!(expected, comply(original)); + assert_eq!(expected, lengthen_lines(original, 50)); } From e254e7ef2d54ee546f75db6c1a75aa6bb1b83514 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:47:04 +0200 Subject: [PATCH 05/27] match fn name --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index aa34fbbb53f20..8e963627066a9 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -233,7 +233,7 @@ r? @reviewer } #[test] -fn test_prettify() { +fn test_lengthen_lines() { let original = "\ do not split short sentences From 8b2c9d8189ab55595f3a636b9e1cfe41b0748217 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:49:54 +0200 Subject: [PATCH 06/27] sembr src/about-this-guide.md --- src/doc/rustc-dev-guide/src/about-this-guide.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/about-this-guide.md b/src/doc/rustc-dev-guide/src/about-this-guide.md index 841691d859f98..2082481a200e6 100644 --- a/src/doc/rustc-dev-guide/src/about-this-guide.md +++ b/src/doc/rustc-dev-guide/src/about-this-guide.md @@ -77,8 +77,7 @@ You might also find the following sites useful: - [std-dev-guide] -- a similar guide for developing the standard library. - [rust-analyzer book] -- documentation for the rust-analyzer. - [The t-compiler Zulip][z] -- The [Rust Internals forum][rif], a place to ask questions and - discuss Rust's internals +- The [Rust Internals forum][rif], a place to ask questions and discuss Rust's internals - The [Rust reference][rr], even though it doesn't specifically talk about Rust's internals, is a great resource nonetheless - Although out of date, [Tom Lee's great blog article][tlgba] is very helpful @@ -89,11 +88,10 @@ You might also find the following sites useful: the compiler, the books, the references, and the guides) to quickly find information about the language and compiler. - You can also use Rustdoc's built-in search feature to find documentation on - types and functions within the crates you're looking at. You can also search - by type signature! For example, searching for `* -> vec` should find all - functions that return a `Vec`. - _Hint:_ Find more tips and keyboard shortcuts by typing `?` on any Rustdoc - page! + types and functions within the crates you're looking at. + You can also search by type signature! + For example, searching for `* -> vec` should find all functions that return a `Vec`. + _Hint:_ Find more tips and keyboard shortcuts by typing `?` on any Rustdoc page! [rustc dev guide]: about-this-guide.md From 6a911741048a5a585c92533677b62ee65aaa8dcb Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:53:15 +0200 Subject: [PATCH 07/27] sembr src/appendix/bibliography.md --- .../src/appendix/bibliography.md | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/appendix/bibliography.md b/src/doc/rustc-dev-guide/src/appendix/bibliography.md index 13a9c3a0b40bf..c161bba5b34fe 100644 --- a/src/doc/rustc-dev-guide/src/appendix/bibliography.md +++ b/src/doc/rustc-dev-guide/src/appendix/bibliography.md @@ -1,7 +1,7 @@ # Rust Bibliography -This is a reading list of material relevant to Rust. It includes prior -research that has - at one time or another - influenced the design of +This is a reading list of material relevant to Rust. +It includes prior research that has - at one time or another - influenced the design of Rust, as well as publications about Rust. ## Type system @@ -44,8 +44,7 @@ Rust, as well as publications about Rust. ## Papers *about* Rust -* [GPU Programming in Rust: Implementing High Level Abstractions in a Systems - Level +* [GPU Programming in Rust: Implementing High Level Abstractions in a Systems Level Language](https://ieeexplore.ieee.org/document/6650903). Early GPU work by Eric Holk. * [Parallel closures: a new twist on an old @@ -55,38 +54,47 @@ Rust, as well as publications about Rust. Language](https://dada.cs.washington.edu/research/tr/2015/03/UW-CSE-15-03-02.pdf). Early formalization of a subset of the type system, by Eric Reed. * [Experience Report: Developing the Servo Web Browser Engine using - Rust](https://arxiv.org/abs/1505.07383). By Lars Bergstrom. + Rust](https://arxiv.org/abs/1505.07383). + By Lars Bergstrom. * [Implementing a Generic Radix Trie in - Rust](https://michaelsproul.github.io/rust_radix_paper/rust-radix-sproul.pdf). Undergrad - paper by Michael Sproul. + Rust](https://michaelsproul.github.io/rust_radix_paper/rust-radix-sproul.pdf). + Undergrad paper by Michael Sproul. * [Reenix: Implementing a Unix-Like Operating System in - Rust](https://scialex.github.io/reenix.pdf). Undergrad paper by Alex - Light. + Rust](https://scialex.github.io/reenix.pdf). + Undergrad paper by Alex Light. * [Evaluation of performance and productivity metrics of potential programming languages in the HPC environment](https://github.com/1wilkens/thesis-ba). - Bachelor's thesis by Florian Wilkens. Compares C, Go and Rust. + Bachelor's thesis by Florian Wilkens. + Compares C, Go and Rust. * [Nom, a byte oriented, streaming, zero copy, parser combinators library - in Rust](http://spw15.langsec.org/papers/couprie-nom.pdf). By - Geoffroy Couprie, research for VLC. + in Rust](http://spw15.langsec.org/papers/couprie-nom.pdf). + By Geoffroy Couprie, research for VLC. * [Graph-Based Higher-Order Intermediate - Representation](https://compilers.cs.uni-saarland.de/papers/lkh15_cgo.pdf). An - experimental IR implemented in Impala, a Rust-like language. -* [Code Refinement of Stencil - Codes](https://compilers.cs.uni-saarland.de/papers/ppl14_web.pdf). Another - paper using Impala. + Representation](https://compilers.cs.uni-saarland.de/papers/lkh15_cgo.pdf). + An experimental IR implemented in Impala, a Rust-like language. +* [Code Refinement of Stencil Codes](https://compilers.cs.uni-saarland.de/papers/ppl14_web.pdf). + Another paper using Impala. * [Parallelization in Rust with fork-join and - friends](http://publications.lib.chalmers.se/records/fulltext/219016/219016.pdf). Linus - Farnstrand's master's thesis. -* [Session Types for - Rust](https://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip - Munksgaard's master's thesis. Research for Servo. -* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](https://amitlevy.com/papers/tock-plos2015.pdf) -* [You can't spell trust without Rust](https://faultlore.com/blah/papers/thesis.pdf). Aria Beingessner's master's thesis. -* [Rust-Bio: a fast and safe bioinformatics library](https://rust-bio.github.io/). Johannes Köster -* [Safe, Correct, and Fast Low-Level Networking](https://csperkins.org/research/thesis-msci-clipsham.pdf). Robert Clipsham's master's thesis. -* [Formalizing Rust traits](https://open.library.ubc.ca/cIRcle/collections/ubctheses/24/items/1.0220521). Jonatan Milewski's master's thesis. + friends](http://publications.lib.chalmers.se/records/fulltext/219016/219016.pdf). + Linus Farnstrand's master's thesis. +* [Session Types for Rust](https://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). + Philip Munksgaard's master's thesis. + Research for Servo. +* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. + al.](https://amitlevy.com/papers/tock-plos2015.pdf) +* [You can't spell trust without Rust](https://faultlore.com/blah/papers/thesis.pdf). + Aria Beingessner's master's thesis. +* [Rust-Bio: a fast and safe bioinformatics library](https://rust-bio.github.io/). + Johannes Köster +* [Safe, Correct, and Fast Low-Level Networking](https://csperkins.org/research/thesis-msci-clipsham.pdf). + Robert Clipsham's master's thesis. +* [Formalizing Rust traits](https://open.library.ubc.ca/cIRcle/collections/ubctheses/24/items/1.0220521). + Jonatan Milewski's master's thesis. * [Rust as a Language for High Performance GC Implementation](https://dl.acm.org/doi/pdf/10.1145/3241624.2926707) -* [Simple Verification of Rust Programs via Functional Purification](https://github.com/Kha/electrolysis). Sebastian Ullrich's master's thesis. +* [Simple Verification of Rust Programs via Functional Purification](https://github.com/Kha/electrolysis). + Sebastian Ullrich's master's thesis. * [Writing parsers like it is 2017](http://spw17.langsec.org/papers/chifflier-parsing-in-2017.pdf) Pierre Chifflier and Geoffroy Couprie for the Langsec Workshop * [The Case for Writing a Kernel in Rust](https://www.tockos.org/assets/papers/rust-kernel-apsys2017.pdf) * [RustBelt: Securing the Foundations of the Rust Programming Language](https://plv.mpi-sws.org/rustbelt/popl18/) -* [Oxide: The Essence of Rust](https://arxiv.org/abs/1903.00982). By Aaron Weiss, Olek Gierczak, Daniel Patterson, Nicholas D. Matsakis, and Amal Ahmed. +* [Oxide: The Essence of Rust](https://arxiv.org/abs/1903.00982). + By Aaron Weiss, Olek Gierczak, Daniel Patterson, Nicholas D. + Matsakis, and Amal Ahmed. From f685b240d8169cd0be8b21312cec07241f7fae08 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:09:33 +0200 Subject: [PATCH 08/27] fix corner case --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 8e963627066a9..2eb32491e3aa7 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -80,6 +80,7 @@ fn ignore(line: &str, in_code_block: bool) -> bool { in_code_block || line.to_lowercase().contains("e.g.") || line.contains("i.e.") + || line.contains("et. al") || line.contains('|') || line.trim_start().starts_with('>') || line.starts_with('#') From e1fe9c64624a1040b88da91eef5044e3d810a537 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:11:34 +0200 Subject: [PATCH 09/27] sembr src/appendix/bibliography.md (after fix from parent commit) Please enter the commit message for your changes. Lines starting --- src/doc/rustc-dev-guide/src/appendix/bibliography.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/appendix/bibliography.md b/src/doc/rustc-dev-guide/src/appendix/bibliography.md index c161bba5b34fe..4f87e4d2fa002 100644 --- a/src/doc/rustc-dev-guide/src/appendix/bibliography.md +++ b/src/doc/rustc-dev-guide/src/appendix/bibliography.md @@ -79,8 +79,7 @@ Rust, as well as publications about Rust. * [Session Types for Rust](https://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip Munksgaard's master's thesis. Research for Servo. -* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. - al.](https://amitlevy.com/papers/tock-plos2015.pdf) +* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](https://amitlevy.com/papers/tock-plos2015.pdf) * [You can't spell trust without Rust](https://faultlore.com/blah/papers/thesis.pdf). Aria Beingessner's master's thesis. * [Rust-Bio: a fast and safe bioinformatics library](https://rust-bio.github.io/). From 2dac444b7e2b7a87157b46b6a708c6fa6bce4c27 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:18:45 +0200 Subject: [PATCH 10/27] sembr src/diagnostics/error-codes.md --- .../src/diagnostics/error-codes.md | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md b/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md index c7bb6669dce46..9a302f9100f1c 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md @@ -1,24 +1,24 @@ # Error codes -We generally try to assign each error message a unique code like `E0123`. These -codes are defined in the compiler in the `diagnostics.rs` files found in each -crate, which basically consist of macros. All error codes have an associated -explanation: new error codes must include them. Note that not all _historical_ -(no longer emitted) error codes have explanations. +We generally try to assign each error message a unique code like `E0123`. +These codes are defined in the compiler in the `diagnostics.rs` files found in each +crate, which basically consist of macros. +All error codes have an associated explanation: new error codes must include them. +Note that not all _historical_ (no longer emitted) error codes have explanations. ## Error explanations The explanations are written in Markdown (see the [CommonMark Spec] for -specifics around syntax), and all of them are linked in the [`rustc_error_codes`] -crate. Please read [RFC 1567] for details on how to format and write long error -codes. As of February 2023, there is an -effort[^new-explanations] to replace this largely outdated RFC with a new more -flexible standard. +specifics around syntax), and all of them are linked in the [`rustc_error_codes`] crate. +Please read [RFC 1567] for details on how to format and write long error codes. +As of February 2023, there is an +effort[^new-explanations] to replace this largely outdated RFC with a new more flexible standard. Error explanations should expand on the error message and provide details about -_why_ the error occurs. It is not helpful for users to copy-paste a quick fix; -explanations should help users understand why their code cannot be accepted by -the compiler. Rust prides itself on helpful error messages and long-form -explanations are no exception. However, before error explanations are +_why_ the error occurs. +It is not helpful for users to copy-paste a quick fix; +explanations should help users understand why their code cannot be accepted by the compiler. +Rust prides itself on helpful error messages and long-form explanations are no exception. +However, before error explanations are overhauled[^new-explanations] it is a bit open as to how exactly they should be written, as always: ask your reviewer or ask around on the Rust Zulip. @@ -33,12 +33,12 @@ written, as always: ask your reviewer or ask around on the Rust Zulip. Error codes are stored in `compiler/rustc_error_codes`. -To create a new error, you first need to find the next available code. +To create a new error, you first need to find the next available code. You can find it by opening `rustc_error_codes/src/lib.rs` and scrolling down to the end of the `error_codes!` macro declaration. -Here we might see the highest error code in use is `E0805`, so we _probably_ want -`E0806`. To be sure, run `rg E0806` and check, you should see no references. +Here we might see the highest error code in use is `E0805`, so we _probably_ want `E0806`. +To be sure, run `rg E0806` and check, you should see no references. You will have to write an extended description for your error, which will go in `rustc_error_codes/src/error_codes/E0806.md`. @@ -62,8 +62,7 @@ struct_span_code_err!(self.dcx(), // some path to the `DiagCtxt` here .emit() // actually issue the error ``` -If you want to add notes or other snippets, you can invoke methods before you -call `.emit()`: +If you want to add notes or other snippets, you can invoke methods before you call `.emit()`: ```rust struct_span_code_err!(...) From 5e1352b6318d1e10560546c831f682debf0e43f4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:25:13 +0200 Subject: [PATCH 11/27] sembr src/query.md --- src/doc/rustc-dev-guide/src/query.md | 104 ++++++++++++++------------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 5df9de7620381..28e421acb2077 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -2,11 +2,13 @@ As described in [Overview of the compiler], the Rust compiler is still (as of July 2021) transitioning from a -traditional "pass-based" setup to a "demand-driven" system. The compiler query -system is the key to rustc's demand-driven organization. -The idea is pretty simple. Instead of entirely independent passes +traditional "pass-based" setup to a "demand-driven" system. +The compiler query system is the key to rustc's demand-driven organization. +The idea is pretty simple. +Instead of entirely independent passes (parsing, type-checking, etc.), a set of function-like *queries* -compute information about the input source. For example, +compute information about the input source. +For example, there is a query called `type_of` that, given the [`DefId`] of some item, will compute the type of that item and return it to you. @@ -14,25 +16,21 @@ some item, will compute the type of that item and return it to you. [Overview of the compiler]: overview.md#queries Query execution is *memoized*. The first time you invoke a -query, it will go do the computation, but the next time, the result is -returned from a hashtable. Moreover, query execution fits nicely into +query, it will go do the computation, but the next time, the result is returned from a hashtable. +Moreover, query execution fits nicely into *incremental computation*; the idea is roughly that, when you invoke a -query, the result *may* be returned to you by loading stored data -from disk.[^incr-comp-detail] +query, the result *may* be returned to you by loading stored data from disk.[^incr-comp-detail] -Eventually, we want the entire compiler -control-flow to be query driven. There will effectively be one -top-level query (`compile`) that will run compilation on a crate; this -will in turn demand information about that crate, starting from the -*end*. For example: +Eventually, we want the entire compiler control-flow to be query driven. +There will effectively be one top-level query (`compile`) that will run compilation on a crate; this +will in turn demand information about that crate, starting from the *end*. For example: - The `compile` query might demand to get a list of codegen-units (i.e. modules that need to be compiled by LLVM). - But computing the list of codegen-units would invoke some subquery that returns the list of all modules defined in the Rust source. - That query in turn would invoke something asking for the HIR. -- This keeps going further and further back until we wind up doing the - actual parsing. +- This keeps going further and further back until we wind up doing the actual parsing. Although this vision is not fully realized, large sections of the compiler (for example, generating [MIR]) currently work exactly like this. @@ -46,9 +44,9 @@ If you intend to write a query of your own, this is a good read. ## Invoking queries -Invoking a query is simple. The [`TyCtxt`] ("type context") struct offers a method -for each defined query. For example, to invoke the `type_of` -query, you would just do this: +Invoking a query is simple. +The [`TyCtxt`] ("type context") struct offers a method for each defined query. +For example, to invoke the `type_of` query, you would just do this: ```rust,ignore let ty = tcx.type_of(some_def_id); @@ -58,8 +56,8 @@ let ty = tcx.type_of(some_def_id); ## How the compiler executes a query -So you may be wondering what happens when you invoke a query -method. The answer is that, for each query, the compiler maintains a +So you may be wondering what happens when you invoke a query method. +The answer is that, for each query, the compiler maintains a cache – if your query has already been executed, then, the answer is simple: we clone the return value out of the cache and return it (therefore, you should try to ensure that the return types of queries @@ -68,11 +66,12 @@ are cheaply cloneable; insert an `Rc` if necessary). ### Providers If, however, the query is *not* in the cache, then the compiler will -call the corresponding **provider** function. A provider is a function -implemented in a specific module and **manually registered** into either +call the corresponding **provider** function. +A provider is a function implemented in a specific module and **manually registered** into either the [`Providers`][providers_struct] struct (for local crate queries) or the [`ExternProviders`][extern_providers_struct] struct (for external crate queries) -during compiler initialization. The macro system generates both structs, +during compiler initialization. +The macro system generates both structs, which act as function tables for all query implementations, where each field is a function pointer to the actual provider. @@ -80,8 +79,8 @@ field is a function pointer to the actual provider. They are **not** Rust traits, but plain structs with function pointer fields. **Providers are defined per-crate.** The compiler maintains, -internally, a table of providers for every crate, at least -conceptually. There are two sets of providers: +internally, a table of providers for every crate, at least conceptually. +There are two sets of providers: - The `Providers` struct for queries about the **local crate** (that is, the one being compiled) - The `ExternProviders` struct for queries about **external crates** (that is, dependencies of the local crate) @@ -89,8 +88,7 @@ dependencies of the local crate) Note that what determines the crate that a query is targeting is not the *kind* of query, but the *key*. For example, when you invoke `tcx.type_of(def_id)`, that could be a local query or an external query, depending on what crate the `def_id` -is referring to (see the [`self::keys::Key`][Key] trait for more -information on how that works). +is referring to (see the [`self::keys::Key`][Key] trait for more information on how that works). Providers always have the same signature: @@ -106,10 +104,11 @@ fn provider<'tcx>( Providers take two arguments: the `tcx` and the query key. They return the result of the query. -N.B. Most of the `rustc_*` crates only provide **local +N.B. +Most of the `rustc_*` crates only provide **local providers**. Almost all **extern providers** wind up going through the -[`rustc_metadata` crate][rustc_metadata], which loads the information -from the crate metadata. But in some cases there are crates that +[`rustc_metadata` crate][rustc_metadata], which loads the information from the crate metadata. +But in some cases there are crates that provide queries for *both* local and external crates, in which case they define both a `provide` and a `provide_extern` function, through [`wasm_import_module_map`][wasm_import_module_map], that `rustc_driver` can invoke. @@ -120,7 +119,8 @@ they define both a `provide` and a `provide_extern` function, through ### How providers are set up When the tcx is created, it is given both the local and external providers by its creator using -the `Providers` struct from `rustc_middle::util`. This struct contains both the local and external providers: +the `Providers` struct from `rustc_middle::util`. +This struct contains both the local and external providers: ```rust,ignore pub struct Providers { @@ -134,7 +134,7 @@ Each of these provider structs is generated by the macros and contains function #### How are providers registered? -The `util::Providers` struct is filled in during compiler initialization, by the `rustc_interface` crate from the `DEFAULT_QUERY_PROVIDERS` static. +The `util::Providers` struct is filled in during compiler initialization, by the `rustc_interface` crate from the `DEFAULT_QUERY_PROVIDERS` static. The actual provider functions are defined across various `rustc_*` crates (like `rustc_middle`, `rustc_hir_analysis`, etc). To register providers, each crate exposes a [`provide`][provide_fn] function that looks like this: @@ -151,7 +151,9 @@ pub fn provide(providers: &mut query::Providers) { } ``` -Note that this function accepts `query::Providers` not `util::Providers`. It is exceedingly rare to need a `provide` function that doesn't just accept `query::Providers`. If more than the `queries` field of `util::Providers` is being updated then `util::Providers` can be accepted instead: +Note that this function accepts `query::Providers` not `util::Providers`. +It is exceedingly rare to need a `provide` function that doesn't just accept `query::Providers`. +If more than the `queries` field of `util::Providers` is being updated then `util::Providers` can be accepted instead: ```rust,ignore pub fn provide(providers: &mut rustc_middle::util::Providers) { providers.queries.type_of = type_of; @@ -173,7 +175,8 @@ Note that `util::Providers` implements `DerefMut` to `query::Providers` so calle #### Adding a new provider -Suppose you want to add a new query called `fubar`. This section focuses on wiring up the providers; for how to declare the query itself in the big `rustc_queries!` macro, see [Adding a new query](#adding-a-new-query) below. +Suppose you want to add a new query called `fubar`. +This section focuses on wiring up the providers; for how to declare the query itself in the big `rustc_queries!` macro, see [Adding a new query](#adding-a-new-query) below. In practice you usually: @@ -184,7 +187,8 @@ In practice you usually: // existing assignments } ``` - If it exists, you will extend it to set the field for your new query. If the crate does not yet have a `provide` function, add one and make sure it is included in `DEFAULT_QUERY_PROVIDERS` in the `rustc_interface` crate so that it actually gets called during initialization (see the discussion above). + If it exists, you will extend it to set the field for your new query. + If the crate does not yet have a `provide` function, add one and make sure it is included in `DEFAULT_QUERY_PROVIDERS` in the `rustc_interface` crate so that it actually gets called during initialization (see the discussion above). 3. Implement the provider function itself: ```rust,ignore fn fubar<'tcx>(tcx: TyCtxt<'tcx>, key: LocalDefId) -> Fubar<'tcx> { ... } @@ -210,7 +214,8 @@ The process works like this: This determines whether to use the local provider from [`Providers`][providers_struct] or the external provider from [`ExternProviders`][extern_providers_struct]. 2. For external crates, the query system will look for a provider in the [`ExternProviders`][extern_providers_struct] struct. - The `rustc_metadata` crate registers these external providers through the `provide_extern` function in `rustc_metadata/src/rmeta/decoder/cstore_impl.rs`. Just like: + The `rustc_metadata` crate registers these external providers through the `provide_extern` function in `rustc_metadata/src/rmeta/decoder/cstore_impl.rs`. + Just like: ```rust pub fn provide_extern(providers: &mut ExternProviders) { providers.foo = |tcx, def_id| { @@ -222,7 +227,8 @@ The process works like this: } ``` -3. The metadata is stored in a binary format in `.rmeta` files that contains pre-computed information about the external crate, such as types, function signatures, trait implementations, and other information needed by the compiler. When an external query is made, the `rustc_metadata` crate: +3. The metadata is stored in a binary format in `.rmeta` files that contains pre-computed information about the external crate, such as types, function signatures, trait implementations, and other information needed by the compiler. + When an external query is made, the `rustc_metadata` crate: - Loads the `.rmeta` file for the external crate - Decodes the metadata using the `Decodable` trait - Returns the decoded information to the query system @@ -234,10 +240,11 @@ Here is a simplified example, when you call `tcx.type_of(def_id)` for a type def 3. The provider will load and decode the type information from the external crate's metadata 4. Return the decoded type to the caller -This is why most `rustc_*` crates only need to provide local providers - the external providers are handled by the metadata system. +This is why most `rustc_*` crates only need to provide local providers - the external providers are handled by the metadata system. The only exception is when a crate needs to provide special handling for external queries, in which case it would implement both local and external providers. -When we define a new query that should work across crates, it does not automatically become cross-crate just because it is listed in `rustc_queries!`. You will typically need to: +When we define a new query that should work across crates, it does not automatically become cross-crate just because it is listed in `rustc_queries!`. +You will typically need to: - Add the query to `rustc_queries!` with appropriate modifiers (for example whether it is cached on disk). - Implement a local provider in the owning crate and register it via that crate's `provide` function. @@ -296,17 +303,16 @@ query keyword Let's go over these elements one by one: - **Query keyword:** indicates a start of a query definition. -- **Name of query:** the name of the query method - (`tcx.type_of(..)`). Also used as the name of a struct - (`ty::queries::type_of`) that will be generated to represent +- **Name of query:** the name of the query method (`tcx.type_of(..)`). + Also used as the name of a struct (`ty::queries::type_of`) that will be generated to represent this query. - **Query key type:** the type of the argument to this query. This type must implement the [`ty::query::keys::Key`][Key] trait, which defines (for example) how to map it to a crate, and so forth. -- **Result type of query:** the type produced by this query. This type - should (a) not use `RefCell` or other interior mutability and (b) be - cheaply cloneable. Interning or using `Rc` or `Arc` is recommended for - non-trivial data types.[^steal] +- **Result type of query:** the type produced by this query. + This type should (a) not use `RefCell` or other interior mutability and (b) be + cheaply cloneable. + Interning or using `Rc` or `Arc` is recommended for non-trivial data types.[^steal] - **Query modifiers:** various flags and options that customize how the query is processed (mostly with respect to [incremental compilation][incrcomp]). @@ -320,9 +326,9 @@ So, to add a query: or add a new one if needed and ensure that `rustc_driver` is invoking it. [^steal]: The one exception to those rules is the `ty::steal::Steal` type, -which is used to cheaply modify MIR in place. See the definition -of `Steal` for more details. New uses of `Steal` should **not** be -added without alerting `@rust-lang/compiler`. +which is used to cheaply modify MIR in place. +See the definition of `Steal` for more details. +New uses of `Steal` should **not** be added without alerting `@rust-lang/compiler`. ## External links From 40d05f8108b551e435445a86977d7d8e8b2e2cfa Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:36:27 +0200 Subject: [PATCH 12/27] corner case --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 1 + src/doc/rustc-dev-guide/src/query.md | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 2eb32491e3aa7..d41a57d6f7474 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -79,6 +79,7 @@ fn display(header: &str, paths: &[PathBuf]) { fn ignore(line: &str, in_code_block: bool) -> bool { in_code_block || line.to_lowercase().contains("e.g.") + || line.to_lowercase().contains("n.b.") || line.contains("i.e.") || line.contains("et. al") || line.contains('|') diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 28e421acb2077..90bb08d8abcd8 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -104,8 +104,7 @@ fn provider<'tcx>( Providers take two arguments: the `tcx` and the query key. They return the result of the query. -N.B. -Most of the `rustc_*` crates only provide **local +N.B. Most of the `rustc_*` crates only provide **local providers**. Almost all **extern providers** wind up going through the [`rustc_metadata` crate][rustc_metadata], which loads the information from the crate metadata. But in some cases there are crates that @@ -158,10 +157,10 @@ If more than the `queries` field of `util::Providers` is being updated then `ut pub fn provide(providers: &mut rustc_middle::util::Providers) { providers.queries.type_of = type_of; // ... add more local providers here - + providers.extern_queries.type_of = extern_type_of; // ... add more external providers here - + providers.hooks.some_hook = some_hook; // ... add more hooks here } @@ -205,7 +204,7 @@ In practice you usually: ### How queries interact with external crate metadata -When a query is made for an external crate (i.e., a dependency), the query system needs to load the information from that crate's metadata. +When a query is made for an external crate (i.e., a dependency), the query system needs to load the information from that crate's metadata. This is handled by the [`rustc_metadata` crate][rustc_metadata], which is responsible for decoding and providing the information stored in the `.rmeta` files. The process works like this: From 2fe2052bbec7bab1951712ddde3f3c0863575c4d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:40:03 +0200 Subject: [PATCH 13/27] manual sembr --- src/doc/rustc-dev-guide/src/query.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 90bb08d8abcd8..1961d68509f93 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -23,7 +23,9 @@ query, the result *may* be returned to you by loading stored data from disk.[^in Eventually, we want the entire compiler control-flow to be query driven. There will effectively be one top-level query (`compile`) that will run compilation on a crate; this -will in turn demand information about that crate, starting from the *end*. For example: +will in turn demand information about that crate, starting from the *end*. + +For example: - The `compile` query might demand to get a list of codegen-units (i.e. modules that need to be compiled by LLVM). From 4673d56b4178fbbccb428784f9a1c706bdcc8f3f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:41:31 +0200 Subject: [PATCH 14/27] sembr src/conventions.md --- src/doc/rustc-dev-guide/src/conventions.md | 64 ++++++++++------------ 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/conventions.md b/src/doc/rustc-dev-guide/src/conventions.md index 92ed0825c8c3e..36ea0c5842403 100644 --- a/src/doc/rustc-dev-guide/src/conventions.md +++ b/src/doc/rustc-dev-guide/src/conventions.md @@ -1,9 +1,8 @@ # Coding conventions -This file offers some tips on the coding conventions for rustc. This -chapter covers [formatting](#formatting), [coding for correctness](#cc), -[using crates from crates.io](#cio), and some tips on -[structuring your PR for easy review](#er). +This file offers some tips on the coding conventions for rustc. +This chapter covers [formatting](#formatting), [coding for correctness](#cc), +[using crates from crates.io](#cio), and some tips on [structuring your PR for easy review](#er). @@ -15,11 +14,11 @@ However, for now we don't use stable `rustfmt`; we use a pinned version with a special config, so this may result in different style from normal [`rustfmt`]. Therefore, formatting this repository using `cargo fmt` is not recommended. -Instead, formatting should be done using `./x fmt`. It's a good habit to run -`./x fmt` before every commit, as this reduces conflicts later. +Instead, formatting should be done using `./x fmt`. +It's a good habit to run `./x fmt` before every commit, as this reduces conflicts later. -Formatting is checked by the `tidy` script. It runs automatically when you do -`./x test` and can be run in isolation with `./x fmt --check`. +Formatting is checked by the `tidy` script. +It runs automatically when you do `./x test` and can be run in isolation with `./x fmt --check`. > **Note: Formatting and test suites** > @@ -47,13 +46,12 @@ When modifying that code, use this command to format it: ./x test tidy --extra-checks cpp:fmt --bless ``` -This uses a pinned version of `clang-format`, to avoid relying on the local -environment. +This uses a pinned version of `clang-format`, to avoid relying on the local environment. ### Formatting and linting Python code -The Rust repository contains quite a lot of Python code. We try to keep -it both linted and formatted by the [ruff] tool. +The Rust repository contains quite a lot of Python code. +We try to keep it both linted and formatted by the [ruff] tool. When modifying Python code, use this command to format it: @@ -78,8 +76,8 @@ These use a pinned version of `ruff`, to avoid relying on the local environment. ### Copyright notice -In the past, files began with a copyright and license notice. Please **omit** -this notice for new files licensed under the standard terms (dual +In the past, files began with a copyright and license notice. +Please **omit** this notice for new files licensed under the standard terms (dual MIT/Apache-2.0). All of the copyright notices should be gone by now, but if you come across one @@ -87,8 +85,8 @@ in the rust-lang/rust repo, feel free to open a PR to remove it. ### Line length -Lines should be at most 100 characters. It's even better if you can -keep things to 80. +Lines should be at most 100 characters. +It's even better if you can keep things to 80. Sometimes, and particularly for tests, it can be necessary to exempt yourself from this limit. In that case, you can add a comment towards the top of the file like so: @@ -105,17 +103,15 @@ Prefer 4-space indents. ## Coding for correctness -Beyond formatting, there are a few other tips that are worth -following. +Beyond formatting, there are a few other tips that are worth following. ### Prefer exhaustive matches Using `_` in a match is convenient, but it means that when new variants are added to the enum, they may not get handled correctly. Ask yourself: if a new variant were added to this enum, what's the -chance that it would want to use the `_` code, versus having some -other treatment? Unless the answer is "low", then prefer an -exhaustive match. +chance that it would want to use the `_` code, versus having some other treatment? +Unless the answer is "low", then prefer an exhaustive match. The same advice applies to `if let` and `while let`, which are effectively tests for a single variant. @@ -155,41 +151,39 @@ See the [crates.io dependencies][crates] section. ## How to structure your PR -How you prepare the commits in your PR can make a big difference for the -reviewer. Here are some tips. +How you prepare the commits in your PR can make a big difference for the reviewer. +Here are some tips. **Isolate "pure refactorings" into their own commit.** For example, if you rename a method, then put that rename into its own commit, along with the renames of all the uses. **More commits is usually better.** If you are doing a large change, -it's almost always better to break it up into smaller steps that can -be independently understood. The one thing to be aware of is that if +it's almost always better to break it up into smaller steps that can be independently understood. +The one thing to be aware of is that if you introduce some code following one strategy, then change it -dramatically (versus adding to it) in a later commit, that -'back-and-forth' can be confusing. +dramatically (versus adding to it) in a later commit, that 'back-and-forth' can be confusing. **Format liberally.** While only the final commit of a PR must be correctly formatted, it is both easier to review and less noisy to format each commit individually using `./x fmt`. -**No merges.** We do not allow merge commits into our history, other -than those by bors. If you get a merge conflict, rebase instead via a +**No merges.** We do not allow merge commits into our history, other than those by bors. +If you get a merge conflict, rebase instead via a command like `git rebase --interactive rust-lang/main` (presuming you use the name `rust-lang` for your remote). **Individual commits do not have to build (but it's nice).** We do not require that every intermediate commit successfully builds – we only -expect to be able to bisect at a PR level. However, if you *can* make -individual commits build, that is always helpful. +expect to be able to bisect at a PR level. +However, if you *can* make individual commits build, that is always helpful. ## Naming conventions -Apart from normal Rust style/naming conventions, there are also some specific -to the compiler. +Apart from normal Rust style/naming conventions, there are also some specific to the compiler. -- `cx` tends to be short for "context" and is often used as a suffix. For - example, `tcx` is a common name for the [Typing Context][tcx]. +- `cx` tends to be short for "context" and is often used as a suffix. + For example, `tcx` is a common name for the [Typing Context][tcx]. - [`'tcx`][tcx] is used as the lifetime name for the Typing Context. From 3aa4a794a7e76fd0977dcd9d020bfd59aa9a43be Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:48:43 +0200 Subject: [PATCH 15/27] that basically repeats the title --- src/doc/rustc-dev-guide/src/conventions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/conventions.md b/src/doc/rustc-dev-guide/src/conventions.md index 36ea0c5842403..5153f2c5711a9 100644 --- a/src/doc/rustc-dev-guide/src/conventions.md +++ b/src/doc/rustc-dev-guide/src/conventions.md @@ -1,6 +1,5 @@ # Coding conventions -This file offers some tips on the coding conventions for rustc. This chapter covers [formatting](#formatting), [coding for correctness](#cc), [using crates from crates.io](#cio), and some tips on [structuring your PR for easy review](#er). From 186fc3c0003c70f73e7cdeddd51d2531c033d82a Mon Sep 17 00:00:00 2001 From: Redddy Date: Thu, 18 Dec 2025 12:00:12 +0900 Subject: [PATCH 16/27] Clarify serialization macros documentation remove `MetadataDecodable` and add `BlobDecodable` and `LazyDecodable`. --- src/doc/rustc-dev-guide/src/serialization.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index a6c2ee17a6678..fcea4f3e605bb 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -126,20 +126,21 @@ and `Encodable`. all `Encoders` and `Decoders`. These should be used in crates that don't depend on [`rustc_middle`], or that have to be serialized by a type that does not implement `TyEncoder`. -- [`MetadataEncodable`] and [`MetadataDecodable`] generate implementations that - only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`] and - [`rustc_metadata::rmeta::decoder::DecodeContext`]. These are used for types - that contain [`rustc_metadata::rmeta::`]`Lazy*`. +- [`MetadataEncodable`] generate implementations that + only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`]. +- [`BlobDecodable`] and [`LazyDecodable`] generate implementations that decode + with the metadata blob decoders in [`rustc_metadata::rmeta`]; use `BlobDecodable` + when the type has no lazy metadata handles, and `LazyDecodable` when it does. - `TyEncodable` and `TyDecodable` generate implementation that apply to any `TyEncoder` or `TyDecoder`. These should be used for types that are only serialized in crate metadata and/or the incremental cache, which is most serializable types in `rustc_middle`. -[`MetadataDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.MetadataDecodable.html +[`BlobDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.BlobDecodable.html +[`LazyDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.LazyDecodable.html [`MetadataEncodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.MetadataEncodable.html [`rustc_macros`]: https://github.com/rust-lang/rust/tree/HEAD/compiler/rustc_macros -[`rustc_metadata::rmeta::`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/index.html -[`rustc_metadata::rmeta::decoder::DecodeContext`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/struct.DecodeContext.html +[`rustc_metadata::rmeta`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/index.html [`rustc_metadata::rmeta::encoder::EncodeContext`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/encoder/struct.EncodeContext.html [`rustc_middle`]: https://github.com/rust-lang/rust/tree/HEAD/compiler/rustc_middle From 1dff3e71a46c4bdde01ba52c37c07902ed089c6e Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 18 Dec 2025 01:25:57 -0800 Subject: [PATCH 17/27] stabilization_guide: add missing `)` in prose --- src/doc/rustc-dev-guide/src/stabilization_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/stabilization_guide.md b/src/doc/rustc-dev-guide/src/stabilization_guide.md index 19296b22cecf1..6167546a2bc83 100644 --- a/src/doc/rustc-dev-guide/src/stabilization_guide.md +++ b/src/doc/rustc-dev-guide/src/stabilization_guide.md @@ -64,7 +64,7 @@ Before the stabilization will be considered by the lang team, there must be a co There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`]. Search for the `declare_features!` macro. There should be an entry for the feature you are aiming to stabilize, -something like the following (taken from [rust-lang/rust#32409]: +something like the following (taken from [rust-lang/rust#32409]): ```rust,ignore // pub(restricted) visibilities (RFC 1422) From e1e8e0648cebb900fd0a1c44057caa1513bba126 Mon Sep 17 00:00:00 2001 From: Redddy Date: Thu, 18 Dec 2025 21:13:17 +0900 Subject: [PATCH 18/27] fix typo Co-authored-by: Tshepang Mbambo --- src/doc/rustc-dev-guide/src/serialization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index fcea4f3e605bb..0fb7870c3a5f8 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -126,9 +126,9 @@ and `Encodable`. all `Encoders` and `Decoders`. These should be used in crates that don't depend on [`rustc_middle`], or that have to be serialized by a type that does not implement `TyEncoder`. -- [`MetadataEncodable`] generate implementations that +- [`MetadataEncodable`] generates implementations that only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`]. -- [`BlobDecodable`] and [`LazyDecodable`] generate implementations that decode +- [`BlobDecodable`] and [`LazyDecodable`] generates implementations that decode with the metadata blob decoders in [`rustc_metadata::rmeta`]; use `BlobDecodable` when the type has no lazy metadata handles, and `LazyDecodable` when it does. - `TyEncodable` and `TyDecodable` generate implementation that apply to any From 54a25b152642d5e72b367a45e1080d255b5a6314 Mon Sep 17 00:00:00 2001 From: Redddy Date: Thu, 18 Dec 2025 23:54:18 +0900 Subject: [PATCH 19/27] Clarify descriptions for BlobDecodable and LazyDecodable --- src/doc/rustc-dev-guide/src/serialization.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index 0fb7870c3a5f8..91b2cc92125e2 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -128,9 +128,10 @@ and `Encodable`. not implement `TyEncoder`. - [`MetadataEncodable`] generates implementations that only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`]. -- [`BlobDecodable`] and [`LazyDecodable`] generates implementations that decode - with the metadata blob decoders in [`rustc_metadata::rmeta`]; use `BlobDecodable` - when the type has no lazy metadata handles, and `LazyDecodable` when it does. +- [`BlobDecodable`] and [`LazyDecodable`] serve as the decoding counterparts to + `MetadataEncodable`. They generate implementations that decode with the + metadata blob decoders in `rustc_metadata::rmeta`; use `BlobDecodable` when + the type has no lazy metadata handles, and `LazyDecodable` when it does. - `TyEncodable` and `TyDecodable` generate implementation that apply to any `TyEncoder` or `TyDecoder`. These should be used for types that are only serialized in crate metadata and/or the incremental cache, which is most From c3bd76b7afc20bb46c503d1a4edab9da82484f13 Mon Sep 17 00:00:00 2001 From: Redddy Date: Sat, 20 Dec 2025 15:22:41 +0900 Subject: [PATCH 20/27] Add Rustc Explore video link --- src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md b/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md index 90c4097cc3e62..0bd4c6eb13398 100644 --- a/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md +++ b/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md @@ -6,6 +6,7 @@ These are videos where various experts explain different parts of the compiler: - [January 2019: Tom Tromey discusses debugging support in rustc](https://www.youtube.com/watch?v=elBxMRSNYr4) - [June 2019: Responsive compilers - Nicholas Matsakis - PLISS 2019](https://www.youtube.com/watch?v=N6b44kMS6OM) - [June 2019: Things I Learned (TIL) - Nicholas Matsakis - PLISS 2019](https://www.youtube.com/watch?v=LIYkT3p5gTs) +- [October 2022: Rustc Explore](https://www.youtube.com/playlist?list=PL85XCvVPmGQj3-MujOJ0jcoSqQ6Yi6Rkk) ## Rust Analyzer - [January 2019: How Salsa Works](https://www.youtube.com/watch?v=_muY4HjSqVw) @@ -46,4 +47,4 @@ These are videos where various experts explain different parts of the compiler: ## Code Generation - [January 2019: Cranelift](https://www.youtube.com/watch?v=9OIA7DTFQWU) -- [December 2024: LLVM Developers' Meeting - Rust ❤️ LLVM](https://www.youtube.com/watch?v=Kqz-umsAnk8) \ No newline at end of file +- [December 2024: LLVM Developers' Meeting - Rust ❤️ LLVM](https://www.youtube.com/watch?v=Kqz-umsAnk8) From 44a9d841f47006c34ccddad7809cca2a21e02e1e Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 19 Dec 2025 21:20:27 -0500 Subject: [PATCH 21/27] Don't export upstream monomorphizations from compiler-builtins --- compiler/rustc_middle/src/ty/context.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 471bd1d937e94..779a5f3f5218a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2272,6 +2272,12 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn local_crate_exports_generics(self) -> bool { + // compiler-builtins has some special treatment in codegen, which can result in confusing + // behavior if another crate ends up calling into its monomorphizations. + // https://github.com/rust-lang/rust/issues/150173 + if self.is_compiler_builtins(LOCAL_CRATE) { + return false; + } self.crate_types().iter().any(|crate_type| { match crate_type { CrateType::Executable From 7ca2eb9c6f67e694cfc7d762f722c3a510fe59b0 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sat, 20 Dec 2025 23:37:09 +0900 Subject: [PATCH 22/27] moved test --- .../issue-50581.rs => array-slice-vec/array-break-length-2.rs} | 0 .../array-break-length-2.stderr} | 0 .../issue-36400.rs => borrowck/borrow-immutable-deref-box.rs} | 0 .../borrow-immutable-deref-box.stderr} | 0 .../issue-18423.rs => box/box-lifetime-argument-not-allowed.rs} | 0 .../box-lifetime-argument-not-allowed.stderr} | 0 .../cast-rfc0401.rs => cast/cast-rfc0401-fail.rs} | 0 .../cast-rfc0401.stderr => cast/cast-rfc0401-fail.stderr} | 0 tests/ui/{issues/issue-22289.rs => cast/cast-to-dyn-any.rs} | 0 .../ui/{issues/issue-22289.stderr => cast/cast-to-dyn-any.stderr} | 0 .../closure-array-break-length-2.rs} | 0 .../closure-array-break-length-2.stderr} | 0 .../closure-move-use-after-move-diagnostic.rs} | 0 .../closure-move-use-after-move-diagnostic.stderr} | 0 .../{issues/issue-38458.rs => consts/const-return-outside-fn.rs} | 0 .../issue-38458.stderr => consts/const-return-outside-fn.stderr} | 0 .../ui/{issues/issue-28568.rs => drop/drop-conflicting-impls.rs} | 0 .../issue-28568.stderr => drop/drop-conflicting-impls.stderr} | 0 .../issue-23217.rs => enum/enum-discriminant-missing-variant.rs} | 0 .../enum-discriminant-missing-variant.stderr} | 0 .../{issues/issue-21554.rs => mismatched_types/cast-rfc0401-2.rs} | 0 .../issue-21554.stderr => mismatched_types/cast-rfc0401-2.stderr} | 0 .../issue-47184.rs => nll/borrowck-annotate-static-lifetime.rs} | 0 .../borrowck-annotate-static-lifetime.stderr} | 0 tests/ui/{issues/issue-46983.rs => nll/nll-anon-to-static.rs} | 0 .../{issues/issue-46983.stderr => nll/nll-anon-to-static.stderr} | 0 .../issue-45965.rs => parser/missing-operator-after-float.rs} | 0 .../missing-operator-after-float.stderr} | 0 .../{issues/issue-44078.rs => parser/unbalanced-doublequote-2.rs} | 0 .../issue-44078.stderr => parser/unbalanced-doublequote-2.stderr} | 0 .../issue-23173.rs => resolve/missing-associated-items.rs} | 0 .../missing-associated-items.stderr} | 0 tests/ui/{issues/issue-50582.rs => typeck/for-in-const-eval.rs} | 0 .../issue-50582.stderr => typeck/for-in-const-eval.stderr} | 0 34 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-50581.rs => array-slice-vec/array-break-length-2.rs} (100%) rename tests/ui/{issues/issue-50581.stderr => array-slice-vec/array-break-length-2.stderr} (100%) rename tests/ui/{issues/issue-36400.rs => borrowck/borrow-immutable-deref-box.rs} (100%) rename tests/ui/{issues/issue-36400.stderr => borrowck/borrow-immutable-deref-box.stderr} (100%) rename tests/ui/{issues/issue-18423.rs => box/box-lifetime-argument-not-allowed.rs} (100%) rename tests/ui/{issues/issue-18423.stderr => box/box-lifetime-argument-not-allowed.stderr} (100%) rename tests/ui/{mismatched_types/cast-rfc0401.rs => cast/cast-rfc0401-fail.rs} (100%) rename tests/ui/{mismatched_types/cast-rfc0401.stderr => cast/cast-rfc0401-fail.stderr} (100%) rename tests/ui/{issues/issue-22289.rs => cast/cast-to-dyn-any.rs} (100%) rename tests/ui/{issues/issue-22289.stderr => cast/cast-to-dyn-any.stderr} (100%) rename tests/ui/{array-slice-vec/array-break-length.rs => closures/closure-array-break-length-2.rs} (100%) rename tests/ui/{array-slice-vec/array-break-length.stderr => closures/closure-array-break-length-2.stderr} (100%) rename tests/ui/{issues/issue-24357.rs => closures/closure-move-use-after-move-diagnostic.rs} (100%) rename tests/ui/{issues/issue-24357.stderr => closures/closure-move-use-after-move-diagnostic.stderr} (100%) rename tests/ui/{issues/issue-38458.rs => consts/const-return-outside-fn.rs} (100%) rename tests/ui/{issues/issue-38458.stderr => consts/const-return-outside-fn.stderr} (100%) rename tests/ui/{issues/issue-28568.rs => drop/drop-conflicting-impls.rs} (100%) rename tests/ui/{issues/issue-28568.stderr => drop/drop-conflicting-impls.stderr} (100%) rename tests/ui/{issues/issue-23217.rs => enum/enum-discriminant-missing-variant.rs} (100%) rename tests/ui/{issues/issue-23217.stderr => enum/enum-discriminant-missing-variant.stderr} (100%) rename tests/ui/{issues/issue-21554.rs => mismatched_types/cast-rfc0401-2.rs} (100%) rename tests/ui/{issues/issue-21554.stderr => mismatched_types/cast-rfc0401-2.stderr} (100%) rename tests/ui/{issues/issue-47184.rs => nll/borrowck-annotate-static-lifetime.rs} (100%) rename tests/ui/{issues/issue-47184.stderr => nll/borrowck-annotate-static-lifetime.stderr} (100%) rename tests/ui/{issues/issue-46983.rs => nll/nll-anon-to-static.rs} (100%) rename tests/ui/{issues/issue-46983.stderr => nll/nll-anon-to-static.stderr} (100%) rename tests/ui/{issues/issue-45965.rs => parser/missing-operator-after-float.rs} (100%) rename tests/ui/{issues/issue-45965.stderr => parser/missing-operator-after-float.stderr} (100%) rename tests/ui/{issues/issue-44078.rs => parser/unbalanced-doublequote-2.rs} (100%) rename tests/ui/{issues/issue-44078.stderr => parser/unbalanced-doublequote-2.stderr} (100%) rename tests/ui/{issues/issue-23173.rs => resolve/missing-associated-items.rs} (100%) rename tests/ui/{issues/issue-23173.stderr => resolve/missing-associated-items.stderr} (100%) rename tests/ui/{issues/issue-50582.rs => typeck/for-in-const-eval.rs} (100%) rename tests/ui/{issues/issue-50582.stderr => typeck/for-in-const-eval.stderr} (100%) diff --git a/tests/ui/issues/issue-50581.rs b/tests/ui/array-slice-vec/array-break-length-2.rs similarity index 100% rename from tests/ui/issues/issue-50581.rs rename to tests/ui/array-slice-vec/array-break-length-2.rs diff --git a/tests/ui/issues/issue-50581.stderr b/tests/ui/array-slice-vec/array-break-length-2.stderr similarity index 100% rename from tests/ui/issues/issue-50581.stderr rename to tests/ui/array-slice-vec/array-break-length-2.stderr diff --git a/tests/ui/issues/issue-36400.rs b/tests/ui/borrowck/borrow-immutable-deref-box.rs similarity index 100% rename from tests/ui/issues/issue-36400.rs rename to tests/ui/borrowck/borrow-immutable-deref-box.rs diff --git a/tests/ui/issues/issue-36400.stderr b/tests/ui/borrowck/borrow-immutable-deref-box.stderr similarity index 100% rename from tests/ui/issues/issue-36400.stderr rename to tests/ui/borrowck/borrow-immutable-deref-box.stderr diff --git a/tests/ui/issues/issue-18423.rs b/tests/ui/box/box-lifetime-argument-not-allowed.rs similarity index 100% rename from tests/ui/issues/issue-18423.rs rename to tests/ui/box/box-lifetime-argument-not-allowed.rs diff --git a/tests/ui/issues/issue-18423.stderr b/tests/ui/box/box-lifetime-argument-not-allowed.stderr similarity index 100% rename from tests/ui/issues/issue-18423.stderr rename to tests/ui/box/box-lifetime-argument-not-allowed.stderr diff --git a/tests/ui/mismatched_types/cast-rfc0401.rs b/tests/ui/cast/cast-rfc0401-fail.rs similarity index 100% rename from tests/ui/mismatched_types/cast-rfc0401.rs rename to tests/ui/cast/cast-rfc0401-fail.rs diff --git a/tests/ui/mismatched_types/cast-rfc0401.stderr b/tests/ui/cast/cast-rfc0401-fail.stderr similarity index 100% rename from tests/ui/mismatched_types/cast-rfc0401.stderr rename to tests/ui/cast/cast-rfc0401-fail.stderr diff --git a/tests/ui/issues/issue-22289.rs b/tests/ui/cast/cast-to-dyn-any.rs similarity index 100% rename from tests/ui/issues/issue-22289.rs rename to tests/ui/cast/cast-to-dyn-any.rs diff --git a/tests/ui/issues/issue-22289.stderr b/tests/ui/cast/cast-to-dyn-any.stderr similarity index 100% rename from tests/ui/issues/issue-22289.stderr rename to tests/ui/cast/cast-to-dyn-any.stderr diff --git a/tests/ui/array-slice-vec/array-break-length.rs b/tests/ui/closures/closure-array-break-length-2.rs similarity index 100% rename from tests/ui/array-slice-vec/array-break-length.rs rename to tests/ui/closures/closure-array-break-length-2.rs diff --git a/tests/ui/array-slice-vec/array-break-length.stderr b/tests/ui/closures/closure-array-break-length-2.stderr similarity index 100% rename from tests/ui/array-slice-vec/array-break-length.stderr rename to tests/ui/closures/closure-array-break-length-2.stderr diff --git a/tests/ui/issues/issue-24357.rs b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs similarity index 100% rename from tests/ui/issues/issue-24357.rs rename to tests/ui/closures/closure-move-use-after-move-diagnostic.rs diff --git a/tests/ui/issues/issue-24357.stderr b/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr similarity index 100% rename from tests/ui/issues/issue-24357.stderr rename to tests/ui/closures/closure-move-use-after-move-diagnostic.stderr diff --git a/tests/ui/issues/issue-38458.rs b/tests/ui/consts/const-return-outside-fn.rs similarity index 100% rename from tests/ui/issues/issue-38458.rs rename to tests/ui/consts/const-return-outside-fn.rs diff --git a/tests/ui/issues/issue-38458.stderr b/tests/ui/consts/const-return-outside-fn.stderr similarity index 100% rename from tests/ui/issues/issue-38458.stderr rename to tests/ui/consts/const-return-outside-fn.stderr diff --git a/tests/ui/issues/issue-28568.rs b/tests/ui/drop/drop-conflicting-impls.rs similarity index 100% rename from tests/ui/issues/issue-28568.rs rename to tests/ui/drop/drop-conflicting-impls.rs diff --git a/tests/ui/issues/issue-28568.stderr b/tests/ui/drop/drop-conflicting-impls.stderr similarity index 100% rename from tests/ui/issues/issue-28568.stderr rename to tests/ui/drop/drop-conflicting-impls.stderr diff --git a/tests/ui/issues/issue-23217.rs b/tests/ui/enum/enum-discriminant-missing-variant.rs similarity index 100% rename from tests/ui/issues/issue-23217.rs rename to tests/ui/enum/enum-discriminant-missing-variant.rs diff --git a/tests/ui/issues/issue-23217.stderr b/tests/ui/enum/enum-discriminant-missing-variant.stderr similarity index 100% rename from tests/ui/issues/issue-23217.stderr rename to tests/ui/enum/enum-discriminant-missing-variant.stderr diff --git a/tests/ui/issues/issue-21554.rs b/tests/ui/mismatched_types/cast-rfc0401-2.rs similarity index 100% rename from tests/ui/issues/issue-21554.rs rename to tests/ui/mismatched_types/cast-rfc0401-2.rs diff --git a/tests/ui/issues/issue-21554.stderr b/tests/ui/mismatched_types/cast-rfc0401-2.stderr similarity index 100% rename from tests/ui/issues/issue-21554.stderr rename to tests/ui/mismatched_types/cast-rfc0401-2.stderr diff --git a/tests/ui/issues/issue-47184.rs b/tests/ui/nll/borrowck-annotate-static-lifetime.rs similarity index 100% rename from tests/ui/issues/issue-47184.rs rename to tests/ui/nll/borrowck-annotate-static-lifetime.rs diff --git a/tests/ui/issues/issue-47184.stderr b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr similarity index 100% rename from tests/ui/issues/issue-47184.stderr rename to tests/ui/nll/borrowck-annotate-static-lifetime.stderr diff --git a/tests/ui/issues/issue-46983.rs b/tests/ui/nll/nll-anon-to-static.rs similarity index 100% rename from tests/ui/issues/issue-46983.rs rename to tests/ui/nll/nll-anon-to-static.rs diff --git a/tests/ui/issues/issue-46983.stderr b/tests/ui/nll/nll-anon-to-static.stderr similarity index 100% rename from tests/ui/issues/issue-46983.stderr rename to tests/ui/nll/nll-anon-to-static.stderr diff --git a/tests/ui/issues/issue-45965.rs b/tests/ui/parser/missing-operator-after-float.rs similarity index 100% rename from tests/ui/issues/issue-45965.rs rename to tests/ui/parser/missing-operator-after-float.rs diff --git a/tests/ui/issues/issue-45965.stderr b/tests/ui/parser/missing-operator-after-float.stderr similarity index 100% rename from tests/ui/issues/issue-45965.stderr rename to tests/ui/parser/missing-operator-after-float.stderr diff --git a/tests/ui/issues/issue-44078.rs b/tests/ui/parser/unbalanced-doublequote-2.rs similarity index 100% rename from tests/ui/issues/issue-44078.rs rename to tests/ui/parser/unbalanced-doublequote-2.rs diff --git a/tests/ui/issues/issue-44078.stderr b/tests/ui/parser/unbalanced-doublequote-2.stderr similarity index 100% rename from tests/ui/issues/issue-44078.stderr rename to tests/ui/parser/unbalanced-doublequote-2.stderr diff --git a/tests/ui/issues/issue-23173.rs b/tests/ui/resolve/missing-associated-items.rs similarity index 100% rename from tests/ui/issues/issue-23173.rs rename to tests/ui/resolve/missing-associated-items.rs diff --git a/tests/ui/issues/issue-23173.stderr b/tests/ui/resolve/missing-associated-items.stderr similarity index 100% rename from tests/ui/issues/issue-23173.stderr rename to tests/ui/resolve/missing-associated-items.stderr diff --git a/tests/ui/issues/issue-50582.rs b/tests/ui/typeck/for-in-const-eval.rs similarity index 100% rename from tests/ui/issues/issue-50582.rs rename to tests/ui/typeck/for-in-const-eval.rs diff --git a/tests/ui/issues/issue-50582.stderr b/tests/ui/typeck/for-in-const-eval.stderr similarity index 100% rename from tests/ui/issues/issue-50582.stderr rename to tests/ui/typeck/for-in-const-eval.stderr From 4578082361406cdf6836301c127534f1a2317135 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 21 Dec 2025 09:13:49 +0900 Subject: [PATCH 23/27] Cleaned up some tests add comment to closure-move-use-after-move-diagnostic.rs add comment to missing-operator-after-float.rs add comment to closure-array-break-length.rs add comment to box-lifetime-argument-not-allowed.rs add comment to const-return-outside-fn.rs add comment to drop-conflicting-impls.rs add comment to unbalanced-doublequote-2.rs add comment to borrow-immutable-deref-box.rs add comment to for-in-const-eval.rs add comment to borrowck-annotated-static-lifetime.rs cleaned up cast-rfc0401.rs add comment to nll-anon-to-static.rs add comment to cast-to-dyn-any.rs add comment to missing-associated-items.rs add comment to enum-discriminant-missing-variant.rs --- .../array-slice-vec/array-break-length-2.rs | 3 - .../array-break-length-2.stderr | 9 --- .../ui/borrowck/borrow-immutable-deref-box.rs | 1 + .../borrow-immutable-deref-box.stderr | 2 +- .../box/box-lifetime-argument-not-allowed.rs | 7 +- .../box-lifetime-argument-not-allowed.stderr | 4 +- tests/ui/cast/cast-rfc0401-2.rs | 8 -- tests/ui/cast/cast-rfc0401-2.stderr | 15 ---- tests/ui/cast/cast-rfc0401-fail.rs | 29 ++++--- tests/ui/cast/cast-rfc0401-fail.stderr | 76 ++++++++++--------- tests/ui/cast/cast-to-dyn-any.rs | 1 + tests/ui/cast/cast-to-dyn-any.stderr | 2 +- .../closures/closure-array-break-length-2.rs | 9 --- .../closure-array-break-length-2.stderr | 15 ---- .../ui/closures/closure-array-break-length.rs | 11 +++ .../closure-array-break-length.stderr | 26 ++++++- .../closure-move-use-after-move-diagnostic.rs | 21 ++--- ...sure-move-use-after-move-diagnostic.stderr | 25 +++--- tests/ui/consts/const-return-outside-fn.rs | 1 + .../ui/consts/const-return-outside-fn.stderr | 2 +- tests/ui/drop/drop-conflicting-impls.rs | 7 +- tests/ui/drop/drop-conflicting-impls.stderr | 2 +- .../enum/enum-discriminant-missing-variant.rs | 1 + .../enum-discriminant-missing-variant.stderr | 2 +- tests/ui/mismatched_types/cast-rfc0401-2.rs | 6 -- .../ui/mismatched_types/cast-rfc0401-2.stderr | 9 --- .../nll/borrowck-annotate-static-lifetime.rs | 1 + .../borrowck-annotate-static-lifetime.stderr | 2 +- tests/ui/nll/nll-anon-to-static.rs | 1 + tests/ui/nll/nll-anon-to-static.stderr | 2 +- .../ui/parser/missing-operator-after-float.rs | 1 + .../missing-operator-after-float.stderr | 2 +- tests/ui/parser/unbalanced-doublequote-2.rs | 1 + .../ui/parser/unbalanced-doublequote-2.stderr | 2 +- tests/ui/resolve/missing-associated-items.rs | 12 ++- .../resolve/missing-associated-items.stderr | 10 +-- tests/ui/typeck/for-in-const-eval.rs | 1 + tests/ui/typeck/for-in-const-eval.stderr | 2 +- 38 files changed, 160 insertions(+), 171 deletions(-) delete mode 100644 tests/ui/array-slice-vec/array-break-length-2.rs delete mode 100644 tests/ui/array-slice-vec/array-break-length-2.stderr delete mode 100644 tests/ui/cast/cast-rfc0401-2.rs delete mode 100644 tests/ui/cast/cast-rfc0401-2.stderr delete mode 100644 tests/ui/closures/closure-array-break-length-2.rs delete mode 100644 tests/ui/closures/closure-array-break-length-2.stderr delete mode 100644 tests/ui/mismatched_types/cast-rfc0401-2.rs delete mode 100644 tests/ui/mismatched_types/cast-rfc0401-2.stderr diff --git a/tests/ui/array-slice-vec/array-break-length-2.rs b/tests/ui/array-slice-vec/array-break-length-2.rs deleted file mode 100644 index 12bb9930eca40..0000000000000 --- a/tests/ui/array-slice-vec/array-break-length-2.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - |_: [u8; break]| (); //~ ERROR [E0268] -} diff --git a/tests/ui/array-slice-vec/array-break-length-2.stderr b/tests/ui/array-slice-vec/array-break-length-2.stderr deleted file mode 100644 index bac1ade3b0c8f..0000000000000 --- a/tests/ui/array-slice-vec/array-break-length-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0268]: `break` outside of a loop or labeled block - --> $DIR/issue-50581.rs:2:14 - | -LL | |_: [u8; break]| (); - | ^^^^^ cannot `break` outside of a loop or labeled block - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/borrowck/borrow-immutable-deref-box.rs b/tests/ui/borrowck/borrow-immutable-deref-box.rs index a405f9b113525..6d4932b5b4b5d 100644 --- a/tests/ui/borrowck/borrow-immutable-deref-box.rs +++ b/tests/ui/borrowck/borrow-immutable-deref-box.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn f(x: &mut u32) {} fn main() { diff --git a/tests/ui/borrowck/borrow-immutable-deref-box.stderr b/tests/ui/borrowck/borrow-immutable-deref-box.stderr index 522fb36e14343..6456dc8a0e5a6 100644 --- a/tests/ui/borrowck/borrow-immutable-deref-box.stderr +++ b/tests/ui/borrowck/borrow-immutable-deref-box.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable - --> $DIR/issue-36400.rs:5:7 + --> $DIR/borrow-immutable-deref-box.rs:6:7 | LL | f(&mut *x); | ^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/box/box-lifetime-argument-not-allowed.rs b/tests/ui/box/box-lifetime-argument-not-allowed.rs index 675fd041154be..647fe0917d0a3 100644 --- a/tests/ui/box/box-lifetime-argument-not-allowed.rs +++ b/tests/ui/box/box-lifetime-argument-not-allowed.rs @@ -1,8 +1,9 @@ -// Test that `Box` cannot be used with a lifetime argument. +//! Test that `Box` cannot be used with a lifetime argument. +//! regression test for issue struct Foo<'a> { - x: Box<'a, isize> + x: Box<'a, isize>, //~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied } -fn main() { } +fn main() {} diff --git a/tests/ui/box/box-lifetime-argument-not-allowed.stderr b/tests/ui/box/box-lifetime-argument-not-allowed.stderr index b5f19b5c9b23c..a597a03023af3 100644 --- a/tests/ui/box/box-lifetime-argument-not-allowed.stderr +++ b/tests/ui/box/box-lifetime-argument-not-allowed.stderr @@ -1,7 +1,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/issue-18423.rs:4:8 + --> $DIR/box-lifetime-argument-not-allowed.rs:5:8 | -LL | x: Box<'a, isize> +LL | x: Box<'a, isize>, | ^^^ -- help: remove the lifetime argument | | | expected 0 lifetime arguments diff --git a/tests/ui/cast/cast-rfc0401-2.rs b/tests/ui/cast/cast-rfc0401-2.rs deleted file mode 100644 index 70604a587ea1f..0000000000000 --- a/tests/ui/cast/cast-rfc0401-2.rs +++ /dev/null @@ -1,8 +0,0 @@ -// RFC 401 test extracted into distinct file. This is because some the -// change to suppress "derived" errors wound up suppressing this error -// message, since the fallback for `3` doesn't occur. - -fn main() { - let _ = 3 as bool; - //~^ ERROR cannot cast `i32` as `bool` -} diff --git a/tests/ui/cast/cast-rfc0401-2.stderr b/tests/ui/cast/cast-rfc0401-2.stderr deleted file mode 100644 index f2956cdfa3356..0000000000000 --- a/tests/ui/cast/cast-rfc0401-2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0054]: cannot cast `i32` as `bool` - --> $DIR/cast-rfc0401-2.rs:6:13 - | -LL | let _ = 3 as bool; - | ^^^^^^^^^ - | -help: compare with zero instead - | -LL - let _ = 3 as bool; -LL + let _ = 3 != 0; - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0054`. diff --git a/tests/ui/cast/cast-rfc0401-fail.rs b/tests/ui/cast/cast-rfc0401-fail.rs index b2ff5b4a0c063..fb04e3f5f9a0b 100644 --- a/tests/ui/cast/cast-rfc0401-fail.rs +++ b/tests/ui/cast/cast-rfc0401-fail.rs @@ -1,29 +1,33 @@ -fn illegal_cast(u: *const U) -> *const V -{ +fn illegal_cast(u: *const U) -> *const V { u as *const V //~ ERROR is invalid } -fn illegal_cast_2(u: *const U) -> *const str -{ +fn illegal_cast_2(u: *const U) -> *const str { u as *const str //~ ERROR is invalid } -trait Foo { fn foo(&self) {} } +trait Foo { + fn foo(&self) {} +} impl Foo for T {} -trait Bar { fn foo(&self) {} } +trait Bar { + fn foo(&self) {} +} impl Bar for T {} enum E { - A, B + A, + B, } -fn main() -{ +struct Inches(i32); + +fn main() { let f: f32 = 1.2; let v = core::ptr::null::(); - let fat_v : *const [u8] = unsafe { &*core::ptr::null::<[u8; 1]>()}; - let fat_sv : *const [i8] = unsafe { &*core::ptr::null::<[i8; 1]>()}; + let fat_v: *const [u8] = unsafe { &*core::ptr::null::<[u8; 1]>() }; + let fat_sv: *const [i8] = unsafe { &*core::ptr::null::<[i8; 1]>() }; let foo: &dyn Foo = &f; let _ = v as &u8; //~ ERROR non-primitive cast @@ -39,6 +43,7 @@ fn main() let _ = 3_i32 as bool; //~ ERROR cannot cast let _ = E::A as bool; //~ ERROR cannot cast let _ = 0x61u32 as char; //~ ERROR can be cast as + let _ = Inches as f32; //~ ERROR is invalid let _ = false as f32; //~ ERROR is invalid let _ = E::A as f32; //~ ERROR is invalid @@ -58,7 +63,7 @@ fn main() let _ = &f as *const f64; //~ ERROR is invalid let _ = fat_sv as usize; //~ ERROR is invalid - let a : *const str = "hello"; + let a: *const str = "hello"; let _ = a as *const dyn Foo; //~ ERROR the size for values of type // check no error cascade diff --git a/tests/ui/cast/cast-rfc0401-fail.stderr b/tests/ui/cast/cast-rfc0401-fail.stderr index a188b7791fdc8..c41e6e3612dd3 100644 --- a/tests/ui/cast/cast-rfc0401-fail.stderr +++ b/tests/ui/cast/cast-rfc0401-fail.stderr @@ -1,5 +1,5 @@ error[E0606]: casting `*const U` as `*const V` is invalid - --> $DIR/cast-rfc0401.rs:3:5 + --> $DIR/cast-rfc0401-fail.rs:2:5 | LL | u as *const V | ^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | u as *const V = note: the pointers may have different metadata error[E0606]: casting `*const U` as `*const str` is invalid - --> $DIR/cast-rfc0401.rs:8:5 + --> $DIR/cast-rfc0401-fail.rs:6:5 | LL | u as *const str | ^^^^^^^^^^^^^^^ @@ -15,13 +15,13 @@ LL | u as *const str = note: the pointers may have different metadata error[E0609]: no field `f` on type `fn() {main}` - --> $DIR/cast-rfc0401.rs:65:18 + --> $DIR/cast-rfc0401-fail.rs:70:18 | LL | let _ = main.f as *const u32; | ^ unknown field error[E0605]: non-primitive cast: `*const u8` as `&u8` - --> $DIR/cast-rfc0401.rs:29:13 + --> $DIR/cast-rfc0401-fail.rs:33:13 | LL | let _ = v as &u8; | ^^^^^^^^ invalid cast @@ -33,43 +33,43 @@ LL + let _ = &*v; | error[E0605]: non-primitive cast: `*const u8` as `E` - --> $DIR/cast-rfc0401.rs:30:13 + --> $DIR/cast-rfc0401-fail.rs:34:13 | LL | let _ = v as E; | ^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0605]: non-primitive cast: `*const u8` as `fn()` - --> $DIR/cast-rfc0401.rs:31:13 + --> $DIR/cast-rfc0401-fail.rs:35:13 | LL | let _ = v as fn(); | ^^^^^^^^^ invalid cast error[E0605]: non-primitive cast: `*const u8` as `(u32,)` - --> $DIR/cast-rfc0401.rs:32:13 + --> $DIR/cast-rfc0401-fail.rs:36:13 | LL | let _ = v as (u32,); | ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0605]: non-primitive cast: `Option<&*const u8>` as `*const u8` - --> $DIR/cast-rfc0401.rs:33:13 + --> $DIR/cast-rfc0401-fail.rs:37:13 | LL | let _ = Some(&v) as *const u8; | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0606]: casting `*const u8` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:35:13 + --> $DIR/cast-rfc0401-fail.rs:39:13 | LL | let _ = v as f32; | ^^^^^^^^ error[E0606]: casting `fn() {main}` as `f64` is invalid - --> $DIR/cast-rfc0401.rs:36:13 + --> $DIR/cast-rfc0401-fail.rs:40:13 | LL | let _ = main as f64; | ^^^^^^^^^^^ error[E0606]: casting `&*const u8` as `usize` is invalid - --> $DIR/cast-rfc0401.rs:37:13 + --> $DIR/cast-rfc0401-fail.rs:41:13 | LL | let _ = &v as usize; | ^^^^^^^^^^^ @@ -77,13 +77,13 @@ LL | let _ = &v as usize; = help: cast through a raw pointer first error[E0606]: casting `f32` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:38:13 + --> $DIR/cast-rfc0401-fail.rs:42:13 | LL | let _ = f as *const u8; | ^^^^^^^^^^^^^^ error[E0054]: cannot cast `i32` as `bool` - --> $DIR/cast-rfc0401.rs:39:13 + --> $DIR/cast-rfc0401-fail.rs:43:13 | LL | let _ = 3_i32 as bool; | ^^^^^^^^^^^^^ @@ -95,13 +95,13 @@ LL + let _ = 3_i32 != 0; | error[E0054]: cannot cast `E` as `bool` - --> $DIR/cast-rfc0401.rs:40:13 + --> $DIR/cast-rfc0401-fail.rs:44:13 | LL | let _ = E::A as bool; | ^^^^^^^^^^^^ unsupported cast error[E0604]: only `u8` can be cast as `char`, not `u32` - --> $DIR/cast-rfc0401.rs:41:13 + --> $DIR/cast-rfc0401-fail.rs:45:13 | LL | let _ = 0x61u32 as char; | ^^^^^^^^^^^^^^^ invalid cast @@ -112,8 +112,14 @@ LL - let _ = 0x61u32 as char; LL + let _ = char::from_u32(0x61u32); | +error[E0606]: casting `fn(i32) -> Inches {Inches}` as `f32` is invalid + --> $DIR/cast-rfc0401-fail.rs:46:13 + | +LL | let _ = Inches as f32; + | ^^^^^^^^^^^^^ + error[E0606]: casting `bool` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:43:13 + --> $DIR/cast-rfc0401-fail.rs:48:13 | LL | let _ = false as f32; | ^^^^^^^^^^^^ @@ -121,7 +127,7 @@ LL | let _ = false as f32; = help: cast through an integer first error[E0606]: casting `E` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:44:13 + --> $DIR/cast-rfc0401-fail.rs:49:13 | LL | let _ = E::A as f32; | ^^^^^^^^^^^ @@ -129,7 +135,7 @@ LL | let _ = E::A as f32; = help: cast through an integer first error[E0606]: casting `char` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:45:13 + --> $DIR/cast-rfc0401-fail.rs:50:13 | LL | let _ = 'a' as f32; | ^^^^^^^^^^ @@ -137,25 +143,25 @@ LL | let _ = 'a' as f32; = help: cast through an integer first error[E0606]: casting `bool` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:47:13 + --> $DIR/cast-rfc0401-fail.rs:52:13 | LL | let _ = false as *const u8; | ^^^^^^^^^^^^^^^^^^ error[E0606]: casting `E` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:48:13 + --> $DIR/cast-rfc0401-fail.rs:53:13 | LL | let _ = E::A as *const u8; | ^^^^^^^^^^^^^^^^^ error[E0606]: casting `char` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:49:13 + --> $DIR/cast-rfc0401-fail.rs:54:13 | LL | let _ = 'a' as *const u8; | ^^^^^^^^^^^^^^^^ error[E0606]: cannot cast `usize` to a pointer that is wide - --> $DIR/cast-rfc0401.rs:51:24 + --> $DIR/cast-rfc0401-fail.rs:56:24 | LL | let _ = 42usize as *const [u8]; | ------- ^^^^^^^^^^^ creating a `*const [u8]` requires both an address and a length @@ -163,43 +169,43 @@ LL | let _ = 42usize as *const [u8]; | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` error[E0607]: cannot cast thin pointer `*const u8` to wide pointer `*const [u8]` - --> $DIR/cast-rfc0401.rs:52:13 + --> $DIR/cast-rfc0401-fail.rs:57:13 | LL | let _ = v as *const [u8]; | ^^^^^^^^^^^^^^^^ error[E0606]: casting `&dyn Foo` as `*const str` is invalid - --> $DIR/cast-rfc0401.rs:54:13 + --> $DIR/cast-rfc0401-fail.rs:59:13 | LL | let _ = foo as *const str; | ^^^^^^^^^^^^^^^^^ error[E0606]: casting `&dyn Foo` as `*mut str` is invalid - --> $DIR/cast-rfc0401.rs:55:13 + --> $DIR/cast-rfc0401-fail.rs:60:13 | LL | let _ = foo as *mut str; | ^^^^^^^^^^^^^^^ error[E0606]: casting `fn() {main}` as `*mut str` is invalid - --> $DIR/cast-rfc0401.rs:56:13 + --> $DIR/cast-rfc0401-fail.rs:61:13 | LL | let _ = main as *mut str; | ^^^^^^^^^^^^^^^^ error[E0606]: casting `&f32` as `*mut f32` is invalid - --> $DIR/cast-rfc0401.rs:57:13 + --> $DIR/cast-rfc0401-fail.rs:62:13 | LL | let _ = &f as *mut f32; | ^^^^^^^^^^^^^^ error[E0606]: casting `&f32` as `*const f64` is invalid - --> $DIR/cast-rfc0401.rs:58:13 + --> $DIR/cast-rfc0401-fail.rs:63:13 | LL | let _ = &f as *const f64; | ^^^^^^^^^^^^^^^^ error[E0606]: casting `*const [i8]` as `usize` is invalid - --> $DIR/cast-rfc0401.rs:59:13 + --> $DIR/cast-rfc0401-fail.rs:64:13 | LL | let _ = fat_sv as usize; | ^^^^^^^^^^^^^^^ @@ -207,7 +213,7 @@ LL | let _ = fat_sv as usize; = help: cast through a thin pointer first error[E0606]: casting `*const dyn Foo` as `*const [u16]` is invalid - --> $DIR/cast-rfc0401.rs:68:13 + --> $DIR/cast-rfc0401-fail.rs:73:13 | LL | let _ = cf as *const [u16]; | ^^^^^^^^^^^^^^^^^^ @@ -215,7 +221,7 @@ LL | let _ = cf as *const [u16]; = note: the pointers have different metadata error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid - --> $DIR/cast-rfc0401.rs:69:13 + --> $DIR/cast-rfc0401-fail.rs:74:13 | LL | let _ = cf as *const dyn Bar; | ^^^^^^^^^^^^^^^^^^^^ @@ -223,7 +229,7 @@ LL | let _ = cf as *const dyn Bar; = note: the trait objects may have different vtables error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/cast-rfc0401.rs:53:13 + --> $DIR/cast-rfc0401-fail.rs:58:13 | LL | let _ = fat_v as *const dyn Foo; | ^^^^^ doesn't have a size known at compile-time @@ -232,7 +238,7 @@ LL | let _ = fat_v as *const dyn Foo; = note: required for the cast from `*const [u8]` to `*const dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/cast-rfc0401.rs:62:13 + --> $DIR/cast-rfc0401-fail.rs:67:13 | LL | let _ = a as *const dyn Foo; | ^ doesn't have a size known at compile-time @@ -241,7 +247,7 @@ LL | let _ = a as *const dyn Foo; = note: required for the cast from `*const str` to `*const dyn Foo` error[E0606]: casting `&{float}` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:71:30 + --> $DIR/cast-rfc0401-fail.rs:76:30 | LL | vec![0.0].iter().map(|s| s as f32).collect::>(); | ^^^^^^^^ @@ -251,7 +257,7 @@ help: dereference the expression LL | vec![0.0].iter().map(|s| *s as f32).collect::>(); | + -error: aborting due to 34 previous errors +error: aborting due to 35 previous errors Some errors have detailed explanations: E0054, E0277, E0604, E0605, E0606, E0607, E0609. For more information about an error, try `rustc --explain E0054`. diff --git a/tests/ui/cast/cast-to-dyn-any.rs b/tests/ui/cast/cast-to-dyn-any.rs index e1b3dfe5b61bd..3180c530209e8 100644 --- a/tests/ui/cast/cast-to-dyn-any.rs +++ b/tests/ui/cast/cast-to-dyn-any.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { 0 as &dyn std::any::Any; //~ ERROR non-primitive cast } diff --git a/tests/ui/cast/cast-to-dyn-any.stderr b/tests/ui/cast/cast-to-dyn-any.stderr index 560fbc73bbdc8..6ee1098fcf406 100644 --- a/tests/ui/cast/cast-to-dyn-any.stderr +++ b/tests/ui/cast/cast-to-dyn-any.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `i32` as `&(dyn Any + 'static)` - --> $DIR/issue-22289.rs:2:5 + --> $DIR/cast-to-dyn-any.rs:3:5 | LL | 0 as &dyn std::any::Any; | ^^^^^^^^^^^^^^^^^^^^^^^ invalid cast diff --git a/tests/ui/closures/closure-array-break-length-2.rs b/tests/ui/closures/closure-array-break-length-2.rs deleted file mode 100644 index 60589f7c264a6..0000000000000 --- a/tests/ui/closures/closure-array-break-length-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - loop { - |_: [_; break]| {} //~ ERROR: `break` outside of a loop - } - - loop { - |_: [_; continue]| {} //~ ERROR: `continue` outside of a loop - } -} diff --git a/tests/ui/closures/closure-array-break-length-2.stderr b/tests/ui/closures/closure-array-break-length-2.stderr deleted file mode 100644 index 2df7b6d7f63c6..0000000000000 --- a/tests/ui/closures/closure-array-break-length-2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0268]: `break` outside of a loop or labeled block - --> $DIR/array-break-length.rs:3:17 - | -LL | |_: [_; break]| {} - | ^^^^^ cannot `break` outside of a loop or labeled block - -error[E0268]: `continue` outside of a loop - --> $DIR/array-break-length.rs:7:17 - | -LL | |_: [_; continue]| {} - | ^^^^^^^^ cannot `continue` outside of a loop - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/closures/closure-array-break-length.rs b/tests/ui/closures/closure-array-break-length.rs index fda590fda022c..c90ae6585dcab 100644 --- a/tests/ui/closures/closure-array-break-length.rs +++ b/tests/ui/closures/closure-array-break-length.rs @@ -1,7 +1,18 @@ +//! regression test for issue fn main() { |_: [_; continue]| {}; //~ ERROR: `continue` outside of a loop + |_: [_; break]| (); //~ ERROR: `break` outside of a loop or labeled block + while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of a loop while |_: [_; break]| {} {} //~ ERROR: `break` outside of a loop + + loop { + |_: [_; break]| {} //~ ERROR: `break` outside of a loop + } + + loop { + |_: [_; continue]| {} //~ ERROR: `continue` outside of a loop + } } diff --git a/tests/ui/closures/closure-array-break-length.stderr b/tests/ui/closures/closure-array-break-length.stderr index 7e0b0027a6f09..3256c50bb9066 100644 --- a/tests/ui/closures/closure-array-break-length.stderr +++ b/tests/ui/closures/closure-array-break-length.stderr @@ -1,21 +1,39 @@ error[E0268]: `continue` outside of a loop - --> $DIR/closure-array-break-length.rs:2:13 + --> $DIR/closure-array-break-length.rs:3:13 | LL | |_: [_; continue]| {}; | ^^^^^^^^ cannot `continue` outside of a loop +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/closure-array-break-length.rs:5:13 + | +LL | |_: [_; break]| (); + | ^^^^^ cannot `break` outside of a loop or labeled block + error[E0268]: `continue` outside of a loop - --> $DIR/closure-array-break-length.rs:4:19 + --> $DIR/closure-array-break-length.rs:7:19 | LL | while |_: [_; continue]| {} {} | ^^^^^^^^ cannot `continue` outside of a loop error[E0268]: `break` outside of a loop or labeled block - --> $DIR/closure-array-break-length.rs:6:19 + --> $DIR/closure-array-break-length.rs:9:19 | LL | while |_: [_; break]| {} {} | ^^^^^ cannot `break` outside of a loop or labeled block -error: aborting due to 3 previous errors +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/closure-array-break-length.rs:12:17 + | +LL | |_: [_; break]| {} + | ^^^^^ cannot `break` outside of a loop or labeled block + +error[E0268]: `continue` outside of a loop + --> $DIR/closure-array-break-length.rs:16:17 + | +LL | |_: [_; continue]| {} + | ^^^^^^^^ cannot `continue` outside of a loop + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/closures/closure-move-use-after-move-diagnostic.rs b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs index 63c061594d87e..3326af7486c5e 100644 --- a/tests/ui/closures/closure-move-use-after-move-diagnostic.rs +++ b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs @@ -1,13 +1,16 @@ +//! regression test for struct NoCopy; //~ NOTE if `NoCopy` implemented `Clone`, you could clone the value //~^ NOTE consider implementing `Clone` for this type fn main() { - let x = NoCopy; - //~^ NOTE move occurs because `x` has type `NoCopy` - let f = move || { let y = x; }; - //~^ NOTE value moved into closure here - //~| NOTE variable moved due to use in closure - //~| NOTE you could clone this value - let z = x; - //~^ ERROR use of moved value: `x` - //~| NOTE value used here after move + let x = NoCopy; + //~^ NOTE move occurs because `x` has type `NoCopy` + let f = move || { + //~^ NOTE value moved into closure here + let y = x; + //~^ NOTE variable moved due to use in closure + //~| NOTE you could clone this value + }; + let z = x; + //~^ ERROR use of moved value: `x` + //~| NOTE value used here after move } diff --git a/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr b/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr index 2d85077fe4c21..94f80da1b10a4 100644 --- a/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr +++ b/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr @@ -1,25 +1,26 @@ error[E0382]: use of moved value: `x` - --> $DIR/issue-24357.rs:10:12 + --> $DIR/closure-move-use-after-move-diagnostic.rs:13:13 | -LL | let x = NoCopy; - | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait +LL | let x = NoCopy; + | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait LL | -LL | let f = move || { let y = x; }; - | ------- - variable moved due to use in closure - | | - | value moved into closure here +LL | let f = move || { + | ------- value moved into closure here +LL | +LL | let y = x; + | - variable moved due to use in closure ... -LL | let z = x; - | ^ value used here after move +LL | let z = x; + | ^ value used here after move | note: if `NoCopy` implemented `Clone`, you could clone the value - --> $DIR/issue-24357.rs:1:1 + --> $DIR/closure-move-use-after-move-diagnostic.rs:2:1 | LL | struct NoCopy; | ^^^^^^^^^^^^^ consider implementing `Clone` for this type ... -LL | let f = move || { let y = x; }; - | - you could clone this value +LL | let y = x; + | - you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-return-outside-fn.rs b/tests/ui/consts/const-return-outside-fn.rs index 665a8fdf8e26e..c2ee8642bf4b1 100644 --- a/tests/ui/consts/const-return-outside-fn.rs +++ b/tests/ui/consts/const-return-outside-fn.rs @@ -1,3 +1,4 @@ +//! regression test for issue const x: () = { return; //~ ERROR return statement outside of function body }; diff --git a/tests/ui/consts/const-return-outside-fn.stderr b/tests/ui/consts/const-return-outside-fn.stderr index fbf88d5033973..131d577a2547e 100644 --- a/tests/ui/consts/const-return-outside-fn.stderr +++ b/tests/ui/consts/const-return-outside-fn.stderr @@ -1,5 +1,5 @@ error[E0572]: return statement outside of function body - --> $DIR/issue-38458.rs:2:5 + --> $DIR/const-return-outside-fn.rs:3:5 | LL | return; | ^^^^^^ diff --git a/tests/ui/drop/drop-conflicting-impls.rs b/tests/ui/drop/drop-conflicting-impls.rs index ce511158f0051..fba3462a24b2f 100644 --- a/tests/ui/drop/drop-conflicting-impls.rs +++ b/tests/ui/drop/drop-conflicting-impls.rs @@ -1,12 +1,13 @@ +//! regression test for issue struct MyStruct; impl Drop for MyStruct { - fn drop(&mut self) { } + fn drop(&mut self) {} } impl Drop for MyStruct { -//~^ ERROR conflicting implementations of trait - fn drop(&mut self) { } + //~^ ERROR conflicting implementations of trait + fn drop(&mut self) {} } fn main() {} diff --git a/tests/ui/drop/drop-conflicting-impls.stderr b/tests/ui/drop/drop-conflicting-impls.stderr index c8db0403e59a2..ee310f498d373 100644 --- a/tests/ui/drop/drop-conflicting-impls.stderr +++ b/tests/ui/drop/drop-conflicting-impls.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Drop` for type `MyStruct` - --> $DIR/issue-28568.rs:7:1 + --> $DIR/drop-conflicting-impls.rs:8:1 | LL | impl Drop for MyStruct { | ---------------------- first implementation here diff --git a/tests/ui/enum/enum-discriminant-missing-variant.rs b/tests/ui/enum/enum-discriminant-missing-variant.rs index 09f9ebccf2505..1bdbfb1fbcd42 100644 --- a/tests/ui/enum/enum-discriminant-missing-variant.rs +++ b/tests/ui/enum/enum-discriminant-missing-variant.rs @@ -1,3 +1,4 @@ +//! regression test for issue pub enum SomeEnum { B = SomeEnum::A, //~ ERROR no variant or associated item named `A` found } diff --git a/tests/ui/enum/enum-discriminant-missing-variant.stderr b/tests/ui/enum/enum-discriminant-missing-variant.stderr index 830d260f99d7d..ef98a93e86f66 100644 --- a/tests/ui/enum/enum-discriminant-missing-variant.stderr +++ b/tests/ui/enum/enum-discriminant-missing-variant.stderr @@ -1,5 +1,5 @@ error[E0599]: no variant or associated item named `A` found for enum `SomeEnum` in the current scope - --> $DIR/issue-23217.rs:2:19 + --> $DIR/enum-discriminant-missing-variant.rs:3:19 | LL | pub enum SomeEnum { | ----------------- variant or associated item `A` not found for this enum diff --git a/tests/ui/mismatched_types/cast-rfc0401-2.rs b/tests/ui/mismatched_types/cast-rfc0401-2.rs deleted file mode 100644 index c176b1247cea9..0000000000000 --- a/tests/ui/mismatched_types/cast-rfc0401-2.rs +++ /dev/null @@ -1,6 +0,0 @@ -struct Inches(i32); - -fn main() { - Inches as f32; - //~^ ERROR casting -} diff --git a/tests/ui/mismatched_types/cast-rfc0401-2.stderr b/tests/ui/mismatched_types/cast-rfc0401-2.stderr deleted file mode 100644 index b1b59af6ec2b2..0000000000000 --- a/tests/ui/mismatched_types/cast-rfc0401-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0606]: casting `fn(i32) -> Inches {Inches}` as `f32` is invalid - --> $DIR/issue-21554.rs:4:5 - | -LL | Inches as f32; - | ^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0606`. diff --git a/tests/ui/nll/borrowck-annotate-static-lifetime.rs b/tests/ui/nll/borrowck-annotate-static-lifetime.rs index 2f78ce0002ba3..9d849db9b4f39 100644 --- a/tests/ui/nll/borrowck-annotate-static-lifetime.rs +++ b/tests/ui/nll/borrowck-annotate-static-lifetime.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { let _vec: Vec<&'static String> = vec![&String::new()]; //~^ ERROR temporary value dropped while borrowed [E0716] diff --git a/tests/ui/nll/borrowck-annotate-static-lifetime.stderr b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr index d25c6eda9c349..9cb9007d91314 100644 --- a/tests/ui/nll/borrowck-annotate-static-lifetime.stderr +++ b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-47184.rs:2:44 + --> $DIR/borrowck-annotate-static-lifetime.rs:3:44 | LL | let _vec: Vec<&'static String> = vec![&String::new()]; | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement diff --git a/tests/ui/nll/nll-anon-to-static.rs b/tests/ui/nll/nll-anon-to-static.rs index 4bd49a8796b34..3dc79950056cf 100644 --- a/tests/ui/nll/nll-anon-to-static.rs +++ b/tests/ui/nll/nll-anon-to-static.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn foo(x: &u32) -> &'static u32 { &*x //~^ ERROR lifetime may not live long enough diff --git a/tests/ui/nll/nll-anon-to-static.stderr b/tests/ui/nll/nll-anon-to-static.stderr index f47df306ab845..e431dfd992e15 100644 --- a/tests/ui/nll/nll-anon-to-static.stderr +++ b/tests/ui/nll/nll-anon-to-static.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-46983.rs:2:5 + --> $DIR/nll-anon-to-static.rs:3:5 | LL | fn foo(x: &u32) -> &'static u32 { | - let's call the lifetime of this reference `'1` diff --git a/tests/ui/parser/missing-operator-after-float.rs b/tests/ui/parser/missing-operator-after-float.rs index 15649f777e090..8868689ff81f3 100644 --- a/tests/ui/parser/missing-operator-after-float.rs +++ b/tests/ui/parser/missing-operator-after-float.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 }; //~^ ERROR expected function, found `{float}` diff --git a/tests/ui/parser/missing-operator-after-float.stderr b/tests/ui/parser/missing-operator-after-float.stderr index 95a39b1d1980e..08878cf098a7c 100644 --- a/tests/ui/parser/missing-operator-after-float.stderr +++ b/tests/ui/parser/missing-operator-after-float.stderr @@ -1,5 +1,5 @@ error[E0618]: expected function, found `{float}` - --> $DIR/issue-45965.rs:2:30 + --> $DIR/missing-operator-after-float.rs:3:30 | LL | let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 }; | ^^^---------- diff --git a/tests/ui/parser/unbalanced-doublequote-2.rs b/tests/ui/parser/unbalanced-doublequote-2.rs index b8c0e285ffcab..1906f96f6c9b9 100644 --- a/tests/ui/parser/unbalanced-doublequote-2.rs +++ b/tests/ui/parser/unbalanced-doublequote-2.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { "😊""; //~ ERROR unterminated double quote } diff --git a/tests/ui/parser/unbalanced-doublequote-2.stderr b/tests/ui/parser/unbalanced-doublequote-2.stderr index 3e12de34e11ee..3a6efaf7d4ec4 100644 --- a/tests/ui/parser/unbalanced-doublequote-2.stderr +++ b/tests/ui/parser/unbalanced-doublequote-2.stderr @@ -1,5 +1,5 @@ error[E0765]: unterminated double quote string - --> $DIR/issue-44078.rs:2:8 + --> $DIR/unbalanced-doublequote-2.rs:3:8 | LL | "😊""; | _________^ diff --git a/tests/ui/resolve/missing-associated-items.rs b/tests/ui/resolve/missing-associated-items.rs index 92f4c546440ab..72d6cbb3f1497 100644 --- a/tests/ui/resolve/missing-associated-items.rs +++ b/tests/ui/resolve/missing-associated-items.rs @@ -1,9 +1,17 @@ -enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ } +//! regression test for issue +enum Token { + LeftParen, + RightParen, + Plus, + Minus, /* etc */ +} struct Struct { a: usize, } -fn use_token(token: &Token) { unimplemented!() } +fn use_token(token: &Token) { + unimplemented!() +} fn main() { use_token(&Token::Homura); //~ ERROR no variant or associated item named `Homura` diff --git a/tests/ui/resolve/missing-associated-items.stderr b/tests/ui/resolve/missing-associated-items.stderr index d07d1a7caaf24..d27a3a644aee5 100644 --- a/tests/ui/resolve/missing-associated-items.stderr +++ b/tests/ui/resolve/missing-associated-items.stderr @@ -1,14 +1,14 @@ error[E0599]: no variant or associated item named `Homura` found for enum `Token` in the current scope - --> $DIR/issue-23173.rs:9:23 + --> $DIR/missing-associated-items.rs:17:23 | -LL | enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ } +LL | enum Token { | ---------- variant or associated item `Homura` not found for this enum ... LL | use_token(&Token::Homura); | ^^^^^^ variant or associated item not found in `Token` error[E0599]: no function or associated item named `method` found for struct `Struct` in the current scope - --> $DIR/issue-23173.rs:10:13 + --> $DIR/missing-associated-items.rs:18:13 | LL | struct Struct { | ------------- function or associated item `method` not found for this struct @@ -17,7 +17,7 @@ LL | Struct::method(); | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no function or associated item named `method` found for struct `Struct` in the current scope - --> $DIR/issue-23173.rs:11:13 + --> $DIR/missing-associated-items.rs:19:13 | LL | struct Struct { | ------------- function or associated item `method` not found for this struct @@ -26,7 +26,7 @@ LL | Struct::method; | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no associated item named `Assoc` found for struct `Struct` in the current scope - --> $DIR/issue-23173.rs:12:13 + --> $DIR/missing-associated-items.rs:20:13 | LL | struct Struct { | ------------- associated item `Assoc` not found for this struct diff --git a/tests/ui/typeck/for-in-const-eval.rs b/tests/ui/typeck/for-in-const-eval.rs index 1358e0bde4c82..f187a9ef30771 100644 --- a/tests/ui/typeck/for-in-const-eval.rs +++ b/tests/ui/typeck/for-in-const-eval.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { Vec::<[(); 1 + for x in 0..1 {}]>::new(); //~^ ERROR cannot add diff --git a/tests/ui/typeck/for-in-const-eval.stderr b/tests/ui/typeck/for-in-const-eval.stderr index 168f5894fb030..e7a2558495813 100644 --- a/tests/ui/typeck/for-in-const-eval.stderr +++ b/tests/ui/typeck/for-in-const-eval.stderr @@ -1,5 +1,5 @@ error[E0277]: cannot add `()` to `{integer}` - --> $DIR/issue-50582.rs:2:18 + --> $DIR/for-in-const-eval.rs:3:18 | LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` From 75f53dd70e23b09e2557ca7c73bcaa22b9d1a8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Dec 2025 14:16:25 +0100 Subject: [PATCH 24/27] Update bors configuration --- rust-bors.toml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/rust-bors.toml b/rust-bors.toml index e813c6c4b1166..996b50b2ea27a 100644 --- a/rust-bors.toml +++ b/rust-bors.toml @@ -25,3 +25,42 @@ labels_blocking_approval = [ "S-waiting-on-t-rustdoc-frontend", "S-waiting-on-t-clippy" ] + +# If CI runs quicker than this duration, consider it to be a failure +min_ci_time = 600 + +[labels] +approved = [ + "+S-waiting-on-bors", + "-S-blocked", + "-S-waiting-on-author", + "-S-waiting-on-crater", + "-S-waiting-on-review", + "-S-waiting-on-team" +] +unapproved = [ + "+S-waiting-on-author", + "-S-blocked", + "-S-waiting-on-bors", + "-S-waiting-on-crater", + "-S-waiting-on-review", + "-S-waiting-on-team" +] +try_failed = [ + "+S-waiting-on-author", + "-S-waiting-on-review", + "-S-waiting-on-crater" +] +auto_build_succeeded = ["+merged-by-bors"] +auto_build_failed = [ + "+S-waiting-on-review", + "-S-blocked", + "-S-waiting-on-bors", + "-S-waiting-on-author", + "-S-waiting-on-crater", + "-S-waiting-on-team" +] + +# Flip this two once new bors is used for actual merges on this repository +merge_queue_enabled = false +report_merge_conflicts = true From bbf4ec3b0fd31a813208791dcce4264ed6bdbae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Dec 2025 15:47:03 +0100 Subject: [PATCH 25/27] Add support for `automation/bors/auto` merge branch --- .github/workflows/ci.yml | 7 ++++--- src/ci/citool/src/main.rs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05aa600e649eb..bb6bc325a3bb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ on: - try - try-perf - automation/bors/try + - automation/bors/auto pull_request: branches: - "**" @@ -56,7 +57,7 @@ jobs: - name: Test citool # Only test citool on the auto branch, to reduce latency of the calculate matrix job # on PR/try builds. - if: ${{ github.ref == 'refs/heads/auto' }} + if: ${{ github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto' }} run: | cd src/ci/citool CARGO_INCREMENTAL=0 cargo test @@ -79,7 +80,7 @@ jobs: # access the environment. # # We only enable the environment for the rust-lang/rust repository, so that CI works on forks. - environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }} + environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }} env: CI_JOB_NAME: ${{ matrix.name }} CI_JOB_DOC_URL: ${{ matrix.doc_url }} @@ -313,7 +314,7 @@ jobs: needs: [ calculate_matrix, job ] # !cancelled() executes the job regardless of whether the previous jobs passed or failed if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }} - environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }} + environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }} steps: - name: checkout the source code uses: actions/checkout@v5 diff --git a/src/ci/citool/src/main.rs b/src/ci/citool/src/main.rs index 4fe9cee900ca6..d7b491d38f41f 100644 --- a/src/ci/citool/src/main.rs +++ b/src/ci/citool/src/main.rs @@ -46,7 +46,9 @@ impl GitHubContext { let patterns = if !patterns.is_empty() { Some(patterns) } else { None }; Some(RunType::TryJob { job_patterns: patterns }) } - ("push", "refs/heads/auto") => Some(RunType::AutoJob), + ("push", "refs/heads/auto" | "refs/heads/automation/bors/auto") => { + Some(RunType::AutoJob) + } ("push", "refs/heads/main") => Some(RunType::MainJob), _ => None, } From 306bd5e3040580df4b20067c157f39e0ed5e4028 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 23 Dec 2025 15:50:33 +0000 Subject: [PATCH 26/27] Avoid using env::temp when linking a binary This keeps all build artefacts (even temporary ones) within the build directory. --- compiler/rustc_codegen_ssa/src/back/link.rs | 11 ++++++----- compiler/rustc_fs_util/src/lib.rs | 6 +----- tests/run-make/invalid-tmpdir-env-var/rmake.rs | 10 ++++++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 70db6794742d0..ba07345dd43f5 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -103,17 +103,18 @@ pub fn link_binary( }); if outputs.outputs.should_link() { - let tmpdir = TempDirBuilder::new() - .prefix("rustc") - .tempdir() - .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); - let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); let output = out_filename( sess, crate_type, outputs, codegen_results.crate_info.local_crate_name, ); + let tmpdir = TempDirBuilder::new() + .prefix("rustc") + .tempdir_in(output.parent().unwrap_or_else(|| Path::new("."))) + .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); + let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); + let crate_name = format!("{}", codegen_results.crate_info.local_crate_name); let out_filename = output.file_for_writing( outputs, diff --git a/compiler/rustc_fs_util/src/lib.rs b/compiler/rustc_fs_util/src/lib.rs index 7a883a13b72da..e21da4cdddf7d 100644 --- a/compiler/rustc_fs_util/src/lib.rs +++ b/compiler/rustc_fs_util/src/lib.rs @@ -1,6 +1,6 @@ use std::ffi::{CString, OsStr}; use std::path::{Path, PathBuf, absolute}; -use std::{env, fs, io}; +use std::{fs, io}; use tempfile::TempDir; @@ -139,8 +139,4 @@ impl<'a, 'b> TempDirBuilder<'a, 'b> { } self.builder.tempdir_in(dir) } - - pub fn tempdir(&self) -> io::Result { - self.tempdir_in(env::temp_dir()) - } } diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-env-var/rmake.rs index c5b9dca33a940..bbfec6cca83a9 100644 --- a/tests/run-make/invalid-tmpdir-env-var/rmake.rs +++ b/tests/run-make/invalid-tmpdir-env-var/rmake.rs @@ -1,9 +1,7 @@ //@ needs-target-std // // When the TMP (on Windows) or TMPDIR (on Unix) variable is set to an invalid -// or non-existing directory, this used to cause an internal compiler error (ICE). After the -// addition of proper error handling in #28430, this test checks that the expected message is -// printed. +// or non-existing directory, this used to cause an internal compiler error (ICE). // See https://github.com/rust-lang/rust/issues/14698 use run_make_support::{is_windows, rustc}; @@ -18,5 +16,9 @@ fn main() { } else { rustc.env("TMPDIR", "fake"); } - rustc.input("foo.rs").run_fail().assert_stderr_contains("couldn't create a temp dir"); + let result = rustc.input("foo.rs").run_unchecked(); + // Ensure that rustc doesn't ICE. + if !result.status().success() { + result.assert_stderr_not_contains("internal compiler error"); + } } From d6943479f51e578ca9a69cf685a2d9980d5dbf12 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 23 Dec 2025 17:46:09 +0000 Subject: [PATCH 27/27] Rename invalid-tmpdir-env-var to invalid-tmpdir-no-ice --- .../{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/foo.rs | 0 .../{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/rmake.rs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/run-make/{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/foo.rs (100%) rename tests/run-make/{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/rmake.rs (100%) diff --git a/tests/run-make/invalid-tmpdir-env-var/foo.rs b/tests/run-make/invalid-tmpdir-no-ice/foo.rs similarity index 100% rename from tests/run-make/invalid-tmpdir-env-var/foo.rs rename to tests/run-make/invalid-tmpdir-no-ice/foo.rs diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-no-ice/rmake.rs similarity index 100% rename from tests/run-make/invalid-tmpdir-env-var/rmake.rs rename to tests/run-make/invalid-tmpdir-no-ice/rmake.rs