Unnecessary references lint#138230
Conversation
|
r? @Noratrieb rustbot has assigned @Noratrieb. Use |
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
compiler-errors
left a comment
There was a problem hiding this comment.
This lint seems really specific to a single kind of expression, and there are plenty of other cases where unnecessary references are created when the user is trying to create a raw pointer. Unless this can be greatly generalized, it doesn't really seem worth adding this.
|
r? RalfJung |
|
I agree, and my intention is to generalize this lint to cover all unnecessarily created references. Could you please list other cases that you think should be included? I can update this PR to cover them or create an issue to track these cases and mention that they should be added to the |
|
Sorry, I am swamped. Happy to discuss which cases the lint shoild fire on, but I can't review the implementation.
r? compiler
|
|
Do we have some people who are our "linting experts"? |
Which examples did you have in mind? A starting point might be to uplift https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr from cliippy to rustc, as you mention. It is not clear to me what the difference is between that lint and this one. |
cc @Urgau |
|
Happy to take over the review. If @Nadrieril doesn't want to review it of course. As for the lint it-self, I join @RalfJung that this is lint is currently As a drive-by, |
|
Much appreciated :) r? @Urgau |
1e686f1 to
e113827
Compare
|
I'm having a little bit of difficulty following the conversation and understanding what the current implementation does. I can't find a consolidated description. Does the current implementation only check for Is there an intention for this lint to cover any situation where a borrow is "unnecessary"? For example, would it also encompass
|
|
Replacing
This sounds like
Not from my side, no. It is specifically about borrows that are unnecessary where removing them actually can make a semantic difference (which I think can only happen if removing the borrow entirely avoids creating any reference, using only raw pointers instead). |
|
@rfcbot concern name-and-scope @ehuss asked:
@RalfJung's reply was:
If we mean to limit the scope of the lint in this way, probably the current name is a bit too encompassing. Do we have any other ideas for that? As @ehuss notes, it'd be good to include these intended scope restrictions in the lint documentation as well. |
5f1cb56 to
abc1e1e
Compare
This comment has been minimized.
This comment has been minimized.
|
I'm afraid I don't have the capacity to do code-level review here. |
This comment has been minimized.
This comment has been minimized.
abc1e1e to
f4e1186
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
f4e1186 to
b6eda97
Compare
View all comments
Close #127724