radicle-dev / radicle-surf

A code browsing library for VCS file systems.
Other
32 stars 11 forks source link

`clippy::format_push_string` complains about the use of `push_str` #207

Closed sebastinez closed 2 years ago

sebastinez commented 2 years ago

cargo clippy warns about using push_str since https://github.com/rust-lang/rust-clippy/commit/a86bf81e44dd530b69b686c556069bb8f6569c64 and recommends to use write! instead. https://github.com/rust-lang/rust-clippy/issues/6261

If we want to comply with clippy we should maybe do that rewrite and handle the Result that write! returns

error: `format!(..)` appended to existing `String`
   --> surf/src/file_system/path.rs:181:17
    |
181 |                 pathspec.push_str(&format!("{}/", label));
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: the lint level is defined here
   --> surf/src/lib.rs:18:68
    |
18  | #![deny(missing_docs, unused_import_braces, unused_qualifications, warnings)]
    |                                                                    ^^^^^^^^
    = note: `#[deny(clippy::format_push_string)]` implied by `#[deny(warnings)]`
    = help: consider using `write!` to avoid the extra allocation
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string
error: `format!(..)` appended to existing `String`
   --> surf/src/vcs/git/reference/glob.rs:106:13
    |
106 |             namespace_glob.push_str(&format!("refs/namespaces/{}/", n));
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using `write!` to avoid the extra allocation
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string
FintanH commented 2 years ago

Mmmm right, thanks for flagging! I keep my versions pinned via Nix so I update the toolchain manually.

I can get around to this :)

FintanH commented 2 years ago

Fixed in https://github.com/radicle-dev/radicle-surf/commit/b85d2183d786e5fa447aab9d2f420a32f1061bfa