Skip to content

Commit e01d3e0

Browse files
authored
Rollup merge of #123477 - lcnr:forced_ambig-no-ice, r=compiler-errors
do not ICE in `fn forced_ambiguity` if we get an error see the comment. currently causing an ICE in typenum which we've been unable to minimize. r? `@compiler-errors`
2 parents 58eb6e5 + 9444ca3 commit e01d3e0

File tree

1 file changed

+10
-3
lines changed
  • compiler/rustc_trait_selection/src/solve/assembly

1 file changed

+10
-3
lines changed

compiler/rustc_trait_selection/src/solve/assembly/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,18 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
312312
fn forced_ambiguity(&mut self, cause: MaybeCause) -> Vec<Candidate<'tcx>> {
313313
let source = CandidateSource::BuiltinImpl(BuiltinImplSource::Misc);
314314
let certainty = Certainty::Maybe(cause);
315-
let result = self.evaluate_added_goals_and_make_canonical_response(certainty).unwrap();
315+
// This may fail if `try_evaluate_added_goals` overflows because it
316+
// fails to reach a fixpoint but ends up getting an error after
317+
// running for some additional step.
318+
//
319+
// FIXME: Add a test for this. It seems to be necessary for typenum but
320+
// is incredibly hard to minimize as it may rely on being inside of a
321+
// trait solver cycle.
322+
let result = self.evaluate_added_goals_and_make_canonical_response(certainty);
316323
let mut dummy_probe = self.inspect.new_probe();
317-
dummy_probe.probe_kind(ProbeKind::TraitCandidate { source, result: Ok(result) });
324+
dummy_probe.probe_kind(ProbeKind::TraitCandidate { source, result });
318325
self.inspect.finish_probe(dummy_probe);
319-
vec![Candidate { source, result }]
326+
if let Ok(result) = result { vec![Candidate { source, result }] } else { vec![] }
320327
}
321328

322329
#[instrument(level = "debug", skip_all)]

0 commit comments

Comments
 (0)