Skip to content

Commit ec3ee99

Browse files
committed
Fix trait solver overflow with non_local_definitions lint
1 parent 0e3235f commit ec3ee99

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/rustc_lint/src/non_local_def.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,18 @@ fn impl_trait_ref_has_enough_non_local_candidates<'tcx>(
264264
binder: EarlyBinder<TraitRef<'tcx>>,
265265
mut did_has_local_parent: impl FnMut(DefId) -> bool,
266266
) -> bool {
267-
let infcx = tcx.infer_ctxt().build();
267+
let infcx = tcx
268+
.infer_ctxt()
269+
// We use the new trait solver since the obligation we are trying to
270+
// prove here may overflow and those are fatal in the old trait solver.
271+
//
272+
// Which is unacceptable. Thanksfully the part we use here are very
273+
// similar to the new-trait-solver-as-coherence, which is in stabilization.
274+
//
275+
// https://github.com/rust-lang/rust/issues/123573
276+
.with_next_trait_solver(true)
277+
.build();
278+
268279
let trait_ref = binder.instantiate(tcx, infcx.fresh_args_for_item(infer_span, trait_def_id));
269280

270281
let trait_ref = trait_ref.fold_with(&mut ReplaceLocalTypesWithInfer {

0 commit comments

Comments
 (0)