about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-29 10:18:57 +0100
committerGitHub <noreply@github.com>2024-11-29 10:18:57 +0100
commit6863327eccd088d857ce6c6f4e81028f6219ab00 (patch)
tree300dc2eaea1bd39e0265811dd50236d9105fe501 /tests
parent95560d6fe758537594ece757ef7fba604dfee123 (diff)
parent34a8c2dbba9fe2d57029027781500ab7fc305199 (diff)
downloadrust-6863327eccd088d857ce6c6f4e81028f6219ab00.tar.gz
rust-6863327eccd088d857ce6c6f4e81028f6219ab00.zip
Rollup merge of #133501 - lcnr:post-borrowck-analysis, r=compiler-errors
support revealing defined opaque post borrowck

By adding a new `TypingMode::PostBorrowckAnalysis`. Currently only supported with the new solver and I didn't look into the way we replace `ReErased`. ``@compiler-errors`` mentioned that always using existentials may be unsound.

r? ``@compiler-errors``
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/traits/next-solver/opaques/dont-remap-tait-substs.rs (renamed from tests/ui/traits/next-solver/dont-remap-tait-substs.rs)0
-rw-r--r--tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr (renamed from tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr)0
-rw-r--r--tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr (renamed from tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr)0
-rw-r--r--tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs (renamed from tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs)0
-rw-r--r--tests/ui/traits/next-solver/opaques/no-define-in-wf-check.current.stderr34
-rw-r--r--tests/ui/traits/next-solver/opaques/no-define-in-wf-check.rs66
-rw-r--r--tests/ui/traits/next-solver/opaques/select-alias-bound-as-param.rs (renamed from tests/ui/traits/next-solver/select-alias-bound-as-param.rs)0
7 files changed, 100 insertions, 0 deletions
diff --git a/tests/ui/traits/next-solver/dont-remap-tait-substs.rs b/tests/ui/traits/next-solver/opaques/dont-remap-tait-substs.rs
index 904bc179495..904bc179495 100644
--- a/tests/ui/traits/next-solver/dont-remap-tait-substs.rs
+++ b/tests/ui/traits/next-solver/opaques/dont-remap-tait-substs.rs
diff --git a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr
index 158fefd1538..158fefd1538 100644
--- a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr
+++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr
diff --git a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr
index 158fefd1538..158fefd1538 100644
--- a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr
+++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr
diff --git a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs
index 10b746cc989..10b746cc989 100644
--- a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs
+++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs
diff --git a/tests/ui/traits/next-solver/opaques/no-define-in-wf-check.current.stderr b/tests/ui/traits/next-solver/opaques/no-define-in-wf-check.current.stderr
new file mode 100644
index 00000000000..9a28dc093c1
--- /dev/null
+++ b/tests/ui/traits/next-solver/opaques/no-define-in-wf-check.current.stderr
@@ -0,0 +1,34 @@
+error: unconstrained opaque type
+  --> $DIR/no-define-in-wf-check.rs:19:18
+   |
+LL |     type Tait1 = impl Sized;
+   |                  ^^^^^^^^^^
+   |
+   = note: `Tait1` must be used in combination with a concrete type within the same module
+
+error: unconstrained opaque type
+  --> $DIR/no-define-in-wf-check.rs:27:18
+   |
+LL |     type Tait1 = impl Sized;
+   |                  ^^^^^^^^^^
+   |
+   = note: `Tait1` must be used in combination with a concrete type within the same module
+
+error: unconstrained opaque type
+  --> $DIR/no-define-in-wf-check.rs:36:18
+   |
+LL |     type Tait1 = impl Sized;
+   |                  ^^^^^^^^^^
+   |
+   = note: `Tait1` must be used in combination with a concrete type within the same module
+
+error: unconstrained opaque type
+  --> $DIR/no-define-in-wf-check.rs:47:18
+   |
+LL |     type Tait1 = impl Sized;
+   |                  ^^^^^^^^^^
+   |
+   = note: `Tait1` must be used in combination with a concrete type within the same module
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/traits/next-solver/opaques/no-define-in-wf-check.rs b/tests/ui/traits/next-solver/opaques/no-define-in-wf-check.rs
new file mode 100644
index 00000000000..dd6df097da1
--- /dev/null
+++ b/tests/ui/traits/next-solver/opaques/no-define-in-wf-check.rs
@@ -0,0 +1,66 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@[next] check-pass
+
+// Regression test for trait-system-refactor-initiative#106. We previously
+// tried to define other opaques while checking that opaques are well-formed.
+//
+// This resulted in undesirable ambiguity
+
+#![feature(type_alias_impl_trait)]
+
+mod ex0 {
+    fn foo() -> (impl Sized, impl Sized) {
+        ((), ())
+    }
+}
+mod ex1 {
+    type Tait1 = impl Sized;
+    //[current]~^ ERROR unconstrained opaque type
+    fn foo(x: Tait1) -> impl Sized {
+        let () = x;
+    }
+}
+
+mod ex2 {
+    type Tait1 = impl Sized;
+    //[current]~^ ERROR unconstrained opaque type
+    type Tait2 = impl Sized;
+    fn foo(x: Tait1) -> Tait2 {
+        let () = x;
+    }
+}
+
+mod ex3 {
+    type Tait1 = impl Sized;
+    //[current]~^ ERROR unconstrained opaque type
+    trait Something<T> {}
+    impl<T, U> Something<U> for T {}
+    type Tait2 = impl Something<Tait1>;
+    fn foo(x: Tait1) -> Tait2 {
+        let () = x;
+    }
+}
+
+mod ex4 {
+    type Tait1 = impl Sized;
+    //[current]~^ ERROR unconstrained opaque type
+    trait Trait<U> {
+        type Assoc;
+    }
+
+    impl<T, U> Trait<U> for T {
+        type Assoc = T;
+    }
+
+    // ambiguity when checking that `Tait2` is wf
+    //
+    // ambiguity proving `(): Trait<Tait1>`.
+    type Tait2 = impl Trait<(), Assoc = impl Trait<Tait1>>;
+    fn foo(x: Tait1) -> Tait2 {
+        let () = x;
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/next-solver/select-alias-bound-as-param.rs b/tests/ui/traits/next-solver/opaques/select-alias-bound-as-param.rs
index fd40ef1f872..fd40ef1f872 100644
--- a/tests/ui/traits/next-solver/select-alias-bound-as-param.rs
+++ b/tests/ui/traits/next-solver/opaques/select-alias-bound-as-param.rs