Skip to content

Commit c3def26

Browse files
committed
Auto merge of #118870 - Enselic:rustc_passes-query-stability, r=compiler-errors
rustc_passes: Enforce `rustc::potential_query_instability` lint Stop allowing `rustc::potential_query_instability` in all of `rustc_passes` and instead allow it on a case-by-case basis if it is safe. In this case, all instances of the lint are safe to allow. Part of #84447 which is E-help-wanted.
2 parents 56d25ba + e9b16cc commit c3def26

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎compiler/rustc_passes/src/diagnostic_items.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
8383

8484
// Collect diagnostic items in other crates.
8585
for&cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)){
86+
// We are collecting many DiagnosticItems hash maps into one
87+
// DiagnosticItems hash map. The iteration order does not matter.
88+
#[allow(rustc::potential_query_instability)]
8689
for(&name,&def_id)in&tcx.diagnostic_items(cnum).name_to_id{
8790
collect_item(tcx,&mut items, name, def_id);
8891
}

‎compiler/rustc_passes/src/hir_stats.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ impl<'k> StatCollector<'k> {
121121
}
122122

123123
fnprint(&self,title:&str,prefix:&str){
124+
// We will soon sort, so the initial order does not matter.
125+
#[allow(rustc::potential_query_instability)]
124126
letmut nodes:Vec<_> = self.nodes.iter().collect();
125127
nodes.sort_by_key(|(_, node)| node.stats.count* node.stats.size);
126128

@@ -147,6 +149,8 @@ impl<'k> StatCollector<'k> {
147149
to_readable_str(node.stats.size)
148150
);
149151
if !node.subnodes.is_empty(){
152+
// We will soon sort, so the initial order does not matter.
153+
#[allow(rustc::potential_query_instability)]
150154
letmut subnodes:Vec<_> = node.subnodes.iter().collect();
151155
subnodes.sort_by_key(|(_, subnode)| subnode.count* subnode.size);
152156

‎compiler/rustc_passes/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//!
55
//! This API is completely unstable and subject to change.
66
7-
#![allow(rustc::potential_query_instability)]
87
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
98
#![doc(rust_logo)]
109
#![feature(rustdoc_internals)]

‎compiler/rustc_passes/src/stability.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,9 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
10481048
tcx.sess.emit_err(errors::UnknownFeature{ span,feature:*feature });
10491049
}
10501050

1051+
// We only use the hash map contents to emit errors, and the order of
1052+
// emitted errors do not affect query stability.
1053+
#[allow(rustc::potential_query_instability)]
10511054
for(implied_by, feature)in remaining_implications {
10521055
let local_defined_features = tcx.lib_features(LOCAL_CRATE);
10531056
let span = local_defined_features

0 commit comments

Comments
 (0)