Fix associated existentials for generic traits
This commit is contained in:
parent
9130efdad3
commit
93974cb09e
|
@ -1517,7 +1517,8 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
|
|||
}
|
||||
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
|
||||
let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind {
|
||||
tcx.mk_anon(assoc_ty.item.def_id, substs)
|
||||
let item_substs = Substs::identity_for_item(tcx, assoc_ty.item.def_id);
|
||||
tcx.mk_anon(assoc_ty.item.def_id, item_substs)
|
||||
} else {
|
||||
tcx.type_of(assoc_ty.item.def_id)
|
||||
};
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2018 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(existential_type)]
|
||||
// compile-pass
|
||||
|
||||
trait Bar {}
|
||||
struct Dummy<U>(U);
|
||||
impl<V> Bar for Dummy<V> {}
|
||||
|
||||
trait Foo<T> {
|
||||
type Assoc: Bar;
|
||||
fn foo(t: T) -> Self::Assoc;
|
||||
}
|
||||
|
||||
impl<W> Foo<W> for i32 {
|
||||
existential type Assoc: Bar;
|
||||
fn foo(w: W) -> Self::Assoc {
|
||||
Dummy(w)
|
||||
}
|
||||
}
|
||||
|
||||
struct NonGeneric;
|
||||
impl Bar for NonGeneric {}
|
||||
|
||||
impl<W> Foo<W> for u32 {
|
||||
existential type Assoc: Bar;
|
||||
fn foo(_: W) -> Self::Assoc {
|
||||
NonGeneric
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue