Skip to content

Commit c3ce4e6

Browse files
committed
Auto merge of rust-lang#131063 - matthiaskrgr:rollup-hfs3fo1, r=matthiaskrgr
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
2 parents b529e27 + 5ba81d7 commit c3ce4e6

File tree

16 files changed

+64
-117
lines changed

16 files changed

+64
-117
lines changed

compiler/rustc_builtin_macros/src/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a,
4343
return Err(cx.dcx().create_err(errors::RequiresCfgPattern { span }));
4444
}
4545

46-
let cfg = p.parse_meta_item(AllowLeadingUnsafe::Yes)?;
46+
let cfg = p.parse_meta_item(AllowLeadingUnsafe::No)?;
4747

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

compiler/rustc_interface/src/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
174174
}
175175
};
176176

177-
let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) {
177+
let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) {
178178
Ok(meta_item) if parser.token == token::Eof => meta_item,
179179
Ok(..) => expected_error(),
180180
Err(err) => {

src/bootstrap/src/core/build_steps/compile.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,6 @@ pub fn rustc_cargo(
10531053

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

1056-
// If the rustc output is piped to e.g. `head -n1` we want the process to be
1057-
// killed, rather than having an error bubble up and cause a panic.
1058-
cargo.rustflag("-Zon-broken-pipe=kill");
1059-
10601056
if builder.config.llvm_enzyme {
10611057
cargo.rustflag("-l").rustflag("Enzyme-19");
10621058
}

src/bootstrap/src/core/build_steps/tool.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ pub fn prepare_tool_cargo(
200200
cargo.arg("--features").arg(features.join(", "));
201201
}
202202

203+
// Warning: be very careful with RUSTFLAGS or command-line options, as conditionally applied
204+
// RUSTFLAGS or cli flags can lead to hard-to-diagnose rebuilds due to flag differences, causing
205+
// previous tool build artifacts to get invalidated.
206+
203207
// Enable internal lints for clippy and rustdoc
204208
// NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`
205209
// See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776
@@ -209,13 +213,6 @@ pub fn prepare_tool_cargo(
209213
// See https://github.com/rust-lang/rust/issues/116538
210214
cargo.rustflag("-Zunstable-options");
211215

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

src/bootstrap/src/core/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,8 @@ impl<'a> Builder<'a> {
15641564
let libdir = self.rustc_libdir(compiler);
15651565

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

15711571
let mut rustflags = Rustflags::new(target);

src/bootstrap/src/core/config/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,7 @@ impl Config {
24502450

24512451
/// Runs a function if verbosity is greater than 0
24522452
pub fn verbose(&self, f: impl Fn()) {
2453-
if self.verbose > 0 {
2453+
if self.is_verbose() {
24542454
f()
24552455
}
24562456
}
@@ -2735,7 +2735,7 @@ impl Config {
27352735
.success();
27362736
if has_changes {
27372737
if if_unchanged {
2738-
if self.verbose > 0 {
2738+
if self.is_verbose() {
27392739
println!(
27402740
"WARNING: saw changes to compiler/ or library/ since {commit}; \
27412741
ignoring `download-rustc`"
@@ -2832,7 +2832,7 @@ impl Config {
28322832
let has_changes = !t!(git.as_command_mut().status()).success();
28332833
if has_changes {
28342834
if if_unchanged {
2835-
if self.verbose > 0 {
2835+
if self.is_verbose() {
28362836
println!(
28372837
"warning: saw changes to one of {modified_paths:?} since {commit}; \
28382838
ignoring `{option_name}`"

tests/ui/asm/aarch64/type-check-4.rs

-27
This file was deleted.

tests/ui/asm/aarch64/type-check-4.stderr

-21
This file was deleted.

tests/ui/asm/non-const.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ needs-asm-support
2+
3+
use std::arch::global_asm;
4+
5+
fn main() {}
6+
7+
// Constants must be... constant
8+
fn non_const_fn(x: i32) -> i32 { x }
9+
10+
global_asm!("/* {} */", const non_const_fn(0));
11+
//~^ERROR: cannot call non-const fn

tests/ui/asm/non-const.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0015]: cannot call non-const fn `non_const_fn` in constants
2+
--> $DIR/non-const.rs:10:31
3+
|
4+
LL | global_asm!("/* {} */", const non_const_fn(0));
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0015`.

tests/ui/asm/x86_64/type-check-4.rs

-27
This file was deleted.

tests/ui/asm/x86_64/type-check-4.stderr

-21
This file was deleted.

tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ mod inner {
2727
#[unsafe(used)] //~ ERROR: is not an unsafe attribute
2828
static FOO: usize = 0;
2929

30-
fn main() {}
30+
fn main() {
31+
let _a = cfg!(unsafe(foo));
32+
//~^ ERROR: expected identifier, found keyword `unsafe`
33+
//~^^ ERROR: invalid predicate `r#unsafe`
34+
}

tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr

+19-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ LL | #[unsafe(test)]
2222
|
2323
= note: extraneous unsafe is not allowed in attributes
2424

25+
error: expected identifier, found keyword `unsafe`
26+
--> $DIR/extraneous-unsafe-attributes.rs:31:19
27+
|
28+
LL | let _a = cfg!(unsafe(foo));
29+
| ^^^^^^ expected identifier, found keyword
30+
|
31+
help: escape `unsafe` to use it as an identifier
32+
|
33+
LL | let _a = cfg!(r#unsafe(foo));
34+
| ++
35+
36+
error[E0537]: invalid predicate `r#unsafe`
37+
--> $DIR/extraneous-unsafe-attributes.rs:31:19
38+
|
39+
LL | let _a = cfg!(unsafe(foo));
40+
| ^^^^^^^^^^^
41+
2542
error: `ignore` is not an unsafe attribute
2643
--> $DIR/extraneous-unsafe-attributes.rs:13:3
2744
|
@@ -62,5 +79,6 @@ LL | #[unsafe(used)]
6279
|
6380
= note: extraneous unsafe is not allowed in attributes
6481

65-
error: aborting due to 8 previous errors
82+
error: aborting due to 10 previous errors
6683

84+
For more information about this error, try `rustc --explain E0537`.

tests/ui/check-cfg/invalid-arguments.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//@ revisions: values_any_missing_values values_any_before_ident ident_in_values_1
99
//@ revisions: ident_in_values_2 unknown_meta_item_1 unknown_meta_item_2 unknown_meta_item_3
1010
//@ revisions: mixed_values_any mixed_any any_values giberich unterminated
11-
//@ revisions: none_not_empty cfg_none
11+
//@ revisions: none_not_empty cfg_none unsafe_attr
1212
//
1313
//@ [anything_else]compile-flags: --check-cfg=anything_else(...)
1414
//@ [boolean]compile-flags: --check-cfg=cfg(true)
@@ -33,5 +33,6 @@
3333
//@ [cfg_none]compile-flags: --check-cfg=cfg(none())
3434
//@ [giberich]compile-flags: --check-cfg=cfg(...)
3535
//@ [unterminated]compile-flags: --check-cfg=cfg(
36+
//@ [unsafe_attr]compile-flags: --check-cfg=unsafe(cfg(foo))
3637

3738
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: invalid `--check-cfg` argument: `unsafe(cfg(foo))`
2+
|
3+
= note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
4+
= note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
5+

0 commit comments

Comments
 (0)