about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/counters.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-03 21:10:22 +0000
committerbors <bors@rust-lang.org>2021-11-03 21:10:22 +0000
commit4ff90232a0c0c6adb9d2052da2206b26c3c723e4 (patch)
tree3dbec732404540d443efcd85604821982c2d2252 /compiler/rustc_mir_transform/src/coverage/counters.rs
parentbaba6687df3e83fdb15cc6ec239b4a1c75a30505 (diff)
parent8e4bcdf84b2f07d0a3e0aac21b85b54b14031f33 (diff)
downloadrust-4ff90232a0c0c6adb9d2052da2206b26c3c723e4.tar.gz
rust-4ff90232a0c0c6adb9d2052da2206b26c3c723e4.zip
Auto merge of #90475 - camelid:docvisitor, r=notriddle
rustdoc: Add `DocVisitor` and use it where possible

`DocFolder` allows transforming the docs, accomplished by making its methods take and return types by-value. However, several of the rustdoc `DocFolder` impls only *visit* the docs; they don't change anything. Passing around types by-value is thus unnecessary, confusing, and potentially inefficient for those impls.

`DocVisitor` is very similar to `DocFolder`, except that its methods take shared references and return nothing (i.e., the unit type). This should both be more efficient and make the code clearer.

There is an additional reason to add `DocVisitor`, too. As part of my cleanup of `external_traits`, I'm planning to add a `fn cache(&mut self) -> &mut Cache` method to `DocFolder` so that `external_traits` can be retrieved explicitly from the `Cache`, rather than implicitly via `Crate.external_traits` (which is an `Rc<RefCell<...>>`). However, some of the `DocFolder` impls that could be turned into `DocVisitor` impls only have a shared reference to the `Cache`, because they are used during rendering. (They have to access the `Cache` via `html::render::Context.shared.cache`, which involves an `Rc`.)

Since `DocVisitor` does not mutate any of the types it's visiting, its equivalent `cache()` method will only need a shared reference to the `Cache`, avoiding the problem described above.

r? `@GuillaumeGomez`
cc `@jyn514`
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/counters.rs')
0 files changed, 0 insertions, 0 deletions