From 540e41f8b3822661d2f9d0768bbfe1dd3bb65e4d Mon Sep 17 00:00:00 2001
From: Alice Ryhl <aliceryhl@google.com>
Date: Wed, 25 Sep 2024 10:23:30 +0200
Subject: [PATCH 01/13] Add missing module flags for
 function-return=thunk-extern

---
 compiler/rustc_codegen_llvm/src/context.rs | 14 +++++++++++++-
 tests/codegen/function-return.rs           |  6 ++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index 2b8912d1db2..81b82840472 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
 use rustc_middle::{bug, span_bug};
 use rustc_session::Session;
 use rustc_session::config::{
-    BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, PAuthKey, PacRet,
+    BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet,
 };
 use rustc_span::source_map::Spanned;
 use rustc_span::{DUMMY_SP, Span};
@@ -378,6 +378,18 @@ pub(crate) unsafe fn create_module<'ll>(
         }
     }
 
+    match sess.opts.unstable_opts.function_return {
+        FunctionReturn::Keep => {}
+        FunctionReturn::ThunkExtern => unsafe {
+            llvm::LLVMRustAddModuleFlagU32(
+                llmod,
+                llvm::LLVMModFlagBehavior::Override,
+                c"function_return_thunk_extern".as_ptr(),
+                1,
+            )
+        },
+    }
+
     match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support())
     {
         // Set up the small-data optimization limit for architectures that use
diff --git a/tests/codegen/function-return.rs b/tests/codegen/function-return.rs
index 0ca1a41ee86..2b9de4e1478 100644
--- a/tests/codegen/function-return.rs
+++ b/tests/codegen/function-return.rs
@@ -26,3 +26,9 @@ pub fn foo() {
     // keep-thunk-extern: attributes #0 = { {{.*}}fn_ret_thunk_extern{{.*}} }
     // thunk-extern-keep-NOT: fn_ret_thunk_extern
 }
+
+// unset-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
+// keep-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
+// thunk-extern: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
+// keep-thunk-extern: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
+// thunk-extern-keep-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}

From 51537c686c16121aecb5a2b916a1c91a68d60770 Mon Sep 17 00:00:00 2001
From: Mads Marquart <mads@marquart.dk>
Date: Wed, 2 Oct 2024 20:08:48 +0200
Subject: [PATCH 02/13] Fix target_vendor in non-idf Xtensa ESP32 targets

The Xtensa ESP32 targets are the following:
- xtensa-esp32-none-elf
- xtensa-esp32-espidf
- xtensa-esp32s2-none-elf
- xtensa-esp32s2-espidf
- xtensa-esp32s3-none-elf
- xtensa-esp32s3-espidf

The ESP-IDF targets already set `target_vendor="espressif"`, however,
the ESP32 is produced by Espressif regardless of whether using the IDF
or not, so we should set the target vendor there as well.
---
 compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs  | 1 +
 .../rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs     | 1 +
 .../rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs     | 1 +
 3 files changed, 3 insertions(+)

diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs
index 51960dbec4a..254ae54db21 100644
--- a/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs
+++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs
@@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
         },
 
         options: TargetOptions {
+            vendor: "espressif".into(),
             cpu: "esp32".into(),
             linker: Some("xtensa-esp32-elf-gcc".into()),
             max_atomic_width: Some(32),
diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs
index 21330615a87..34d8383a604 100644
--- a/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs
+++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs
@@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
         },
 
         options: TargetOptions {
+            vendor: "espressif".into(),
             cpu: "esp32-s2".into(),
             linker: Some("xtensa-esp32s2-elf-gcc".into()),
             max_atomic_width: Some(32),
diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs
index fca47b4bdb1..023a67f2871 100644
--- a/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs
+++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs
@@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
         },
 
         options: TargetOptions {
+            vendor: "espressif".into(),
             cpu: "esp32-s3".into(),
             linker: Some("xtensa-esp32s3-elf-gcc".into()),
             max_atomic_width: Some(32),

From ad7d41ce90a78dea19b6dffe8aad22ce7b9be32f Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 7 Oct 2024 10:28:16 +0000
Subject: [PATCH 03/13] Test for issue 23600

---
 src/tools/tidy/src/issues.txt                                    | 1 -
 .../{issue-77062-large-zst-array.rs => large-zst-array-77062.rs} | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tests/ui/consts/{issue-77062-large-zst-array.rs => large-zst-array-77062.rs} (53%)

diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt
index 86cae849b97..8dc1ee38ffd 100644
--- a/src/tools/tidy/src/issues.txt
+++ b/src/tools/tidy/src/issues.txt
@@ -802,7 +802,6 @@ ui/consts/issue-70942-trait-vs-impl-mismatch.rs
 ui/consts/issue-73976-monomorphic.rs
 ui/consts/issue-73976-polymorphic.rs
 ui/consts/issue-76064.rs
-ui/consts/issue-77062-large-zst-array.rs
 ui/consts/issue-78655.rs
 ui/consts/issue-79137-monomorphic.rs
 ui/consts/issue-79137-toogeneric.rs
diff --git a/tests/ui/consts/issue-77062-large-zst-array.rs b/tests/ui/consts/large-zst-array-77062.rs
similarity index 53%
rename from tests/ui/consts/issue-77062-large-zst-array.rs
rename to tests/ui/consts/large-zst-array-77062.rs
index ef5178fba95..089353d0885 100644
--- a/tests/ui/consts/issue-77062-large-zst-array.rs
+++ b/tests/ui/consts/large-zst-array-77062.rs
@@ -1,4 +1,5 @@
 //@ build-pass
+pub static FOO: [(); usize::MAX] = [(); usize::MAX];
 
 fn main() {
     let _ = &[(); usize::MAX];

From b577b26249826cdd8a2aa1bdafbe7d5a58ec98fd Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 7 Oct 2024 11:30:18 +0000
Subject: [PATCH 04/13] Add stdio configuring to run-make Rustc

---
 src/tools/run-make-support/src/macros.rs | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/tools/run-make-support/src/macros.rs b/src/tools/run-make-support/src/macros.rs
index f7fe4f54223..be71470321c 100644
--- a/src/tools/run-make-support/src/macros.rs
+++ b/src/tools/run-make-support/src/macros.rs
@@ -70,6 +70,30 @@ macro_rules! impl_common_helpers {
                 self
             }
 
+            /// Configuration for the child process’s standard input (stdin) handle.
+            ///
+            /// See [`std::process::Command::stdin`].
+            pub fn stdin<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
+                self.cmd.stdin(cfg);
+                self
+            }
+
+            /// Configuration for the child process’s standard output (stdout) handle.
+            ///
+            /// See [`std::process::Command::stdout`].
+            pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
+                self.cmd.stdout(cfg);
+                self
+            }
+
+            /// Configuration for the child process’s standard error (stderr) handle.
+            ///
+            /// See [`std::process::Command::stderr`].
+            pub fn stderr<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
+                self.cmd.stderr(cfg);
+                self
+            }
+
             /// Inspect what the underlying [`Command`] is up to the
             /// current construction.
             pub fn inspect<I>(&mut self, inspector: I) -> &mut Self

From 3afb7d687c17518684f3aa4a42909e2b1d9887be Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 7 Oct 2024 11:30:51 +0000
Subject: [PATCH 05/13] Migrate `emit-to-stdout` to new run-make

Co-authored-by: Oneirical <manchot@videotron.ca>
Co-authored-by: Chris Denton <chris@chrisdenton.dev>
---
 src/tools/run-make-support/src/macros.rs      |  6 +-
 .../tidy/src/allowed_run_make_makefiles.txt   |  1 -
 tests/run-make/emit-to-stdout/Makefile        | 51 -------------
 tests/run-make/emit-to-stdout/rmake.rs        | 73 +++++++++++++++++++
 4 files changed, 76 insertions(+), 55 deletions(-)
 delete mode 100644 tests/run-make/emit-to-stdout/Makefile
 create mode 100644 tests/run-make/emit-to-stdout/rmake.rs

diff --git a/src/tools/run-make-support/src/macros.rs b/src/tools/run-make-support/src/macros.rs
index be71470321c..cc3d1281d0a 100644
--- a/src/tools/run-make-support/src/macros.rs
+++ b/src/tools/run-make-support/src/macros.rs
@@ -73,7 +73,7 @@ macro_rules! impl_common_helpers {
             /// Configuration for the child process’s standard input (stdin) handle.
             ///
             /// See [`std::process::Command::stdin`].
-            pub fn stdin<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
+            pub fn stdin<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
                 self.cmd.stdin(cfg);
                 self
             }
@@ -81,7 +81,7 @@ macro_rules! impl_common_helpers {
             /// Configuration for the child process’s standard output (stdout) handle.
             ///
             /// See [`std::process::Command::stdout`].
-            pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
+            pub fn stdout<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
                 self.cmd.stdout(cfg);
                 self
             }
@@ -89,7 +89,7 @@ macro_rules! impl_common_helpers {
             /// Configuration for the child process’s standard error (stderr) handle.
             ///
             /// See [`std::process::Command::stderr`].
-            pub fn stderr<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self {
+            pub fn stderr<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
                 self.cmd.stderr(cfg);
                 self
             }
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 50d21c7ed4c..7a0f98d59f0 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -1,6 +1,5 @@
 run-make/branch-protection-check-IBT/Makefile
 run-make/cat-and-grep-sanity-check/Makefile
-run-make/emit-to-stdout/Makefile
 run-make/extern-fn-reachable/Makefile
 run-make/incr-add-rust-src-component/Makefile
 run-make/issue-84395-lto-embed-bitcode/Makefile
diff --git a/tests/run-make/emit-to-stdout/Makefile b/tests/run-make/emit-to-stdout/Makefile
deleted file mode 100644
index 80e9b6a4ded..00000000000
--- a/tests/run-make/emit-to-stdout/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-include ../tools.mk
-
-SRC=test.rs
-OUT=$(TMPDIR)/out
-
-all: asm llvm-ir dep-info mir llvm-bc obj metadata link multiple-types multiple-types-option-o
-
-asm: $(OUT)
-	$(RUSTC) --emit asm=$(OUT)/$@ $(SRC)
-	$(RUSTC) --emit asm=- $(SRC) | diff - $(OUT)/$@
-llvm-ir: $(OUT)
-	$(RUSTC) --emit llvm-ir=$(OUT)/$@ $(SRC)
-	$(RUSTC) --emit llvm-ir=- $(SRC) | diff - $(OUT)/$@
-dep-info: $(OUT)
-	$(RUSTC) -Z dep-info-omit-d-target=yes --emit dep-info=$(OUT)/$@ $(SRC)
-	$(RUSTC) --emit dep-info=- $(SRC) | diff - $(OUT)/$@
-mir: $(OUT)
-	$(RUSTC) --emit mir=$(OUT)/$@ $(SRC)
-	$(RUSTC) --emit mir=- $(SRC) | diff - $(OUT)/$@
-
-llvm-bc: $(OUT)
-	$(RUSTC) --emit llvm-bc=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true
-	diff $(OUT)/$@ emit-llvm-bc.stderr
-obj: $(OUT)
-	$(RUSTC) --emit obj=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true
-	diff $(OUT)/$@ emit-obj.stderr
-
-# For metadata output, a temporary directory will be created to hold the temporary
-# metadata file. But when output is stdout, the temporary directory will be located
-# in the same place as $(SRC), which is mounted as read-only in the tests. Thus as
-# a workaround, $(SRC) is copied to the test output directory $(OUT) and we compile
-# it there.
-metadata: $(OUT)
-	cp $(SRC) $(OUT)
-	(cd $(OUT); $(RUSTC) --emit metadata=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true)
-	diff $(OUT)/$@ emit-metadata.stderr
-
-link: $(OUT)
-	$(RUSTC) --emit link=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true
-	diff $(OUT)/$@ emit-link.stderr
-
-multiple-types: $(OUT)
-	$(RUSTC) --emit asm=- --emit llvm-ir=- --emit dep-info=- --emit mir=- $(SRC) 2>$(OUT)/$@ || true
-	diff $(OUT)/$@ emit-multiple-types.stderr
-
-multiple-types-option-o: $(OUT)
-	$(RUSTC) -o - --emit asm,llvm-ir,dep-info,mir $(SRC) 2>$(OUT)/$@ || true
-	diff $(OUT)/$@ emit-multiple-types.stderr
-
-$(OUT):
-	mkdir -p $(OUT)
diff --git a/tests/run-make/emit-to-stdout/rmake.rs b/tests/run-make/emit-to-stdout/rmake.rs
new file mode 100644
index 00000000000..a9a3796731b
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/rmake.rs
@@ -0,0 +1,73 @@
+//! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout
+//! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`)
+//! being written this way will result in an error if stdout is a tty.
+//! Multiple output types going to stdout will trigger an error too,
+//! as they would all be mixed together.
+//!
+//! See <https://github.com/rust-lang/rust/pull/111626>.
+
+use std::fs::File;
+
+use run_make_support::{diff, run_in_tmpdir, rustc};
+
+// Test emitting text outputs to stdout works correctly
+fn run_diff(name: &str, file_args: &[&str]) {
+    rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run();
+    let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8();
+    diff().expected_file(name).actual_text("stdout", &out).run();
+}
+
+// Test that emitting binary formats to a terminal gives the correct error
+fn run_terminal_err_diff(name: &str) {
+    #[cfg(not(windows))]
+    let terminal = File::create("/dev/ptmx").unwrap();
+    // FIXME: If this test fails and the compiler does print to the console,
+    // then this will produce a lot of output.
+    // We should spawn a new console instead to print stdout.
+    #[cfg(windows)]
+    let terminal = File::options().read(true).write(true).open(r"\\.\CONOUT$").unwrap();
+
+    let err = File::create(name).unwrap();
+    rustc().emit(format!("{name}=-")).input("test.rs").stdout(terminal).stderr(err).run_fail();
+    diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run();
+}
+
+fn main() {
+    run_in_tmpdir(|| {
+        run_diff("asm", &[]);
+        run_diff("llvm-ir", &[]);
+        run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]);
+        run_diff("mir", &[]);
+
+        run_terminal_err_diff("llvm-bc");
+        run_terminal_err_diff("obj");
+        run_terminal_err_diff("metadata");
+        run_terminal_err_diff("link");
+
+        // Test error for emitting multiple types to stdout
+        rustc()
+            .input("test.rs")
+            .emit("asm=-")
+            .emit("llvm-ir=-")
+            .emit("dep-info=-")
+            .emit("mir=-")
+            .stderr(File::create("multiple-types").unwrap())
+            .run_fail();
+        diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run();
+
+        // Same as above, but using `-o`
+        rustc()
+            .input("test.rs")
+            .output("-")
+            .emit("asm,llvm-ir,dep-info,mir")
+            .stderr(File::create("multiple-types-option-o").unwrap())
+            .run_fail();
+        diff()
+            .expected_file("emit-multiple-types.stderr")
+            .actual_file("multiple-types-option-o")
+            .run();
+
+        // Test that `-o -` redirected to a file works correctly (#26719)
+        rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run();
+    });
+}

From b27c22d6b0a230fc122d541356580f0fb2be2366 Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 7 Oct 2024 11:32:53 +0000
Subject: [PATCH 06/13] Add test for issue 28994

---
 .../fn-pointer/hrtb-assoc-fn-traits-28994.rs  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs

diff --git a/tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs b/tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs
new file mode 100644
index 00000000000..e2f02053f95
--- /dev/null
+++ b/tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs
@@ -0,0 +1,22 @@
+//@ check-pass
+//! Tests that a HRTB + FnOnce bound involving an associated type don't prevent
+//! a function pointer from implementing `Fn` traits.
+//! Test for <https://github.com/rust-lang/rust/issues/28994>
+
+trait LifetimeToType<'a> {
+    type Out;
+}
+
+impl<'a> LifetimeToType<'a> for () {
+    type Out = &'a ();
+}
+
+fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out {
+    val
+}
+
+fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { }
+
+fn main() {
+    assert_fn(id);
+}

From fa4f18be5553bd23856abf717ad86acf0412a2ef Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 7 Oct 2024 11:36:47 +0000
Subject: [PATCH 07/13] Add test for issue 30472

---
 .../assoc-type-hrtb-normalization-30472.rs    | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 tests/ui/traits/assoc-type-hrtb-normalization-30472.rs

diff --git a/tests/ui/traits/assoc-type-hrtb-normalization-30472.rs b/tests/ui/traits/assoc-type-hrtb-normalization-30472.rs
new file mode 100644
index 00000000000..4ce3b9b3b77
--- /dev/null
+++ b/tests/ui/traits/assoc-type-hrtb-normalization-30472.rs
@@ -0,0 +1,32 @@
+//@ check-pass
+//! Tests that associated type projections normalize properly in the presence of HRTBs.
+//! Original issue: <https://github.com/rust-lang/rust/issues/30472>
+
+
+pub trait MyFrom<T> {}
+impl<T> MyFrom<T> for T {}
+
+pub trait MyInto<T> {}
+impl<T, U> MyInto<U> for T where U: MyFrom<T> {}
+
+
+pub trait A<'self_> {
+    type T;
+}
+pub trait B: for<'self_> A<'self_> {
+    // Originally caused the `type U = usize` example below to fail with a type mismatch error
+    type U: for<'self_> MyFrom<<Self as A<'self_>>::T>;
+}
+
+
+pub struct M;
+impl<'self_> A<'self_> for M {
+    type T = usize;
+}
+
+impl B for M {
+    type U = usize;
+}
+
+
+fn main() {}

From 382365bfe3f136fe97273e58532d799a82b373ea Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 7 Oct 2024 11:36:58 +0000
Subject: [PATCH 08/13] Add test for issue 30867

---
 tests/ui/traits/hrtb-related-type-params-30867.rs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 tests/ui/traits/hrtb-related-type-params-30867.rs

diff --git a/tests/ui/traits/hrtb-related-type-params-30867.rs b/tests/ui/traits/hrtb-related-type-params-30867.rs
new file mode 100644
index 00000000000..ec1e3355bfb
--- /dev/null
+++ b/tests/ui/traits/hrtb-related-type-params-30867.rs
@@ -0,0 +1,14 @@
+//@ check-pass
+//! Tests that HRTB impl selection covers type parameters not directly related
+//! to the trait.
+//! Test for <https://github.com/rust-lang/rust/issues/30867>
+
+#![crate_type = "lib"]
+
+trait Unary<T> {}
+impl<T, U, F: Fn(T) -> U> Unary<T> for F {}
+fn unary<F: for<'a> Unary<&'a T>, T>() {}
+
+pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() {
+    unary::<F, i32>()
+}

From 4d7c6ca1bba06574ab04ea4f4d40f42216c05e56 Mon Sep 17 00:00:00 2001
From: rustbot <47979223+rustbot@users.noreply.github.com>
Date: Mon, 7 Oct 2024 13:01:01 -0400
Subject: [PATCH 09/13] Update books

---
 src/doc/book            | 2 +-
 src/doc/embedded-book   | 2 +-
 src/doc/nomicon         | 2 +-
 src/doc/reference       | 2 +-
 src/doc/rust-by-example | 2 +-
 src/doc/rustc-dev-guide | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/doc/book b/src/doc/book
index 99cf75a5414..f38ce8baef9 160000
--- a/src/doc/book
+++ b/src/doc/book
@@ -1 +1 @@
-Subproject commit 99cf75a5414fa8adbe3974bd0836661ca901708f
+Subproject commit f38ce8baef98cb20229e56f1be2d50e345f11792
diff --git a/src/doc/embedded-book b/src/doc/embedded-book
index dbae36bf3f8..f40a8b420ec 160000
--- a/src/doc/embedded-book
+++ b/src/doc/embedded-book
@@ -1 +1 @@
-Subproject commit dbae36bf3f8410aa4313b3bad42e374735d48a9d
+Subproject commit f40a8b420ec4b4505d9489965e261f1d5c28ba23
diff --git a/src/doc/nomicon b/src/doc/nomicon
index 14649f15d23..456b904f791 160000
--- a/src/doc/nomicon
+++ b/src/doc/nomicon
@@ -1 +1 @@
-Subproject commit 14649f15d232d509478206ee9ed5105641aa60d0
+Subproject commit 456b904f791751892b01282fd2757904993c4c26
diff --git a/src/doc/reference b/src/doc/reference
index 24fb2687cdb..c64e52a3d30 160000
--- a/src/doc/reference
+++ b/src/doc/reference
@@ -1 +1 @@
-Subproject commit 24fb2687cdbc54fa18ae4acf5d879cfceca77b2c
+Subproject commit c64e52a3d306eac0129f3ad6c6d8806ab99ae2e9
diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example
index c79ec345f08..8bede1b919a 160000
--- a/src/doc/rust-by-example
+++ b/src/doc/rust-by-example
@@ -1 +1 @@
-Subproject commit c79ec345f08a1e94494cdc8c999709a90203fd88
+Subproject commit 8bede1b919a81ab7d0c961f6bbf68d3efa297bd2
diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide
index 555f3de2fa0..07bc9ca9eb1 160000
--- a/src/doc/rustc-dev-guide
+++ b/src/doc/rustc-dev-guide
@@ -1 +1 @@
-Subproject commit 555f3de2fa0d61c4294b74d245f1cbad6fcbf589
+Subproject commit 07bc9ca9eb1cd6d9fbbf758c2753b748804a134f

From e23419fc97a8ca2fb3f6331115c13b2a5948d2c9 Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Mon, 7 Oct 2024 10:30:27 -0700
Subject: [PATCH 10/13] rustdoc: improve `<wbr>`-insertion for
 SCREAMING_CAMEL_CASE

---
 src/librustdoc/html/escape.rs       | 2 +-
 src/librustdoc/html/escape/tests.rs | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs
index 691f86847b5..72ad42c2bd0 100644
--- a/src/librustdoc/html/escape.rs
+++ b/src/librustdoc/html/escape.rs
@@ -108,7 +108,7 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
                 || pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
             let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
             let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
-            if i - last > 3 && is_uppercase() && !next_is_uppercase() {
+            if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
                 EscapeBodyText(&text[last..i]).fmt(fmt)?;
                 fmt.write_str("<wbr>")?;
                 last = i;
diff --git a/src/librustdoc/html/escape/tests.rs b/src/librustdoc/html/escape/tests.rs
index a09649e9e18..de702e16063 100644
--- a/src/librustdoc/html/escape/tests.rs
+++ b/src/librustdoc/html/escape/tests.rs
@@ -24,6 +24,10 @@ fn escape_body_text_with_wbr() {
     assert_eq!(&E("first:second").to_string(), "first:<wbr>second");
     assert_eq!(&E("first::second").to_string(), "first::<wbr>second");
     assert_eq!(&E("MY_CONSTANT").to_string(), "MY_<wbr>CONSTANT");
+    assert_eq!(
+        &E("_SIDD_MASKED_NEGATIVE_POLARITY").to_string(),
+        "_SIDD_<wbr>MASKED_<wbr>NEGATIVE_<wbr>POLARITY"
+    );
     // a string won't get wrapped if it's less than 8 bytes
     assert_eq!(&E("HashSet").to_string(), "HashSet");
     // an individual word won't get wrapped if it's less than 4 bytes

From f7eced3a21a3a0377b2a23ba6fb0f8a346e837f1 Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Mon, 7 Oct 2024 13:27:50 -0700
Subject: [PATCH 11/13] Add comment to describe camelcase line break

---
 src/librustdoc/html/escape.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs
index 72ad42c2bd0..31a2701f06a 100644
--- a/src/librustdoc/html/escape.rs
+++ b/src/librustdoc/html/escape.rs
@@ -108,6 +108,16 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
                 || pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
             let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
             let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
+            // Check for CamelCase.
+            //
+            // `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
+            // correct, but needlessly bloated.
+            //
+            // is_uppercase && !next_is_uppercase checks for camelCase. HTTPSProxy,
+            // for example, should become HTTPS<wbr>Proxy.
+            //
+            // !next_is_underscore avoids turning TEST_RUN into TEST<wbr>_<wbr>RUN, which is also
+            // needlessly bloated.
             if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
                 EscapeBodyText(&text[last..i]).fmt(fmt)?;
                 fmt.write_str("<wbr>")?;

From 89b0f8a6891ce111ab256269dba1cfa09695b818 Mon Sep 17 00:00:00 2001
From: Eric Huss <eric@huss.org>
Date: Mon, 7 Oct 2024 14:36:49 -0700
Subject: [PATCH 12/13] Fix utf8-bom test

The BOM was accidentally removed in https://github.com/rust-lang/rust/pull/57108
---
 tests/ui/utf8-bom.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/ui/utf8-bom.rs b/tests/ui/utf8-bom.rs
index e2e4ccd63c1..5b9e27fb7b9 100644
--- a/tests/ui/utf8-bom.rs
+++ b/tests/ui/utf8-bom.rs
@@ -1,6 +1,4 @@
+// This file has utf-8 BOM, it should be compiled normally without error.
 //@ run-pass
-//
-
-// This file has utf-8 BOM, it should be compiled normally without error.
 
 pub fn main() {}

From db6e31bba789a9afff3fdbf0633a0922bde6af6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?=
 <jieyouxu@outlook.com>
Date: Mon, 7 Oct 2024 23:40:17 +0000
Subject: [PATCH 13/13] Remove myself from vacation

---
 triagebot.toml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/triagebot.toml b/triagebot.toml
index 0172a80b3a5..d3e4af9b718 100644
--- a/triagebot.toml
+++ b/triagebot.toml
@@ -926,7 +926,6 @@ users_on_vacation = [
     "jhpratt",
     "jyn514",
     "oli-obk",
-    "jieyouxu",
 ]
 
 [assign.adhoc_groups]