safe transmute: use FxIndex{Map,Set}
instead of FxHash{Map,Set}
resolves query instability issues, and probably better for performance
This commit is contained in:
parent
f46fffc276
commit
1d844fe629
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
rustc_data_structures = { path = "../rustc_data_structures", optional = true}
|
rustc_data_structures = { path = "../rustc_data_structures"}
|
||||||
rustc_hir = { path = "../rustc_hir", optional = true}
|
rustc_hir = { path = "../rustc_hir", optional = true}
|
||||||
rustc_infer = { path = "../rustc_infer", optional = true}
|
rustc_infer = { path = "../rustc_infer", optional = true}
|
||||||
rustc_macros = { path = "../rustc_macros", optional = true}
|
rustc_macros = { path = "../rustc_macros", optional = true}
|
||||||
|
@ -18,7 +18,6 @@ rustc_target = { path = "../rustc_target", optional = true}
|
||||||
[features]
|
[features]
|
||||||
rustc = [
|
rustc = [
|
||||||
"rustc_middle",
|
"rustc_middle",
|
||||||
"rustc_data_structures",
|
|
||||||
"rustc_hir",
|
"rustc_hir",
|
||||||
"rustc_infer",
|
"rustc_infer",
|
||||||
"rustc_macros",
|
"rustc_macros",
|
||||||
|
|
|
@ -104,7 +104,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug")]
|
#[instrument(level = "debug")]
|
||||||
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
|
|
||||||
pub(crate) fn from_nfa(nfa: Nfa<R>) -> Self {
|
pub(crate) fn from_nfa(nfa: Nfa<R>) -> Self {
|
||||||
let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa;
|
let Nfa { transitions: nfa_transitions, start: nfa_start, accepting: nfa_accepting } = nfa;
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,6 @@ where
|
||||||
|
|
||||||
let mut transitions: Map<State, Map<Transition<R>, Set<State>>> = self.transitions;
|
let mut transitions: Map<State, Map<Transition<R>, Set<State>>> = self.transitions;
|
||||||
|
|
||||||
// the iteration order doesn't matter
|
|
||||||
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
|
|
||||||
for (source, transition) in other.transitions {
|
for (source, transition) in other.transitions {
|
||||||
let fix_state = |state| if state == other.start { self.accepting } else { state };
|
let fix_state = |state| if state == other.start { self.accepting } else { state };
|
||||||
let entry = transitions.entry(fix_state(source)).or_default();
|
let entry = transitions.entry(fix_state(source)).or_default();
|
||||||
|
@ -142,8 +140,6 @@ where
|
||||||
|
|
||||||
let mut transitions: Map<State, Map<Transition<R>, Set<State>>> = self.transitions.clone();
|
let mut transitions: Map<State, Map<Transition<R>, Set<State>>> = self.transitions.clone();
|
||||||
|
|
||||||
// the iteration order doesn't matter
|
|
||||||
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
|
|
||||||
for (&(mut source), transition) in other.transitions.iter() {
|
for (&(mut source), transition) in other.transitions.iter() {
|
||||||
// if source is starting state of `other`, replace with starting state of `self`
|
// if source is starting state of `other`, replace with starting state of `self`
|
||||||
if source == other.start {
|
if source == other.start {
|
||||||
|
@ -152,8 +148,6 @@ where
|
||||||
let entry = transitions.entry(source).or_default();
|
let entry = transitions.entry(source).or_default();
|
||||||
for (edge, destinations) in transition {
|
for (edge, destinations) in transition {
|
||||||
let entry = entry.entry(edge.clone()).or_default();
|
let entry = entry.entry(edge.clone()).or_default();
|
||||||
// the iteration order doesn't matter
|
|
||||||
#[cfg_attr(feature = "rustc", allow(rustc::potential_query_instability))]
|
|
||||||
for &(mut destination) in destinations {
|
for &(mut destination) in destinations {
|
||||||
// if dest is accepting state of `other`, replace with accepting state of `self`
|
// if dest is accepting state of `other`, replace with accepting state of `self`
|
||||||
if destination == other.accepting {
|
if destination == other.accepting {
|
||||||
|
|
|
@ -13,11 +13,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate tracing;
|
extern crate tracing;
|
||||||
|
|
||||||
#[cfg(feature = "rustc")]
|
pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set};
|
||||||
pub(crate) use rustc_data_structures::fx::{FxHashMap as Map, FxHashSet as Set};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "rustc"))]
|
|
||||||
pub(crate) use std::collections::{HashMap as Map, HashSet as Set};
|
|
||||||
|
|
||||||
pub(crate) mod layout;
|
pub(crate) mod layout;
|
||||||
pub(crate) mod maybe_transmutable;
|
pub(crate) mod maybe_transmutable;
|
||||||
|
|
Loading…
Reference in a new issue