mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Test match guards, reference patterns
This commit is contained in:
parent
4cce7a6407
commit
977ba46bb1
1 changed files with 51 additions and 0 deletions
|
@ -1126,6 +1126,25 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_guard() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
fn main() {
|
||||
match true {
|
||||
true if false => {}
|
||||
true => {}
|
||||
false => {}
|
||||
}
|
||||
match true {
|
||||
//^^^^ Missing match arm
|
||||
true if false => {}
|
||||
false => {}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
mod false_negatives {
|
||||
//! The implementation of match checking here is a work in progress. As we roll this out, we
|
||||
//! prefer false negatives to false positives (ideally there would be no false positives). This
|
||||
|
@ -1149,6 +1168,38 @@ fn main() {
|
|||
// ^^ Internal: match check bailed out
|
||||
11..20 => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reference_patterns_at_top_level() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
fn main() {
|
||||
match &false {
|
||||
&true => {}
|
||||
// ^^^^^ Internal: match check bailed out
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reference_patterns_in_fields() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
fn main() {
|
||||
match (&false,) {
|
||||
(true,) => {}
|
||||
// ^^^^^^^ Internal: match check bailed out
|
||||
}
|
||||
match (&false,) {
|
||||
(&true,) => {}
|
||||
// ^^^^^^^^ Internal: match check bailed out
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue