diff options
| author | kennytm <kennytm@gmail.com> | 2018-02-10 14:24:06 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-10 14:24:06 +0800 |
| commit | 3554c3ab6f8b4b0689618d585098554c0b855bdd (patch) | |
| tree | f027d0bcdca10e05f0ffa29ddc249127cbc4a24c | |
| parent | a580eefe5f92186d13dcf530891ca93ef3a9adf8 (diff) | |
| parent | 774997dab3c1a0a6e2ffa03d9d86c7048ec0481d (diff) | |
| download | rust-3554c3ab6f8b4b0689618d585098554c0b855bdd.tar.gz rust-3554c3ab6f8b4b0689618d585098554c0b855bdd.zip | |
Rollup merge of #48086 - Zoxc:gen-fix, r=nikomatsakis
Fix visitation order of calls so that it matches execution order. Fixes #48048 r? @nikomatsakis
| -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 + |
