From 8c9bf663d4a8074e4955d1ad3f85a3b82e946297 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 2 Jan 2018 16:21:35 -0800 Subject: 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. --- src/libsyntax/diagnostics/metadata.rs | 11 ++++++----- src/libsyntax/lib.rs | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/diagnostics/metadata.rs b/src/libsyntax/diagnostics/metadata.rs index 5f06475919f..dc01a79190b 100644 --- a/src/libsyntax/diagnostics/metadata.rs +++ b/src/libsyntax/diagnostics/metadata.rs @@ -14,9 +14,10 @@ //! currently always a crate name. use std::collections::BTreeMap; -use std::path::PathBuf; +use std::env; use std::fs::{remove_file, create_dir_all, File}; use std::io::Write; +use std::path::PathBuf; use std::error::Error; use rustc_serialize::json::as_json; @@ -24,9 +25,6 @@ use syntax_pos::{Span, FileName}; use ext::base::ExtCtxt; use diagnostics::plugin::{ErrorMap, ErrorInfo}; -// Default metadata directory to use for extended error JSON. -const ERROR_METADATA_PREFIX: &'static str = "tmp/extended-errors"; - /// JSON encodable/decodable version of `ErrorInfo`. #[derive(PartialEq, RustcDecodable, RustcEncodable)] pub struct ErrorMetadata { @@ -59,7 +57,10 @@ impl ErrorLocation { /// /// See `output_metadata`. pub fn get_metadata_dir(prefix: &str) -> PathBuf { - PathBuf::from(ERROR_METADATA_PREFIX).join(prefix) + env::var_os("RUSTC_ERROR_METADATA_DST") + .map(PathBuf::from) + .expect("env var `RUSTC_ERROR_METADATA_DST` isn't set") + .join(prefix) } /// Map `name` to a path in the given directory: /.json diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 0b51f2e9814..d7f7ff554db 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -151,4 +151,5 @@ pub mod ext { #[cfg(test)] mod test_snippet; +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { libsyntax, DIAGNOSTICS } -- cgit 1.4.1-3-g733a5