diff --git a/tests/ui/traits/next-solver/closure-capture-in-loop-120328.rs b/tests/ui/traits/next-solver/closure-capture-in-loop-120328.rs new file mode 100644 index 0000000000000..7a310063984cd --- /dev/null +++ b/tests/ui/traits/next-solver/closure-capture-in-loop-120328.rs @@ -0,0 +1,13 @@ +//@ compile-flags: -Znext-solver +//@ edition: 2021 +//@ check-pass + +// Regression test for . +// Closures capturing an iterated variable in edition 2021 used to ICE +// with the next trait solver during MIR building. + +fn main() { + for item in &[1, 2, 3] { + let _ = || *item; + } +}