From cd4354578a9a8cae62d9340eda66ec6689ac8ba7 Mon Sep 17 00:00:00 2001
From: Tamir Duberstein <tamird@gmail.com>
Date: Thu, 1 Jun 2023 13:07:51 -0400
Subject: [PATCH 1/9] Avoid passing --cpu-features when empty

Added in 12ac719b99560072cbe52a957f22d3fe6946cf2a, this logic always
passed --cpu-features, even when the value was the empty string.
---
 compiler/rustc_codegen_ssa/src/back/link.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index f8bb9bf2bb5..8dbd4456a6b 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2256,11 +2256,13 @@ fn add_order_independent_options(
     } else if flavor == LinkerFlavor::Bpf {
         cmd.arg("--cpu");
         cmd.arg(&codegen_results.crate_info.target_cpu);
-        cmd.arg("--cpu-features");
-        cmd.arg(match &sess.opts.cg.target_feature {
-            feat if !feat.is_empty() => feat.as_ref(),
-            _ => sess.target.options.features.as_ref(),
-        });
+        if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features]
+            .into_iter()
+            .find(|feat| !feat.is_empty())
+        {
+            cmd.arg("--cpu-features");
+            cmd.arg(feat);
+        }
     }
 
     cmd.linker_plugin_lto();

From edf342afc6dc8358a0dcb8aeea4b4fa071864977 Mon Sep 17 00:00:00 2001
From: kadiwa <kalle.wachsmuth@gmail.com>
Date: Mon, 5 Jun 2023 13:52:47 +0200
Subject: [PATCH 2/9] bootstrap: remove dep `is-terminal`

---
 src/bootstrap/Cargo.lock | 13 -------------
 src/bootstrap/Cargo.toml |  1 -
 src/bootstrap/config.rs  |  3 +--
 3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock
index 8f8778efee7..d48866d58ce 100644
--- a/src/bootstrap/Cargo.lock
+++ b/src/bootstrap/Cargo.lock
@@ -51,7 +51,6 @@ dependencies = [
  "filetime",
  "hex",
  "ignore",
- "is-terminal",
  "junction",
  "libc",
  "object",
@@ -386,18 +385,6 @@ dependencies = [
  "windows-sys",
 ]
 
-[[package]]
-name = "is-terminal"
-version = "0.4.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8"
-dependencies = [
- "hermit-abi 0.3.1",
- "io-lifetimes",
- "rustix",
- "windows-sys",
-]
-
 [[package]]
 name = "itoa"
 version = "1.0.2"
diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml
index 367c6190967..85eb543e48e 100644
--- a/src/bootstrap/Cargo.toml
+++ b/src/bootstrap/Cargo.toml
@@ -30,7 +30,6 @@ path = "bin/sccache-plus-cl.rs"
 test = false
 
 [dependencies]
-is-terminal = "0.4"
 build_helper = { path = "../tools/build_helper" }
 cmake = "0.1.38"
 filetime = "0.2"
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 8ea7e836375..2bc8441759f 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -12,6 +12,7 @@ use std::collections::{HashMap, HashSet};
 use std::env;
 use std::fmt;
 use std::fs;
+use std::io::IsTerminal;
 use std::path::{Path, PathBuf};
 use std::process::Command;
 use std::str::FromStr;
@@ -894,8 +895,6 @@ define_config! {
 
 impl Config {
     pub fn default_opts() -> Config {
-        use is_terminal::IsTerminal;
-
         let mut config = Config::default();
         config.llvm_optimize = true;
         config.ninja_in_file = true;

From 3522baa8ba671cd2eb07f077424c0073d152aad6 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume.gomez@huawei.com>
Date: Wed, 7 Jun 2023 17:42:04 +0200
Subject: [PATCH 3/9] Migrate GUI colors test to original CSS color format

---
 tests/rustdoc-gui/theme-change.goml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/rustdoc-gui/theme-change.goml b/tests/rustdoc-gui/theme-change.goml
index ae694721389..e4b031b735e 100644
--- a/tests/rustdoc-gui/theme-change.goml
+++ b/tests/rustdoc-gui/theme-change.goml
@@ -3,9 +3,9 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
 set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
 reload:
 
-store-value: (background_light, "rgb(255, 255, 255)")
-store-value: (background_dark, "rgb(53, 53, 53)")
-store-value: (background_ayu, "rgb(15, 20, 25)")
+store-value: (background_light, "white")
+store-value: (background_dark, "#353535")
+store-value: (background_ayu, "#0f1419")
 
 click: "#settings-menu"
 wait-for: "#theme-ayu"

From 053e6b80c7c5a6b6052468e7d35f6ef1d011274f Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Wed, 7 Jun 2023 17:16:34 +0000
Subject: [PATCH 4/9] Remove accidental comment

---
 compiler/rustc_builtin_macros/src/format.rs | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs
index c59a733c055..4c878785b7b 100644
--- a/compiler/rustc_builtin_macros/src/format.rs
+++ b/compiler/rustc_builtin_macros/src/format.rs
@@ -554,9 +554,6 @@ fn report_missing_placeholders(
     fmt_span: Span,
 ) {
     let mut diag = if let &[(span, named)] = &unused[..] {
-        //let mut diag = ecx.struct_span_err(span, msg);
-        //diag.span_label(span, msg);
-        //diag
         ecx.create_err(errors::FormatUnusedArg { span, named })
     } else {
         let unused_labels =

From adbfd0da6860a29d6c7a2adb315e79c91202f7ef 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: Thu, 8 Jun 2023 00:52:53 +0800
Subject: [PATCH 5/9] Fix ICE for while loop with assignment condition with LHS
 place expr

---
 compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs    | 13 +++++++++++--
 tests/ui/suggestions/while-let-typo.rs             |  2 +-
 tests/ui/suggestions/while-let-typo.stderr         | 13 ++++++++++++-
 ...issue-112385-while-assign-lhs-place-expr-ice.rs |  9 +++++++++
 ...e-112385-while-assign-lhs-place-expr-ice.stderr | 14 ++++++++++++++
 5 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs
 create mode 100644 tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr

diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index eba5c829e39..30a543aab50 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -1640,7 +1640,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                                                 hir::Stmt {
                                                     kind:
                                                         hir::StmtKind::Expr(hir::Expr {
-                                                            kind: hir::ExprKind::Assign(..),
+                                                            kind: hir::ExprKind::Assign(lhs, ..),
                                                             ..
                                                         }),
                                                     ..
@@ -1650,7 +1650,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                                     } = blk
                                     {
                                         self.comes_from_while_condition(blk.hir_id, |_| {
-                                            err.downgrade_to_delayed_bug();
+                                            // We cannot suppress the error if the LHS of assignment
+                                            // is a syntactic place expression because E0070 would
+                                            // not be emitted by `check_lhs_assignable`.
+                                            let res = self.typeck_results.borrow().expr_ty_opt(lhs);
+
+                                            if !lhs.is_syntactic_place_expr()
+                                                || res.references_error()
+                                            {
+                                                err.downgrade_to_delayed_bug();
+                                            }
                                         })
                                     }
                                 }
diff --git a/tests/ui/suggestions/while-let-typo.rs b/tests/ui/suggestions/while-let-typo.rs
index dbbcdee3c19..21b254054bb 100644
--- a/tests/ui/suggestions/while-let-typo.rs
+++ b/tests/ui/suggestions/while-let-typo.rs
@@ -2,7 +2,7 @@ fn main() {
     let foo = Some(0);
     let bar = None;
     while Some(x) = foo {} //~ ERROR cannot find value `x` in this scope
-    while Some(foo) = bar {}
+    while Some(foo) = bar {} //~ ERROR mismatched types
     while 3 = foo {} //~ ERROR mismatched types
     while Some(3) = foo {} //~ ERROR invalid left-hand side of assignment
     while x = 5 {} //~ ERROR cannot find value `x` in this scope
diff --git a/tests/ui/suggestions/while-let-typo.stderr b/tests/ui/suggestions/while-let-typo.stderr
index 7cc2ed3149b..69a7e5761d4 100644
--- a/tests/ui/suggestions/while-let-typo.stderr
+++ b/tests/ui/suggestions/while-let-typo.stderr
@@ -20,6 +20,17 @@ help: you might have meant to use pattern matching
 LL |     while let x = 5 {}
    |           +++
 
+error[E0308]: mismatched types
+  --> $DIR/while-let-typo.rs:5:11
+   |
+LL |     while Some(foo) = bar {}
+   |           ^^^^^^^^^^^^^^^ expected `bool`, found `()`
+   |
+help: consider adding `let`
+   |
+LL |     while let Some(foo) = bar {}
+   |           +++
+
 error[E0308]: mismatched types
   --> $DIR/while-let-typo.rs:6:11
    |
@@ -39,7 +50,7 @@ help: you might have meant to use pattern destructuring
 LL |     while let Some(3) = foo {}
    |           +++
 
-error: aborting due to 4 previous errors
+error: aborting due to 5 previous errors
 
 Some errors have detailed explanations: E0070, E0308, E0425.
 For more information about an error, try `rustc --explain E0070`.
diff --git a/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs
new file mode 100644
index 00000000000..3cb011dc06f
--- /dev/null
+++ b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs
@@ -0,0 +1,9 @@
+// Previously, the while loop with an assignment statement (mistakenly) as the condition
+// which has a place expr as the LHS would trigger an ICE in typeck.
+// Reduced from https://github.com/rust-lang/rust/issues/112385.
+
+fn main() {
+    let foo = Some(());
+    while Some(foo) = None {}
+    //~^ ERROR mismatched types
+}
diff --git a/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr
new file mode 100644
index 00000000000..cf2648d0840
--- /dev/null
+++ b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-112385-while-assign-lhs-place-expr-ice.rs:7:11
+   |
+LL |     while Some(foo) = None {}
+   |           ^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+   |
+help: consider adding `let`
+   |
+LL |     while let Some(foo) = None {}
+   |           +++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.

From fbe3a475f290c0847623357c732caa62b29389f3 Mon Sep 17 00:00:00 2001
From: Maybe Waffle <waffle.lapkin@gmail.com>
Date: Wed, 7 Jun 2023 18:59:31 +0000
Subject: [PATCH 6/9] Don't `use compile_error as print`

---
 compiler/rustc_driver_impl/src/lib.rs | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index 14888cf4d75..c503a44c196 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -58,11 +58,18 @@ use std::str;
 use std::sync::OnceLock;
 use std::time::Instant;
 
+#[allow(unused_macros)]
+macro do_not_use_print($($t:tt)*) {
+    std::compile_error!(
+        "Don't use `print` or `println` here, use `safe_print` or `safe_println` instead"
+    )
+}
+
 // This import blocks the use of panicking `print` and `println` in all the code
 // below. Please use `safe_print` and `safe_println` to avoid ICE when
 // encountering an I/O error during print.
 #[allow(unused_imports)]
-use std::{compile_error as print, compile_error as println};
+use {do_not_use_print as print, do_not_use_print as println};
 
 pub mod args;
 pub mod pretty;

From c38d80ee9f4fde1596ae4bff0733c3ec045e2f3e Mon Sep 17 00:00:00 2001
From: Maybe Waffle <waffle.lapkin@gmail.com>
Date: Wed, 7 Jun 2023 17:17:27 +0000
Subject: [PATCH 7/9] Track more diagnostics in `rustc_expand`

---
 compiler/rustc_expand/src/base.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs
index 0d43b30474b..6839e6ffa35 100644
--- a/compiler/rustc_expand/src/base.rs
+++ b/compiler/rustc_expand/src/base.rs
@@ -1108,6 +1108,7 @@ impl<'a> ExtCtxt<'a> {
     }
 
     #[rustc_lint_diagnostics]
+    #[track_caller]
     pub fn struct_span_err<S: Into<MultiSpan>>(
         &self,
         sp: S,
@@ -1116,6 +1117,7 @@ impl<'a> ExtCtxt<'a> {
         self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg)
     }
 
+    #[track_caller]
     pub fn create_err(
         &self,
         err: impl IntoDiagnostic<'a>,
@@ -1123,6 +1125,7 @@ impl<'a> ExtCtxt<'a> {
         self.sess.create_err(err)
     }
 
+    #[track_caller]
     pub fn emit_err(&self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
         self.sess.emit_err(err)
     }
@@ -1133,10 +1136,12 @@ impl<'a> ExtCtxt<'a> {
     /// Compilation will be stopped in the near future (at the end of
     /// the macro expansion phase).
     #[rustc_lint_diagnostics]
+    #[track_caller]
     pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
         self.sess.parse_sess.span_diagnostic.span_err(sp, msg);
     }
     #[rustc_lint_diagnostics]
+    #[track_caller]
     pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
         self.sess.parse_sess.span_diagnostic.span_warn(sp, msg);
     }

From 5e57e27d7a949f56402b80e2a78c618ed8a3aedb Mon Sep 17 00:00:00 2001
From: Takayuki Maeda <takoyaki0316@gmail.com>
Date: Thu, 8 Jun 2023 00:57:22 +0900
Subject: [PATCH 8/9] add a test for #105709

replace build with check

Co-authored-by: Michael Goulet <michael@errs.io>

use appropriate test name
---
 .../inline-const-in-const-generic-defaults.rs            | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs

diff --git a/tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs b/tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs
new file mode 100644
index 00000000000..d81cba62754
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(generic_const_exprs)]
+#![feature(inline_const)]
+#![allow(incomplete_features)]
+
+pub struct ConstDefaultUnstable<const N: usize = { const { 3 } }>;
+
+pub fn main() {}

From 29a51e14d9d7eb299683556a172cd06a11237b35 Mon Sep 17 00:00:00 2001
From: sladynnunes <snunes@usc.edu>
Date: Sun, 28 May 2023 02:14:36 -0700
Subject: [PATCH 9/9] Migrate item_opaque_type to Askama

Migrate item_opaque_type to Askama

Fix wrap_item parameters

Fix to write
---
 src/librustdoc/html/render/print_item.rs | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 62027a3fa19..1e36ca1ae7f 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1124,7 +1124,12 @@ fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &
     write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
 }
 
-fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::OpaqueTy) {
+fn item_opaque_ty(
+    w: &mut impl fmt::Write,
+    cx: &mut Context<'_>,
+    it: &clean::Item,
+    t: &clean::OpaqueTy,
+) {
     wrap_item(w, |w| {
         write!(
             w,
@@ -1134,16 +1139,18 @@ fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &cl
             where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
             bounds = bounds(&t.bounds, false, cx),
             attrs = render_attributes_in_pre(it, "", cx.tcx()),
-        );
+        )
+        .unwrap();
     });
 
-    write!(w, "{}", document(cx, it, None, HeadingOffset::H2));
+    write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
 
     // Render any items associated directly to this alias, as otherwise they
     // won't be visible anywhere in the docs. It would be nice to also show
     // associated items from the aliased type (see discussion in #32077), but
     // we need #14072 to make sense of the generics.
     write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
+        .unwrap();
 }
 
 fn item_typedef(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::Typedef) {