Skip to content

Commit e41c331

Browse files
committed
Fix type inference for proc expressions
1 parent 6c672ee commit e41c331

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/librustc/middle/typeck/check/mod.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -2247,8 +2247,19 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
22472247
}
22482248
_ => {
22492249
// Not an error! Means we're inferring the closure type
2250-
(None, ast::impure_fn, ast::BorrowedSigil,
2251-
ast::Many, ty::EmptyBuiltinBounds())
2250+
let mut sigil = ast::BorrowedSigil;
2251+
let mut onceness = ast::Many;
2252+
let mut bounds = ty::EmptyBuiltinBounds();
2253+
match expr.node {
2254+
ast::ExprProc(..) => {
2255+
sigil = ast::OwnedSigil;
2256+
onceness = ast::Once;
2257+
bounds.add(ty::BoundSend);
2258+
}
2259+
_ => ()
2260+
}
2261+
(None, ast::impure_fn, sigil,
2262+
onceness, bounds)
22522263
}
22532264
}
22542265
};

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

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 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+
fn f(p: proc()) {
12+
p();
13+
}
14+
15+
pub fn main() {
16+
let p = proc() ();
17+
f(p);
18+
}

0 commit comments

Comments
 (0)