rust/tests/compile-fail/match_if_let.rs
Georg Brandl cab9905705 better help text for "match -> if let" lint
Implements the suggestion from #87.

Changes span_help_and_lint(), which is only used for this lint,
to use fileline_help() instead of span_help() to avoid printing
the span twice.

Also adds complete suggested new code. I had to distinguish
between blocks, which need no additionals braces, and other exprs.
2015-08-11 19:26:51 +02:00

27 lines
545 B
Rust
Executable File

#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
fn main(){
let x = Some(1u8);
match x { //~ ERROR You seem to be trying to use match
//~^ HELP Try
Some(y) => {
println!("{:?}", y);
}
_ => ()
}
// Not linted
match x {
Some(y) => println!("{:?}", y),
None => ()
}
let z = (1u8,1u8);
match z { //~ ERROR You seem to be trying to use match
//~^ HELP Try
(2...3, 7...9) => println!("{:?}", z),
_ => {}
}
}