nikomatsakis / borrowck

Modeling NLL and the Rust borrowck
Apache License 2.0
75 stars 12 forks source link

add function prototypes #6

Open nikomatsakis opened 7 years ago

nikomatsakis commented 7 years ago

Currently the IR includes only "use" statements, which are meant to model opaque functions. It'd be nice to replace those with function prototypes. You would give a signature like:

fn foo<...>(T1..Tn) -> Tr;

then you would write:

x = foo<..>(y, z);

and we would instantiate the function signature, add the constraints that all of the types/regions must outlive this point, and create the relevant subtyping relations, all in one step.

One can still model the existing a = use(b) by something like:

fn opaque<A,B>(B) -> A

which would permit

a = opaque<TA, TB>(b)

where TA is the type of a and TB is the type of B.