mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 13:23:25 +00:00
Fix false positive type mismatch in const reference patterns
This commit is contained in:
parent
96f660813c
commit
4f722165b6
3 changed files with 96 additions and 45 deletions
|
|
@ -1153,3 +1153,41 @@ fn main() {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_mismatch_pat_const_reference() {
|
||||
check_no_mismatches(
|
||||
r#"
|
||||
const TEST_STR: &'static str = "abcd";
|
||||
|
||||
fn main() {
|
||||
let s = "abcd";
|
||||
match s {
|
||||
TEST_STR => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
"#,
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
struct Foo<T>(T);
|
||||
|
||||
impl<T> Foo<T> {
|
||||
const TEST_I32_REF: &'static i32 = &3;
|
||||
const TEST_I32: i32 = 3;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match &6 {
|
||||
Foo::<i32>::TEST_I32_REF => (),
|
||||
Foo::<i32>::TEST_I32 => (),
|
||||
//^^^^^^^^^^^^^^^^^^^^ expected &i32, got i32
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue