@@ -9,42 +9,36 @@ note: the lint level is defined here
99 |
1010LL | #![deny(clippy::index_refutable_slice)]
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12- help: try using a slice pattern here
12+ help: replace the binding and indexed access with a slice pattern
1313 |
14- LL | if let Some([slice_0, ..]) = slice {
15- | ~~~~~~~~~~~~~
16- help: and replace the index expressions here
14+ LL ~ if let Some([slice_0, ..]) = slice {
15+ LL |
16+ LL ~ println!("{}", slice_0);
1717 |
18- LL | println!("{}", slice_0);
19- | ~~~~~~~
2018
2119error: this binding can be a slice pattern to avoid indexing
2220 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:23:17
2321 |
2422LL | if let Some(slice) = slice {
2523 | ^^^^^
2624 |
27- help: try using a slice pattern here
25+ help: replace the binding and indexed access with a slice pattern
2826 |
29- LL | if let Some([slice_0, ..]) = slice {
30- | ~~~~~~~~~~~~~
31- help: and replace the index expressions here
27+ LL ~ if let Some([slice_0, ..]) = slice {
28+ LL |
29+ LL ~ println!("{}", slice_0);
3230 |
33- LL | println!("{}", slice_0);
34- | ~~~~~~~
3531
3632error: this binding can be a slice pattern to avoid indexing
3733 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:30:17
3834 |
3935LL | if let Some(slice) = slice {
4036 | ^^^^^
4137 |
42- help: try using a slice pattern here
43- |
44- LL | if let Some([slice_0, _, slice_2, ..]) = slice {
45- | ~~~~~~~~~~~~~~~~~~~~~~~~~
46- help: and replace the index expressions here
38+ help: replace the binding and indexed access with a slice pattern
4739 |
40+ LL ~ if let Some([slice_0, _, slice_2, ..]) = slice {
41+ LL |
4842LL ~ println!("{}", slice_2);
4943LL ~ println!("{}", slice_0);
5044 |
@@ -55,104 +49,94 @@ error: this binding can be a slice pattern to avoid indexing
5549LL | if let SomeEnum::One(slice) | SomeEnum::Three(slice) = slice_wrapped {
5650 | ^^^^^
5751 |
58- help: try using a slice pattern here
52+ help: replace the binding and indexed access with a slice pattern
5953 |
60- LL | if let SomeEnum::One([slice_0, ..]) | SomeEnum::Three([slice_0, ..]) = slice_wrapped {
61- | ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
62- help: and replace the index expressions here
54+ LL ~ if let SomeEnum::One([slice_0, ..]) | SomeEnum::Three([slice_0, ..]) = slice_wrapped {
55+ LL |
56+ LL ~ println!("{}", slice_0);
6357 |
64- LL | println!("{}", slice_0);
65- | ~~~~~~~
6658
6759error: this binding can be a slice pattern to avoid indexing
6860 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:46:29
6961 |
7062LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) {
7163 | ^
7264 |
73- help: try using a slice pattern here
65+ help: replace the binding and indexed access with a slice pattern
7466 |
75- LL | if let (SomeEnum::Three([_, _, a_2, ..]), Some(b)) = (a_wrapped, b_wrapped) {
76- | ~~~~~~~~~~~~~~~
77- help: and replace the index expressions here
67+ LL ~ if let (SomeEnum::Three([_, _, a_2, ..]), Some(b)) = (a_wrapped, b_wrapped) {
68+ LL |
69+ LL |
70+ LL ~ println!("{} -> {}", a_2, b[1]);
7871 |
79- LL | println!("{} -> {}", a_2, b[1]);
80- | ~~~
8172
8273error: this binding can be a slice pattern to avoid indexing
8374 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:46:38
8475 |
8576LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) {
8677 | ^
8778 |
88- help: try using a slice pattern here
79+ help: replace the binding and indexed access with a slice pattern
8980 |
90- LL | if let (SomeEnum::Three(a), Some([_, b_1, ..])) = (a_wrapped, b_wrapped) {
91- | ~~~~~~~~~~~~
92- help: and replace the index expressions here
81+ LL ~ if let (SomeEnum::Three(a), Some([_, b_1, ..])) = (a_wrapped, b_wrapped) {
82+ LL |
83+ LL |
84+ LL ~ println!("{} -> {}", a[2], b_1);
9385 |
94- LL | println!("{} -> {}", a[2], b_1);
95- | ~~~
9686
9787error: this binding can be a slice pattern to avoid indexing
9888 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:55:21
9989 |
10090LL | if let Some(ref slice) = slice {
10191 | ^^^^^
10292 |
103- help: try using a slice pattern here
93+ help: replace the binding and indexed access with a slice pattern
10494 |
105- LL | if let Some([_, ref slice_1, ..]) = slice {
106- | ~~~~~~~~~~~~~~~~~~~~
107- help: and replace the index expressions here
95+ LL ~ if let Some([_, ref slice_1, ..]) = slice {
96+ LL |
97+ LL ~ println!("{:?}", slice_1);
10898 |
109- LL | println!("{:?}", slice_1);
110- | ~~~~~~~
11199
112100error: this binding can be a slice pattern to avoid indexing
113101 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:64:17
114102 |
115103LL | if let Some(slice) = &slice {
116104 | ^^^^^
117105 |
118- help: try using a slice pattern here
106+ help: replace the binding and indexed access with a slice pattern
119107 |
120- LL | if let Some([slice_0, ..]) = &slice {
121- | ~~~~~~~~~~~~~
122- help: and replace the index expressions here
108+ LL ~ if let Some([slice_0, ..]) = &slice {
109+ LL |
110+ LL ~ println!("{:?}", slice_0);
123111 |
124- LL | println!("{:?}", slice_0);
125- | ~~~~~~~
126112
127113error: this binding can be a slice pattern to avoid indexing
128114 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:134:17
129115 |
130116LL | if let Some(slice) = wrap.inner {
131117 | ^^^^^
132118 |
133- help: try using a slice pattern here
119+ help: replace the binding and indexed access with a slice pattern
134120 |
135- LL | if let Some([slice_0, ..]) = wrap.inner {
136- | ~~~~~~~~~~~~~
137- help: and replace the index expressions here
121+ LL ~ if let Some([slice_0, ..]) = wrap.inner {
122+ LL |
123+ LL | if wrap.is_awesome {
124+ LL ~ println!("This is awesome! {}", slice_0);
138125 |
139- LL | println!("This is awesome! {}", slice_0);
140- | ~~~~~~~
141126
142127error: this binding can be a slice pattern to avoid indexing
143128 --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:142:17
144129 |
145130LL | if let Some(slice) = wrap.inner {
146131 | ^^^^^
147132 |
148- help: try using a slice pattern here
133+ help: replace the binding and indexed access with a slice pattern
149134 |
150- LL | if let Some([slice_0, ..]) = wrap.inner {
151- | ~~~~~~~~~~~~~
152- help: and replace the index expressions here
135+ LL ~ if let Some([slice_0, ..]) = wrap.inner {
136+ LL |
137+ LL | if wrap.is_super_awesome() {
138+ LL ~ println!("This is super awesome! {}", slice_0);
153139 |
154- LL | println!("This is super awesome! {}", slice_0);
155- | ~~~~~~~
156140
157141error: aborting due to 10 previous errors
158142
0 commit comments