Skip to content

Commit bff2d2a

Browse files
committed
Auto merge of #4241 - Keruspe:rust-1.19.0, r=alexcrichton
[beta] hash '__CARGO_DEFAULT_LIB_METADATA' in metadata for rustc This is a backport of #4239 for beta
2 parents c9bdd3e + 225aed0 commit bff2d2a

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,17 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
442442
// Note, though, that the compiler's build system at least wants
443443
// path dependencies (eg libstd) to have hashes in filenames. To account for
444444
// that we have an extra hack here which reads the
445-
// `__CARGO_DEFAULT_METADATA` environment variable and creates a
445+
// `__CARGO_DEFAULT_LIB_METADATA` environment variable and creates a
446446
// hash in the filename if that's present.
447447
//
448448
// This environment variable should not be relied on! It's
449449
// just here for rustbuild. We need a more principled method
450450
// doing this eventually.
451+
let __cargo_default_lib_metadata = env::var("__CARGO_DEFAULT_LIB_METADATA");
451452
if !unit.profile.test &&
452453
(unit.target.is_dylib() || unit.target.is_cdylib()) &&
453454
unit.pkg.package_id().source_id().is_path() &&
454-
!env::var("__CARGO_DEFAULT_LIB_METADATA").is_ok() {
455+
!__cargo_default_lib_metadata.is_ok() {
455456
return None;
456457
}
457458

@@ -491,6 +492,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
491492
rustc.verbose_version.hash(&mut hasher);
492493
}
493494

495+
// Seed the contents of __CARGO_DEFAULT_LIB_METADATA to the hasher if present.
496+
// This should be the release channel, to get a different hash for each channel.
497+
if let Ok(ref channel) = __cargo_default_lib_metadata {
498+
channel.hash(&mut hasher);
499+
}
500+
494501
Some(Metadata(hasher.finish()))
495502
}
496503

tests/bench.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ fn cargo_bench_failing_test() {
242242
[FINISHED] release [optimized] target(s) in [..]
243243
[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
244244
thread '[..]' panicked at 'assertion failed: \
245-
`(left == right)` (left: \
246-
`\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:14
247-
[..]
248-
", p.url()))
245+
`(left == right)`[..]", p.url()))
246+
.with_stderr_contains("[..]left: `\"hello\"`[..]")
247+
.with_stderr_contains("[..]right: `\"nope\"`[..]")
248+
.with_stderr_contains("[..]src[/]foo.rs:14")
249249
.with_status(101));
250250
}
251251

tests/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ suffix = env::consts::DLL_SUFFIX,
849849
assert_that(p.cargo("clean"), execs().with_status(0));
850850

851851
// If you set the env-var, then we expect metadata on libbar
852-
assert_that(p.cargo("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "1"),
852+
assert_that(p.cargo("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "stable"),
853853
execs().with_status(0).with_stderr(&format!("\
854854
[COMPILING] bar v0.0.1 ({url}/bar)
855855
[RUNNING] `rustc --crate-name bar bar[/]src[/]lib.rs --crate-type dylib \

tests/test.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ test test_hello ... FAILED
215215
failures:
216216
217217
---- test_hello stdout ----
218-
<tab>thread 'test_hello' panicked at 'assertion failed: \
219-
`(left == right)` (left: \
220-
`\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:12
221-
")
218+
<tab>thread 'test_hello' panicked at 'assertion failed:[..]")
219+
.with_stdout_contains("[..]`(left == right)`[..]")
220+
.with_stdout_contains("[..]left: `\"hello\"`,[..]")
221+
.with_stdout_contains("[..]right: `\"nope\"`[..]")
222+
.with_stdout_contains("[..]src[/]foo.rs:12[..]")
222223
.with_stdout_contains("\
223224
failures:
224225
test_hello

0 commit comments

Comments
 (0)