Skip to content

Commit a5cf56d

Browse files
alexcrichtonMark-Simulacrum
authored andcommitted
rustc: Don't use relative paths for extended errors
These no longer work now that Cargo changes the cwd of rustc while it's running. Instead use an absolute path that's set by rustbuild.
1 parent 4d90ac3 commit a5cf56d

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

src/bootstrap/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ impl<'a> Builder<'a> {
484484
} else {
485485
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
486486
})
487-
.env("TEST_MIRI", self.config.test_miri.to_string());
488-
487+
.env("TEST_MIRI", self.config.test_miri.to_string())
488+
.env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
489489
if let Some(n) = self.config.rust_codegen_units {
490490
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
491491
}

src/bootstrap/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ impl Step for ErrorIndex {
980980
build.run(builder.tool_cmd(Tool::ErrorIndex)
981981
.arg("markdown")
982982
.arg(&output)
983-
.env("CFG_BUILD", &build.build));
983+
.env("CFG_BUILD", &build.build)
984+
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()));
984985

985986
markdown_test(builder, compiler, &output);
986987
}

src/bootstrap/doc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ impl Step for ErrorIndex {
671671
index.arg(out.join("error-index.html"));
672672

673673
// FIXME: shouldn't have to pass this env var
674-
index.env("CFG_BUILD", &build.build);
674+
index.env("CFG_BUILD", &build.build)
675+
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir());
675676

676677
build.run(&mut index);
677678
}

src/bootstrap/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,11 @@ impl Build {
721721
self.config.python.as_ref().unwrap()
722722
}
723723

724+
/// Temporary directory that extended error information is emitted to.
725+
fn extended_error_dir(&self) -> PathBuf {
726+
self.out.join("tmp/extended-error-metadata")
727+
}
728+
724729
/// Tests whether the `compiler` compiling for `target` should be forced to
725730
/// use a stage1 compiler instead.
726731
///

src/libsyntax/diagnostics/metadata.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
//! currently always a crate name.
1515
1616
use std::collections::BTreeMap;
17-
use std::path::PathBuf;
17+
use std::env;
1818
use std::fs::{remove_file, create_dir_all, File};
1919
use std::io::Write;
20+
use std::path::PathBuf;
2021
use std::error::Error;
2122
use rustc_serialize::json::as_json;
2223

2324
use syntax_pos::{Span, FileName};
2425
use ext::base::ExtCtxt;
2526
use diagnostics::plugin::{ErrorMap, ErrorInfo};
2627

27-
// Default metadata directory to use for extended error JSON.
28-
const ERROR_METADATA_PREFIX: &'static str = "tmp/extended-errors";
29-
3028
/// JSON encodable/decodable version of `ErrorInfo`.
3129
#[derive(PartialEq, RustcDecodable, RustcEncodable)]
3230
pub struct ErrorMetadata {
@@ -59,7 +57,10 @@ impl ErrorLocation {
5957
///
6058
/// See `output_metadata`.
6159
pub fn get_metadata_dir(prefix: &str) -> PathBuf {
62-
PathBuf::from(ERROR_METADATA_PREFIX).join(prefix)
60+
env::var_os("RUSTC_ERROR_METADATA_DST")
61+
.map(PathBuf::from)
62+
.expect("env var `RUSTC_ERROR_METADATA_DST` isn't set")
63+
.join(prefix)
6364
}
6465

6566
/// Map `name` to a path in the given directory: <directory>/<name>.json

0 commit comments

Comments
 (0)