Skip to content

Commit 56ab485

Browse files
committed
support rustdoc test from stdin to rustc
1 parent fbdf1d2 commit 56ab485

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc_driver/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,15 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>, Option
439439
} else {
440440
None
441441
};
442+
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
443+
let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").
444+
expect("when UNSTABLE_RUSTDOC_TEST_PATH is set \
445+
UNSTABLE_RUSTDOC_TEST_LINE also needs to be set");
446+
let line = isize::from_str_radix(&line, 10).
447+
expect("UNSTABLE_RUSTDOC_TEST_LINE needs to be an number");
448+
let file_name = FileName::doc_test_source_code(PathBuf::from(path), line);
449+
return Some((Input::Str { name: file_name, input: src }, None, err));
450+
}
442451
Some((Input::Str { name: FileName::anon_source_code(&src), input: src },
443452
None, err))
444453
} else {

0 commit comments

Comments
 (0)