Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/ui/impl-trait/associated-impl-trait-type-into-emplacable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//! add regression test for <https://github.com/rust-lang/rust/issues/146514>.

//@ check-pass

#![feature(impl_trait_in_assoc_type)]

use std::marker::PhantomData;

struct Emp<T, F> {
phantom: PhantomData<(*const T, F)>,
}

impl<T, F> Emp<T, F> {
fn from_fn(_: F) -> Emp<T, F> {
loop {}
}

fn unsize(self) -> Emp<Slice, impl Sized> {
Emp::from_fn(|| ())
}
}

trait IntoEmplacable {
type Closure;

fn into_emplacable(self) -> Emp<Slice, Self::Closure>;
}

impl<F> IntoEmplacable for Emp<Arr, F> {
type Closure = impl Sized;

fn into_emplacable(self) -> Emp<Slice, Self::Closure> {
self.unsize()
}
}

impl<F> Into<Emp<Slice, <Emp<Arr, F> as IntoEmplacable>::Closure>> for Emp<Arr, F> {
fn into(self) -> Emp<Slice, <Emp<Arr, F> as IntoEmplacable>::Closure> {
self.into_emplacable()
}
}

fn box_new_with(_: Emp<Slice, impl Sized>) {}

pub struct Arr;
pub struct Slice;

pub fn foo() {
let e: Emp<Arr, ()> = Emp { phantom: PhantomData };
box_new_with(e.into());
}
fn main() {}
Loading