aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-04-08 17:12:15 +0100
committerBenjamin Coenen <[email protected]>2020-04-08 17:12:15 +0100
commit8f1dba6f9ae1d8d314dd9d007e4c582ed1403e8d (patch)
treee6d269d0a10de37aff7c5f2c2849eab9a9108b02 /crates/ra_hir_ty
parent18a5e164838e1dc2abcc6b79d4fc2f96ffd2507c (diff)
feat: add attributes support on struct fields and method #3870
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r--crates/ra_hir_ty/src/expr.rs9
-rw-r--r--crates/ra_hir_ty/src/tests.rs9
2 files changed, 6 insertions, 12 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs
index 6547eedae..fb779cbef 100644
--- a/crates/ra_hir_ty/src/expr.rs
+++ b/crates/ra_hir_ty/src/expr.rs
@@ -166,14 +166,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
166 166
167 let variant_data = variant_data(db.upcast(), variant_def); 167 let variant_data = variant_data(db.upcast(), variant_def);
168 168
169 let lit_fields: FxHashSet<_> = fields 169 let lit_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect();
170 .iter()
171 .filter_map(|f| {
172 // TODO: check if cfg_is_enabled with .attrs ?
173
174 Some(&f.name)
175 })
176 .collect();
177 let missed_fields: Vec<Name> = variant_data 170 let missed_fields: Vec<Name> = variant_data
178 .fields() 171 .fields()
179 .iter() 172 .iter()
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() {
324fn no_such_field_with_feature_flag_diagnostics() { 324fn no_such_field_with_feature_flag_diagnostics() {
325 let diagnostics = TestDB::with_files( 325 let diagnostics = TestDB::with_files(
326 r#" 326 r#"
327 //- /lib.rs 327 //- /lib.rs crate:foo cfg:feature=foo
328 struct MyStruct { 328 struct MyStruct {
329 my_val: usize, 329 my_val: usize,
330 #[cfg(feature = "foo")] 330 #[cfg(feature = "foo")]
@@ -336,7 +336,7 @@ fn no_such_field_with_feature_flag_diagnostics() {
336 pub(crate) fn new(my_val: usize, bar: bool) -> Self { 336 pub(crate) fn new(my_val: usize, bar: bool) -> Self {
337 Self { my_val, bar } 337 Self { my_val, bar }
338 } 338 }
339 339
340 #[cfg(not(feature = "foo"))] 340 #[cfg(not(feature = "foo"))]
341 pub(crate) fn new(my_val: usize, _bar: bool) -> Self { 341 pub(crate) fn new(my_val: usize, _bar: bool) -> Self {
342 Self { my_val } 342 Self { my_val }
@@ -344,7 +344,8 @@ fn no_such_field_with_feature_flag_diagnostics() {
344 } 344 }
345 "#, 345 "#,
346 ) 346 )
347 .diagnostics(); 347 .diagnostics()
348 .0;
348 349
349 assert_snapshot!(diagnostics, ""); 350 assert_snapshot!(diagnostics, @r###""###);
350} 351}