Skip to content

Commit 8b80bc1

Browse files
Revert "Improve code readability"
This reverts commit eb93d1b.
1 parent 286a632 commit 8b80bc1

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

src/librustdoc/html/render/write_shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub(super) fn write_shared(
138138
Ok((ret, krates))
139139
}
140140

141-
/// Read a file and return all lines that match the <code>"{crate}":{data},\ </code> format,
141+
/// Read a file and return all lines that match the <code>"{crate}":{data},\</code> format,
142142
/// and return a tuple `(Vec<DataString>, Vec<CrateNameString>)`.
143143
///
144144
/// This forms the payload of files that look like this:

src/librustdoc/visit_ast.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
187187
ret
188188
}
189189

190-
#[inline]
191-
fn add_to_current_mod(
192-
&mut self,
193-
item: &'tcx hir::Item<'_>,
194-
renamed: Option<Symbol>,
195-
parent_id: Option<hir::HirId>,
196-
) {
197-
self.modules.last_mut().unwrap().items.push((item, renamed, parent_id))
198-
}
199-
200190
fn visit_item_inner(
201191
&mut self,
202192
item: &'tcx hir::Item<'_>,
@@ -257,7 +247,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
257247
}
258248
}
259249

260-
self.add_to_current_mod(item, renamed, parent_id);
250+
self.modules.last_mut().unwrap().items.push((item, renamed, parent_id));
261251
}
262252
}
263253
hir::ItemKind::Macro(ref macro_def, _) => {
@@ -277,7 +267,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
277267
let nonexported = !self.cx.tcx.has_attr(def_id, sym::macro_export);
278268

279269
if is_macro_2_0 || nonexported || self.inlining {
280-
self.add_to_current_mod(item, renamed, None);
270+
self.modules.last_mut().unwrap().items.push((item, renamed, None));
281271
}
282272
}
283273
hir::ItemKind::Mod(ref m) => {
@@ -293,20 +283,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
293283
| hir::ItemKind::Static(..)
294284
| hir::ItemKind::Trait(..)
295285
| hir::ItemKind::TraitAlias(..) => {
296-
self.add_to_current_mod(item, renamed, parent_id);
286+
self.modules.last_mut().unwrap().items.push((item, renamed, parent_id))
297287
}
298288
hir::ItemKind::Const(..) => {
299289
// Underscore constants do not correspond to a nameable item and
300290
// so are never useful in documentation.
301291
if name != kw::Underscore {
302-
self.add_to_current_mod(item, renamed, parent_id);
292+
self.modules.last_mut().unwrap().items.push((item, renamed, parent_id));
303293
}
304294
}
305295
hir::ItemKind::Impl(impl_) => {
306296
// Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
307297
// them up regardless of where they're located.
308298
if !self.inlining && impl_.of_trait.is_none() {
309-
self.add_to_current_mod(item, None, None);
299+
self.modules.last_mut().unwrap().items.push((item, None, None));
310300
}
311301
}
312302
}
@@ -343,13 +333,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
343333
// macro in the same module.
344334
let mut inserted = FxHashSet::default();
345335
for export in self.cx.tcx.module_reexports(CRATE_DEF_ID).unwrap_or(&[]) {
346-
if let Res::Def(DefKind::Macro(_), def_id) = export.res &&
347-
let Some(local_def_id) = def_id.as_local() &&
348-
self.cx.tcx.has_attr(def_id, sym::macro_export) &&
349-
inserted.insert(def_id)
350-
{
351-
let item = self.cx.tcx.hir().expect_item(local_def_id);
352-
top_level_module.items.push((item, None, None));
336+
if let Res::Def(DefKind::Macro(_), def_id) = export.res {
337+
if let Some(local_def_id) = def_id.as_local() {
338+
if self.cx.tcx.has_attr(def_id, sym::macro_export) {
339+
if inserted.insert(def_id) {
340+
let item = self.cx.tcx.hir().expect_item(local_def_id);
341+
top_level_module.items.push((item, None, None));
342+
}
343+
}
344+
}
353345
}
354346
}
355347

0 commit comments

Comments
 (0)