summaryrefslogtreecommitdiffstats
path: root/src/test/ui/closures
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/closures')
-rw-r--r--src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr4
-rw-r--r--src/test/ui/closures/binder/late-bound-in-body.rs9
-rw-r--r--src/test/ui/closures/binder/nested-closures-regions.rs9
-rw-r--r--src/test/ui/closures/binder/nested-closures-regions.stderr38
-rw-r--r--src/test/ui/closures/binder/nested-closures.rs7
-rw-r--r--src/test/ui/closures/closure-array-break-length.stderr4
-rw-r--r--src/test/ui/closures/issue-23012-supertrait-signature-inference.rs29
-rw-r--r--src/test/ui/closures/issue-78720.stderr4
-rw-r--r--src/test/ui/closures/issue-90871.rs4
-rw-r--r--src/test/ui/closures/issue-90871.stderr23
-rw-r--r--src/test/ui/closures/supertrait-hint-references-assoc-ty.rs17
11 files changed, 132 insertions, 16 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr
index 384010859..39ec71ba2 100644
--- a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr
+++ b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr
@@ -16,7 +16,7 @@ LL | / || match out_ref {
LL | | Variant::A => (),
LL | | Variant::B => (),
LL | | };
- | |______^
+ | |_____^
|
= note: closures are lazy and do nothing unless called
= note: `#[warn(unused_must_use)]` on by default
@@ -28,7 +28,7 @@ LL | / || match here.field {
LL | | Variant::A => (),
LL | | Variant::B => (),
LL | | };
- | |______^
+ | |_____^
|
= note: closures are lazy and do nothing unless called
diff --git a/src/test/ui/closures/binder/late-bound-in-body.rs b/src/test/ui/closures/binder/late-bound-in-body.rs
new file mode 100644
index 000000000..bb5c7552f
--- /dev/null
+++ b/src/test/ui/closures/binder/late-bound-in-body.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(closure_lifetime_binder)]
+
+fn main() {
+ let _ = for<'a> || -> () {
+ let _: &'a bool = &true;
+ };
+}
diff --git a/src/test/ui/closures/binder/nested-closures-regions.rs b/src/test/ui/closures/binder/nested-closures-regions.rs
new file mode 100644
index 000000000..6bfc6c80b
--- /dev/null
+++ b/src/test/ui/closures/binder/nested-closures-regions.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(closure_lifetime_binder)]
+#![feature(rustc_attrs)]
+
+#[rustc_regions]
+fn main() {
+ for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+}
diff --git a/src/test/ui/closures/binder/nested-closures-regions.stderr b/src/test/ui/closures/binder/nested-closures-regions.stderr
new file mode 100644
index 000000000..b385e0ed6
--- /dev/null
+++ b/src/test/ui/closures/binder/nested-closures-regions.stderr
@@ -0,0 +1,38 @@
+note: external requirements
+ --> $DIR/nested-closures-regions.rs:8:24
+ |
+LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: defining type: main::{closure#0}::{closure#0} with closure substs [
+ i8,
+ extern "rust-call" fn((&(),)),
+ (),
+ ]
+ = note: late-bound region is '_#4r
+ = note: late-bound region is '_#2r
+ = note: number of external vids: 3
+ = note: where '_#1r: '_#2r
+ = note: where '_#2r: '_#1r
+
+note: no external requirements
+ --> $DIR/nested-closures-regions.rs:8:5
+ |
+LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: defining type: main::{closure#0} with closure substs [
+ i8,
+ extern "rust-call" fn(()),
+ (),
+ ]
+ = note: late-bound region is '_#2r
+
+note: no external requirements
+ --> $DIR/nested-closures-regions.rs:7:1
+ |
+LL | fn main() {
+ | ^^^^^^^^^
+ |
+ = note: defining type: main
+
diff --git a/src/test/ui/closures/binder/nested-closures.rs b/src/test/ui/closures/binder/nested-closures.rs
new file mode 100644
index 000000000..b3c36e7ee
--- /dev/null
+++ b/src/test/ui/closures/binder/nested-closures.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+#![feature(closure_lifetime_binder)]
+
+fn main() {
+ for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; };
+}
diff --git a/src/test/ui/closures/closure-array-break-length.stderr b/src/test/ui/closures/closure-array-break-length.stderr
index 2b8ab9bfc..7e0b0027a 100644
--- a/src/test/ui/closures/closure-array-break-length.stderr
+++ b/src/test/ui/closures/closure-array-break-length.stderr
@@ -10,11 +10,11 @@ error[E0268]: `continue` outside of a loop
LL | while |_: [_; continue]| {} {}
| ^^^^^^^^ cannot `continue` outside of a loop
-error[E0268]: `break` outside of a loop
+error[E0268]: `break` outside of a loop or labeled block
--> $DIR/closure-array-break-length.rs:6:19
|
LL | while |_: [_; break]| {} {}
- | ^^^^^ cannot `break` outside of a loop
+ | ^^^^^ cannot `break` outside of a loop or labeled block
error: aborting due to 3 previous errors
diff --git a/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs b/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs
new file mode 100644
index 000000000..5899b703e
--- /dev/null
+++ b/src/test/ui/closures/issue-23012-supertrait-signature-inference.rs
@@ -0,0 +1,29 @@
+// 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.
+
+pub trait Receive<T, E>: FnOnce(Result<T, E>) {
+ fn receive(self, res: Result<T, E>);
+}
+
+impl<T, E, F: FnOnce(Result<T, E>)> Receive<T, E> for F {
+ fn receive(self, res: Result<T, E>) {
+ self(res)
+ }
+}
+
+pub trait Async<T, E> {
+ fn receive<F: Receive<T, E>>(self, f: F);
+}
+
+impl<T, E> Async<T, E> for Result<T, E> {
+ fn receive<F: Receive<T, E>>(self, f: F) {
+ f(self)
+ }
+}
+
+pub fn main() {
+ Ok::<u32, ()>(123).receive(|res| {
+ res.unwrap();
+ });
+}
diff --git a/src/test/ui/closures/issue-78720.stderr b/src/test/ui/closures/issue-78720.stderr
index 3dd138772..da3f539a0 100644
--- a/src/test/ui/closures/issue-78720.stderr
+++ b/src/test/ui/closures/issue-78720.stderr
@@ -12,8 +12,8 @@ LL | _func: F,
|
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
|
-LL | pub trait Fn<Args>: FnMut<Args> {
- | ------------------------------- similarly named trait `Fn` defined here
+LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
+ | -------------------------------------- similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
diff --git a/src/test/ui/closures/issue-90871.rs b/src/test/ui/closures/issue-90871.rs
index 9c70bbc85..7ce061cd3 100644
--- a/src/test/ui/closures/issue-90871.rs
+++ b/src/test/ui/closures/issue-90871.rs
@@ -1,5 +1,7 @@
+#![feature(type_ascription)]
+
fn main() {
- 2: n([u8; || 1])
+ type_ascribe!(2, n([u8; || 1]))
//~^ ERROR cannot find type `n` in this scope
//~| ERROR mismatched types
}
diff --git a/src/test/ui/closures/issue-90871.stderr b/src/test/ui/closures/issue-90871.stderr
index 1e102cc98..a482750fb 100644
--- a/src/test/ui/closures/issue-90871.stderr
+++ b/src/test/ui/closures/issue-90871.stderr
@@ -1,21 +1,26 @@
error[E0412]: cannot find type `n` in this scope
- --> $DIR/issue-90871.rs:2:8
+ --> $DIR/issue-90871.rs:4:22
|
-LL | 2: n([u8; || 1])
- | ^ expecting a type here because of type ascription
+LL | type_ascribe!(2, n([u8; || 1]))
+ | ^ help: a trait with a similar name exists: `Fn`
+ |
+ ::: $SRC_DIR/core/src/ops/function.rs:LL:COL
+ |
+LL | pub trait Fn<Args: Tuple>: FnMut<Args> {
+ | -------------------------------------- similarly named trait `Fn` defined here
error[E0308]: mismatched types
- --> $DIR/issue-90871.rs:2:15
+ --> $DIR/issue-90871.rs:4:29
|
-LL | 2: n([u8; || 1])
- | ^^^^ expected `usize`, found closure
+LL | type_ascribe!(2, n([u8; || 1]))
+ | ^^^^ expected `usize`, found closure
|
= note: expected type `usize`
- found closure `[closure@$DIR/issue-90871.rs:2:15: 2:17]`
+ found closure `[closure@$DIR/issue-90871.rs:4:29: 4:31]`
help: use parentheses to call this closure
|
-LL | 2: n([u8; (|| 1)()])
- | + +++
+LL | type_ascribe!(2, n([u8; (|| 1)()]))
+ | + +++
error: aborting due to 2 previous errors
diff --git a/src/test/ui/closures/supertrait-hint-references-assoc-ty.rs b/src/test/ui/closures/supertrait-hint-references-assoc-ty.rs
new file mode 100644
index 000000000..270bf14c3
--- /dev/null
+++ b/src/test/ui/closures/supertrait-hint-references-assoc-ty.rs
@@ -0,0 +1,17 @@
+// check-pass
+
+pub trait Fn0: Fn(i32) -> Self::Out {
+ type Out;
+}
+
+impl<F: Fn(i32) -> ()> Fn0 for F {
+ type Out = ();
+}
+
+pub fn closure_typer(_: impl Fn0) {}
+
+fn main() {
+ closure_typer(move |x| {
+ let _: i64 = x.into();
+ });
+}