2022-01-11 11:41:15 -06:00
|
|
|
#![warn(clippy::deref_by_slicing)]
|
2022-05-28 20:57:15 -05:00
|
|
|
#![allow(clippy::borrow_deref_ref)]
|
2022-01-11 11:41:15 -06:00
|
|
|
|
2022-02-13 17:43:19 -06:00
|
|
|
use std::io::Read;
|
|
|
|
|
2022-01-11 11:41:15 -06:00
|
|
|
fn main() {
|
|
|
|
let mut vec = vec![0];
|
|
|
|
let _ = &vec[..];
|
|
|
|
let _ = &mut vec[..];
|
|
|
|
|
|
|
|
let ref_vec = &mut vec;
|
|
|
|
let _ = &ref_vec[..];
|
2022-02-13 17:43:19 -06:00
|
|
|
let mut_slice = &mut ref_vec[..];
|
|
|
|
let _ = &mut mut_slice[..]; // Err, re-borrows slice
|
2022-01-11 11:41:15 -06:00
|
|
|
|
|
|
|
let s = String::new();
|
|
|
|
let _ = &s[..];
|
2022-02-13 17:43:19 -06:00
|
|
|
|
|
|
|
static S: &[u8] = &[0, 1, 2];
|
|
|
|
let _ = &mut &S[..]; // Err, re-borrows slice
|
|
|
|
|
|
|
|
let slice: &[u32] = &[0u32, 1u32];
|
|
|
|
let slice_ref = &slice;
|
|
|
|
let _ = &slice_ref[..]; // Err, derefs slice
|
|
|
|
|
|
|
|
let bytes: &[u8] = &[];
|
|
|
|
let _ = (&bytes[..]).read_to_end(&mut vec![]).unwrap(); // Err, re-borrows slice
|
2024-07-18 13:23:04 -05:00
|
|
|
|
|
|
|
// issue 12751
|
|
|
|
let a = &mut [1, 2, 3][..];
|
|
|
|
let _ = &a[..];
|
2022-01-11 11:41:15 -06:00
|
|
|
}
|