Skip to content

Commit ed7f3d7

Browse files
committed
Auto merge of #134530 - notriddle:notriddle/five-doctests-crater, r=<try>
[crater only] count crates that have more than five doctests on one item Follow up for https://rust-lang.zulipchat.com/#narrow/channel/393423-t-rustdoc.2Fmeetings/topic/2024-12-09/near/487096843 cc `@camelid` `@GuillaumeGomez`
2 parents 9e136a3 + 0cf5ffe commit ed7f3d7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustdoc/doctest/rust.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,19 @@ impl HirCollector<'_> {
126126
})
127127
.unwrap_or(DUMMY_SP)
128128
};
129+
// TEST(notriddle): fail if there's more than 5 tests in a single docblock
130+
let test_count_before = self.collector.tests.len();
129131
markdown::find_testable_code(
130132
&doc,
131133
&mut self.collector,
132134
self.codes,
133135
self.enable_per_target_ignores,
134136
Some(&crate::html::markdown::ExtraInfo::new(self.tcx, def_id, span)),
135137
);
138+
let test_count_after = self.collector.tests.len();
139+
if test_count_after - test_count_before > 5 {
140+
self.tcx.sess.dcx().fatal(format!("{def_id:?} has more than five doctests"));
141+
}
136142
}
137143

138144
nested(self);

0 commit comments

Comments
 (0)