summaryrefslogtreecommitdiffstats
path: root/tests/incremental/const-generics/change-const-param-gat.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/incremental/const-generics/change-const-param-gat.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/incremental/const-generics/change-const-param-gat.rs')
-rw-r--r--tests/incremental/const-generics/change-const-param-gat.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/incremental/const-generics/change-const-param-gat.rs b/tests/incremental/const-generics/change-const-param-gat.rs
new file mode 100644
index 000000000..f1449d568
--- /dev/null
+++ b/tests/incremental/const-generics/change-const-param-gat.rs
@@ -0,0 +1,29 @@
+// revisions: rpass1 rpass2 rpass3
+// compile-flags: -Zincremental-ignore-spans
+#![feature(generic_associated_types)]
+
+// This test unsures that with_opt_const_param returns the
+// def_id of the N param in the Foo::Assoc GAT.
+
+trait Foo {
+ type Assoc<const N: usize>;
+ fn foo(
+ &self,
+ ) -> Self::Assoc<{ if cfg!(rpass2) { 3 } else { 2 } }>;
+}
+
+impl Foo for () {
+ type Assoc<const N: usize> = [(); N];
+ fn foo(
+ &self,
+ ) -> Self::Assoc<{ if cfg!(rpass2) { 3 } else { 2 } }> {
+ [(); { if cfg!(rpass2) { 3 } else { 2 } }]
+ }
+}
+
+fn main() {
+ assert_eq!(
+ ().foo(),
+ [(); { if cfg!(rpass2) { 3 } else { 2 } }]
+ );
+}