Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1635,14 +1635,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let raw_ty = self.expr_ty(expr);
let raw_ty = self.infcx().shallow_resolve(raw_ty);
let resolve_ty = |&: ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
ty::adjust_ty(self.tcx(),
expr.span,
expr.id,
raw_ty,
adjustment,
|method_call| self.inh.method_map.borrow()
.get(&method_call)
.map(|method| method.ty))
.map(|method| resolve_ty(method.ty)))
}

pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
Expand Down
7 changes: 1 addition & 6 deletions src/librustc_typeck/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,8 @@ impl<'a,'tcx> SeedBorrowKind<'a,'tcx> {
capture_clause: ast::CaptureClause,
_body: &ast::Block)
{
let is_old_skool_closure = match self.fcx.expr_ty(expr).sty {
_ => false,
};

match capture_clause {
ast::CaptureByValue if !is_old_skool_closure => {
}
ast::CaptureByValue => {}
_ => {
ty::with_freevars(self.tcx(), expr.id, |freevars| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, yay for cleanup.

for freevar in freevars.iter() {
Expand Down
17 changes: 17 additions & 0 deletions src/test/run-pass/issue-21306.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2015 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.

use std::sync::Arc;

fn main() {
let x = 5us;
let command = Arc::new(Box::new(|&:| { x*2 }));
assert_eq!(command(), 10);
}