2014-12-14 07:17:23 -05:00
|
|
|
// Test a case where you have an impl of `Foo<X>` for all `X` that
|
|
|
|
// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730.
|
|
|
|
|
|
|
|
trait Foo<X> {
|
|
|
|
fn foo(&self, x: X) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn want_hrtb<T>()
|
2014-12-05 18:12:25 -08:00
|
|
|
where T : for<'a> Foo<&'a isize>
|
2014-12-14 07:17:23 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-05 18:12:25 -08:00
|
|
|
// AnyInt implements Foo<&'a isize> for any 'a, so it is a match.
|
2014-12-14 07:17:23 -05:00
|
|
|
struct AnyInt;
|
2014-12-05 18:12:25 -08:00
|
|
|
impl<'a> Foo<&'a isize> for AnyInt { }
|
2014-12-14 07:17:23 -05:00
|
|
|
fn give_any() {
|
|
|
|
want_hrtb::<AnyInt>()
|
|
|
|
}
|
|
|
|
|
2014-12-05 18:12:25 -08:00
|
|
|
// StaticInt only implements Foo<&'static isize>, so it is an error.
|
2014-12-14 07:17:23 -05:00
|
|
|
struct StaticInt;
|
2014-12-05 18:12:25 -08:00
|
|
|
impl Foo<&'static isize> for StaticInt { }
|
2014-12-14 07:17:23 -05:00
|
|
|
fn give_static() {
|
2016-04-05 22:56:23 +03:00
|
|
|
want_hrtb::<StaticInt>() //~ ERROR `for<'a> StaticInt: Foo<&'a isize>` is not satisfied
|
2014-12-14 07:17:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|