Skip to content
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

Unnecessary references for casting from immutable reference to mutable reference. #1212

Closed
ticki opened this issue Sep 2, 2016 · 2 comments · Fixed by #7977
Closed

Unnecessary references for casting from immutable reference to mutable reference. #1212

ticki opened this issue Sep 2, 2016 · 2 comments · Fixed by #7977
Assignees
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages T-middle Type: Probably requires verifiying types

Comments

@ticki
Copy link

ticki commented Sep 2, 2016

A warning should be generated with:

let mut a = 2;
let mut a_mut = &mut a;
let a_ref: &u8 = &a_mut;

which is more approriately written as:

let mut a = 2;
let mut a_mut = &mut a;
let a_ref: &u8 = a_mut;

(when possible)

@mcarton
Copy link
Member

mcarton commented Sep 2, 2016

I would have guessed this was already covered by needless_borrow, but it seems like not.

@mcarton mcarton added T-middle Type: Probably requires verifiying types C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Sep 2, 2016
@oli-obk
Copy link
Contributor

oli-obk commented Sep 5, 2016

I think the issue is that this is a conversion from a &&mut T to a &T. I'll check how we can improve the needless_borrow lint.

@oli-obk oli-obk self-assigned this Sep 6, 2016
@bors bors closed this as completed in 2776076 Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants