mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Auto merge of #131063 - matthiaskrgr:rollup-hfs3fo1, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #130895 (make type-check-4 asm tests about non-const expressions) - #131057 (Reject leading unsafe in `cfg!(...)` and `--check-cfg`) - #131060 (Drop conditionally applied cargo `-Zon-broken-pipe=kill` flags to fix stage 1 cargo rebuilds) - #131061 (replace manual verbose checks with `Config::is_verbose`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
c3ce4e66a5
@ -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);
|
||||
|
||||
|
@ -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) => {
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
@ -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`"
|
||||
@ -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}`"
|
||||
|
@ -1,27 +0,0 @@
|
||||
//@ only-aarch64
|
||||
//@ build-fail
|
||||
|
||||
use std::arch::global_asm;
|
||||
|
||||
fn main() {}
|
||||
|
||||
// Constants must be... constant
|
||||
|
||||
static mut S: i32 = 1;
|
||||
const fn const_foo(x: i32) -> i32 {
|
||||
x
|
||||
}
|
||||
const fn const_bar<T>(x: T) -> T {
|
||||
x
|
||||
}
|
||||
global_asm!("{}", const unsafe { S });
|
||||
//~^ ERROR: evaluation of constant value failed
|
||||
//~| mutable global memory
|
||||
global_asm!("{}", const const_foo(0));
|
||||
global_asm!("{}", const const_foo(unsafe { S }));
|
||||
//~^ ERROR: evaluation of constant value failed
|
||||
//~| mutable global memory
|
||||
global_asm!("{}", const const_bar(0));
|
||||
global_asm!("{}", const const_bar(unsafe { S }));
|
||||
//~^ ERROR: evaluation of constant value failed
|
||||
//~| mutable global memory
|
@ -1,21 +0,0 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/type-check-4.rs:17:34
|
||||
|
|
||||
LL | global_asm!("{}", const unsafe { S });
|
||||
| ^ constant accesses mutable global memory
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/type-check-4.rs:21:44
|
||||
|
|
||||
LL | global_asm!("{}", const const_foo(unsafe { S }));
|
||||
| ^ constant accesses mutable global memory
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/type-check-4.rs:25:44
|
||||
|
|
||||
LL | global_asm!("{}", const const_bar(unsafe { S }));
|
||||
| ^ constant accesses mutable global memory
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
11
tests/ui/asm/non-const.rs
Normal file
11
tests/ui/asm/non-const.rs
Normal file
@ -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
tests/ui/asm/non-const.stderr
Normal file
11
tests/ui/asm/non-const.stderr
Normal file
@ -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`.
|
@ -1,27 +0,0 @@
|
||||
//@ only-x86_64
|
||||
//@ build-fail
|
||||
|
||||
use std::arch::global_asm;
|
||||
|
||||
fn main() {}
|
||||
|
||||
// Constants must be... constant
|
||||
|
||||
static mut S: i32 = 1;
|
||||
const fn const_foo(x: i32) -> i32 {
|
||||
x
|
||||
}
|
||||
const fn const_bar<T>(x: T) -> T {
|
||||
x
|
||||
}
|
||||
global_asm!("{}", const unsafe { S });
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| mutable global memory
|
||||
global_asm!("{}", const const_foo(0));
|
||||
global_asm!("{}", const const_foo(unsafe { S }));
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| mutable global memory
|
||||
global_asm!("{}", const const_bar(0));
|
||||
global_asm!("{}", const const_bar(unsafe { S }));
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| mutable global memory
|
@ -1,21 +0,0 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/type-check-4.rs:17:34
|
||||
|
|
||||
LL | global_asm!("{}", const unsafe { S });
|
||||
| ^ constant accesses mutable global memory
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/type-check-4.rs:21:44
|
||||
|
|
||||
LL | global_asm!("{}", const const_foo(unsafe { S }));
|
||||
| ^ constant accesses mutable global memory
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/type-check-4.rs:25:44
|
||||
|
|
||||
LL | global_asm!("{}", const const_bar(unsafe { S }));
|
||||
| ^ constant accesses mutable global memory
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
@ -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`
|
||||
}
|
||||
|
@ -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
|
||||
|
|
||||
@ -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`.
|
||||
|
@ -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)
|
||||
@ -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
tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
Normal file
5
tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user