Skip to content

Commit bdc6fc4

Browse files
committed
rustc_lint: Enforce rustc::potential_query_instability lint
Stop allowing `rustc::potential_query_instability` on all of `rustc_lint` and instead allow it on a case-by-case basis if it is safe to do so. In this particular crate, all lints were safe to allow.
1 parent 92ad4b4 commit bdc6fc4

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

compiler/rustc_lint/src/context.rs

+7
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ impl LintStore {
432432
// Note: find_best_match_for_name depends on the sort order of its input vector.
433433
// To ensure deterministic output, sort elements of the lint_groups hash map.
434434
// Also, never suggest deprecated lint groups.
435+
// We will soon sort, so the initial order does not matter.
436+
#[allow(rustc::potential_query_instability)]
435437
let mut groups: Vec<_> = self
436438
.lint_groups
437439
.iter()
@@ -710,6 +712,8 @@ pub trait LintContext {
710712
} else if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
711713
if let Some(ExpectedValues::Some(best_match_values)) =
712714
sess.parse_sess.check_config.expecteds.get(&best_match) {
715+
// We will soon sort, so the initial order does not matter.
716+
#[allow(rustc::potential_query_instability)]
713717
let mut possibilities = best_match_values.iter()
714718
.flatten()
715719
.map(Symbol::as_str)
@@ -778,6 +782,9 @@ pub trait LintContext {
778782
bug!("it shouldn't be possible to have a diagnostic on a value whose name is not in values");
779783
};
780784
let mut have_none_possibility = false;
785+
// We later sort possibilities if it is not empty, so the
786+
// order here does not matter.
787+
#[allow(rustc::potential_query_instability)]
781788
let possibilities: Vec<Symbol> = values.iter()
782789
.inspect(|a| have_none_possibility |= a.is_none())
783790
.copied()

compiler/rustc_lint/src/levels.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10281028
}
10291029

10301030
if !is_crate_node {
1031+
// We break on the first lint, and it does not matter which one.
1032+
#[allow(rustc::potential_query_instability)]
10311033
for (id, &(level, ref src)) in self.current_specs().iter() {
10321034
if !id.lint.crate_level_only {
10331035
continue;

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
//!
2626
//! This API is completely unstable and subject to change.
2727
28-
#![allow(rustc::potential_query_instability)]
2928
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3029
#![doc(rust_logo)]
3130
#![feature(rustdoc_internals)]

compiler/rustc_lint/src/non_ascii_idents.rs

+6
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ impl EarlyLintPass for NonAsciiIdents {
174174

175175
// Sort by `Span` so that error messages make sense with respect to the
176176
// order of identifier locations in the code.
177+
// We will soon sort, so the initial order does not matter.
178+
#[allow(rustc::potential_query_instability)]
177179
let mut symbols: Vec<_> = symbols.iter().collect();
178180
symbols.sort_by_key(|k| k.1);
179181

@@ -287,6 +289,8 @@ impl EarlyLintPass for NonAsciiIdents {
287289
}
288290

289291
if has_suspicious {
292+
// The end result is put in `lint_reports` which is sorted.
293+
#[allow(rustc::potential_query_instability)]
290294
let verified_augmented_script_sets = script_states
291295
.iter()
292296
.flat_map(|(k, v)| match v {
@@ -299,6 +303,8 @@ impl EarlyLintPass for NonAsciiIdents {
299303
let mut lint_reports: BTreeMap<(Span, Vec<char>), AugmentedScriptSet> =
300304
BTreeMap::new();
301305

306+
// The end result is put in `lint_reports` which is sorted.
307+
#[allow(rustc::potential_query_instability)]
302308
'outerloop: for (augment_script_set, usage) in script_states {
303309
let ScriptSetUsage::Suspicious(mut ch_list, sp) = usage else { continue };
304310

0 commit comments

Comments
 (0)