Skip to content

Commit 0b941ed

Browse files
Last DocContext/TyCtxt cleanup
1 parent 4b39934 commit 0b941ed

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

src/librustdoc/clean/mod.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ fn generate_item_with_correct_attrs(
184184
import_ids: &[LocalDefId],
185185
renamed: Option<Symbol>,
186186
) -> Item {
187-
let target_attrs = inline::load_attrs(cx.tcx, def_id);
187+
let tcx = cx.tcx;
188+
let target_attrs = inline::load_attrs(tcx, def_id);
188189
let attrs = if !import_ids.is_empty() {
189190
let mut attrs = Vec::with_capacity(import_ids.len());
190191
let mut is_inline = false;
@@ -196,11 +197,11 @@ fn generate_item_with_correct_attrs(
196197
// cfgs on the path up until the glob can be removed, and only cfgs on the globbed item
197198
// itself matter), for non-inlined re-exports see #85043.
198199
let import_is_inline = find_attr!(
199-
inline::load_attrs(cx.tcx, import_id.to_def_id()),
200+
inline::load_attrs(tcx, import_id.to_def_id()),
200201
Doc(d)
201202
if d.inline.first().is_some_and(|(inline, _)| *inline == DocInline::Inline)
202-
) || (is_glob_import(cx.tcx, import_id)
203-
&& (cx.document_hidden() || !cx.tcx.is_doc_hidden(def_id)));
203+
) || (is_glob_import(tcx, import_id)
204+
&& (cx.document_hidden() || !tcx.is_doc_hidden(def_id)));
204205
attrs.extend(get_all_import_attributes(cx, import_id, def_id, is_inline));
205206
is_inline = is_inline || import_is_inline;
206207
}
@@ -1458,15 +1459,15 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
14581459
bounds.retain(|b| {
14591460
// FIXME(sized-hierarchy): Always skip `MetaSized` bounds so that only `?Sized`
14601461
// is shown and none of the new sizedness traits leak into documentation.
1461-
!b.is_meta_sized_bound(cx.tcx)
1462+
!b.is_meta_sized_bound(tcx)
14621463
});
14631464

14641465
// Our Sized/?Sized bound didn't get handled when creating the generics
14651466
// because we didn't actually get our whole set of bounds until just now
14661467
// (some of them may have come from the trait). If we do have a sized
14671468
// bound, we remove it, and if we don't then we add the `?Sized` bound
14681469
// at the end.
1469-
match bounds.iter().position(|b| b.is_sized_bound(cx.tcx)) {
1470+
match bounds.iter().position(|b| b.is_sized_bound(tcx)) {
14701471
Some(i) => {
14711472
bounds.remove(i);
14721473
}
@@ -1516,7 +1517,7 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
15161517
}
15171518
};
15181519

1519-
Item::from_def_id_and_parts(assoc_item.def_id, Some(assoc_item.name()), kind, cx.tcx)
1520+
Item::from_def_id_and_parts(assoc_item.def_id, Some(assoc_item.name()), kind, tcx)
15201521
}
15211522

15221523
fn first_non_private_clean_path<'tcx>(
@@ -2767,12 +2768,8 @@ fn clean_maybe_renamed_item<'tcx>(
27672768
import_ids: &[LocalDefId],
27682769
) -> Vec<Item> {
27692770
use hir::ItemKind;
2770-
fn get_name(
2771-
cx: &DocContext<'_>,
2772-
item: &hir::Item<'_>,
2773-
renamed: Option<Symbol>,
2774-
) -> Option<Symbol> {
2775-
renamed.or_else(|| cx.tcx.hir_opt_name(item.hir_id()))
2771+
fn get_name(tcx: TyCtxt<'_>, item: &hir::Item<'_>, renamed: Option<Symbol>) -> Option<Symbol> {
2772+
renamed.or_else(|| tcx.hir_opt_name(item.hir_id()))
27762773
}
27772774

27782775
let def_id = item.owner_id.to_def_id();
@@ -2789,7 +2786,7 @@ fn clean_maybe_renamed_item<'tcx>(
27892786
ItemKind::Use(path, kind) => {
27902787
return clean_use_statement(
27912788
item,
2792-
get_name(cx, item, renamed),
2789+
get_name(cx.tcx, item, renamed),
27932790
path,
27942791
kind,
27952792
cx,
@@ -2799,7 +2796,7 @@ fn clean_maybe_renamed_item<'tcx>(
27992796
_ => {}
28002797
}
28012798

2802-
let mut name = get_name(cx, item, renamed).unwrap();
2799+
let mut name = get_name(cx.tcx, item, renamed).unwrap();
28032800

28042801
let kind = match item.kind {
28052802
ItemKind::Static(mutability, _, ty, body_id) => StaticItem(Static {

0 commit comments

Comments
 (0)