rollup merge of #17984 : bkoropoff/issue-17651

This commit is contained in:
Alex Crichton 2014-10-13 15:09:56 -07:00
commit 02350ac20b
2 changed files with 24 additions and 4 deletions

View File

@ -32,13 +32,16 @@ struct RvalueContext<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
fn visit_fn(&mut self,
_: visit::FnKind<'v>,
fk: visit::FnKind<'v>,
fd: &'v ast::FnDecl,
b: &'v ast::Block,
_: Span,
s: Span,
_: ast::NodeId) {
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
euv.walk_fn(fd, b);
{
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
euv.walk_fn(fd, b);
}
visit::walk_fn(self, fk, fd, b, s)
}
}

View File

@ -0,0 +1,17 @@
// Copyright 2014 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.
// Test that moves of unsized values within closures are caught
// and rejected.
fn main() {
(|| box *[0u].as_slice())();
//~^ ERROR cannot move a value of type [uint]
}