aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/expr.rs3
-rw-r--r--crates/ra_hir_ty/src/tests.rs30
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
5use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId}; 5use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId};
6use hir_expand::diagnostics::DiagnosticSink; 6use hir_expand::diagnostics::DiagnosticSink;
7use ra_syntax::ast; 7use ra_syntax::{ast, AstPtr};
8use ra_syntax::AstPtr;
9use rustc_hash::FxHashSet; 8use rustc_hash::FxHashSet;
10 9
11use crate::{ 10use 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]
324fn 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}