feat: Migrate to Rust 2024 edition with clippy improvements#180
Closed
inureyes wants to merge 2 commits into
Closed
feat: Migrate to Rust 2024 edition with clippy improvements#180inureyes wants to merge 2 commits into
inureyes wants to merge 2 commits into
Conversation
- Update edition from 2021 to 2024 in both Cargo.toml files - Cargo.toml (bssh main package) - crates/bssh-russh/Cargo.toml (SSH library fork) - Fix pattern matching for 2024 edition: - Remove explicit 'ref' and 'ref mut' bindings in if-let patterns - 2024 edition uses implicit borrowing in patterns - Updated session_info to mutable variable where needed - src/server/handler.rs (4 pattern changes) - src/server/shell.rs (1 pattern change) - Code changes summary: - 119 files reformatted by rustfmt - No breaking API changes - All unsafe code, macros, async/await remain compatible - All dependencies support 2024 edition - Compilation status: - cargo build --release: ✅ SUCCESS - All binaries (bssh, bssh-server, bssh-keygen) compile correctly 2024 edition improvements applied: - Implicit pattern borrowing eliminates need for 'ref'/'ref mut' - Support for guard clauses (if let X = Y && condition) - Better error messages and compile-time checks
- Collapse nested if-let statements using 2024 edition guard clause syntax
- Convert 38 instances from nested if-let to single if-let with && conditions
- Improves code readability and embraces 2024 edition improvements
Files modified:
- crates/bssh-russh/src/client/mod.rs (7 fixes)
- crates/bssh-russh/src/server/session.rs (12 fixes)
- crates/bssh-russh/src/client/session.rs (9 fixes)
- crates/bssh-russh/src/server/mod.rs (2 fixes)
- crates/bssh-russh/src/client/encrypted.rs (3 fixes)
- crates/bssh-russh/src/server/encrypted.rs (2 fixes)
- crates/bssh-russh/src/ssh_read.rs (1 fix)
- crates/bssh-russh/src/keys/known_hosts.rs (1 fix)
- crates/bssh-russh/src/kex/dh/mod.rs (1 fix)
Example transformation:
// Before
if let Some(x) = y {
if condition {
// ...
}
}
// After (2024 edition)
if let Some(x) = y && condition {
// ...
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrate bssh codebase to Rust 2024 edition and apply clippy improvements.
Cargo.tomlandcrates/bssh-russh/Cargo.tomlto edition 2024ref/ref mutbindings in favor of implicit borrowing (2024 feature)&&syntaxNote on Unsafe Functions
Rust 2024 marks
std::env::set_varandstd::env::remove_varas unsafe due to race conditions in multi-threaded environments. ~102 test usages remain unwrapped pending implementation of EnvGuard RAII wrapper (issue #179).Testing
Follow-up
Issue #179 created for comprehensive solution using RAII wrapper pattern.