Open
Description
Summary
.
Reproducer
I tried this code:
// Test various stacked-borrows-related things.
const fn main() {}
pub const fn read_does_not_invalidate2() {
fn _foo(x: &mut (i32, i32)) -> &i32 {
let xraw = x as *mut (i32, i32);
let ret = unsafe { &(*xraw).1 };
ret
}
}
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected expression, found `as`
--> src/main.rs:8:31
|
8 | unsafe { &(*xraw).1 } as _
| ^^ expected expression
|
help: parentheses are required to parse this as an expression
|
8 | (unsafe { &(*xraw).1 }) as _
| + +
error: aborting due to previous error
Original diagnostics will follow.
warning: returning the result of a `let` binding from a block
--> src/main.rs:8:9
|
7 | let ret = unsafe { &(*xraw).1 };
| -------------------------------- unnecessary `let` binding
8 | ret
| ^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
= note: `-W clippy::let-and-return` implied by `-W clippy::all`
help: return the expression directly
|
7 ~
8 ~ unsafe { &(*xraw).1 } as _
|
Version
rustc 1.67.0-nightly (1eb62b123 2022-11-27)
binary: rustc
commit-hash: 1eb62b1235fd77200e6bd967d70e83c0f2497233
commit-date: 2022-11-27
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4
Additional Labels
No response