summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2024-03-12 14:26:30 +0100
committerlcnr <rust@lcnr.de>2024-04-25 19:44:00 +0000
commit03878c682a68dc2891eccbd04b5d2f04c91ba0c4 (patch)
tree48daca477cf106446c77e40ecf5cf5770e1d8234 /tests
parent662eadbafb4d4021eb0f0cbe0b2521f2e3da3531 (diff)
hir typeck: look into nested goals
uses a `ProofTreeVisitor` to look into nested goals when looking at the pending obligations during hir typeck. Used by closure signature inference, coercion, and for async functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/closures/deduce-signature/deduce-from-opaque-type-after-norm.rs11
-rw-r--r--tests/ui/closures/deduce-signature/deduce-from-opaque-type.rs9
-rw-r--r--tests/ui/closures/deduce-signature/infer-higher-ranked-signature.rs20
-rw-r--r--tests/ui/closures/deduce-signature/infer-signature-from-impl.rs (renamed from tests/ui/closures/infer-signature-from-impl.rs)3
-rw-r--r--tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr15
-rw-r--r--tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr (renamed from tests/ui/closures/infer-signature-from-impl.next.stderr)3
-rw-r--r--tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.rs23
-rw-r--r--tests/ui/closures/deduce-signature/supertrait-signature-inference-issue-23012.rs (renamed from tests/ui/closures/issue-23012-supertrait-signature-inference.rs)3
-rw-r--r--tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs11
-rw-r--r--tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr14
10 files changed, 84 insertions, 28 deletions
diff --git a/tests/ui/closures/deduce-signature/deduce-from-opaque-type-after-norm.rs b/tests/ui/closures/deduce-signature/deduce-from-opaque-type-after-norm.rs
new file mode 100644
index 00000000000..9885d381d24
--- /dev/null
+++ b/tests/ui/closures/deduce-signature/deduce-from-opaque-type-after-norm.rs
@@ -0,0 +1,11 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+trait Foo {
+ fn test() -> impl Fn(u32) -> u32 {
+ |x| x.count_ones()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/closures/deduce-signature/deduce-from-opaque-type.rs b/tests/ui/closures/deduce-signature/deduce-from-opaque-type.rs
new file mode 100644
index 00000000000..3185a431f0b
--- /dev/null
+++ b/tests/ui/closures/deduce-signature/deduce-from-opaque-type.rs
@@ -0,0 +1,9 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+fn foo() -> impl FnOnce(u32) -> u32 {
+ |x| x.leading_zeros()
+}
+
+fn main() {}
diff --git a/tests/ui/closures/deduce-signature/infer-higher-ranked-signature.rs b/tests/ui/closures/deduce-signature/infer-higher-ranked-signature.rs
new file mode 100644
index 00000000000..d9ab0149087
--- /dev/null
+++ b/tests/ui/closures/deduce-signature/infer-higher-ranked-signature.rs
@@ -0,0 +1,20 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+//@ check-pass
+
+trait Foo {}
+fn needs_foo<T>(_: T)
+where
+ Wrap<T>: Foo,
+{
+}
+
+struct Wrap<T>(T);
+impl<T> Foo for Wrap<T> where T: for<'a> Fn(&'a i32) {}
+
+fn main() {
+ needs_foo(|x| {
+ x.to_string();
+ });
+}
diff --git a/tests/ui/closures/infer-signature-from-impl.rs b/tests/ui/closures/deduce-signature/infer-signature-from-impl.rs
index fa455c15ec7..20802ce37ee 100644
--- a/tests/ui/closures/infer-signature-from-impl.rs
+++ b/tests/ui/closures/deduce-signature/infer-signature-from-impl.rs
@@ -1,8 +1,7 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
-//@[next] known-bug: trait-system-refactor-initiative#71
-//@[current] check-pass
+//@ check-pass
trait Foo {}
fn needs_foo<T>(_: T)
diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr
new file mode 100644
index 00000000000..eaa0d32e75d
--- /dev/null
+++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr
@@ -0,0 +1,15 @@
+error: implementation of `Foo` is not general enough
+ --> $DIR/obligation-with-leaking-placeholders.rs:18:5
+ |
+LL | / needs_foo(|x| {
+LL | |
+LL | |
+LL | | x.to_string();
+LL | | });
+ | |______^ implementation of `Foo` is not general enough
+ |
+ = note: `Wrap<{closure@$DIR/obligation-with-leaking-placeholders.rs:18:15: 18:18}>` must implement `Foo<'0>`, for any lifetime `'0`...
+ = note: ...but it actually implements `Foo<'1>`, for some specific lifetime `'1`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/closures/infer-signature-from-impl.next.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr
index 332917eaaff..3d667f12371 100644
--- a/tests/ui/closures/infer-signature-from-impl.next.stderr
+++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr
@@ -1,8 +1,9 @@
error[E0282]: type annotations needed
- --> $DIR/infer-signature-from-impl.rs:18:16
+ --> $DIR/obligation-with-leaking-placeholders.rs:18:16
|
LL | needs_foo(|x| {
| ^
+...
LL | x.to_string();
| - type must be known at this point
|
diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.rs b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.rs
new file mode 100644
index 00000000000..deb888ec286
--- /dev/null
+++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.rs
@@ -0,0 +1,23 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+
+// See #124385 for more details.
+
+trait Foo<'a> {}
+fn needs_foo<T>(_: T)
+where
+ for<'a> Wrap<T>: Foo<'a>,
+{
+}
+
+struct Wrap<T>(T);
+impl<'a, T> Foo<'a> for Wrap<T> where T: Fn(&'a i32) {}
+
+fn main() {
+ needs_foo(|x| {
+ //[current]~^ implementation of `Foo` is not general enough
+ //[next]~^^ ERROR type annotations needed
+ x.to_string();
+ });
+}
diff --git a/tests/ui/closures/issue-23012-supertrait-signature-inference.rs b/tests/ui/closures/deduce-signature/supertrait-signature-inference-issue-23012.rs
index 732f687309c..16890b28acd 100644
--- a/tests/ui/closures/issue-23012-supertrait-signature-inference.rs
+++ b/tests/ui/closures/deduce-signature/supertrait-signature-inference-issue-23012.rs
@@ -1,3 +1,6 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
//@ check-pass
// Checks that we can infer a closure signature even if the `FnOnce` bound is
// a supertrait of the obligations we have currently registered for the Ty var.
diff --git a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs
deleted file mode 100644
index a0fe7f0d0a5..00000000000
--- a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-//@ compile-flags: -Znext-solver
-// FIXME(-Znext-solver): This test is currently broken because the `deduce_closure_signature`
-// is unable to look at nested obligations.
-trait Foo {
- fn test() -> impl Fn(u32) -> u32 {
- |x| x.count_ones()
- //~^ ERROR type annotations needed
- }
-}
-
-fn main() {}
diff --git a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr
deleted file mode 100644
index 3d7cd1af467..00000000000
--- a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0282]: type annotations needed
- --> $DIR/deduce-closure-signature-after-normalization.rs:6:10
- |
-LL | |x| x.count_ones()
- | ^ - type must be known at this point
- |
-help: consider giving this closure parameter an explicit type
- |
-LL | |x: /* Type */| x.count_ones()
- | ++++++++++++
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0282`.