Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
trait Bar { }
trait Baz { }
// Implemented(Self: Baz) :- FromEnv(Self: Baz).
trait Foo {
type Item<T>: Baz where T: Bar;
}
// (*) FromEnv(<Self as Foo>::Item<T>: Baz) :- FromEnv(Self: Foo), FromEnv(T: Bar).
struct AlwaysBar<T> { }
impl<T> Bar for AlwaysBar<T> { }
fn baz<X: Baz>() { }
fn foo<X: Foo, T>() // where AlwaysBar<T>: Bar
{
// We must prove: `Implemented(<X as Foo>::Item<AlwaysBar<T>>: Baz)`.
// The only way to prove it is to use the rule (*).
// This requires `FromEnv(Always<T>: Bar)`, which we don't have in our env.
baz::<X::Item<AlwaysBar<T>>>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.