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
structA<'self>{cur:&'self mutint}impl<'self>Iterator<&'self int>forA<'self>{fnnext(&mutself) -> Option<&'self int>{*self.cur += 1;returnSome(&*self.cur);}}fnmain(){letmut a = 3;letmut a = A{cur:&mut a };let b = a.next();println!("{:?}", b);let c = a.next();println!("{:?}", b);println!("{:?}", c);}
Runs with:
$ rustc foo.rs
warning: no debug symbols in executable (-arch x86_64)
$ ./foo
Some(&4)Some(&5)Some(&5)
I thought something like this should be a compiler error? It seems to me that the lifetime of b would conflict with attempting to re-borrow a as mut.
This code:
Runs with:
I thought something like this should be a compiler error? It seems to me that the lifetime of
b
would conflict with attempting to re-borrowa
asmut
.cc @nikomatsakis
@blake2-ppc discovered this in a bug in a test he wrote for #9062
The text was updated successfully, but these errors were encountered: