Skip to content

Commit e740925

Browse files
committed
Auto merge of rust-lang#112415 - GuillaumeGomez:rollup-5pa9frd, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - rust-lang#112034 (Migrate `item_opaque_ty` to Askama) - rust-lang#112179 (Avoid passing --cpu-features when empty) - rust-lang#112309 (bootstrap: remove dependency `is-terminal`) - rust-lang#112388 (Migrate GUI colors test to original CSS color format) - rust-lang#112389 (Add a test for rust-lang#105709) - rust-lang#112392 (Fix ICE for while loop with assignment condition with LHS place expr) - rust-lang#112394 (Remove accidental comment) - rust-lang#112396 (Track more diagnostics in `rustc_expand`) - rust-lang#112401 (Don't `use compile_error as print`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a0df04c + cf5e0b0 commit e740925

File tree

15 files changed

+90
-35
lines changed

15 files changed

+90
-35
lines changed

compiler/rustc_builtin_macros/src/format.rs

-3
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,6 @@ fn report_missing_placeholders(
554554
fmt_span: Span,
555555
) {
556556
let mut diag = if let &[(span, named)] = &unused[..] {
557-
//let mut diag = ecx.struct_span_err(span, msg);
558-
//diag.span_label(span, msg);
559-
//diag
560557
ecx.create_err(errors::FormatUnusedArg { span, named })
561558
} else {
562559
let unused_labels =

compiler/rustc_codegen_ssa/src/back/link.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -2271,11 +2271,13 @@ fn add_order_independent_options(
22712271
} else if flavor == LinkerFlavor::Bpf {
22722272
cmd.arg("--cpu");
22732273
cmd.arg(&codegen_results.crate_info.target_cpu);
2274-
cmd.arg("--cpu-features");
2275-
cmd.arg(match &sess.opts.cg.target_feature {
2276-
feat if !feat.is_empty() => feat.as_ref(),
2277-
_ => sess.target.options.features.as_ref(),
2278-
});
2274+
if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features]
2275+
.into_iter()
2276+
.find(|feat| !feat.is_empty())
2277+
{
2278+
cmd.arg("--cpu-features");
2279+
cmd.arg(feat);
2280+
}
22792281
}
22802282

22812283
cmd.linker_plugin_lto();

compiler/rustc_driver_impl/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,18 @@ use std::str;
5858
use std::sync::OnceLock;
5959
use std::time::Instant;
6060

61+
#[allow(unused_macros)]
62+
macro do_not_use_print($($t:tt)*) {
63+
std::compile_error!(
64+
"Don't use `print` or `println` here, use `safe_print` or `safe_println` instead"
65+
)
66+
}
67+
6168
// This import blocks the use of panicking `print` and `println` in all the code
6269
// below. Please use `safe_print` and `safe_println` to avoid ICE when
6370
// encountering an I/O error during print.
6471
#[allow(unused_imports)]
65-
use std::{compile_error as print, compile_error as println};
72+
use {do_not_use_print as print, do_not_use_print as println};
6673

6774
pub mod args;
6875
pub mod pretty;

compiler/rustc_expand/src/base.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ impl<'a> ExtCtxt<'a> {
11101110
}
11111111

11121112
#[rustc_lint_diagnostics]
1113+
#[track_caller]
11131114
pub fn struct_span_err<S: Into<MultiSpan>>(
11141115
&self,
11151116
sp: S,
@@ -1118,13 +1119,15 @@ impl<'a> ExtCtxt<'a> {
11181119
self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg)
11191120
}
11201121

1122+
#[track_caller]
11211123
pub fn create_err(
11221124
&self,
11231125
err: impl IntoDiagnostic<'a>,
11241126
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
11251127
self.sess.create_err(err)
11261128
}
11271129

1130+
#[track_caller]
11281131
pub fn emit_err(&self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
11291132
self.sess.emit_err(err)
11301133
}
@@ -1135,10 +1138,12 @@ impl<'a> ExtCtxt<'a> {
11351138
/// Compilation will be stopped in the near future (at the end of
11361139
/// the macro expansion phase).
11371140
#[rustc_lint_diagnostics]
1141+
#[track_caller]
11381142
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
11391143
self.sess.parse_sess.span_diagnostic.span_err(sp, msg);
11401144
}
11411145
#[rustc_lint_diagnostics]
1146+
#[track_caller]
11421147
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
11431148
self.sess.parse_sess.span_diagnostic.span_warn(sp, msg);
11441149
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16401640
hir::Stmt {
16411641
kind:
16421642
hir::StmtKind::Expr(hir::Expr {
1643-
kind: hir::ExprKind::Assign(..),
1643+
kind: hir::ExprKind::Assign(lhs, ..),
16441644
..
16451645
}),
16461646
..
@@ -1650,7 +1650,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16501650
} = blk
16511651
{
16521652
self.comes_from_while_condition(blk.hir_id, |_| {
1653-
err.downgrade_to_delayed_bug();
1653+
// We cannot suppress the error if the LHS of assignment
1654+
// is a syntactic place expression because E0070 would
1655+
// not be emitted by `check_lhs_assignable`.
1656+
let res = self.typeck_results.borrow().expr_ty_opt(lhs);
1657+
1658+
if !lhs.is_syntactic_place_expr()
1659+
|| res.references_error()
1660+
{
1661+
err.downgrade_to_delayed_bug();
1662+
}
16541663
})
16551664
}
16561665
}

src/bootstrap/Cargo.lock

-13
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ dependencies = [
5151
"filetime",
5252
"hex",
5353
"ignore",
54-
"is-terminal",
5554
"junction",
5655
"libc",
5756
"object",
@@ -386,18 +385,6 @@ dependencies = [
386385
"windows-sys",
387386
]
388387

389-
[[package]]
390-
name = "is-terminal"
391-
version = "0.4.6"
392-
source = "registry+https://github.com/rust-lang/crates.io-index"
393-
checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8"
394-
dependencies = [
395-
"hermit-abi 0.3.1",
396-
"io-lifetimes",
397-
"rustix",
398-
"windows-sys",
399-
]
400-
401388
[[package]]
402389
name = "itoa"
403390
version = "1.0.2"

src/bootstrap/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ path = "bin/sccache-plus-cl.rs"
3030
test = false
3131

3232
[dependencies]
33-
is-terminal = "0.4"
3433
build_helper = { path = "../tools/build_helper" }
3534
cmake = "0.1.38"
3635
filetime = "0.2"

src/bootstrap/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::collections::{HashMap, HashSet};
1212
use std::env;
1313
use std::fmt;
1414
use std::fs;
15+
use std::io::IsTerminal;
1516
use std::path::{Path, PathBuf};
1617
use std::process::Command;
1718
use std::str::FromStr;
@@ -894,8 +895,6 @@ define_config! {
894895

895896
impl Config {
896897
pub fn default_opts() -> Config {
897-
use is_terminal::IsTerminal;
898-
899898
let mut config = Config::default();
900899
config.llvm_optimize = true;
901900
config.ninja_in_file = true;

src/librustdoc/html/render/print_item.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,12 @@ fn item_trait_alias(
11291129
.unwrap();
11301130
}
11311131

1132-
fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::OpaqueTy) {
1132+
fn item_opaque_ty(
1133+
w: &mut impl fmt::Write,
1134+
cx: &mut Context<'_>,
1135+
it: &clean::Item,
1136+
t: &clean::OpaqueTy,
1137+
) {
11331138
wrap_item(w, |w| {
11341139
write!(
11351140
w,
@@ -1139,16 +1144,18 @@ fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &cl
11391144
where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
11401145
bounds = bounds(&t.bounds, false, cx),
11411146
attrs = render_attributes_in_pre(it, "", cx.tcx()),
1142-
);
1147+
)
1148+
.unwrap();
11431149
});
11441150

1145-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2));
1151+
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
11461152

11471153
// Render any items associated directly to this alias, as otherwise they
11481154
// won't be visible anywhere in the docs. It would be nice to also show
11491155
// associated items from the aliased type (see discussion in #32077), but
11501156
// we need #14072 to make sense of the generics.
11511157
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
1158+
.unwrap();
11521159
}
11531160

11541161
fn item_typedef(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::Typedef) {

tests/rustdoc-gui/theme-change.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
33
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
44
reload:
55

6-
store-value: (background_light, "rgb(255, 255, 255)")
7-
store-value: (background_dark, "rgb(53, 53, 53)")
8-
store-value: (background_ayu, "rgb(15, 20, 25)")
6+
store-value: (background_light, "white")
7+
store-value: (background_dark, "#353535")
8+
store-value: (background_ayu, "#0f1419")
99

1010
click: "#settings-menu"
1111
wait-for: "#theme-ayu"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
3+
#![feature(generic_const_exprs)]
4+
#![feature(inline_const)]
5+
#![allow(incomplete_features)]
6+
7+
pub struct ConstDefaultUnstable<const N: usize = { const { 3 } }>;
8+
9+
pub fn main() {}

tests/ui/suggestions/while-let-typo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fn main() {
22
let foo = Some(0);
33
let bar = None;
44
while Some(x) = foo {} //~ ERROR cannot find value `x` in this scope
5-
while Some(foo) = bar {}
5+
while Some(foo) = bar {} //~ ERROR mismatched types
66
while 3 = foo {} //~ ERROR mismatched types
77
while Some(3) = foo {} //~ ERROR invalid left-hand side of assignment
88
while x = 5 {} //~ ERROR cannot find value `x` in this scope

tests/ui/suggestions/while-let-typo.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ help: you might have meant to use pattern matching
2020
LL | while let x = 5 {}
2121
| +++
2222

23+
error[E0308]: mismatched types
24+
--> $DIR/while-let-typo.rs:5:11
25+
|
26+
LL | while Some(foo) = bar {}
27+
| ^^^^^^^^^^^^^^^ expected `bool`, found `()`
28+
|
29+
help: consider adding `let`
30+
|
31+
LL | while let Some(foo) = bar {}
32+
| +++
33+
2334
error[E0308]: mismatched types
2435
--> $DIR/while-let-typo.rs:6:11
2536
|
@@ -39,7 +50,7 @@ help: you might have meant to use pattern destructuring
3950
LL | while let Some(3) = foo {}
4051
| +++
4152

42-
error: aborting due to 4 previous errors
53+
error: aborting due to 5 previous errors
4354

4455
Some errors have detailed explanations: E0070, E0308, E0425.
4556
For more information about an error, try `rustc --explain E0070`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Previously, the while loop with an assignment statement (mistakenly) as the condition
2+
// which has a place expr as the LHS would trigger an ICE in typeck.
3+
// Reduced from https://github.com/rust-lang/rust/issues/112385.
4+
5+
fn main() {
6+
let foo = Some(());
7+
while Some(foo) = None {}
8+
//~^ ERROR mismatched types
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-112385-while-assign-lhs-place-expr-ice.rs:7:11
3+
|
4+
LL | while Some(foo) = None {}
5+
| ^^^^^^^^^^^^^^^^ expected `bool`, found `()`
6+
|
7+
help: consider adding `let`
8+
|
9+
LL | while let Some(foo) = None {}
10+
| +++
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)