Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/macros.rs')
| -rw-r--r-- | crates/hir-ty/src/tests/macros.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/macros.rs b/crates/hir-ty/src/tests/macros.rs index 81268f37fd..a4299d9f05 100644 --- a/crates/hir-ty/src/tests/macros.rs +++ b/crates/hir-ty/src/tests/macros.rs @@ -1,6 +1,8 @@ use expect_test::expect; use test_utils::{bench, bench_fixture, skip_slow_tests}; +use crate::tests::check_infer_with_mismatches; + use super::{check_infer, check_types}; #[test] @@ -1247,3 +1249,28 @@ fn infinitely_recursive_macro_type() { "#]], ); } + +#[test] +fn cfg_tails() { + check_infer_with_mismatches( + r#" +//- /lib.rs crate:foo cfg:feature=foo +struct S {} + +impl S { + fn new2(bar: u32) -> Self { + #[cfg(feature = "foo")] + { Self { } } + #[cfg(not(feature = "foo"))] + { Self { } } + } +} +"#, + expect![[r#" + 34..37 'bar': u32 + 52..170 '{ ... }': S + 62..106 '#[cfg(... { } }': S + 96..104 'Self { }': S + "#]], + ); +} |