rust-lang / rust-lang/rust-clippy

tracing

Open
#10,062 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

Detects and fixes overly complex statements for tracing lib

Specifically for recording fields

Lint Name

simplify_tracing_field_record

Category

complexity

Advantage
  • Removes unnecessary complexity
Drawbacks
  • possibly tough to detect? maybe?
  • possibly increases complexity for expressions like info_span!("foo", a = format!("{:?}", bar.baz.quux()))
Example
// both ...
info_span!("foo", a = format!("{:?}", bar))
// and
info_span!("foo", a = format!("{bar:?}"))

Could be written as:

info_span!("foo", a = ?bar)

and

info_span!("foo", a = format!("{}", bar))
// or 
info_span!("foo", a = format!("{bar}"))

Could be written as:

info_span!("foo", a = %bar)

(same for debug_span!, warn_span!, error_span, ...)

  1. See macros: https://docs.rs/tracing/latest/tracing/index.html#macros
  2. See ? and % described https://docs.rs/tracing/latest/tracing/index.html#recording-fields

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the tracing macro and recording-fields documentation linked in the issue, then review the examples for ? and % field recording. Done means the simplify_tracing_field_record lint handles the shown info_span! forms and corresponding span macros while considering the stated concern about complex expressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.