Un-remap rustc-dev component paths
This commit is contained in:
@@ -1759,6 +1759,17 @@ impl<'a> CrateMetadataRef<'a> {
|
||||
&mut name,
|
||||
);
|
||||
|
||||
// If this file is under $sysroot/lib/rustlib/rustc-src/
|
||||
// and the user wish to simulate remapping with -Z simulate-remapped-rust-src-base,
|
||||
// then we change `name` to a similar state as if the rust was bootstrapped
|
||||
// with `remap-debuginfo = true`.
|
||||
try_to_translate_real_to_virtual(
|
||||
option_env!("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR"),
|
||||
&sess.opts.real_rustc_dev_source_base_dir,
|
||||
"compiler",
|
||||
&mut name,
|
||||
);
|
||||
|
||||
// If this file's path has been remapped to `/rustc/$hash`,
|
||||
// we might be able to reverse that.
|
||||
//
|
||||
@@ -1770,6 +1781,17 @@ impl<'a> CrateMetadataRef<'a> {
|
||||
&mut name,
|
||||
);
|
||||
|
||||
// If this file's path has been remapped to `/rustc-dev/$hash`,
|
||||
// we might be able to reverse that.
|
||||
//
|
||||
// NOTE: if you update this, you might need to also update bootstrap's code for generating
|
||||
// the `rustc-dev` component in `Src::run` in `src/bootstrap/dist.rs`.
|
||||
try_to_translate_virtual_to_real(
|
||||
option_env!("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR"),
|
||||
&sess.opts.real_rustc_dev_source_base_dir,
|
||||
&mut name,
|
||||
);
|
||||
|
||||
let local_version = sess.source_map().new_imported_source_file(
|
||||
name,
|
||||
src_hash,
|
||||
|
||||
@@ -1364,6 +1364,7 @@ impl Default for Options {
|
||||
cli_forced_local_thinlto_off: false,
|
||||
remap_path_prefix: Vec::new(),
|
||||
real_rust_source_base_dir: None,
|
||||
real_rustc_dev_source_base_dir: None,
|
||||
edition: DEFAULT_EDITION,
|
||||
json_artifact_notifications: false,
|
||||
json_unused_externs: JsonUnusedExterns::No,
|
||||
@@ -2713,6 +2714,10 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||
// This is the location used by the `rust-src` `rustup` component.
|
||||
real_source_base_dir("lib/rustlib/src/rust", "library/std/src/lib.rs");
|
||||
|
||||
let real_rustc_dev_source_base_dir =
|
||||
// This is the location used by the `rustc-dev` `rustup` component.
|
||||
real_source_base_dir("lib/rustlib/rustc-src/rust", "compiler/rustc/src/main.rs");
|
||||
|
||||
let mut search_paths = vec![];
|
||||
for s in &matches.opt_strs("L") {
|
||||
search_paths.push(SearchPath::from_cli_opt(
|
||||
@@ -2766,6 +2771,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||
cli_forced_local_thinlto_off: disable_local_thinlto,
|
||||
remap_path_prefix,
|
||||
real_rust_source_base_dir,
|
||||
real_rustc_dev_source_base_dir,
|
||||
edition,
|
||||
json_artifact_notifications,
|
||||
json_unused_externs,
|
||||
|
||||
@@ -397,6 +397,15 @@ top_level_options!(
|
||||
/// (the `rust.remap-debuginfo` option in `bootstrap.toml`).
|
||||
real_rust_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH],
|
||||
|
||||
/// Base directory containing the `compiler/` directory for the rustc sources.
|
||||
/// Right now it's always `$sysroot/lib/rustlib/rustc-src/rust`
|
||||
/// (i.e. the `rustup` `rustc-dev` component).
|
||||
///
|
||||
/// This directory is what the virtual `/rustc-dev/$hash` is translated back to,
|
||||
/// if Rust was built with path remapping to `/rustc/$hash` enabled
|
||||
/// (the `rust.remap-debuginfo` option in `bootstrap.toml`).
|
||||
real_rustc_dev_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH],
|
||||
|
||||
edition: Edition [TRACKED],
|
||||
|
||||
/// `true` if we're emitting JSON blobs about each artifact produced
|
||||
|
||||
@@ -113,6 +113,8 @@ Compiletest makes the following replacements on the compiler output:
|
||||
- The base directory where the test's output goes is replaced with
|
||||
`$TEST_BUILD_DIR`. This only comes up in a few rare circumstances. Example:
|
||||
`/path/to/rust/build/x86_64-unknown-linux-gnu/test/ui`
|
||||
- The real directory to the standard library source is replaced with `$SRC_DIR_REAL`.
|
||||
- The real directory to the compiler source is replaced with `$COMPILER_DIR_REAL`.
|
||||
- Tabs are replaced with `\t`.
|
||||
- Backslashes (`\`) are converted to forward slashes (`/`) within paths (using a
|
||||
heuristic). This helps normalize differences with Windows-style paths.
|
||||
|
||||
@@ -2371,6 +2371,12 @@ impl<'test> TestCx<'test> {
|
||||
let rust_src_dir = rust_src_dir.read_link_utf8().unwrap_or(rust_src_dir.to_path_buf());
|
||||
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");
|
||||
|
||||
// Real paths into the compiler
|
||||
let rustc_src_dir = &self.config.sysroot_base.join("lib/rustlib/rustc-src/rust");
|
||||
rustc_src_dir.try_exists().expect(&*format!("{} should exists", rustc_src_dir));
|
||||
let rustc_src_dir = rustc_src_dir.read_link_utf8().unwrap_or(rustc_src_dir.to_path_buf());
|
||||
normalize_path(&rustc_src_dir.join("compiler"), "$COMPILER_DIR_REAL");
|
||||
|
||||
// eg.
|
||||
// /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui/<test_dir>/$name.$revision.$mode/
|
||||
normalize_path(&self.output_base_dir(), "$TEST_BUILD_DIR");
|
||||
|
||||
15
tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr
Normal file
15
tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr
Normal file
@@ -0,0 +1,15 @@
|
||||
error[E0277]: the trait bound `NotAValidResultType: VisitorResult` is not satisfied
|
||||
--> $DIR/rustc-dev-remap.rs:LL:COL
|
||||
|
|
||||
LL | type Result = NotAValidResultType;
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `VisitorResult` is not implemented for `NotAValidResultType`
|
||||
|
|
||||
= help: the following other types implement trait `VisitorResult`:
|
||||
()
|
||||
ControlFlow<T>
|
||||
note: required by a bound in `rustc_ast::visit::Visitor::Result`
|
||||
--> /rustc-dev/xyz/compiler/rustc_ast/src/visit.rs:LL:COL
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
18
tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr
Normal file
18
tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr
Normal file
@@ -0,0 +1,18 @@
|
||||
error[E0277]: the trait bound `NotAValidResultType: VisitorResult` is not satisfied
|
||||
--> $DIR/rustc-dev-remap.rs:LL:COL
|
||||
|
|
||||
LL | type Result = NotAValidResultType;
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `VisitorResult` is not implemented for `NotAValidResultType`
|
||||
|
|
||||
= help: the following other types implement trait `VisitorResult`:
|
||||
()
|
||||
ControlFlow<T>
|
||||
note: required by a bound in `rustc_ast::visit::Visitor::Result`
|
||||
--> $COMPILER_DIR_REAL/rustc_ast/src/visit.rs:LL:COL
|
||||
|
|
||||
LL | type Result: VisitorResult = ();
|
||||
| ^^^^^^^^^^^^^ required by this bound in `Visitor::Result`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
30
tests/ui-fulldeps/rustc-dev-remap.rs
Normal file
30
tests/ui-fulldeps/rustc-dev-remap.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
//@ check-fail
|
||||
//
|
||||
//@ ignore-stage1
|
||||
//@ ignore-cross-compile
|
||||
//@ ignore-remote
|
||||
//
|
||||
//@ revisions: only-remap remap-unremap
|
||||
//@ compile-flags: -Z simulate-remapped-rust-src-base=/rustc-dev/xyz
|
||||
//@ [remap-unremap]compile-flags: -Ztranslate-remapped-path-to-local-path=yes
|
||||
|
||||
// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically
|
||||
// as the remapped revision will begin with $COMPILER_DIR_REAL,
|
||||
// so we have to do it ourselves.
|
||||
//@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:COL"
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_ast;
|
||||
|
||||
use rustc_ast::visit::Visitor;
|
||||
|
||||
struct MyStruct;
|
||||
struct NotAValidResultType;
|
||||
|
||||
impl Visitor<'_> for MyStruct {
|
||||
type Result = NotAValidResultType;
|
||||
//~^ ERROR the trait bound `NotAValidResultType: VisitorResult` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user