lints 0.2.0

Writes [lints.rust] to stdout such that all lints are denied or allowed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
use super::{
    ExitCode, HashSet, convert,
    io::{self, Write as _},
};
use core::{
    cmp::Ordering,
    hash::{Hash, Hasher},
};
// We skip all lines until: "name  default  meaning" trimming leading spaces.
// We verify the next line is "----  -------  -------" trimming leading spaces.
//
// Next we grab the lints.
// The regex for lints is verified to be `^ *[\-0-9A-Za-z]+ +(allow|warn|deny) +.*$`.
//
// We verify all three kinds of lints are non-empty and no lint exists more than once. We verify the
// `warn` lints contain a lint called "warnings" which does not count towards the emptiness of
// `warn` lints.
//
// Next we skip all lines until: "name  sub-lints" trimming leading spaces.
// We verify the next line is "----  ---------" trimming leading spaces.
//
// Next we grab the lint groups.
// The regex for lint groups is verified to be `^ +[\-0-9A-Za-z]+ +[ ,\-0-9A-Za-z]+$`.
//
// We verify lint group names are unique among themselves and the individual lints sans `"warnings"`
// which is allowed to exist.
// We verify the lint groups are non-empty except "warnings" if it is defined.
// We verify each lint in a lint group is unique.
// We verify each lint is the name of one of the lints unless `--allow-undefined-lints` was passed.
// We verify when there is multiple lints, each lint is separated with a single comma and space.
/// Error from parsing.
#[cfg_attr(test, derive(Debug, PartialEq))]
pub(crate) enum E<'a> {
    /// Output doesn't start as expected.
    Start,
    /// The contained line is not the format of a lint.
    UnexpectedLintLine(&'a [u8]),
    /// The contained lint appeared more than once.
    DuplicateLint(&'a [u8]),
    /// There wasn't a `warn`-by-default lint called `"warnings"`.
    MissingWarningLint,
    /// There were no `allow`-by-default lints.
    NoAllowLints,
    /// There were no `warn`-by-default lints except for `"warnings"`.
    NoWarnLints,
    /// There were no `deny`-by-default lints.
    NoDenyLints,
    /// Output doesn't contain what it should between the lints and lint groups.
    Middle,
    /// The contained line is not the format of a lint group.
    UnexpectedLintGroupLine(&'a [u8]),
    /// The contained lint group name appeared more than once.
    DuplicateLintGroup(&'a [u8]),
    /// The contained lint group name is the same as the name of a lint.
    LintSameNameAsLintGroup(&'a [u8]),
    /// The contained lint group name contained a lint more than once.
    LintGroupContainsDuplicateLint(&'a [u8], &'a [u8]),
    /// The contained lint group name contained an unknown lint.
    LintGroupContainsUnknownLint(&'a [u8], &'a [u8]),
    /// The contained lint group name has no lints.
    EmptyLintGroup(&'a [u8]),
    /// There were no lint groups.
    NoLintGroups,
    /// Output doesn't end as expected.
    End,
}
/// Lines before lints.
const START: &str = "name  default  meaning
----  -------  -------";
/// Lines between lints and lint groups.
const MIDDLE: &str = "name  sub-lints
----  ---------";
impl E<'_> {
    /// Writes `self` into `stderr`.
    pub(crate) fn into_exit_code(self) -> ExitCode {
        let mut stderr = io::stderr().lock();
        match self {
            Self::Start => writeln!(stderr, "rustc -Whelp doesn't contain '{START}' ignoring leading spaces"),
            Self::UnexpectedLintLine(line) => writeln!(
                stderr,
                "rustc -Whelp contained the following line that is not the expected format of a lint: {}.",
                String::from_utf8_lossy(line),
            ),
            Self::DuplicateLint(lint) => writeln!(
                stderr,
                "rustc -Whelp contained the lint '{}' more than once.",
                super::as_str(lint)
            ),
            Self::MissingWarningLint => writeln!(
                stderr,
                "rustc -Whelp didn't contain a warn-by-default lint called 'warnings'."
            ),
            Self::NoAllowLints => writeln!(
                stderr,
                "rustc -Whelp didn't contain any allow-by-default lints."
            ),
            Self::NoWarnLints => writeln!(
                stderr,
                "rustc -Whelp didn't contain any warn-by-default lints except for 'warnings'."
            ),
            Self::NoDenyLints => writeln!(
                stderr,
                "rustc -Whelp didn't contain any deny-by-default lints."
            ),
            Self::Middle => writeln!(
                stderr,
                "rustc -Whelp doesn't contain '{MIDDLE}' ignoring leading spaces after the lints."
            ),
            Self::UnexpectedLintGroupLine(line) => writeln!(
                stderr,
                "rustc -Whelp contained the following line that is not the expected format of a lint group: {}.",
                String::from_utf8_lossy(line),
            ),
            Self::DuplicateLintGroup(group) => {
                writeln!(
                    stderr,
                    "rustc -Whelp contained multiple lint groups called '{}'.",
                    super::as_str(group)
                )
            }
            Self::LintSameNameAsLintGroup(group) => {
                writeln!(
                    stderr,
                    "rustc -Whelp contained a lint and lint group both named '{}'.",
                    super::as_str(group)
                )
            }
            Self::LintGroupContainsDuplicateLint(group, lint) => writeln!(
                stderr,
                "rustc -Whelp contained the lint group '{}' which has the lint '{}' more than once.",
                super::as_str(group),
                super::as_str(lint),
            ),
            Self::LintGroupContainsUnknownLint(group, lint) => writeln!(
                stderr,
                "rustc -Whelp contained the lint group '{}' which has the unknown lint '{}'.",
                super::as_str(group),
                super::as_str(lint),
            ),
            Self::EmptyLintGroup(group) => {
                writeln!(
                    stderr,
                    "rustc -Whelp contained the empty lint group '{}'.",
                    super::as_str(group),
                )
            }
            Self::NoLintGroups => writeln!(
                stderr,
                "rustc -Whelp didn't contain any lint groups."
            ),
            Self::End => writeln!(stderr, "rustc -Whelp did not have at least one empty line after the lint groups."),
        }.map_or(ExitCode::FAILURE, |()| ExitCode::FAILURE)
    }
}
/// Moves `line` to start at the first non-space.
#[expect(
    clippy::arithmetic_side_effects,
    clippy::indexing_slicing,
    reason = "comments justifies correctness"
)]
fn skip_leading_space(line: &mut &[u8]) {
    // The `usize` contained in the `Result` is at most `line.len()`, we indexing is fine.
    *line = &line[line
        .iter()
        .try_fold(0, |idx, b| {
            if *b == b' ' {
                // `idx < line.len()`, so overflow is not possible.
                Ok(idx + 1)
            } else {
                Err(idx)
            }
        })
        .map_or_else(convert::identity, convert::identity)..];
}
/// [`Iterator`] of lines.
///
/// In the event a `b'\n'` doesn't exist, `None` will be returned. This means in the event the last
/// "line" does not end with `b'\n'`, it won't be returned.
struct Lines<'a>(&'a [u8]);
impl<'a> Iterator for Lines<'a> {
    type Item = &'a [u8];
    #[expect(
        clippy::arithmetic_side_effects,
        clippy::indexing_slicing,
        reason = "comments justify correctness"
    )]
    fn next(&mut self) -> Option<Self::Item> {
        self.0
            .iter()
            .try_fold(0, |idx, b| {
                if *b == b'\n' {
                    Err(idx)
                } else {
                    // `idx < self.0.len()`, so overflow is not possible.
                    Ok(idx + 1)
                }
            })
            .map_or_else(
                |idx| {
                    // `idx <= self.0.len()`, so this won't `panic`.
                    let (val, rem) = self.0.split_at(idx);
                    // `rem` starts with a newline, so this won't `panic`.
                    self.0 = &rem[1..];
                    Some(val)
                },
                |_| None,
            )
    }
}
/// Extracts the lint or lint group name from `line`.
///
/// Returns `Some` iff a valid lint or lint group name is found ignoring leading spaces and
/// if there is non-spaces after. The first `slice` is the name and the second slice is
/// the remaining portion of `line` with leading spaces removed.
#[expect(
    clippy::arithmetic_side_effects,
    reason = "comment justifies correctness"
)]
fn get_lint_name(mut line: &[u8]) -> Option<(&[u8], &[u8])> {
    skip_leading_space(&mut line);
    line.iter()
        .try_fold(0, |idx, b| {
            if *b == b' ' {
                Err(Some(idx))
            } else if *b == b'-' || b.is_ascii_alphanumeric() {
                // `idx < line.len()`, so overflow is not possible.
                Ok(idx + 1)
            } else {
                Err(None)
            }
        })
        .map_or_else(
            |opt| {
                opt.and_then(|idx| {
                    let (name, mut rem) = line.split_at(idx);
                    let len = rem.len();
                    skip_leading_space(&mut rem);
                    if len == rem.len() {
                        None
                    } else {
                        Some((name, rem))
                    }
                })
            },
            |_| None,
        )
}
/// The lints.
///
/// All `HashSet`s are non-empty with no overlap. `warn` doesn't contain `"warnings"`.
struct Lints<'a> {
    /// `allow`-by-default lints.
    allow: HashSet<&'a [u8]>,
    /// `warn`-by-default lints.
    warn: HashSet<&'a [u8]>,
    /// `deny`-by-default lints.
    deny: HashSet<&'a [u8]>,
}
/// `"warnings"`.
pub(crate) const WARNINGS: &str = "warnings";
impl<'a> Lints<'a> {
    /// Gets the lints from `lines` erring when there are duplicates, there is no `warn`-by-default
    /// lint called `"warnings"`, or the lints are empty (ignoring the `"warnings"` lint).
    #[expect(
        clippy::arithmetic_side_effects,
        clippy::indexing_slicing,
        reason = "comments justify correctness"
    )]
    fn new(lines: &mut Lines<'a>) -> Result<Self, E<'a>> {
        /// Get the lint from `line`.
        ///
        /// Returns `Some` iff a valid lint name is found after removing leading spaces.
        /// The first `slice` is the name, and the second `slice` is the next "word".
        fn get_lint(line: &[u8]) -> Option<(&[u8], &[u8])> {
            get_lint_name(line).and_then(|(lint, rem)| {
                rem.iter()
                    // `idx < rem.len()`, so overflow is not possible.
                    .try_fold(0, |idx, b| if *b == b' ' { Err(idx) } else { Ok(idx + 1) })
                    // `idx <= rem.len()`, so this won't `panic`.
                    .map_or_else(|idx| Some((lint, &rem[..idx])), |_| None)
            })
        }
        let mut allow = HashSet::with_capacity(128);
        let mut warn = HashSet::with_capacity(128);
        let mut deny = HashSet::with_capacity(128);
        lines
            .try_fold((), |(), line| {
                if line.is_empty() {
                    Err(None)
                } else {
                    get_lint(line)
                        .ok_or(Some(E::UnexpectedLintLine(line)))
                        .and_then(|(lint, status)| match status {
                            b"allow" => {
                                if !allow.insert(lint) || warn.contains(lint) || deny.contains(lint)
                                {
                                    Err(Some(E::DuplicateLint(lint)))
                                } else {
                                    Ok(())
                                }
                            }
                            b"warn" => {
                                if !warn.insert(lint) || allow.contains(lint) || deny.contains(lint)
                                {
                                    Err(Some(E::DuplicateLint(lint)))
                                } else {
                                    Ok(())
                                }
                            }
                            b"deny" => {
                                if !deny.insert(lint) || allow.contains(lint) || warn.contains(lint)
                                {
                                    Err(Some(E::DuplicateLint(lint)))
                                } else {
                                    Ok(())
                                }
                            }
                            _ => Err(Some(E::UnexpectedLintLine(line))),
                        })
                }
            })
            .map_or_else(
                |opt| {
                    opt.map_or_else(
                        || {
                            if warn.remove(WARNINGS.as_bytes()) {
                                if allow.is_empty() {
                                    Err(E::NoAllowLints)
                                } else if warn.is_empty() {
                                    Err(E::NoWarnLints)
                                } else if deny.is_empty() {
                                    Err(E::NoDenyLints)
                                } else {
                                    Ok(Self { allow, warn, deny })
                                }
                            } else {
                                Err(E::MissingWarningLint)
                            }
                        },
                        Err,
                    )
                },
                |()| Err(E::Middle),
            )
    }
}
/// [`Iterator`] of values separated by commas and spaces.
///
/// In the event a value comes after a comma, a single leading space is assumed to exist and will be removed.
struct Csv<'a>(&'a [u8]);
impl<'a> Iterator for Csv<'a> {
    type Item = Result<&'a [u8], ()>;
    #[expect(
        clippy::arithmetic_side_effects,
        reason = "comments justify correctness"
    )]
    fn next(&mut self) -> Option<Self::Item> {
        /// `b", "`.
        const COMMA_SPACE: &[u8; 2] = b", ";
        (!self.0.is_empty()).then(|| {
            match self.0.iter().try_fold(0, |idx, b| {
                if *b == b',' {
                    Err(idx)
                } else {
                    // `idx < self.0.len()`, so overflow is not possible.
                    Ok(idx + 1)
                }
            }) {
                Ok(_) => {
                    let val = self.0;
                    self.0 = &[];
                    Ok(val)
                }
                Err(idx) => {
                    // `idx <= self.0.len()`, so this won't `panic`.
                    let (val, rem) = self.0.split_at(idx);
                    rem.split_at_checked(COMMA_SPACE.len())
                        .ok_or(())
                        .and_then(|(fst, fst_rem)| {
                            if fst == COMMA_SPACE {
                                self.0 = fst_rem;
                                Ok(val)
                            } else {
                                Err(())
                            }
                        })
                }
            }
        })
    }
}
/// Group of lints.
pub(crate) struct LintGroup<'a> {
    /// Name of the group.
    pub name: &'a [u8],
    /// Lints that make up the group.
    pub lints: HashSet<&'a [u8]>,
}
impl Eq for LintGroup<'_> {}
impl PartialEq for LintGroup<'_> {
    fn eq(&self, other: &Self) -> bool {
        self.name == other.name
    }
}
impl Hash for LintGroup<'_> {
    fn hash<H: Hasher>(&self, state: &mut H) {
        self.name.hash(state);
    }
}
impl PartialOrd for LintGroup<'_> {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}
impl Ord for LintGroup<'_> {
    fn cmp(&self, other: &Self) -> Ordering {
        self.name.cmp(other.name)
    }
}
/// Data from `rustc -Whelp`.
pub(crate) struct Data<'a> {
    /// `allow`-by-default lints.
    pub allow: Vec<&'a [u8]>,
    /// `warn`-by-default lints.
    pub warn: Vec<&'a [u8]>,
    /// `deny`-by-default lints.
    pub deny: Vec<&'a [u8]>,
    /// Lint groups.
    pub groups: Vec<LintGroup<'a>>,
}
impl<'a> Data<'a> {
    /// Moves until the lints.
    ///
    /// Returns `true` iff the header was found.
    fn move_to_lints(lines: &mut Lines<'_>) -> bool {
        lines
            .try_fold((), |(), mut line| {
                skip_leading_space(&mut line);
                if line == b"name  default  meaning" {
                    Err(())
                } else {
                    Ok(())
                }
            })
            .map_or_else(
                |()| {
                    lines.next().is_some_and(|mut line| {
                        skip_leading_space(&mut line);
                        line == b"----  -------  -------"
                    })
                },
                |()| false,
            )
    }
    /// Moves until the lint groups.
    ///
    /// Returns `true` iff the header was found.
    fn move_to_lint_groups(lines: &mut Lines<'_>) -> bool {
        lines
            .try_fold((), |(), mut line| {
                skip_leading_space(&mut line);
                if line == b"name  sub-lints" {
                    Err(())
                } else {
                    Ok(())
                }
            })
            .map_or_else(
                |()| {
                    lines.next().is_some_and(|mut line| {
                        skip_leading_space(&mut line);
                        line == b"----  ---------"
                    })
                },
                |()| false,
            )
    }
    /// Gets the lint groups from `lines` erring when there are duplicate lint group names or if a lint group
    /// name is the name of a lint (with the exception of `"warnings"`), or if a group contains duplicate lints.
    /// In the event `allow_undefined_lints` is `false`, every lint in a lint group must exist in `single_lints`.
    fn get_lint_groups(
        output: &mut Lines<'a>,
        single_lints: &Lints<'_>,
        allow_undefined_lints: bool,
    ) -> Result<HashSet<LintGroup<'a>>, E<'a>> {
        let mut groups = HashSet::with_capacity(16);
        output
            .try_fold((), |(), line| {
                if line.is_empty() {
                    Err(None)
                } else {
                    get_lint_name(line)
                        .ok_or(Some(E::UnexpectedLintGroupLine(line)))
                        .and_then(|(name, group_lints)| {
                            if name == WARNINGS.as_bytes() {
                                Ok(())
                            } else if single_lints.allow.contains(name)
                                || single_lints.warn.contains(name)
                                || single_lints.deny.contains(name)
                            {
                                Err(Some(E::LintSameNameAsLintGroup(name)))
                            } else {
                                let mut lints = HashSet::with_capacity(32);
                                Csv(group_lints)
                                    .try_fold((), |(), res| {
                                        res.map_err(|()| Some(E::UnexpectedLintGroupLine(line)))
                                            .and_then(|lint| {
                                                if allow_undefined_lints
                                                    || single_lints.allow.contains(lint)
                                                    || single_lints.warn.contains(lint)
                                                    || single_lints.deny.contains(lint)
                                                {
                                                    if lints.insert(lint) {
                                                        Ok(())
                                                    } else {
                                                        Err(Some(
                                                            E::LintGroupContainsDuplicateLint(
                                                                name, lint,
                                                            ),
                                                        ))
                                                    }
                                                } else {
                                                    Err(Some(E::LintGroupContainsUnknownLint(
                                                        name, lint,
                                                    )))
                                                }
                                            })
                                    })
                                    .and_then(|()| {
                                        if lints.is_empty() {
                                            Err(Some(E::EmptyLintGroup(name)))
                                        } else if groups.insert(LintGroup { name, lints }) {
                                            Ok(())
                                        } else {
                                            Err(Some(E::DuplicateLintGroup(name)))
                                        }
                                    })
                            }
                        })
                }
            })
            .map_or_else(
                |opt| {
                    opt.map_or_else(
                        || {
                            if groups.is_empty() {
                                Err(E::NoLintGroups)
                            } else {
                                Ok(groups)
                            }
                        },
                        Err,
                    )
                },
                |()| Err(E::End),
            )
    }
    /// Parses output and returns lints and lint groups.
    pub(crate) fn new(output: &'a [u8], allow_undefined_lints: bool) -> Result<Self, E<'a>> {
        let mut lines = Lines(output);
        if Self::move_to_lints(&mut lines) {
            Lints::new(&mut lines).and_then(|lints| {
                if Self::move_to_lint_groups(&mut lines) {
                    Self::get_lint_groups(&mut lines, &lints, allow_undefined_lints).map(
                        |group_set| {
                            let mut allow = Vec::with_capacity(lints.allow.len());
                            lints.allow.into_iter().fold((), |(), lint| {
                                allow.push(lint);
                            });
                            allow.sort_unstable();
                            let mut warn = Vec::with_capacity(lints.warn.len());
                            lints.warn.into_iter().fold((), |(), lint| {
                                warn.push(lint);
                            });
                            warn.sort_unstable();
                            let mut deny = Vec::with_capacity(lints.deny.len());
                            lints.deny.into_iter().fold((), |(), lint| {
                                deny.push(lint);
                            });
                            deny.sort_unstable();
                            let mut groups = Vec::with_capacity(group_set.len());
                            group_set.into_iter().fold((), |(), group| {
                                groups.push(group);
                            });
                            groups.sort_unstable();
                            Self {
                                allow,
                                warn,
                                deny,
                                groups,
                            }
                        },
                    )
                } else {
                    Err(E::Middle)
                }
            })
        } else {
            Err(E::Start)
        }
    }
}
#[cfg(all(test, not(target_pointer_width = "16")))]
mod tests {
    use super::{Data, E, io::Read as _};
    use std::fs::{self, File};
    #[expect(
        clippy::assertions_on_constants,
        reason = "want to pretty-print problematic file"
    )]
    #[expect(clippy::verbose_file_reads, reason = "want to lock file")]
    #[expect(clippy::tests_outside_test_module, reason = "false positive")]
    #[test]
    fn outputs() {
        let mut output = Vec::with_capacity(u16::MAX.into());
        assert!(
            fs::read_dir("./outputs/").is_ok_and(|mut dir| {
                dir.try_fold((), |(), ent_res| {
                    if ent_res.is_ok_and(|ent| {
                        File::options()
                            .read(true)
                            .open(ent.path())
                            .is_ok_and(|mut file| {
                                file.lock_shared().is_ok_and(|()| {
                                    output.clear();
                                    file.read_to_end(&mut output).is_ok_and(|_| {
                                        // Release lock.
                                        drop(file);
                                        let file_name = ent.file_name();
                                        let file_name_bytes = file_name.as_encoded_bytes();
                                        Data::new(&output, false).map_or_else(
                                            |e| match file_name_bytes {
                                                b"1.34.0.txt" | b"1.34.1.txt" | b"1.34.2.txt" => {
                                                    assert_eq!(
                                                        e,
                                                        E::LintGroupContainsUnknownLint(
                                                            b"future-incompatible",
                                                            b"duplicate-matcher-binding-name"
                                                        ),
                                                        "1.34.0.txt, 1.34.1.txt, and 1.34.2.txt can't be parsed for a reason other than the expected reason"
                                                    );
                                                    Data::new(&output, true).is_ok()
                                                }
                                                b"1.48.0.txt" => {
                                                    assert_eq!(
                                                        e,
                                                        E::LintGroupContainsUnknownLint(
                                                            b"rustdoc",
                                                            b"private-intra-doc-links"
                                                        ),
                                                        "1.48.0.txt can't be parsed for a reason other than the expected reason"
                                                    );
                                                    Data::new(&output, true).is_ok()
                                                }
                                                _ => {
                                                    assert!(
                                                        false,
                                                        "{} cannot be parsed due to {e:?}.",
                                                        String::from_utf8_lossy(file_name_bytes),
                                                    );
                                                    false
                                                }
                                            },
                                            |_| {
                                                if matches!(file_name_bytes, b"1.34.0.txt" | b"1.34.1.txt" | b"1.34.2.txt" | b"1.48.0.txt") {
                                                    assert!(false, "{} shouldn't be parsable", String::from_utf8_lossy(file_name_bytes));
                                                    false
                                                } else {
                                                    true
                                                }
                                            },
                                        )
                                    })
                                })
                            })
                    }) {
                        Ok(())
                    } else {
                        Err(())
                    }
                })
                .is_ok()
            })
        );
    }
}