Skip to content

Commit 89574a6

Browse files
committed
resolve type variables in the custom type op pathway
1 parent 1ca467d commit 89574a6

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/librustc/traits/query/type_op/custom.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ fn scrape_region_constraints<'gcx, 'tcx, R>(
106106
infcx.tcx,
107107
region_obligations
108108
.iter()
109-
.map(|(_, r_o)| (r_o.sup_type, r_o.sub_region)),
109+
.map(|(_, r_o)| (r_o.sup_type, r_o.sub_region))
110+
.map(|(ty, r)| (infcx.resolve_type_vars_if_possible(&ty), r)),
110111
&region_constraint_data,
111112
);
112113

src/test/ui/issue-53568.rs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2018 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+
// Regression test for an NLL-related ICE (#53568) -- we failed to
12+
// resolve inference variables in "custom type-ops".
13+
//
14+
// compile-pass
15+
16+
#![feature(nll)]
17+
#![allow(dead_code)]
18+
19+
trait Future {
20+
type Item;
21+
}
22+
23+
impl<F, T> Future for F
24+
where F: Fn() -> T
25+
{
26+
type Item = T;
27+
}
28+
29+
trait Connect {}
30+
31+
struct Connector<H> {
32+
handler: H,
33+
}
34+
35+
impl<H, T> Connect for Connector<H>
36+
where
37+
T: 'static,
38+
H: Future<Item = T>
39+
{
40+
}
41+
42+
struct Client<C> {
43+
connector: C,
44+
}
45+
46+
fn build<C>(_connector: C) -> Client<C> {
47+
unimplemented!()
48+
}
49+
50+
fn client<H>(handler: H) -> Client<impl Connect>
51+
where H: Fn() + Copy
52+
{
53+
let connector = Connector {
54+
handler,
55+
};
56+
let client = build(connector);
57+
client
58+
}
59+
60+
fn main() { }
61+

0 commit comments

Comments
 (0)