diff options
Diffstat (limited to 'tests/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs')
-rw-r--r-- | tests/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs b/tests/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs new file mode 100644 index 000000000..00100e0e9 --- /dev/null +++ b/tests/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs @@ -0,0 +1,19 @@ +// Test that the compiler checks that the 'static bound declared in +// the trait must be satisfied on the impl. Issue #20890. + +trait Foo { + type Value: 'static; + fn dummy(&self) {} +} + +impl<'a> Foo for &'a i32 { + type Value = &'a i32; + //~^ ERROR the type `&'a i32` does not fulfill the required lifetime +} + +impl<'a> Foo for i32 { + // OK. + type Value = i32; +} + +fn main() {} |