about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-09-30 13:33:35 +0000
committerbors <bors@rust-lang.org>2024-09-30 13:33:35 +0000
commitc3ce4e66a5732a5b89c9f495b44357bf6b29d424 (patch)
tree77e54d4034ab2dba3738a4fee99f64c3ab408f40 /tests
parentb529e278bbbeb706e70ee6138939b6361ad53bd3 (diff)
parent5ba81d723ae1bd13d496b52d2f02e53b583de752 (diff)
downloadrust-c3ce4e66a5732a5b89c9f495b44357bf6b29d424.tar.gz
rust-c3ce4e66a5732a5b89c9f495b44357bf6b29d424.zip
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
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/asm/aarch64/type-check-4.rs27
-rw-r--r--tests/ui/asm/aarch64/type-check-4.stderr21
-rw-r--r--tests/ui/asm/non-const.rs11
-rw-r--r--tests/ui/asm/non-const.stderr11
-rw-r--r--tests/ui/asm/x86_64/type-check-4.rs27
-rw-r--r--tests/ui/asm/x86_64/type-check-4.stderr21
-rw-r--r--tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs6
-rw-r--r--tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr20
-rw-r--r--tests/ui/check-cfg/invalid-arguments.rs3
-rw-r--r--tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr5
10 files changed, 53 insertions, 99 deletions
diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs
deleted file mode 100644
index c24567bd5b0..00000000000
--- a/tests/ui/asm/aarch64/type-check-4.rs
+++ /dev/null
@@ -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
diff --git a/tests/ui/asm/aarch64/type-check-4.stderr b/tests/ui/asm/aarch64/type-check-4.stderr
deleted file mode 100644
index 8c22dfcdb5e..00000000000
--- a/tests/ui/asm/aarch64/type-check-4.stderr
+++ /dev/null
@@ -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`.
diff --git a/tests/ui/asm/non-const.rs b/tests/ui/asm/non-const.rs
new file mode 100644
index 00000000000..63c46563226
--- /dev/null
+++ b/tests/ui/asm/non-const.rs
@@ -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
diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr
new file mode 100644
index 00000000000..5fae2ac9843
--- /dev/null
+++ b/tests/ui/asm/non-const.stderr
@@ -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`.
diff --git a/tests/ui/asm/x86_64/type-check-4.rs b/tests/ui/asm/x86_64/type-check-4.rs
deleted file mode 100644
index ebc6edc07e4..00000000000
--- a/tests/ui/asm/x86_64/type-check-4.rs
+++ /dev/null
@@ -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
diff --git a/tests/ui/asm/x86_64/type-check-4.stderr b/tests/ui/asm/x86_64/type-check-4.stderr
deleted file mode 100644
index 8c22dfcdb5e..00000000000
--- a/tests/ui/asm/x86_64/type-check-4.stderr
+++ /dev/null
@@ -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`.
diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
index b561550c198..273b127bf9c 100644
--- a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
+++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs
@@ -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`
+}
diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
index 9fb7f062b91..445d239d867 100644
--- a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
+++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr
@@ -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`.
diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs
index b8588ecb4ff..c6b1218ce27 100644
--- a/tests/ui/check-cfg/invalid-arguments.rs
+++ b/tests/ui/check-cfg/invalid-arguments.rs
@@ -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() {}
diff --git a/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr b/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
new file mode 100644
index 00000000000..5236ed6f605
--- /dev/null
+++ b/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr
@@ -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
+