rust-lang / rust-lang/rust-clippy
tracing
Open
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, ...)
- See macros: https://docs.rs/tracing/latest/tracing/index.html#macros
- See
?and%described https://docs.rs/tracing/latest/tracing/index.html#recording-fields
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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