Skip to content

Commit 7bc3588

Browse files
committed
auto merge of #18729 : bkoropoff/rust/issue-18711, r=cmr
Closes #18711
2 parents c437fcf + 5f6392d commit 7bc3588

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

src/librustc/middle/trans/closure.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,9 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
489489
closure_id,
490490
&bcx.fcx.param_substs.substs).unwrap();
491491

492-
let unboxed_closures = bcx.tcx().unboxed_closures.borrow();
493-
let function_type = (*unboxed_closures)[closure_id]
494-
.closure_type
495-
.clone();
492+
let function_type = (*bcx.tcx().unboxed_closures.borrow())[closure_id]
493+
.closure_type
494+
.clone();
496495
let function_type = ty::mk_closure(bcx.tcx(), function_type);
497496

498497
let freevars: Vec<ty::Freevar> =

src/test/auxiliary/issue-18711.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 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(unboxed_closures, overloaded_calls)]
12+
#![crate_type = "rlib"]
13+
14+
pub fn inner<F>(f: F) -> F {
15+
(move |:| f)()
16+
}

src/test/run-pass/issue-18711.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 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+
// Test that we don't panic on a RefCell borrow conflict in certain
12+
// code paths involving unboxed closures.
13+
14+
#![feature(unboxed_closures, overloaded_calls)]
15+
16+
// aux-build:issue-18711.rs
17+
extern crate "issue-18711" as issue;
18+
19+
fn main() {
20+
(|:| issue::inner(()))();
21+
}

0 commit comments

Comments
 (0)