Commit 92da5d8
authored
Fix
Follows #468
## Synopsis
In #468, the `FromStr` derive was reworked. However, the check for
inferring trait bounds for the inner type was simplified to
`!generics.params.is_empty()`, which is not a very correct assumption,
because applies the redundant bounds for cases like these:
```rust
#[derive(FromStr)]
struct Int<const N: usize>(i32);
```
```rust
impl<const N: usize> derive_more::core::str::FromStr for Int<N>
where
i32: derive_more::core::str::FromStr
{ /* ... */}
```
## Solution
Use `utils::GenericSearch` machinery as a common mechanism for this
purpose.
## Additionally
Refactored `utils::GenericSearch` to use `Vec` instead `HashSet`,
because in the majority of cases there won't be any duplicates in
generic parameters and their number won't be big enough for a `HashSet`
to make a positive performance benefit. At the same moment, `HashSet`
requires `Hash` implementation of `syn::Ident` which is gated by the
`syn/extra-traits` feature, and thus we can lift it requirement for
`utils::GenericSearch` usage.FromStr generics check (#476)1 parent b982f90 commit 92da5d8
4 files changed
+135
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
2381 | 2381 | | |
2382 | 2382 | | |
2383 | 2383 | | |
2384 | | - | |
| 2384 | + | |
2385 | 2385 | | |
2386 | 2386 | | |
2387 | 2387 | | |
2388 | | - | |
2389 | | - | |
2390 | 2388 | | |
2391 | 2389 | | |
2392 | 2390 | | |
2393 | 2391 | | |
2394 | | - | |
| 2392 | + | |
2395 | 2393 | | |
2396 | 2394 | | |
2397 | | - | |
| 2395 | + | |
2398 | 2396 | | |
2399 | 2397 | | |
2400 | | - | |
| 2398 | + | |
2401 | 2399 | | |
2402 | 2400 | | |
2403 | 2401 | | |
| |||
2436 | 2434 | | |
2437 | 2435 | | |
2438 | 2436 | | |
2439 | | - | |
| 2437 | + | |
2440 | 2438 | | |
2441 | 2439 | | |
2442 | 2440 | | |
2443 | 2441 | | |
2444 | 2442 | | |
2445 | 2443 | | |
2446 | 2444 | | |
2447 | | - | |
| 2445 | + | |
2448 | 2446 | | |
2449 | 2447 | | |
2450 | 2448 | | |
| |||
2453 | 2451 | | |
2454 | 2452 | | |
2455 | 2453 | | |
2456 | | - | |
| 2454 | + | |
| 2455 | + | |
2457 | 2456 | | |
2458 | 2457 | | |
2459 | 2458 | | |
2460 | 2459 | | |
2461 | 2460 | | |
2462 | 2461 | | |
2463 | | - | |
| 2462 | + | |
2464 | 2463 | | |
2465 | 2464 | | |
2466 | 2465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
11 | 20 | | |
12 | 21 | | |
13 | 22 | | |
| |||
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
138 | 257 | | |
139 | 258 | | |
140 | 259 | | |
| |||
0 commit comments