From b87b335e6859ead3baa7fde20e3ea2ac69f63d85 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Sat, 25 Apr 2020 15:48:04 +0200 Subject: add support for cfg feature attributes on expression #4063 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_ty/src/tests.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index b6a96bb5c..588d81282 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -390,6 +390,38 @@ fn no_such_field_with_feature_flag_diagnostics_on_struct_lit() { assert_snapshot!(diagnostics, @r###""###); } +#[test] +fn no_such_field_with_feature_flag_diagnostics_on_block_expr() { + let diagnostics = TestDB::with_files( + r#" + //- /lib.rs crate:foo cfg:feature=foo + struct S { + #[cfg(feature = "foo")] + foo: u32, + #[cfg(not(feature = "foo"))] + bar: u32, + } + + impl S { + fn new(bar: u32) -> Self { + #[cfg(feature = "foo")] + { + Self { foo: bar } + } + #[cfg(not(feature = "foo"))] + { + Self { bar } + } + } + } + "#, + ) + .diagnostics() + .0; + + assert_snapshot!(diagnostics, @r###""###); +} + #[test] fn no_such_field_with_feature_flag_diagnostics_on_struct_fields() { let diagnostics = TestDB::with_files( -- cgit v1.2.3