Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Remove allow(rustc::potential_query_instability) in rustc_session #99065

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#![feature(rustc_attrs)]
#![feature(map_many_mut)]
#![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)]

#[macro_use]
extern crate rustc_macros;
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_session/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::config::CheckCfg;
use crate::lint::{BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId};
use crate::SessionDiagnostic;
use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{
Expand All @@ -29,7 +29,7 @@ pub type CrateCheckConfig = CheckCfg<Symbol>;
/// used and should be feature gated accordingly in `check_crate`.
#[derive(Default)]
pub struct GatedSpans {
pub spans: Lock<FxHashMap<Symbol, Vec<Span>>>,
pub spans: Lock<FxIndexMap<Symbol, Vec<Span>>>,
}

impl GatedSpans {
Expand All @@ -56,9 +56,9 @@ impl GatedSpans {
}

/// Prepend the given set of `spans` onto the set in `self`.
pub fn merge(&self, mut spans: FxHashMap<Symbol, Vec<Span>>) {
pub fn merge(&self, mut spans: FxIndexMap<Symbol, Vec<Span>>) {
let mut inner = self.spans.borrow_mut();
for (gate, mut gate_spans) in inner.drain() {
for (gate, mut gate_spans) in inner.drain(..) {
Copy link
Contributor Author

@NiklasJonsson NiklasJonsson Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this just puts the contents of the drained hashmap into another one, I don't see a way that the iteration order can affect the resulting map, so we could also add a local allow here but replacing the map seemed preferable. Though, I'm not sure if this has any performance implications.

spans.entry(gate).or_default().append(&mut gate_spans);
}
*inner = spans;
Expand All @@ -68,7 +68,7 @@ impl GatedSpans {
#[derive(Default)]
pub struct SymbolGallery {
/// All symbols occurred and their first occurrence span.
pub symbols: Lock<FxHashMap<Symbol, Span>>,
pub symbols: Lock<FxIndexMap<Symbol, Span>>,
}

impl SymbolGallery {
Expand Down Expand Up @@ -147,13 +147,13 @@ pub struct ParseSess {
/// Places where identifiers that contain invalid Unicode codepoints but that look like they
/// should be. Useful to avoid bad tokenization when encountering emoji. We group them to
/// provide a single error per unique incorrect identifier.
pub bad_unicode_identifiers: Lock<FxHashMap<Symbol, Vec<Span>>>,
pub bad_unicode_identifiers: Lock<FxIndexMap<Symbol, Vec<Span>>>,
source_map: Lrc<SourceMap>,
pub buffered_lints: Lock<Vec<BufferedEarlyLint>>,
/// Contains the spans of block expressions that could have been incomplete based on the
/// operation token that followed it, but that the parser cannot identify without further
/// analysis.
pub ambiguous_block_expr_parse: Lock<FxHashMap<Span, Span>>,
pub ambiguous_block_expr_parse: Lock<FxIndexMap<Span, Span>>,
pub gated_spans: GatedSpans,
pub symbol_gallery: SymbolGallery,
/// The parser has reached `Eof` due to an unclosed brace. Used to silence unnecessary errors.
Expand Down