Skip to content

Commit 8c9bf66

Browse files
committed
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 53fd0c5 commit 8c9bf66

File tree

17 files changed

+36
-9
lines changed

17 files changed

+36
-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
@@ -975,7 +975,8 @@ impl Step for ErrorIndex {
975975
build.run(builder.tool_cmd(Tool::ErrorIndex)
976976
.arg("markdown")
977977
.arg(&output)
978-
.env("CFG_BUILD", &build.build));
978+
.env("CFG_BUILD", &build.build)
979+
.env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()));
979980

980981
markdown_test(builder, compiler, &output);
981982
}

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
@@ -718,6 +718,11 @@ impl Build {
718718
self.config.python.as_ref().unwrap()
719719
}
720720

721+
/// Temporary directory that extended error information is emitted to.
722+
fn extended_error_dir(&self) -> PathBuf {
723+
self.out.join("tmp/extended-error-metadata")
724+
}
725+
721726
/// Tests whether the `compiler` compiling for `target` should be forced to
722727
/// use a stage1 compiler instead.
723728
///

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,5 @@ fn noop() {
175175

176176

177177
// Build the diagnostics array at the end so that the metadata includes error use sites.
178+
#[cfg(not(stage0))] // remove after the next snapshot
178179
__build_diagnostic_array! { librustc, DIAGNOSTICS }

src/librustc_const_eval/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ pub fn provide(providers: &mut Providers) {
5656
}
5757

5858
// Build the diagnostics array at the end so that the metadata includes error use sites.
59+
#[cfg(not(stage0))] // remove after the next snapshot
5960
__build_diagnostic_array! { librustc_const_eval, DIAGNOSTICS }

src/librustc_driver/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,14 @@ fn exit_on_err() -> ! {
12681268
panic!();
12691269
}
12701270

1271+
#[cfg(stage0)]
1272+
pub fn diagnostics_registry() -> errors::registry::Registry {
1273+
use errors::registry::Registry;
1274+
1275+
Registry::new(&[])
1276+
}
1277+
1278+
#[cfg(not(stage0))]
12711279
pub fn diagnostics_registry() -> errors::registry::Registry {
12721280
use errors::registry::Registry;
12731281

src/librustc_metadata/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ pub mod cstore;
5858
pub mod dynamic_lib;
5959
pub mod locator;
6060

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

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ pub fn provide(providers: &mut Providers) {
7979
providers.const_eval = interpret::const_eval_provider;
8080
}
8181

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

src/librustc_passes/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mod mir_stats;
4545
pub mod no_asm;
4646
pub mod static_recursion;
4747

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

5051
pub fn provide(providers: &mut Providers) {

src/librustc_plugin/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ pub mod registry;
8282
pub mod load;
8383
pub mod build;
8484

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

src/librustc_privacy/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1725,4 +1725,5 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
17251725
Rc::new(visitor.access_levels)
17261726
}
17271727

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

src/librustc_resolve/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4089,4 +4089,5 @@ pub enum MakeGlobMap {
40894089
No,
40904090
}
40914091

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

src/librustc_trans/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,5 @@ pub struct CrateInfo {
328328
used_crates_dynamic: Vec<(CrateNum, LibSource)>,
329329
}
330330

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

src/librustc_typeck/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,5 @@ pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait:
380380
(principal, projections)
381381
}
382382

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

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

src/libsyntax/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,5 @@ pub mod ext {
151151
#[cfg(test)]
152152
mod test_snippet;
153153

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

0 commit comments

Comments
 (0)