You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubstructS<'a>(&'aint);impl<'a>PartialEqforS<'a>{fneq(&self,b:&S<'a>) -> bool{true}}fnmain(){let i = 1;let a = S(&i);{let j = 0;let b = S(&j);(a == b);}}
a.rs:15:20: 15:21 error: `j` does not live long enough
a.rs:15 let b = S(&j);
^
a.rs:9:11: 19:2 note: reference must be valid for the block at 9:10...
a.rs:9 fn main() {
a.rs:10 let i = 1;
a.rs:11 let a = S(&i);
a.rs:12
a.rs:13 {
a.rs:14 let j = 0;
...
a.rs:13:5: 18:6 note: ...but borrowed value is only valid for the block at 13:4
a.rs:13 {
a.rs:14 let j = 0;
a.rs:15 let b = S(&j);
a.rs:16
a.rs:17 (a == b);
a.rs:18 }
a == b causes error but b == a or a.eq(&b) don't. Same for a < b.
The text was updated successfully, but these errors were encountered:
Introducing another type variable to allow for the lifetimes to be inexact would help, and would presumably also eliminate the need for the "reborrow" that we do.
a == b
causes error butb == a
ora.eq(&b)
don't. Same fora < b
.The text was updated successfully, but these errors were encountered: