Skip to content

Commit 11c926f

Browse files
committed
Add a test for conditionally compiled tails
1 parent ebbcf9f commit 11c926f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

crates/hir_ty/src/tests/regression.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,3 +1050,52 @@ fn test() {
10501050
"#]],
10511051
);
10521052
}
1053+
1054+
#[test]
1055+
fn cfg_tail() {
1056+
// https://github.com/rust-analyzer/rust-analyzer/issues/8378
1057+
check_infer(
1058+
r#"
1059+
fn fake_tail(){
1060+
{ "first" }
1061+
#[cfg(never)] 9
1062+
}
1063+
fn multiple_fake(){
1064+
{ "fake" }
1065+
{ "fake" }
1066+
{ "second" }
1067+
#[cfg(never)] { 11 }
1068+
#[cfg(never)] 12;
1069+
#[cfg(never)] 13
1070+
}
1071+
fn no_normal_tail(){
1072+
{ "third" }
1073+
#[cfg(never)] 14;
1074+
#[cfg(never)] 15;
1075+
}
1076+
fn no_actual_tail(){
1077+
{ "fourth" };
1078+
#[cfg(never)] 14;
1079+
#[cfg(never)] 15
1080+
}
1081+
"#,
1082+
expect![[r#"
1083+
14..53 '{ ...)] 9 }': &str
1084+
20..31 '{ "first" }': &str
1085+
22..29 '"first"': &str
1086+
72..190 '{ ...] 13 }': &str
1087+
78..88 '{ "fake" }': &str
1088+
80..86 '"fake"': &str
1089+
93..103 '{ "fake" }': &str
1090+
95..101 '"fake"': &str
1091+
108..120 '{ "second" }': &str
1092+
110..118 '"second"': &str
1093+
210..273 '{ ... 15; }': &str
1094+
216..227 '{ "third" }': &str
1095+
218..225 '"third"': &str
1096+
293..357 '{ ...] 15 }': ()
1097+
299..311 '{ "fourth" }': &str
1098+
301..309 '"fourth"': &str
1099+
"#]],
1100+
)
1101+
}

0 commit comments

Comments
 (0)