-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
moves from unsafe ptrs / initializers #2610
Comments
Obsolete since we don't have |
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Jun 3, 2021
fix `needless_borrow` suggestion fixes: rust-lang#2610 While I'm working on this, should needless_borrow be split into two? One lint for expressions and another for patterns. In expression it only lints when the compiler inserts a dereference, but for patterns it's whenever a double reference is created. I think at least the case where a double reference is needed should be split into a new lint as it's not 'needless', it can just be done without a ref binding. For illustration: ```rust fn foo(x: &&str) {} match Some("test") { // ref binding is useless here Some(ref x) => *x, _ => (), } match Some("test") { // ref binding is useless here Some(ref x) => x.len(), _ => (), } match Some("test") { // double reference is needed, but could be `Some(x) => foo(&x)` Some(ref x) => foo(x), _ => (), } ``` changelog: Improve the suggestion for `needless_borrow` in patterns to change all usage sites as needed. changelog: Add lint `ref_binding_to_reference`
RalfJung
pushed a commit
to RalfJung/rust
that referenced
this issue
Oct 22, 2022
The job Click to see the possible cause of the failure (guessed by this bot)
|
Aaron1011
pushed a commit
to Aaron1011/rust
that referenced
this issue
Jan 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Today we accept this:
where
p
is an unsafe ptr. This is ok. However, I think we accept it because we are not properly checking for moves in initializers and not for any good reason. We should probably accept moves out of unsafe ptrs (it's useful) but also check initializers properly. I'm not sure whether this is a borrowck or liveness bug but I think borrowck.The text was updated successfully, but these errors were encountered: