Munksgaard / session-types

MIT License
550 stars 21 forks source link

Fix problems reported by clippy #37

Closed laumann closed 6 years ago

laumann commented 6 years ago

Just ran clippy and it gives this beautiful report:

   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
warning: you should put `session_types` between ticks in the documentation
 --> src/lib.rs:1:5
  |
1 | //! session_types
  warning: you should put `session_types` between ticks in the documentation
 --> src/lib.rs:1:5
  |
1 | //! session_types
  |     ^^^^^^^^^^^^^
  |
  = note: #[warn(doc_markdown)] on by default
  = help|     ^^^^^^^^^^^^^
  |
  = note: #[warn(doc_markdown)] on by default
  = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#doc_markdown

: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#doc_markdown

    Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs
    Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
   Compiling    Compiling libc v0.2.4
libc v0.2.4
   Compiling   Compiling rand v0.3.14
 rand v0.3.14
warning: this argument is passed by value, but not consumed in the function body
  --> examples/many-clients.rs:20:15
   |
20 | fn server(rx: Receiver<Chan<(), Server>>) {
   | warning: this argument is passed by value, but not consumed in the function body
  --> examples/many-clients.rs:20:15
   |
20 | fn server(rx: Receiver<Chan<(), Server>>) {
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Receiver<Chan<(), Server>>`
   |
   = note: #[warn(needless_pass_by_value)] on by default
   =               ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Receiver<Chan<(), Server>>`
   |
   = note: #[warn(needless_pass_by_value)] on by default
   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_pass_by_value

help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_pass_by_value

warning: this loop could be written as a `while let` loop
  --> examples/many-clients.rs:22:5
   |
22 | / warning: this loop could be written as a `while let` loop
  --> examples/many-clients.rs:22:5
   |
22 | /     loop {
23 | |         match rx.recv() {
24 |     loop {
23 | |         match rx.recv() {
24 | |             Ok(c) => {
25|             Ok(c) => {
25 | |                 spawn(move || server_handler(c)); | |                 spawn(move || server_handler(c));
...  |

...  |
29 | |29 | |         }
30          }
30 | |     }
| |     }
   | |_____^ help: try: `while let Ok(c) = rx.recv() { .. }`   | |_____^ help: try: `while let Ok(c) = rx.recv() { .. }`

   |
|
   = note: #[warn(while_let_loop)] on by default   = note: #[warn(while_let_loop)] on by default

   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#while_let_loop   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#while_let_loop

      Finished dev [unoptimized + debuginfo] target(s) in 3.11 secs
  Finished dev [unoptimized + debuginfo] target(s) in 3.11 secs
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
warning: writing `&String` instead of `&str` involves a new object where a slice will do. Consider changing the type to `&str`
  --> examples/atm.rs:19:17
   |
19 | fn approved(id: &Id) -> bool {warning: writing `&String` instead of `&str` involves a new object where a slice will do. Consider changing the type to `&str`
  --> examples/atm.rs:19:17
   |
19 | fn approved(id: &Id) -> bool {
   |                 ^^^
   |
   = note: #[warn(ptr_arg)] on by default

   |                 ^^^
   |
   = note: #[warn(ptr_arg)] on by default
   =    = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#ptr_arg

help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#ptr_arg

    Finished dev [unoptimized + debuginfo] target(s) in 1.66 secs
    Finished dev [unoptimized + debuginfo] target(s) in 1.66 secs
   Compiling   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
 session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
warning: very complex type used. Consider factoring parts into `type` definitions
warning: very complex type used. Consider factoring parts into `type` definitions
   --> examples/arithmetic.rs:138:22
    |
138 |                  c2: Chan<(), Send<Chan<(AskNeg<R, S>, ()), Recv<i64, Var<Z>>>, Eps>>) {
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    =    --> examples/arithmetic.rs:138:22
    |
138 |                  c2: Chan<(), Send<Chan<(AskNeg<R, S>, ()), Recv<i64, Var<Z>>>, Eps>>) {
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(type_complexity)] on by default
note: #[warn(type_complexity)] on by default
    =     = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#type_complexity

help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#type_complexity

warning: very complex type used. Consider factoring parts into `type` definitions
   warning: very complex type used. Consider factoring parts into `type` definitions
   --> examples/arithmetic.rs:143:80
    |
143 | --> examples/arithmetic.rs:143:80
    |
143 | fn get_neg<R: std::marker::Send + 'static, S: std::marker::Send + 'static>(c1: Chan<(), Recv<Chan<(AskNeg<R, S>, ()), Recv<i64, Var<Z>>>, Eps>>) {
    |                                                                                fn get_neg<R: std::marker::Send + 'static, S: std::marker::Send + 'static>(c1: Chan<(), Recv<Chan<(AskNeg<R, S>, ()), Recv<i64, Var<Z>>>, Eps>>) {
    |                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
|
    =     = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#type_complexity

help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#type_complexity

       Finished dev [unoptimized + debuginfo] target(s) in 2.46 secs
 Finished dev [unoptimized + debuginfo] target(s) in 2.46 secs
   Compiling session_types v0.2.0 (   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
file:///home/tj/rust/rust-sessions)
warning: 5th binding whose name is just one char
  --> examples/planeclip.rs:35:42
warning: 5th binding whose name is just one char
  --> examples/planeclip.rs:35:42
   |
35 | fn above(Point(x, y, z): Point, Plane(a, b, c, d): Plane) -> bool {
   |                                          ^
   |
   = note: #[warn(many_single_char_names)] on by default
   |
35 | fn above(Point(x, y, z): Point, Plane(a, b, c, d): Plane) -> bool {
   |                                          ^
   |
   = note: #[warn(many_single_char_names)] on by default
   =    = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: 6th binding whose name is just one char
warning: 6th binding whose name is just one char
  --> examples/planeclip.rs:35:45
   |  --> examples/planeclip.rs:35:45
   |
35 | fn above(Point(x, y, z): Point, Plane(a, b, c, d): Plane) -> bool {
35 | fn above(Point(x, y, z): Point, Plane(a, b, c, d): Plane) -> bool {
   |                                             ^
   |                                             ^
   |
   |

   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: 7th binding whose name is just one char
warning: 7th binding whose name is just one char
  --> examples/planeclip.rs:35:48
   |
35 | fn above(Point(x, y, z): Point, Plane(a, b, c, d): Plane) -> bool {
   |                                                ^
   |  --> examples/planeclip.rs:35:48
   |
35 | fn above(Point(x, y, z): Point, Plane(a, b, c, d): Plane) -> bool {
   |                                                ^
   |

   = help   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: 5th binding whose name is just one char
warning: 5th binding whose name is just one char
  --> examples/planeclip.rs:47:13
   |  --> examples/planeclip.rs:47:13
   |
47 |         let t = (a * x1 + b * y1 + c * z1 + d) /
47 |         let t = (a * x1 + b * y1 + c * z1 + d) /
   |             
   |             ^
   |^
   |

   = help   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: 6th binding whose name is just one char
warning: 6th binding whose name is just one char
  --> examples/planeclip.rs:49:13
   |  --> examples/planeclip.rs:49:13
   |
49 |         let x = x1 + (x2 - x1) * t;
49 |         let x = x1 + (x2 - x1) * t;
   |             
   |             ^
   |^
   |

   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: 7th binding whose name is just one char
warning: 7th binding whose name is just one char
  --> examples/planeclip.rs:50:13
     --> examples/planeclip.rs:50:13
   |
50 |
50 |         let y = y1 + (y2 - y1) * t;
   | |         let y = y1 + (y2 - y1) * t;
   |             ^
               ^
   |
|
   = help   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: 8th binding whose name is just one char
warning: 8th binding whose name is just one char
  --> examples/planeclip.rs:51:13
     --> examples/planeclip.rs:51:13
   |
51 |
51 |         let z = z1 + (z2 - z1) * t;
   | |         let z = z1 + (z2 - z1) * t;
   |             ^
               ^
   |
|
   = help   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#many_single_char_names

warning: this argument is passed by value, but not consumed in the function body
  --> examples/planeclip.rs:60:36
   |
60 |     (c: Chan<(), SendList<A>>, xs: Vec<A>)
   |                                    warning: this argument is passed by value, but not consumed in the function body
  --> examples/planeclip.rs:60:36
   |
60 |     (c: Chan<(), SendList<A>>, xs: Vec<A>)
   |                                    ^^^^^^ help: consider changing the type to: `&[A]`
   |
   = note: #[warn(needless_pass_by_value)] on by default
   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_pass_by_value

^^^^^^ help: consider changing the type to: `&[A]`
   |
   = note: #[warn(needless_pass_by_value)] on by default
   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_pass_by_value

warning: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
  --> examples/planeclip.rs:63:14
   |
63 |     for x in xs.iter() {
warning: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
  --> examples/planeclip.rs:63:14
   |
63 |     for x in xs.iter() {
   |              ^^^^^^^^^ help: to write this more concisely, try: `&xs`
   |
   |              ^^^^^^^^^ help: to write this more concisely, try: `&xs`
   |
   = note: #[warn(explicit_iter_loop)] on by default
   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#explicit_iter_loop

   = note: #[warn(explicit_iter_loop)] on by default
   = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#explicit_iter_loop

warning: it is more idiomatic to loop over containers instead of using explicit iteration methods`
   --> examples/planeclip.rs:144:18
    |
144 |     for plane in planes.into_iter() {
warning: it is more idiomatic to loop over containers instead of using explicit iteration methods`
   --> examples/planeclip.rs:144:18
    |
144 |     for plane in planes.into_iter() {
    |                  ^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `planes`
    |
    |                  ^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `planes`
    |
        = note: #[warn(explicit_into_iter_loop)] on by default
= note: #[warn(explicit_into_iter_loop)] on by default
        = help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#explicit_into_iter_loop

= help: for further information visit https://github.com/rust-lang-nursery/rust-clippy/wiki#explicit_into_iter_loop

        Finished dev [unoptimized + debuginfo] target(s) in 1.58 secs
Finished dev [unoptimized + debuginfo] target(s) in 1.58 secs
   Compiling session_types v   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
0.2.0 (file:///home/tj/rust/rust-sessions)
    Finished     Finished dev [unoptimized + debuginfo] target(s) in 0.90 secs
dev [unoptimized + debuginfo] target(s) in 0.90 secs
   Compiling session_types v0.2.0 (   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
file:///home/tj/rust/rust-sessions)
    Finished dev [unoptimized + debuginfo] target(s) in 0.66 secs    Finished dev [unoptimized + debuginfo] target(s) in 0.66 secs

   Compiling session_types   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
 v0.2.0 (file:///home/tj/rust/rust-sessions)
    Finished    Finished dev [unoptimized + debuginfo] target(s) in 1.38 secs
 dev [unoptimized + debuginfo] target(s) in 1.38 secs
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
warning: unused `#[macro_use]` import
 --> tests/chan_select.rs:1:1
  |
1 | #[macro_use] extern crate session_types;
  | ^^^^^^^^^^^^warning: unused `#[macro_use]` import
 --> tests/chan_select.rs:1:1
  |
1 | #[macro_use] extern crate session_types;
  | ^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

  |
  = note: #[warn(unused_imports)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.40 secs
    Finished dev [unoptimized + debuginfo] target(s) in 0.40 secs
   Compiling session_types   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
 v0.2.0 (file:///home/tj/rust/rust-sessions)
    Finished     Finished dev [unoptimized + debuginfo] target(s) in 1.12 secs
dev [unoptimized + debuginfo] target(s) in 1.12 secs
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
   Compiling session_types v0.2.0 (file:///home/tj/rust/rust-sessions)
    Finished dev [unoptimized + debuginfo] target(s) in 0.40 secs
    Finished dev [unoptimized + debuginfo] target(s) in 0.40 secs