add support of cfg attributes on enum variants #4279

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2020-05-03 17:56:45 +02:00
parent 682c079043
commit bed115d6e1
2 changed files with 34 additions and 1 deletions

View file

@ -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(