diff --git a/tests/ui/impl-trait/associated-impl-trait-type-into-emplacable.rs b/tests/ui/impl-trait/associated-impl-trait-type-into-emplacable.rs new file mode 100644 index 000000000000..2c63b2743a0c --- /dev/null +++ b/tests/ui/impl-trait/associated-impl-trait-type-into-emplacable.rs @@ -0,0 +1,52 @@ +//! add regression test for . + +//@ check-pass + +#![feature(impl_trait_in_assoc_type)] + +use std::marker::PhantomData; + +struct Emp { + phantom: PhantomData<(*const T, F)>, +} + +impl Emp { + fn from_fn(_: F) -> Emp { + loop {} + } + + fn unsize(self) -> Emp { + Emp::from_fn(|| ()) + } +} + +trait IntoEmplacable { + type Closure; + + fn into_emplacable(self) -> Emp; +} + +impl IntoEmplacable for Emp { + type Closure = impl Sized; + + fn into_emplacable(self) -> Emp { + self.unsize() + } +} + +impl Into as IntoEmplacable>::Closure>> for Emp { + fn into(self) -> Emp as IntoEmplacable>::Closure> { + self.into_emplacable() + } +} + +fn box_new_with(_: Emp) {} + +pub struct Arr; +pub struct Slice; + +pub fn foo() { + let e: Emp = Emp { phantom: PhantomData }; + box_new_with(e.into()); +} +fn main() {}