summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs')
-rw-r--r--tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs121
1 files changed, 121 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs
new file mode 100644
index 000000000..14539d4b6
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs
@@ -0,0 +1,121 @@
+// compile-flags: --cfg something
+// edition:2018
+
+#![feature(async_closure)]
+#![deny(unused_variables)]
+
+extern "C" {
+ fn ffi(
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ #[cfg_attr(something, cfg(nothing))] c: i32,
+ #[cfg_attr(nothing, cfg(nothing))] ...
+ );
+}
+
+type FnType = fn(
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+);
+
+async fn foo_async(
+ #[cfg(something)] a: i32,
+ //~^ ERROR unused variable: `a`
+ #[cfg(nothing)] b: i32,
+) {}
+fn foo(
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+) {}
+
+struct RefStruct {}
+impl RefStruct {
+ async fn bar_async(
+ &self,
+ #[cfg(something)] a: i32,
+ //~^ ERROR unused variable: `a`
+ #[cfg(nothing)] b: i32,
+ ) {}
+ fn bar(
+ &self,
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ ) {}
+ fn issue_64682_associated_fn(
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ ) {}
+}
+trait RefTrait {
+ fn bar(
+ &self,
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ ) {}
+ fn issue_64682_associated_fn(
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ ) {}
+}
+impl RefTrait for RefStruct {
+ fn bar(
+ &self,
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ ) {}
+ fn issue_64682_associated_fn(
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ ) {}
+}
+
+fn main() {
+ let _: unsafe extern "C" fn(_, ...) = ffi;
+ let _: fn(_, _) = foo;
+ let _: FnType = |_, _| {};
+ let a = async move |
+ #[cfg(something)] a: i32,
+ //~^ ERROR unused variable: `a`
+ #[cfg(nothing)] b: i32,
+ | {};
+ let c = |
+ #[cfg(nothing)] a: i32,
+ #[cfg(something)] b: i32,
+ //~^ ERROR unused variable: `b`
+ #[cfg_attr(nothing, cfg(nothing))] c: i32,
+ //~^ ERROR unused variable: `c`
+ #[cfg_attr(something, cfg(nothing))] d: i32,
+ | {};
+ a(1);
+ c(1, 2);
+}