|
| 1 | +macro_rules! test_macro { |
| 2 | + (|$transaction: ident| $body: expr) => {{ |
| 3 | + let $transaction = some_value; |
| 4 | + let _ = $body; |
| 5 | + }}; |
| 6 | +} |
| 7 | + |
| 8 | +fn test_func<T>(func: impl FnOnce(u8) -> T) { |
| 9 | +} |
| 10 | + |
| 11 | +fn test_func2<T>(func: impl FnOnce(u8) -> T, value: u8) { |
| 12 | +} |
| 13 | + |
| 14 | +// _0: in-macro |
| 15 | +// _1: last argument in function invocation |
| 16 | +// _2: non-last argument in function invocation |
| 17 | +// _3: simple expression |
| 18 | + |
| 19 | +// test0: the cause reported in issue: label is used, and there is usage, multiple statements |
| 20 | +pub fn rustfnmt_test0_0(condition: bool) { |
| 21 | + test_macro!(|transaction| 'block: { |
| 22 | + if condition { |
| 23 | + break 'block 0; |
| 24 | + } |
| 25 | + |
| 26 | + todo!() |
| 27 | + }); |
| 28 | +} |
| 29 | + |
| 30 | +pub fn rustfnmt_test0_1(condition: bool) { |
| 31 | + test_func(|transaction| 'block: { |
| 32 | + if condition { |
| 33 | + break 'block 0; |
| 34 | + } |
| 35 | + |
| 36 | + todo!() |
| 37 | + }); |
| 38 | +} |
| 39 | + |
| 40 | +pub fn rustfnmt_test0_2(condition: bool) { |
| 41 | + test_func2(|transaction| 'block: { |
| 42 | + if condition { |
| 43 | + break 'block 0; |
| 44 | + } |
| 45 | + |
| 46 | + todo!() |
| 47 | + }, 0); |
| 48 | +} |
| 49 | + |
| 50 | +pub fn rustfnmt_test0_3(condition: bool) { |
| 51 | + let x = |transaction| 'block: { |
| 52 | + if condition { |
| 53 | + break 'block 0; |
| 54 | + } |
| 55 | + |
| 56 | + todo!() |
| 57 | + }; |
| 58 | +} |
| 59 | + |
| 60 | +// test0: the cause reported in issue: label is used, and there is usage, multiple statements |
| 61 | +pub fn rustfnmt_test0_0(condition: bool) { |
| 62 | + test_macro!(|transaction| 'block: { |
| 63 | + if condition { |
| 64 | + break 'block 0; |
| 65 | + } |
| 66 | + |
| 67 | + todo!() |
| 68 | + }); |
| 69 | +} |
| 70 | + |
| 71 | +pub fn rustfnmt_test0_1(condition: bool) { |
| 72 | + test_func(|transaction| 'block: { |
| 73 | + if condition { |
| 74 | + break 'block 0; |
| 75 | + } |
| 76 | + |
| 77 | + todo!() |
| 78 | + }); |
| 79 | +} |
| 80 | + |
| 81 | +pub fn rustfnmt_test0_2(condition: bool) { |
| 82 | + test_func2(|transaction| 'block: { |
| 83 | + if condition { |
| 84 | + break 'block 0; |
| 85 | + } |
| 86 | + |
| 87 | + todo!() |
| 88 | + }, 0); |
| 89 | +} |
| 90 | + |
| 91 | +pub fn rustfnmt_test0_3(condition: bool) { |
| 92 | + let x = |transaction| 'block: { |
| 93 | + if condition { |
| 94 | + break 'block 0; |
| 95 | + } |
| 96 | + |
| 97 | + todo!() |
| 98 | + }; |
| 99 | +} |
| 100 | + |
| 101 | + |
| 102 | +// test1: label is unused, and there is usage, multiple statements |
| 103 | +pub fn rustfnmt_test1_0(condition: bool) { |
| 104 | + test_macro!(|transaction| 'block: { |
| 105 | + if condition { |
| 106 | + todo!(""); |
| 107 | + } |
| 108 | + |
| 109 | + todo!() |
| 110 | + }); |
| 111 | +} |
| 112 | + |
| 113 | +pub fn rustfnmt_test1_1(condition: bool) { |
| 114 | + test_func(|transaction| 'block: { |
| 115 | + if condition { |
| 116 | + todo!(""); |
| 117 | + } |
| 118 | + |
| 119 | + todo!() |
| 120 | + }); |
| 121 | +} |
| 122 | + |
| 123 | +pub fn rustfnmt_test1_2(condition: bool) { |
| 124 | + test_func2(|transaction| 'block: { |
| 125 | + if condition { |
| 126 | + todo!(""); |
| 127 | + } |
| 128 | + |
| 129 | + todo!() |
| 130 | + }, 0); |
| 131 | +} |
| 132 | + |
| 133 | +pub fn rustfnmt_test1_3(condition: bool) { |
| 134 | + let x = |transaction| 'block: { |
| 135 | + if condition { |
| 136 | + todo!(""); |
| 137 | + } |
| 138 | + |
| 139 | + todo!() |
| 140 | + }; |
| 141 | +} |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | +// test2: label is used, single expression |
| 146 | +pub fn rustfnmt_test2_0(condition: bool) { |
| 147 | + test_macro!(|transaction| 'block: { |
| 148 | + break 'block 0; |
| 149 | + }); |
| 150 | +} |
| 151 | + |
| 152 | +pub fn rustfnmt_test2_1(condition: bool) { |
| 153 | + test_func(|transaction| 'block: { |
| 154 | + break 'block 0; |
| 155 | + }); |
| 156 | +} |
| 157 | + |
| 158 | +pub fn rustfnmt_test2_2(condition: bool) { |
| 159 | + test_func2(|transaction| 'block: { |
| 160 | + break 'block 0; |
| 161 | + }, 0); |
| 162 | +} |
| 163 | + |
| 164 | +pub fn rustfnmt_test2_3(condition: bool) { |
| 165 | + let x = |transaction| 'block: { |
| 166 | + break 'block 0; |
| 167 | + }; |
| 168 | +} |
| 169 | + |
| 170 | +// test3: label is unused, single general multi-line expression |
| 171 | +pub fn rustfnmt_test3_0(condition: bool) { |
| 172 | + test_macro!(|transaction| 'block: { |
| 173 | + vec![ |
| 174 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 175 | + 0, |
| 176 | + ] |
| 177 | + }); |
| 178 | +} |
| 179 | + |
| 180 | +pub fn rustfnmt_test3_1(condition: bool) { |
| 181 | + test_func(|transaction| 'block: { |
| 182 | + vec![ |
| 183 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 184 | + 0, |
| 185 | + ] |
| 186 | + }); |
| 187 | +} |
| 188 | + |
| 189 | +pub fn rustfnmt_test3_2(condition: bool) { |
| 190 | + test_func2(|transaction| 'block: { |
| 191 | + vec![ |
| 192 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 193 | + 0, |
| 194 | + ] |
| 195 | + }, 0); |
| 196 | +} |
| 197 | + |
| 198 | +pub fn rustfnmt_test3_3(condition: bool) { |
| 199 | + let x = |transaction| 'block: { |
| 200 | + vec![ |
| 201 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 202 | + 0, |
| 203 | + ] |
| 204 | + }; |
| 205 | +} |
| 206 | + |
| 207 | +// test4: label is unused, single block statement-expression |
| 208 | +pub fn rustfnmt_test4_0(condition: bool) { |
| 209 | + test_macro!(|transaction| 'block: { |
| 210 | + if condition { |
| 211 | + break 'block 1; |
| 212 | + } else { |
| 213 | + break 'block 0; |
| 214 | + } |
| 215 | + }); |
| 216 | +} |
| 217 | + |
| 218 | +pub fn rustfnmt_test4_1(condition: bool) { |
| 219 | + test_func(|transaction| 'block: { |
| 220 | + if condition { |
| 221 | + break 'block 1; |
| 222 | + } else { |
| 223 | + break 'block 0; |
| 224 | + } |
| 225 | + }); |
| 226 | +} |
| 227 | + |
| 228 | +pub fn rustfnmt_test4_2(condition: bool) { |
| 229 | + test_func2(|transaction| 'block: { |
| 230 | + if condition { |
| 231 | + break 'block 1; |
| 232 | + } else { |
| 233 | + break 'block 0; |
| 234 | + } |
| 235 | + }, 1); |
| 236 | +} |
| 237 | + |
| 238 | +pub fn rustfnmt_test4_3(condition: bool) { |
| 239 | + let x = |transaction| 'block: { |
| 240 | + if condition { |
| 241 | + break 'block 1; |
| 242 | + } else { |
| 243 | + break 'block 0; |
| 244 | + } |
| 245 | + }; |
| 246 | +} |
0 commit comments