mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #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: https://github.com/rust-lang/rust/issues/84447
This commit is contained in:
commit
7e0797c13f
@ -2,7 +2,7 @@ use std::cell::LazyCell;
|
|||||||
use std::ops::{ControlFlow, Deref};
|
use std::ops::{ControlFlow, Deref};
|
||||||
|
|
||||||
use hir::intravisit::{self, Visitor};
|
use hir::intravisit::{self, Visitor};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_err};
|
use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_err};
|
||||||
use rustc_hir::ItemKind;
|
use rustc_hir::ItemKind;
|
||||||
@ -404,7 +404,7 @@ fn check_trait_item<'tcx>(
|
|||||||
/// ```
|
/// ```
|
||||||
fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
|
fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
|
||||||
// Associates every GAT's def_id to a list of possibly missing bounds detected by this lint.
|
// Associates every GAT's def_id to a list of possibly missing bounds detected by this lint.
|
||||||
let mut required_bounds_by_item = FxHashMap::default();
|
let mut required_bounds_by_item = FxIndexMap::default();
|
||||||
let associated_items = tcx.associated_items(trait_def_id);
|
let associated_items = tcx.associated_items(trait_def_id);
|
||||||
|
|
||||||
// Loop over all GATs together, because if this lint suggests adding a where-clause bound
|
// 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) {
|
|||||||
// Gather the bounds with which all other items inside of this trait constrain the GAT.
|
// Gather the bounds with which all other items inside of this trait constrain the GAT.
|
||||||
// This is calculated by taking the intersection of the bounds that each item
|
// This is calculated by taking the intersection of the bounds that each item
|
||||||
// constrains the GAT with individually.
|
// constrains the GAT with individually.
|
||||||
let mut new_required_bounds: Option<FxHashSet<ty::Clause<'_>>> = None;
|
let mut new_required_bounds: Option<FxIndexSet<ty::Clause<'_>>> = None;
|
||||||
for item in associated_items.in_definition_order() {
|
for item in associated_items.in_definition_order() {
|
||||||
let item_def_id = item.def_id.expect_local();
|
let item_def_id = item.def_id.expect_local();
|
||||||
// Skip our own GAT, since it does not constrain itself at all.
|
// 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) {
|
|||||||
fn augment_param_env<'tcx>(
|
fn augment_param_env<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
new_predicates: Option<&FxHashSet<ty::Clause<'tcx>>>,
|
new_predicates: Option<&FxIndexSet<ty::Clause<'tcx>>>,
|
||||||
) -> ty::ParamEnv<'tcx> {
|
) -> ty::ParamEnv<'tcx> {
|
||||||
let Some(new_predicates) = new_predicates else {
|
let Some(new_predicates) = new_predicates else {
|
||||||
return param_env;
|
return param_env;
|
||||||
@ -625,9 +625,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
|
|||||||
wf_tys: &FxIndexSet<Ty<'tcx>>,
|
wf_tys: &FxIndexSet<Ty<'tcx>>,
|
||||||
gat_def_id: LocalDefId,
|
gat_def_id: LocalDefId,
|
||||||
gat_generics: &'tcx ty::Generics,
|
gat_generics: &'tcx ty::Generics,
|
||||||
) -> Option<FxHashSet<ty::Clause<'tcx>>> {
|
) -> Option<FxIndexSet<ty::Clause<'tcx>>> {
|
||||||
// The bounds we that we would require from `to_check`
|
// The bounds we that we would require from `to_check`
|
||||||
let mut bounds = FxHashSet::default();
|
let mut bounds = FxIndexSet::default();
|
||||||
|
|
||||||
let (regions, types) = GATArgsCollector::visit(gat_def_id.to_def_id(), to_check);
|
let (regions, types) = GATArgsCollector::visit(gat_def_id.to_def_id(), to_check);
|
||||||
|
|
||||||
@ -789,18 +789,18 @@ fn test_region_obligations<'tcx>(
|
|||||||
struct GATArgsCollector<'tcx> {
|
struct GATArgsCollector<'tcx> {
|
||||||
gat: DefId,
|
gat: DefId,
|
||||||
// Which region appears and which parameter index its instantiated with
|
// Which region appears and which parameter index its instantiated with
|
||||||
regions: FxHashSet<(ty::Region<'tcx>, usize)>,
|
regions: FxIndexSet<(ty::Region<'tcx>, usize)>,
|
||||||
// Which params appears and which parameter index its instantiated with
|
// Which params appears and which parameter index its instantiated with
|
||||||
types: FxHashSet<(Ty<'tcx>, usize)>,
|
types: FxIndexSet<(Ty<'tcx>, usize)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> GATArgsCollector<'tcx> {
|
impl<'tcx> GATArgsCollector<'tcx> {
|
||||||
fn visit<T: TypeFoldable<TyCtxt<'tcx>>>(
|
fn visit<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||||
gat: DefId,
|
gat: DefId,
|
||||||
t: T,
|
t: T,
|
||||||
) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) {
|
) -> (FxIndexSet<(ty::Region<'tcx>, usize)>, FxIndexSet<(Ty<'tcx>, usize)>) {
|
||||||
let mut visitor =
|
let mut visitor =
|
||||||
GATArgsCollector { gat, regions: FxHashSet::default(), types: FxHashSet::default() };
|
GATArgsCollector { gat, regions: FxIndexSet::default(), types: FxIndexSet::default() };
|
||||||
t.visit_with(&mut visitor);
|
t.visit_with(&mut visitor);
|
||||||
(visitor.regions, visitor.types)
|
(visitor.regions, visitor.types)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet, IndexEntry};
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::struct_span_code_err;
|
use rustc_errors::struct_span_code_err;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
@ -215,7 +215,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
|||||||
|
|
||||||
struct ConnectedRegion {
|
struct ConnectedRegion {
|
||||||
idents: SmallVec<[Symbol; 8]>,
|
idents: SmallVec<[Symbol; 8]>,
|
||||||
impl_blocks: FxHashSet<usize>,
|
impl_blocks: FxIndexSet<usize>,
|
||||||
}
|
}
|
||||||
let mut connected_regions: IndexVec<RegionId, _> = Default::default();
|
let mut connected_regions: IndexVec<RegionId, _> = Default::default();
|
||||||
// Reverse map from the Symbol to the connected region id.
|
// Reverse map from the Symbol to the connected region id.
|
||||||
|
@ -23,7 +23,7 @@ mod lint;
|
|||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
use rustc_ast::TraitObjectSyntax;
|
use rustc_ast::TraitObjectSyntax;
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, struct_span_code_err,
|
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, struct_span_code_err,
|
||||||
@ -2394,8 +2394,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
#[instrument(level = "trace", skip(self, generate_err))]
|
#[instrument(level = "trace", skip(self, generate_err))]
|
||||||
fn validate_late_bound_regions<'cx>(
|
fn validate_late_bound_regions<'cx>(
|
||||||
&'cx self,
|
&'cx self,
|
||||||
constrained_regions: FxHashSet<ty::BoundRegionKind>,
|
constrained_regions: FxIndexSet<ty::BoundRegionKind>,
|
||||||
referenced_regions: FxHashSet<ty::BoundRegionKind>,
|
referenced_regions: FxIndexSet<ty::BoundRegionKind>,
|
||||||
generate_err: impl Fn(&str) -> Diag<'cx>,
|
generate_err: impl Fn(&str) -> Diag<'cx>,
|
||||||
) {
|
) {
|
||||||
for br in referenced_regions.difference(&constrained_regions) {
|
for br in referenced_regions.difference(&constrained_regions) {
|
||||||
|
@ -58,7 +58,6 @@ This API is completely unstable and subject to change.
|
|||||||
// tidy-alphabetical-start
|
// tidy-alphabetical-start
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
#![allow(rustc::diagnostic_outside_of_impl)]
|
#![allow(rustc::diagnostic_outside_of_impl)]
|
||||||
#![allow(rustc::potential_query_instability)]
|
|
||||||
#![allow(rustc::untranslatable_diagnostic)]
|
#![allow(rustc::untranslatable_diagnostic)]
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
|
@ -186,7 +186,7 @@ pub struct ResolverGlobalCtxt {
|
|||||||
pub proc_macros: Vec<LocalDefId>,
|
pub proc_macros: Vec<LocalDefId>,
|
||||||
/// Mapping from ident span to path span for paths that don't exist as written, but that
|
/// Mapping from ident span to path span for paths that don't exist as written, but that
|
||||||
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
|
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
|
||||||
pub confused_type_with_std_module: FxHashMap<Span, Span>,
|
pub confused_type_with_std_module: FxIndexMap<Span, Span>,
|
||||||
pub doc_link_resolutions: FxHashMap<LocalDefId, DocLinkResMap>,
|
pub doc_link_resolutions: FxHashMap<LocalDefId, DocLinkResMap>,
|
||||||
pub doc_link_traits_in_scope: FxHashMap<LocalDefId, Vec<DefId>>,
|
pub doc_link_traits_in_scope: FxHashMap<LocalDefId, Vec<DefId>>,
|
||||||
pub all_macro_rules: FxHashMap<Symbol, Res<ast::NodeId>>,
|
pub all_macro_rules: FxHashMap<Symbol, Res<ast::NodeId>>,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_type_ir::fold::TypeFoldable;
|
use rustc_type_ir::fold::TypeFoldable;
|
||||||
pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
|
pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn collect_constrained_late_bound_regions<T>(
|
pub fn collect_constrained_late_bound_regions<T>(
|
||||||
self,
|
self,
|
||||||
value: Binder<'tcx, T>,
|
value: Binder<'tcx, T>,
|
||||||
) -> FxHashSet<ty::BoundRegionKind>
|
) -> FxIndexSet<ty::BoundRegionKind>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
@ -121,7 +121,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn collect_referenced_late_bound_regions<T>(
|
pub fn collect_referenced_late_bound_regions<T>(
|
||||||
self,
|
self,
|
||||||
value: Binder<'tcx, T>,
|
value: Binder<'tcx, T>,
|
||||||
) -> FxHashSet<ty::BoundRegionKind>
|
) -> FxIndexSet<ty::BoundRegionKind>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self,
|
self,
|
||||||
value: Binder<'tcx, T>,
|
value: Binder<'tcx, T>,
|
||||||
just_constrained: bool,
|
just_constrained: bool,
|
||||||
) -> FxHashSet<ty::BoundRegionKind>
|
) -> FxIndexSet<ty::BoundRegionKind>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
@ -148,7 +148,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// into a hash set.
|
/// into a hash set.
|
||||||
struct LateBoundRegionsCollector {
|
struct LateBoundRegionsCollector {
|
||||||
current_index: ty::DebruijnIndex,
|
current_index: ty::DebruijnIndex,
|
||||||
regions: FxHashSet<ty::BoundRegionKind>,
|
regions: FxIndexSet<ty::BoundRegionKind>,
|
||||||
|
|
||||||
/// `true` if we only want regions that are known to be
|
/// `true` if we only want regions that are known to be
|
||||||
/// "constrained" when you equate this type with another type. In
|
/// "constrained" when you equate this type with another type. In
|
||||||
|
@ -1188,7 +1188,7 @@ pub struct Resolver<'ra, 'tcx> {
|
|||||||
/// A list of proc macro LocalDefIds, written out in the order in which
|
/// A list of proc macro LocalDefIds, written out in the order in which
|
||||||
/// they are declared in the static array generated by proc_macro_harness.
|
/// they are declared in the static array generated by proc_macro_harness.
|
||||||
proc_macros: Vec<NodeId>,
|
proc_macros: Vec<NodeId>,
|
||||||
confused_type_with_std_module: FxHashMap<Span, Span>,
|
confused_type_with_std_module: FxIndexMap<Span, Span>,
|
||||||
/// Whether lifetime elision was successful.
|
/// Whether lifetime elision was successful.
|
||||||
lifetime_elision_allowed: FxHashSet<NodeId>,
|
lifetime_elision_allowed: FxHashSet<NodeId>,
|
||||||
|
|
||||||
|
@ -108,17 +108,6 @@ LL | type Bar<'b>;
|
|||||||
= note: this bound is currently required to ensure that impls have maximum flexibility
|
= note: this bound is currently required to ensure that impls have maximum flexibility
|
||||||
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
|
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
|
||||||
|
|
||||||
error: missing required bound on `Iterator`
|
|
||||||
--> $DIR/self-outlives-lint.rs:142:5
|
|
||||||
|
|
|
||||||
LL | type Iterator<'a>: Iterator<Item = Self::Item<'a>>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
|
||||||
| |
|
|
||||||
| help: add the required where clause: `where Self: 'a`
|
|
||||||
|
|
|
||||||
= note: this bound is currently required to ensure that impls have maximum flexibility
|
|
||||||
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
|
|
||||||
|
|
||||||
error: missing required bound on `Item`
|
error: missing required bound on `Item`
|
||||||
--> $DIR/self-outlives-lint.rs:140:5
|
--> $DIR/self-outlives-lint.rs:140:5
|
||||||
|
|
|
|
||||||
@ -130,6 +119,17 @@ LL | type Item<'a>;
|
|||||||
= note: this bound is currently required to ensure that impls have maximum flexibility
|
= note: this bound is currently required to ensure that impls have maximum flexibility
|
||||||
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
|
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
|
||||||
|
|
||||||
|
error: missing required bound on `Iterator`
|
||||||
|
--> $DIR/self-outlives-lint.rs:142:5
|
||||||
|
|
|
||||||
|
LL | type Iterator<'a>: Iterator<Item = Self::Item<'a>>;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
|
| |
|
||||||
|
| help: add the required where clause: `where Self: 'a`
|
||||||
|
|
|
||||||
|
= note: this bound is currently required to ensure that impls have maximum flexibility
|
||||||
|
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
|
||||||
|
|
||||||
error: missing required bound on `Item`
|
error: missing required bound on `Item`
|
||||||
--> $DIR/self-outlives-lint.rs:148:5
|
--> $DIR/self-outlives-lint.rs:148:5
|
||||||
|
|
|
|
||||||
|
Loading…
Reference in New Issue
Block a user