Skip to content

Commit 6be9eec

Browse files
author
Jon Gjengset
committed
Include allowed features in fingerprint
If this weren't the case, a user that compiled, and then re-ran cargo with a particular set of allowed features would not see any breakage even if other unstable features were used. The downside of this is that changing allow-features causes a full re-compile, but that still _seems_ like the right thing to do.
1 parent a0549c0 commit 6be9eec

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/cargo/core/compiler/fingerprint.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,14 +1327,18 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
13271327
// Include metadata since it is exposed as environment variables.
13281328
let m = unit.pkg.manifest().metadata();
13291329
let metadata = util::hash_u64((&m.authors, &m.description, &m.homepage, &m.repository));
1330-
let config = if unit.mode.is_doc() && cx.bcx.config.cli_unstable().rustdoc_map {
1331-
cx.bcx
1332-
.config
1333-
.doc_extern_map()
1334-
.map_or(0, |map| util::hash_u64(map))
1335-
} else {
1336-
0
1337-
};
1330+
let mut config = 0u64;
1331+
if unit.mode.is_doc() && cx.bcx.config.cli_unstable().rustdoc_map {
1332+
config = config.wrapping_add(
1333+
cx.bcx
1334+
.config
1335+
.doc_extern_map()
1336+
.map_or(0, |map| util::hash_u64(map)),
1337+
);
1338+
}
1339+
if let Some(allow_features) = &cx.bcx.config.cli_unstable().allow_features {
1340+
config = config.wrapping_add(util::hash_u64(allow_features));
1341+
}
13381342
let compile_kind = unit.kind.fingerprint_hash();
13391343
Ok(Fingerprint {
13401344
rustc: util::hash_u64(&cx.bcx.rustc().verbose_version),

src/cargo/core/features.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
//! of that page. Update the rest of the documentation to add the new
9393
//! feature.
9494
95-
use std::collections::HashSet;
95+
use std::collections::BTreeSet;
9696
use std::env;
9797
use std::fmt;
9898
use std::str::FromStr;
@@ -554,7 +554,7 @@ impl Features {
554554
#[serde(default, rename_all = "kebab-case")]
555555
pub struct CliUnstable {
556556
pub print_im_a_teapot: bool,
557-
pub allow_features: Option<HashSet<String>>,
557+
pub allow_features: Option<BTreeSet<String>>,
558558

559559
pub unstable_options: bool,
560560
pub no_index_update: bool,

0 commit comments

Comments
 (0)