]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_doc_main.rs
Avoid needless_doctest_main on 'extern crate'
[rust.git] / tests / ui / needless_doc_main.rs
1 /// This is a test for needless `fn main()` in doctests.
2 ///
3 /// # Examples
4 ///
5 /// This should lint
6 /// ```
7 /// fn main() {
8 ///     unimplemented!();
9 /// }
10 /// ```
11 fn bad_doctest() {}
12
13 /// # Examples
14 ///
15 /// This shouldn't lint, because the `main` is empty:
16 /// ```
17 /// fn main(){}
18 /// ```
19 ///
20 /// This shouldn't lint either, because there's a `static`:
21 /// ```
22 /// static ANSWER: i32 = 42;
23 ///
24 /// fn main() {
25 ///     assert_eq!(42, ANSWER);
26 /// }
27 /// ```
28 ///
29 /// Neither should this lint because of `extern crate`:
30 /// ```
31 /// #![feature(test)]
32 /// extern crate test;
33 /// fn main() {
34 ///     assert_eq(1u8, test::black_box(1));
35 /// }
36 /// ```
37 fn no_false_positives() {}
38
39 fn main() {
40     bad_doctest();
41     no_false_positives();
42 }