-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.17.0 regression: loop mutable vs immutable alias. #41599
Comments
Reduced test case: fn parse<'b>(_r: *mut [&'b u8], _b: &'b u8) {}
fn main() {
let mut buf = 0u8;
let mut headers = [];
loop {
{&mut buf;}
parse(&mut headers, &buf);
}
} Changing the type of |
Where is the |
cc @rust-lang/compiler |
Looks like it could be related to #40319 |
Yupp! This is #40319, which fixed the slice case - it had accidentally been allowed before. |
Pretty sure it is that - this compiles and runs on rust 1.16, and is clearly unsound fn parse<'b>(r: &mut [&'b u8], b: &'b u8) {
r[0] = b;
}
fn main() {
let mut buf = 0u8;
let mut headers = [&0];
parse(&mut headers, &buf);
let immutable: [&u8; 1] = headers;
assert_eq!(*immutable[0], 0);
buf = 1;
assert_eq!(*immutable[0], 1);
} |
What's with the |
Sorry. Just a typo. Anyway, I don't get it. |
@dpc Well, the bug was found by a user of |
Oh, so the lifetime |
So I guess all is well. Closing. :) |
https://github.com/dpc/mioco/blob/0a12aae802256468f30a43cde2689e8846176914/examples/http-server.rs#L47
This code compiles on 1.16.0, but errors on 1.17.0:
Reproduced and confirmed by another person on
#rust
. I'm working on minimizing, but since it's late, I might not be able to deliver today.The text was updated successfully, but these errors were encountered: