Skip to content

Commit 295d600

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 231dbbc commit 295d600

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

compiler/rustc_lint/src/context.rs

+2
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ impl LintStore {
430430
// Note: find_best_match_for_name depends on the sort order of its input vector.
431431
// To ensure deterministic output, sort elements of the lint_groups hash map.
432432
// Also, never suggest deprecated lint groups.
433+
// We will soon sort, so the initial order does not matter.
434+
#[allow(rustc::potential_query_instability)]
433435
let mut groups: Vec<_> = self
434436
.lint_groups
435437
.iter()

compiler/rustc_lint/src/context/diagnostics.rs

+5
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ pub(super) fn builtin(
197197
if let Some(ExpectedValues::Some(best_match_values)) =
198198
sess.parse_sess.check_config.expecteds.get(&best_match)
199199
{
200+
// We will soon sort, so the initial order does not matter.
201+
#[allow(rustc::potential_query_instability)]
200202
let mut possibilities =
201203
best_match_values.iter().flatten().map(Symbol::as_str).collect::<Vec<_>>();
202204
possibilities.sort();
@@ -298,6 +300,9 @@ pub(super) fn builtin(
298300
);
299301
};
300302
let mut have_none_possibility = false;
303+
// We later sort possibilities if it is not empty, so the
304+
// order here does not matter.
305+
#[allow(rustc::potential_query_instability)]
301306
let possibilities: Vec<Symbol> = values
302307
.iter()
303308
.inspect(|a| have_none_possibility |= a.is_none())

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)