rust/compiler
bors 37ec98f5d3 Auto merge of #146725 - lcnr:eager-instantiate-binder, r=BoxyUwU
`-Znext-solver` instantiate predicate binder without recanonicalizing goal

This strengthens the leak check to match the old trait solver. The new trait solver now also instantiates higher ranked goals in the same scope as candidate selection, so the leak check in each candidate detects placeholder errors involving this higher ranked goal.

E.g. let's look at tests/ui/higher-ranked/leak-check/leak-check-in-selection-2.rs
```rust
trait Trait<T, U> {}
impl<'a> Trait<&'a str, &'a str> for () {}
impl<'a> Trait<&'a str, String> for () {}
fn impls_trait<T: for<'a> Trait<&'a str, U>, U>() {}

fn main() {
    impls_trait::<(), _>();
}
```
Here proving `(): for<'a> Trait<&'a str, ?u>` via `impl<'a> Trait<&'a str, &'a str> for ()` equates `?u` with `&'!a str` which results in a leak check error as `?u` cannot name `'a`. If this leak check error happens while considering candidates we drop the first impl and infer `?u` to `String`. If not, this remains ambiguous.

This behavior is a bit iffy, see the FCP proposal in rust-lang/rust#119820 for more details on why this current behavior is somewhat undesirable. However, considering placeholders from higher-ranked goals for candidate selection does allow more code to compile and a lot of the code *feels like it should compile*. **This caused us to revert the change of rust-lang/rust#119820 in rust-lang/rust#127568.**

I originally expected that we can avoid breakage with the new solver differently here, e.g. by considering OR-region constraints. However, doing so is a significant change and I don't have a great idea for how that should work. Matching the old solver behavior for now should not make this cleaner approach any more difficult in the future, so let's just go with what actually allows us to stabilize the new solver for now.

This PR changing the new solver to match the behavior of the old one wrt the leak check. As the new solver is already used by default in coherence, this allows more code to compile, see `tests/ui/higher-ranked/leak-check/leak-check-in-selection-7-coherence.rs`:
```rust
struct W<T, U>(T, U);

trait Trait<T> {}
// using this impl results in a higher-ranked region error.
impl<'a> Trait<W<&'a str, &'a str>> for () {}
impl<'a> Trait<W<&'a str, String>> for () {}

trait NotString {}
impl NotString for &str {}
impl NotString for u32 {}

trait Overlap<U> {}
impl<T: for<'a> Trait<W<&'a str, U>>, U> Overlap<U> for T {}
impl<U: NotString> Overlap<U> for () {}

fn main() {}
```

This behavior is quite arbitrary and not something I expect users to rely on in practice, however, it should still go through an FCP imo.

r? `@BoxyUwU` originally implemented by `@compiler-errors` in https://github.com/rust-lang/rust/pull/136997. Closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/120.
2025-10-21 21:09:46 +00:00
..
rustc Make llvm_enzyme a regular cargo feature 2025-09-15 15:31:56 +00:00
rustc_abi Rollup merge of #147134 - workingjubilee:remove-explicit-abialign-deref, r=Zalathar 2025-09-29 15:44:55 +10:00
rustc_arena some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_ast Auto merge of #146221 - camsteffen:ast-boxes, r=cjgillot 2025-10-16 02:31:44 +00:00
rustc_ast_ir turn pointer width into an integer in target.json 2025-08-27 23:44:49 +02:00
rustc_ast_lowering Rollup merge of #147734 - fmease:tighten-relaxed, r=lcnr 2025-10-20 22:30:53 +11:00
rustc_ast_passes Extract common logic for iterating over features 2025-10-02 21:43:14 +00:00
rustc_ast_pretty Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_attr_parsing Rollup merge of #147532 - JonathanBrouwer:cfg_attr2, r=jdonszelmann 2025-10-18 15:09:03 +02:00
rustc_baked_icu_data Use default locale fallback data 2025-08-28 09:48:54 +00:00
rustc_borrowck Auto merge of #144607 - camsteffen:impl-trait-header-option, r=lcnr 2025-10-18 00:08:18 +00:00
rustc_builtin_macros Rollup merge of #144438 - dawidl022:contracts/guarded-lowering, r=oli-obk 2025-10-16 19:35:22 +02:00
rustc_codegen_cranelift Rollup merge of #145724 - folkertdev:track-caller-drop-no-mangle, r=fee1-dead 2025-10-18 08:08:36 +02:00
rustc_codegen_gcc remove broken link 2025-10-20 20:50:44 +00:00
rustc_codegen_llvm Auto merge of #142696 - ZuseZ4:offload-device1, r=oli-obk 2025-10-20 10:17:29 +00:00
rustc_codegen_ssa comments for deduce_param_attrs 2025-10-19 10:12:43 +02:00
rustc_const_eval Rollup merge of #147764 - beepster4096:oopsies_sorry, r=saethlin 2025-10-18 08:08:38 +02:00
rustc_data_structures Rollup merge of #147716 - zhetaicheleba:master, r=jdonszelmann 2025-10-15 23:41:05 +02:00
rustc_driver compiler: Add Windows resources to rustc-main and rustc_driver 2025-09-05 14:06:31 -04:00
rustc_driver_impl fixes for numerous clippy warnings 2025-09-19 20:56:07 +00:00
rustc_error_codes Rollup merge of #146585 - hkBst:indexing-1, r=jdonszelmann 2025-10-02 10:27:49 +02:00
rustc_error_messages Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_errors fix: Use untrimmed line numbers for trimmed suggestions 2025-10-19 23:58:04 +08:00
rustc_expand Rollup merge of #147438 - reddevilmidzy:rename-non-inline-module-in-msg, r=fee1-dead 2025-10-18 23:54:44 +02:00
rustc_feature Extract common logic for iterating over features 2025-10-02 21:43:14 +00:00
rustc_fluent_macro some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_fs_util Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_graphviz some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hashes some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hir Rollup merge of #147676 - jdonszelmann:span-is-doc-comment, r=GuillaumeGomez 2025-10-15 23:41:03 +02:00
rustc_hir_analysis Rollup merge of #147734 - fmease:tighten-relaxed, r=lcnr 2025-10-20 22:30:53 +11:00
rustc_hir_id rustc_hir_id: Add a comment explaining why the crate exists 2025-08-20 15:04:00 -07:00
rustc_hir_pretty Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-dead 2025-09-02 17:08:58 +02:00
rustc_hir_typeck Auto merge of #146725 - lcnr:eager-instantiate-binder, r=BoxyUwU 2025-10-21 21:09:46 +00:00
rustc_incremental Do not GC the current active incremental session directory 2025-10-20 02:39:55 +00:00
rustc_index Rollup merge of #147751 - nnethercote:bit_set-Word, r=Zalathar 2025-10-16 19:35:27 +02:00
rustc_index_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_infer rename select_where_possible and select_all_or_error 2025-10-07 23:02:23 +01:00
rustc_interface Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
rustc_lexer Fix a crash/mislex when more than one frontmatter closing possibility is considered 2025-09-22 15:10:41 -04:00
rustc_lint Rollup merge of #147382 - joshtriplett:unused-must-use-ignore-result-unit-uninhabited, r=fmease 2025-10-20 16:12:54 +11:00
rustc_lint_defs remove useless #![deny]s 2025-10-19 19:48:21 +02:00
rustc_llvm Rollup merge of #147608 - Zalathar:debuginfo, r=nnethercote 2025-10-13 11:25:23 +02:00
rustc_log Restrict sysroot crate imports to those defined in this repo. 2025-10-15 13:17:25 +01:00
rustc_macros use declarative macro for #[derive(TryFromU32)] 2025-10-06 14:54:38 +00:00
rustc_metadata Auto merge of #147695 - cjgillot:deduce-param-freeze, r=tmiasko 2025-10-18 12:37:45 +00:00
rustc_middle Auto merge of #147723 - ChayimFriedman2:ns-types, r=BoxyUwU 2025-10-21 14:43:26 +00:00
rustc_mir_build Fix ICE in pattern matching with generic const array length errors 2025-10-16 19:15:32 +08:00
rustc_mir_dataflow make move unwrap_binder! a move subpath 2025-10-11 22:51:40 -07:00
rustc_mir_transform Auto merge of #147867 - cjgillot:invalidate-cleanup, r=tmiasko 2025-10-21 01:17:03 +00:00
rustc_monomorphize Remove Option from impl_trait_header 2025-10-17 08:36:34 -05:00
rustc_next_trait_solver Auto merge of #146725 - lcnr:eager-instantiate-binder, r=BoxyUwU 2025-10-21 21:09:46 +00:00
rustc_parse Parse const unsafe trait properly 2025-10-18 23:39:30 +00:00
rustc_parse_format Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_passes Rollup merge of #138679 - Shunpoco:issue-125323, r=oli-obk 2025-10-18 23:54:43 +02:00
rustc_pattern_analysis Rename various "concrete opaque type" terminology to say "hidden type" 2025-09-27 22:58:02 +01:00
rustc_privacy Split impl_(opt_)trait_ref 2025-10-17 08:36:34 -05:00
rustc_proc_macro Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_public Remove StatementKind::Deinit. 2025-10-10 12:57:24 +00:00
rustc_public_bridge Rollup merge of #147800 - makai410:rp-cache-obj, r=celinval 2025-10-21 12:20:56 +11:00
rustc_query_impl fixup limit handling code 2025-09-08 15:07:12 -07:00
rustc_query_system Auto merge of #147508 - nnethercote:TaskDeps-improvements, r=saethlin 2025-10-17 04:47:43 +00:00
rustc_resolve use module_child index as disambiguator for external items 2025-10-17 18:04:28 +02:00
rustc_sanitizers Split impl_(opt_)trait_ref 2025-10-17 08:36:34 -05:00
rustc_serialize Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_session Fix autodiff incorrectly applying fat-lto to proc-macro crates 2025-10-17 16:52:55 +03:00
rustc_span Allow vector-scalar (vs) registers in ppc inline assembly 2025-10-14 09:52:56 -05:00
rustc_symbol_mangling Split impl_(opt_)trait_ref 2025-10-17 08:36:34 -05:00
rustc_target Rollup merge of #147454 - ferrocene:hoverbear/panic-abort-uwtables-qnx, r=wesleywiser 2025-10-18 08:08:37 +02:00
rustc_thread_pool some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_trait_selection instantiate predicate binder without recanonicalizing goal in new solver 2025-10-20 10:31:08 +02:00
rustc_traits Auto merge of #146096 - adwinwhite:handle_normalization_overflow_in_mono1, r=saethlin 2025-10-13 00:20:10 +00:00
rustc_transmute prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
rustc_ty_utils Auto merge of #147695 - cjgillot:deduce-param-freeze, r=tmiasko 2025-10-18 12:37:45 +00:00
rustc_type_ir Auto merge of #146725 - lcnr:eager-instantiate-binder, r=BoxyUwU 2025-10-21 21:09:46 +00:00
rustc_type_ir_macros some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_windows_rc [win] Use find-msvc-tools instead of cc to find the linker and rc on Windows 2025-09-19 12:00:30 -07:00