From ab864ed259c10ff51f7c9c3421d098eeea7b0245 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:58:05 +0200 Subject: feat: add attributes support on struct fields #3870 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_ty/src/tests.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'crates/ra_hir_ty/src/tests.rs') diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 027e5a8f8..c3d793cc2 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -318,3 +318,32 @@ fn no_such_field_diagnostics() { "### ); } + +#[test] +fn no_such_field_with_feature_flag_diagnostics() { + let diagnostics = TestDB::with_files( + r#" + //- /lib.rs + struct MyStruct { + my_val: usize, + #[cfg(feature = "foo")] + bar: bool, + } + + impl MyStruct { + #[cfg(feature = "foo")] + pub(crate) fn new(my_val: usize, bar: bool) -> Self { + Self { my_val, bar } + } + + #[cfg(not(feature = "foo"))] + pub(crate) fn new(my_val: usize, _bar: bool) -> Self { + Self { my_val } + } + } + "#, + ) + .diagnostics(); + + assert_snapshot!(diagnostics, ""); +} -- cgit v1.2.3 From 8f1dba6f9ae1d8d314dd9d007e4c582ed1403e8d Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Wed, 8 Apr 2020 18:12:15 +0200 Subject: feat: add attributes support on struct fields and method #3870 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_ty/src/tests.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_ty/src/tests.rs') diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index e6ac0aec3..060814e53 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -324,7 +324,7 @@ fn no_such_field_diagnostics() { fn no_such_field_with_feature_flag_diagnostics() { let diagnostics = TestDB::with_files( r#" - //- /lib.rs + //- /lib.rs crate:foo cfg:feature=foo struct MyStruct { my_val: usize, #[cfg(feature = "foo")] @@ -336,7 +336,7 @@ fn no_such_field_with_feature_flag_diagnostics() { pub(crate) fn new(my_val: usize, bar: bool) -> Self { Self { my_val, bar } } - + #[cfg(not(feature = "foo"))] pub(crate) fn new(my_val: usize, _bar: bool) -> Self { Self { my_val } @@ -344,7 +344,8 @@ fn no_such_field_with_feature_flag_diagnostics() { } "#, ) - .diagnostics(); + .diagnostics() + .0; - assert_snapshot!(diagnostics, ""); + assert_snapshot!(diagnostics, @r###""###); } -- cgit v1.2.3