rust/tests/ui/associated-types/issue-64848.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
408 B
Rust
Raw Normal View History

2020-01-14 23:34:20 +00:00
//@ build-pass
trait AssociatedConstant {
const DATA: ();
}
impl<F, T> AssociatedConstant for F
where
F: FnOnce() -> T,
T: AssociatedConstant,
{
const DATA: () = T::DATA;
}
impl AssociatedConstant for () {
const DATA: () = ();
}
fn foo() -> impl AssociatedConstant {
()
}
fn get_data<T: AssociatedConstant>(_: T) -> &'static () {
&T::DATA
}
fn main() {
get_data(foo);
}