summaryrefslogtreecommitdiffstats
path: root/src/test/ui/mir
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/mir')
-rw-r--r--src/test/ui/mir/important-higher-ranked-regions.rs26
-rw-r--r--src/test/ui/mir/mir_ascription_coercion.rs2
-rw-r--r--src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs (renamed from src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs)0
-rw-r--r--src/test/ui/mir/validate/needs-reveal-all.rs52
4 files changed, 79 insertions, 1 deletions
diff --git a/src/test/ui/mir/important-higher-ranked-regions.rs b/src/test/ui/mir/important-higher-ranked-regions.rs
new file mode 100644
index 000000000..cadfb3b66
--- /dev/null
+++ b/src/test/ui/mir/important-higher-ranked-regions.rs
@@ -0,0 +1,26 @@
+// check-pass
+// compile-flags: -Zvalidate-mir
+
+// This test checks that bivariant parameters are handled correctly
+// in the mir.
+#![allow(coherence_leak_check)]
+trait Trait {
+ type Assoc;
+}
+
+struct Foo<T, U>(T)
+where
+ T: Trait<Assoc = U>;
+
+impl Trait for for<'a> fn(&'a ()) {
+ type Assoc = u32;
+}
+impl Trait for fn(&'static ()) {
+ type Assoc = String;
+}
+
+fn foo(x: Foo<for<'a> fn(&'a ()), u32>) -> Foo<fn(&'static ()), String> {
+ x
+}
+
+fn main() {}
diff --git a/src/test/ui/mir/mir_ascription_coercion.rs b/src/test/ui/mir/mir_ascription_coercion.rs
index 0ebd20e97..9e04d6019 100644
--- a/src/test/ui/mir/mir_ascription_coercion.rs
+++ b/src/test/ui/mir/mir_ascription_coercion.rs
@@ -6,5 +6,5 @@
fn main() {
let x = [1, 2, 3];
// The RHS should coerce to &[i32]
- let _y : &[i32] = &x : &[i32; 3];
+ let _y : &[i32] = type_ascribe!(&x, &[i32; 3]);
}
diff --git a/src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs b/src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs
index cd6c5bf27..cd6c5bf27 100644
--- a/src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs
+++ b/src/test/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs
diff --git a/src/test/ui/mir/validate/needs-reveal-all.rs b/src/test/ui/mir/validate/needs-reveal-all.rs
new file mode 100644
index 000000000..3852daf24
--- /dev/null
+++ b/src/test/ui/mir/validate/needs-reveal-all.rs
@@ -0,0 +1,52 @@
+// Regression test for #105009. the issue here was that even after the `RevealAll` pass,
+// `validate` still used `Reveal::UserFacing`. This meant that it now ends up comparing
+// opaque types with their revealed version, resulting in an ICE.
+//
+// We're using these flags to run the `RevealAll` pass while making it less likely to
+// accidentally removing the assignment from `Foo<fn_ptr>` to `Foo<fn_def>`.
+
+// compile-flags: -Zinline_mir=yes -Zmir-opt-level=0 -Zvalidate-mir
+// run-pass
+
+use std::hint::black_box;
+
+trait Func {
+ type Ret: Id;
+}
+
+trait Id {
+ type Assoc;
+}
+impl Id for u32 {
+ type Assoc = u32;
+}
+impl Id for i32 {
+ type Assoc = i32;
+}
+
+impl<F: FnOnce() -> R, R: Id> Func for F {
+ type Ret = R;
+}
+
+fn bar() -> impl Copy + Id {
+ 0u32
+}
+
+struct Foo<T: Func> {
+ _func: T,
+ value: Option<<<T as Func>::Ret as Id>::Assoc>,
+}
+
+fn main() {
+ let mut fn_def = black_box(Foo {
+ _func: bar,
+ value: None,
+ });
+ let fn_ptr = black_box(Foo {
+ _func: bar as fn() -> _,
+ value: None,
+ });
+
+ fn_def.value = fn_ptr.value;
+ black_box(fn_def);
+}