Skip to content

ref: narrow unused lint expectations in sentry-core hub#1079

Open
szokeasaurusrex wants to merge 4 commits intomasterfrom
cursor/hub-unused-expects-41e4
Open

ref: narrow unused lint expectations in sentry-core hub#1079
szokeasaurusrex wants to merge 4 commits intomasterfrom
cursor/hub-unused-expects-41e4

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex commented Apr 23, 2026

Remove the blanket #![allow(unused)] in sentry-core/src/hub.rs. This will allow the linter to find problems like the following (from #1073) and many more, rather than needing to rely on the clanker for such things.

image

Instead, we now have a macro that adds a let _ = ...arguments... when the client feature is enabled. This solves the stated purpose of having the allow(unused) in the first place, but where more narrowly.

The clanker also cleaned up some truly unused things that were suppressed before.

🤖What the clanker wrote

Description

Removes the blanket #![allow(unused)] from sentry-core/src/hub.rs.

Instead of repeating a long #[cfg_attr(not(feature = "client"), expect(unused, ...))] annotation across many parameters, this change uses a small documented local use_without_client! helper macro that only touches those values in not(feature = "client") builds. That keeps the handling narrow to the specific methods and arguments that need it, while avoiding duplicated attributes in the signatures.

Also cleans up truly unused imports, removes an unnecessary mut in the release-health session setup path, and keeps the file rustfmt-clean for CI.

Validated with:

  • cargo +1.88.0 fmt --all --check
  • cargo +1.88.0 clippy -p sentry-core --no-default-features -- -D warnings
  • cargo +1.88.0 clippy -p sentry-core --no-default-features --features client -- -D warnings
  • cargo +1.88.0 clippy -p sentry-core --all-features -- -D warnings
  • cargo +1.88.0 clippy -p sentry-core --no-default-features --features release-health -- -D warnings
  • cargo +1.88.0 clippy -p sentry-core --no-default-features --features logs -- -D warnings

Note: a full local workspace cargo clippy --all-features --workspace --tests --examples --locked is blocked in this environment by missing system OpenSSL development libraries, which is unrelated to this hub.rs change.

Issues

  • N/A

Reminders

Open in Web Open in Cursor 

cursoragent and others added 4 commits April 23, 2026 20:05
Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
Co-authored-by: Daniel Szoke <szokeasaurusrex@users.noreply.github.com>
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review April 23, 2026 20:20
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner April 23, 2026 20:20
@szokeasaurusrex szokeasaurusrex enabled auto-merge (squash) April 23, 2026 20:20
Comment thread sentry-core/src/hub.rs
Comment on lines +11 to +18
/// Marks values as used in minimal builds where `with_client_impl!` turns many
/// method bodies into no-ops and would otherwise leave their parameters unused.
macro_rules! use_without_client {
($($value:expr),+ $(,)?) => {
#[cfg(not(feature = "client"))]
let _ = ($( &$value ),+,);
};
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

clanker came up with this idea, pretty nice. thanks GPT-5.4

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.

2 participants