2019-11-29 21:47:26 +01:00
|
|
|
/// This is a test for needless `fn main()` in doctests.
|
|
|
|
///
|
|
|
|
/// # Examples
|
|
|
|
///
|
|
|
|
/// This should lint
|
|
|
|
/// ```
|
|
|
|
/// fn main() {
|
|
|
|
/// unimplemented!();
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-03-10 20:19:37 +01:00
|
|
|
///
|
|
|
|
/// This should, too.
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// fn main() {
|
|
|
|
/// unimplemented!();
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// This one too.
|
|
|
|
///
|
|
|
|
/// ```no_run
|
|
|
|
/// fn main() {
|
|
|
|
/// unimplemented!();
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
fn bad_doctests() {}
|
2019-11-29 21:47:26 +01:00
|
|
|
|
|
|
|
/// # Examples
|
|
|
|
///
|
|
|
|
/// This shouldn't lint, because the `main` is empty:
|
|
|
|
/// ```
|
|
|
|
/// fn main(){}
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// This shouldn't lint either, because there's a `static`:
|
|
|
|
/// ```
|
|
|
|
/// static ANSWER: i32 = 42;
|
|
|
|
///
|
|
|
|
/// fn main() {
|
|
|
|
/// assert_eq!(42, ANSWER);
|
|
|
|
/// }
|
|
|
|
/// ```
|
2019-12-23 13:11:20 +01:00
|
|
|
///
|
|
|
|
/// Neither should this lint because of `extern crate`:
|
|
|
|
/// ```
|
|
|
|
/// #![feature(test)]
|
|
|
|
/// extern crate test;
|
|
|
|
/// fn main() {
|
|
|
|
/// assert_eq(1u8, test::black_box(1));
|
|
|
|
/// }
|
|
|
|
/// ```
|
2020-03-10 20:19:37 +01:00
|
|
|
///
|
2020-03-10 22:30:07 +01:00
|
|
|
/// We should not lint ignored examples:
|
2020-03-10 20:19:37 +01:00
|
|
|
///
|
|
|
|
/// ```rust,ignore
|
|
|
|
/// fn main() {
|
|
|
|
/// unimplemented!();
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// Or even non-rust examples:
|
|
|
|
///
|
|
|
|
/// ```text
|
|
|
|
/// fn main() {
|
|
|
|
/// is what starts the program
|
|
|
|
/// }
|
|
|
|
/// ```
|
2019-11-29 21:47:26 +01:00
|
|
|
fn no_false_positives() {}
|
|
|
|
|
|
|
|
fn main() {
|
2020-03-10 20:19:37 +01:00
|
|
|
bad_doctests();
|
2019-11-29 21:47:26 +01:00
|
|
|
no_false_positives();
|
|
|
|
}
|