use rustc_metadata::cstore::CStore;
use rustc_resolve::MakeGlobMap;
use syntax::ast;
-use syntax::codemap::CodeMap;
+use syntax::source_map::SourceMap;
use syntax::edition::Edition;
use syntax::feature_gate::UnstableFeatures;
use syntax::with_globals;
..config::Options::default()
};
driver::spawn_thread_pool(sessopts, |sessopts| {
- let codemap = Lrc::new(CodeMap::new(sessopts.file_path_mapping()));
+ let source_map = Lrc::new(SourceMap::new(sessopts.file_path_mapping()));
let handler =
errors::Handler::with_tty_emitter(ColorConfig::Auto,
true, false,
- Some(codemap.clone()));
+ Some(source_map.clone()));
let mut sess = session::build_session_(
- sessopts, Some(input_path.to_owned()), handler, codemap.clone(),
+ sessopts, Some(input_path.to_owned()), handler, source_map.clone(),
);
let codegen_backend = rustc_driver::get_codegen_backend(&sess);
let cstore = CStore::new(codegen_backend.metadata_loader());
false,
opts,
maybe_sysroot,
- Some(codemap),
+ Some(source_map),
None,
linker,
edition
// never wrap the test in `fn main() { ... }`
let (test, line_offset) = make_test(test, Some(cratename), as_test_harness, opts);
// FIXME(#44940): if doctests ever support path remapping, then this filename
- // needs to be the result of CodeMap::span_to_unmapped_path
+ // needs to be the result of SourceMap::span_to_unmapped_path
let input = config::Input::Str {
name: filename.to_owned(),
input: test.to_owned(),
let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout()));
let (libdir, outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| {
- let codemap = Lrc::new(CodeMap::new_doctest(
+ let source_map = Lrc::new(SourceMap::new_doctest(
sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize
));
let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()),
- Some(codemap.clone()),
+ Some(source_map.clone()),
false,
false);
let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter);
let mut sess = session::build_session_(
- sessopts, None, diagnostic_handler, codemap,
+ sessopts, None, diagnostic_handler, source_map,
);
let codegen_backend = rustc_driver::get_codegen_backend(&sess);
let cstore = CStore::new(codegen_backend.metadata_loader());
opts: TestOptions,
maybe_sysroot: Option<PathBuf>,
position: Span,
- codemap: Option<Lrc<CodeMap>>,
+ source_map: Option<Lrc<SourceMap>>,
filename: Option<PathBuf>,
linker: Option<PathBuf>,
edition: Edition,
impl Collector {
pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, cg: CodegenOptions,
externs: Externs, use_headers: bool, opts: TestOptions,
- maybe_sysroot: Option<PathBuf>, codemap: Option<Lrc<CodeMap>>,
+ maybe_sysroot: Option<PathBuf>, source_map: Option<Lrc<SourceMap>>,
filename: Option<PathBuf>, linker: Option<PathBuf>, edition: Edition) -> Collector {
Collector {
tests: Vec::new(),
opts,
maybe_sysroot,
position: DUMMY_SP,
- codemap,
+ source_map,
filename,
linker,
edition,
let opts = self.opts.clone();
let maybe_sysroot = self.maybe_sysroot.clone();
let linker = self.linker.clone();
- let edition = self.edition;
+ let edition = config.edition.unwrap_or(self.edition);
debug!("Creating test {}: {}", name, test);
self.tests.push(testing::TestDescAndFn {
desc: testing::TestDesc {
}
pub fn get_line(&self) -> usize {
- if let Some(ref codemap) = self.codemap {
+ if let Some(ref source_map) = self.source_map {
let line = self.position.lo().to_usize();
- let line = codemap.lookup_char_pos(BytePos(line as u32)).line;
+ let line = source_map.lookup_char_pos(BytePos(line as u32)).line;
if line > 0 { line - 1 } else { line }
} else {
0
}
fn get_filename(&self) -> FileName {
- if let Some(ref codemap) = self.codemap {
- let filename = codemap.span_to_filename(self.position);
+ if let Some(ref source_map) = self.source_map {
+ let filename = source_map.span_to_filename(self.position);
if let FileName::Real(ref filename) = filename {
if let Ok(cur_dir) = env::current_dir() {
if let Ok(path) = filename.strip_prefix(&cur_dir) {
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
- assert_eq!(output, (expected.clone(), 2));
+ assert_eq!(output, (expected, 2));
}
#[test]
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
- assert_eq!(output, (expected.clone(), 2));
+ assert_eq!(output, (expected, 2));
}
#[test]
//Ceci n'est pas une `fn main`
assert_eq!(2+2, 4);".to_string();
let output = make_test(input, None, true, &opts);
- assert_eq!(output, (expected.clone(), 1));
+ assert_eq!(output, (expected, 1));
}
#[test]
assert_eq!(2+2, 4);
}".to_string();
let output = make_test(input, None, false, &opts);
- assert_eq!(output, (expected.clone(), 1));
+ assert_eq!(output, (expected, 1));
}
}