Skip to content

Merge pull request #74 from andrewbaxter/fix-static-mut #131

Merge pull request #74 from andrewbaxter/fix-static-mut

Merge pull request #74 from andrewbaxter/fix-static-mut #131

GitHub Actions / clippy succeeded May 10, 2024 in 0s

clippy

39 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 39
Note 0
Help 0

Versions

  • rustc 1.77.2 (25ef9e3d8 2024-04-09)
  • cargo 1.77.2 (e52e36006 2024-03-26)
  • clippy 0.1.77 (25ef9e3 2024-04-09)

Annotations

Check warning on line 342 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `FormatConfig` which implements the `Copy` trait

warning: using `clone` on type `FormatConfig` which implements the `Copy` trait
   --> src/bin/genemichaels.rs:342:22
    |
342 |         let config = self.config.clone();
    |                      ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `self.config`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
    = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 336 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/bin/genemichaels.rs:325:9
    |
325 | /         return FormatPool {
326 | |             log: log.clone(),
327 | |             config: config,
328 | |             pool: {
...   |
335 | |             errors: Arc::new(Mutex::new(vec![])),
336 | |         };
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
    |
325 ~         FormatPool {
326 +             log: log.clone(),
327 +             config: config,
328 +             pool: {
329 +                 let mut p = threadpool::Builder::new();
330 +                 if let Some(t) = thread_count {
331 +                     p = p.num_threads(t);
332 +                 }
333 +                 p.build()
334 +             },
335 +             errors: Arc::new(Mutex::new(vec![])),
336 ~         }
    |

Check warning on line 181 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/bin/genemichaels.rs:181:38
    |
181 |             let config = load_config(&log, &[args.config, Some(PathBuf::from(CONFIG_JSON))])?;
    |                                      ^^^^ help: change this to: `log`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 166 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/bin/genemichaels.rs:166:38
    |
166 |             let config = load_config(&log, &[args.config, Some(PathBuf::from(CONFIG_JSON))])?;
    |                                      ^^^^ help: change this to: `log`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 102 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/bin/genemichaels.rs:102:21
    |
102 |                     return true;
    |                     ^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
    |
102 -                     return true;
102 +                     true
    |

Check warning on line 107 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

question mark operator is useless here

warning: question mark operator is useless here
   --> src/bin/genemichaels.rs:93:12
    |
93  |       return Ok(
    |  ____________^
94  | |         serde_json::from_str(
95  | |             &String::from_utf8(read(path).log_context(log, "Failed to read config file")?)
96  | |                 .log_context(log, "Failed to decode file as utf8")?
...   |
106 | |         ).log_context(log, "Failed to parse file as json")?,
107 | |     );
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
    = note: `#[warn(clippy::needless_question_mark)]` on by default
help: try removing question mark and `Ok()`
    |
93  ~     return serde_json::from_str(
94  +             &String::from_utf8(read(path).log_context(log, "Failed to read config file")?)
95  +                 .log_context(log, "Failed to decode file as utf8")?
96  +                 .lines()
97  +                 .filter(|l| {
98  +                     if l.trim_start().starts_with("//") {
99  +                         return false;
100 +                     }
101 +                     return true;
102 +                 })
103 +                 .collect::<Vec<&str>>()
104 +                 .join("\n"),
105 ~         ).log_context(log, "Failed to parse file as json");
    |

Check warning on line 82 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `let...else` may be rewritten with the `?` operator

warning: this `let...else` may be rewritten with the `?` operator
  --> src/bin/genemichaels.rs:80:9
   |
80 | /         let Some(p) = p else {
81 | |             return None;
82 | |         };
   | |__________^ help: replace it with: `let p = p?;`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
   = note: `#[warn(clippy::question_mark)]` on by default

Check warning on line 87 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
  --> src/bin/genemichaels.rs:87:9
   |
87 |         return Some(p);
   |         ^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
   |
87 -         return Some(p);
87 +         Some(p)
   |

Check warning on line 107 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/bin/genemichaels.rs:93:5
    |
93  | /     return Ok(
94  | |         serde_json::from_str(
95  | |             &String::from_utf8(read(path).log_context(log, "Failed to read config file")?)
96  | |                 .log_context(log, "Failed to decode file as utf8")?
...   |
106 | |         ).log_context(log, "Failed to parse file as json")?,
107 | |     );
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
93  ~     Ok(
94  +         serde_json::from_str(
95  +             &String::from_utf8(read(path).log_context(log, "Failed to read config file")?)
96  +                 .log_context(log, "Failed to decode file as utf8")?
97  +                 .lines()
98  +                 .filter(|l| {
99  +                     if l.trim_start().starts_with("//") {
100 +                         return false;
101 +                     }
102 +                     return true;
103 +                 })
104 +                 .collect::<Vec<&str>>()
105 +                 .join("\n"),
106 +         ).log_context(log, "Failed to parse file as json")?,
107 ~     )
    |

Check warning on line 327 in src/bin/genemichaels.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

redundant field names in struct initialization

warning: redundant field names in struct initialization
   --> src/bin/genemichaels.rs:327:13
    |
327 |             config: config,
    |             ^^^^^^^^^^^^^^ help: replace it with: `config`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: `#[warn(clippy::redundant_field_names)]` on by default

Check warning on line 544 in src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `FormatConfig` which implements the `Copy` trait

warning: using `clone` on type `FormatConfig` which implements the `Copy` trait
   --> src/lib.rs:544:17
    |
544 |         config: config.clone(),
    |                 ^^^^^^^^^^^^^^ help: try dereferencing it: `*config`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
    = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 202 in src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `new_segs.get(0)`

warning: accessing first element with `new_segs.get(0)`
   --> src/lib.rs:202:21
    |
202 |         let seg_i = new_segs.get(0).unwrap();
    |                     ^^^^^^^^^^^^^^^ help: try: `new_segs.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 125 in src/sg_pat.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this loop could be written as a `while let` loop

warning: this loop could be written as a `while let` loop
   --> src/sg_pat.rs:78:29
    |
78  | / ...                   loop {
79  | | ...                       let t = match at.1.as_ref() {
80  | | ...                           Pat::Tuple(t) => t,
81  | | ...                           _ => break,
...   |
124 | | ...                       return sg0.build(out);
125 | | ...                   };
    | |_______________________^ help: try: `while let Pat::Tuple(t) = at.1.as_ref() { .. }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop
    = note: `#[warn(clippy::while_let_loop)]` on by default

Check warning on line 569 in src/sg_general.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/sg_general.rs:566:17
    |
566 | /                 return Some(Whitespace {
567 | |                     loc: w.loc,
568 | |                     mode: WhitespaceMode::Comment(c),
569 | |                 });
    | |__________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
    |
566 ~                 Some(Whitespace {
567 +                     loc: w.loc,
568 +                     mode: WhitespaceMode::Comment(c),
569 ~                 })
    |

Check warning on line 563 in src/sg_general.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/sg_general.rs:560:17
    |
560 | /                 return Some(Whitespace {
561 | |                     loc: w.loc,
562 | |                     mode: WhitespaceMode::BlankLines(use_lines),
563 | |                 });
    | |__________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
    |
560 ~                 Some(Whitespace {
561 +                     loc: w.loc,
562 +                     mode: WhitespaceMode::BlankLines(use_lines),
563 ~                 })
    |

Check warning on line 165 in src/sg_expr.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `children.get(0)`

warning: accessing first element with `children.get(0)`
   --> src/sg_expr.rs:165:48
    |
165 |         sg.child(build_child(out, base_indent, children.get(0).unwrap()));
    |                                                ^^^^^^^^^^^^^^^ help: try: `children.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 981 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/whitespace.rs:981:29
    |
981 |                 unicode_len(&prefix),
    |                             ^^^^^^^ help: change this to: `prefix`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 992 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`

warning: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
   --> src/whitespace.rs:967:15
    |
967 |       match es!({
    |  _______________^
968 | |         let mut out = String::new();
969 | |         let mut state = State {
970 | |             line_buffer: String::new(),
...   |
991 | |         Ok(out)
992 | |     }) {
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
    = note: `#[warn(clippy::blocks_in_conditions)]` on by default

Check warning on line 910 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)`
   --> src/whitespace.rs:910:17
    |
910 |                 x.children.get(0)
    |                 ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

Check warning on line 853 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

accessing first element with `x.children.get(0)`

warning: accessing first element with `x.children.get(0)`
   --> src/whitespace.rs:853:17
    |
853 |                 x.children.get(0)
    |                 ^^^^^^^^^^^^^^^^^ help: try: `x.children.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
    = note: `#[warn(clippy::get_first)]` on by default

Check warning on line 627 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow
   --> src/whitespace.rs:627:70
    |
627 |             write_forward_breaks(state, &mut s, out, max_len, false, (&text[b..]).to_string(), b, breaks);
    |                                                                      ^^^^^^^^^^^^ help: change this to: `text[b..]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 612 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression borrows a value the compiler would automatically borrow

warning: this expression borrows a value the compiler would automatically borrow
   --> src/whitespace.rs:612:17
    |
612 |                 (&text[found.writable..]).to_string(),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `text[found.writable..]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 565 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/whitespace.rs:565:40
    |
565 |             state.line_buffer.push_str(&text);
    |                                        ^^^^^ help: change this to: `text`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 550 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/whitespace.rs:550:50
    |
550 |                 writable: if width + unicode_len(&text) > max_len {
    |                                                  ^^^^^ help: change this to: `text`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 557 in src/whitespace.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

unneeded `return` statement

warning: unneeded `return` statement
   --> src/whitespace.rs:549:13
    |
549 | /             return FoundWritableLen {
550 | |                 writable: if width + unicode_len(&text) > max_len {
551 | |                     writable
552 | |                 } else {
...   |
556 | |                 next_break: None,
557 | |             };
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
549 ~             FoundWritableLen {
550 +                 writable: if width + unicode_len(&text) > max_len {
551 +                     writable
552 +                 } else {
553 +                     text.len()
554 +                 },
555 +                 previous_break: previous_break,
556 +                 next_break: None,
557 ~             }
    |