move manual "extern crate" statements outside auto "fn main" in doctests

This commit is contained in:
QuietMisdreavus 2018-02-09 14:43:21 -06:00
parent 5313e8728f
commit b3d6597855

View File

@ -417,7 +417,8 @@ fn partition_source(s: &str) -> (String, String) {
for line in s.lines() { for line in s.lines() {
let trimline = line.trim(); let trimline = line.trim();
let header = trimline.is_whitespace() || let header = trimline.is_whitespace() ||
trimline.starts_with("#!["); trimline.starts_with("#![") ||
trimline.starts_with("extern crate");
if !header || after_header { if !header || after_header {
after_header = true; after_header = true;
after.push_str(line); after.push_str(line);
@ -858,8 +859,8 @@ use asdf::qwop;
assert_eq!(2+2, 4);"; assert_eq!(2+2, 4);";
let expected = let expected =
"#![allow(unused)] "#![allow(unused)]
fn main() {
extern crate asdf; extern crate asdf;
fn main() {
use asdf::qwop; use asdf::qwop;
assert_eq!(2+2, 4); assert_eq!(2+2, 4);
}".to_string(); }".to_string();