From bed115d6e1a634d79e175e543a7936cd03200ebc Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Sun, 3 May 2020 17:56:45 +0200 Subject: add support of cfg attributes on enum variants #4279 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_ty/src/tests.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 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 588d81282..d60732e19 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -360,6 +360,33 @@ fn no_such_field_with_feature_flag_diagnostics() { assert_snapshot!(diagnostics, @r###""###); } +#[test] +fn no_such_field_enum_with_feature_flag_diagnostics() { + let diagnostics = TestDB::with_files( + r#" + //- /lib.rs crate:foo cfg:feature=foo + enum Foo { + #[cfg(not(feature = "foo"))] + Buz, + #[cfg(feature = "foo")] + Bar, + Baz + } + + fn test_fn(f: Foo) { + match f { + Foo::Bar => {}, + Foo::Baz => {}, + } + } + "#, + ) + .diagnostics() + .0; + + assert_snapshot!(diagnostics, @r###""###); +} + #[test] fn no_such_field_with_feature_flag_diagnostics_on_struct_lit() { let diagnostics = TestDB::with_files( -- cgit v1.2.3