Previously we would only warn on Rust code but we can also do so when
testing markdown (the diag::Handler is available).
#![allow(non_camel_case_types)]
#![allow(non_camel_case_types)]
use std::cell::RefCell;
use std::collections::{HashMap, VecDeque};
use std::default::Default;
use std::cell::RefCell;
use std::collections::{HashMap, VecDeque};
use std::default::Default;
use std::str;
use syntax::feature_gate::UnstableFeatures;
use syntax::codemap::Span;
use std::str;
use syntax::feature_gate::UnstableFeatures;
use syntax::codemap::Span;
use html::render::derive_id;
use html::toc::TocBuilder;
use html::render::derive_id;
use html::toc::TocBuilder;
}
pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector, position: Span,
}
pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector, position: Span,
- sess: Option<&session::Session>) {
+ handler: &errors::Handler) {
tests.set_position(position);
let is_nightly = UnstableFeatures::from_environment().is_nightly_build();
tests.set_position(position);
let is_nightly = UnstableFeatures::from_environment().is_nightly_build();
line, filename, block_info.allow_fail);
prev_offset = offset;
} else {
line, filename, block_info.allow_fail);
prev_offset = offset;
} else {
- if let Some(ref sess) = sess {
- sess.span_warn(position, "invalid start of a new code block");
- }
+ handler.span_warn(position, "invalid start of a new code block");
true, opts, maybe_sysroot, None,
Some(PathBuf::from(input)),
linker, edition);
true, opts, maybe_sysroot, None,
Some(PathBuf::from(input)),
linker, edition);
- find_testable_code(&input_str, &mut collector, DUMMY_SP, None);
+ find_testable_code(&input_str, &mut collector, DUMMY_SP, diag);
test_args.insert(0, "rustdoctest".to_string());
testing::test_main(&test_args, collector.tests,
testing::Options::new().display_output(display_warnings));
test_args.insert(0, "rustdoctest".to_string());
testing::test_main(&test_args, collector.tests,
testing::Options::new().display_output(display_warnings));
markdown::find_testable_code(&doc,
self.collector,
attrs.span.unwrap_or(DUMMY_SP),
markdown::find_testable_code(&doc,
self.collector,
attrs.span.unwrap_or(DUMMY_SP),
+ self.sess.diagnostic());