about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-17 18:56:35 +0000
committerbors <bors@rust-lang.org>2014-06-17 18:56:35 +0000
commit2fd618e77accd37426819952ad443e50bb3c9015 (patch)
treeaf98ffa51c454d9f63b7ac23e25ce87cbc3ae063
parentdb298145c702c49e5f3cc17adeafe58c8b1bbd6a (diff)
parent8827395a3a830a421409ba995991bfd5bce38c1e (diff)
downloadrust-2fd618e77accd37426819952ad443e50bb3c9015.tar.gz
rust-2fd618e77accd37426819952ad443e50bb3c9015.zip
auto merge of #14976 : luqmana/rust/focwtc, r=pcwalton
Fixes #14959.
-rw-r--r--src/librustc/middle/typeck/check/regionck.rs5
-rw-r--r--src/test/run-pass/issue-14959.rs48
2 files changed, 52 insertions, 1 deletions
diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs
index 93ab492eb3a..e8d507c8b4a 100644
--- a/src/librustc/middle/typeck/check/regionck.rs
+++ b/src/librustc/middle/typeck/check/regionck.rs
@@ -443,7 +443,10 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
 
     match expr.node {
         ast::ExprCall(ref callee, ref args) => {
-            if !has_method_map {
+            if has_method_map {
+                constrain_call(rcx, None, expr, Some(*callee),
+                               args.as_slice(), false);
+            } else {
                 constrain_callee(rcx, callee.id, expr, &**callee);
                 constrain_call(rcx,
                                Some(callee.id),
diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs
new file mode 100644
index 00000000000..7fbb0657c70
--- /dev/null
+++ b/src/test/run-pass/issue-14959.rs
@@ -0,0 +1,48 @@
+// 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(overloaded_calls)]
+
+use std::ops::Fn;
+
+trait Response {}
+trait Request {}
+trait Ingot<R, S> {
+    fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status;
+}
+
+#[allow(dead_code)]
+struct HelloWorld;
+
+struct SendFile<'a>;
+struct Alloy;
+enum Status {
+    Continue
+}
+
+impl Alloy {
+    fn find<T>(&self) -> Option<T> {
+        None
+    }
+}
+
+impl<'a, 'b> Fn<(&'b mut Response,),()> for SendFile<'a> {
+    fn call(&self, (_res,): (&'b mut Response,)) {}
+}
+
+impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld {
+    fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status {
+        let send_file = alloy.find::<SendFile>().unwrap();
+        send_file(res);
+        Continue
+    }
+}
+
+fn main() {}