summaryrefslogtreecommitdiffstats
path: root/tests/ui/conditional-compilation/cfg-generic-params.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/conditional-compilation/cfg-generic-params.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/conditional-compilation/cfg-generic-params.rs')
-rw-r--r--tests/ui/conditional-compilation/cfg-generic-params.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/ui/conditional-compilation/cfg-generic-params.rs b/tests/ui/conditional-compilation/cfg-generic-params.rs
new file mode 100644
index 000000000..53aa35563
--- /dev/null
+++ b/tests/ui/conditional-compilation/cfg-generic-params.rs
@@ -0,0 +1,40 @@
+// compile-flags:--cfg yes
+
+fn f_lt<#[cfg(yes)] 'a: 'a, #[cfg(no)] T>() {}
+fn f_ty<#[cfg(no)] 'a: 'a, #[cfg(yes)] T>() {}
+
+type FnGood = for<#[cfg(yes)] 'a, #[cfg(no)] T> fn(); // OK
+type FnBad = for<#[cfg(no)] 'a, #[cfg(yes)] T> fn();
+//~^ ERROR only lifetime parameters can be used in this context
+
+type PolyGood = dyn for<#[cfg(yes)] 'a, #[cfg(no)] T> Copy; // OK
+type PolyBad = dyn for<#[cfg(no)] 'a, #[cfg(yes)] T> Copy;
+//~^ ERROR only lifetime parameters can be used in this context
+
+struct WhereGood where for<#[cfg(yes)] 'a, #[cfg(no)] T> u8: Copy; // OK
+struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy;
+//~^ ERROR only lifetime parameters can be used in this context
+
+fn f_lt_no<#[cfg_attr(no, unknown)] 'a>() {} // OK
+fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {}
+//~^ ERROR cannot find attribute `unknown` in this scope
+fn f_ty_no<#[cfg_attr(no, unknown)] T>() {} // OK
+fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {}
+//~^ ERROR cannot find attribute `unknown` in this scope
+
+type FnNo = for<#[cfg_attr(no, unknown)] 'a> fn(); // OK
+type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn();
+//~^ ERROR cannot find attribute `unknown` in this scope
+
+type PolyNo = dyn for<#[cfg_attr(no, unknown)] 'a> Copy; // OK
+type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy;
+//~^ ERROR cannot find attribute `unknown` in this scope
+
+struct WhereNo where for<#[cfg_attr(no, unknown)] 'a> u8: Copy; // OK
+struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy;
+//~^ ERROR cannot find attribute `unknown` in this scope
+
+fn main() {
+ f_lt::<'static>();
+ f_ty::<u8>();
+}