Skip to content

Commit 4ed1ba6

Browse files
authored
Rollup merge of rust-lang#48086 - Zoxc:gen-fix, r=nikomatsakis
Fix visitation order of calls so that it matches execution order. Fixes rust-lang#48048 r? @nikomatsakis
2 parents 1ef535e + 774997d commit 4ed1ba6

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/librustc/hir/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
965965
walk_list!(visitor, visit_expr, subexpressions);
966966
}
967967
ExprCall(ref callee_expression, ref arguments) => {
968+
visitor.visit_expr(callee_expression);
968969
walk_list!(visitor, visit_expr, arguments);
969-
visitor.visit_expr(callee_expression)
970970
}
971971
ExprMethodCall(ref segment, _, ref arguments) => {
972972
visitor.visit_path_segment(expression.span, segment);

src/test/ui/generator/issue-48048.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(generators)]
12+
13+
fn main() {
14+
let x = (|_| {},);
15+
16+
|| {
17+
let x = x;
18+
19+
x.0({ //~ ERROR borrow may still be in use when generator yields
20+
yield;
21+
});
22+
};
23+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error[E0626]: borrow may still be in use when generator yields
2+
--> $DIR/issue-48048.rs:19:9
3+
|
4+
19 | x.0({ //~ ERROR borrow may still be in use when generator yields
5+
| ^^^
6+
20 | yield;
7+
| ----- possible yield occurs here
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)