Skip to content

Commit a982242

Browse files
committed
experimental: add feature flags to mvces
1 parent 36a7f16 commit a982242

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ice.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ impl ICE {
174174
write!(mvce_file, "{}", mvce_string)
175175
.expect(&format!("failed to write mvce '{mvce_display}'"));
176176

177+
// add feature flags into the mvce
178+
179+
// filter and convert ""-Zcrate-attr=feature(x)" to "#![feature(x)]"
180+
let feature_flags = &ice
181+
.args
182+
.clone()
183+
.iter()
184+
.filter(|flag| flag.starts_with("-Zcrate-attr=feature("))
185+
.map(|flag| flag.replace("-Zcrate-attr=", ""))
186+
.map(|feature| format!("#![{feature}]\n"))
187+
.collect::<String>();
188+
dbg!(feature_flags);
189+
177190
let flags = ice
178191
.args
179192
.clone()
@@ -216,6 +229,7 @@ impl ICE {
216229
"snippet:
217230
````rust
218231
{original_code}
232+
{feature_flags}
219233
````"
220234
)
221235
// if we have a very long original snippet. collapse it
@@ -224,6 +238,7 @@ impl ICE {
224238
"auto-reduced (treereduce-rust):
225239
````rust
226240
{mvce_string}
241+
{feature_flags}
227242
````
228243
229244
<details><summary><strong>original code</strong></summary>
@@ -241,6 +256,7 @@ original:
241256
"auto-reduced (treereduce-rust):
242257
````rust
243258
{mvce_string}
259+
{feature_flags}
244260
````
245261
246262
original:

0 commit comments

Comments
 (0)