Skip to content

Rollup of 8 pull requests #88874

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

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
04db063
Don't build the library and standard library before documenting them
jyn514 Sep 5, 2021
76e09eb
Do not unshallow -- already done by other code
Mark-Simulacrum Sep 6, 2021
c9d46eb
Rework DepthFirstSearch API
nikomatsakis Nov 23, 2020
2987f4b
WIP state
BoxyUwU Sep 6, 2021
9b29138
as casts and block exprs
BoxyUwU Sep 6, 2021
4483c2b
dont support blocks
BoxyUwU Sep 6, 2021
47b16f4
bless stderr
BoxyUwU Sep 6, 2021
c170dcf
tidy
BoxyUwU Sep 6, 2021
08e8644
move thir visitor to rustc_middle
BoxyUwU Sep 6, 2021
fc63e9a
dont build abstract const for monomorphic consts
BoxyUwU Sep 6, 2021
4cbcb09
handle `ExprKind::NeverToAny`
BoxyUwU Sep 6, 2021
1f57f8b
remove `WorkNode`
BoxyUwU Sep 6, 2021
15101c8
remove debug stmts
BoxyUwU Sep 7, 2021
406d2ab
rename mir -> thir around abstract consts
BoxyUwU Sep 7, 2021
79be080
remove comment
BoxyUwU Sep 7, 2021
955e2b2
nits
BoxyUwU Sep 7, 2021
8c7954d
add a `CastKind` to `Node::Cast`
BoxyUwU Sep 7, 2021
3212734
resolve `from_hir_call` FIXME
BoxyUwU Sep 7, 2021
cd2915e
fmt
BoxyUwU Sep 7, 2021
fd9bb30
CI please
BoxyUwU Sep 7, 2021
c86c634
Allow missing code examples in trait impls.
hnj2 Sep 8, 2021
8295e4a
add test for builtin types N + N unifying with fn call
BoxyUwU Sep 9, 2021
44e6f2e
Remove unnecessary `Cache.*_did` fields
camelid Aug 22, 2021
294510e
rustc: Remove local variable IDs from `Export`s
petrochenkov Sep 5, 2021
03f9fe2
explicitly link to external `ena` docs
lcnr Sep 11, 2021
df281ee
Only take `tcx` when it's all that's needed
camelid Aug 27, 2021
0bb1c28
rustdoc: Get symbol for `TyParam` directly
camelid Aug 23, 2021
6a84d34
Create a valid `Res` in `external_path()`
camelid Aug 24, 2021
c2207f5
Remove unused `hir_id` parameter from `resolve_type`
camelid Aug 27, 2021
5321b35
Fix redundant arguments in `external_path()`
camelid Sep 11, 2021
913764d
Remove unnecessary `is_trait` argument
camelid Sep 11, 2021
280fc2d
rustdoc: Cleanup a pattern match in `external_generic_args()`
camelid Sep 11, 2021
f00af15
Rollup merge of #88675 - jyn514:faster-doc, r=Mark-Simulacrum
Manishearth Sep 12, 2021
68bb06a
Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco
Manishearth Sep 12, 2021
ae14fc4
Rollup merge of #88699 - Mark-Simulacrum:fixes-cherry-picker, r=pietr…
Manishearth Sep 12, 2021
4972d14
Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr
Manishearth Sep 12, 2021
543b8c0
Rollup merge of #88711 - Mark-Simulacrum:fix-dfs-bug, r=jackh726
Manishearth Sep 12, 2021
c134e96
Rollup merge of #88745 - hnj2:allow-trait-impl-missing-code, r=Guilla…
Manishearth Sep 12, 2021
49a7f5f
Rollup merge of #88810 - camelid:cleanup-pt1, r=jyn514
Manishearth Sep 12, 2021
d6b179b
Rollup merge of #88813 - lcnr:ena-docs, r=jyn514
Manishearth Sep 12, 2021
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
54 changes: 52 additions & 2 deletions compiler/rustc_data_structures/src/graph/iterate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,58 @@ impl<G> DepthFirstSearch<'graph, G>
where
G: ?Sized + DirectedGraph + WithNumNodes + WithSuccessors,
{
pub fn new(graph: &'graph G, start_node: G::Node) -> Self {
Self { graph, stack: vec![start_node], visited: BitSet::new_empty(graph.num_nodes()) }
pub fn new(graph: &'graph G) -> Self {
Self { graph, stack: vec![], visited: BitSet::new_empty(graph.num_nodes()) }
}

/// Version of `push_start_node` that is convenient for chained
/// use.
pub fn with_start_node(mut self, start_node: G::Node) -> Self {
self.push_start_node(start_node);
self
}

/// Pushes another start node onto the stack. If the node
/// has not already been visited, then you will be able to
/// walk its successors (and so forth) after the current
/// contents of the stack are drained. If multiple start nodes
/// are added into the walk, then their mutual successors
/// will all be walked. You can use this method once the
/// iterator has been completely drained to add additional
/// start nodes.
pub fn push_start_node(&mut self, start_node: G::Node) {
if self.visited.insert(start_node) {
self.stack.push(start_node);
}
}

/// Searches all nodes reachable from the current start nodes.
/// This is equivalent to just invoke `next` repeatedly until
/// you get a `None` result.
pub fn complete_search(&mut self) {
while let Some(_) = self.next() {}
}

/// Returns true if node has been visited thus far.
/// A node is considered "visited" once it is pushed
/// onto the internal stack; it may not yet have been yielded
/// from the iterator. This method is best used after
/// the iterator is completely drained.
pub fn visited(&self, node: G::Node) -> bool {
self.visited.contains(node)
}
}

impl<G> std::fmt::Debug for DepthFirstSearch<'_, G>
where
G: ?Sized + DirectedGraph + WithNumNodes + WithSuccessors,
{
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut f = fmt.debug_set();
for n in self.visited.iter() {
f.entry(&n);
}
f.finish()
}
}

Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_data_structures/src/graph/iterate/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ fn is_cyclic() {
assert!(!is_cyclic(&diamond_acyclic));
assert!(is_cyclic(&diamond_cyclic));
}

#[test]
fn dfs() {
let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3), (3, 0)]);

let result: Vec<usize> = DepthFirstSearch::new(&graph).with_start_node(0).collect();
assert_eq!(result, vec![0, 2, 3, 1]);
}

#[test]
fn dfs_debug() {
let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3), (3, 0)]);
let mut dfs = DepthFirstSearch::new(&graph).with_start_node(0);
dfs.complete_search();
assert_eq!(format!("{{0, 1, 2, 3}}"), format!("{:?}", dfs));
}
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where
where
Self: WithNumNodes,
{
iterate::DepthFirstSearch::new(self, from)
iterate::DepthFirstSearch::new(self).with_start_node(from)
}
}

Expand Down