Skip to content

Commit 41bd06f

Browse files
committed
fix and test rust-lang#43475
1 parent c701ba6 commit 41bd06f

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/librustc/traits/select.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,21 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
14201420
-> bool
14211421
{
14221422
assert!(!skol_trait_ref.has_escaping_regions());
1423+
debug!("match_projection: obligation={:?}, trait_bound={:?}",
1424+
obligation, trait_bound);
1425+
1426+
let Normalized { value: normal_bound, obligations } =
1427+
project::normalize(
1428+
self, obligation.param_env.clone(), obligation.cause.clone(),
1429+
&trait_bound);
1430+
debug!("match_projection: \
1431+
obligation={:?}, normal_bound={:?}, \
1432+
additional inferred_obligations={:?}",
1433+
obligation, normal_bound, obligations);
1434+
self.inferred_obligations.extend(obligations);
1435+
14231436
match self.infcx.at(&obligation.cause, obligation.param_env)
1424-
.sup(ty::Binder(skol_trait_ref), trait_bound) {
1437+
.sup(ty::Binder(skol_trait_ref), normal_bound) {
14251438
Ok(InferOk { obligations, .. }) => {
14261439
self.inferred_obligations.extend(obligations);
14271440
}

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

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2014 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+
trait Foo {
12+
type FooT: Foo;
13+
}
14+
15+
impl Foo for () {
16+
type FooT = ();
17+
}
18+
19+
trait Bar<A: Foo> {
20+
type BarT: Bar<A::FooT>;
21+
}
22+
23+
impl Bar<()> for () {
24+
type BarT = ();
25+
}
26+
27+
fn test<C: Bar<()>>() {}
28+
29+
fn main() {
30+
test::<()>()
31+
}

0 commit comments

Comments
 (0)