Skip to content

Commit 3984e42

Browse files
authored
Unrolled build for rust-lang#133764
Rollup merge of rust-lang#133764 - aDotInTheVoid:rename, r=GuillaumeGomez rustdoc: Rename `set_back_info` to `restore_module_data`. Follow-up to rust-lang#133345, r? `@GuillaumeGomez` Most of the references to `info` got removed as it was clear that `module_data` makes more sense here. Makes it clearer that `save_module_data` and `restore_module_data` are a pair.
2 parents 2633e01 + cb9838c commit 3984e42

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/librustdoc/formats/renderer.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ pub(crate) trait FormatRenderer<'tcx>: Sized {
1717
///
1818
/// This is true for html, and false for json. See #80664
1919
const RUN_ON_MODULE: bool;
20+
2021
/// This associated type is the type where the current module information is stored.
2122
///
2223
/// For each module, we go through their items by calling for each item:
2324
///
24-
/// 1. save_module_data
25-
/// 2. item
26-
/// 3. set_back_info
25+
/// 1. `save_module_data`
26+
/// 2. `item`
27+
/// 3. `restore_module_data`
2728
///
28-
/// However,the `item` method might update information in `self` (for example if the child is
29-
/// a module). To prevent it to impact the other children of the current module, we need to
30-
/// reset the information between each call to `item` by using `set_back_info`.
29+
/// This is because the `item` method might update information in `self` (for example if the child
30+
/// is a module). To prevent it from impacting the other children of the current module, we need to
31+
/// reset the information between each call to `item` by using `restore_module_data`.
3132
type ModuleData;
3233

3334
/// Sets up any state required for the renderer. When this is called the cache has already been
@@ -41,18 +42,18 @@ pub(crate) trait FormatRenderer<'tcx>: Sized {
4142

4243
/// This method is called right before call [`Self::item`]. This method returns a type
4344
/// containing information that needs to be reset after the [`Self::item`] method has been
44-
/// called with the [`Self::set_back_info`] method.
45+
/// called with the [`Self::restore_module_data`] method.
4546
///
4647
/// In short it goes like this:
4748
///
4849
/// ```ignore (not valid code)
49-
/// let reset_data = type.save_module_data();
50-
/// type.item(item)?;
51-
/// type.set_back_info(reset_data);
50+
/// let reset_data = renderer.save_module_data();
51+
/// renderer.item(item)?;
52+
/// renderer.restore_module_data(reset_data);
5253
/// ```
5354
fn save_module_data(&mut self) -> Self::ModuleData;
5455
/// Used to reset current module's information.
55-
fn set_back_info(&mut self, info: Self::ModuleData);
56+
fn restore_module_data(&mut self, info: Self::ModuleData);
5657

5758
/// Renders a single non-module item. This means no recursive sub-item rendering is required.
5859
fn item(&mut self, item: clean::Item) -> Result<(), Error>;
@@ -91,7 +92,7 @@ fn run_format_inner<'tcx, T: FormatRenderer<'tcx>>(
9192
for it in module.items {
9293
let info = cx.save_module_data();
9394
run_format_inner(cx, it, prof)?;
94-
cx.set_back_info(info);
95+
cx.restore_module_data(info);
9596
}
9697

9798
cx.mod_item_out()?;

src/librustdoc/html/render/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
601601
self.info
602602
}
603603

604-
fn set_back_info(&mut self, info: Self::ModuleData) {
604+
fn restore_module_data(&mut self, info: Self::ModuleData) {
605605
self.info = info;
606606
}
607607

src/librustdoc/json/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
163163
}
164164

165165
fn save_module_data(&mut self) -> Self::ModuleData {
166-
unreachable!("RUN_ON_MODULE = false should never call save_module_data")
166+
unreachable!("RUN_ON_MODULE = false, should never call save_module_data")
167167
}
168-
169-
fn set_back_info(&mut self, _info: Self::ModuleData) {
170-
unreachable!("RUN_ON_MODULE = false should never call set_back_info")
168+
fn restore_module_data(&mut self, _info: Self::ModuleData) {
169+
unreachable!("RUN_ON_MODULE = false, should never call set_back_info")
171170
}
172171

173172
/// Inserts an item into the index. This should be used rather than directly calling insert on
@@ -248,7 +247,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
248247
}
249248

250249
fn mod_item_in(&mut self, _item: &clean::Item) -> Result<(), Error> {
251-
unreachable!("RUN_ON_MODULE = false should never call mod_item_in")
250+
unreachable!("RUN_ON_MODULE = false, should never call mod_item_in")
252251
}
253252

254253
fn after_krate(&mut self) -> Result<(), Error> {

0 commit comments

Comments
 (0)