aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r--crates/ra_hir_ty/src/tests.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 608408d88..02f2e5de0 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -349,3 +349,63 @@ fn no_such_field_with_feature_flag_diagnostics() {
349 349
350 assert_snapshot!(diagnostics, @r###""###); 350 assert_snapshot!(diagnostics, @r###""###);
351} 351}
352
353#[test]
354fn no_such_field_with_feature_flag_diagnostics_on_struct_lit() {
355 let diagnostics = TestDB::with_files(
356 r#"
357 //- /lib.rs crate:foo cfg:feature=foo
358 struct S {
359 #[cfg(feature = "foo")]
360 foo: u32,
361 #[cfg(not(feature = "foo"))]
362 bar: u32,
363 }
364
365 impl S {
366 #[cfg(feature = "foo")]
367 fn new(foo: u32) -> Self {
368 Self { foo }
369 }
370 #[cfg(not(feature = "foo"))]
371 fn new(bar: u32) -> Self {
372 Self { bar }
373 }
374 }
375 "#,
376 )
377 .diagnostics()
378 .0;
379
380 assert_snapshot!(diagnostics, @r###""###);
381}
382
383#[test]
384fn no_such_field_with_feature_flag_diagnostics_on_struct_fields() {
385 let diagnostics = TestDB::with_files(
386 r#"
387 //- /lib.rs crate:foo cfg:feature=foo
388 struct S {
389 #[cfg(feature = "foo")]
390 foo: u32,
391 #[cfg(not(feature = "foo"))]
392 bar: u32,
393 }
394
395 impl S {
396 fn new(val: u32) -> Self {
397 Self {
398 #[cfg(feature = "foo")]
399 foo: val,
400 #[cfg(not(feature = "foo"))]
401 bar: val,
402 }
403 }
404 }
405 "#,
406 )
407 .diagnostics()
408 .0;
409
410 assert_snapshot!(diagnostics, @r###""###);
411}