mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-27 07:03:45 +00:00
resolve type vars with obligations in more places
This fixes a few cases of inference misses, some of them regressions caused by the impl selected for a method not being immediately evaluated.
This commit is contained in:
parent
de0e695f62
commit
15f6540ec0
@ -2818,6 +2818,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
formal_ret: Ty<'tcx>,
|
||||
formal_args: &[Ty<'tcx>])
|
||||
-> Vec<Ty<'tcx>> {
|
||||
let formal_ret = self.resolve_type_vars_with_obligations(formal_ret);
|
||||
let expected_args = expected_ret.only_has_type(self).and_then(|ret_ty| {
|
||||
self.fudge_regions_if_ok(&RegionVariableOrigin::Coercion(call_span), || {
|
||||
// Attempt to apply a subtyping relationship between the formal
|
||||
@ -3978,6 +3979,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
hir::ExprTup(ref elts) => {
|
||||
let flds = expected.only_has_type(self).and_then(|ty| {
|
||||
let ty = self.resolve_type_vars_with_obligations(ty);
|
||||
match ty.sty {
|
||||
ty::TyTuple(ref flds, _) => Some(&flds[..]),
|
||||
_ => None
|
||||
|
@ -0,0 +1,37 @@
|
||||
// Copyright 2017 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.
|
||||
|
||||
pub struct ClientMap;
|
||||
pub struct ClientMap2;
|
||||
|
||||
pub trait Service {
|
||||
type Request;
|
||||
fn call(&self, _req: Self::Request);
|
||||
}
|
||||
|
||||
pub struct S<T>(T);
|
||||
|
||||
impl Service for ClientMap {
|
||||
type Request = S<Box<Fn(i32)>>;
|
||||
fn call(&self, _req: Self::Request) {}
|
||||
}
|
||||
|
||||
|
||||
impl Service for ClientMap2 {
|
||||
type Request = (Box<Fn(i32)>,);
|
||||
fn call(&self, _req: Self::Request) {}
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
ClientMap.call(S { 0: Box::new(|_msgid| ()) });
|
||||
ClientMap.call(S(Box::new(|_msgid| ())));
|
||||
ClientMap2.call((Box::new(|_msgid| ()),));
|
||||
}
|
Loading…
Reference in New Issue
Block a user