]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/regions-fn-subtyping-return-static-fail.rs
1 // In this fn, the type `F` is a function that takes a reference to a
2 // struct and returns another reference with the same lifetime.
4 // Meanwhile, the bare fn `foo` takes a reference to a struct with
5 // *ANY* lifetime and returns a reference with the 'static lifetime.
6 // This can safely be considered to be an instance of `F` because all
7 // lifetimes are sublifetimes of 'static.
10 #![allow(unused_variables)]
14 // Given 'cx, return 'cx
15 type F
= for<'cx
> fn(&'cx S
) -> &'cx S
;
18 // Given anything, return 'static
19 type G
= for<'cx
> fn(&'cx S
) -> &'
static S
;
23 fn foo(x
: &S
) -> &'
static S
{
28 fn bar
<'a
, 'b
>(x
: &'a S
) -> &'b S
{
32 // Meets F, but not G.
48 want_G(baz
); //~ ERROR mismatched types