Skip to content

Commit

Permalink
Auto merge of rust-lang#112415 - GuillaumeGomez:rollup-5pa9frd, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

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
  • Loading branch information
bors committed Jun 8, 2023
2 parents a0df04c + cf5e0b0 commit e740925
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 35 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
12 changes: 7 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ impl<'a> ExtCtxt<'a> {
}

#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,
Expand All @@ -1118,13 +1119,15 @@ 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>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.sess.create_err(err)
}

#[track_caller]
pub fn emit_err(&self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
self.sess.emit_err(err)
}
Expand All @@ -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<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);
}
Expand Down
13 changes: 11 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ..),
..
}),
..
Expand All @@ -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();
}
})
}
}
Expand Down
13 changes: 0 additions & 13 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dependencies = [
"filetime",
"hex",
"ignore",
"is-terminal",
"junction",
"libc",
"object",
Expand Down Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/rustdoc-gui/theme-change.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}
2 changes: 1 addition & 1 deletion tests/ui/suggestions/while-let-typo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion tests/ui/suggestions/while-let-typo.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand All @@ -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`.
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit e740925

Please sign in to comment.