v3 isn’t borrowing from v1, it’s borrowing from v2. v4 is borrowing from v1. No conflict.
borrow_from_global's signature says it’s returning a borrow from self because it’s using the lifetime parameter of self in the output. The fact the body of the fn is using a global is an implementation detail (and allowed due to variance/subtyping).
The first doesn’t store the return value into anything, so the borrow of self (starts and) ends at that line.
Can I conclude that after such a function call, all its input parameters which have the same lifetime specifier as its return type has (including subtypes) are regarded as borrowed? not related to whatever is returned?
e.g. Afterlet result = foo(&mut v1, &mut v2, &mut v3); , beforeresult dies, no matter what result is:
For sig fn foo<'a, 'b, T>(a1: &'a mut T, a2: &'a mut T, b1: &'b mut T) -> &'a T : We can’t borrow v1, v2.
For sig fn foo<'a, 'b, T>(a1: &'a mut T, a2: &'a mut T, b1: &'b mut T) -> &'b T : We can’t borrow v3.
For sig fn foo<'a, 'b: 'd, 'c: 'd, 'd, T>(a1: &'a mut T, b1: &'b mut T, c1: &'c mut T) -> &'d T : We can’t borrow v2, v3.
Yes. Note that this form has same semantics as the first one, except applied to v2, v3 instead of v1, v2. If you associate the same lifetime parameter with b1, c1 in this example, the compiler finds the intersection for you so you don’t need to spell out the outlives relationships with respect to your own d lifetime parameter.