From b502d55288e4f8898fb851bd279c9797b4171004 Mon Sep 17 00:00:00 2001 From: danieljofficial Date: Wed, 13 May 2026 14:03:45 +0100 Subject: [PATCH 1/2] move closures related ui tests into its folder --- .../boxed-closure-captures-fnmut-with-ref.rs | 21 +++++++++++++++++++ .../boxed-closure-sent-through-thread.rs} | 0 .../boxed-closure-with-borrowed-param.rs} | 0 .../ui/closures/call-boxed-closure-no-args.rs | 9 ++++++++ ...closure-through-lifetime-generic-struct.rs | 10 +++++++++ .../call-fnmut-trait-object-via-ref-mut.rs} | 0 ...re-kind-caching-during-upvar-inference.rs} | 0 ...ind-caching-during-upvar-inference.stderr} | 0 .../closure-to-fn-pointer-lifetime-error.rs} | 0 ...osure-to-fn-pointer-lifetime-error.stderr} | 0 .../closure-with-fixed-size-array-param.rs} | 0 .../debug-info-for-closure-capture.rs} | 0 .../closures/destructure-newtype-closure.rs | 7 +++++++ .../drop-glue-for-closure-with-captures.rs} | 0 ...explicit-return-in-closure-and-outer-fn.rs | 10 +++++++++ .../fn-sugar-in-boxed-trait-object.rs | 8 +++++++ ...tb-closure-in-recursive-enum-type-error.rs | 20 ++++++++++++++++++ ...losure-in-recursive-enum-type-error.stderr | 14 +++++++++++++ .../module-path-not-confused-with-upvar.rs} | 0 .../move-closure-can-call-captured-fnmut.rs | 20 ++++++++++++++++++ tests/ui/closures/move-closure-is-send.rs | 18 ++++++++++++++++ .../no-unused-mut-warning-for-move-closure.rs | 12 +++++++++++ .../pass-lifetime-fn-to-generic-fnonce.rs | 9 ++++++++ ...ref-binding-lifetime-in-closure-pattern.rs | 9 ++++++++ ...ion-obligations-closure-and-projection.rs} | 0 .../unique-closure-type-mismatch.rs} | 0 .../unique-closure-type-mismatch.stderr} | 0 27 files changed, 167 insertions(+) create mode 100644 tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs rename tests/ui/{issues/issue-3609.rs => closures/boxed-closure-sent-through-thread.rs} (100%) rename tests/ui/{issues/issue-3424.rs => closures/boxed-closure-with-borrowed-param.rs} (100%) create mode 100644 tests/ui/closures/call-boxed-closure-no-args.rs create mode 100644 tests/ui/closures/call-closure-through-lifetime-generic-struct.rs rename tests/ui/{issues/issue-32389.rs => closures/call-fnmut-trait-object-via-ref-mut.rs} (100%) rename tests/ui/{issues/issue-34349.rs => closures/closure-kind-caching-during-upvar-inference.rs} (100%) rename tests/ui/{issues/issue-34349.stderr => closures/closure-kind-caching-during-upvar-inference.stderr} (100%) rename tests/ui/{issues/issue-40000.rs => closures/closure-to-fn-pointer-lifetime-error.rs} (100%) rename tests/ui/{issues/issue-40000.stderr => closures/closure-to-fn-pointer-lifetime-error.stderr} (100%) rename tests/ui/{issues/issue-28181.rs => closures/closure-with-fixed-size-array-param.rs} (100%) rename tests/ui/{issues/issue-26484.rs => closures/debug-info-for-closure-capture.rs} (100%) create mode 100644 tests/ui/closures/destructure-newtype-closure.rs rename tests/ui/{issues/issue-36260.rs => closures/drop-glue-for-closure-with-captures.rs} (100%) create mode 100644 tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs create mode 100644 tests/ui/closures/fn-sugar-in-boxed-trait-object.rs create mode 100644 tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs create mode 100644 tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr rename tests/ui/{issues/issue-29522.rs => closures/module-path-not-confused-with-upvar.rs} (100%) create mode 100644 tests/ui/closures/move-closure-can-call-captured-fnmut.rs create mode 100644 tests/ui/closures/move-closure-is-send.rs create mode 100644 tests/ui/closures/no-unused-mut-warning-for-move-closure.rs create mode 100644 tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs create mode 100644 tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs rename tests/ui/{issues/issue-46069.rs => closures/region-obligations-closure-and-projection.rs} (100%) rename tests/ui/{issues/issue-24036.rs => closures/unique-closure-type-mismatch.rs} (100%) rename tests/ui/{issues/issue-24036.stderr => closures/unique-closure-type-mismatch.stderr} (100%) diff --git a/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs b/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs new file mode 100644 index 0000000000000..b3b008229a53a --- /dev/null +++ b/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs @@ -0,0 +1,21 @@ +//@ check-pass + +pub trait Promisable: Send + Sync {} +impl Promisable for T {} + +pub fn propagate<'a, T, E, F, G>(mut action: F) + -> Box) -> Result + 'a> + where + T: Promisable + Clone + 'a, + E: Promisable + Clone + 'a, + F: FnMut(&T) -> Result + Send + 'a, + G: FnMut(Result) -> Result + 'a { + Box::new(move |result: Result| { + match result { + Ok(ref t) => action(t), + Err(ref e) => Err(e.clone()), + } + }) +} + +fn main() {} diff --git a/tests/ui/issues/issue-3609.rs b/tests/ui/closures/boxed-closure-sent-through-thread.rs similarity index 100% rename from tests/ui/issues/issue-3609.rs rename to tests/ui/closures/boxed-closure-sent-through-thread.rs diff --git a/tests/ui/issues/issue-3424.rs b/tests/ui/closures/boxed-closure-with-borrowed-param.rs similarity index 100% rename from tests/ui/issues/issue-3424.rs rename to tests/ui/closures/boxed-closure-with-borrowed-param.rs diff --git a/tests/ui/closures/call-boxed-closure-no-args.rs b/tests/ui/closures/call-boxed-closure-no-args.rs new file mode 100644 index 0000000000000..b213b79d37cab --- /dev/null +++ b/tests/ui/closures/call-boxed-closure-no-args.rs @@ -0,0 +1,9 @@ +//@ run-pass +// Test that overloaded calls work with zero arity closures + + +fn main() { + let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; + + let _: Option> = functions.iter().map(|f| (*f)()).collect(); +} diff --git a/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs b/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs new file mode 100644 index 0000000000000..da28a14685f6c --- /dev/null +++ b/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs @@ -0,0 +1,10 @@ +//@ run-pass +#![allow(unused_variables)] +use std::marker::PhantomData; + +fn main() { + struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F, marker: PhantomData<&'a ()> } + let f = |x: Vec<&str>| -> &str { "foobar" }; + let sym = Symbol { function: f, marker: PhantomData }; + (sym.function)(vec![]); +} diff --git a/tests/ui/issues/issue-32389.rs b/tests/ui/closures/call-fnmut-trait-object-via-ref-mut.rs similarity index 100% rename from tests/ui/issues/issue-32389.rs rename to tests/ui/closures/call-fnmut-trait-object-via-ref-mut.rs diff --git a/tests/ui/issues/issue-34349.rs b/tests/ui/closures/closure-kind-caching-during-upvar-inference.rs similarity index 100% rename from tests/ui/issues/issue-34349.rs rename to tests/ui/closures/closure-kind-caching-during-upvar-inference.rs diff --git a/tests/ui/issues/issue-34349.stderr b/tests/ui/closures/closure-kind-caching-during-upvar-inference.stderr similarity index 100% rename from tests/ui/issues/issue-34349.stderr rename to tests/ui/closures/closure-kind-caching-during-upvar-inference.stderr diff --git a/tests/ui/issues/issue-40000.rs b/tests/ui/closures/closure-to-fn-pointer-lifetime-error.rs similarity index 100% rename from tests/ui/issues/issue-40000.rs rename to tests/ui/closures/closure-to-fn-pointer-lifetime-error.rs diff --git a/tests/ui/issues/issue-40000.stderr b/tests/ui/closures/closure-to-fn-pointer-lifetime-error.stderr similarity index 100% rename from tests/ui/issues/issue-40000.stderr rename to tests/ui/closures/closure-to-fn-pointer-lifetime-error.stderr diff --git a/tests/ui/issues/issue-28181.rs b/tests/ui/closures/closure-with-fixed-size-array-param.rs similarity index 100% rename from tests/ui/issues/issue-28181.rs rename to tests/ui/closures/closure-with-fixed-size-array-param.rs diff --git a/tests/ui/issues/issue-26484.rs b/tests/ui/closures/debug-info-for-closure-capture.rs similarity index 100% rename from tests/ui/issues/issue-26484.rs rename to tests/ui/closures/debug-info-for-closure-capture.rs diff --git a/tests/ui/closures/destructure-newtype-closure.rs b/tests/ui/closures/destructure-newtype-closure.rs new file mode 100644 index 0000000000000..7b49fe8c7b472 --- /dev/null +++ b/tests/ui/closures/destructure-newtype-closure.rs @@ -0,0 +1,7 @@ +//@ run-pass +struct GradFn usize>(F); + +fn main() { + let GradFn(x_squared) : GradFn<_> = GradFn(|| -> usize { 2 }); + let _ = x_squared(); +} diff --git a/tests/ui/issues/issue-36260.rs b/tests/ui/closures/drop-glue-for-closure-with-captures.rs similarity index 100% rename from tests/ui/issues/issue-36260.rs rename to tests/ui/closures/drop-glue-for-closure-with-captures.rs diff --git a/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs b/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs new file mode 100644 index 0000000000000..710dc0acda7e9 --- /dev/null +++ b/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs @@ -0,0 +1,10 @@ +//@ run-pass +#![allow(dead_code)] + +// This used to cause an ICE because the retslot for the "return" had the wrong type +fn testcase<'a>() -> Box + 'a> { + return Box::new((0..3).map(|i| { return i; })); +} + +fn main() { +} diff --git a/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs b/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs new file mode 100644 index 0000000000000..dbb560a199bf7 --- /dev/null +++ b/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs @@ -0,0 +1,8 @@ +//@ run-pass +fn action(mut cb: Box usize>) -> usize { + cb(1) +} + +pub fn main() { + println!("num: {}", action(Box::new(move |u| u))); +} diff --git a/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs new file mode 100644 index 0000000000000..a68369616d8b6 --- /dev/null +++ b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs @@ -0,0 +1,20 @@ +pub enum Expr<'var, VAR> { + Let(Box>, + Box Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) +} + +pub fn add<'var, VAR> + (a: Expr<'var, VAR>, b: Expr<'var, VAR>) -> Expr<'var, VAR> { + loop {} +} + +pub fn let_<'var, VAR, F: for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>> + (a: Expr<'var, VAR>, b: F) -> Expr<'var, VAR> { + loop {} +} + +fn main() { + let ex = |x| { //~ ERROR type annotations needed + let_(add(x,x), |y| { + let_(add(x, x), |x|x)})}; +} diff --git a/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr new file mode 100644 index 0000000000000..f70ac0c9f388a --- /dev/null +++ b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed for `Expr<'_, _>` + --> $DIR/issue-23046.rs:17:15 + | +LL | let ex = |x| { + | ^ + | +help: consider giving this closure parameter an explicit type, where the type for type parameter `VAR` is specified + | +LL | let ex = |x: Expr<'_, VAR>| { + | +++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-29522.rs b/tests/ui/closures/module-path-not-confused-with-upvar.rs similarity index 100% rename from tests/ui/issues/issue-29522.rs rename to tests/ui/closures/module-path-not-confused-with-upvar.rs diff --git a/tests/ui/closures/move-closure-can-call-captured-fnmut.rs b/tests/ui/closures/move-closure-can-call-captured-fnmut.rs new file mode 100644 index 0000000000000..2b2370b0e2b4c --- /dev/null +++ b/tests/ui/closures/move-closure-can-call-captured-fnmut.rs @@ -0,0 +1,20 @@ +//@ check-pass +#![allow(dead_code)] +struct Parser<'a, I, O> { + parse: Box Result + 'a> +} + +impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { + fn compose(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> { + Parser { + parse: Box::new(move |x: I| { + match (self.parse)(x) { + Ok(r) => (rhs.parse)(r), + Err(e) => Err(e) + } + }) + } + } +} + +fn main() {} diff --git a/tests/ui/closures/move-closure-is-send.rs b/tests/ui/closures/move-closure-is-send.rs new file mode 100644 index 0000000000000..d9a7aa9101d3f --- /dev/null +++ b/tests/ui/closures/move-closure-is-send.rs @@ -0,0 +1,18 @@ +//@ run-pass +#![allow(unused_variables)] +//@ needs-threads + +use std::thread; +use std::mem; + +fn main() { + let y = 0u8; + let closure = move |x: u8| y + x; + + // Check that both closures are capturing by value + assert_eq!(1, mem::size_of_val(&closure)); + + thread::spawn(move|| { + let ok = closure; + }).join().ok().unwrap(); +} diff --git a/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs b/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs new file mode 100644 index 0000000000000..f7f4f4348afab --- /dev/null +++ b/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs @@ -0,0 +1,12 @@ +//@ run-pass + +#![deny(warnings)] + +fn foo(_f: F) { } + +fn main() { + let mut var = Vec::new(); + foo(move|| { + var.push(1); + }); +} diff --git a/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs b/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs new file mode 100644 index 0000000000000..2172c631b841d --- /dev/null +++ b/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs @@ -0,0 +1,9 @@ +//@ run-pass +#![allow(unused_variables)] + +fn foo T>(f: F) {} +fn id<'a>(input: &'a u8) -> &'a u8 { input } + +fn main() { + foo(id); +} diff --git a/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs b/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs new file mode 100644 index 0000000000000..fa3988e099945 --- /dev/null +++ b/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs @@ -0,0 +1,9 @@ +//@ check-pass + +fn cb<'a,T>(_x: Box, bool))) -> T>) -> T { + panic!() +} + +fn main() { + cb(Box::new(|(k, &(ref v, b))| (*k, v.clone(), b))); +} diff --git a/tests/ui/issues/issue-46069.rs b/tests/ui/closures/region-obligations-closure-and-projection.rs similarity index 100% rename from tests/ui/issues/issue-46069.rs rename to tests/ui/closures/region-obligations-closure-and-projection.rs diff --git a/tests/ui/issues/issue-24036.rs b/tests/ui/closures/unique-closure-type-mismatch.rs similarity index 100% rename from tests/ui/issues/issue-24036.rs rename to tests/ui/closures/unique-closure-type-mismatch.rs diff --git a/tests/ui/issues/issue-24036.stderr b/tests/ui/closures/unique-closure-type-mismatch.stderr similarity index 100% rename from tests/ui/issues/issue-24036.stderr rename to tests/ui/closures/unique-closure-type-mismatch.stderr From 3429bdf127dd9cb5a8a068f547c24ee62dc855f3 Mon Sep 17 00:00:00 2001 From: danieljofficial Date: Wed, 13 May 2026 15:03:47 +0100 Subject: [PATCH 2/2] add issue links and bless --- .../boxed-closure-captures-fnmut-with-ref.rs | 2 ++ .../boxed-closure-sent-through-thread.rs | 2 ++ .../boxed-closure-with-borrowed-param.rs | 2 ++ .../ui/closures/call-boxed-closure-no-args.rs | 2 ++ ...closure-through-lifetime-generic-struct.rs | 2 ++ .../call-fnmut-trait-object-via-ref-mut.rs | 2 ++ ...ure-kind-caching-during-upvar-inference.rs | 2 ++ ...kind-caching-during-upvar-inference.stderr | 4 ++-- .../closure-to-fn-pointer-lifetime-error.rs | 2 ++ ...losure-to-fn-pointer-lifetime-error.stderr | 4 ++-- .../closure-with-fixed-size-array-param.rs | 2 ++ .../debug-info-for-closure-capture.rs | 2 ++ .../closures/destructure-newtype-closure.rs | 2 ++ .../drop-glue-for-closure-with-captures.rs | 2 ++ ...explicit-return-in-closure-and-outer-fn.rs | 2 ++ .../fn-sugar-in-boxed-trait-object.rs | 2 ++ ...tb-closure-in-recursive-enum-type-error.rs | 2 ++ ...losure-in-recursive-enum-type-error.stderr | 2 +- .../module-path-not-confused-with-upvar.rs | 2 ++ .../move-closure-can-call-captured-fnmut.rs | 2 ++ tests/ui/closures/move-closure-is-send.rs | 2 ++ .../no-unused-mut-warning-for-move-closure.rs | 2 ++ .../pass-lifetime-fn-to-generic-fnonce.rs | 2 ++ ...ref-binding-lifetime-in-closure-pattern.rs | 2 ++ ...gion-obligations-closure-and-projection.rs | 2 ++ .../closures/unique-closure-type-mismatch.rs | 2 ++ .../unique-closure-type-mismatch.stderr | 8 +++---- tests/ui/issues/issue-16560.rs | 18 ---------------- tests/ui/issues/issue-16668.rs | 20 ------------------ tests/ui/issues/issue-16671.rs | 12 ----------- tests/ui/issues/issue-16994.rs | 9 -------- tests/ui/issues/issue-17816.rs | 10 --------- tests/ui/issues/issue-17897.rs | 8 ------- tests/ui/issues/issue-18188.rs | 21 ------------------- tests/ui/issues/issue-19127.rs | 9 -------- tests/ui/issues/issue-20174.rs | 7 ------- tests/ui/issues/issue-20575.rs | 9 -------- tests/ui/issues/issue-22346.rs | 10 --------- tests/ui/issues/issue-23046.rs | 20 ------------------ tests/ui/issues/issue-23046.stderr | 14 ------------- 40 files changed, 55 insertions(+), 176 deletions(-) delete mode 100644 tests/ui/issues/issue-16560.rs delete mode 100644 tests/ui/issues/issue-16668.rs delete mode 100644 tests/ui/issues/issue-16671.rs delete mode 100644 tests/ui/issues/issue-16994.rs delete mode 100644 tests/ui/issues/issue-17816.rs delete mode 100644 tests/ui/issues/issue-17897.rs delete mode 100644 tests/ui/issues/issue-18188.rs delete mode 100644 tests/ui/issues/issue-19127.rs delete mode 100644 tests/ui/issues/issue-20174.rs delete mode 100644 tests/ui/issues/issue-20575.rs delete mode 100644 tests/ui/issues/issue-22346.rs delete mode 100644 tests/ui/issues/issue-23046.rs delete mode 100644 tests/ui/issues/issue-23046.stderr diff --git a/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs b/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs index b3b008229a53a..6f2c38843d754 100644 --- a/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs +++ b/tests/ui/closures/boxed-closure-captures-fnmut-with-ref.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/18188 + //@ check-pass pub trait Promisable: Send + Sync {} diff --git a/tests/ui/closures/boxed-closure-sent-through-thread.rs b/tests/ui/closures/boxed-closure-sent-through-thread.rs index a226e5b01362a..14320e0c4ab3c 100644 --- a/tests/ui/closures/boxed-closure-sent-through-thread.rs +++ b/tests/ui/closures/boxed-closure-sent-through-thread.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/3609 + //@ check-pass #![allow(unused_must_use)] #![allow(dead_code)] diff --git a/tests/ui/closures/boxed-closure-with-borrowed-param.rs b/tests/ui/closures/boxed-closure-with-borrowed-param.rs index 4d1a652142032..2d8dd4d800b85 100644 --- a/tests/ui/closures/boxed-closure-with-borrowed-param.rs +++ b/tests/ui/closures/boxed-closure-with-borrowed-param.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/3424 + //@ check-pass #![allow(dead_code)] #![allow(non_camel_case_types)] diff --git a/tests/ui/closures/call-boxed-closure-no-args.rs b/tests/ui/closures/call-boxed-closure-no-args.rs index b213b79d37cab..bf6b73ee6fd57 100644 --- a/tests/ui/closures/call-boxed-closure-no-args.rs +++ b/tests/ui/closures/call-boxed-closure-no-args.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/20575 + //@ run-pass // Test that overloaded calls work with zero arity closures diff --git a/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs b/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs index da28a14685f6c..aa2180e3c7f09 100644 --- a/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs +++ b/tests/ui/closures/call-closure-through-lifetime-generic-struct.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/17816 + //@ run-pass #![allow(unused_variables)] use std::marker::PhantomData; diff --git a/tests/ui/closures/call-fnmut-trait-object-via-ref-mut.rs b/tests/ui/closures/call-fnmut-trait-object-via-ref-mut.rs index 683c4874e8c20..2f1d29f77f27c 100644 --- a/tests/ui/closures/call-fnmut-trait-object-via-ref-mut.rs +++ b/tests/ui/closures/call-fnmut-trait-object-via-ref-mut.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/32389 + //@ run-pass fn foo() -> T { loop {} } diff --git a/tests/ui/closures/closure-kind-caching-during-upvar-inference.rs b/tests/ui/closures/closure-kind-caching-during-upvar-inference.rs index d861802610aac..e24e23d49d555 100644 --- a/tests/ui/closures/closure-kind-caching-during-upvar-inference.rs +++ b/tests/ui/closures/closure-kind-caching-during-upvar-inference.rs @@ -1,3 +1,5 @@ +//! Issue: https://github.com/rust-lang/rust/issues/34349 + // This is a regression test for a problem encountered around upvar // inference and trait caching: in particular, we were entering a // temporary closure kind during inference, and then caching results diff --git a/tests/ui/closures/closure-kind-caching-during-upvar-inference.stderr b/tests/ui/closures/closure-kind-caching-during-upvar-inference.stderr index 6a6188f10c8f8..291ad5960bc21 100644 --- a/tests/ui/closures/closure-kind-caching-during-upvar-inference.stderr +++ b/tests/ui/closures/closure-kind-caching-during-upvar-inference.stderr @@ -1,5 +1,5 @@ error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut` - --> $DIR/issue-34349.rs:16:17 + --> $DIR/closure-kind-caching-during-upvar-inference.rs:18:17 | LL | let diary = || { | ^^ this closure implements `FnMut`, not `Fn` @@ -12,7 +12,7 @@ LL | apply(diary); | required by a bound introduced by this call | note: required by a bound in `apply` - --> $DIR/issue-34349.rs:11:32 + --> $DIR/closure-kind-caching-during-upvar-inference.rs:13:32 | LL | fn apply(f: F) where F: Fn() { | ^^^^ required by this bound in `apply` diff --git a/tests/ui/closures/closure-to-fn-pointer-lifetime-error.rs b/tests/ui/closures/closure-to-fn-pointer-lifetime-error.rs index a6e05e7ba02a3..74d5470f89665 100644 --- a/tests/ui/closures/closure-to-fn-pointer-lifetime-error.rs +++ b/tests/ui/closures/closure-to-fn-pointer-lifetime-error.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/40000 + fn main() { let bar: fn(&mut u32) = |_| {}; diff --git a/tests/ui/closures/closure-to-fn-pointer-lifetime-error.stderr b/tests/ui/closures/closure-to-fn-pointer-lifetime-error.stderr index 0737a9610e294..7466751e43b51 100644 --- a/tests/ui/closures/closure-to-fn-pointer-lifetime-error.stderr +++ b/tests/ui/closures/closure-to-fn-pointer-lifetime-error.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/closure-to-fn-pointer-lifetime-error.rs:8:9 | LL | foo(bar); | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | foo(bar); found trait object `dyn Fn(&i32)` error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/closure-to-fn-pointer-lifetime-error.rs:8:9 | LL | foo(bar); | ^^^ one type is more general than the other diff --git a/tests/ui/closures/closure-with-fixed-size-array-param.rs b/tests/ui/closures/closure-with-fixed-size-array-param.rs index e1cb5ba1c8828..f12df2e5f628a 100644 --- a/tests/ui/closures/closure-with-fixed-size-array-param.rs +++ b/tests/ui/closures/closure-with-fixed-size-array-param.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/28181 + //@ run-pass fn bar(f: F) -> usize where F: Fn([usize; 1]) -> usize { f([2]) } diff --git a/tests/ui/closures/debug-info-for-closure-capture.rs b/tests/ui/closures/debug-info-for-closure-capture.rs index c7053505567ab..2a8db27bda805 100644 --- a/tests/ui/closures/debug-info-for-closure-capture.rs +++ b/tests/ui/closures/debug-info-for-closure-capture.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/26484 + //@ run-pass //@ compile-flags:-g diff --git a/tests/ui/closures/destructure-newtype-closure.rs b/tests/ui/closures/destructure-newtype-closure.rs index 7b49fe8c7b472..f8543e64cb353 100644 --- a/tests/ui/closures/destructure-newtype-closure.rs +++ b/tests/ui/closures/destructure-newtype-closure.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/20174 + //@ run-pass struct GradFn usize>(F); diff --git a/tests/ui/closures/drop-glue-for-closure-with-captures.rs b/tests/ui/closures/drop-glue-for-closure-with-captures.rs index 265b0d2f80217..2ccf4c31a995e 100644 --- a/tests/ui/closures/drop-glue-for-closure-with-captures.rs +++ b/tests/ui/closures/drop-glue-for-closure-with-captures.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/36260 + //@ run-pass // Make sure this compiles without getting a linker error because of missing // drop-glue because the collector missed adding drop-glue for the closure: diff --git a/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs b/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs index 710dc0acda7e9..74e0ea345dd62 100644 --- a/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs +++ b/tests/ui/closures/explicit-return-in-closure-and-outer-fn.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/22346 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs b/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs index dbb560a199bf7..8f475057f376d 100644 --- a/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs +++ b/tests/ui/closures/fn-sugar-in-boxed-trait-object.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/17897 + //@ run-pass fn action(mut cb: Box usize>) -> usize { cb(1) diff --git a/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs index a68369616d8b6..e66603a1f7dc6 100644 --- a/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs +++ b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/23046 + pub enum Expr<'var, VAR> { Let(Box>, Box Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) diff --git a/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr index f70ac0c9f388a..56ebb0a339a50 100644 --- a/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr +++ b/tests/ui/closures/hrtb-closure-in-recursive-enum-type-error.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed for `Expr<'_, _>` - --> $DIR/issue-23046.rs:17:15 + --> $DIR/hrtb-closure-in-recursive-enum-type-error.rs:19:15 | LL | let ex = |x| { | ^ diff --git a/tests/ui/closures/module-path-not-confused-with-upvar.rs b/tests/ui/closures/module-path-not-confused-with-upvar.rs index 2a39ef28bdbbc..9eb56bee2f33c 100644 --- a/tests/ui/closures/module-path-not-confused-with-upvar.rs +++ b/tests/ui/closures/module-path-not-confused-with-upvar.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/29522 + //@ run-pass #![allow(unused_variables)] // check that we don't accidentally capture upvars just because their name diff --git a/tests/ui/closures/move-closure-can-call-captured-fnmut.rs b/tests/ui/closures/move-closure-can-call-captured-fnmut.rs index 2b2370b0e2b4c..8267dd513417a 100644 --- a/tests/ui/closures/move-closure-can-call-captured-fnmut.rs +++ b/tests/ui/closures/move-closure-can-call-captured-fnmut.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16668 + //@ check-pass #![allow(dead_code)] struct Parser<'a, I, O> { diff --git a/tests/ui/closures/move-closure-is-send.rs b/tests/ui/closures/move-closure-is-send.rs index d9a7aa9101d3f..ace163a37d839 100644 --- a/tests/ui/closures/move-closure-is-send.rs +++ b/tests/ui/closures/move-closure-is-send.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16560 + //@ run-pass #![allow(unused_variables)] //@ needs-threads diff --git a/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs b/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs index f7f4f4348afab..a8c8aae3bb299 100644 --- a/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs +++ b/tests/ui/closures/no-unused-mut-warning-for-move-closure.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16671 + //@ run-pass #![deny(warnings)] diff --git a/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs b/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs index 2172c631b841d..2da3ac24eb5b0 100644 --- a/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs +++ b/tests/ui/closures/pass-lifetime-fn-to-generic-fnonce.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/19127 + //@ run-pass #![allow(unused_variables)] diff --git a/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs b/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs index fa3988e099945..72648a92decf3 100644 --- a/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs +++ b/tests/ui/closures/ref-binding-lifetime-in-closure-pattern.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16994 + //@ check-pass fn cb<'a,T>(_x: Box, bool))) -> T>) -> T { diff --git a/tests/ui/closures/region-obligations-closure-and-projection.rs b/tests/ui/closures/region-obligations-closure-and-projection.rs index adfb567d7dd32..9010b7c8c6bed 100644 --- a/tests/ui/closures/region-obligations-closure-and-projection.rs +++ b/tests/ui/closures/region-obligations-closure-and-projection.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/46069 + //@ run-pass use std::iter::{Fuse, Cloned}; use std::slice::Iter; diff --git a/tests/ui/closures/unique-closure-type-mismatch.rs b/tests/ui/closures/unique-closure-type-mismatch.rs index 7df036c8e3a45..ee05c9ed77e40 100644 --- a/tests/ui/closures/unique-closure-type-mismatch.rs +++ b/tests/ui/closures/unique-closure-type-mismatch.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/24036 + fn closure_to_loc() { let mut x = |c| c + 1; x = |c| c + 1; diff --git a/tests/ui/closures/unique-closure-type-mismatch.stderr b/tests/ui/closures/unique-closure-type-mismatch.stderr index 184383b736942..3a31b6db4f62b 100644 --- a/tests/ui/closures/unique-closure-type-mismatch.stderr +++ b/tests/ui/closures/unique-closure-type-mismatch.stderr @@ -1,18 +1,18 @@ error[E0308]: mismatched types - --> $DIR/issue-24036.rs:3:9 + --> $DIR/unique-closure-type-mismatch.rs:5:9 | LL | let mut x = |c| c + 1; | --- the expected closure LL | x = |c| c + 1; | ^^^^^^^^^ expected closure, found a different closure | - = note: expected closure `{closure@$DIR/issue-24036.rs:2:17: 2:20}` - found closure `{closure@$DIR/issue-24036.rs:3:9: 3:12}` + = note: expected closure `{closure@$DIR/unique-closure-type-mismatch.rs:4:17: 4:20}` + found closure `{closure@$DIR/unique-closure-type-mismatch.rs:5:9: 5:12}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object error[E0284]: type annotations needed - --> $DIR/issue-24036.rs:9:15 + --> $DIR/unique-closure-type-mismatch.rs:11:15 | LL | 1 => |c| c + 1, | ^ - type must be known at this point diff --git a/tests/ui/issues/issue-16560.rs b/tests/ui/issues/issue-16560.rs deleted file mode 100644 index d9a7aa9101d3f..0000000000000 --- a/tests/ui/issues/issue-16560.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -//@ needs-threads - -use std::thread; -use std::mem; - -fn main() { - let y = 0u8; - let closure = move |x: u8| y + x; - - // Check that both closures are capturing by value - assert_eq!(1, mem::size_of_val(&closure)); - - thread::spawn(move|| { - let ok = closure; - }).join().ok().unwrap(); -} diff --git a/tests/ui/issues/issue-16668.rs b/tests/ui/issues/issue-16668.rs deleted file mode 100644 index 2b2370b0e2b4c..0000000000000 --- a/tests/ui/issues/issue-16668.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ check-pass -#![allow(dead_code)] -struct Parser<'a, I, O> { - parse: Box Result + 'a> -} - -impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { - fn compose(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> { - Parser { - parse: Box::new(move |x: I| { - match (self.parse)(x) { - Ok(r) => (rhs.parse)(r), - Err(e) => Err(e) - } - }) - } - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-16671.rs b/tests/ui/issues/issue-16671.rs deleted file mode 100644 index f7f4f4348afab..0000000000000 --- a/tests/ui/issues/issue-16671.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass - -#![deny(warnings)] - -fn foo(_f: F) { } - -fn main() { - let mut var = Vec::new(); - foo(move|| { - var.push(1); - }); -} diff --git a/tests/ui/issues/issue-16994.rs b/tests/ui/issues/issue-16994.rs deleted file mode 100644 index fa3988e099945..0000000000000 --- a/tests/ui/issues/issue-16994.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ check-pass - -fn cb<'a,T>(_x: Box, bool))) -> T>) -> T { - panic!() -} - -fn main() { - cb(Box::new(|(k, &(ref v, b))| (*k, v.clone(), b))); -} diff --git a/tests/ui/issues/issue-17816.rs b/tests/ui/issues/issue-17816.rs deleted file mode 100644 index da28a14685f6c..0000000000000 --- a/tests/ui/issues/issue-17816.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -use std::marker::PhantomData; - -fn main() { - struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F, marker: PhantomData<&'a ()> } - let f = |x: Vec<&str>| -> &str { "foobar" }; - let sym = Symbol { function: f, marker: PhantomData }; - (sym.function)(vec![]); -} diff --git a/tests/ui/issues/issue-17897.rs b/tests/ui/issues/issue-17897.rs deleted file mode 100644 index dbb560a199bf7..0000000000000 --- a/tests/ui/issues/issue-17897.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -fn action(mut cb: Box usize>) -> usize { - cb(1) -} - -pub fn main() { - println!("num: {}", action(Box::new(move |u| u))); -} diff --git a/tests/ui/issues/issue-18188.rs b/tests/ui/issues/issue-18188.rs deleted file mode 100644 index b3b008229a53a..0000000000000 --- a/tests/ui/issues/issue-18188.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ check-pass - -pub trait Promisable: Send + Sync {} -impl Promisable for T {} - -pub fn propagate<'a, T, E, F, G>(mut action: F) - -> Box) -> Result + 'a> - where - T: Promisable + Clone + 'a, - E: Promisable + Clone + 'a, - F: FnMut(&T) -> Result + Send + 'a, - G: FnMut(Result) -> Result + 'a { - Box::new(move |result: Result| { - match result { - Ok(ref t) => action(t), - Err(ref e) => Err(e.clone()), - } - }) -} - -fn main() {} diff --git a/tests/ui/issues/issue-19127.rs b/tests/ui/issues/issue-19127.rs deleted file mode 100644 index 2172c631b841d..0000000000000 --- a/tests/ui/issues/issue-19127.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] - -fn foo T>(f: F) {} -fn id<'a>(input: &'a u8) -> &'a u8 { input } - -fn main() { - foo(id); -} diff --git a/tests/ui/issues/issue-20174.rs b/tests/ui/issues/issue-20174.rs deleted file mode 100644 index 7b49fe8c7b472..0000000000000 --- a/tests/ui/issues/issue-20174.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -struct GradFn usize>(F); - -fn main() { - let GradFn(x_squared) : GradFn<_> = GradFn(|| -> usize { 2 }); - let _ = x_squared(); -} diff --git a/tests/ui/issues/issue-20575.rs b/tests/ui/issues/issue-20575.rs deleted file mode 100644 index b213b79d37cab..0000000000000 --- a/tests/ui/issues/issue-20575.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -// Test that overloaded calls work with zero arity closures - - -fn main() { - let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; - - let _: Option> = functions.iter().map(|f| (*f)()).collect(); -} diff --git a/tests/ui/issues/issue-22346.rs b/tests/ui/issues/issue-22346.rs deleted file mode 100644 index 710dc0acda7e9..0000000000000 --- a/tests/ui/issues/issue-22346.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -// This used to cause an ICE because the retslot for the "return" had the wrong type -fn testcase<'a>() -> Box + 'a> { - return Box::new((0..3).map(|i| { return i; })); -} - -fn main() { -} diff --git a/tests/ui/issues/issue-23046.rs b/tests/ui/issues/issue-23046.rs deleted file mode 100644 index a68369616d8b6..0000000000000 --- a/tests/ui/issues/issue-23046.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub enum Expr<'var, VAR> { - Let(Box>, - Box Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) -} - -pub fn add<'var, VAR> - (a: Expr<'var, VAR>, b: Expr<'var, VAR>) -> Expr<'var, VAR> { - loop {} -} - -pub fn let_<'var, VAR, F: for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>> - (a: Expr<'var, VAR>, b: F) -> Expr<'var, VAR> { - loop {} -} - -fn main() { - let ex = |x| { //~ ERROR type annotations needed - let_(add(x,x), |y| { - let_(add(x, x), |x|x)})}; -} diff --git a/tests/ui/issues/issue-23046.stderr b/tests/ui/issues/issue-23046.stderr deleted file mode 100644 index f70ac0c9f388a..0000000000000 --- a/tests/ui/issues/issue-23046.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed for `Expr<'_, _>` - --> $DIR/issue-23046.rs:17:15 - | -LL | let ex = |x| { - | ^ - | -help: consider giving this closure parameter an explicit type, where the type for type parameter `VAR` is specified - | -LL | let ex = |x: Expr<'_, VAR>| { - | +++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0282`.