rust-clippy/tests/compile-fail/methods.rs
Georg Brandl 7aee04878f tests: use fragment of lint text for error checking
(Did not touch strings.rs, which is fixed by @llogiq's PR)
2015-08-13 08:12:07 +02:00

15 lines
483 B
Rust
Executable file

#![feature(plugin)]
#![plugin(clippy)]
#[deny(option_unwrap_used, result_unwrap_used)]
#[deny(str_to_string, string_to_string)]
fn main() {
let opt = Some(0);
let _ = opt.unwrap(); //~ERROR used unwrap() on an Option
let res: Result<i32, ()> = Ok(0);
let _ = res.unwrap(); //~ERROR used unwrap() on a Result
let string = "str".to_string(); //~ERROR `str.to_owned()` is faster
let _again = string.to_string(); //~ERROR `String.to_string()` is a no-op
}