rust-clippy/tests/ui/unused_io_amount.rs

35 lines
638 B
Rust
Raw Normal View History

2017-01-07 11:35:45 +00:00
#![feature(plugin)]
#![plugin(clippy)]
#![allow(dead_code)]
use std::io;
// FIXME: compiletest doesn't understand errors from macro invocation span
2017-01-07 11:35:45 +00:00
fn try_macro<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
try!(s.write(b"test"));
let mut buf = [0u8; 4];
try!(s.read(&mut buf));
Ok(())
}
fn question_mark<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
s.write(b"test")?;
2017-02-08 13:58:07 +00:00
2017-01-07 11:35:45 +00:00
let mut buf = [0u8; 4];
s.read(&mut buf)?;
2017-02-08 13:58:07 +00:00
2017-01-07 11:35:45 +00:00
Ok(())
}
fn unwrap<T: io::Read + io::Write>(s: &mut T) {
s.write(b"test").unwrap();
2017-02-08 13:58:07 +00:00
2017-01-07 11:35:45 +00:00
let mut buf = [0u8; 4];
s.read(&mut buf).unwrap();
2017-02-08 13:58:07 +00:00
2017-01-07 11:35:45 +00:00
}
fn main() {
}