Skip to content

Conversation

@radix
Copy link

@radix radix commented Mar 13, 2025

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.

@radix radix requested review from a team, davidbarsky and hawkw as code owners March 13, 2025 20:36
@radix radix requested review from carllerche and yaahc as code owners March 18, 2025 16:07
@radix radix changed the base branch from master to v0.1.x March 18, 2025 16:07
@radix
Copy link
Author

radix commented Mar 18, 2025

I've updated this PR to target 0.1.x, since that's the version we're on.

I'm not sure what the CI failures are about - they don't seem relevant to my change but maybe I'm missing a subtle implication of my change.

@jplatte
Copy link
Member

jplatte commented May 27, 2025

I've updated this PR to target 0.1.x

Please undo that, as the maintainers have stated in multiple other PRs that they prefer to take care of backporting themselves.

I'm not sure what the CI failures are about

Should be gone after rebasing.

Copy link
Contributor

@hds hds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're still interested in submitting this PR, please rebase onto the main branch (which is equivalent to the email oldv0.1.x branch).

This process has changed recently, so sorry for the conflicting messages.

@hds hds changed the base branch from v0.1.x to main November 23, 2025 18:23
@hds hds added kind/feature New feature or request crate/core Related to the `tracing-core` crate meta/breaking This is a breaking change, and should wait until the next breaking release. labels Nov 23, 2025
@hds
Copy link
Contributor

hds commented Nov 23, 2025

If you're still interested in submitting this PR, please rebase onto the main branch (which is equivalent to the email oldv0.1.x branch).

This process has changed recently, so sorry for the conflicting messages.

Okay. Thinking about this. I'm not sure if it's not a breaking change.

Let me dwell on it a little and ask some experts.

@mladedav
Copy link
Contributor

Not an expert, but for what it's worth, I don't think adding must_use qualifies as a breaking change. At worst, people get new warnings (which they of course can treat as errors) which I don't think is considered as breaking.

@mladedav
Copy link
Contributor

On the other hand, at least this RFC considers that potentially breaking:

Marking functions #[must_use] is a breaking change in certain cases, e.g. if someone is ignoring their result and has the relevant lint (or warnings in general) set to be an error. This is a general problem of improving/expanding lints.

@jplatte
Copy link
Member

jplatte commented Nov 25, 2025

Yeah, #[deny()] / #[forbid()] is opting out of usual semver guarantees. std adds new warnings (which affects (#[deny(warnings)]) or improves existing ones all the time.

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

Labels

crate/core Related to the `tracing-core` crate kind/feature New feature or request meta/breaking This is a breaking change, and should wait until the next breaking release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants