Skip to content

Commit

Permalink
rustc: Don't use relative paths for extended errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton committed Jan 4, 2018
1 parent 53fd0c5 commit 8c9bf66
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ impl<'a> Builder<'a> {
} else {
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
})
.env("TEST_MIRI", self.config.test_miri.to_string());

.env("TEST_MIRI", self.config.test_miri.to_string())
.env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
if let Some(n) = self.config.rust_codegen_units {
cargo.env("RUSTC_CODEGEN_UNITS", n.to_string());
}
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,8 @@ impl Step for ErrorIndex {
build.run(builder.tool_cmd(Tool::ErrorIndex)
.arg("markdown")
.arg(&output)
.env("CFG_BUILD", &build.build));
.env("CFG_BUILD", &build.build)
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()));

markdown_test(builder, compiler, &output);
}
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ impl Step for ErrorIndex {
index.arg(out.join("error-index.html"));

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

build.run(&mut index);
}
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ impl Build {
self.config.python.as_ref().unwrap()
}

/// Temporary directory that extended error information is emitted to.
fn extended_error_dir(&self) -> PathBuf {
self.out.join("tmp/extended-error-metadata")
}

/// Tests whether the `compiler` compiling for `target` should be forced to
/// use a stage1 compiler instead.
///
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,5 @@ fn noop() {


// Build the diagnostics array at the end so that the metadata includes error use sites.
#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_const_eval/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ pub fn provide(providers: &mut Providers) {
}

// Build the diagnostics array at the end so that the metadata includes error use sites.
#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_const_eval, DIAGNOSTICS }
8 changes: 8 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,14 @@ fn exit_on_err() -> ! {
panic!();
}

#[cfg(stage0)]
pub fn diagnostics_registry() -> errors::registry::Registry {
use errors::registry::Registry;

Registry::new(&[])
}

#[cfg(not(stage0))]
pub fn diagnostics_registry() -> errors::registry::Registry {
use errors::registry::Registry;

Expand Down
1 change: 1 addition & 0 deletions src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ pub mod cstore;
pub mod dynamic_lib;
pub mod locator;

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_metadata, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ pub fn provide(providers: &mut Providers) {
providers.const_eval = interpret::const_eval_provider;
}

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_mir, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_passes/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod mir_stats;
pub mod no_asm;
pub mod static_recursion;

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_passes, DIAGNOSTICS }

pub fn provide(providers: &mut Providers) {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_plugin/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ pub mod registry;
pub mod load;
pub mod build;

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_plugin, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1725,4 +1725,5 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Rc::new(visitor.access_levels)
}

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_privacy, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4089,4 +4089,5 @@ pub enum MakeGlobMap {
No,
}

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_resolve, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,5 @@ pub struct CrateInfo {
used_crates_dynamic: Vec<(CrateNum, LibSource)>,
}

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_trans, DIAGNOSTICS }
1 change: 1 addition & 0 deletions src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,5 @@ pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait:
(principal, projections)
}

#[cfg(not(stage0))] // remove after the next snapshot
__build_diagnostic_array! { librustc_typeck, DIAGNOSTICS }
11 changes: 6 additions & 5 deletions src/libsyntax/diagnostics/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
//! 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;

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 {
Expand Down Expand Up @@ -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: <directory>/<name>.json
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

0 comments on commit 8c9bf66

Please sign in to comment.