]> git.lizzy.rs Git - rust.git/blob - tests/ui/index_refutable_slice/slice_indexing_in_macro.rs
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
[rust.git] / tests / ui / index_refutable_slice / slice_indexing_in_macro.rs
1 #![deny(clippy::index_refutable_slice)]
2
3 extern crate if_chain;
4 use if_chain::if_chain;
5
6 macro_rules! if_let_slice_macro {
7     () => {
8         // This would normally be linted
9         let slice: Option<&[u32]> = Some(&[1, 2, 3]);
10         if let Some(slice) = slice {
11             println!("{}", slice[0]);
12         }
13     };
14 }
15
16 fn main() {
17     // Don't lint this
18     if_let_slice_macro!();
19
20     // Do lint this
21     if_chain! {
22         let slice: Option<&[u32]> = Some(&[1, 2, 3]);
23         if let Some(slice) = slice;
24         then {
25             println!("{}", slice[0]);
26         }
27     }
28 }