Skip to content

Commit

Permalink
Auto merge of #103218 - CastilloDel:infer, r=jackh726
Browse files Browse the repository at this point in the history
Remove #![allow(rustc::potential_query_instability)] from rustc_infer

Related to #84447

This PR probably needs to be benchmarked to check for regressions.
  • Loading branch information
bors committed Nov 7, 2022
2 parents 9b735a7 + e950201 commit ca08a32
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 26 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![deny(rustc::diagnostic_outside_of_impl)]
//! Error reporting machinery for lifetime errors.

use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
fn get_impl_ident_and_self_ty_from_trait(
&self,
def_id: DefId,
trait_objects: &FxHashSet<DefId>,
trait_objects: &FxIndexSet<DefId>,
) -> Option<(Ident, &'tcx hir::Ty<'tcx>)> {
let tcx = self.infcx.tcx;
match tcx.hir().get_if_local(def_id) {
Expand Down Expand Up @@ -830,7 +830,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
};
debug!(?param);

let mut visitor = TraitObjectVisitor(FxHashSet::default());
let mut visitor = TraitObjectVisitor(FxIndexSet::default());
visitor.visit_ty(param.param_ty);

let Some((ident, self_ty)) =
Expand All @@ -843,7 +843,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
fn suggest_constrain_dyn_trait_in_impl(
&self,
err: &mut Diagnostic,
found_dids: &FxHashSet<DefId>,
found_dids: &FxIndexSet<DefId>,
ident: Ident,
self_ty: &hir::Ty<'_>,
) -> bool {
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use crate::traits::{
StatementAsExpression,
};

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString, MultiSpan};
use rustc_hir as hir;
Expand Down Expand Up @@ -1498,9 +1498,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
values = None;
}
struct OpaqueTypesVisitor<'tcx> {
types: FxHashMap<TyCategory, FxHashSet<Span>>,
expected: FxHashMap<TyCategory, FxHashSet<Span>>,
found: FxHashMap<TyCategory, FxHashSet<Span>>,
types: FxIndexMap<TyCategory, FxIndexSet<Span>>,
expected: FxIndexMap<TyCategory, FxIndexSet<Span>>,
found: FxIndexMap<TyCategory, FxIndexSet<Span>>,
ignore_span: Span,
tcx: TyCtxt<'tcx>,
}
Expand Down Expand Up @@ -1538,7 +1538,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self,
err: &mut Diagnostic,
target: &str,
types: &FxHashMap<TyCategory, FxHashSet<Span>>,
types: &FxIndexMap<TyCategory, FxIndexSet<Span>>,
) {
for (key, values) in types.iter() {
let count = values.len();
Expand Down Expand Up @@ -3254,7 +3254,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if blk.expr.is_some() {
return false;
}
let mut shadowed = FxHashSet::default();
let mut shadowed = FxIndexSet::default();
let mut candidate_idents = vec![];
let mut find_compatible_candidates = |pat: &hir::Pat<'_>| {
if let hir::PatKind::Binding(_, hir_id, ident, _) = &pat.kind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::ObligationCauseCode;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
Expand Down Expand Up @@ -73,7 +73,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {

// Next, let's figure out the set of trait objects with implicit static bounds
let ty = self.tcx().type_of(*impl_def_id);
let mut v = super::static_impl_trait::TraitObjectVisitor(FxHashSet::default());
let mut v = super::static_impl_trait::TraitObjectVisitor(FxIndexSet::default());
v.visit_ty(ty);
let mut traits = vec![];
for matching_def_id in v.0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{walk_ty, Visitor};
Expand Down Expand Up @@ -236,7 +236,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
// Same case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a `'static`
// lifetime as above, but called using a fully-qualified path to the method:
// `Foo::qux(bar)`.
let mut v = TraitObjectVisitor(FxHashSet::default());
let mut v = TraitObjectVisitor(FxIndexSet::default());
v.visit_ty(param.param_ty);
if let Some((ident, self_ty)) =
self.get_impl_ident_and_self_ty_from_trait(item_def_id, &v.0)
Expand Down Expand Up @@ -408,7 +408,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
fn get_impl_ident_and_self_ty_from_trait(
&self,
def_id: DefId,
trait_objects: &FxHashSet<DefId>,
trait_objects: &FxIndexSet<DefId>,
) -> Option<(Ident, &'tcx hir::Ty<'tcx>)> {
let tcx = self.tcx();
match tcx.hir().get_if_local(def_id) {
Expand Down Expand Up @@ -490,7 +490,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
return false;
};

let mut v = TraitObjectVisitor(FxHashSet::default());
let mut v = TraitObjectVisitor(FxIndexSet::default());
v.visit_ty(ty);

// Get the `Ident` of the method being called and the corresponding `impl` (to point at
Expand All @@ -506,7 +506,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
fn suggest_constrain_dyn_trait_in_impl(
&self,
err: &mut Diagnostic,
found_dids: &FxHashSet<DefId>,
found_dids: &FxIndexSet<DefId>,
ident: Ident,
self_ty: &hir::Ty<'_>,
) -> bool {
Expand Down Expand Up @@ -538,7 +538,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
}

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

impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
region: ty::BoundRegionKind,
) -> bool {
let late_bound_regions = self.tcx().collect_referenced_late_bound_regions(&ty);
// We are only checking is any region meets the condition so order doesn't matter
#[allow(rustc::potential_query_instability)]
late_bound_regions.iter().any(|r| *r == region)
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
// are placeholders as upper bounds, but the universe of the
// variable `'a`, or some variable that `'a` has to outlive, doesn't
// permit those placeholders.
//
// We only iterate to find the min, which means it doesn't cause reproducibility issues
#[allow(rustc::potential_query_instability)]
let min_universe = lower_vid_bounds
.into_iter()
.map(|vid| self.var_infos[vid].universe)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::*;
use crate::infer::CombinedSnapshot;
use rustc_data_structures::{
fx::FxIndexMap,
graph::{scc::Sccs, vec_graph::VecGraph},
undo_log::UndoLogs,
};
Expand Down Expand Up @@ -371,7 +372,7 @@ rustc_index::newtype_index! {
/// an edge `R1 -> R2` in the graph.
struct MiniGraph<'tcx> {
/// Map from a region to the index of the node in the graph.
nodes: FxHashMap<ty::Region<'tcx>, LeakCheckNode>,
nodes: FxIndexMap<ty::Region<'tcx>, LeakCheckNode>,

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

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

fn add_node(
nodes: &mut FxHashMap<ty::Region<'tcx>, LeakCheckNode>,
nodes: &mut FxIndexMap<ty::Region<'tcx>, LeakCheckNode>,
r: ty::Region<'tcx>,
) -> LeakCheckNode {
let l = nodes.len();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{
InferCtxtUndoLogs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin,
};

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

/// Represents a constraint that influences the inference process.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//!
//! This API is completely unstable and subject to change.

#![allow(rustc::potential_query_instability)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::ObjectSafetyViolation;

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

let mut reported_violations = FxHashSet::default();
let mut reported_violations = FxIndexSet::default();
let mut multi_span = vec![];
let mut messages = vec![];
for violation in violations {
Expand Down

0 comments on commit ca08a32

Please sign in to comment.