Skip to content

Commit 1374bc8

Browse files
committed
test: ensure no_such_field diagnostic don't work for field with disabled cfg
1 parent 4505f03 commit 1374bc8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

crates/ide-diagnostics/src/handlers/no_such_field.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,36 @@ fn missing_record_expr_field_fixes(
128128
mod tests {
129129
use crate::tests::{check_diagnostics, check_fix, check_no_fix};
130130

131+
#[test]
132+
fn dont_work_for_field_with_disabled_cfg() {
133+
check_diagnostics(
134+
r#"
135+
struct Test {
136+
#[cfg(feature = "hello")]
137+
test: u32,
138+
other: u32
139+
}
140+
141+
fn main() {
142+
let a = Test {
143+
#[cfg(feature = "hello")]
144+
test: 1,
145+
other: 1
146+
};
147+
148+
let Test {
149+
#[cfg(feature = "hello")]
150+
test,
151+
mut other,
152+
..
153+
} = a;
154+
155+
other += 1;
156+
}
157+
"#,
158+
);
159+
}
160+
131161
#[test]
132162
fn no_such_field_diagnostics() {
133163
check_diagnostics(

0 commit comments

Comments
 (0)