Skip to content

Commit 7d7dfba

Browse files
committedDec 13, 2021
Include rustc version in rustc_span::StableCrateId
Normalize symbol hashes in compiletest. Remove DefId sorting
·
1.88.01.59.0
1 parent a737592 commit 7d7dfba

File tree

50 files changed

+261
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+261
-204
lines changed
 

‎compiler/rustc_resolve/src/late/lifetimes.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
20092009
}
20102010
};
20112011

2012-
let mut def_ids: Vec<_> = defined_by
2012+
let def_ids: Vec<_> = defined_by
20132013
.values()
20142014
.flat_map(|region| match region {
20152015
Region::EarlyBound(_, def_id, _)
@@ -2020,9 +2020,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
20202020
})
20212021
.collect();
20222022

2023-
// ensure that we issue lints in a repeatable order
2024-
def_ids.sort_by_cached_key(|&def_id| self.tcx.def_path_hash(def_id));
2025-
20262023
'lifetimes: for def_id in def_ids {
20272024
debug!("check_uses_for_lifetimes_defined_by_scope: def_id = {:?}", def_id);
20282025

‎compiler/rustc_span/src/def_id.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ impl Borrow<Fingerprint> for DefPathHash {
126126
}
127127
}
128128

129-
/// A [StableCrateId] is a 64 bit hash of the crate name combined with all
130-
/// `-Cmetadata` arguments. It is to [CrateNum] what [DefPathHash] is to
131-
/// [DefId]. It is stable across compilation sessions.
129+
/// A [`StableCrateId`] is a 64 bit hash of the crate name combined with all
130+
/// `-Cmetadata` arguments. It is to [`CrateNum`] what [`DefPathHash`] is to
131+
/// [`DefId`]. It is stable across compilation sessions.
132132
///
133133
/// Since the ID is a hash value there is a (very small) chance that two crates
134-
/// end up with the same [StableCrateId]. The compiler will check for such
134+
/// end up with the same [`StableCrateId`]. The compiler will check for such
135135
/// collisions when loading crates and abort compilation in order to avoid
136136
/// further trouble.
137137
#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)]
@@ -152,7 +152,7 @@ impl StableCrateId {
152152
let mut hasher = StableHasher::new();
153153
crate_name.hash(&mut hasher);
154154

155-
// We don't want the stable crate id to dependent on the order
155+
// We don't want the stable crate ID to depend on the order of
156156
// -C metadata arguments, so sort them:
157157
metadata.sort();
158158
// Every distinct -C metadata value is only incorporated once:
@@ -171,6 +171,12 @@ impl StableCrateId {
171171
// linking against a library of the same name, if this is an executable.
172172
hasher.write(if is_exe { b"exe" } else { b"lib" });
173173

174+
// Also incorporate the rustc version. Otherwise, with -Zsymbol-mangling-version=v0
175+
// and no -Cmetadata, symbols from the same crate compiled with different versions of
176+
// rustc are named the same.
177+
let rustc_version = option_env!("CFG_VERSION").unwrap_or("unknown version").as_bytes();
178+
hasher.write(rustc_version);
179+
174180
StableCrateId(hasher.finish())
175181
}
176182
}

0 commit comments

Comments
 (0)
Please sign in to comment.