Skip to content

Commit a9d7e36

Browse files
committed
Fix numerous typos, renamings, and minor nits raised by mw.
1 parent 11c671b commit a9d7e36

File tree

6 files changed

+35
-29
lines changed

6 files changed

+35
-29
lines changed

src/librustc/dep_graph/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ However, you should rarely need to invoke those methods directly.
123123
Instead, the idea is to *encapsulate* shared state into some API that
124124
will invoke `read` and `write` automatically. The most common way to
125125
do this is to use a `DepTrackingMap`, described in the next section,
126-
but any sort of abstraction brarier will do. In general, the strategy
126+
but any sort of abstraction barrier will do. In general, the strategy
127127
is that getting access to information implicitly adds an appropriate
128128
`read`. So, for example, when you use the
129129
`dep_graph::visit_all_items_in_krate` helper method, it will visit
@@ -197,7 +197,7 @@ from/to the node `DepNode::Variant(K)` (for some variant specific to
197197
the map).
198198

199199
Each `DepTrackingMap` is parameterized by a special type `M` that
200-
implements `DepTrackingMapId`; this trait defines the key and value
200+
implements `DepTrackingMapConfig`; this trait defines the key and value
201201
types of the map, and also defines a fn for converting from the key to
202202
a `DepNode` label. You don't usually have to muck about with this by
203203
hand, there is a macro for creating it. You can see the complete set
@@ -221,7 +221,13 @@ of the map will be a `DefId` and value will be
221221
`DepNode::ItemSignature(K)` for a given key.
222222

223223
Once that is done, you can just use the `DepTrackingMap` like any
224-
other map.
224+
other map:
225+
226+
```rust
227+
let mut map: DepTrackingMap<M> = DepTrackingMap::new(dep_graph);
228+
map.insert(key, value); // registers dep_graph.write
229+
map.get(key; // registers dep_graph.read
230+
```
225231

226232
#### Memoization
227233

@@ -305,7 +311,7 @@ distinguish which fns used which fn sigs.
305311

306312
There are various ways to write tests against the dependency graph.
307313
The simplest mechanism are the
308-
`#[rustc_if_this_changed` and `#[rustc_then_this_would_need]`
314+
`#[rustc_if_this_changed]` and `#[rustc_then_this_would_need]`
309315
annotations. These are used in compile-fail tests to test whether the
310316
expected set of paths exist in the dependency graph. As an example,
311317
see `src/test/compile-fail/dep-graph-caller-callee.rs`.
@@ -354,7 +360,7 @@ source_filter // nodes originating from source_filter
354360
source_filter -> target_filter // nodes in between source_filter and target_filter
355361
```
356362

357-
`source_filter` and `target_filter` are a comma-separated list of strings.
363+
`source_filter` and `target_filter` are a `&`-separated list of strings.
358364
A node is considered to match a filter if all of those strings appear in its
359365
label. So, for example:
360366

@@ -363,10 +369,10 @@ RUST_DEP_GRAPH_FILTER='-> TypeckItemBody'
363369
```
364370

365371
would select the predecessors of all `TypeckItemBody` nodes. Usually though you
366-
want the `TypeckItemBody` nod for some particular fn, so you might write:
372+
want the `TypeckItemBody` node for some particular fn, so you might write:
367373

368374
```
369-
RUST_DEP_GRAPH_FILTER='-> TypeckItemBody,bar'
375+
RUST_DEP_GRAPH_FILTER='-> TypeckItemBody & bar'
370376
```
371377

372378
This will select only the `TypeckItemBody` nodes for fns with `bar` in their name.
@@ -375,7 +381,7 @@ Perhaps you are finding that when you change `foo` you need to re-type-check `ba
375381
but you don't think you should have to. In that case, you might do:
376382

377383
```
378-
RUST_DEP_GRAPH_FILTER='Hir,foo -> TypeckItemBody,bar'
384+
RUST_DEP_GRAPH_FILTER='Hir&foo -> TypeckItemBody & bar'
379385
```
380386

381387
This will dump out all the nodes that lead from `Hir(foo)` to

src/librustc/dep_graph/dep_tracking_map.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ use super::{DepNode, DepGraph};
2020
/// A DepTrackingMap offers a subset of the `Map` API and ensures that
2121
/// we make calls to `read` and `write` as appropriate. We key the
2222
/// maps with a unique type for brevity.
23-
pub struct DepTrackingMap<M: DepTrackingMapId> {
23+
pub struct DepTrackingMap<M: DepTrackingMapConfig> {
2424
phantom: PhantomData<M>,
2525
graph: DepGraph,
2626
map: FnvHashMap<M::Key, M::Value>,
2727
}
2828

29-
pub trait DepTrackingMapId {
29+
pub trait DepTrackingMapConfig {
3030
type Key: Eq + Hash + Clone;
3131
type Value: Clone;
3232
fn to_dep_node(key: &Self::Key) -> DepNode;
3333
}
3434

35-
impl<M: DepTrackingMapId> DepTrackingMap<M> {
35+
impl<M: DepTrackingMapConfig> DepTrackingMap<M> {
3636
pub fn new(graph: DepGraph) -> DepTrackingMap<M> {
3737
DepTrackingMap {
3838
phantom: PhantomData,
@@ -71,7 +71,7 @@ impl<M: DepTrackingMapId> DepTrackingMap<M> {
7171
}
7272
}
7373

74-
impl<M: DepTrackingMapId> MemoizationMap for RefCell<DepTrackingMap<M>> {
74+
impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
7575
type Key = M::Key;
7676
type Value = M::Value;
7777

@@ -89,9 +89,9 @@ impl<M: DepTrackingMapId> MemoizationMap for RefCell<DepTrackingMap<M>> {
8989
/// **Important:* when `op` is invoked, the current task will be
9090
/// switched to `Map(key)`. Therefore, if `op` makes use of any
9191
/// HIR nodes or shared state accessed through its closure
92-
/// environment, it must explicitly read that state. As an
93-
/// example, see `type_scheme_of_item` in `collect`, which looks
94-
/// something like this:
92+
/// environment, it must explicitly register a read of that
93+
/// state. As an example, see `type_scheme_of_item` in `collect`,
94+
/// which looks something like this:
9595
///
9696
/// ```
9797
/// fn type_scheme_of_item(..., item: &hir::Item) -> ty::TypeScheme<'tcx> {
@@ -126,7 +126,7 @@ impl<M: DepTrackingMapId> MemoizationMap for RefCell<DepTrackingMap<M>> {
126126
}
127127
}
128128

129-
impl<'k, M: DepTrackingMapId> Index<&'k M::Key> for DepTrackingMap<M> {
129+
impl<'k, M: DepTrackingMapConfig> Index<&'k M::Key> for DepTrackingMap<M> {
130130
type Output = M::Value;
131131

132132
#[inline]

src/librustc/dep_graph/edges.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet};
1212
use super::{DepGraphQuery, DepNode};
1313

1414
pub struct DepGraphEdges {
15-
ids: Vec<DepNode>,
15+
nodes: Vec<DepNode>,
1616
indices: FnvHashMap<DepNode, IdIndex>,
1717
edges: FnvHashSet<(IdIndex, IdIndex)>,
1818
open_nodes: Vec<OpenNode>,
@@ -43,15 +43,15 @@ enum OpenNode {
4343
impl DepGraphEdges {
4444
pub fn new() -> DepGraphEdges {
4545
DepGraphEdges {
46-
ids: vec![],
46+
nodes: vec![],
4747
indices: FnvHashMap(),
4848
edges: FnvHashSet(),
4949
open_nodes: Vec::new()
5050
}
5151
}
5252

53-
fn id(&self, index: IdIndex) -> &DepNode {
54-
&self.ids[index.index()]
53+
fn id(&self, index: IdIndex) -> DepNode {
54+
self.nodes[index.index()]
5555
}
5656

5757
/// Creates a node for `id` in the graph.
@@ -60,8 +60,8 @@ impl DepGraphEdges {
6060
return i;
6161
}
6262

63-
let index = IdIndex::new(self.ids.len());
64-
self.ids.push(id.clone());
63+
let index = IdIndex::new(self.nodes.len());
64+
self.nodes.push(id.clone());
6565
self.indices.insert(id, index);
6666
index
6767
}
@@ -83,7 +83,7 @@ impl DepGraphEdges {
8383
pub fn push_task(&mut self, key: DepNode) {
8484
let top_node = self.current_node();
8585

86-
let new_node = self.make_node(key.clone());
86+
let new_node = self.make_node(key);
8787
self.open_nodes.push(OpenNode::Node(new_node));
8888

8989
// if we are in the midst of doing task T, then this new task
@@ -155,8 +155,8 @@ impl DepGraphEdges {
155155

156156
pub fn query(&self) -> DepGraphQuery {
157157
let edges: Vec<_> = self.edges.iter()
158-
.map(|&(i, j)| (self.id(i).clone(), self.id(j).clone()))
158+
.map(|&(i, j)| (self.id(i), self.id(j)))
159159
.collect();
160-
DepGraphQuery::new(&self.ids, &edges)
160+
DepGraphQuery::new(&self.nodes, &edges)
161161
}
162162
}

src/librustc/dep_graph/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl DepGraph {
152152
}
153153
}
154154

155-
pub use self::dep_tracking_map::{DepTrackingMap, DepTrackingMapId};
155+
pub use self::dep_tracking_map::{DepTrackingMap, DepTrackingMapConfig};
156156

157157
pub use self::query::DepGraphQuery;
158158

src/librustc/dep_graph/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct DepGraphThreadData {
4848
// where to send buffer when full
4949
swap_out: Sender<Vec<DepMessage>>,
5050

51-
// where to receiver query results
51+
// where to receive query results
5252
query_in: Receiver<DepGraphQuery>,
5353
}
5454

src/librustc/middle/ty/maps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use dep_graph::{DepNode, DepTrackingMapId};
11+
use dep_graph::{DepNode, DepTrackingMapConfig};
1212
use middle::def_id::DefId;
1313
use middle::ty;
1414
use std::marker::PhantomData;
@@ -20,7 +20,7 @@ macro_rules! dep_map_ty {
2020
data: PhantomData<&'tcx ()>
2121
}
2222

23-
impl<'tcx> DepTrackingMapId for $ty_name<'tcx> {
23+
impl<'tcx> DepTrackingMapConfig for $ty_name<'tcx> {
2424
type Key = $key;
2525
type Value = $value;
2626
fn to_dep_node(key: &$key) -> DepNode { DepNode::$node_name(*key) }

0 commit comments

Comments
 (0)