Skip to content

Incorrect fn subtyping with bound regions and 'static  #13974

Closed
@nikomatsakis

Description

@nikomatsakis

This test file incorrect returns a compilation error:

struct S;
type F = fn<'cx>(&'cx S) -> &'cx S;
fn foo(x: &S) -> &'static S { fail!() }
fn want_F(f: F) { }
pub fn main() {
    want_F(foo); // Incorrect error here
}

In particular, a fn like foo which always returns a pointer with 'static lifetime should be considered a subtype of a fn type that always returns pointer with same lifetime as its input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions