summaryrefslogtreecommitdiffstats
path: root/tests/incremental
diff options
context:
space:
mode:
Diffstat (limited to 'tests/incremental')
-rw-r--r--tests/incremental/change_crate_dep_kind.rs1
-rw-r--r--tests/incremental/const-generic-type-cycle.rs17
-rw-r--r--tests/incremental/const-generics/change-const-param-gat.rs29
-rw-r--r--tests/incremental/const-generics/change-const-param-type.rs68
-rw-r--r--tests/incremental/hashes/enum_constructors.rs4
-rw-r--r--tests/incremental/hashes/let_expressions.rs12
-rw-r--r--tests/incremental/issue-80691-bad-eval-cache.rs1
7 files changed, 124 insertions, 8 deletions
diff --git a/tests/incremental/change_crate_dep_kind.rs b/tests/incremental/change_crate_dep_kind.rs
index 8c35f6ca0..f51826601 100644
--- a/tests/incremental/change_crate_dep_kind.rs
+++ b/tests/incremental/change_crate_dep_kind.rs
@@ -2,6 +2,7 @@
// detected then -Zincremental-verify-ich will trigger an assertion.
// ignore-wasm32-bare compiled with panic=abort by default
+// needs-unwind
// revisions:cfail1 cfail2
// compile-flags: -Z query-dep-graph -Cpanic=unwind
// build-pass (FIXME(62277): could be check-pass?)
diff --git a/tests/incremental/const-generic-type-cycle.rs b/tests/incremental/const-generic-type-cycle.rs
new file mode 100644
index 000000000..ca7b12e9e
--- /dev/null
+++ b/tests/incremental/const-generic-type-cycle.rs
@@ -0,0 +1,17 @@
+// Verify that we do not ICE when we try to overwrite an anon-const's type because of a trait
+// cycle.
+//
+// compile-flags: -Zincremental-ignore-spans
+// revisions: cpass cfail
+// error-pattern: cycle detected when computing type of `Bar::N`
+
+#![feature(trait_alias)]
+#![crate_type="lib"]
+
+#[cfg(cpass)]
+trait Bar<const N: usize> {}
+
+#[cfg(cfail)]
+trait Bar<const N: dyn BB> {}
+
+trait BB = Bar<{ 2 + 1 }>;
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 } }]
+ );
+}
diff --git a/tests/incremental/const-generics/change-const-param-type.rs b/tests/incremental/const-generics/change-const-param-type.rs
new file mode 100644
index 000000000..1aac1bc7d
--- /dev/null
+++ b/tests/incremental/const-generics/change-const-param-type.rs
@@ -0,0 +1,68 @@
+// revisions: rpass1 rpass2 rpass3
+// compile-flags: -Zincremental-ignore-spans
+
+enum Foo<const N: usize> {
+ Variant,
+ Variant2(),
+ Variant3 {},
+}
+
+impl Foo<1> {
+ fn foo<const N: usize>(&self) -> [(); N] { [(); N] }
+}
+
+impl Foo<2> {
+ fn foo<const N: u32>(self) -> usize { N as usize }
+}
+
+struct Bar<const N: usize>;
+struct Bar2<const N: usize>();
+struct Bar3<const N: usize> {}
+
+#[cfg(rpass1)]
+struct ChangingStruct<const N: usize>;
+
+#[cfg(any(rpass2, rpass3))]
+struct ChangingStruct<const N: u32>;
+
+struct S;
+
+impl S {
+ #[cfg(rpass1)]
+ fn changing_method<const N: usize>(self) {}
+
+ #[cfg(any(rpass2, rpass3))]
+ fn changing_method<const N: u32>(self) {}
+}
+
+// We want to verify that all goes well when the value of the const argument change.
+// To avoid modifying `main`'s HIR, we use a separate constant, and use `{ FOO_ARG + 1 }`
+// inside the body to keep having an `AnonConst` to compute.
+const FOO_ARG: usize = if cfg!(rpass2) { 1 } else { 0 };
+
+fn main() {
+ let foo = Foo::Variant::<{ FOO_ARG + 1 }>;
+ foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>();
+
+ let foo = Foo::Variant2::<{ FOO_ARG + 1 }>();
+ foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>();
+
+ let foo = Foo::Variant3::<{ FOO_ARG + 1 }> {};
+ foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>();
+
+ let foo = Foo::<{ FOO_ARG + 1 }>::Variant;
+ foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>();
+
+ let foo = Foo::<{ FOO_ARG + 1 }>::Variant2();
+ foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>();
+
+ let foo = Foo::<{ FOO_ARG + 1 }>::Variant3 {};
+ foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>();
+
+ let _ = Bar::<{ FOO_ARG + 1 }>;
+ let _ = Bar2::<{ FOO_ARG + 1 }>();
+ let _ = Bar3::<{ FOO_ARG + 1 }> {};
+
+ let _ = ChangingStruct::<{ 5 }>;
+ let _ = S.changing_method::<{ 5 }>();
+}
diff --git a/tests/incremental/hashes/enum_constructors.rs b/tests/incremental/hashes/enum_constructors.rs
index db367d070..f685fe46d 100644
--- a/tests/incremental/hashes/enum_constructors.rs
+++ b/tests/incremental/hashes/enum_constructors.rs
@@ -334,9 +334,9 @@ pub fn change_constructor_variant_c_like() {
}
#[cfg(not(any(cfail1,cfail4)))]
-#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
+#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
+#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn change_constructor_variant_c_like() {
let _x = Clike::C;
diff --git a/tests/incremental/hashes/let_expressions.rs b/tests/incremental/hashes/let_expressions.rs
index 7aca43242..a835b8eef 100644
--- a/tests/incremental/hashes/let_expressions.rs
+++ b/tests/incremental/hashes/let_expressions.rs
@@ -91,7 +91,7 @@ pub fn change_mutability_of_slot() {
}
#[cfg(not(any(cfail1,cfail4)))]
-#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
+#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
@@ -176,7 +176,7 @@ pub fn change_mutability_of_binding_in_pattern() {
}
#[cfg(not(any(cfail1,cfail4)))]
-#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
+#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
@@ -193,9 +193,9 @@ pub fn add_initializer() {
}
#[cfg(not(any(cfail1,cfail4)))]
-#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
+#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
+#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn add_initializer() {
let _x: i16 = 3i16;
@@ -210,9 +210,9 @@ pub fn change_initializer() {
}
#[cfg(not(any(cfail1,cfail4)))]
-#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
+#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
+#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn change_initializer() {
let _x = 5u16;
diff --git a/tests/incremental/issue-80691-bad-eval-cache.rs b/tests/incremental/issue-80691-bad-eval-cache.rs
index 1a644fd88..ad8a338a7 100644
--- a/tests/incremental/issue-80691-bad-eval-cache.rs
+++ b/tests/incremental/issue-80691-bad-eval-cache.rs
@@ -1,6 +1,7 @@
// revisions: rfail1 rfail2
// failure-status: 101
// error-pattern: not implemented
+// needs-unwind -Cpanic=abort causes abort instead of exit(101)
pub trait Interner {
type InternedVariableKinds;