Advertisement
AngheloAlf

clippy bug on mapfile_parser

Oct 2nd, 2023
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 7.45 KB | Software | 0 0
  1. $ cargo clippy --fix  --all-targets --all-features -- -D warnings
  2.     Checking pyo3-ffi v0.19.2
  3.     Checking pyo3 v0.19.2
  4.     Checking mapfile_parser v2.2.0 (/home/angie/Documents/n64decomp/mapfile_parser)
  5. warning: failed to automatically apply fixes suggested by rustc to crate `mapfile_parser`
  6.  
  7. after fixes were automatically applied the compiler reported errors within these files:
  8.  
  9.   * src/rs/segment.rs
  10.  
  11. This likely indicates a bug in either rustc or cargo itself,
  12. and we would appreciate a bug report! You're likely to see
  13. a number of compiler warnings after this message which cargo
  14. attempted to fix but failed. If you could open an issue at
  15. https://github.com/rust-lang/rust/issues
  16. quoting the full output of this command we'd be very appreciative!
  17. Note that you may be able to make some more progress in the near-term
  18. fixing code with the `--broken-code` flag
  19.  
  20. The following errors were reported:
  21. error[E0382]: borrow of moved value: `path`
  22.    --> src/rs/segment.rs:133:34
  23.     |
  24. 119 |             let mut path: PathBuf = file
  25.     |                 -------- move occurs because `path` has type `std::path::PathBuf`, which does not implement the `Copy` trait
  26. ...
  27. 130 |             if let std::collections::hash_map::Entry::Vacant(e) = aux_dict.entry(path) {
  28.     |                                                                                  ---- value moved here
  29. ...
  30. 133 |                 aux_dict.get_mut(&path).unwrap().push(file);
  31.     |                                  ^^^^^ value borrowed here after move
  32.  
  33. error: aborting due to previous error
  34.  
  35. For more information about this error, try `rustc --explain E0382`.
  36. Original diagnostics will follow.
  37.  
  38. warning: redundant field names in struct initialization
  39.   --> src/rs/segment.rs:39:13
  40.    |
  41. 39 |             name: name,
  42.    |             ^^^^^^^^^^ help: replace it with: `name`
  43.    |
  44.    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
  45.    = note: `-D clippy::redundant-field-names` implied by `-D warnings`
  46.  
  47. warning: unneeded late initialization
  48.    --> src/rs/file.rs:168:9
  49.     |
  50. 168 |         let average_size;
  51.     |         ^^^^^^^^^^^^^^^^^
  52.     |
  53.     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
  54.     = note: `-D clippy::needless-late-init` implied by `-D warnings`
  55. help: declare `average_size` here
  56.     |
  57. 169 |         let average_size = if sym_count > 0 {
  58.     |         ++++++++++++++++++
  59. help: remove the assignments from the branches
  60.     |
  61. 170 ~             self.size as f64 / sym_count as f64
  62. 171 |         } else {
  63. 172 ~             self.size as f64 / 1.0
  64.     |
  65. help: add a semicolon after the `if` expression
  66.     |
  67. 173 |         };
  68.     |          +
  69.  
  70. warning: you should consider adding a `Default` implementation for `MapFile`
  71.   --> src/rs/mapfile.rs:29:5
  72.    |
  73. 29 | /     pub fn new() -> Self {
  74. 30 | |         MapFile {
  75. 31 | |             segments_list: Vec::new(),
  76. 32 | |             debugging: false,
  77. 33 | |         }
  78. 34 | |     }
  79.    | |_____^
  80.    |
  81.    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
  82.    = note: `-D clippy::new-without-default` implied by `-D warnings`
  83. help: try adding this
  84.    |
  85. 27 + impl Default for MapFile {
  86. 28 +     fn default() -> Self {
  87. 29 +         Self::new()
  88. 30 +     }
  89. 31 + }
  90.    |
  91.  
  92. warning: the loop variable `i` is used to index `temp_segment_list`
  93.    --> src/rs/mapfile.rs:148:18
  94.     |
  95. 148 |         for i in 0..temp_segment_list.len() {
  96.     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  97.     |
  98.     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
  99.     = note: `-D clippy::needless-range-loop` implied by `-D warnings`
  100. help: consider using an iterator and enumerate()
  101.     |
  102. 148 |         for (i, <item>) in temp_segment_list.iter_mut().enumerate() {
  103.     |             ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104.  
  105. warning: this `if` has identical blocks
  106.    --> src/rs/mapfile.rs:410:49
  107.     |
  108. 410 |                       if whole_file_is_undecomped {
  109.     |  _________________________________________________^
  110. 411 | |                         total_stats.undecomped_size += sym_size;
  111. 412 | |                         folder_progress.undecomped_size += sym_size;
  112. 413 | |                     } else if func_asm_path.exists() {
  113.     | |_____________________^
  114.     |
  115. note: same as this
  116.    --> src/rs/mapfile.rs:413:54
  117.     |
  118. 413 |                       } else if func_asm_path.exists() {
  119.     |  ______________________________________________________^
  120. 414 | |                         total_stats.undecomped_size += sym_size;
  121. 415 | |                         folder_progress.undecomped_size += sym_size;
  122. 416 | |                     } else {
  123.     | |_____________________^
  124.     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
  125.     = note: `#[warn(clippy::if_same_then_else)]` on by default
  126.  
  127. warning: you should consider adding a `Default` implementation for `MapsComparisonInfo`
  128.   --> src/rs/maps_comparison_info.rs:25:5
  129.    |
  130. 25 | /     pub fn new() -> Self {
  131. 26 | |         MapsComparisonInfo {
  132. 27 | |             bad_files: HashSet::new(),
  133. 28 | |             missing_files: HashSet::new(),
  134. 29 | |             compared_list: Vec::new(),
  135. 30 | |         }
  136. 31 | |     }
  137.    | |_____^
  138.    |
  139.    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
  140. help: try adding this
  141.    |
  142. 23 + impl Default for MapsComparisonInfo {
  143. 24 +     fn default() -> Self {
  144. 25 +         Self::new()
  145. 26 +     }
  146. 27 + }
  147.    |
  148.  
  149. warning: you should consider adding a `Default` implementation for `ProgressStats`
  150.   --> src/rs/progress_stats.rs:21:5
  151.    |
  152. 21 | /     pub fn new() -> Self {
  153. 22 | |         Self {
  154. 23 | |             undecomped_size: 0,
  155. 24 | |             decomped_size: 0,
  156. 25 | |         }
  157. 26 | |     }
  158.    | |_____^
  159.    |
  160.    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
  161. help: try adding this
  162.    |
  163. 19 + impl Default for ProgressStats {
  164. 20 +     fn default() -> Self {
  165. 21 +         Self::new()
  166. 22 +     }
  167. 23 + }
  168.    |
  169.  
  170. warning: usage of `contains_key` followed by `insert` on a `HashMap`
  171.    --> src/rs/segment.rs:130:13
  172.     |
  173. 130 | /             if !aux_dict.contains_key(&path) {
  174. 131 | |                 aux_dict.insert(path, vec![file]);
  175. 132 | |             } else {
  176. 133 | |                 aux_dict.get_mut(&path).unwrap().push(file);
  177. 134 | |             }
  178.     | |_____________^
  179.     |
  180.     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
  181.     = note: `-D clippy::map-entry` implied by `-D warnings`
  182. help: try this
  183.     |
  184. 130 ~             if let std::collections::hash_map::Entry::Vacant(e) = aux_dict.entry(path) {
  185. 131 +                 e.insert(vec![file]);
  186. 132 +             } else {
  187. 133 +                 aux_dict.get_mut(&path).unwrap().push(file);
  188. 134 +             }
  189.     |
  190.  
  191. warning: `mapfile_parser` (lib) generated 8 warnings (1 duplicate) (run `cargo clippy --fix --lib -p mapfile_parser` to apply 1 suggestion)
  192. warning: `mapfile_parser` (lib test) generated 8 warnings (7 duplicates) (run `cargo clippy --fix --lib -p mapfile_parser --tests` to apply 1 suggestion)
  193.     Finished dev [unoptimized + debuginfo] target(s) in 5.21s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement