librustc_data_structures => 2018
This commit is contained in:
parent
43e04fb552
commit
3e2b5a4b08
25 changed files with 86 additions and 107 deletions
|
@ -2,6 +2,7 @@
|
||||||
authors = ["The Rust Project Developers"]
|
authors = ["The Rust Project Developers"]
|
||||||
name = "rustc_data_structures"
|
name = "rustc_data_structures"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "rustc_data_structures"
|
name = "rustc_data_structures"
|
||||||
|
@ -16,8 +17,8 @@ serialize = { path = "../libserialize" }
|
||||||
graphviz = { path = "../libgraphviz" }
|
graphviz = { path = "../libgraphviz" }
|
||||||
cfg-if = "0.1.2"
|
cfg-if = "0.1.2"
|
||||||
stable_deref_trait = "1.0.0"
|
stable_deref_trait = "1.0.0"
|
||||||
rustc-rayon = "0.1.1"
|
rayon = { version = "0.1.1", package = "rustc-rayon" }
|
||||||
rustc-rayon-core = "0.1.1"
|
rayon-core = { version = "0.1.1", package = "rustc-rayon-core" }
|
||||||
rustc-hash = "1.0.1"
|
rustc-hash = "1.0.1"
|
||||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use indexed_vec::{Idx, IndexVec};
|
use crate::indexed_vec::{Idx, IndexVec};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
@ -208,7 +208,7 @@ impl<T: Idx> SubtractFromBitSet<T> for BitSet<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Idx> fmt::Debug for BitSet<T> {
|
impl<T: Idx> fmt::Debug for BitSet<T> {
|
||||||
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
w.debug_list()
|
w.debug_list()
|
||||||
.entries(self.iter())
|
.entries(self.iter())
|
||||||
.finish()
|
.finish()
|
||||||
|
@ -366,7 +366,7 @@ impl<T: Idx> SparseBitSet<T> {
|
||||||
dense
|
dense
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iter(&self) -> slice::Iter<T> {
|
fn iter(&self) -> slice::Iter<'_, T> {
|
||||||
self.elems.iter()
|
self.elems.iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ impl<T: Idx> HybridBitSet<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> HybridIter<T> {
|
pub fn iter(&self) -> HybridIter<'_, T> {
|
||||||
match self {
|
match self {
|
||||||
HybridBitSet::Sparse(sparse) => HybridIter::Sparse(sparse.iter()),
|
HybridBitSet::Sparse(sparse) => HybridIter::Sparse(sparse.iter()),
|
||||||
HybridBitSet::Dense(dense) => HybridIter::Dense(dense.iter()),
|
HybridBitSet::Dense(dense) => HybridIter::Dense(dense.iter()),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
use crate::stable_hasher;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use stable_hasher;
|
|
||||||
use serialize;
|
use serialize;
|
||||||
use serialize::opaque::{EncodeResult, Encoder, Decoder};
|
use serialize::opaque::{EncodeResult, Encoder, Decoder};
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ impl Fingerprint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for Fingerprint {
|
impl ::std::fmt::Display for Fingerprint {
|
||||||
fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, formatter: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
write!(formatter, "{:x}-{:x}", self.0, self.1)
|
write!(formatter, "{:x}-{:x}", self.0, self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,9 @@ cfg_if! {
|
||||||
if #[cfg(unix)] {
|
if #[cfg(unix)] {
|
||||||
use std::ffi::{CString, OsStr};
|
use std::ffi::{CString, OsStr};
|
||||||
use std::os::unix::prelude::*;
|
use std::os::unix::prelude::*;
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
mod os {
|
mod os {
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct flock {
|
pub struct flock {
|
||||||
pub l_type: libc::c_short,
|
pub l_type: libc::c_short,
|
||||||
|
@ -35,8 +32,6 @@ cfg_if! {
|
||||||
|
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
mod os {
|
mod os {
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct flock {
|
pub struct flock {
|
||||||
pub l_start: libc::off_t,
|
pub l_start: libc::off_t,
|
||||||
|
@ -53,8 +48,6 @@ cfg_if! {
|
||||||
target_os = "netbsd",
|
target_os = "netbsd",
|
||||||
target_os = "openbsd"))]
|
target_os = "openbsd"))]
|
||||||
mod os {
|
mod os {
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct flock {
|
pub struct flock {
|
||||||
pub l_start: libc::off_t,
|
pub l_start: libc::off_t,
|
||||||
|
@ -70,8 +63,6 @@ cfg_if! {
|
||||||
|
|
||||||
#[cfg(target_os = "haiku")]
|
#[cfg(target_os = "haiku")]
|
||||||
mod os {
|
mod os {
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct flock {
|
pub struct flock {
|
||||||
pub l_type: libc::c_short,
|
pub l_type: libc::c_short,
|
||||||
|
@ -87,8 +78,6 @@ cfg_if! {
|
||||||
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||||
mod os {
|
mod os {
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct flock {
|
pub struct flock {
|
||||||
pub l_start: libc::off_t,
|
pub l_start: libc::off_t,
|
||||||
|
@ -104,8 +93,6 @@ cfg_if! {
|
||||||
|
|
||||||
#[cfg(target_os = "solaris")]
|
#[cfg(target_os = "solaris")]
|
||||||
mod os {
|
mod os {
|
||||||
use libc;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct flock {
|
pub struct flock {
|
||||||
pub l_type: libc::c_short,
|
pub l_type: libc::c_short,
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl<Node: Idx> Dominators<Node> {
|
||||||
self.immediate_dominators[node].unwrap()
|
self.immediate_dominators[node].unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dominators(&self, node: Node) -> Iter<Node> {
|
pub fn dominators(&self, node: Node) -> Iter<'_, Node> {
|
||||||
assert!(self.is_reachable(node), "node {:?} is not reachable", node);
|
assert!(self.is_reachable(node), "node {:?} is not reachable", node);
|
||||||
Iter {
|
Iter {
|
||||||
dominators: self,
|
dominators: self,
|
||||||
|
@ -136,7 +136,7 @@ impl<Node: Idx> Dominators<Node> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Iter<'dom, Node: Idx + 'dom> {
|
pub struct Iter<'dom, Node: Idx> {
|
||||||
dominators: &'dom Dominators<Node>,
|
dominators: &'dom Dominators<Node>,
|
||||||
node: Option<Node>,
|
node: Option<Node>,
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ impl<Node: Idx> DominatorTree<Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Node: Idx> fmt::Debug for DominatorTree<Node> {
|
impl<Node: Idx> fmt::Debug for DominatorTree<Node> {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmt::Debug::fmt(
|
fmt::Debug::fmt(
|
||||||
&DominatorTreeNode {
|
&DominatorTreeNode {
|
||||||
tree: self,
|
tree: self,
|
||||||
|
@ -188,7 +188,7 @@ struct DominatorTreeNode<'tree, Node: Idx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> {
|
impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let subtrees: Vec<_> = self.tree
|
let subtrees: Vec<_> = self.tree
|
||||||
.children(self.node)
|
.children(self.node)
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
//! the field `next_edge`). Each of those fields is an array that should
|
//! the field `next_edge`). Each of those fields is an array that should
|
||||||
//! be indexed by the direction (see the type `Direction`).
|
//! be indexed by the direction (see the type `Direction`).
|
||||||
|
|
||||||
use bit_set::BitSet;
|
use crate::bit_set::BitSet;
|
||||||
|
use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::usize;
|
use std::usize;
|
||||||
use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -212,15 +212,19 @@ impl<N: Debug, E: Debug> Graph<N, E> {
|
||||||
.all(|(edge_idx, edge)| f(edge_idx, edge))
|
.all(|(edge_idx, edge)| f(edge_idx, edge))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
|
pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> {
|
||||||
self.adjacent_edges(source, OUTGOING)
|
self.adjacent_edges(source, OUTGOING)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
|
pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> {
|
||||||
self.adjacent_edges(source, INCOMING)
|
self.adjacent_edges(source, INCOMING)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adjacent_edges(&self, source: NodeIndex, direction: Direction) -> AdjacentEdges<N, E> {
|
pub fn adjacent_edges(
|
||||||
|
&self,
|
||||||
|
source: NodeIndex,
|
||||||
|
direction: Direction
|
||||||
|
) -> AdjacentEdges<'_, N, E> {
|
||||||
let first_edge = self.node(source).first_edge[direction.repr];
|
let first_edge = self.node(source).first_edge[direction.repr];
|
||||||
AdjacentEdges {
|
AdjacentEdges {
|
||||||
graph: self,
|
graph: self,
|
||||||
|
@ -291,11 +295,7 @@ impl<N: Debug, E: Debug> Graph<N, E> {
|
||||||
|
|
||||||
// # Iterators
|
// # Iterators
|
||||||
|
|
||||||
pub struct AdjacentEdges<'g, N, E>
|
pub struct AdjacentEdges<'g, N, E> {
|
||||||
where
|
|
||||||
N: 'g,
|
|
||||||
E: 'g,
|
|
||||||
{
|
|
||||||
graph: &'g Graph<N, E>,
|
graph: &'g Graph<N, E>,
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
next: EdgeIndex,
|
next: EdgeIndex,
|
||||||
|
@ -331,11 +331,7 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DepthFirstTraversal<'g, N, E>
|
pub struct DepthFirstTraversal<'g, N, E> {
|
||||||
where
|
|
||||||
N: 'g,
|
|
||||||
E: 'g,
|
|
||||||
{
|
|
||||||
graph: &'g Graph<N, E>,
|
graph: &'g Graph<N, E>,
|
||||||
stack: Vec<NodeIndex>,
|
stack: Vec<NodeIndex>,
|
||||||
visited: BitSet<usize>,
|
visited: BitSet<usize>,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use graph::implementation::*;
|
use crate::graph::implementation::*;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
type TestGraph = Graph<&'static str, &'static str>;
|
type TestGraph = Graph<&'static str, &'static str>;
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
//! node in the graph. This uses Tarjan's algorithm that completes in
|
//! node in the graph. This uses Tarjan's algorithm that completes in
|
||||||
//! O(n) time.
|
//! O(n) time.
|
||||||
|
|
||||||
use fx::FxHashSet;
|
use crate::fx::FxHashSet;
|
||||||
use graph::{DirectedGraph, WithNumNodes, WithSuccessors};
|
use crate::graph::{DirectedGraph, WithNumNodes, WithSuccessors};
|
||||||
use indexed_vec::{Idx, IndexVec};
|
use crate::indexed_vec::{Idx, IndexVec};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
mod test;
|
mod test;
|
||||||
|
@ -93,7 +93,7 @@ impl<S: Idx> SccData<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors + 'c, S: Idx> {
|
struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors, S: Idx> {
|
||||||
graph: &'c G,
|
graph: &'c G,
|
||||||
|
|
||||||
/// The state of each node; used during walk to record the stack
|
/// The state of each node; used during walk to record the stack
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
|
||||||
use graph::test::TestGraph;
|
use crate::graph::test::TestGraph;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use fx::FxHashMap;
|
use crate::fx::FxHashMap;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
|
@ -257,7 +257,7 @@ macro_rules! newtype_index {
|
||||||
@type [$type:ident]
|
@type [$type:ident]
|
||||||
@debug_format [$debug_format:tt]) => (
|
@debug_format [$debug_format:tt]) => (
|
||||||
impl ::std::fmt::Debug for $type {
|
impl ::std::fmt::Debug for $type {
|
||||||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
write!(fmt, $debug_format, self.as_u32())
|
write!(fmt, $debug_format, self.as_u32())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ impl<I: Idx, T: serialize::Decodable> serialize::Decodable for IndexVec<I, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {
|
impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmt::Debug::fmt(&self.raw, fmt)
|
fmt::Debug::fmt(&self.raw, fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,7 +573,7 @@ impl<I: Idx, T> IndexVec<I, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter(&self) -> slice::Iter<T> {
|
pub fn iter(&self) -> slice::Iter<'_, T> {
|
||||||
self.raw.iter()
|
self.raw.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ impl<I: Idx, T> IndexVec<I, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter_mut(&mut self) -> slice::IterMut<T> {
|
pub fn iter_mut(&mut self) -> slice::IterMut<'_, T> {
|
||||||
self.raw.iter_mut()
|
self.raw.iter_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,23 +24,16 @@
|
||||||
#![cfg_attr(unix, feature(libc))]
|
#![cfg_attr(unix, feature(libc))]
|
||||||
#![cfg_attr(test, feature(test))]
|
#![cfg_attr(test, feature(test))]
|
||||||
|
|
||||||
extern crate core;
|
#![deny(rust_2018_idioms)]
|
||||||
extern crate ena;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
#[allow(unused_extern_crates)]
|
||||||
extern crate serialize as rustc_serialize; // used by deriving
|
extern crate serialize as rustc_serialize; // used by deriving
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate parking_lot;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate cfg_if;
|
extern crate cfg_if;
|
||||||
extern crate stable_deref_trait;
|
|
||||||
extern crate rustc_rayon as rayon;
|
|
||||||
extern crate rustc_rayon_core as rayon_core;
|
|
||||||
extern crate rustc_hash;
|
|
||||||
extern crate serialize;
|
|
||||||
extern crate graphviz;
|
|
||||||
extern crate smallvec;
|
|
||||||
|
|
||||||
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
use crate::obligation_forest::{ForestObligation, ObligationForest};
|
||||||
use graphviz as dot;
|
use graphviz as dot;
|
||||||
use obligation_forest::{ForestObligation, ObligationForest};
|
|
||||||
use std::env::var_os;
|
use std::env::var_os;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -41,22 +41,22 @@ impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest<O>
|
||||||
type Node = usize;
|
type Node = usize;
|
||||||
type Edge = (usize, usize);
|
type Edge = (usize, usize);
|
||||||
|
|
||||||
fn graph_id(&self) -> dot::Id {
|
fn graph_id(&self) -> dot::Id<'_> {
|
||||||
dot::Id::new("trait_obligation_forest").unwrap()
|
dot::Id::new("trait_obligation_forest").unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_id(&self, index: &Self::Node) -> dot::Id {
|
fn node_id(&self, index: &Self::Node) -> dot::Id<'_> {
|
||||||
dot::Id::new(format!("obligation_{}", index)).unwrap()
|
dot::Id::new(format!("obligation_{}", index)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_label(&self, index: &Self::Node) -> dot::LabelText {
|
fn node_label(&self, index: &Self::Node) -> dot::LabelText<'_> {
|
||||||
let node = &self.nodes[*index];
|
let node = &self.nodes[*index];
|
||||||
let label = format!("{:?} ({:?})", node.obligation.as_predicate(), node.state.get());
|
let label = format!("{:?} ({:?})", node.obligation.as_predicate(), node.state.get());
|
||||||
|
|
||||||
dot::LabelText::LabelStr(label.into())
|
dot::LabelText::LabelStr(label.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText {
|
fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText<'_> {
|
||||||
dot::LabelText::LabelStr("".into())
|
dot::LabelText::LabelStr("".into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,11 @@ impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest<O
|
||||||
type Node = usize;
|
type Node = usize;
|
||||||
type Edge = (usize, usize);
|
type Edge = (usize, usize);
|
||||||
|
|
||||||
fn nodes(&self) -> dot::Nodes<Self::Node> {
|
fn nodes(&self) -> dot::Nodes<'_, Self::Node> {
|
||||||
(0..self.nodes.len()).collect()
|
(0..self.nodes.len()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edges(&self) -> dot::Edges<Self::Edge> {
|
fn edges(&self) -> dot::Edges<'_, Self::Edge> {
|
||||||
(0..self.nodes.len())
|
(0..self.nodes.len())
|
||||||
.flat_map(|i| {
|
.flat_map(|i| {
|
||||||
let node = &self.nodes[i];
|
let node = &self.nodes[i];
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
//! processing step, we compress the vector to remove completed and error
|
//! processing step, we compress the vector to remove completed and error
|
||||||
//! nodes, which aren't needed anymore.
|
//! nodes, which aren't needed anymore.
|
||||||
|
|
||||||
use fx::{FxHashMap, FxHashSet};
|
use crate::fx::{FxHashMap, FxHashSet};
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
@ -733,7 +733,7 @@ impl<O> Node<O> {
|
||||||
|
|
||||||
// I need a Clone closure
|
// I need a Clone closure
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct GetObligation<'a, O: 'a>(&'a [Node<O>]);
|
struct GetObligation<'a, O>(&'a [Node<O>]);
|
||||||
|
|
||||||
impl<'a, 'b, O> FnOnce<(&'b usize,)> for GetObligation<'a, O> {
|
impl<'a, 'b, O> FnOnce<(&'b usize,)> for GetObligation<'a, O> {
|
||||||
type Output = &'a O;
|
type Output = &'a O;
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ impl<O, T: ?Sized> Debug for OwningRef<O, T>
|
||||||
where O: Debug,
|
where O: Debug,
|
||||||
T: Debug,
|
T: Debug,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f,
|
write!(f,
|
||||||
"OwningRef {{ owner: {:?}, reference: {:?} }}",
|
"OwningRef {{ owner: {:?}, reference: {:?} }}",
|
||||||
self.owner(),
|
self.owner(),
|
||||||
|
@ -1014,7 +1014,7 @@ impl<O, T: ?Sized> Debug for OwningRefMut<O, T>
|
||||||
where O: Debug,
|
where O: Debug,
|
||||||
T: Debug,
|
T: Debug,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f,
|
write!(f,
|
||||||
"OwningRefMut {{ owner: {:?}, reference: {:?} }}",
|
"OwningRefMut {{ owner: {:?}, reference: {:?} }}",
|
||||||
self.owner(),
|
self.owner(),
|
||||||
|
@ -1047,7 +1047,7 @@ unsafe impl<O, T: ?Sized> Sync for OwningRefMut<O, T>
|
||||||
where O: Sync, for<'a> (&'a mut T): Sync {}
|
where O: Sync, for<'a> (&'a mut T): Sync {}
|
||||||
|
|
||||||
impl Debug for dyn Erased {
|
impl Debug for dyn Erased {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "<Erased>",)
|
write!(f, "<Erased>",)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::ops::Deref;
|
||||||
/// A wrapper around reference that compares and hashes like a pointer.
|
/// A wrapper around reference that compares and hashes like a pointer.
|
||||||
/// Can be used as a key in sets/maps indexed by pointers to avoid `unsafe`.
|
/// Can be used as a key in sets/maps indexed by pointers to avoid `unsafe`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PtrKey<'a, T: 'a>(pub &'a T);
|
pub struct PtrKey<'a, T>(pub &'a T);
|
||||||
|
|
||||||
impl<'a, T> Clone for PtrKey<'a, T> {
|
impl<'a, T> Clone for PtrKey<'a, T> {
|
||||||
fn clone(&self) -> Self { *self }
|
fn clone(&self) -> Self { *self }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use fx::FxHashMap;
|
use crate::fx::FxHashMap;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl<K: Ord, V> SortedMap<K, V> {
|
||||||
|
|
||||||
/// Iterate over elements, sorted by key
|
/// Iterate over elements, sorted by key
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter(&self) -> ::std::slice::Iter<(K, V)> {
|
pub fn iter(&self) -> ::std::slice::Iter<'_, (K, V)> {
|
||||||
self.data.iter()
|
self.data.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use std::hash::{Hash, Hasher, BuildHasher};
|
use std::hash::{Hash, Hasher, BuildHasher};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use sip128::SipHasher128;
|
use crate::sip128::SipHasher128;
|
||||||
|
use crate::indexed_vec;
|
||||||
|
use crate::bit_set;
|
||||||
|
|
||||||
/// When hashing something that ends up affecting properties like symbol names,
|
/// When hashing something that ends up affecting properties like symbol names,
|
||||||
/// we want these symbol names to be calculated independently of other factors
|
/// we want these symbol names to be calculated independently of other factors
|
||||||
|
@ -17,7 +19,7 @@ pub struct StableHasher<W> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: StableHasherResult> ::std::fmt::Debug for StableHasher<W> {
|
impl<W: StableHasherResult> ::std::fmt::Debug for StableHasher<W> {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
write!(f, "{:?}", self.state)
|
write!(f, "{:?}", self.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,7 +435,7 @@ impl<T, CTX> HashStable<CTX> for ::std::mem::Discriminant<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: ::indexed_vec::Idx, T, CTX> HashStable<CTX> for ::indexed_vec::IndexVec<I, T>
|
impl<I: indexed_vec::Idx, T, CTX> HashStable<CTX> for indexed_vec::IndexVec<I, T>
|
||||||
where T: HashStable<CTX>,
|
where T: HashStable<CTX>,
|
||||||
{
|
{
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
fn hash_stable<W: StableHasherResult>(&self,
|
||||||
|
@ -447,7 +449,7 @@ impl<I: ::indexed_vec::Idx, T, CTX> HashStable<CTX> for ::indexed_vec::IndexVec<
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<I: ::indexed_vec::Idx, CTX> HashStable<CTX> for ::bit_set::BitSet<I>
|
impl<I: indexed_vec::Idx, CTX> HashStable<CTX> for bit_set::BitSet<I>
|
||||||
{
|
{
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
fn hash_stable<W: StableHasherResult>(&self,
|
||||||
ctx: &mut CTX,
|
ctx: &mut CTX,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
||||||
use stable_hasher;
|
use crate::stable_hasher;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Svh {
|
pub struct Svh {
|
||||||
|
@ -40,7 +40,7 @@ impl Hash for Svh {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Svh {
|
impl fmt::Display for Svh {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.pad(&self.to_string())
|
f.pad(&self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ use std::collections::HashMap;
|
||||||
use std::hash::{Hash, BuildHasher};
|
use std::hash::{Hash, BuildHasher};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use owning_ref::{Erased, OwningRef};
|
use crate::owning_ref::{Erased, OwningRef};
|
||||||
|
|
||||||
pub fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
|
pub fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
|
||||||
where A: FnOnce() -> RA,
|
where A: FnOnce() -> RA,
|
||||||
|
@ -261,12 +261,12 @@ cfg_if! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn lock(&self) -> LockGuard<T> {
|
pub fn lock(&self) -> LockGuard<'_, T> {
|
||||||
self.0.lock()
|
self.0.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn lock_mut(&self) -> LockGuard<T> {
|
pub fn lock_mut(&self) -> LockGuard<'_, T> {
|
||||||
self.lock()
|
self.lock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,19 +490,19 @@ impl<T> Lock<T> {
|
||||||
|
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn try_lock(&self) -> Option<LockGuard<T>> {
|
pub fn try_lock(&self) -> Option<LockGuard<'_, T>> {
|
||||||
self.0.try_lock()
|
self.0.try_lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(parallel_compiler))]
|
#[cfg(not(parallel_compiler))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn try_lock(&self) -> Option<LockGuard<T>> {
|
pub fn try_lock(&self) -> Option<LockGuard<'_, T>> {
|
||||||
self.0.try_borrow_mut().ok()
|
self.0.try_borrow_mut().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn lock(&self) -> LockGuard<T> {
|
pub fn lock(&self) -> LockGuard<'_, T> {
|
||||||
if ERROR_CHECKING {
|
if ERROR_CHECKING {
|
||||||
self.0.try_lock().expect("lock was already held")
|
self.0.try_lock().expect("lock was already held")
|
||||||
} else {
|
} else {
|
||||||
|
@ -512,7 +512,7 @@ impl<T> Lock<T> {
|
||||||
|
|
||||||
#[cfg(not(parallel_compiler))]
|
#[cfg(not(parallel_compiler))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn lock(&self) -> LockGuard<T> {
|
pub fn lock(&self) -> LockGuard<'_, T> {
|
||||||
self.0.borrow_mut()
|
self.0.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,12 +522,12 @@ impl<T> Lock<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn borrow(&self) -> LockGuard<T> {
|
pub fn borrow(&self) -> LockGuard<'_, T> {
|
||||||
self.lock()
|
self.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn borrow_mut(&self) -> LockGuard<T> {
|
pub fn borrow_mut(&self) -> LockGuard<'_, T> {
|
||||||
self.lock()
|
self.lock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -568,13 +568,13 @@ impl<T> RwLock<T> {
|
||||||
|
|
||||||
#[cfg(not(parallel_compiler))]
|
#[cfg(not(parallel_compiler))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn read(&self) -> ReadGuard<T> {
|
pub fn read(&self) -> ReadGuard<'_, T> {
|
||||||
self.0.borrow()
|
self.0.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn read(&self) -> ReadGuard<T> {
|
pub fn read(&self) -> ReadGuard<'_, T> {
|
||||||
if ERROR_CHECKING {
|
if ERROR_CHECKING {
|
||||||
self.0.try_read().expect("lock was already held")
|
self.0.try_read().expect("lock was already held")
|
||||||
} else {
|
} else {
|
||||||
|
@ -589,25 +589,25 @@ impl<T> RwLock<T> {
|
||||||
|
|
||||||
#[cfg(not(parallel_compiler))]
|
#[cfg(not(parallel_compiler))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn try_write(&self) -> Result<WriteGuard<T>, ()> {
|
pub fn try_write(&self) -> Result<WriteGuard<'_, T>, ()> {
|
||||||
self.0.try_borrow_mut().map_err(|_| ())
|
self.0.try_borrow_mut().map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn try_write(&self) -> Result<WriteGuard<T>, ()> {
|
pub fn try_write(&self) -> Result<WriteGuard<'_, T>, ()> {
|
||||||
self.0.try_write().ok_or(())
|
self.0.try_write().ok_or(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(parallel_compiler))]
|
#[cfg(not(parallel_compiler))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn write(&self) -> WriteGuard<T> {
|
pub fn write(&self) -> WriteGuard<'_, T> {
|
||||||
self.0.borrow_mut()
|
self.0.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn write(&self) -> WriteGuard<T> {
|
pub fn write(&self) -> WriteGuard<'_, T> {
|
||||||
if ERROR_CHECKING {
|
if ERROR_CHECKING {
|
||||||
self.0.try_write().expect("lock was already held")
|
self.0.try_write().expect("lock was already held")
|
||||||
} else {
|
} else {
|
||||||
|
@ -621,12 +621,12 @@ impl<T> RwLock<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn borrow(&self) -> ReadGuard<T> {
|
pub fn borrow(&self) -> ReadGuard<'_, T> {
|
||||||
self.read()
|
self.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn borrow_mut(&self) -> WriteGuard<T> {
|
pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
|
||||||
self.write()
|
self.write()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl<T: PartialEq> Element<T> {
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
use self::test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_contains_and_insert() {
|
fn test_contains_and_insert() {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use bit_set::BitMatrix;
|
use crate::bit_set::BitMatrix;
|
||||||
use fx::FxHashMap;
|
use crate::fx::FxHashMap;
|
||||||
use sync::Lock;
|
use crate::stable_hasher::{HashStable, StableHasher, StableHasherResult};
|
||||||
|
use crate::sync::Lock;
|
||||||
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
|
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
|
||||||
use stable_hasher::{HashStable, StableHasher, StableHasherResult};
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use indexed_vec::{Idx, IndexVec};
|
use crate::indexed_vec::{Idx, IndexVec};
|
||||||
|
|
||||||
pub fn iter<Ls>(
|
pub fn iter<Ls>(
|
||||||
first: Option<Ls::LinkIndex>,
|
first: Option<Ls::LinkIndex>,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use bit_set::BitSet;
|
use crate::bit_set::BitSet;
|
||||||
use indexed_vec::Idx;
|
use crate::indexed_vec::Idx;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
/// A work queue is a handy data structure for tracking work left to
|
/// A work queue is a handy data structure for tracking work left to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue