Skip to content

Commit

Permalink
Auto merge of rust-lang#131063 - matthiaskrgr:rollup-hfs3fo1, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#130895 (make type-check-4 asm tests about non-const expressions)
 - rust-lang#131057 (Reject leading unsafe in `cfg!(...)` and `--check-cfg`)
 - rust-lang#131060 (Drop conditionally applied cargo `-Zon-broken-pipe=kill` flags to fix stage 1 cargo rebuilds)
 - rust-lang#131061 (replace manual verbose checks with `Config::is_verbose`)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 30, 2024
2 parents b529e27 + 5ba81d7 commit c3ce4e6
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 117 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a,
return Err(cx.dcx().create_err(errors::RequiresCfgPattern { span }));
}

let cfg = p.parse_meta_item(AllowLeadingUnsafe::Yes)?;
let cfg = p.parse_meta_item(AllowLeadingUnsafe::No)?;

let _ = p.eat(&token::Comma);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
}
};

let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) {
let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) {
Ok(meta_item) if parser.token == token::Eof => meta_item,
Ok(..) => expected_error(),
Err(err) => {
Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,6 @@ pub fn rustc_cargo(

cargo.rustdocflag("-Zcrate-attr=warn(rust_2018_idioms)");

// If the rustc output is piped to e.g. `head -n1` we want the process to be
// killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");

if builder.config.llvm_enzyme {
cargo.rustflag("-l").rustflag("Enzyme-19");
}
Expand Down
11 changes: 4 additions & 7 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ pub fn prepare_tool_cargo(
cargo.arg("--features").arg(features.join(", "));
}

// Warning: be very careful with RUSTFLAGS or command-line options, as conditionally applied
// RUSTFLAGS or cli flags can lead to hard-to-diagnose rebuilds due to flag differences, causing
// previous tool build artifacts to get invalidated.

// Enable internal lints for clippy and rustdoc
// NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`
// See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776
Expand All @@ -209,13 +213,6 @@ pub fn prepare_tool_cargo(
// See https://github.com/rust-lang/rust/issues/116538
cargo.rustflag("-Zunstable-options");

// `-Zon-broken-pipe=kill` breaks cargo tests
if !path.ends_with("cargo") {
// If the output is piped to e.g. `head -n1` we want the process to be killed,
// rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");
}

cargo
}

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1564,8 +1564,8 @@ impl<'a> Builder<'a> {
let libdir = self.rustc_libdir(compiler);

let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
if !matches!(self.config.dry_run, DryRun::SelfCheck) {
self.verbose_than(0, || println!("using sysroot {sysroot_str}"));
if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) {
println!("using sysroot {sysroot_str}");
}

let mut rustflags = Rustflags::new(target);
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ impl Config {

/// Runs a function if verbosity is greater than 0
pub fn verbose(&self, f: impl Fn()) {
if self.verbose > 0 {
if self.is_verbose() {
f()
}
}
Expand Down Expand Up @@ -2735,7 +2735,7 @@ impl Config {
.success();
if has_changes {
if if_unchanged {
if self.verbose > 0 {
if self.is_verbose() {
println!(
"WARNING: saw changes to compiler/ or library/ since {commit}; \
ignoring `download-rustc`"
Expand Down Expand Up @@ -2832,7 +2832,7 @@ impl Config {
let has_changes = !t!(git.as_command_mut().status()).success();
if has_changes {
if if_unchanged {
if self.verbose > 0 {
if self.is_verbose() {
println!(
"warning: saw changes to one of {modified_paths:?} since {commit}; \
ignoring `{option_name}`"
Expand Down
27 changes: 0 additions & 27 deletions tests/ui/asm/aarch64/type-check-4.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ui/asm/aarch64/type-check-4.stderr

This file was deleted.

11 changes: 11 additions & 0 deletions tests/ui/asm/non-const.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ needs-asm-support

use std::arch::global_asm;

fn main() {}

// Constants must be... constant
fn non_const_fn(x: i32) -> i32 { x }

global_asm!("/* {} */", const non_const_fn(0));
//~^ERROR: cannot call non-const fn
11 changes: 11 additions & 0 deletions tests/ui/asm/non-const.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0015]: cannot call non-const fn `non_const_fn` in constants
--> $DIR/non-const.rs:10:31
|
LL | global_asm!("/* {} */", const non_const_fn(0));
| ^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0015`.
27 changes: 0 additions & 27 deletions tests/ui/asm/x86_64/type-check-4.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ui/asm/x86_64/type-check-4.stderr

This file was deleted.

6 changes: 5 additions & 1 deletion tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ mod inner {
#[unsafe(used)] //~ ERROR: is not an unsafe attribute
static FOO: usize = 0;

fn main() {}
fn main() {
let _a = cfg!(unsafe(foo));
//~^ ERROR: expected identifier, found keyword `unsafe`
//~^^ ERROR: invalid predicate `r#unsafe`
}
20 changes: 19 additions & 1 deletion tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ LL | #[unsafe(test)]
|
= note: extraneous unsafe is not allowed in attributes

error: expected identifier, found keyword `unsafe`
--> $DIR/extraneous-unsafe-attributes.rs:31:19
|
LL | let _a = cfg!(unsafe(foo));
| ^^^^^^ expected identifier, found keyword
|
help: escape `unsafe` to use it as an identifier
|
LL | let _a = cfg!(r#unsafe(foo));
| ++

error[E0537]: invalid predicate `r#unsafe`
--> $DIR/extraneous-unsafe-attributes.rs:31:19
|
LL | let _a = cfg!(unsafe(foo));
| ^^^^^^^^^^^

error: `ignore` is not an unsafe attribute
--> $DIR/extraneous-unsafe-attributes.rs:13:3
|
Expand Down Expand Up @@ -62,5 +79,6 @@ LL | #[unsafe(used)]
|
= note: extraneous unsafe is not allowed in attributes

error: aborting due to 8 previous errors
error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0537`.
3 changes: 2 additions & 1 deletion tests/ui/check-cfg/invalid-arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//@ revisions: values_any_missing_values values_any_before_ident ident_in_values_1
//@ revisions: ident_in_values_2 unknown_meta_item_1 unknown_meta_item_2 unknown_meta_item_3
//@ revisions: mixed_values_any mixed_any any_values giberich unterminated
//@ revisions: none_not_empty cfg_none
//@ revisions: none_not_empty cfg_none unsafe_attr
//
//@ [anything_else]compile-flags: --check-cfg=anything_else(...)
//@ [boolean]compile-flags: --check-cfg=cfg(true)
Expand All @@ -33,5 +33,6 @@
//@ [cfg_none]compile-flags: --check-cfg=cfg(none())
//@ [giberich]compile-flags: --check-cfg=cfg(...)
//@ [unterminated]compile-flags: --check-cfg=cfg(
//@ [unsafe_attr]compile-flags: --check-cfg=unsafe(cfg(foo))

fn main() {}
5 changes: 5 additions & 0 deletions tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: invalid `--check-cfg` argument: `unsafe(cfg(foo))`
|
= note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
= note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details

0 comments on commit c3ce4e6

Please sign in to comment.