This commit refactors `SourceMap` and most importantly `RealFileName` to make it self-contained in order to achieve cross-compiler consistency. This is achieved: - by making `RealFileName` immutable - by only having `SourceMap::to_real_filename` create `RealFileName` - by also making `RealFileName` holds it's working directory, it's embeddable name and the remapped scopes - by making most `FileName` and `RealFileName` methods take a scope as an argument In order for `SourceMap::to_real_filename` to know which scopes to apply `FilePathMapping` now takes the current remapping scopes to apply, which makes `FileNameDisplayPreference` and company useless and are removed. The scopes type `RemapPathScopeComponents` was moved from `rustc_session::config` to `rustc_span`. The previous system for scoping the local/remapped filenames `RemapFileNameExt::for_scope` is no longer useful as it's replaced by methods on `FileName` and `RealFileName`.
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
//@ needs-target-std
|
|
|
|
use run_make_support::{Rustc, cwd, diff, rust_lib_name, rustc};
|
|
|
|
fn rustc_with_common_args() -> Rustc {
|
|
let mut rustc = rustc();
|
|
rustc.remap_path_prefix(cwd(), "$DIR");
|
|
rustc.edition("2018"); // Don't require `extern crate`
|
|
rustc
|
|
}
|
|
|
|
fn main() {
|
|
rustc_with_common_args()
|
|
.input(cwd().join("foo-v1.rs"))
|
|
.crate_type("rlib")
|
|
.crate_name("foo")
|
|
.extra_filename("-v1")
|
|
.metadata("-v1")
|
|
.run();
|
|
|
|
rustc_with_common_args()
|
|
.input(cwd().join("foo-v2.rs"))
|
|
.crate_type("rlib")
|
|
.crate_name("foo")
|
|
.extra_filename("-v2")
|
|
.metadata("-v2")
|
|
.run();
|
|
|
|
rustc_with_common_args()
|
|
.input(cwd().join("re-export-foo.rs"))
|
|
.crate_type("rlib")
|
|
.extern_("foo", rust_lib_name("foo-v2"))
|
|
.run();
|
|
|
|
let stderr = rustc_with_common_args()
|
|
.input("main.rs")
|
|
.extern_("foo", rust_lib_name("foo-v1"))
|
|
.extern_("re_export_foo", rust_lib_name("re_export_foo"))
|
|
.library_search_path(cwd())
|
|
.ui_testing()
|
|
.run_fail()
|
|
.stderr_utf8();
|
|
|
|
diff().expected_file("main.stderr").normalize(r"\\", "/").actual_text("(rustc)", &stderr).run();
|
|
}
|