mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Add test for needless_pass_by_ref_mut
to ensure that the lint is not emitted if variable is used in an unsafe block or function
This commit is contained in:
parent
bc97f7d0c9
commit
80a092c6df
1 changed files with 12 additions and 0 deletions
|
@ -276,6 +276,18 @@ async fn _f(v: &mut Vec<()>) {
|
|||
_ = || || x;
|
||||
}
|
||||
|
||||
struct Data<T: ?Sized> {
|
||||
value: T,
|
||||
}
|
||||
// Unsafe functions should not warn.
|
||||
unsafe fn get_mut_unchecked<T>(ptr: &mut NonNull<Data<T>>) -> &mut T {
|
||||
&mut (*ptr.as_ptr()).value
|
||||
}
|
||||
// Unsafe blocks should not warn.
|
||||
fn get_mut_unchecked2<T>(ptr: &mut NonNull<Data<T>>) -> &mut T {
|
||||
unsafe { &mut (*ptr.as_ptr()).value }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut u = 0;
|
||||
let mut v = vec![0];
|
||||
|
|
Loading…
Reference in a new issue