diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index c59a733c05568..4c878785b7b45 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 = diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index d71a37862e6eb..b04d2743b378e 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2271,11 +2271,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(); diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 14888cf4d75c0..c503a44c19698 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; diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index b7c30841983d7..8a251ea29d7fc 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1110,6 +1110,7 @@ impl<'a> ExtCtxt<'a> { } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err>( &self, sp: S, @@ -1118,6 +1119,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>, @@ -1125,6 +1127,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) } @@ -1135,10 +1138,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>(&self, sp: S, msg: impl Into) { self.sess.parse_sess.span_diagnostic.span_err(sp, msg); } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_warn>(&self, sp: S, msg: impl Into) { self.sess.parse_sess.span_diagnostic.span_warn(sp, msg); } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index eba5c829e396d..30a543aab508f 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/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 8f8778efee796..d48866d58ce1b 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 367c6190967c6..85eb543e48ead 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 8ea7e83637596..2bc8441759f4d 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; diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index be78ad564e4dc..4be0a7b4a5fb8 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1129,7 +1129,12 @@ fn item_trait_alias( .unwrap(); } -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, @@ -1139,16 +1144,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) { diff --git a/tests/rustdoc-gui/theme-change.goml b/tests/rustdoc-gui/theme-change.goml index ae6947213897e..e4b031b735eb0 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" 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 0000000000000..d81cba6275405 --- /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; + +pub fn main() {} diff --git a/tests/ui/suggestions/while-let-typo.rs b/tests/ui/suggestions/while-let-typo.rs index dbbcdee3c19f6..21b254054bbc0 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 7cc2ed3149b14..69a7e5761d421 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 0000000000000..3cb011dc06fcd --- /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 0000000000000..cf2648d084079 --- /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`.