mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
rollup merge of #19889: FlaPer87/unboxed-closure
The fix just checks if the bound is `Copy` and returns an `Err` if so. Closes: #19817 @nikomatsakis r?
This commit is contained in:
commit
56fb9bc7ac
@ -1209,6 +1209,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// is reserve judgement and then intertwine this
|
||||
// analysis with closure inference.
|
||||
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
|
||||
|
||||
// Unboxed closures shouldn't be
|
||||
// implicitly copyable
|
||||
if bound == ty::BoundCopy {
|
||||
return Ok(ParameterBuiltin);
|
||||
}
|
||||
|
||||
match self.tcx().freevars.borrow().get(&def_id.node) {
|
||||
None => {
|
||||
// No upvars.
|
||||
|
@ -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.
|
||||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
fn main() {
|
||||
let f = move|:| ();
|
||||
f();
|
||||
f(); //~ ERROR use of moved value
|
||||
}
|
Loading…
Reference in New Issue
Block a user