Skip to content

Commit 6bf8881

Browse files
committed
Handle rustc_middle cases of rustc::potential_query_instability lint
1 parent 1e008dd commit 6bf8881

15 files changed

+43
-43
lines changed

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
// tidy-alphabetical-start
2828
#![allow(internal_features)]
2929
#![allow(rustc::diagnostic_outside_of_impl)]
30-
#![allow(rustc::potential_query_instability)]
3130
#![allow(rustc::untranslatable_diagnostic)]
3231
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
3332
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ rustc_queries! {
21692169
query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet<LocalDefId> {
21702170
desc { "fetching potentially unused trait imports" }
21712171
}
2172-
query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx UnordSet<Symbol> {
2172+
query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxIndexSet<Symbol> {
21732173
desc { |tcx| "finding names imported by glob use for `{}`", tcx.def_path_str(def_id) }
21742174
}
21752175

compiler/rustc_middle/src/query/on_disk_cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::hash_map::Entry;
22
use std::mem;
33
use std::sync::Arc;
44

5-
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
5+
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
66
use rustc_data_structures::memmap::Mmap;
77
use rustc_data_structures::sync::{HashMapExt, Lock, RwLock};
88
use rustc_data_structures::unhash::UnhashMap;
@@ -57,7 +57,7 @@ pub struct OnDiskCache {
5757

5858
// Collects all `QuerySideEffect` created during the current compilation
5959
// session.
60-
current_side_effects: Lock<FxHashMap<DepNodeIndex, QuerySideEffect>>,
60+
current_side_effects: Lock<FxIndexMap<DepNodeIndex, QuerySideEffect>>,
6161

6262
file_index_to_stable_id: FxHashMap<SourceFileIndex, EncodedSourceFileId>,
6363

compiler/rustc_middle/src/ty/context.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use rustc_data_structures::steal::Steal;
2828
use rustc_data_structures::sync::{
2929
self, DynSend, DynSync, FreezeReadGuard, Lock, RwLock, WorkerLocal,
3030
};
31-
use rustc_data_structures::unord::UnordSet;
3231
use rustc_errors::{
3332
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, LintDiagnostic, MultiSpan,
3433
};
@@ -2378,6 +2377,8 @@ macro_rules! sty_debug_print {
23782377
$(let mut $variant = total;)*
23792378

23802379
for shard in tcx.interners.type_.lock_shards() {
2380+
// It seems that ordering doesn't affect anything here.
2381+
#[allow(rustc::potential_query_instability)]
23812382
let types = shard.iter();
23822383
for &(InternedInSet(t), ()) in types {
23832384
let variant = match t.internee {
@@ -3355,9 +3356,7 @@ pub fn provide(providers: &mut Providers) {
33553356
providers.maybe_unused_trait_imports =
33563357
|tcx, ()| &tcx.resolutions(()).maybe_unused_trait_imports;
33573358
providers.names_imported_by_glob_use = |tcx, id| {
3358-
tcx.arena.alloc(UnordSet::from(
3359-
tcx.resolutions(()).glob_map.get(&id).cloned().unwrap_or_default(),
3360-
))
3359+
tcx.arena.alloc(tcx.resolutions(()).glob_map.get(&id).cloned().unwrap_or_default())
33613360
};
33623361

33633362
providers.extern_mod_stmt_cnum =

compiler/rustc_middle/src/ty/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::fmt::Write;
44
use std::ops::ControlFlow;
55

6-
use rustc_data_structures::fx::FxHashMap;
6+
use rustc_data_structures::fx::FxIndexMap;
77
use rustc_errors::{
88
Applicability, Diag, DiagArgValue, IntoDiagArg, into_diag_arg_using_display, listify, pluralize,
99
};
@@ -287,7 +287,7 @@ pub fn suggest_constraining_type_params<'a>(
287287
param_names_and_constraints: impl Iterator<Item = (&'a str, &'a str, Option<DefId>)>,
288288
span_to_replace: Option<Span>,
289289
) -> bool {
290-
let mut grouped = FxHashMap::default();
290+
let mut grouped = FxIndexMap::default();
291291
let mut unstable_suggestion = false;
292292
param_names_and_constraints.for_each(|(param_name, constraint, def_id)| {
293293
let stable = match def_id {

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub struct ResolverGlobalCtxt {
172172
pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,
173173
pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
174174
pub module_children: LocalDefIdMap<Vec<ModChild>>,
175-
pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
175+
pub glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
176176
pub main_def: Option<MainDefinition>,
177177
pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
178178
/// A list of proc macro LocalDefIds, written out in the order in which

compiler/rustc_middle/src/ty/print/pretty.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3520,6 +3520,8 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
35203520

35213521
// Put the symbol from all the unique namespace+symbol pairs into `map`.
35223522
let mut map: DefIdMap<Symbol> = Default::default();
3523+
// Precatious is taken below in the loop so we can allow this lint here.
3524+
#[allow(rustc::potential_query_instability)]
35233525
for ((_, symbol), opt_def_id) in unique_symbols_rev.drain() {
35243526
use std::collections::hash_map::Entry::{Occupied, Vacant};
35253527

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ pub struct Resolver<'ra, 'tcx> {
11041104
underscore_disambiguator: u32,
11051105

11061106
/// Maps glob imports to the names of items actually imported.
1107-
glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
1107+
glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
11081108
glob_error: Option<ErrorGuaranteed>,
11091109
visibilities_for_hashing: Vec<(LocalDefId, ty::Visibility)>,
11101110
used_imports: FxHashSet<NodeId>,

src/tools/clippy/clippy_lints/src/wildcard_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl LateLintPass<'_> for WildcardImports {
150150
(span, false)
151151
};
152152

153-
let mut imports = used_imports.items().map(ToString::to_string).into_sorted_stable_ord();
153+
let mut imports: Vec<_> = used_imports.iter().map(ToString::to_string).collect();
154154
let imports_string = if imports.len() == 1 {
155155
imports.pop().unwrap()
156156
} else if braced_glob {

src/tools/clippy/tests/ui/wildcard_imports.fixed

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::fn_mod::foo;
1616
//~^ wildcard_imports
1717
use crate::mod_mod::inner_mod;
1818
//~^ wildcard_imports
19-
use crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod};
19+
use crate::multi_fn_mod::{multi_foo, multi_bar, multi_inner_mod};
2020
//~^ wildcard_imports
2121
#[macro_use]
2222
use crate::struct_mod::{A, inner_struct_mod};
@@ -26,7 +26,7 @@ use crate::struct_mod::{A, inner_struct_mod};
2626
use wildcard_imports_helper::inner::inner_for_self_import;
2727
use wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar;
2828
//~^ wildcard_imports
29-
use wildcard_imports_helper::{ExternA, extern_foo};
29+
use wildcard_imports_helper::{extern_foo, ExternA};
3030
//~^ wildcard_imports
3131

3232
use std::io::prelude::*;
@@ -138,7 +138,7 @@ mod in_fn_test {
138138
fn test_extern() {
139139
use wildcard_imports_helper::inner::inner_for_self_import::{self, inner_extern_foo};
140140
//~^ wildcard_imports
141-
use wildcard_imports_helper::{ExternA, extern_foo};
141+
use wildcard_imports_helper::{extern_foo, ExternA};
142142
//~^ wildcard_imports
143143

144144
inner_for_self_import::inner_extern_foo();
@@ -160,7 +160,7 @@ mod in_fn_test {
160160
}
161161

162162
fn test_extern_reexported() {
163-
use wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported};
163+
use wildcard_imports_helper::{extern_exported, ExternExportedStruct, ExternExportedEnum};
164164
//~^ wildcard_imports
165165

166166
extern_exported();
@@ -190,7 +190,7 @@ mod in_fn_test {
190190
}
191191

192192
fn test_reexported() {
193-
use crate::in_fn_test::{ExportedEnum, ExportedStruct, exported};
193+
use crate::in_fn_test::{exported, ExportedStruct, ExportedEnum};
194194
//~^ wildcard_imports
195195

196196
exported();

src/tools/clippy/tests/ui/wildcard_imports.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error: usage of wildcard import
1717
--> tests/ui/wildcard_imports.rs:19:5
1818
|
1919
LL | use crate::multi_fn_mod::*;
20-
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}`
20+
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_foo, multi_bar, multi_inner_mod}`
2121

2222
error: usage of wildcard import
2323
--> tests/ui/wildcard_imports.rs:22:5
@@ -35,7 +35,7 @@ error: usage of wildcard import
3535
--> tests/ui/wildcard_imports.rs:29:5
3636
|
3737
LL | use wildcard_imports_helper::*;
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_foo, ExternA}`
3939

4040
error: usage of wildcard import
4141
--> tests/ui/wildcard_imports.rs:100:13
@@ -59,7 +59,7 @@ error: usage of wildcard import
5959
--> tests/ui/wildcard_imports.rs:141:13
6060
|
6161
LL | use wildcard_imports_helper::*;
62-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
62+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_foo, ExternA}`
6363

6464
error: usage of wildcard import
6565
--> tests/ui/wildcard_imports.rs:154:20
@@ -77,13 +77,13 @@ error: usage of wildcard import
7777
--> tests/ui/wildcard_imports.rs:163:13
7878
|
7979
LL | use wildcard_imports_helper::*;
80-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}`
80+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_exported, ExternExportedStruct, ExternExportedEnum}`
8181

8282
error: usage of wildcard import
8383
--> tests/ui/wildcard_imports.rs:193:9
8484
|
8585
LL | use crate::in_fn_test::*;
86-
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}`
86+
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{exported, ExportedStruct, ExportedEnum}`
8787

8888
error: usage of wildcard import
8989
--> tests/ui/wildcard_imports.rs:203:9

src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.fixed

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::fn_mod::foo;
1414
//~^ wildcard_imports
1515
use crate::mod_mod::inner_mod;
1616
//~^ wildcard_imports
17-
use crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod};
17+
use crate::multi_fn_mod::{multi_foo, multi_bar, multi_inner_mod};
1818
//~^ wildcard_imports
1919
use crate::struct_mod::{A, inner_struct_mod};
2020
//~^ wildcard_imports
@@ -23,7 +23,7 @@ use crate::struct_mod::{A, inner_struct_mod};
2323
use wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar;
2424
//~^ wildcard_imports
2525
use wildcard_imports_helper::prelude::v1::*;
26-
use wildcard_imports_helper::{ExternA, extern_foo};
26+
use wildcard_imports_helper::{extern_foo, ExternA};
2727
//~^ wildcard_imports
2828

2929
use std::io::prelude::*;
@@ -132,7 +132,7 @@ mod in_fn_test {
132132
fn test_extern() {
133133
use wildcard_imports_helper::inner::inner_for_self_import::{self, inner_extern_foo};
134134
//~^ wildcard_imports
135-
use wildcard_imports_helper::{ExternA, extern_foo};
135+
use wildcard_imports_helper::{extern_foo, ExternA};
136136
//~^ wildcard_imports
137137

138138
inner_for_self_import::inner_extern_foo();
@@ -154,7 +154,7 @@ mod in_fn_test {
154154
}
155155

156156
fn test_extern_reexported() {
157-
use wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported};
157+
use wildcard_imports_helper::{extern_exported, ExternExportedStruct, ExternExportedEnum};
158158
//~^ wildcard_imports
159159

160160
extern_exported();
@@ -184,7 +184,7 @@ mod in_fn_test {
184184
}
185185

186186
fn test_reexported() {
187-
use crate::in_fn_test::{ExportedEnum, ExportedStruct, exported};
187+
use crate::in_fn_test::{exported, ExportedStruct, ExportedEnum};
188188
//~^ wildcard_imports
189189

190190
exported();

src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error: usage of wildcard import
1717
--> tests/ui/wildcard_imports_2021.rs:17:5
1818
|
1919
LL | use crate::multi_fn_mod::*;
20-
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}`
20+
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_foo, multi_bar, multi_inner_mod}`
2121

2222
error: usage of wildcard import
2323
--> tests/ui/wildcard_imports_2021.rs:19:5
@@ -35,7 +35,7 @@ error: usage of wildcard import
3535
--> tests/ui/wildcard_imports_2021.rs:26:5
3636
|
3737
LL | use wildcard_imports_helper::*;
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_foo, ExternA}`
3939

4040
error: usage of wildcard import
4141
--> tests/ui/wildcard_imports_2021.rs:95:13
@@ -59,7 +59,7 @@ error: usage of wildcard import
5959
--> tests/ui/wildcard_imports_2021.rs:135:13
6060
|
6161
LL | use wildcard_imports_helper::*;
62-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
62+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_foo, ExternA}`
6363

6464
error: usage of wildcard import
6565
--> tests/ui/wildcard_imports_2021.rs:148:20
@@ -77,13 +77,13 @@ error: usage of wildcard import
7777
--> tests/ui/wildcard_imports_2021.rs:157:13
7878
|
7979
LL | use wildcard_imports_helper::*;
80-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}`
80+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_exported, ExternExportedStruct, ExternExportedEnum}`
8181

8282
error: usage of wildcard import
8383
--> tests/ui/wildcard_imports_2021.rs:187:9
8484
|
8585
LL | use crate::in_fn_test::*;
86-
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}`
86+
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{exported, ExportedStruct, ExportedEnum}`
8787

8888
error: usage of wildcard import
8989
--> tests/ui/wildcard_imports_2021.rs:197:9

src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.fixed

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::fn_mod::foo;
1414
//~^ wildcard_imports
1515
use crate::mod_mod::inner_mod;
1616
//~^ wildcard_imports
17-
use crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod};
17+
use crate::multi_fn_mod::{multi_foo, multi_bar, multi_inner_mod};
1818
//~^ wildcard_imports
1919
use crate::struct_mod::{A, inner_struct_mod};
2020
//~^ wildcard_imports
@@ -23,7 +23,7 @@ use crate::struct_mod::{A, inner_struct_mod};
2323
use wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar;
2424
//~^ wildcard_imports
2525
use wildcard_imports_helper::prelude::v1::*;
26-
use wildcard_imports_helper::{ExternA, extern_foo};
26+
use wildcard_imports_helper::{extern_foo, ExternA};
2727
//~^ wildcard_imports
2828

2929
use std::io::prelude::*;
@@ -132,7 +132,7 @@ mod in_fn_test {
132132
fn test_extern() {
133133
use wildcard_imports_helper::inner::inner_for_self_import::{self, inner_extern_foo};
134134
//~^ wildcard_imports
135-
use wildcard_imports_helper::{ExternA, extern_foo};
135+
use wildcard_imports_helper::{extern_foo, ExternA};
136136
//~^ wildcard_imports
137137

138138
inner_for_self_import::inner_extern_foo();
@@ -154,7 +154,7 @@ mod in_fn_test {
154154
}
155155

156156
fn test_extern_reexported() {
157-
use wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported};
157+
use wildcard_imports_helper::{extern_exported, ExternExportedStruct, ExternExportedEnum};
158158
//~^ wildcard_imports
159159

160160
extern_exported();
@@ -184,7 +184,7 @@ mod in_fn_test {
184184
}
185185

186186
fn test_reexported() {
187-
use crate::in_fn_test::{ExportedEnum, ExportedStruct, exported};
187+
use crate::in_fn_test::{exported, ExportedStruct, ExportedEnum};
188188
//~^ wildcard_imports
189189

190190
exported();

src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error: usage of wildcard import
1717
--> tests/ui/wildcard_imports_2021.rs:17:5
1818
|
1919
LL | use crate::multi_fn_mod::*;
20-
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}`
20+
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_foo, multi_bar, multi_inner_mod}`
2121

2222
error: usage of wildcard import
2323
--> tests/ui/wildcard_imports_2021.rs:19:5
@@ -35,7 +35,7 @@ error: usage of wildcard import
3535
--> tests/ui/wildcard_imports_2021.rs:26:5
3636
|
3737
LL | use wildcard_imports_helper::*;
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_foo, ExternA}`
3939

4040
error: usage of wildcard import
4141
--> tests/ui/wildcard_imports_2021.rs:95:13
@@ -59,7 +59,7 @@ error: usage of wildcard import
5959
--> tests/ui/wildcard_imports_2021.rs:135:13
6060
|
6161
LL | use wildcard_imports_helper::*;
62-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}`
62+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_foo, ExternA}`
6363

6464
error: usage of wildcard import
6565
--> tests/ui/wildcard_imports_2021.rs:148:20
@@ -77,13 +77,13 @@ error: usage of wildcard import
7777
--> tests/ui/wildcard_imports_2021.rs:157:13
7878
|
7979
LL | use wildcard_imports_helper::*;
80-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}`
80+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{extern_exported, ExternExportedStruct, ExternExportedEnum}`
8181

8282
error: usage of wildcard import
8383
--> tests/ui/wildcard_imports_2021.rs:187:9
8484
|
8585
LL | use crate::in_fn_test::*;
86-
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}`
86+
| ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{exported, ExportedStruct, ExportedEnum}`
8787

8888
error: usage of wildcard import
8989
--> tests/ui/wildcard_imports_2021.rs:197:9

0 commit comments

Comments
 (0)