Skip to content

Commit c2efcc4

Browse files
committed
Auto merge of #154862 - jhpratt:rollup-mjtl7mx, r=jhpratt
Rollup of 4 pull requests Successful merges: - #152853 (deny-by-default & report in deps `uninhabited_static`) - #153615 (fixed generics of crate node ICE) - #154744 (Remove `Clone` impl for `StableHashingContext`.) - #154841 (add regression test for Redundant memory strores with mut parameters …)
2 parents 9602bda + b96adb3 commit c2efcc4

File tree

29 files changed

+476
-114
lines changed

29 files changed

+476
-114
lines changed

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
175175

176176
// FIXME: Sorting this is unnecessary since we are sorting later anyway.
177177
// Can we skip the later sorting?
178-
let sorted = tcx.with_stable_hashing_context(|hcx| {
179-
tcx.reachable_non_generics(LOCAL_CRATE).to_sorted(&hcx, true)
178+
let sorted = tcx.with_stable_hashing_context(|mut hcx| {
179+
tcx.reachable_non_generics(LOCAL_CRATE).to_sorted(&mut hcx, true)
180180
});
181181

182182
let mut symbols: Vec<_> =

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub trait HashStable<Hcx> {
5050
/// bringing maps into a predictable order before hashing them.
5151
pub trait ToStableHashKey<Hcx> {
5252
type KeyType: Ord + Sized + HashStable<Hcx>;
53-
fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType;
53+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType;
5454
}
5555

5656
/// Trait for marking a type as having a sort order that is
@@ -427,15 +427,15 @@ impl StableOrd for String {
427427
impl<Hcx> ToStableHashKey<Hcx> for String {
428428
type KeyType = String;
429429
#[inline]
430-
fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType {
430+
fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType {
431431
self.clone()
432432
}
433433
}
434434

435435
impl<Hcx, T1: ToStableHashKey<Hcx>, T2: ToStableHashKey<Hcx>> ToStableHashKey<Hcx> for (T1, T2) {
436436
type KeyType = (T1::KeyType, T2::KeyType);
437437
#[inline]
438-
fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType {
438+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType {
439439
(self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx))
440440
}
441441
}

compiler/rustc_data_structures/src/unord.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a, T: Copy + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I> {
143143

144144
impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
145145
#[inline]
146-
pub fn into_sorted<Hcx>(self, hcx: &Hcx) -> Vec<T>
146+
pub fn into_sorted<Hcx>(self, hcx: &mut Hcx) -> Vec<T>
147147
where
148148
T: ToStableHashKey<Hcx>,
149149
{
@@ -168,7 +168,7 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
168168
}
169169

170170
#[inline]
171-
pub fn collect_sorted<Hcx, C>(self, hcx: &Hcx, cache_sort_key: bool) -> C
171+
pub fn collect_sorted<Hcx, C>(self, hcx: &mut Hcx, cache_sort_key: bool) -> C
172172
where
173173
T: ToStableHashKey<Hcx>,
174174
C: FromIterator<T> + BorrowMut<[T]>,
@@ -315,7 +315,7 @@ impl<V: Eq + Hash> UnordSet<V> {
315315
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
316316
/// for `V` is expensive (e.g. a `DefId -> DefPathHash` lookup).
317317
#[inline]
318-
pub fn to_sorted<Hcx>(&self, hcx: &Hcx, cache_sort_key: bool) -> Vec<&V>
318+
pub fn to_sorted<Hcx>(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<&V>
319319
where
320320
V: ToStableHashKey<Hcx>,
321321
{
@@ -357,7 +357,7 @@ impl<V: Eq + Hash> UnordSet<V> {
357357
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
358358
/// for `V` is expensive (e.g. a `DefId -> DefPathHash` lookup).
359359
#[inline]
360-
pub fn into_sorted<Hcx>(self, hcx: &Hcx, cache_sort_key: bool) -> Vec<V>
360+
pub fn into_sorted<Hcx>(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<V>
361361
where
362362
V: ToStableHashKey<Hcx>,
363363
{
@@ -555,7 +555,7 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
555555
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
556556
/// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup).
557557
#[inline]
558-
pub fn to_sorted<Hcx>(&self, hcx: &Hcx, cache_sort_key: bool) -> Vec<(&K, &V)>
558+
pub fn to_sorted<Hcx>(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(&K, &V)>
559559
where
560560
K: ToStableHashKey<Hcx>,
561561
{
@@ -582,7 +582,7 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
582582
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
583583
/// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup).
584584
#[inline]
585-
pub fn into_sorted<Hcx>(self, hcx: &Hcx, cache_sort_key: bool) -> Vec<(K, V)>
585+
pub fn into_sorted<Hcx>(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(K, V)>
586586
where
587587
K: ToStableHashKey<Hcx>,
588588
{
@@ -610,7 +610,11 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
610610
/// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation
611611
/// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup).
612612
#[inline]
613-
pub fn values_sorted<Hcx>(&self, hcx: &Hcx, cache_sort_key: bool) -> impl Iterator<Item = &V>
613+
pub fn values_sorted<Hcx>(
614+
&self,
615+
hcx: &mut Hcx,
616+
cache_sort_key: bool,
617+
) -> impl Iterator<Item = &V>
614618
where
615619
K: ToStableHashKey<Hcx>,
616620
{
@@ -710,7 +714,7 @@ impl<Hcx, V: Hash + Eq + HashStable<Hcx>> HashStable<Hcx> for UnordBag<V> {
710714

711715
#[inline]
712716
fn to_sorted_vec<Hcx, T, K, I>(
713-
hcx: &Hcx,
717+
hcx: &mut Hcx,
714718
iter: I,
715719
cache_sort_key: bool,
716720
extract_key: fn(&T) -> &K,

compiler/rustc_hir/src/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for Namespace {
716716
type KeyType = Namespace;
717717

718718
#[inline]
719-
fn to_stable_hash_key(&self, _: &Hcx) -> Namespace {
719+
fn to_stable_hash_key(&self, _: &mut Hcx) -> Namespace {
720720
*self
721721
}
722722
}

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for BodyId {
1313
type KeyType = (DefPathHash, ItemLocalId);
1414

1515
#[inline]
16-
fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) {
16+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) {
1717
let BodyId { hir_id } = *self;
1818
hir_id.to_stable_hash_key(hcx)
1919
}
@@ -23,7 +23,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ItemId {
2323
type KeyType = DefPathHash;
2424

2525
#[inline]
26-
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
26+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
2727
self.owner_id.def_id.to_stable_hash_key(hcx)
2828
}
2929
}
@@ -32,7 +32,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for TraitItemId {
3232
type KeyType = DefPathHash;
3333

3434
#[inline]
35-
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
35+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
3636
self.owner_id.def_id.to_stable_hash_key(hcx)
3737
}
3838
}
@@ -41,7 +41,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ImplItemId {
4141
type KeyType = DefPathHash;
4242

4343
#[inline]
44-
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
44+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
4545
self.owner_id.def_id.to_stable_hash_key(hcx)
4646
}
4747
}
@@ -50,7 +50,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ForeignItemId {
5050
type KeyType = DefPathHash;
5151

5252
#[inline]
53-
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
53+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
5454
self.owner_id.def_id.to_stable_hash_key(hcx)
5555
}
5656
}

compiler/rustc_hir_id/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for OwnerId {
6565
type KeyType = DefPathHash;
6666

6767
#[inline]
68-
fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash {
68+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
6969
hcx.def_path_hash(self.to_def_id())
7070
}
7171
}
@@ -180,7 +180,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for HirId {
180180
type KeyType = (DefPathHash, ItemLocalId);
181181

182182
#[inline]
183-
fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) {
183+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) {
184184
let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx);
185185
(def_path_hash, self.local_id)
186186
}
@@ -190,7 +190,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ItemLocalId {
190190
type KeyType = ItemLocalId;
191191

192192
#[inline]
193-
fn to_stable_hash_key(&self, _: &Hcx) -> ItemLocalId {
193+
fn to_stable_hash_key(&self, _: &mut Hcx) -> ItemLocalId {
194194
*self
195195
}
196196
}

compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
375375

376376
impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
377377
fn eval_closure_size(&mut self) {
378-
self.tcx().with_stable_hashing_context(|ref hcx| {
378+
self.tcx().with_stable_hashing_context(|mut hcx| {
379379
let fcx_typeck_results = self.fcx.typeck_results.borrow();
380380

381381
self.typeck_results.closure_size_eval = fcx_typeck_results
382382
.closure_size_eval
383-
.to_sorted(hcx, false)
383+
.to_sorted(&mut hcx, false)
384384
.into_iter()
385385
.map(|(&closure_def_id, data)| {
386386
let closure_hir_id = self.tcx().local_def_id_to_hir_id(closure_def_id);
@@ -392,12 +392,12 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
392392
}
393393

394394
fn visit_min_capture_map(&mut self) {
395-
self.tcx().with_stable_hashing_context(|ref hcx| {
395+
self.tcx().with_stable_hashing_context(|mut hcx| {
396396
let fcx_typeck_results = self.fcx.typeck_results.borrow();
397397

398398
self.typeck_results.closure_min_captures = fcx_typeck_results
399399
.closure_min_captures
400-
.to_sorted(hcx, false)
400+
.to_sorted(&mut hcx, false)
401401
.into_iter()
402402
.map(|(&closure_def_id, root_min_captures)| {
403403
let root_var_map_wb = root_min_captures
@@ -423,12 +423,12 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
423423
}
424424

425425
fn visit_fake_reads_map(&mut self) {
426-
self.tcx().with_stable_hashing_context(move |ref hcx| {
426+
self.tcx().with_stable_hashing_context(move |mut hcx| {
427427
let fcx_typeck_results = self.fcx.typeck_results.borrow();
428428

429429
self.typeck_results.closure_fake_reads = fcx_typeck_results
430430
.closure_fake_reads
431-
.to_sorted(hcx, true)
431+
.to_sorted(&mut hcx, true)
432432
.into_iter()
433433
.map(|(&closure_def_id, fake_reads)| {
434434
let resolved_fake_reads = fake_reads

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,12 +2718,13 @@ declare_lint! {
27182718
///
27192719
/// ### Example
27202720
///
2721-
/// ```rust
2721+
#[cfg_attr(bootstrap, doc = "```rust")]
2722+
#[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")]
27222723
/// enum Void {}
27232724
/// unsafe extern {
27242725
/// static EXTERN: Void;
27252726
/// }
2726-
/// ```
2727+
#[doc = "```"]
27272728
///
27282729
/// {{produces}}
27292730
///
@@ -2734,10 +2735,11 @@ declare_lint! {
27342735
/// compiler which assumes that there are no initialized uninhabited places (such as locals or
27352736
/// statics). This was accidentally allowed, but is being phased out.
27362737
pub UNINHABITED_STATIC,
2737-
Warn,
2738+
Deny,
27382739
"uninhabited static",
27392740
@future_incompatible = FutureIncompatibleInfo {
27402741
reason: fcw!(FutureReleaseError #74840),
2742+
report_in_deps: true,
27412743
};
27422744
}
27432745

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LintExpectationId {
158158
type KeyType = (DefPathHash, ItemLocalId, u16, u16);
159159

160160
#[inline]
161-
fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType {
161+
fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType {
162162
match self {
163163
LintExpectationId::Stable { hir_id, attr_index, lint_index, .. } => {
164164
let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx);
@@ -632,7 +632,7 @@ impl<Hcx> ToStableHashKey<Hcx> for LintId {
632632
type KeyType = &'static str;
633633

634634
#[inline]
635-
fn to_stable_hash_key(&self, _: &Hcx) -> &'static str {
635+
fn to_stable_hash_key(&self, _: &mut Hcx) -> &'static str {
636636
self.lint_name_raw()
637637
}
638638
}

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl WorkProductId {
234234
impl<Hcx> ToStableHashKey<Hcx> for WorkProductId {
235235
type KeyType = Fingerprint;
236236
#[inline]
237-
fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType {
237+
fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType {
238238
self.hash
239239
}
240240
}

0 commit comments

Comments
 (0)