Skip to content

Commit

Permalink
test: ensure no_such_field diagnostic don't work for field with dis…
Browse files Browse the repository at this point in the history
…abled cfg
  • Loading branch information
Young-Flash committed Jan 25, 2024
1 parent 4505f03 commit 1374bc8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions crates/ide-diagnostics/src/handlers/no_such_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,36 @@ fn missing_record_expr_field_fixes(
mod tests {
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]
fn no_such_field_diagnostics() {
check_diagnostics(
Expand Down

0 comments on commit 1374bc8

Please sign in to comment.