Skip to content

Commit edca2ac

Browse files
Avoid blessing duplicated Expects
1 parent 670586d commit edca2ac

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/test/mod.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
251251
db.program_ir().unwrap()
252252
};
253253

254-
for (goal_text, solver_choice, expected) in goals {
254+
let mut last_expected_pos = None;
255+
256+
for (goal_text, solver_choice, mut expected) in goals {
255257
match (&solver_choice, &expected) {
256258
(SolverChoice::Recursive { .. }, TestGoal::All(_))
257259
| (SolverChoice::Recursive { .. }, TestGoal::First(_)) => {
@@ -264,6 +266,15 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
264266
db.set_solver_choice(solver_choice);
265267
}
266268

269+
if let TestGoal::Aggregated(expected) = &mut expected {
270+
if let Some(last_expected_pos) = last_expected_pos {
271+
if last_expected_pos == ExpectPos::of(expected) {
272+
expected.bless(false)
273+
}
274+
}
275+
last_expected_pos = Some(ExpectPos::of(expected));
276+
}
277+
267278
chalk_integration::tls::set_current_program(&program, || {
268279
println!("----------------------------------------------------------------------");
269280
println!("goal {}", goal_text);
@@ -332,6 +343,23 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
332343
})
333344
}
334345

346+
#[derive(Clone, Copy, PartialEq, Eq)]
347+
struct ExpectPos {
348+
file: &'static str,
349+
line: u32,
350+
column: u32,
351+
}
352+
353+
impl ExpectPos {
354+
fn of(e: &Expect) -> Self {
355+
Self {
356+
file: e.position.file,
357+
line: e.position.line,
358+
column: e.position.column
359+
}
360+
}
361+
}
362+
335363
mod arrays;
336364
mod auto_traits;
337365
mod closures;

0 commit comments

Comments
 (0)