Closed
Description
Reproduction:
use std::marker::PhantomData;
use chalk_ir::interner::{HasInterner, Interner};
use chalk_derive::HasInterner;
#[derive(HasInterner)]
struct WithInterner<I: Interner> {
_phantom: PhantomData<I>,
}
fn test<I: Interner>(i: I) {
let x: <WithInterner<I> as HasInterner>::Interner = i;
}
With chalk_ir
and chalk_derive
dependencies. x
should be type I
, which works if I write the HasInterner
impl by hand, but not in the above code.
It turns out that the synstructure
derive macro expands to an impl in a named constant:
#[allow(non_upper_case_globals)]
#[doc(hidden)]
const _DERIVE_chalk_ir_interner_HasInterner_FOR_WithInterner: () = {
impl<I: Interner> ::chalk_ir::interner::HasInterner for WithInterner<I> {
type Interner = I;
}
};
Which we don't support. Maybe we can change synstructure to use unnamed consts, or build a hack to treat _DERIVE
consts like unnamed ones 😬