Skip to content

Commit eef1176

Browse files
committed
Try a few more pedantic Clippy lints
You still can't convince me that an if-else is _more_ readable than my match on a boolean in LocatedError::from_parts. I also don't care for the insistence on replacing closures directly with their functions; shouldn't the compiler be able to optimize that? I'd love to turn on the one about un-backticked items in doc comments, but it keeps picking up on "MessagePack" despite that being the human name of that particular data format. I'm not sure if you can customize exclusions to that rule.
1 parent a51e5b2 commit eef1176

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
clippy::unnecessary_cast,
2222
// More general style-type things.
2323
clippy::from_over_into,
24+
clippy::needless_raw_string_hashes,
2425
clippy::semicolon_if_nothing_returned,
26+
clippy::similar_names,
2527
)]
2628
#![warn(
2729
// Print macros can panic, and should only be for temporary debugging.

src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
clippy::unnecessary_cast,
1212
// More general style-type things.
1313
clippy::from_over_into,
14+
clippy::needless_raw_string_hashes,
1415
clippy::semicolon_if_nothing_returned,
16+
clippy::similar_names,
1517
)]
1618
#![warn(
1719
// Print macros can panic, and should only be for temporary debugging.
@@ -175,10 +177,10 @@ where
175177
let argv0 = usage_name();
176178
let _ = write!(
177179
w,
178-
r#"Usage: {argv0} {USAGE}
180+
r"Usage: {argv0} {USAGE}
179181
Formats: json, msgpack, toml, yaml
180182
Try '{argv0} --help' for more information.
181-
"#
183+
"
182184
);
183185
}
184186

src/msgpack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::transcode;
1313

1414
/// The maximum allowed nesting depth of MessagePack values.
1515
///
16-
/// This particular value is the undocumented default from rmp_serde, which
16+
/// This particular value is the undocumented default from [`rmp_serde`], which
1717
/// seems to be enough to reliably prevent stack overflows on debug builds of
1818
/// the program using the default main thread stack size on Linux and macOS.
1919
const DEPTH_LIMIT: usize = 1024;

src/transcode/stream.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ impl<'de, S: Serializer> de::Visitor<'de> for &mut Visitor<S> {
329329
}
330330

331331
fn visit_seq<A: de::SeqAccess<'de>>(self, mut de: A) -> Result<Self::Value, A::Error> {
332-
let ser = self.0.take_parent();
333-
let mut seq = match ser.serialize_seq(de.size_hint()) {
332+
let mut seq = match self.0.take_parent().serialize_seq(de.size_hint()) {
334333
Ok(seq) => seq,
335334
Err(ser_err) => {
336335
self.0.capture_error(ErrorSource::Ser, ser_err);
@@ -360,8 +359,7 @@ impl<'de, S: Serializer> de::Visitor<'de> for &mut Visitor<S> {
360359
}
361360

362361
fn visit_map<A: de::MapAccess<'de>>(self, mut de: A) -> Result<Self::Value, A::Error> {
363-
let ser = self.0.take_parent();
364-
let mut map = match ser.serialize_map(de.size_hint()) {
362+
let mut map = match self.0.take_parent().serialize_map(de.size_hint()) {
365363
Ok(map) => map,
366364
Err(ser_err) => {
367365
self.0.capture_error(ErrorSource::Ser, ser_err);

src/yaml/chunker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ mod tests {
198198

199199
#[test]
200200
fn chunker_normal_usage() {
201-
const INPUT: &str = r#"---
201+
const INPUT: &str = r"---
202202
test: true
203203
---
204204
12345
205205
---
206206
[list, of strings]
207-
"#;
207+
";
208208

209209
let chunker = Chunker::new(INPUT.as_bytes());
210210
let docs = chunker.collect::<Result<Vec<_>, io::Error>>().unwrap();

src/yaml/chunker/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ where
115115
///
116116
/// # Safety
117117
///
118-
/// The data pointer provided to yaml_parser_set_input must be a valid
118+
/// The data pointer provided to `yaml_parser_set_input` must be a valid
119119
/// `ReadState<R>` pointer.
120120
unsafe fn read_handler(
121121
read_state: *mut c_void,

0 commit comments

Comments
 (0)