diff options
| author | bors <bors@rust-lang.org> | 2024-04-21 17:02:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-21 17:02:03 +0000 |
| commit | f22a0c2d9f9cd83dfe84b65e9fa1b3fa8303c7b5 (patch) | |
| tree | 2a90e9e916bbdddabdc338aa7d9149db9052a8cc /compiler | |
| parent | aa31bad26b6bbf71c2072465ddb0dfe807c2b7d5 (diff) | |
| parent | c2e2245fd86ac61e138af2ff604ccd5381627d38 (diff) | |
| download | rust-f22a0c2d9f9cd83dfe84b65e9fa1b3fa8303c7b5.tar.gz rust-f22a0c2d9f9cd83dfe84b65e9fa1b3fa8303c7b5.zip | |
Auto merge of #123594 - Urgau:fix-non_local_def-lint-overflow, r=lcnr
Fix trait solver overflow with `non_local_definitions` lint This PR fixes the trait solver overflow with the `non_local_definitions` lint reported in https://github.com/rust-lang/rust/issues/123573 using the suggestion from `@lcnr:` https://github.com/rust-lang/rust/issues/123573#issuecomment-2041348320 to use the next trait solver. ~~I have not (yet) tried to create a minimized repro~~ ``@compiler-errors`` did the minimization (thanks you) but I have manually tested on the `starlark-rust` project that it fixes the issue. Fixes #123573 r? `@lcnr`
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/non_local_def.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 4b06278330f..004c2c2e4f4 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -264,7 +264,19 @@ fn impl_trait_ref_has_enough_non_local_candidates<'tcx>( binder: EarlyBinder<TraitRef<'tcx>>, mut did_has_local_parent: impl FnMut(DefId) -> bool, ) -> bool { - let infcx = tcx.infer_ctxt().build(); + let infcx = tcx + .infer_ctxt() + // We use the new trait solver since the obligation we are trying to + // prove here may overflow and those are fatal in the old trait solver. + // Which is unacceptable for a lint. + // + // Thanksfully the part we use here are very similar to the + // new-trait-solver-as-coherence, which is in stabilization. + // + // https://github.com/rust-lang/rust/issues/123573 + .with_next_trait_solver(true) + .build(); + let trait_ref = binder.instantiate(tcx, infcx.fresh_args_for_item(infer_span, trait_def_id)); let trait_ref = trait_ref.fold_with(&mut ReplaceLocalTypesWithInfer { |
