Skip to content

Commit 068a926

Browse files
authored
Rollup merge of #58312 - taiki-e:librustc_data_structures-2018, r=Centril
librustc_data_structures => 2018 Transitions `librustc_data_structures` to Rust 2018; cc #58099 r? @Centril
2 parents 5e208f6 + 3e2b5a4 commit 068a926

25 files changed

+86
-107
lines changed

src/librustc_data_structures/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = ["The Rust Project Developers"]
33
name = "rustc_data_structures"
44
version = "0.0.0"
5+
edition = "2018"
56

67
[lib]
78
name = "rustc_data_structures"
@@ -16,8 +17,8 @@ serialize = { path = "../libserialize" }
1617
graphviz = { path = "../libgraphviz" }
1718
cfg-if = "0.1.2"
1819
stable_deref_trait = "1.0.0"
19-
rustc-rayon = "0.1.1"
20-
rustc-rayon-core = "0.1.1"
20+
rayon = { version = "0.1.1", package = "rustc-rayon" }
21+
rayon-core = { version = "0.1.1", package = "rustc-rayon-core" }
2122
rustc-hash = "1.0.1"
2223
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
2324

src/librustc_data_structures/bit_set.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use indexed_vec::{Idx, IndexVec};
1+
use crate::indexed_vec::{Idx, IndexVec};
22
use smallvec::SmallVec;
33
use std::fmt;
44
use std::iter;
@@ -208,7 +208,7 @@ impl<T: Idx> SubtractFromBitSet<T> for BitSet<T> {
208208
}
209209

210210
impl<T: Idx> fmt::Debug for BitSet<T> {
211-
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
211+
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
212212
w.debug_list()
213213
.entries(self.iter())
214214
.finish()
@@ -366,7 +366,7 @@ impl<T: Idx> SparseBitSet<T> {
366366
dense
367367
}
368368

369-
fn iter(&self) -> slice::Iter<T> {
369+
fn iter(&self) -> slice::Iter<'_, T> {
370370
self.elems.iter()
371371
}
372372
}
@@ -536,7 +536,7 @@ impl<T: Idx> HybridBitSet<T> {
536536
}
537537
}
538538

539-
pub fn iter(&self) -> HybridIter<T> {
539+
pub fn iter(&self) -> HybridIter<'_, T> {
540540
match self {
541541
HybridBitSet::Sparse(sparse) => HybridIter::Sparse(sparse.iter()),
542542
HybridBitSet::Dense(dense) => HybridIter::Dense(dense.iter()),

src/librustc_data_structures/fingerprint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::stable_hasher;
12
use std::mem;
2-
use stable_hasher;
33
use serialize;
44
use serialize::opaque::{EncodeResult, Encoder, Decoder};
55

@@ -70,7 +70,7 @@ impl Fingerprint {
7070
}
7171

7272
impl ::std::fmt::Display for Fingerprint {
73-
fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
73+
fn fmt(&self, formatter: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7474
write!(formatter, "{:x}-{:x}", self.0, self.1)
7575
}
7676
}

src/librustc_data_structures/flock.rs

-13
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ cfg_if! {
1414
if #[cfg(unix)] {
1515
use std::ffi::{CString, OsStr};
1616
use std::os::unix::prelude::*;
17-
use libc;
1817

1918
#[cfg(any(target_os = "linux", target_os = "android"))]
2019
mod os {
21-
use libc;
22-
2320
#[repr(C)]
2421
pub struct flock {
2522
pub l_type: libc::c_short,
@@ -35,8 +32,6 @@ cfg_if! {
3532

3633
#[cfg(target_os = "freebsd")]
3734
mod os {
38-
use libc;
39-
4035
#[repr(C)]
4136
pub struct flock {
4237
pub l_start: libc::off_t,
@@ -53,8 +48,6 @@ cfg_if! {
5348
target_os = "netbsd",
5449
target_os = "openbsd"))]
5550
mod os {
56-
use libc;
57-
5851
#[repr(C)]
5952
pub struct flock {
6053
pub l_start: libc::off_t,
@@ -70,8 +63,6 @@ cfg_if! {
7063

7164
#[cfg(target_os = "haiku")]
7265
mod os {
73-
use libc;
74-
7566
#[repr(C)]
7667
pub struct flock {
7768
pub l_type: libc::c_short,
@@ -87,8 +78,6 @@ cfg_if! {
8778

8879
#[cfg(any(target_os = "macos", target_os = "ios"))]
8980
mod os {
90-
use libc;
91-
9281
#[repr(C)]
9382
pub struct flock {
9483
pub l_start: libc::off_t,
@@ -104,8 +93,6 @@ cfg_if! {
10493

10594
#[cfg(target_os = "solaris")]
10695
mod os {
107-
use libc;
108-
10996
#[repr(C)]
11097
pub struct flock {
11198
pub l_type: libc::c_short,

src/librustc_data_structures/graph/dominators/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<Node: Idx> Dominators<Node> {
117117
self.immediate_dominators[node].unwrap()
118118
}
119119

120-
pub fn dominators(&self, node: Node) -> Iter<Node> {
120+
pub fn dominators(&self, node: Node) -> Iter<'_, Node> {
121121
assert!(self.is_reachable(node), "node {:?} is not reachable", node);
122122
Iter {
123123
dominators: self,
@@ -136,7 +136,7 @@ impl<Node: Idx> Dominators<Node> {
136136
}
137137
}
138138

139-
pub struct Iter<'dom, Node: Idx + 'dom> {
139+
pub struct Iter<'dom, Node: Idx> {
140140
dominators: &'dom Dominators<Node>,
141141
node: Option<Node>,
142142
}
@@ -171,7 +171,7 @@ impl<Node: Idx> DominatorTree<Node> {
171171
}
172172

173173
impl<Node: Idx> fmt::Debug for DominatorTree<Node> {
174-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
174+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
175175
fmt::Debug::fmt(
176176
&DominatorTreeNode {
177177
tree: self,
@@ -188,7 +188,7 @@ struct DominatorTreeNode<'tree, Node: Idx> {
188188
}
189189

190190
impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> {
191-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
191+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
192192
let subtrees: Vec<_> = self.tree
193193
.children(self.node)
194194
.iter()

src/librustc_data_structures/graph/implementation/mod.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
//! the field `next_edge`). Each of those fields is an array that should
2121
//! be indexed by the direction (see the type `Direction`).
2222
23-
use bit_set::BitSet;
23+
use crate::bit_set::BitSet;
24+
use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
2425
use std::fmt::Debug;
2526
use std::usize;
26-
use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
2727

2828
#[cfg(test)]
2929
mod tests;
@@ -212,15 +212,19 @@ impl<N: Debug, E: Debug> Graph<N, E> {
212212
.all(|(edge_idx, edge)| f(edge_idx, edge))
213213
}
214214

215-
pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
215+
pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> {
216216
self.adjacent_edges(source, OUTGOING)
217217
}
218218

219-
pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
219+
pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> {
220220
self.adjacent_edges(source, INCOMING)
221221
}
222222

223-
pub fn adjacent_edges(&self, source: NodeIndex, direction: Direction) -> AdjacentEdges<N, E> {
223+
pub fn adjacent_edges(
224+
&self,
225+
source: NodeIndex,
226+
direction: Direction
227+
) -> AdjacentEdges<'_, N, E> {
224228
let first_edge = self.node(source).first_edge[direction.repr];
225229
AdjacentEdges {
226230
graph: self,
@@ -291,11 +295,7 @@ impl<N: Debug, E: Debug> Graph<N, E> {
291295

292296
// # Iterators
293297

294-
pub struct AdjacentEdges<'g, N, E>
295-
where
296-
N: 'g,
297-
E: 'g,
298-
{
298+
pub struct AdjacentEdges<'g, N, E> {
299299
graph: &'g Graph<N, E>,
300300
direction: Direction,
301301
next: EdgeIndex,
@@ -331,11 +331,7 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> {
331331
}
332332
}
333333

334-
pub struct DepthFirstTraversal<'g, N, E>
335-
where
336-
N: 'g,
337-
E: 'g,
338-
{
334+
pub struct DepthFirstTraversal<'g, N, E> {
339335
graph: &'g Graph<N, E>,
340336
stack: Vec<NodeIndex>,
341337
visited: BitSet<usize>,

src/librustc_data_structures/graph/implementation/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use graph::implementation::*;
1+
use crate::graph::implementation::*;
22
use std::fmt::Debug;
33

44
type TestGraph = Graph<&'static str, &'static str>;

src/librustc_data_structures/graph/scc/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! node in the graph. This uses Tarjan's algorithm that completes in
44
//! O(n) time.
55
6-
use fx::FxHashSet;
7-
use graph::{DirectedGraph, WithNumNodes, WithSuccessors};
8-
use indexed_vec::{Idx, IndexVec};
6+
use crate::fx::FxHashSet;
7+
use crate::graph::{DirectedGraph, WithNumNodes, WithSuccessors};
8+
use crate::indexed_vec::{Idx, IndexVec};
99
use std::ops::Range;
1010

1111
mod test;
@@ -93,7 +93,7 @@ impl<S: Idx> SccData<S> {
9393
}
9494
}
9595

96-
struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors + 'c, S: Idx> {
96+
struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors, S: Idx> {
9797
graph: &'c G,
9898

9999
/// The state of each node; used during walk to record the stack

src/librustc_data_structures/graph/scc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![cfg(test)]
22

3-
use graph::test::TestGraph;
3+
use crate::graph::test::TestGraph;
44
use super::*;
55

66
#[test]

src/librustc_data_structures/graph/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use fx::FxHashMap;
1+
use crate::fx::FxHashMap;
22
use std::cmp::max;
33
use std::slice;
44
use std::iter;

src/librustc_data_structures/indexed_vec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ macro_rules! newtype_index {
257257
@type [$type:ident]
258258
@debug_format [$debug_format:tt]) => (
259259
impl ::std::fmt::Debug for $type {
260-
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
260+
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
261261
write!(fmt, $debug_format, self.as_u32())
262262
}
263263
}
@@ -495,7 +495,7 @@ impl<I: Idx, T: serialize::Decodable> serialize::Decodable for IndexVec<I, T> {
495495
}
496496

497497
impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {
498-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
498+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
499499
fmt::Debug::fmt(&self.raw, fmt)
500500
}
501501
}
@@ -573,7 +573,7 @@ impl<I: Idx, T> IndexVec<I, T> {
573573
}
574574

575575
#[inline]
576-
pub fn iter(&self) -> slice::Iter<T> {
576+
pub fn iter(&self) -> slice::Iter<'_, T> {
577577
self.raw.iter()
578578
}
579579

@@ -589,7 +589,7 @@ impl<I: Idx, T> IndexVec<I, T> {
589589
}
590590

591591
#[inline]
592-
pub fn iter_mut(&mut self) -> slice::IterMut<T> {
592+
pub fn iter_mut(&mut self) -> slice::IterMut<'_, T> {
593593
self.raw.iter_mut()
594594
}
595595

src/librustc_data_structures/lib.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,16 @@
2424
#![cfg_attr(unix, feature(libc))]
2525
#![cfg_attr(test, feature(test))]
2626

27-
extern crate core;
28-
extern crate ena;
27+
#![deny(rust_2018_idioms)]
28+
2929
#[macro_use]
3030
extern crate log;
31+
#[allow(unused_extern_crates)]
3132
extern crate serialize as rustc_serialize; // used by deriving
3233
#[cfg(unix)]
3334
extern crate libc;
34-
extern crate parking_lot;
3535
#[macro_use]
3636
extern crate cfg_if;
37-
extern crate stable_deref_trait;
38-
extern crate rustc_rayon as rayon;
39-
extern crate rustc_rayon_core as rayon_core;
40-
extern crate rustc_hash;
41-
extern crate serialize;
42-
extern crate graphviz;
43-
extern crate smallvec;
4437

4538
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
4639
#[allow(unused_extern_crates)]

src/librustc_data_structures/obligation_forest/graphviz.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::obligation_forest::{ForestObligation, ObligationForest};
12
use graphviz as dot;
2-
use obligation_forest::{ForestObligation, ObligationForest};
33
use std::env::var_os;
44
use std::fs::File;
55
use std::path::Path;
@@ -41,22 +41,22 @@ impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest<O>
4141
type Node = usize;
4242
type Edge = (usize, usize);
4343

44-
fn graph_id(&self) -> dot::Id {
44+
fn graph_id(&self) -> dot::Id<'_> {
4545
dot::Id::new("trait_obligation_forest").unwrap()
4646
}
4747

48-
fn node_id(&self, index: &Self::Node) -> dot::Id {
48+
fn node_id(&self, index: &Self::Node) -> dot::Id<'_> {
4949
dot::Id::new(format!("obligation_{}", index)).unwrap()
5050
}
5151

52-
fn node_label(&self, index: &Self::Node) -> dot::LabelText {
52+
fn node_label(&self, index: &Self::Node) -> dot::LabelText<'_> {
5353
let node = &self.nodes[*index];
5454
let label = format!("{:?} ({:?})", node.obligation.as_predicate(), node.state.get());
5555

5656
dot::LabelText::LabelStr(label.into())
5757
}
5858

59-
fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText {
59+
fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText<'_> {
6060
dot::LabelText::LabelStr("".into())
6161
}
6262
}
@@ -65,11 +65,11 @@ impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest<O
6565
type Node = usize;
6666
type Edge = (usize, usize);
6767

68-
fn nodes(&self) -> dot::Nodes<Self::Node> {
68+
fn nodes(&self) -> dot::Nodes<'_, Self::Node> {
6969
(0..self.nodes.len()).collect()
7070
}
7171

72-
fn edges(&self) -> dot::Edges<Self::Edge> {
72+
fn edges(&self) -> dot::Edges<'_, Self::Edge> {
7373
(0..self.nodes.len())
7474
.flat_map(|i| {
7575
let node = &self.nodes[i];

src/librustc_data_structures/obligation_forest/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
//! processing step, we compress the vector to remove completed and error
8181
//! nodes, which aren't needed anymore.
8282
83-
use fx::{FxHashMap, FxHashSet};
83+
use crate::fx::{FxHashMap, FxHashSet};
8484

8585
use std::cell::Cell;
8686
use std::collections::hash_map::Entry;
@@ -733,7 +733,7 @@ impl<O> Node<O> {
733733

734734
// I need a Clone closure
735735
#[derive(Clone)]
736-
struct GetObligation<'a, O: 'a>(&'a [Node<O>]);
736+
struct GetObligation<'a, O>(&'a [Node<O>]);
737737

738738
impl<'a, 'b, O> FnOnce<(&'b usize,)> for GetObligation<'a, O> {
739739
type Output = &'a O;

0 commit comments

Comments
 (0)