blob: 5229979b46cf887717a20f7a4ab97a2476b753e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
namespace;
include rt;
// expect: r: used after it was given away; r borrows t, and t was freed on line 11 (t declared on line 8)
// a prototype's borrows clause ties the result to the first argument's owner only.
char* first(char* a, char* b) borrows a;
fn main() {
char* t = rt.new(4); t[0] = 'x'; t[1] = 0;
char* u = rt.new(4); u[0] = 'y'; u[1] = 0;
let r = first(t, u); rt.free(u); rt.put_c(r[0]);
rt.free(t); rt.put_c(r[0]);
return 0;
}
char* first(char* a, char* b) { return a; }
|