Skip to content

Commit 0185ff7

Browse files
committed
Remove extern crate tracing from librustdoc
1 parent 85d089b commit 0185ff7

28 files changed

+181
-140
lines changed

src/librustdoc/clean/auto_trait.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ where
4545
let tcx = self.cx.tcx;
4646
let trait_ref = ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, &[]) };
4747
if !self.cx.generated_synthetics.insert((ty, trait_def_id)) {
48-
debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref);
48+
tracing::debug!(
49+
"get_auto_trait_impl_for({:?}): already generated, aborting",
50+
trait_ref
51+
);
4952
return None;
5053
}
5154

@@ -70,10 +73,12 @@ where
7073
info.vid_to_region,
7174
);
7275

73-
debug!(
76+
tracing::debug!(
7477
"find_auto_trait_generics(item_def_id={:?}, trait_def_id={:?}): \
7578
finished with {:?}",
76-
item_def_id, trait_def_id, new_generics
79+
item_def_id,
80+
trait_def_id,
81+
new_generics
7782
);
7883

7984
new_generics
@@ -139,7 +144,7 @@ where
139144
let ty = tcx.type_of(item_def_id);
140145
let f = auto_trait::AutoTraitFinder::new(tcx);
141146

142-
debug!("get_auto_trait_impls({:?})", ty);
147+
tracing::debug!("get_auto_trait_impls({:?})", ty);
143148
let auto_traits: Vec<_> = self.cx.auto_traits.iter().copied().collect();
144149
let mut auto_traits: Vec<Item> = auto_traits
145150
.into_iter()
@@ -432,10 +437,12 @@ where
432437
mut existing_predicates: Vec<WherePredicate>,
433438
vid_to_region: FxHashMap<ty::RegionVid, ty::Region<'tcx>>,
434439
) -> Generics {
435-
debug!(
440+
tracing::debug!(
436441
"param_env_to_generics(item_def_id={:?}, param_env={:?}, \
437442
existing_predicates={:?})",
438-
item_def_id, param_env, existing_predicates
443+
item_def_id,
444+
param_env,
445+
existing_predicates
439446
);
440447

441448
let tcx = self.cx.tcx;
@@ -466,7 +473,11 @@ where
466473
);
467474
let mut generic_params = raw_generics.params;
468475

469-
debug!("param_env_to_generics({:?}): generic_params={:?}", item_def_id, generic_params);
476+
tracing::debug!(
477+
"param_env_to_generics({:?}): generic_params={:?}",
478+
item_def_id,
479+
generic_params
480+
);
470481

471482
let mut has_sized = FxHashSet::default();
472483
let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default();

src/librustdoc/clean/blanket_impl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
1717
let param_env = cx.tcx.param_env(item_def_id);
1818
let ty = cx.tcx.bound_type_of(item_def_id);
1919

20-
trace!("get_blanket_impls({:?})", ty);
20+
tracing::trace!("get_blanket_impls({:?})", ty);
2121
let mut impls = Vec::new();
2222
for trait_def_id in cx.tcx.all_traits() {
2323
if !cx.cache.access_levels.is_public(trait_def_id)
@@ -28,7 +28,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
2828
// NOTE: doesn't use `for_each_relevant_impl` to avoid looking at anything besides blanket impls
2929
let trait_impls = cx.tcx.trait_impls_of(trait_def_id);
3030
'blanket_impls: for &impl_def_id in trait_impls.blanket_impls() {
31-
trace!(
31+
tracing::trace!(
3232
"get_blanket_impls: Considering impl for trait '{:?}' {:?}",
3333
trait_def_id,
3434
impl_def_id
@@ -74,7 +74,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
7474
.to_predicate(infcx.tcx),
7575
));
7676
for predicate in predicates {
77-
debug!("testing predicate {:?}", predicate);
77+
tracing::debug!("testing predicate {:?}", predicate);
7878
let obligation = traits::Obligation::new(
7979
traits::ObligationCause::dummy(),
8080
param_env,

src/librustdoc/clean/inline.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn try_inline(
5454
}
5555
let mut ret = Vec::new();
5656

57-
debug!("attrs={:?}", attrs);
57+
tracing::debug!("attrs={:?}", attrs);
5858
let attrs_clone = attrs;
5959

6060
let kind = match res {
@@ -493,9 +493,9 @@ pub(crate) fn build_impl(
493493
}
494494

495495
let (merged_attrs, cfg) = merge_attrs(cx, parent_module, load_attrs(cx, did), attrs);
496-
trace!("merged_attrs={:?}", merged_attrs);
496+
tracing::trace!("merged_attrs={:?}", merged_attrs);
497497

498-
trace!(
498+
tracing::trace!(
499499
"build_impl: impl {:?} for {:?}",
500500
trait_.as_ref().map(|t| t.def_id()),
501501
for_.def_id(&cx.cache)
@@ -715,7 +715,7 @@ pub(crate) fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
715715
cx.active_extern_traits.insert(did);
716716
}
717717

718-
debug!("record_extern_trait: {:?}", did);
718+
tracing::debug!("record_extern_trait: {:?}", did);
719719
let trait_ = build_external_trait(cx, did);
720720

721721
cx.external_traits.borrow_mut().insert(did, trait_);

src/librustdoc/clean/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub(crate) fn clean_trait_ref_with_bindings<'tcx>(
166166
inline::record_extern_fqn(cx, trait_ref.def_id, kind);
167167
let path = external_path(cx, trait_ref.def_id, true, bindings, trait_ref.substs);
168168

169-
debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs);
169+
tracing::debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs);
170170

171171
path
172172
}
@@ -249,7 +249,7 @@ pub(crate) fn clean_middle_region<'tcx>(region: ty::Region<'tcx>) -> Option<Life
249249
| ty::ReVar(..)
250250
| ty::RePlaceholder(..)
251251
| ty::ReErased => {
252-
debug!("cannot clean region {:?}", region);
252+
tracing::debug!("cannot clean region {:?}", region);
253253
None
254254
}
255255
}
@@ -1587,11 +1587,11 @@ fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>>
15871587
.map(|resolved| infcx.resolve_vars_if_possible(resolved.value));
15881588
match normalized {
15891589
Ok(normalized_value) => {
1590-
debug!("normalized {:?} to {:?}", ty, normalized_value);
1590+
tracing::debug!("normalized {:?} to {:?}", ty, normalized_value);
15911591
Some(normalized_value)
15921592
}
15931593
Err(err) => {
1594-
debug!("failed to normalize {:?}: {:?}", ty, err);
1594+
tracing::debug!("failed to normalize {:?}: {:?}", ty, err);
15951595
None
15961596
}
15971597
}
@@ -1602,7 +1602,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
16021602
cx: &mut DocContext<'tcx>,
16031603
def_id: Option<DefId>,
16041604
) -> Type {
1605-
trace!("cleaning type: {:?}", ty);
1605+
tracing::trace!("cleaning type: {:?}", ty);
16061606
let ty = normalize(cx, ty).unwrap_or(ty);
16071607
match *ty.kind() {
16081608
ty::Never => Primitive(PrimitiveType::Never),

src/librustdoc/clean/types.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl Item {
475475
cx: &mut DocContext<'_>,
476476
cfg: Option<Arc<Cfg>>,
477477
) -> Item {
478-
trace!("name={:?}, def_id={:?} cfg={:?}", name, def_id, cfg);
478+
tracing::trace!("name={:?}, def_id={:?} cfg={:?}", name, def_id, cfg);
479479

480480
// Primitives and Keywords are written in the source code as private modules.
481481
// The modules need to be private so that nobody actually uses them, but the
@@ -504,9 +504,9 @@ impl Item {
504504
.map_or(&[][..], |v| v.as_slice())
505505
.iter()
506506
.filter_map(|ItemLink { link: s, link_text, page_id: did, ref fragment }| {
507-
debug!(?did);
507+
tracing::debug!(?did);
508508
if let Ok((mut href, ..)) = href(*did, cx) {
509-
debug!(?href);
509+
tracing::debug!(?href);
510510
if let Some(ref fragment) = *fragment {
511511
fragment.render(&mut href, cx.tcx())
512512
}
@@ -1197,7 +1197,7 @@ impl Attributes {
11971197
let mut other_attrs = ast::AttrVec::new();
11981198
for (attr, parent_module) in attrs {
11991199
if let Some((doc_str, comment_kind)) = attr.doc_str_and_comment_kind() {
1200-
trace!("got doc_str={doc_str:?}");
1200+
tracing::trace!("got doc_str={doc_str:?}");
12011201
let doc = beautify_doc_string(doc_str, comment_kind);
12021202
let kind = if attr.is_doc_comment() {
12031203
DocFragmentKind::SugaredDoc
@@ -1929,7 +1929,7 @@ impl PrimitiveType {
19291929
for &crate_num in tcx.crates(()) {
19301930
let e = ExternalCrate { crate_num };
19311931
let crate_name = e.name(tcx);
1932-
debug!(?crate_num, ?crate_name);
1932+
tracing::debug!(?crate_num, ?crate_name);
19331933
for &(def_id, prim) in &e.primitives(tcx) {
19341934
// HACK: try to link to std instead where possible
19351935
if crate_name == sym::core && primitive_locations.contains_key(&prim) {

src/librustdoc/clean/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub(crate) fn build_deref_target_impls(
201201

202202
pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
203203
use rustc_hir::*;
204-
debug!("trying to get a name from pattern: {:?}", p);
204+
tracing::debug!("trying to get a name from pattern: {:?}", p);
205205

206206
Symbol::intern(&match p.kind {
207207
PatKind::Wild | PatKind::Struct(..) => return kw::Underscore,
@@ -217,7 +217,7 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
217217
PatKind::Box(p) => return name_from_pat(&*p),
218218
PatKind::Ref(p, _) => return name_from_pat(&*p),
219219
PatKind::Lit(..) => {
220-
warn!(
220+
tracing::warn!(
221221
"tried to get argument name from PatKind::Lit, which is silly in function arguments"
222222
);
223223
return Symbol::intern("()");
@@ -450,7 +450,7 @@ pub(crate) fn print_const_expr(tcx: TyCtxt<'_>, body: hir::BodyId) -> String {
450450

451451
/// Given a type Path, resolve it to a Type using the TyCtxt
452452
pub(crate) fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
453-
debug!("resolve_type({:?})", path);
453+
tracing::debug!("resolve_type({:?})", path);
454454

455455
match path.res {
456456
Res::PrimTy(p) => Primitive(PrimitiveType::from(p)),
@@ -489,7 +489,7 @@ pub(crate) fn get_auto_trait_and_blanket_impls(
489489
/// [`href()`]: crate::html::format::href
490490
pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
491491
use DefKind::*;
492-
debug!("register_res({:?})", res);
492+
tracing::debug!("register_res({:?})", res);
493493

494494
let (kind, did) = match res {
495495
Res::Def(

src/librustdoc/core.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub(crate) fn create_config(
304304

305305
let hir = tcx.hir();
306306
let body = hir.body(hir.body_owned_by(def_id));
307-
debug!("visiting body for {:?}", def_id);
307+
tracing::debug!("visiting body for {:?}", def_id);
308308
EmitIgnoredResolutionErrors::new(tcx).visit_body(body);
309309
(rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck)(tcx, def_id)
310310
};
@@ -376,7 +376,7 @@ pub(crate) fn run_global_ctxt(
376376
ctxt.external_traits.borrow_mut().insert(sized_trait_did, sized_trait);
377377
}
378378

379-
debug!("crate: {:?}", tcx.hir().krate());
379+
tracing::debug!("crate: {:?}", tcx.hir().krate());
380380

381381
let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt));
382382

@@ -439,7 +439,7 @@ pub(crate) fn run_global_ctxt(
439439
}
440440
}
441441

442-
info!("Executing passes");
442+
tracing::info!("Executing passes");
443443

444444
for p in passes::defaults(show_coverage) {
445445
let run = match p.condition {
@@ -449,7 +449,7 @@ pub(crate) fn run_global_ctxt(
449449
WhenNotDocumentHidden => !ctxt.render_options.document_hidden,
450450
};
451451
if run {
452-
debug!("running pass {}", p.pass.name);
452+
tracing::debug!("running pass {}", p.pass.name);
453453
krate = tcx.sess.time(p.pass.name, || (p.pass.run)(krate, &mut ctxt));
454454
}
455455
}
@@ -489,7 +489,7 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> {
489489
}
490490

491491
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
492-
debug!("visiting path {:?}", path);
492+
tracing::debug!("visiting path {:?}", path);
493493
if path.res == Res::Err {
494494
// We have less context here than in rustc_resolve,
495495
// so we can only emit the name and span.

src/librustdoc/doctest.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub(crate) fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
6666
}
6767
});
6868

69-
debug!(?lint_opts);
69+
tracing::debug!(?lint_opts);
7070

7171
let crate_types =
7272
if options.proc_macro_crate { vec![CrateType::ProcMacro] } else { vec![CrateType::Rlib] };
@@ -715,7 +715,7 @@ pub(crate) fn make_test(
715715
prog.extend([&main_pre, everything_else, &main_post].iter().cloned());
716716
}
717717

718-
debug!("final doctest:\n{prog}");
718+
tracing::debug!("final doctest:\n{prog}");
719719

720720
(prog, line_offset, supports_color)
721721
}
@@ -756,7 +756,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
756756
match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {
757757
Ok(p) => p,
758758
Err(_) => {
759-
debug!("Cannot build a parser to check mod attr so skipping...");
759+
tracing::debug!("Cannot build a parser to check mod attr so skipping...");
760760
return true;
761761
}
762762
};
@@ -865,9 +865,9 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
865865
}
866866
}
867867

868-
debug!("before:\n{before}");
869-
debug!("crates:\n{crates}");
870-
debug!("after:\n{after}");
868+
tracing::debug!("before:\n{before}");
869+
tracing::debug!("crates:\n{crates}");
870+
tracing::debug!("after:\n{after}");
871871

872872
(before, after, crates)
873873
}
@@ -1044,7 +1044,7 @@ impl Tester for Collector {
10441044
)
10451045
};
10461046

1047-
debug!("creating test {name}: {test}");
1047+
tracing::debug!("creating test {name}: {test}");
10481048
self.tests.push(test::TestDescAndFn {
10491049
desc: test::TestDesc {
10501050
name: test::DynTestName(name),

src/librustdoc/formats/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Cache {
142142
let tcx = cx.tcx;
143143

144144
// Crawl the crate to build various caches used for the output
145-
debug!(?cx.cache.crate_version);
145+
tracing::debug!(?cx.cache.crate_version);
146146
cx.cache.traits = krate.external_traits.take();
147147

148148
// Cache where all our extern crates are located
@@ -195,7 +195,7 @@ impl Cache {
195195
impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
196196
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
197197
if item.item_id.is_local() {
198-
debug!("folding {} \"{:?}\", id {:?}", item.type_(), item.name, item.item_id);
198+
tracing::debug!("folding {} \"{:?}\", id {:?}", item.type_(), item.name, item.item_id);
199199
}
200200

201201
// If this is a stripped module,

src/librustdoc/formats/renderer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
8080
let (clean::StrippedItem(box clean::ModuleItem(module)) | clean::ModuleItem(module)) = *item.kind
8181
else { unreachable!() };
8282
for it in module.items {
83-
debug!("Adding {:?} to worklist", it.name);
83+
tracing::debug!("Adding {:?} to worklist", it.name);
8484
work.push((cx.make_child_renderer(), it));
8585
}
8686

0 commit comments

Comments
 (0)