Skip to content

Commit 0cf5ffe

Browse files
committed
Hard error when more than five doctests are on one item
1 parent 3bf62cc commit 0cf5ffe

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)