Clippy run

This commit is contained in:
Paul Lietar 2017-01-29 16:25:09 +00:00
parent 17482c236a
commit bbc438d9b2
12 changed files with 40 additions and 30 deletions

View file

@ -92,7 +92,7 @@ impl <'a> Sink for PortAudioSink<'a> {
Ok(())
}
fn write(&mut self, data: &[i16]) -> io::Result<()> {
match self.0.as_mut().unwrap().write(&data) {
match self.0.as_mut().unwrap().write(data) {
Ok(_) => (),
Err(portaudio::PaError::OutputUnderflowed) =>
error!("PortAudio write underflow"),

View file

@ -42,7 +42,7 @@ impl AudioKeyManager {
}
}
pub fn request<'a>(&self, track: SpotifyId, file: FileId) -> AudioKeyFuture<AudioKey> {
pub fn request(&self, track: SpotifyId, file: FileId) -> AudioKeyFuture<AudioKey> {
let (tx, rx) = oneshot::channel();
let seq = self.lock(move |inner| {
@ -55,7 +55,7 @@ impl AudioKeyManager {
AudioKeyFuture(rx)
}
fn send_key_request<'a>(&self, seq: u32, track: SpotifyId, file: FileId) {
fn send_key_request(&self, seq: u32, track: SpotifyId, file: FileId) {
let mut data: Vec<u8> = Vec::new();
data.write(&file.0).unwrap();
data.write(&track.to_raw()).unwrap();

View file

@ -35,6 +35,7 @@ pub struct Lazy<T>(Mutex<bool>, UnsafeCell<Option<T>>);
unsafe impl <T: Sync> Sync for Lazy<T> {}
unsafe impl <T: Send> Send for Lazy<T> {}
#[cfg_attr(feature = "cargo-clippy", allow(mutex_atomic))]
impl <T> Lazy<T> {
pub fn new() -> Lazy<T> {
Lazy(Mutex::new(false), UnsafeCell::new(None))

View file

@ -3,6 +3,8 @@
#![cfg_attr(not(feature = "with-syntex"), feature(plugin, custom_derive))]
#![cfg_attr(not(feature = "with-syntex"), plugin(protobuf_macros))]
#![cfg_attr(feature = "cargo-clippy", allow(unused_io_amount))]
#[macro_use] extern crate error_chain;
#[macro_use] extern crate futures;
#[macro_use] extern crate lazy_static;

View file

@ -25,7 +25,7 @@ use librespot::version;
fn usage(program: &str, opts: &getopts::Options) -> String {
let brief = format!("Usage: {} [options]", program);
format!("{}", opts.usage(&brief))
opts.usage(&brief)
}
fn setup_logging(verbose: bool) {

View file

@ -72,7 +72,7 @@ impl MercuryRequest {
for p in &self.payload {
packet.write_u16::<BigEndian>(p.len() as u16).unwrap();
packet.write(&p).unwrap();
packet.write(p).unwrap();
}
packet

View file

@ -80,7 +80,7 @@ impl MetadataTrait for Track {
.filter(|file| file.has_file_id())
.map(|file| {
let mut dst = [0u8; 20];
dst.clone_from_slice(&file.get_file_id());
dst.clone_from_slice(file.get_file_id());
(file.get_format(), FileId(dst))
})
.collect();
@ -129,7 +129,7 @@ impl MetadataTrait for Album {
.filter(|image| image.has_file_id())
.map(|image| {
let mut dst = [0u8; 20];
dst.clone_from_slice(&image.get_file_id());
dst.clone_from_slice(image.get_file_id());
FileId(dst)
})
.collect::<Vec<_>>();
@ -157,9 +157,7 @@ impl MetadataTrait for Artist {
let top_tracks = msg.get_top_track()
.iter()
.filter(|tt| !tt.has_country() ||
countrylist_contains(tt.get_country(), &country))
.next()
.find(|tt| !tt.has_country() || countrylist_contains(tt.get_country(), &country))
.unwrap()
.get_track()
.iter()

View file

@ -197,7 +197,7 @@ impl PlayerInternal {
match packet {
Some(Ok(mut packet)) => {
if self.volume < 0xFFFF {
for x in packet.data.iter_mut() {
for x in &mut packet.data {
*x = (*x as i32 * self.volume as i32 / 0xFFFF) as i16;
}
}
@ -314,17 +314,15 @@ impl PlayerInternal {
}
fn run_onstart(&self) {
match self.session.config().onstart {
Some(ref program) => util::run_program(program),
None => {},
};
if let Some(ref program) = self.session.config().onstart {
util::run_program(program)
}
}
fn run_onstop(&self) {
match self.session.config().onstop {
Some(ref program) => util::run_program(program),
None => {},
};
if let Some(ref program) = self.session.config().onstop {
util::run_program(program)
}
}
fn find_available_alternative<'a>(&self, track: &'a Track) -> Option<Cow<'a, Track>> {

View file

@ -77,7 +77,7 @@ pub struct SessionWeak(pub Weak<SessionInternal>);
pub fn device_id(name: &str) -> String {
let mut h = Sha1::new();
h.input_str(&name);
h.input_str(name);
h.result_str()
}
@ -192,6 +192,7 @@ impl Session {
self.0.handle.spawn(f)
}
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
fn dispatch(&self, cmd: u8, data: Vec<u8>) {
match cmd {
0x4 => self.send_packet(0x49, data),

View file

@ -159,8 +159,8 @@ impl Spirc {
(spirc, task)
}
pub fn shutdown(&mut self) {
mpsc::UnboundedSender::send(&mut self.commands, SpircCommand::Shutdown).unwrap();
pub fn shutdown(&self) {
mpsc::UnboundedSender::send(&self.commands, SpircCommand::Shutdown).unwrap();
}
}
@ -312,7 +312,12 @@ impl SpircTask {
// Over 3s it seeks to zero
if self.position() < 3000 {
let current_index = self.state.get_playing_track_index();
let new_index = (current_index - 1) % (self.state.get_track().len() as u32);
let new_index = if current_index == 0 {
self.state.get_track().len() as u32 - 1
} else {
current_index - 1
};
self.state.set_playing_track_index(new_index);
self.state.set_position_ms(0);
@ -379,12 +384,12 @@ impl SpircTask {
self.state.get_position_ms() + diff as u32
}
fn update_tracks(&mut self, ref frame: &protocol::spirc::Frame) {
fn update_tracks(&mut self, frame: &protocol::spirc::Frame) {
let index = frame.get_state().get_playing_track_index();
let tracks = frame.get_state().get_track();
self.state.set_playing_track_index(index);
self.state.set_track(tracks.into_iter().map(Clone::clone).collect());
self.state.set_track(tracks.into_iter().cloned().collect());
}
fn load_track(&mut self, play: bool) {
@ -398,7 +403,12 @@ impl SpircTask {
let end_of_track = self.player.load(track, play, position);
if play {
self.state.set_status(PlayStatus::kPlayStatusPlay);
} else {
self.state.set_status(PlayStatus::kPlayStatusPause);
}
self.end_of_track = end_of_track.boxed();
}

View file

@ -86,10 +86,10 @@ impl std::ops::Mul<u128> for u128 {
2 => (product, 0),
3 => (product << 32, 0),
_ => {
if product != 0 {
panic!("Overflow on mul {:?} {:?} ({} {})", self, rhs, i, j)
} else {
if product == 0 {
(0, 0)
} else {
panic!("Overflow on mul {:?} {:?} ({} {})", self, rhs, i, j)
}
}
};

View file

@ -42,7 +42,7 @@ pub fn mkdir_existing(path: &Path) -> io::Result<()> {
})
}
pub fn run_program(program: &String) {
pub fn run_program(program: &str) {
info!("Running {}", program);
let mut v: Vec<&str> = program.split_whitespace().collect();
let status = Command::new(&v.remove(0))