diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-02-09 09:48:54 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-02-09 10:49:24 +0100 |
| commit | 774997dab3c1a0a6e2ffa03d9d86c7048ec0481d (patch) | |
| tree | d0dd0f880c41d2120b15a13d2571014498068074 | |
| parent | fee39ba8bd98f5b93c60de51336830fa7f0b9d97 (diff) | |
| download | rust-774997dab3c1a0a6e2ffa03d9d86c7048ec0481d.tar.gz rust-774997dab3c1a0a6e2ffa03d9d86c7048ec0481d.zip | |
Fix visitation order of calls so that it matches execution order. Fixes #48048
| -rw-r--r-- | src/librustc/hir/intravisit.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/generator/issue-48048.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/generator/issue-48048.stderr | 10 |
3 files changed, 34 insertions, 1 deletions
diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 97cf9b01410..b804cf7bf5a 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -965,8 +965,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { walk_list!(visitor, visit_expr, subexpressions); } ExprCall(ref callee_expression, ref arguments) => { + visitor.visit_expr(callee_expression); walk_list!(visitor, visit_expr, arguments); - visitor.visit_expr(callee_expression) } ExprMethodCall(ref segment, _, ref arguments) => { visitor.visit_path_segment(expression.span, segment); diff --git a/src/test/ui/generator/issue-48048.rs b/src/test/ui/generator/issue-48048.rs new file mode 100644 index 00000000000..89739bd591c --- /dev/null +++ b/src/test/ui/generator/issue-48048.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators)] + +fn main() { + let x = (|_| {},); + + || { + let x = x; + + x.0({ //~ ERROR borrow may still be in use when generator yields + yield; + }); + }; +} diff --git a/src/test/ui/generator/issue-48048.stderr b/src/test/ui/generator/issue-48048.stderr new file mode 100644 index 00000000000..fd1667128ab --- /dev/null +++ b/src/test/ui/generator/issue-48048.stderr @@ -0,0 +1,10 @@ +error[E0626]: borrow may still be in use when generator yields + --> $DIR/issue-48048.rs:19:9 + | +19 | x.0({ //~ ERROR borrow may still be in use when generator yields + | ^^^ +20 | yield; + | ----- possible yield occurs here + +error: aborting due to previous error + |
