Skip to content

Commit

Permalink
Resolve needless_borrow clippy lints
Browse files Browse the repository at this point in the history
    error: the borrowed expression implements the required traits
       --> src/value/ser.rs:198:60
        |
    198 |         values.insert(String::from(variant), tri!(to_value(&value)));
        |                                                            ^^^^^^ help: change this to: `value`
        |
        = note: `-D clippy::needless-borrow` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: the borrowed expression implements the required traits
       --> src/value/ser.rs:317:37
        |
    317 |         self.vec.push(tri!(to_value(&value)));
        |                                     ^^^^^^ help: change this to: `value`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: the borrowed expression implements the required traits
       --> src/value/ser.rs:366:37
        |
    366 |         self.vec.push(tri!(to_value(&value)));
        |                                     ^^^^^^ help: change this to: `value`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: the borrowed expression implements the required traits
       --> src/value/ser.rs:409:47
        |
    409 |                 map.insert(key, tri!(to_value(&value)));
        |                                               ^^^^^^ help: change this to: `value`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: the borrowed expression implements the required traits
       --> src/value/ser.rs:666:58
        |
    666 |         self.map.insert(String::from(key), tri!(to_value(&value)));
        |                                                          ^^^^^^ help: change this to: `value`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: the borrowed expression implements the required traits
      --> tests/test.rs:98:26
       |
    98 |         let v = to_value(&value).unwrap();
       |                          ^^^^^^ help: change this to: `value`
       |
       = note: `-D clippy::needless-borrow` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: the borrowed expression implements the required traits
       --> tests/test.rs:114:26
        |
    114 |         let v = to_value(&value).unwrap();
        |                          ^^^^^^ help: change this to: `value`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
  • Loading branch information
dtolnay committed Sep 2, 2022
1 parent 5f801ea commit 7af05a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/value/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl serde::Serializer for Serializer {
T: ?Sized + Serialize,
{
let mut values = Map::new();
values.insert(String::from(variant), tri!(to_value(&value)));
values.insert(String::from(variant), tri!(to_value(value)));
Ok(Value::Object(values))
}

Expand Down Expand Up @@ -314,7 +314,7 @@ impl serde::ser::SerializeSeq for SerializeVec {
where
T: ?Sized + Serialize,
{
self.vec.push(tri!(to_value(&value)));
self.vec.push(tri!(to_value(value)));
Ok(())
}

Expand Down Expand Up @@ -363,7 +363,7 @@ impl serde::ser::SerializeTupleVariant for SerializeTupleVariant {
where
T: ?Sized + Serialize,
{
self.vec.push(tri!(to_value(&value)));
self.vec.push(tri!(to_value(value)));
Ok(())
}

Expand Down Expand Up @@ -406,7 +406,7 @@ impl serde::ser::SerializeMap for SerializeMap {
// Panic because this indicates a bug in the program rather than an
// expected failure.
let key = key.expect("serialize_value called before serialize_key");
map.insert(key, tri!(to_value(&value)));
map.insert(key, tri!(to_value(value)));
Ok(())
}
#[cfg(feature = "arbitrary_precision")]
Expand Down Expand Up @@ -663,7 +663,7 @@ impl serde::ser::SerializeStructVariant for SerializeStructVariant {
where
T: ?Sized + Serialize,
{
self.map.insert(String::from(key), tri!(to_value(&value)));
self.map.insert(String::from(key), tri!(to_value(value)));
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where
let s = to_string(value).unwrap();
assert_eq!(s, out);

let v = to_value(&value).unwrap();
let v = to_value(value).unwrap();
let s = to_string(&v).unwrap();
assert_eq!(s, out);
}
Expand All @@ -111,7 +111,7 @@ where
let s = to_string_pretty(value).unwrap();
assert_eq!(s, out);

let v = to_value(&value).unwrap();
let v = to_value(value).unwrap();
let s = to_string_pretty(&v).unwrap();
assert_eq!(s, out);
}
Expand Down

0 comments on commit 7af05a9

Please sign in to comment.