Skip to content

Commit 01ba0e3

Browse files
committed
review comments
1 parent b523b2d commit 01ba0e3

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

Diff for: src/test/ui/borrowck/issue-63026.rs

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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:
4+
// ```
5+
// error[E0515]: cannot return value referencing local variable `__next`
6+
// --> return-local-binding-from-desugaring.rs:LL:CC
7+
// |
8+
// LL | for ref x in xs {
9+
// | ----- `__next` is borrowed here
10+
// ...
11+
// LL | result
12+
// | ^^^^^^ returns a value referencing data owned by the current function
13+
// ```
14+
// FIXME: ideally `LocalKind` would carry more information to more accurately explain the problem.
15+
16+
use std::collections::HashMap;
17+
use std::hash::Hash;
18+
19+
fn group_by<I, F, T>(xs: &mut I, f: F) -> HashMap<T, Vec<&I::Item>>
20+
where
21+
I: Iterator,
22+
F: Fn(&I::Item) -> T,
23+
T: Eq + Hash,
24+
{
25+
let mut result = HashMap::new();
26+
for ref x in xs {
27+
let key = f(x);
28+
result.entry(key).or_insert(Vec::new()).push(x);
29+
}
30+
result //~ ERROR cannot return value referencing local binding
31+
}
32+
33+
fn main() {}

Diff for: src/test/ui/borrowck/issue-63026.stderr renamed to src/test/ui/borrowck/return-local-binding-from-desugaring.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0515]: cannot return value referencing local binding
2-
--> $DIR/issue-63026.rs:15:5
2+
--> $DIR/return-local-binding-from-desugaring.rs:30:5
33
|
44
LL | for ref x in xs {
55
| -- local binding introduced here

0 commit comments

Comments
 (0)