Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f95575

Browse files
authoredOct 2, 2024··
Unrolled build for rust-lang#131140
Rollup merge of rust-lang#131140 - ismailarilik:handle-potential-query-instability-lint-for-rustc-hir-analysis, r=compiler-errors Handle `rustc_hir_analysis` cases of `potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_hir_analysis/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_analysis/src/lib.rs#L61) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: rust-lang#84447
2 parents 44722bd + 807e812 commit 7f95575

File tree

8 files changed

+33
-34
lines changed

8 files changed

+33
-34
lines changed
 

‎compiler/rustc_hir_analysis/src/check/wfcheck.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::cell::LazyCell;
22
use std::ops::{ControlFlow, Deref};
33

44
use hir::intravisit::{self, Visitor};
5-
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
5+
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
66
use rustc_errors::codes::*;
77
use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_err};
88
use rustc_hir::ItemKind;
@@ -404,7 +404,7 @@ fn check_trait_item<'tcx>(
404404
/// ```
405405
fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
406406
// Associates every GAT's def_id to a list of possibly missing bounds detected by this lint.
407-
let mut required_bounds_by_item = FxHashMap::default();
407+
let mut required_bounds_by_item = FxIndexMap::default();
408408
let associated_items = tcx.associated_items(trait_def_id);
409409

410410
// Loop over all GATs together, because if this lint suggests adding a where-clause bound
@@ -430,7 +430,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
430430
// Gather the bounds with which all other items inside of this trait constrain the GAT.
431431
// This is calculated by taking the intersection of the bounds that each item
432432
// constrains the GAT with individually.
433-
let mut new_required_bounds: Option<FxHashSet<ty::Clause<'_>>> = None;
433+
let mut new_required_bounds: Option<FxIndexSet<ty::Clause<'_>>> = None;
434434
for item in associated_items.in_definition_order() {
435435
let item_def_id = item.def_id.expect_local();
436436
// Skip our own GAT, since it does not constrain itself at all.
@@ -589,7 +589,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
589589
fn augment_param_env<'tcx>(
590590
tcx: TyCtxt<'tcx>,
591591
param_env: ty::ParamEnv<'tcx>,
592-
new_predicates: Option<&FxHashSet<ty::Clause<'tcx>>>,
592+
new_predicates: Option<&FxIndexSet<ty::Clause<'tcx>>>,
593593
) -> ty::ParamEnv<'tcx> {
594594
let Some(new_predicates) = new_predicates else {
595595
return param_env;
@@ -625,9 +625,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
625625
wf_tys: &FxIndexSet<Ty<'tcx>>,
626626
gat_def_id: LocalDefId,
627627
gat_generics: &'tcx ty::Generics,
628-
) -> Option<FxHashSet<ty::Clause<'tcx>>> {
628+
) -> Option<FxIndexSet<ty::Clause<'tcx>>> {
629629
// The bounds we that we would require from `to_check`
630-
let mut bounds = FxHashSet::default();
630+
let mut bounds = FxIndexSet::default();
631631

632632
let (regions, types) = GATArgsCollector::visit(gat_def_id.to_def_id(), to_check);
633633

@@ -789,18 +789,18 @@ fn test_region_obligations<'tcx>(
789789
struct GATArgsCollector<'tcx> {
790790
gat: DefId,
791791
// Which region appears and which parameter index its instantiated with
792-
regions: FxHashSet<(ty::Region<'tcx>, usize)>,
792+
regions: FxIndexSet<(ty::Region<'tcx>, usize)>,
793793
// Which params appears and which parameter index its instantiated with
794-
types: FxHashSet<(Ty<'tcx>, usize)>,
794+
types: FxIndexSet<(Ty<'tcx>, usize)>,
795795
}
796796

797797
impl<'tcx> GATArgsCollector<'tcx> {
798798
fn visit<T: TypeFoldable<TyCtxt<'tcx>>>(
799799
gat: DefId,
800800
t: T,
801-
) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) {
801+
) -> (FxIndexSet<(ty::Region<'tcx>, usize)>, FxIndexSet<(Ty<'tcx>, usize)>) {
802802
let mut visitor =
803-
GATArgsCollector { gat, regions: FxHashSet::default(), types: FxHashSet::default() };
803+
GATArgsCollector { gat, regions: FxIndexSet::default(), types: FxIndexSet::default() };
804804
t.visit_with(&mut visitor);
805805
(visitor.regions, visitor.types)
806806
}

‎compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry};
1+
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet, IndexEntry};
22
use rustc_errors::codes::*;
33
use rustc_errors::struct_span_code_err;
44
use rustc_hir as hir;
@@ -215,7 +215,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
215215

216216
struct ConnectedRegion {
217217
idents: SmallVec<[Symbol; 8]>,
218-
impl_blocks: FxHashSet<usize>,
218+
impl_blocks: FxIndexSet<usize>,
219219
}
220220
let mut connected_regions: IndexVec<RegionId, _> = Default::default();
221221
// Reverse map from the Symbol to the connected region id.

‎compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod lint;
2323
use std::slice;
2424

2525
use rustc_ast::TraitObjectSyntax;
26-
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
26+
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
2727
use rustc_errors::codes::*;
2828
use rustc_errors::{
2929
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, struct_span_code_err,
@@ -2394,8 +2394,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23942394
#[instrument(level = "trace", skip(self, generate_err))]
23952395
fn validate_late_bound_regions<'cx>(
23962396
&'cx self,
2397-
constrained_regions: FxHashSet<ty::BoundRegionKind>,
2398-
referenced_regions: FxHashSet<ty::BoundRegionKind>,
2397+
constrained_regions: FxIndexSet<ty::BoundRegionKind>,
2398+
referenced_regions: FxIndexSet<ty::BoundRegionKind>,
23992399
generate_err: impl Fn(&str) -> Diag<'cx>,
24002400
) {
24012401
for br in referenced_regions.difference(&constrained_regions) {

‎compiler/rustc_hir_analysis/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ This API is completely unstable and subject to change.
5858
// tidy-alphabetical-start
5959
#![allow(internal_features)]
6060
#![allow(rustc::diagnostic_outside_of_impl)]
61-
#![allow(rustc::potential_query_instability)]
6261
#![allow(rustc::untranslatable_diagnostic)]
6362
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
6463
#![doc(rust_logo)]

‎compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub struct ResolverGlobalCtxt {
186186
pub proc_macros: Vec<LocalDefId>,
187187
/// Mapping from ident span to path span for paths that don't exist as written, but that
188188
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
189-
pub confused_type_with_std_module: FxHashMap<Span, Span>,
189+
pub confused_type_with_std_module: FxIndexMap<Span, Span>,
190190
pub doc_link_resolutions: FxHashMap<LocalDefId, DocLinkResMap>,
191191
pub doc_link_traits_in_scope: FxHashMap<LocalDefId, Vec<DefId>>,
192192
pub all_macro_rules: FxHashMap<Symbol, Res<ast::NodeId>>,

‎compiler/rustc_middle/src/ty/visit.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::ops::ControlFlow;
22

3-
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_type_ir::fold::TypeFoldable;
55
pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
66

@@ -110,7 +110,7 @@ impl<'tcx> TyCtxt<'tcx> {
110110
pub fn collect_constrained_late_bound_regions<T>(
111111
self,
112112
value: Binder<'tcx, T>,
113-
) -> FxHashSet<ty::BoundRegionKind>
113+
) -> FxIndexSet<ty::BoundRegionKind>
114114
where
115115
T: TypeFoldable<TyCtxt<'tcx>>,
116116
{
@@ -121,7 +121,7 @@ impl<'tcx> TyCtxt<'tcx> {
121121
pub fn collect_referenced_late_bound_regions<T>(
122122
self,
123123
value: Binder<'tcx, T>,
124-
) -> FxHashSet<ty::BoundRegionKind>
124+
) -> FxIndexSet<ty::BoundRegionKind>
125125
where
126126
T: TypeFoldable<TyCtxt<'tcx>>,
127127
{
@@ -132,7 +132,7 @@ impl<'tcx> TyCtxt<'tcx> {
132132
self,
133133
value: Binder<'tcx, T>,
134134
just_constrained: bool,
135-
) -> FxHashSet<ty::BoundRegionKind>
135+
) -> FxIndexSet<ty::BoundRegionKind>
136136
where
137137
T: TypeFoldable<TyCtxt<'tcx>>,
138138
{
@@ -148,7 +148,7 @@ impl<'tcx> TyCtxt<'tcx> {
148148
/// into a hash set.
149149
struct LateBoundRegionsCollector {
150150
current_index: ty::DebruijnIndex,
151-
regions: FxHashSet<ty::BoundRegionKind>,
151+
regions: FxIndexSet<ty::BoundRegionKind>,
152152

153153
/// `true` if we only want regions that are known to be
154154
/// "constrained" when you equate this type with another type. In

‎compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ pub struct Resolver<'ra, 'tcx> {
11881188
/// A list of proc macro LocalDefIds, written out in the order in which
11891189
/// they are declared in the static array generated by proc_macro_harness.
11901190
proc_macros: Vec<NodeId>,
1191-
confused_type_with_std_module: FxHashMap<Span, Span>,
1191+
confused_type_with_std_module: FxIndexMap<Span, Span>,
11921192
/// Whether lifetime elision was successful.
11931193
lifetime_elision_allowed: FxHashSet<NodeId>,
11941194

‎tests/ui/generic-associated-types/self-outlives-lint.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,6 @@ LL | type Bar<'b>;
108108
= note: this bound is currently required to ensure that impls have maximum flexibility
109109
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
110110

111-
error: missing required bound on `Iterator`
112-
--> $DIR/self-outlives-lint.rs:142:5
113-
|
114-
LL | type Iterator<'a>: Iterator<Item = Self::Item<'a>>;
115-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
116-
| |
117-
| help: add the required where clause: `where Self: 'a`
118-
|
119-
= note: this bound is currently required to ensure that impls have maximum flexibility
120-
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
121-
122111
error: missing required bound on `Item`
123112
--> $DIR/self-outlives-lint.rs:140:5
124113
|
@@ -130,6 +119,17 @@ LL | type Item<'a>;
130119
= note: this bound is currently required to ensure that impls have maximum flexibility
131120
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
132121

122+
error: missing required bound on `Iterator`
123+
--> $DIR/self-outlives-lint.rs:142:5
124+
|
125+
LL | type Iterator<'a>: Iterator<Item = Self::Item<'a>>;
126+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
127+
| |
128+
| help: add the required where clause: `where Self: 'a`
129+
|
130+
= note: this bound is currently required to ensure that impls have maximum flexibility
131+
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
132+
133133
error: missing required bound on `Item`
134134
--> $DIR/self-outlives-lint.rs:148:5
135135
|

0 commit comments

Comments
 (0)
Please sign in to comment.