Skip to content

Commit ca08a32

Browse files
committed
Auto merge of rust-lang#103218 - CastilloDel:infer, r=jackh726
Remove #![allow(rustc::potential_query_instability)] from rustc_infer Related to rust-lang#84447 This PR probably needs to be benchmarked to check for regressions.
2 parents 9b735a7 + e950201 commit ca08a32

File tree

10 files changed

+31
-26
lines changed

10 files changed

+31
-26
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![deny(rustc::diagnostic_outside_of_impl)]
33
//! Error reporting machinery for lifetime errors.
44
5-
use rustc_data_structures::fx::FxHashSet;
5+
use rustc_data_structures::fx::FxIndexSet;
66
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
77
use rustc_hir::def_id::DefId;
88
use rustc_hir::intravisit::Visitor;
@@ -276,7 +276,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
276276
fn get_impl_ident_and_self_ty_from_trait(
277277
&self,
278278
def_id: DefId,
279-
trait_objects: &FxHashSet<DefId>,
279+
trait_objects: &FxIndexSet<DefId>,
280280
) -> Option<(Ident, &'tcx hir::Ty<'tcx>)> {
281281
let tcx = self.infcx.tcx;
282282
match tcx.hir().get_if_local(def_id) {
@@ -830,7 +830,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
830830
};
831831
debug!(?param);
832832

833-
let mut visitor = TraitObjectVisitor(FxHashSet::default());
833+
let mut visitor = TraitObjectVisitor(FxIndexSet::default());
834834
visitor.visit_ty(param.param_ty);
835835

836836
let Some((ident, self_ty)) =
@@ -843,7 +843,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
843843
fn suggest_constrain_dyn_trait_in_impl(
844844
&self,
845845
err: &mut Diagnostic,
846-
found_dids: &FxHashSet<DefId>,
846+
found_dids: &FxIndexSet<DefId>,
847847
ident: Ident,
848848
self_ty: &hir::Ty<'_>,
849849
) -> bool {

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::traits::{
5858
StatementAsExpression,
5959
};
6060

61-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
61+
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
6262
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed, IntoDiagnosticArg};
6363
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString, MultiSpan};
6464
use rustc_hir as hir;
@@ -1498,9 +1498,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14981498
values = None;
14991499
}
15001500
struct OpaqueTypesVisitor<'tcx> {
1501-
types: FxHashMap<TyCategory, FxHashSet<Span>>,
1502-
expected: FxHashMap<TyCategory, FxHashSet<Span>>,
1503-
found: FxHashMap<TyCategory, FxHashSet<Span>>,
1501+
types: FxIndexMap<TyCategory, FxIndexSet<Span>>,
1502+
expected: FxIndexMap<TyCategory, FxIndexSet<Span>>,
1503+
found: FxIndexMap<TyCategory, FxIndexSet<Span>>,
15041504
ignore_span: Span,
15051505
tcx: TyCtxt<'tcx>,
15061506
}
@@ -1538,7 +1538,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
15381538
&self,
15391539
err: &mut Diagnostic,
15401540
target: &str,
1541-
types: &FxHashMap<TyCategory, FxHashSet<Span>>,
1541+
types: &FxIndexMap<TyCategory, FxIndexSet<Span>>,
15421542
) {
15431543
for (key, values) in types.iter() {
15441544
let count = values.len();
@@ -3254,7 +3254,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32543254
if blk.expr.is_some() {
32553255
return false;
32563256
}
3257-
let mut shadowed = FxHashSet::default();
3257+
let mut shadowed = FxIndexSet::default();
32583258
let mut candidate_idents = vec![];
32593259
let mut find_compatible_candidates = |pat: &hir::Pat<'_>| {
32603260
if let hir::PatKind::Binding(_, hir_id, ident, _) = &pat.kind

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
99
use crate::infer::lexical_region_resolve::RegionResolutionError;
1010
use crate::infer::{SubregionOrigin, TypeTrace};
1111
use crate::traits::ObligationCauseCode;
12-
use rustc_data_structures::fx::FxHashSet;
12+
use rustc_data_structures::fx::FxIndexSet;
1313
use rustc_errors::{ErrorGuaranteed, MultiSpan};
1414
use rustc_hir as hir;
1515
use rustc_hir::intravisit::Visitor;
@@ -73,7 +73,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
7373

7474
// Next, let's figure out the set of trait objects with implicit static bounds
7575
let ty = self.tcx().type_of(*impl_def_id);
76-
let mut v = super::static_impl_trait::TraitObjectVisitor(FxHashSet::default());
76+
let mut v = super::static_impl_trait::TraitObjectVisitor(FxIndexSet::default());
7777
v.visit_ty(ty);
7878
let mut traits = vec![];
7979
for matching_def_id in v.0 {

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
44
use crate::infer::lexical_region_resolve::RegionResolutionError;
55
use crate::infer::{SubregionOrigin, TypeTrace};
66
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
7-
use rustc_data_structures::fx::FxHashSet;
7+
use rustc_data_structures::fx::FxIndexSet;
88
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
99
use rustc_hir::def_id::DefId;
1010
use rustc_hir::intravisit::{walk_ty, Visitor};
@@ -236,7 +236,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
236236
// Same case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a `'static`
237237
// lifetime as above, but called using a fully-qualified path to the method:
238238
// `Foo::qux(bar)`.
239-
let mut v = TraitObjectVisitor(FxHashSet::default());
239+
let mut v = TraitObjectVisitor(FxIndexSet::default());
240240
v.visit_ty(param.param_ty);
241241
if let Some((ident, self_ty)) =
242242
self.get_impl_ident_and_self_ty_from_trait(item_def_id, &v.0)
@@ -408,7 +408,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
408408
fn get_impl_ident_and_self_ty_from_trait(
409409
&self,
410410
def_id: DefId,
411-
trait_objects: &FxHashSet<DefId>,
411+
trait_objects: &FxIndexSet<DefId>,
412412
) -> Option<(Ident, &'tcx hir::Ty<'tcx>)> {
413413
let tcx = self.tcx();
414414
match tcx.hir().get_if_local(def_id) {
@@ -490,7 +490,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
490490
return false;
491491
};
492492

493-
let mut v = TraitObjectVisitor(FxHashSet::default());
493+
let mut v = TraitObjectVisitor(FxIndexSet::default());
494494
v.visit_ty(ty);
495495

496496
// Get the `Ident` of the method being called and the corresponding `impl` (to point at
@@ -506,7 +506,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
506506
fn suggest_constrain_dyn_trait_in_impl(
507507
&self,
508508
err: &mut Diagnostic,
509-
found_dids: &FxHashSet<DefId>,
509+
found_dids: &FxIndexSet<DefId>,
510510
ident: Ident,
511511
self_ty: &hir::Ty<'_>,
512512
) -> bool {
@@ -538,7 +538,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
538538
}
539539

540540
/// Collect all the trait objects in a type that could have received an implicit `'static` lifetime.
541-
pub struct TraitObjectVisitor(pub FxHashSet<DefId>);
541+
pub struct TraitObjectVisitor(pub FxIndexSet<DefId>);
542542

543543
impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
544544
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
149149
region: ty::BoundRegionKind,
150150
) -> bool {
151151
let late_bound_regions = self.tcx().collect_referenced_late_bound_regions(&ty);
152+
// We are only checking is any region meets the condition so order doesn't matter
153+
#[allow(rustc::potential_query_instability)]
152154
late_bound_regions.iter().any(|r| *r == region)
153155
}
154156

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
842842
// are placeholders as upper bounds, but the universe of the
843843
// variable `'a`, or some variable that `'a` has to outlive, doesn't
844844
// permit those placeholders.
845+
//
846+
// We only iterate to find the min, which means it doesn't cause reproducibility issues
847+
#[allow(rustc::potential_query_instability)]
845848
let min_universe = lower_vid_bounds
846849
.into_iter()
847850
.map(|vid| self.var_infos[vid].universe)

compiler/rustc_infer/src/infer/region_constraints/leak_check.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::*;
22
use crate::infer::CombinedSnapshot;
33
use rustc_data_structures::{
4+
fx::FxIndexMap,
45
graph::{scc::Sccs, vec_graph::VecGraph},
56
undo_log::UndoLogs,
67
};
@@ -371,7 +372,7 @@ rustc_index::newtype_index! {
371372
/// an edge `R1 -> R2` in the graph.
372373
struct MiniGraph<'tcx> {
373374
/// Map from a region to the index of the node in the graph.
374-
nodes: FxHashMap<ty::Region<'tcx>, LeakCheckNode>,
375+
nodes: FxIndexMap<ty::Region<'tcx>, LeakCheckNode>,
375376

376377
/// Map from node index to SCC, and stores the successors of each SCC. All
377378
/// the regions in the same SCC are equal to one another, and if `S1 -> S2`,
@@ -388,7 +389,7 @@ impl<'tcx> MiniGraph<'tcx> {
388389
where
389390
'tcx: 'a,
390391
{
391-
let mut nodes = FxHashMap::default();
392+
let mut nodes = FxIndexMap::default();
392393
let mut edges = Vec::new();
393394

394395
// Note that if `R2: R1`, we get a callback `r1, r2`, so `target` is first parameter.
@@ -438,7 +439,7 @@ impl<'tcx> MiniGraph<'tcx> {
438439
}
439440

440441
fn add_node(
441-
nodes: &mut FxHashMap<ty::Region<'tcx>, LeakCheckNode>,
442+
nodes: &mut FxIndexMap<ty::Region<'tcx>, LeakCheckNode>,
442443
r: ty::Region<'tcx>,
443444
) -> LeakCheckNode {
444445
let l = nodes.len();

compiler/rustc_infer/src/infer/region_constraints/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::{
77
InferCtxtUndoLogs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin,
88
};
99

10-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
10+
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1111
use rustc_data_structures::intern::Interned;
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_data_structures::undo_log::UndoLogs;
@@ -125,7 +125,7 @@ pub struct RegionConstraintData<'tcx> {
125125
/// we record the fact that `'a <= 'b` is implied by the fn
126126
/// signature, and then ignore the constraint when solving
127127
/// equations. This is a bit of a hack but seems to work.
128-
pub givens: FxHashSet<(Region<'tcx>, ty::RegionVid)>,
128+
pub givens: FxIndexSet<(Region<'tcx>, ty::RegionVid)>,
129129
}
130130

131131
/// Represents a constraint that influences the inference process.

compiler/rustc_infer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//!
1313
//! This API is completely unstable and subject to change.
1414
15-
#![allow(rustc::potential_query_instability)]
1615
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1716
#![feature(box_patterns)]
1817
#![feature(control_flow_enum)]

compiler/rustc_infer/src/traits/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::ObjectSafetyViolation;
22

33
use crate::infer::InferCtxt;
4-
use rustc_data_structures::fx::FxHashSet;
4+
use rustc_data_structures::fx::FxIndexSet;
55
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
66
use rustc_hir as hir;
77
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -56,7 +56,7 @@ pub fn report_object_safety_error<'tcx>(
5656
);
5757
err.span_label(span, format!("`{}` cannot be made into an object", trait_str));
5858

59-
let mut reported_violations = FxHashSet::default();
59+
let mut reported_violations = FxIndexSet::default();
6060
let mut multi_span = vec![];
6161
let mut messages = vec![];
6262
for violation in violations {

0 commit comments

Comments
 (0)