Skip to content

Instantly share code, notes, and snippets.

@akesling
Created December 4, 2020 20:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save akesling/4535958548c362d09d52fa5c86c24f23 to your computer and use it in GitHub Desktop.
Rust Clippy Results for https://github.com/RustAudio/rimd
Checking rimd v0.0.2 (/Users/akesling/Devel/FallenTimbre/rimd)
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/midi.rs:194:29
|
194 | 1 => { ret.push(try!(read_byte(reader))); }
| ^^^
|
= note: `#[warn(deprecated)]` on by default
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/midi.rs:195:29
|
195 | 2 => { ret.push(try!(read_byte(reader)));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/midi.rs:196:29
|
196 | ret.push(try!(read_byte(reader))); }
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/midi.rs:201:32
|
201 | let byte = try!(read_byte(reader));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/midi.rs:220:29
|
220 | 2 => { ret.push(try!(read_byte(reader))); } // only need one more byte
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/midi.rs:230:20
|
230 | let stat = try!(read_byte(reader));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/meta.rs:156:40
|
156 | match MetaCommand::from_u8(try!(read_byte(reader))) {
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/meta.rs:165:9
|
165 | try!(read_amount(reader,&mut data,len as usize));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:15:9
|
15 | try!(fill_buf(reader,&mut header));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:23:13
|
23 | try!(fill_buf(reader, &mut skip));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:24:13
|
24 | try!(fill_buf(reader, &mut header));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:49:20
|
49 | let time = try!(SMFReader::read_vtime(reader));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:50:20
|
50 | let stat = try!(read_byte(reader));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:60:29
|
60 | let event = try!(MetaEvent::next_event(reader));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:70:25
|
70 | try!(MidiMessage::next_message_running_status(laststat,stat,reader))
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:72:25
|
72 | try!(MidiMessage::next_message_given_status(stat,reader))
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:89:9
|
89 | try!(fill_buf(reader,&mut buf));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:96:9
|
96 | try!(fill_buf(reader,&mut buf));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:177:24
|
177 | let next = try!(read_byte(reader));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/reader.rs:193:35
|
193 | s.tracks.push(try!(SMFReader::parse_track(reader)));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:100:9
|
100 | try!(writer.write_all(&storage[..]));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:194:9
|
194 | try!(writer.write_all(&[0x4D,0x54,0x68,0x64]));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:195:9
|
195 | try!(writer.write_u32::<BigEndian>(6));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:196:9
|
196 | try!(writer.write_u16::<BigEndian>(self.format));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:197:9
|
197 | try!(writer.write_u16::<BigEndian>(self.tracks.len() as u16));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:198:9
|
198 | try!(writer.write_i16::<BigEndian>(self.ticks));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:205:9
|
205 | try!(self.write_header(writer));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:207:13
|
207 | try!(writer.write_all(&track[..]));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/writer.rs:216:24
|
216 | let mut file = try!(OpenOptions::new().write(true).truncate(true).create(true).open(path));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/util.rs:24:5
|
24 | try!(reader.read(&mut b));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/util.rs:32:26
|
32 | let bytes_read = try!(reader.read(&mut buf[read..]));
| ^^^
warning: use of deprecated macro `try`: use the `?` operator instead
--> src/lib.rs:260:24
|
260 | let mut file = try!(File::open(path));
| ^^^
warning: redundant field names in struct initialization
--> src/builder.rs:18:13
|
18 | time: time,
| ^^^^^^^^^^ help: replace it with: `time`
|
= note: `#[warn(clippy::redundant_field_names)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/builder.rs:24:13
|
24 | time: time,
| ^^^^^^^^^^ help: replace it with: `time`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: this `else { if .. }` block can be collapsed
--> src/builder.rs:104:30
|
104 | else {
| ______________________________^
105 | | if me.data(1) < you.data(1) {
106 | | Ordering::Less
107 | | } else if me.data(1) > you.data(1) {
... |
111 | | }
112 | | }
| |_________________________^
|
= note: `#[warn(clippy::collapsible_if)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
|
104 | else if me.data(1) < you.data(1) {
105 | Ordering::Less
106 | } else if me.data(1) > you.data(1) {
107 | Ordering::Greater
108 | } else {
109 | res
...
warning: redundant field names in struct initialization
--> src/builder.rs:157:29
|
157 | ... vtime: vtime,
| ^^^^^^^^^^^^ help: replace it with: `vtime`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/builder.rs:218:17
|
218 | vtime: vtime,
| ^^^^^^^^^^^^ help: replace it with: `vtime`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/builder.rs:273:21
|
273 | time: time,
| ^^^^^^^^^^ help: replace it with: `time`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/builder.rs:305:21
|
305 | time: time,
| ^^^^^^^^^^ help: replace it with: `time`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/meta.rs:167:13
|
167 | command: command,
| ^^^^^^^^^^^^^^^^ help: replace it with: `command`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/meta.rs:169:13
|
169 | data: data
| ^^^^^^^^^^ help: replace it with: `data`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/meta.rs:353:13
|
353 | data: data,
| ^^^^^^^^^^ help: replace it with: `data`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/reader.rs:43:18
|
43 | Ok(SMF { format: format,
| ^^^^^^^^^^^^^^ help: replace it with: `format`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/reader.rs:45:18
|
45 | division: division } )
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `division`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/reader.rs:159:13
|
159 | copyright: copyright,
| ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `copyright`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/reader.rs:160:13
|
160 | name: name,
| ^^^^^^^^^^ help: replace it with: `name`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/writer.rs:38:13
|
38 | ticks: ticks,
| ^^^^^^^^^^^^ help: replace it with: `ticks`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: redundant field names in struct initialization
--> src/writer.rs:48:13
|
48 | ticks: ticks,
| ^^^^^^^^^^^^ help: replace it with: `ticks`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
warning: statics have by default a `'static` lifetime
--> src/util.rs:6:16
|
6 | static NSTRS: &'static str = "C C#D D#E F F#G G#A A#B ";
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
= note: `#[warn(clippy::redundant_static_lifetimes)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
--> src/lib.rs:215:48
|
215 | SMFError::Error(ref e) => e.description(),
| ^^^^^^^^^^^
warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
--> src/lib.rs:216:50
|
216 | SMFError::MidiError(ref m) => m.description(),
| ^^^^^^^^^^^
warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
--> src/lib.rs:217:50
|
217 | SMFError::MetaError(ref m) => m.description(),
| ^^^^^^^^^^^
warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
--> src/midi.rs:29:42
|
29 | MidiError::Error(ref e) => e.description(),
| ^^^^^^^^^^^
warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
--> src/meta.rs:30:42
|
30 | MetaError::Error(ref e) => e.description(),
| ^^^^^^^^^^^
warning: re-implementing `PartialEq::ne` is unnecessary
--> src/builder.rs:78:5
|
78 | / fn ne(&self, other: &AbsoluteEvent) -> bool {
79 | | !(self.eq(other))
80 | | }
| |_____^
|
= note: `#[warn(clippy::partialeq_ne_impl)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
warning: `if` chain can be rewritten with `match`
--> src/builder.rs:102:25
|
102 | / if me.data(0) < you.data(0) { Ordering::Less }
103 | | else if me.data(0) > you.data(0) { Ordering::Greater }
104 | | else {
105 | | if me.data(1) < you.data(1) {
... |
111 | | }
112 | | }
| |_________________________^
|
= note: `#[warn(clippy::comparison_chain)]` on by default
= help: Consider rewriting the `if` chain to use `cmp` and `match`.
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
warning: `if` chain can be rewritten with `match`
--> src/builder.rs:105:29
|
105 | / ... if me.data(1) < you.data(1) {
106 | | ... Ordering::Less
107 | | ... } else if me.data(1) > you.data(1) {
108 | | ... Ordering::Greater
109 | | ... } else {
110 | | ... res
111 | | ... }
| |_______________________^
|
= help: Consider rewriting the `if` chain to use `cmp` and `match`.
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
warning: you should consider adding a `Default` implementation for `builder::SMFBuilder`
--> src/builder.rs:190:5
|
190 | / pub fn new() -> SMFBuilder {
191 | | SMFBuilder {
192 | | tracks: Vec::new(),
193 | | }
194 | | }
| |_____^
|
= note: `#[warn(clippy::new_without_default)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try this
|
188 | impl Default for builder::SMFBuilder {
189 | fn default() -> Self {
190 | Self::new()
191 | }
192 | }
|
warning: length comparison to zero
--> src/midi.rs:334:17
|
334 | else if self.data.len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `self.data.is_empty()`
|
= note: `#[warn(clippy::len_zero)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
warning: useless use of `format!`
--> src/meta.rs:120:47
|
120 | MetaCommand::EndOfTrack => format!("End Of Track"),
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"End Of Track".to_string()`
|
= note: `#[warn(clippy::useless_format)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
warning: useless use of `format!`
--> src/meta.rs:122:48
|
122 | MetaCommand::SMPTEOffset => format!("SMPTEOffset"),
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"SMPTEOffset".to_string()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
warning: useless use of `format!`
--> src/meta.rs:135:59
|
135 | MetaCommand::SequencerSpecificEvent => format!("SequencerSpecificEvent"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"SequencerSpecificEvent".to_string()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> src/reader.rs:109:21
|
109 | / match e.event {
110 | | Event::Midi(ref m) => { last = m.data[0]; break; }
111 | | _ => ()
112 | | }
| |_____________________^ help: try this: `if let Event::Midi(ref m) = e.event { last = m.data[0]; break; }`
|
= note: `#[warn(clippy::single_match)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> src/reader.rs:119:21
|
119 | / match event.event {
120 | | Event::Meta(ref me) => {
121 | | match me.command {
122 | | MetaCommand::CopyrightNotice => copyright = Some(latin1_decode(&me.data)),
... |
127 | | _ => {}
128 | | }
| |_____________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try this
|
119 | if let Event::Meta(ref me) = event.event {
120 | match me.command {
121 | MetaCommand::CopyrightNotice => copyright = Some(latin1_decode(&me.data)),
122 | MetaCommand::SequenceOrTrackName => name = Some(latin1_decode(&me.data)),
123 | _ => {}
124 | }
...
warning: manual implementation of an assign operation
--> src/reader.rs:182:13
|
182 | res = res << 7;
| ^^^^^^^^^^^^^^ help: replace it with: `res <<= 7`
|
= note: `#[warn(clippy::assign_op_pattern)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> src/reader.rs:190:9
|
190 | / match smf {
191 | | Ok(ref mut s) => {
192 | | for _ in 0..s.tracks.capacity() {
193 | | s.tracks.push(try!(SMFReader::parse_track(reader)));
... |
196 | | _ => {}
197 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try this
|
190 | if let Ok(ref mut s) = smf {
191 | for _ in 0..s.tracks.capacity() {
192 | s.tracks.push(try!(SMFReader::parse_track(reader)));
193 | }
194 | }
|
warning: manual implementation of an assign operation
--> src/writer.rs:84:13
|
84 | cur = cur >> 7;
| ^^^^^^^^^^^^^^ help: replace it with: `cur >>= 7`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
warning: you don't need to add `&` to all patterns
--> src/writer.rs:117:9
|
117 | / match event {
118 | | &Event::Midi(ref midi) => {
119 | | vec.extend(midi.data.iter());
120 | | *length += midi.data.len() as u32;
... |
132 | | }
133 | | }
| |_________^
|
= note: `#[warn(clippy::match_ref_pats)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
117 | match *event {
118 | Event::Midi(ref midi) => {
119 | vec.extend(midi.data.iter());
120 | *length += midi.data.len() as u32;
121 | }
122 | Event::Meta(ref meta) => {
|
warning: manual implementation of an assign operation
--> src/writer.rs:150:13
|
150 | *length = (*length)>>8;
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `*length >>= 8`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> src/writer.rs:170:9
|
170 | / match name {
171 | | Some(n) => {
172 | | let namemeta = Event::Meta(MetaEvent::sequence_or_track_name(n));
173 | | length += SMFWriter::write_vtime(0,&mut vec).unwrap();
... |
176 | | None => {}
177 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try this
|
170 | if let Some(n) = name {
171 | let namemeta = Event::Meta(MetaEvent::sequence_or_track_name(n));
172 | length += SMFWriter::write_vtime(0,&mut vec).unwrap();
173 | self.write_event(&mut vec, &namemeta, &mut length, &mut saw_eot);
174 | }
|
warning: casting integer literal to `f32` is unnecessary
--> src/util.rs:10:28
|
10 | let oct = (num as f32 /12 as f32).floor()-1.0;
| ^^^^^^^^^ help: try: `12_f32`
|
= note: `#[warn(clippy::unnecessary_cast)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
warning: casting a character literal to `u8` truncates
--> src/util.rs:13:39
|
13 | if NSTRS.as_bytes()[nmt+1] == ' ' as u8{
| ^^^^^^^^^ help: use a byte literal instead: `b' '`
|
= note: `#[warn(clippy::char_lit_as_u8)]` on by default
= note: `char` is four bytes wide, but `u8` is a single byte
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8
error: read amount is not handled. Use `Read::read_exact` instead
--> src/util.rs:24:5
|
24 | try!(reader.read(&mut b));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[deny(clippy::unused_io_amount)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
warning: useless use of `format!`
--> src/util.rs:77:23
|
77 | Err(_) => format!("[invalid string data]"),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"[invalid string data]".to_string()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
warning: item `Event` has a public `len` method but no corresponding `is_empty` method
--> src/lib.rs:108:1
|
108 | / impl Event {
109 | | /// Return the number of bytes this event uses.
110 | | pub fn len(&self) -> usize {
111 | | match *self {
... |
119 | | }
120 | | }
| |_^
|
= note: `#[warn(clippy::len_without_is_empty)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
warning: item `TrackEvent` has a public `len` method but no corresponding `is_empty` method
--> src/lib.rs:139:1
|
139 | / impl TrackEvent {
140 | | pub fn fmt_with_time_offset(&self, cur_time: u64) -> String {
141 | | format!("time: {}\t{}",(self.vtime+cur_time),self.event)
142 | | }
... |
149 | | }
150 | | }
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
warning: length comparison to zero
--> src/lib.rs:305:24
|
305 | if events.len() > 0 {
| ^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!events.is_empty()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
error: aborting due to previous error; 76 warnings emitted
error: could not compile `rimd`.
To learn more, run the command again with --verbose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment