Skip to content

Commit d70c876

Browse files
committed
Auto merge of #17148 - Wilfred:span_names, r=Veykril
fix: Tracing span names should match function names When viewing traces, it's slightly confusing when the span name doesn't match the function name. Ensure the names are consistent. (It might be worth moving most of these to use `#[tracing::instrument]` so the name can never go stale. `@davidbarsky` suggested that is marginally slower, so I've just done the simple change here.)
2 parents 9a498e0 + 65b201a commit d70c876

File tree

20 files changed

+31
-31
lines changed

20 files changed

+31
-31
lines changed

src/tools/rust-analyzer/crates/base-db/src/change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl FileChange {
5151
}
5252

5353
pub fn apply(self, db: &mut dyn SourceDatabaseExt) {
54-
let _p = tracing::span!(tracing::Level::INFO, "RootDatabase::apply_change").entered();
54+
let _p = tracing::span!(tracing::Level::INFO, "FileChange::apply").entered();
5555
if let Some(roots) = self.roots {
5656
for (idx, root) in roots.into_iter().enumerate() {
5757
let root_id = SourceRootId(idx as u32);

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn toolchain_channel(db: &dyn SourceDatabase, krate: CrateId) -> Option<ReleaseC
8282
}
8383

8484
fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
85-
let _p = tracing::span!(tracing::Level::INFO, "parse_query", ?file_id).entered();
85+
let _p = tracing::span!(tracing::Level::INFO, "parse", ?file_id).entered();
8686
let text = db.file_text(file_id);
8787
// FIXME: Edition based parsing
8888
SourceFile::parse(&text, span::Edition::CURRENT)

src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ pub(crate) fn impl_datum_query(
806806
krate: CrateId,
807807
impl_id: ImplId,
808808
) -> Arc<ImplDatum> {
809-
let _p = tracing::span!(tracing::Level::INFO, "impl_datum").entered();
809+
let _p = tracing::span!(tracing::Level::INFO, "impl_datum_query").entered();
810810
debug!("impl_datum {:?}", impl_id);
811811
let impl_: hir_def::ImplId = from_chalk(db, impl_id);
812812
impl_def_datum(db, krate, impl_id, impl_)

src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ pub(crate) fn incoherent_inherent_impl_crates(
368368
krate: CrateId,
369369
fp: TyFingerprint,
370370
) -> SmallVec<[CrateId; 2]> {
371-
let _p = tracing::span!(tracing::Level::INFO, "inherent_impl_crates_query").entered();
371+
let _p = tracing::span!(tracing::Level::INFO, "incoherent_inherent_impl_crates").entered();
372372
let mut res = SmallVec::new();
373373
let crate_graph = db.crate_graph();
374374

src/tools/rust-analyzer/crates/hir/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4503,7 +4503,8 @@ impl Type {
45034503
name: Option<&Name>,
45044504
mut callback: impl FnMut(Function) -> Option<T>,
45054505
) -> Option<T> {
4506-
let _p = tracing::span!(tracing::Level::INFO, "iterate_method_candidates").entered();
4506+
let _p =
4507+
tracing::span!(tracing::Level::INFO, "iterate_method_candidates_with_traits").entered();
45074508
let mut slot = None;
45084509

45094510
self.iterate_method_candidates_dyn(

src/tools/rust-analyzer/crates/hir/src/semantics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ impl<'db> SemanticsImpl<'db> {
723723
mut token: SyntaxToken,
724724
f: &mut dyn FnMut(InFile<SyntaxToken>) -> ControlFlow<()>,
725725
) {
726-
let _p = tracing::span!(tracing::Level::INFO, "descend_into_macros").entered();
726+
let _p = tracing::span!(tracing::Level::INFO, "descend_into_macros_impl").entered();
727727
let (sa, span, file_id) =
728728
match token.parent().and_then(|parent| self.analyze_no_infer(&parent)) {
729729
Some(sa) => match sa.file_id.file_id() {
@@ -1372,7 +1372,7 @@ impl<'db> SemanticsImpl<'db> {
13721372
offset: Option<TextSize>,
13731373
infer_body: bool,
13741374
) -> Option<SourceAnalyzer> {
1375-
let _p = tracing::span!(tracing::Level::INFO, "Semantics::analyze_impl").entered();
1375+
let _p = tracing::span!(tracing::Level::INFO, "SemanticsImpl::analyze_impl").entered();
13761376
let node = self.find_file(node);
13771377

13781378
let container = self.with_ctx(|ctx| ctx.find_container(node))?;

src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub(super) struct SourceToDefCtx<'a, 'b> {
118118

119119
impl SourceToDefCtx<'_, '_> {
120120
pub(super) fn file_to_def(&self, file: FileId) -> SmallVec<[ModuleId; 1]> {
121-
let _p = tracing::span!(tracing::Level::INFO, "SourceBinder::file_to_module_def").entered();
121+
let _p = tracing::span!(tracing::Level::INFO, "SourceToDefCtx::file_to_def").entered();
122122
let mut mods = SmallVec::new();
123123
for &crate_id in self.db.relevant_crates(file).iter() {
124124
// Note: `mod` declarations in block modules cannot be supported here

src/tools/rust-analyzer/crates/ide-completion/src/completions/flyimport.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ fn import_on_the_fly_pat_(
296296
position: SyntaxNode,
297297
potential_import_name: String,
298298
) -> Option<()> {
299-
let _p = tracing::span!(tracing::Level::INFO, "import_on_the_fly_pat", ?potential_import_name)
299+
let _p = tracing::span!(tracing::Level::INFO, "import_on_the_fly_pat_", ?potential_import_name)
300300
.entered();
301301

302302
ImportScope::find_insert_use_container(&position, &ctx.sema)?;

src/tools/rust-analyzer/crates/ide-completion/src/render.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn render_resolution_pat(
368368
import_to_add: Option<LocatedImport>,
369369
resolution: ScopeDef,
370370
) -> Builder {
371-
let _p = tracing::span!(tracing::Level::INFO, "render_resolution").entered();
371+
let _p = tracing::span!(tracing::Level::INFO, "render_resolution_pat").entered();
372372
use hir::ModuleDef::*;
373373

374374
if let ScopeDef::ModuleDef(Macro(mac)) = resolution {
@@ -386,7 +386,7 @@ fn render_resolution_path(
386386
import_to_add: Option<LocatedImport>,
387387
resolution: ScopeDef,
388388
) -> Builder {
389-
let _p = tracing::span!(tracing::Level::INFO, "render_resolution").entered();
389+
let _p = tracing::span!(tracing::Level::INFO, "render_resolution_path").entered();
390390
use hir::ModuleDef::*;
391391

392392
match resolution {
@@ -494,7 +494,7 @@ fn render_resolution_simple_(
494494
import_to_add: Option<LocatedImport>,
495495
resolution: ScopeDef,
496496
) -> Builder {
497-
let _p = tracing::span!(tracing::Level::INFO, "render_resolution").entered();
497+
let _p = tracing::span!(tracing::Level::INFO, "render_resolution_simple_").entered();
498498

499499
let db = ctx.db();
500500
let ctx = ctx.import_to_add(import_to_add);

src/tools/rust-analyzer/crates/ide-completion/src/render/literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn render_variant_lit(
2727
variant: hir::Variant,
2828
path: Option<hir::ModPath>,
2929
) -> Option<Builder> {
30-
let _p = tracing::span!(tracing::Level::INFO, "render_enum_variant").entered();
30+
let _p = tracing::span!(tracing::Level::INFO, "render_variant_lit").entered();
3131
let db = ctx.db();
3232

3333
let name = local_name.unwrap_or_else(|| variant.name(db));

0 commit comments

Comments
 (0)