mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Test match guards, reference patterns
This commit is contained in:
parent
4cce7a6407
commit
977ba46bb1
@ -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 {
|
mod false_negatives {
|
||||||
//! The implementation of match checking here is a work in progress. As we roll this out, we
|
//! 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
|
//! prefer false negatives to false positives (ideally there would be no false positives). This
|
||||||
@ -1153,5 +1172,37 @@ fn main() {
|
|||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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…
Reference in New Issue
Block a user