diff options
| author | bors <bors@rust-lang.org> | 2023-12-13 12:47:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-13 12:47:43 +0000 |
| commit | c3def263a44e07e09ae6d57abfc8650227fb4972 (patch) | |
| tree | ff15ead7abf1cedb4ec4a4ce0d9665aaf193620f | |
| parent | 56d25ba5ea3515ba2b361b6c4636373734eb27cc (diff) | |
| parent | e9b16cc2c537fc525a438b15016d4d066baf6645 (diff) | |
| download | rust-c3def263a44e07e09ae6d57abfc8650227fb4972.tar.gz rust-c3def263a44e07e09ae6d57abfc8650227fb4972.zip | |
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 https://github.com/rust-lang/rust/issues/84447 which is E-help-wanted.
| -rw-r--r-- | compiler/rustc_passes/src/diagnostic_items.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/hir_stats.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/stability.rs | 3 |
4 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs index d8b9f4fae87..5f767c9acaa 100644 --- a/compiler/rustc_passes/src/diagnostic_items.rs +++ b/compiler/rustc_passes/src/diagnostic_items.rs @@ -83,6 +83,9 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems { // Collect diagnostic items in other crates. for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) { + // We are collecting many DiagnosticItems hash maps into one + // DiagnosticItems hash map. The iteration order does not matter. + #[allow(rustc::potential_query_instability)] for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id { collect_item(tcx, &mut items, name, def_id); } diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 28354ab0986..85969b72d23 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -121,6 +121,8 @@ impl<'k> StatCollector<'k> { } fn print(&self, title: &str, prefix: &str) { + // We will soon sort, so the initial order does not matter. + #[allow(rustc::potential_query_instability)] let mut nodes: Vec<_> = self.nodes.iter().collect(); nodes.sort_by_key(|(_, node)| node.stats.count * node.stats.size); @@ -147,6 +149,8 @@ impl<'k> StatCollector<'k> { to_readable_str(node.stats.size) ); if !node.subnodes.is_empty() { + // We will soon sort, so the initial order does not matter. + #[allow(rustc::potential_query_instability)] let mut subnodes: Vec<_> = node.subnodes.iter().collect(); subnodes.sort_by_key(|(_, subnode)| subnode.count * subnode.size); diff --git a/compiler/rustc_passes/src/lib.rs b/compiler/rustc_passes/src/lib.rs index 4c4d5e58232..c969867e871 100644 --- a/compiler/rustc_passes/src/lib.rs +++ b/compiler/rustc_passes/src/lib.rs @@ -4,7 +4,6 @@ //! //! This API is completely unstable and subject to change. -#![allow(rustc::potential_query_instability)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 26bd52f55d4..676622cef45 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -1048,6 +1048,9 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) { tcx.sess.emit_err(errors::UnknownFeature { span, feature: *feature }); } + // We only use the hash map contents to emit errors, and the order of + // emitted errors do not affect query stability. + #[allow(rustc::potential_query_instability)] for (implied_by, feature) in remaining_implications { let local_defined_features = tcx.lib_features(LOCAL_CRATE); let span = local_defined_features |
