Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_passes: Enforce rustc::potential_query_instability lint #118870

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_passes/src/diagnostic_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_passes/src/hir_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having different outputs for different platforms is a bug, even for diagnostics.

for (implied_by, feature) in remaining_implications {
let local_defined_features = tcx.lib_features(LOCAL_CRATE);
let span = local_defined_features
Expand Down
Loading