mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
e43d893ea3
wrap chrono in panic hooks to handle panic'ing unwraps on Jan 1, 1601 00:00 UTC and other reasons unknown. An overflow if time_u64 is smaller than EPOCH_AS_FILETIME has been wrapped. Further discussion https://github.com/nushell/nushell/issues/10464 There are two issues that are associated with Chrono. I did not test. It may not relate, but it could. thread 'main' panicked at 'SystemTimeToFileTime failed with: The parameter is incorrect. https://github.com/nushell/nushell/issues/6574 https://github.com/nushell/nushell/issues/9470 # Description I'm not a fan of this code that was pulled from chrono. negative seconds and nano seconds? ```rust // Adapted from https://github.com/chronotope/chrono/blob/v0.4.19/src/datetime.rs#L755-L767. let (sec, nsec, was_success) = match t.duration_since(UNIX_EPOCH) { Ok(dur) => { (dur.as_secs() as i64, dur.subsec_nanos(),true) }, Err(e) => { // unlikely but should be handled let dur = e.duration(); let (sec, nsec) = (dur.as_secs() as i64, dur.subsec_nanos()); if nsec == 0 { (-sec, 0,false) } else { (-sec - 1, 1_000_000_000 - nsec,false) } } }; ``` There's more on the #10464 ticket; # User-Facing Changes Use ls and it will not crash when listing windows pipes ls \\.\pipe. # Tests + Formatting - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) DONE - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style that command yields: ```rust error: casting raw pointers to the same type and constness is unnecessary (`*mut u16` -> `*mut u16`) --> crates\nu-system\src\windows.rs:972:13 | 972 | name.as_mut_ptr() as *mut u16, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `name.as_mut_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `-D clippy::unnecessary-cast` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting raw pointers to the same type and constness is unnecessary (`*mut u16` -> `*mut u16`) --> crates\nu-system\src\windows.rs:974:13 | 974 | domainname.as_mut_ptr() as *mut u16, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `domainname.as_mut_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast error: could not compile `nu-system` (lib) due to 2 previous errors ``` TBD - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library |
||
---|---|---|
.. | ||
src | ||
tests | ||
Cargo.toml | ||
LICENSE |