Skip to content

Commit 9af618b

Browse files
committed
Auto merge of #101239 - oli-obk:tracing_cleanup, r=estebank
Tracing cleanup r? `@ghost`
2 parents fb88811 + 3f1f694 commit 9af618b

File tree

146 files changed

+276
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+276
-452
lines changed

compiler/rustc_ast/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#[macro_use]
2727
extern crate rustc_macros;
2828

29+
#[macro_use]
30+
extern crate tracing;
31+
2932
pub mod util {
3033
pub mod classify;
3134
pub mod comments;

compiler/rustc_ast/src/util/literal.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_span::symbol::{kw, sym, Symbol};
99
use rustc_span::Span;
1010

1111
use std::ascii;
12-
use tracing::debug;
1312

1413
pub enum LitError {
1514
NotLiteral,

compiler/rustc_ast_lowering/src/index.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use rustc_session::Session;
1111
use rustc_span::source_map::SourceMap;
1212
use rustc_span::{Span, DUMMY_SP};
1313

14-
use tracing::debug;
15-
1614
/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
1715
pub(super) struct NodeCollector<'a, 'hir> {
1816
/// Source map
@@ -31,7 +29,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
3129
definitions: &'a definitions::Definitions,
3230
}
3331

34-
#[tracing::instrument(level = "debug", skip(sess, definitions, bodies))]
32+
#[instrument(level = "debug", skip(sess, definitions, bodies))]
3533
pub(super) fn index_hir<'hir>(
3634
sess: &Session,
3735
definitions: &definitions::Definitions,
@@ -67,7 +65,7 @@ pub(super) fn index_hir<'hir>(
6765
}
6866

6967
impl<'a, 'hir> NodeCollector<'a, 'hir> {
70-
#[tracing::instrument(level = "debug", skip(self))]
68+
#[instrument(level = "debug", skip(self))]
7169
fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
7270
debug_assert_eq!(self.owner, hir_id.owner);
7371
debug_assert_ne!(hir_id.local_id.as_u32(), 0);
@@ -142,7 +140,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
142140
});
143141
}
144142

145-
#[tracing::instrument(level = "debug", skip(self))]
143+
#[instrument(level = "debug", skip(self))]
146144
fn visit_item(&mut self, i: &'hir Item<'hir>) {
147145
debug_assert_eq!(i.def_id, self.owner);
148146
self.with_parent(i.hir_id(), |this| {
@@ -156,7 +154,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
156154
});
157155
}
158156

159-
#[tracing::instrument(level = "debug", skip(self))]
157+
#[instrument(level = "debug", skip(self))]
160158
fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) {
161159
debug_assert_eq!(fi.def_id, self.owner);
162160
self.with_parent(fi.hir_id(), |this| {
@@ -175,15 +173,15 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
175173
})
176174
}
177175

178-
#[tracing::instrument(level = "debug", skip(self))]
176+
#[instrument(level = "debug", skip(self))]
179177
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
180178
debug_assert_eq!(ti.def_id, self.owner);
181179
self.with_parent(ti.hir_id(), |this| {
182180
intravisit::walk_trait_item(this, ti);
183181
});
184182
}
185183

186-
#[tracing::instrument(level = "debug", skip(self))]
184+
#[instrument(level = "debug", skip(self))]
187185
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
188186
debug_assert_eq!(ii.def_id, self.owner);
189187
self.with_parent(ii.hir_id(), |this| {

compiler/rustc_ast_lowering/src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
220220
/// Panics if no map has been pushed.
221221
/// Remapping is used when creating lowering `-> impl Trait` return
222222
/// types to create the resulting opaque type.
223-
#[tracing::instrument(level = "debug", skip(self))]
223+
#[instrument(level = "debug", skip(self))]
224224
fn record_def_id_remap(&mut self, from: LocalDefId, to: LocalDefId) {
225225
self.generics_def_id_map.last_mut().expect("no map pushed").insert(from, to);
226226
}
@@ -771,7 +771,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
771771
}
772772

773773
/// Converts a lifetime into a new generic parameter.
774-
#[tracing::instrument(level = "debug", skip(self))]
774+
#[instrument(level = "debug", skip(self))]
775775
fn lifetime_res_to_generic_param(
776776
&mut self,
777777
ident: Ident,
@@ -815,7 +815,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
815815
/// name resolver owing to lifetime elision; this also populates the resolver's node-id->def-id
816816
/// map, so that later calls to `opt_node_id_to_def_id` that refer to these extra lifetime
817817
/// parameters will be successful.
818-
#[tracing::instrument(level = "debug", skip(self))]
818+
#[instrument(level = "debug", skip(self))]
819819
#[inline]
820820
fn lower_lifetime_binder(
821821
&mut self,
@@ -1385,7 +1385,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13851385
/// added explicitly in the HIR). But this includes all the lifetimes, and we only want to
13861386
/// capture the lifetimes that are referenced in the bounds. Therefore, we add *extra* lifetime parameters
13871387
/// for the lifetimes that get captured (`'x`, in our example above) and reference those.
1388-
#[tracing::instrument(level = "debug", skip(self))]
1388+
#[instrument(level = "debug", skip(self))]
13891389
fn lower_opaque_impl_trait(
13901390
&mut self,
13911391
span: Span,
@@ -1621,7 +1621,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16211621
// `make_ret_async`: if `Some`, converts `-> T` into `-> impl Future<Output = T>` in the
16221622
// return type. This is used for `async fn` declarations. The `NodeId` is the ID of the
16231623
// return type `impl Trait` item.
1624-
#[tracing::instrument(level = "debug", skip(self))]
1624+
#[instrument(level = "debug", skip(self))]
16251625
fn lower_fn_decl(
16261626
&mut self,
16271627
decl: &FnDecl,
@@ -1730,7 +1730,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17301730
// `output`: unlowered output type (`T` in `-> T`)
17311731
// `fn_def_id`: `DefId` of the parent function (used to create child impl trait definition)
17321732
// `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
1733-
#[tracing::instrument(level = "debug", skip(self))]
1733+
#[instrument(level = "debug", skip(self))]
17341734
fn lower_async_fn_ret_ty(
17351735
&mut self,
17361736
output: &FnRetTy,
@@ -2013,7 +2013,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20132013
self.new_named_lifetime(l.id, l.id, span, ident)
20142014
}
20152015

2016-
#[tracing::instrument(level = "debug", skip(self))]
2016+
#[instrument(level = "debug", skip(self))]
20172017
fn new_named_lifetime_with_res(
20182018
&mut self,
20192019
id: NodeId,
@@ -2044,7 +2044,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20442044
hir::Lifetime { hir_id: self.lower_node_id(id), span: self.lower_span(span), name }
20452045
}
20462046

2047-
#[tracing::instrument(level = "debug", skip(self))]
2047+
#[instrument(level = "debug", skip(self))]
20482048
fn new_named_lifetime(
20492049
&mut self,
20502050
id: NodeId,
@@ -2132,7 +2132,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21322132
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
21332133
}
21342134

2135-
#[tracing::instrument(level = "debug", skip(self))]
2135+
#[instrument(level = "debug", skip(self))]
21362136
fn lower_poly_trait_ref(
21372137
&mut self,
21382138
p: &PolyTraitRef,

compiler/rustc_ast_lowering/src/path.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_span::symbol::{kw, Ident};
1313
use rustc_span::{BytePos, Span, DUMMY_SP};
1414

1515
use smallvec::smallvec;
16-
use tracing::debug;
1716

1817
impl<'a, 'hir> LoweringContext<'a, 'hir> {
1918
#[instrument(level = "trace", skip(self))]

compiler/rustc_ast_passes/src/feature_gate.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use rustc_span::source_map::Spanned;
1111
use rustc_span::symbol::sym;
1212
use rustc_span::Span;
1313

14-
use tracing::debug;
15-
1614
macro_rules! gate_feature_fn {
1715
($visitor: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr, $help: expr) => {{
1816
let (visitor, has_feature, span, name, explain, help) =

compiler/rustc_ast_passes/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#![feature(let_else)]
1313
#![recursion_limit = "256"]
1414

15+
#[macro_use]
16+
extern crate tracing;
17+
1518
pub mod ast_validation;
1619
mod errors;
1720
pub mod feature_gate;

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_errors::Diagnostic;
66
use rustc_middle::ty::RegionVid;
77
use smallvec::SmallVec;
88
use std::collections::BTreeMap;
9-
use tracing::debug;
109

1110
use crate::MirBorrowckCtxt;
1211

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
265265
/// *user* has a name for. In that case, we'll be able to map
266266
/// `fr` to a `Region<'tcx>`, and that region will be one of
267267
/// named variants.
268-
#[tracing::instrument(level = "trace", skip(self))]
268+
#[instrument(level = "trace", skip(self))]
269269
fn give_name_from_error_region(&self, fr: RegionVid) -> Option<RegionName> {
270270
let error_region = self.to_error_region(fr)?;
271271

@@ -373,7 +373,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
373373
/// | fn foo(x: &u32) { .. }
374374
/// ------- fully elaborated type of `x` is `&'1 u32`
375375
/// ```
376-
#[tracing::instrument(level = "trace", skip(self))]
376+
#[instrument(level = "trace", skip(self))]
377377
fn give_name_if_anonymous_region_appears_in_arguments(
378378
&self,
379379
fr: RegionVid,
@@ -662,7 +662,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
662662
/// | let x = Some(&22);
663663
/// - fully elaborated type of `x` is `Option<&'1 u32>`
664664
/// ```
665-
#[tracing::instrument(level = "trace", skip(self))]
665+
#[instrument(level = "trace", skip(self))]
666666
fn give_name_if_anonymous_region_appears_in_upvars(&self, fr: RegionVid) -> Option<RegionName> {
667667
let upvar_index = self.regioncx.get_upvar_index_for_region(self.infcx.tcx, fr)?;
668668
let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(
@@ -682,7 +682,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
682682
/// must be a closure since, in a free fn, such an argument would
683683
/// have to either also appear in an argument (if using elision)
684684
/// or be early bound (named, not in argument).
685-
#[tracing::instrument(level = "trace", skip(self))]
685+
#[instrument(level = "trace", skip(self))]
686686
fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Option<RegionName> {
687687
let tcx = self.infcx.tcx;
688688
let hir = tcx.hir();
@@ -814,7 +814,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
814814
}
815815
}
816816

817-
#[tracing::instrument(level = "trace", skip(self))]
817+
#[instrument(level = "trace", skip(self))]
818818
fn give_name_if_anonymous_region_appears_in_yield_ty(
819819
&self,
820820
fr: RegionVid,

compiler/rustc_borrowck/src/region_infer/mod.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11391139
/// include the CFG anyhow.
11401140
/// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding
11411141
/// a result `'y`.
1142-
#[instrument(skip(self), level = "debug")]
1142+
#[instrument(skip(self), level = "debug", ret)]
11431143
pub(crate) fn universal_upper_bound(&self, r: RegionVid) -> RegionVid {
11441144
debug!(r = %self.region_value_str(r));
11451145

@@ -1151,8 +1151,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11511151
lub = self.universal_region_relations.postdom_upper_bound(lub, ur);
11521152
}
11531153

1154-
debug!(?lub);
1155-
11561154
lub
11571155
}
11581156

@@ -1333,15 +1331,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13331331
}
13341332

13351333
// Evaluate whether `sup_region: sub_region`.
1336-
#[instrument(skip(self), level = "debug")]
1334+
#[instrument(skip(self), level = "debug", ret)]
13371335
fn eval_outlives(&self, sup_region: RegionVid, sub_region: RegionVid) -> bool {
13381336
debug!(
1339-
"eval_outlives: sup_region's value = {:?} universal={:?}",
1337+
"sup_region's value = {:?} universal={:?}",
13401338
self.region_value_str(sup_region),
13411339
self.universal_regions.is_universal_region(sup_region),
13421340
);
13431341
debug!(
1344-
"eval_outlives: sub_region's value = {:?} universal={:?}",
1342+
"sub_region's value = {:?} universal={:?}",
13451343
self.region_value_str(sub_region),
13461344
self.universal_regions.is_universal_region(sub_region),
13471345
);
@@ -1354,7 +1352,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13541352
// true if `'sup` outlives static.
13551353
if !self.universe_compatible(sub_region_scc, sup_region_scc) {
13561354
debug!(
1357-
"eval_outlives: sub universe `{sub_region_scc:?}` is not nameable \
1355+
"sub universe `{sub_region_scc:?}` is not nameable \
13581356
by super `{sup_region_scc:?}`, promoting to static",
13591357
);
13601358

@@ -1375,9 +1373,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13751373
});
13761374

13771375
if !universal_outlives {
1378-
debug!(
1379-
"eval_outlives: returning false because sub region contains a universal region not present in super"
1380-
);
1376+
debug!("sub region contains a universal region not present in super");
13811377
return false;
13821378
}
13831379

@@ -1386,15 +1382,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
13861382

13871383
if self.universal_regions.is_universal_region(sup_region) {
13881384
// Micro-opt: universal regions contain all points.
1389-
debug!(
1390-
"eval_outlives: returning true because super is universal and hence contains all points"
1391-
);
1385+
debug!("super is universal and hence contains all points");
13921386
return true;
13931387
}
13941388

1395-
let result = self.scc_values.contains_points(sup_region_scc, sub_region_scc);
1396-
debug!("returning {} because of comparison between points in sup/sub", result);
1397-
result
1389+
debug!("comparison between points in sup/sub");
1390+
1391+
self.scc_values.contains_points(sup_region_scc, sub_region_scc)
13981392
}
13991393

14001394
/// Once regions have been propagated, this method is used to see
@@ -1971,7 +1965,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
19711965
}
19721966

19731967
/// Finds some region R such that `fr1: R` and `R` is live at `elem`.
1974-
#[instrument(skip(self), level = "trace")]
1968+
#[instrument(skip(self), level = "trace", ret)]
19751969
pub(crate) fn find_sub_region_live_at(&self, fr1: RegionVid, elem: Location) -> RegionVid {
19761970
trace!(scc = ?self.constraint_sccs.scc(fr1));
19771971
trace!(universe = ?self.scc_universes[self.constraint_sccs.scc(fr1)]);

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
6060
/// Calling `universal_upper_bound` for such a region gives `fr_fn_body`,
6161
/// which has no `external_name` in which case we use `'empty` as the
6262
/// region to pass to `infer_opaque_definition_from_instantiation`.
63-
#[instrument(level = "debug", skip(self, infcx))]
63+
#[instrument(level = "debug", skip(self, infcx), ret)]
6464
pub(crate) fn infer_opaque_types(
6565
&self,
6666
infcx: &InferCtxt<'_, 'tcx>,

compiler/rustc_borrowck/src/universal_regions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,9 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
768768
mir_def_id: LocalDefId,
769769
indices: &mut UniversalRegionIndices<'tcx>,
770770
) {
771-
debug!("replace_late_bound_regions_with_nll_infer_vars(mir_def_id={:?})", mir_def_id);
772771
let typeck_root_def_id = self.tcx.typeck_root_def_id(mir_def_id.to_def_id());
773772
for_each_late_bound_region_defined_on(self.tcx, typeck_root_def_id, |r| {
774-
debug!("replace_late_bound_regions_with_nll_infer_vars: r={:?}", r);
773+
debug!(?r);
775774
if !indices.indices.contains_key(&r) {
776775
let region_vid = self.next_nll_region_var(FR);
777776
debug!(?region_vid);

compiler/rustc_builtin_macros/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
extern crate proc_macro;
1818

19+
#[macro_use]
20+
extern crate tracing;
21+
1922
use crate::deriving::*;
2023

2124
use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtensionKind};

compiler/rustc_builtin_macros/src/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub fn expand_test_or_bench(
335335
// extern crate test
336336
let test_extern = cx.item(sp, test_id, ast::AttrVec::new(), ast::ItemKind::ExternCrate(None));
337337

338-
tracing::debug!("synthetic test item:\n{}\n", pprust::item_to_string(&test_const));
338+
debug!("synthetic test item:\n{}\n", pprust::item_to_string(&test_const));
339339

340340
if is_stmt {
341341
vec![

compiler/rustc_builtin_macros/src/test_harness.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_span::{Span, DUMMY_SP};
1515
use rustc_target::spec::PanicStrategy;
1616
use smallvec::{smallvec, SmallVec};
1717
use thin_vec::thin_vec;
18-
use tracing::debug;
1918

2019
use std::{iter, mem};
2120

compiler/rustc_codegen_llvm/src/asm.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_target::asm::*;
1919

2020
use libc::{c_char, c_uint};
2121
use smallvec::SmallVec;
22-
use tracing::debug;
2322

2423
impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
2524
fn codegen_inline_asm(

compiler/rustc_codegen_llvm/src/back/archive.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
190190

191191
let output_path_z = rustc_fs_util::path_to_c_string(&output_path);
192192

193-
tracing::trace!("invoking LLVMRustWriteImportLibrary");
194-
tracing::trace!(" dll_name {:#?}", dll_name_z);
195-
tracing::trace!(" output_path {}", output_path.display());
196-
tracing::trace!(
193+
trace!("invoking LLVMRustWriteImportLibrary");
194+
trace!(" dll_name {:#?}", dll_name_z);
195+
trace!(" output_path {}", output_path.display());
196+
trace!(
197197
" import names: {}",
198198
dll_imports
199199
.iter()

0 commit comments

Comments
 (0)