Skip to content

Add #[must_use] to Span.#3477

Open
raldone01 wants to merge 2 commits intotokio-rs:v0.2.xfrom
raldone01:add-must-use-to-span
Open

Add #[must_use] to Span.#3477
raldone01 wants to merge 2 commits intotokio-rs:v0.2.xfrom
raldone01:add-must-use-to-span

Conversation

@raldone01
Copy link

Motivation

I noticed we had some code at work that was creating spans with e.g. info_span!() and not doing anything with the spans. This seems like it should be prevented.

Please let me know if I'm wrong about this and there are useful use-cases for creating and not using Spans and I'll close this PR.

Solution

Add a #[must_use] to tracing::Span.

Adding must_use to Span is a little bit of a pain in the test suite but I think it would be good for the end user since spans are meant to be entered.

Same as #3234 but targeting v0.2.x instead of main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant