mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
test: ensure no_such_field
diagnostic don't work for field with disabled cfg
This commit is contained in:
parent
4505f03fbf
commit
1374bc8c93
1 changed files with 30 additions and 0 deletions
|
@ -128,6 +128,36 @@ fn missing_record_expr_field_fixes(
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::{check_diagnostics, check_fix, check_no_fix};
|
use crate::tests::{check_diagnostics, check_fix, check_no_fix};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dont_work_for_field_with_disabled_cfg() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
struct Test {
|
||||||
|
#[cfg(feature = "hello")]
|
||||||
|
test: u32,
|
||||||
|
other: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let a = Test {
|
||||||
|
#[cfg(feature = "hello")]
|
||||||
|
test: 1,
|
||||||
|
other: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
let Test {
|
||||||
|
#[cfg(feature = "hello")]
|
||||||
|
test,
|
||||||
|
mut other,
|
||||||
|
..
|
||||||
|
} = a;
|
||||||
|
|
||||||
|
other += 1;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_such_field_diagnostics() {
|
fn no_such_field_diagnostics() {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
|
|
Loading…
Reference in a new issue