Closed
Description
The following example try to compare two pointers:
fn do_cmp(a: &int, b: &int) {
io::println("do_cmp");
if a == b { io::println("same ref"); }
}
fn main() {
let a = @10;
let b = @10;
do_cmp(a, b);
do_cmp(a, a);
}
We have the following message:
try.rs:3:12: 3:13 error: mismatched types: expected &int
but found &int
(the anonymous lifetime #2 defined on the block at 1:28 does not necessarily outlive the anonymous lifetime #1 defined on the block at 1:28)
try.rs:3 if a == b { io::println("same ref"); }
^
error: aborting due to previous error
I think that it should compile. I think it should also compile if we have this prototype:
fn do_cmp(a: &int, b: @int)