Skip to content

Commit

Permalink
Apply nightly clippy fixes
Browse files Browse the repository at this point in the history
```
warning: you should consider adding a `Default` implementation for `HjsonFormatter<'a>`
   --> crates/nu-json/src/ser.rs:700:5
    |
700 | /     pub fn new() -> Self {
701 | |         HjsonFormatter::with_indent(b"  ")
702 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
    = note: `#[warn(clippy::new_without_default)]` on by default
help: try adding this
    |
698 + impl<'a> Default for HjsonFormatter<'a> {
699 +     fn default() -> Self {
700 +         Self::new()
701 +     }
702 + }
    |

warning: `nu-json` (lib) generated 1 warning
warning: private item shadows public glob re-export
  --> crates/nu-command/src/strings/mod.rs:8:1
   |
8  | mod str_;
   | ^^^^^^^^^
   |
note: the name `str_` in the type namespace is supposed to be publicly re-exported here
  --> crates/nu-command/src/strings/mod.rs:17:9
   |
17 | pub use str_::*;
   |         ^^^^^^^
note: but the private item here shadows it
  --> crates/nu-command/src/strings/mod.rs:8:1
   |
8  | mod str_;
   | ^^^^^^^^^
   = note: `#[warn(hidden_glob_reexports)]` on by default

warning: incorrect NaN comparison, NaN cannot be directly compared to itself
   --> crates/nu-command/src/formats/to/nuon.rs:186:20
    |
186 |                 && val != &f64::NAN
    |                    ^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(invalid_nan_comparisons)]` on by default
help: use `f32::is_nan()` or `f64::is_nan()` instead
    |
186 -                 && val != &f64::NAN
186 +                 && !val.is_nan()
    |

warning: `nu-command` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p nu-command` to apply 1 suggestion)
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
```
  • Loading branch information
nibon7 committed Jun 19, 2023
1 parent d78e3c3 commit 9221c37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/nu-command/src/formats/to/nuon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub fn value_to_string(
Value::Float { val, .. } => {
// This serialises these as 'nan', 'inf' and '-inf', respectively.
if &val.round() == val
&& val != &f64::NAN
&& !val.is_nan()
&& val != &f64::INFINITY
&& val != &f64::NEG_INFINITY
{
Expand Down
20 changes: 10 additions & 10 deletions crates/nu-command/src/strings/str_/case/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub mod camel_case;
pub mod capitalize;
pub mod downcase;
pub mod kebab_case;
pub mod pascal_case;
pub mod screaming_snake_case;
pub mod snake_case;
pub mod str_;
pub mod title_case;
pub mod upcase;
mod camel_case;
mod capitalize;
mod downcase;
mod kebab_case;
mod pascal_case;
mod screaming_snake_case;
mod snake_case;
mod str_;
mod title_case;
mod upcase;

pub use camel_case::SubCommand as StrCamelCase;
pub use capitalize::SubCommand as StrCapitalize;
Expand Down
6 changes: 6 additions & 0 deletions crates/nu-json/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,12 @@ struct HjsonFormatter<'a> {
braces_same_line: bool,
}

impl<'a> Default for HjsonFormatter<'a> {
fn default() -> Self {
Self::new()
}
}

impl<'a> HjsonFormatter<'a> {
/// Construct a formatter that defaults to using two spaces for indentation.
pub fn new() -> Self {
Expand Down

0 comments on commit 9221c37

Please sign in to comment.