diff options
Diffstat (limited to 'crates/hir_def/src/nameres/tests')
-rw-r--r-- | crates/hir_def/src/nameres/tests/diagnostics.rs | 18 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/tests/macros.rs | 8 |
2 files changed, 22 insertions, 4 deletions
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index 1a7b98831..58d69d3c6 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | use base_db::fixture::WithFixture; | 1 | use base_db::fixture::WithFixture; |
2 | use test_utils::mark; | ||
2 | 3 | ||
3 | use crate::test_db::TestDB; | 4 | use crate::test_db::TestDB; |
4 | 5 | ||
@@ -119,3 +120,20 @@ fn inactive_item() { | |||
119 | "#, | 120 | "#, |
120 | ); | 121 | ); |
121 | } | 122 | } |
123 | |||
124 | /// Tests that `cfg` attributes behind `cfg_attr` is handled properly. | ||
125 | #[test] | ||
126 | fn inactive_via_cfg_attr() { | ||
127 | mark::check!(cfg_attr_active); | ||
128 | check_diagnostics( | ||
129 | r#" | ||
130 | //- /lib.rs | ||
131 | #[cfg_attr(not(never), cfg(no))] fn f() {} | ||
132 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled | ||
133 | |||
134 | #[cfg_attr(not(never), cfg(not(no)))] fn f() {} | ||
135 | |||
136 | #[cfg_attr(never, cfg(no))] fn g() {} | ||
137 | "#, | ||
138 | ); | ||
139 | } | ||
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index 6fe2ee78a..f9bf5bc72 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs | |||
@@ -632,11 +632,11 @@ pub struct bar; | |||
632 | #[test] | 632 | #[test] |
633 | fn expand_derive() { | 633 | fn expand_derive() { |
634 | let map = compute_crate_def_map( | 634 | let map = compute_crate_def_map( |
635 | " | 635 | r#" |
636 | //- /main.rs crate:main deps:core | 636 | //- /main.rs crate:main deps:core |
637 | use core::*; | 637 | use core::Copy; |
638 | 638 | ||
639 | #[derive(Copy, Clone)] | 639 | #[derive(Copy, core::Clone)] |
640 | struct Foo; | 640 | struct Foo; |
641 | 641 | ||
642 | //- /core.rs crate:core | 642 | //- /core.rs crate:core |
@@ -645,7 +645,7 @@ fn expand_derive() { | |||
645 | 645 | ||
646 | #[rustc_builtin_macro] | 646 | #[rustc_builtin_macro] |
647 | pub macro Clone {} | 647 | pub macro Clone {} |
648 | ", | 648 | "#, |
649 | ); | 649 | ); |
650 | assert_eq!(map.modules[map.root].scope.impls().len(), 2); | 650 | assert_eq!(map.modules[map.root].scope.impls().len(), 2); |
651 | } | 651 | } |