-
Notifications
You must be signed in to change notification settings - Fork 2
update dependency and fix warning #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates dependencies and improves conditional compilation of debug logging code in the VNC client implementation. The changes aim to reduce code size and eliminate unused variable warnings when the debug-logging feature is disabled.
Changes:
- Updated
thiserrorfrom 1.0 to 2.0 andrandfrom 0.8 to 0.9 in dependencies - Migrated from
rand::thread_rng()torand::rng()for compatibility with rand 0.9 - Moved debug logging variable declarations and accumulation code inside
#[cfg(feature = "debug-logging")]guards
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Cargo.toml | Updates dependency versions for thiserror and rand crates |
| src/auth.rs | Changes random number generator initialization to use rand 0.9 API |
| src/client.rs | Scopes debug logging variables to only compile when debug-logging feature is enabled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| let mut total_pixels = 0u64; | ||
| let mut copy_rect_count = 0; | ||
| } | ||
| #[cfg_attr( | ||
| not(feature = "debug-logging"), | ||
| allow(unused_variables, unused_assignments) | ||
| )] |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables total_pixels and copy_rect_count are declared inside a block that only exists when the debug-logging feature is enabled, but they are used outside this block (at lines 1162-1163, 1232, 1331, 1715, 1722-1723, and 1749). This will cause a compilation error when the feature is enabled because the variables will go out of scope at line 1125.
The variables should be declared at function scope with the #[cfg(feature = "debug-logging")] attribute applied to each variable declaration, not inside a separate block. Remove the braces and apply the attribute to each let statement individually.
| { | |
| let mut total_pixels = 0u64; | |
| let mut copy_rect_count = 0; | |
| } | |
| #[cfg_attr( | |
| not(feature = "debug-logging"), | |
| allow(unused_variables, unused_assignments) | |
| )] | |
| let mut total_pixels = 0u64; | |
| #[cfg_attr( | |
| not(feature = "debug-logging"), | |
| allow(unused_variables, unused_assignments) | |
| )] | |
| #[cfg(feature = "debug-logging")] | |
| let mut copy_rect_count = 0; | |
| #[cfg_attr( | |
| not(feature = "debug-logging"), | |
| allow(unused_variables, unused_assignments) | |
| )] |
| #[cfg_attr( | ||
| not(feature = "debug-logging"), | ||
| allow(unused_variables, unused_assignments) | ||
| )] |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This #[cfg_attr] attribute is orphaned and not attached to any code statement. It should be removed since the variables it was intended to suppress warnings for (total_pixels and copy_rect_count) are now conditionally compiled with #[cfg(feature = "debug-logging")].
This pull request updates dependencies and makes several improvements to conditional debug logging in the VNC client implementation. The most significant changes are the upgrade of the
thiserrorandrandcrates, a fix to how random numbers are generated for authentication, and the scoping of debug logging variables and code to only compile when thedebug-loggingfeature is enabled.Dependency upgrades:
thiserrorfrom version 1.0 to 2.0 inCargo.tomlfor improved error handling support.randfrom version 0.8 to 0.9 inCargo.tomlto keep up with the latest random number generation APIs.Authentication improvements:
VncAuth::generate_challengeto userand::rng()instead ofrand::thread_rng()for compatibility withrand0.9.Debug logging improvements in
VncClient:total_pixelsandcopy_rect_countto only be compiled when thedebug-loggingfeature is enabled, reducing unnecessary variable usage in release builds. [1] [2]total_pixelsandrect_count) into#[cfg(feature = "debug-logging")]blocks to avoid affecting performance or logic when debug logging is disabled. [1] [2] [3]