diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/expr.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 30 |
2 files changed, 31 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index b4592fbf5..e45e9ea14 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs | |||
@@ -4,8 +4,7 @@ use std::sync::Arc; | |||
4 | 4 | ||
5 | use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId}; | 5 | use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId}; |
6 | use hir_expand::diagnostics::DiagnosticSink; | 6 | use hir_expand::diagnostics::DiagnosticSink; |
7 | use ra_syntax::ast; | 7 | use ra_syntax::{ast, AstPtr}; |
8 | use ra_syntax::AstPtr; | ||
9 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
10 | 9 | ||
11 | use crate::{ | 10 | use crate::{ |
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index e4a103d1b..608408d88 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -319,3 +319,33 @@ fn no_such_field_diagnostics() { | |||
319 | "### | 319 | "### |
320 | ); | 320 | ); |
321 | } | 321 | } |
322 | |||
323 | #[test] | ||
324 | fn no_such_field_with_feature_flag_diagnostics() { | ||
325 | let diagnostics = TestDB::with_files( | ||
326 | r#" | ||
327 | //- /lib.rs crate:foo cfg:feature=foo | ||
328 | struct MyStruct { | ||
329 | my_val: usize, | ||
330 | #[cfg(feature = "foo")] | ||
331 | bar: bool, | ||
332 | } | ||
333 | |||
334 | impl MyStruct { | ||
335 | #[cfg(feature = "foo")] | ||
336 | pub(crate) fn new(my_val: usize, bar: bool) -> Self { | ||
337 | Self { my_val, bar } | ||
338 | } | ||
339 | |||
340 | #[cfg(not(feature = "foo"))] | ||
341 | pub(crate) fn new(my_val: usize, _bar: bool) -> Self { | ||
342 | Self { my_val } | ||
343 | } | ||
344 | } | ||
345 | "#, | ||
346 | ) | ||
347 | .diagnostics() | ||
348 | .0; | ||
349 | |||
350 | assert_snapshot!(diagnostics, @r###""###); | ||
351 | } | ||