1 // To avoid leaking the names of local bindings from expressions like for loops, #60984
2 // explicitly ignored them, but an assertion that `LocalKind::Var` *must* have a name would
3 // trigger an ICE. Before this change, this file's output would be:
5 // error[E0515]: cannot return value referencing local variable `__next`
6 // --> return-local-binding-from-desugaring.rs:LL:CC
8 // LL | for ref x in xs {
9 // | ----- `__next` is borrowed here
12 // | ^^^^^^ returns a value referencing data owned by the current function
14 // FIXME: ideally `LocalKind` would carry more information to more accurately explain the problem.
16 use std::collections::HashMap;
19 fn group_by<I, F, T>(xs: &mut I, f: F) -> HashMap<T, Vec<&I::Item>>
25 let mut result = HashMap::new();
28 result.entry(key).or_insert(Vec::new()).push(x);
30 result //~ ERROR cannot return value referencing temporary value