diff options
| author | bors <bors@rust-lang.org> | 2025-05-15 15:31:24 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-05-15 15:31:24 +0000 | 
| commit | c4e05e53d19b550a358ee8b2e29ecd5a11075800 (patch) | |
| tree | 8778851085c74c43bc319b87a1f3ba417e02fec7 /compiler/rustc_trait_selection/src/traits/mod.rs | |
| parent | d163a28381c297a56417d4a5dfe88c6c65429265 (diff) | |
| parent | 257f68777f469bdd26d4763dc0cbd99c99b74e1d (diff) | |
| download | rust-c4e05e53d19b550a358ee8b2e29ecd5a11075800.tar.gz rust-c4e05e53d19b550a358ee8b2e29ecd5a11075800.zip | |
Auto merge of #136988 - compiler-errors:impossible_predicates, r=lcnr
Use the new solver in the `impossible_predicates` The old solver is unsound for many reasons. One of which was weaponized by `@lcnr` in #140212, where the old solver was incompletely considering a dyn vtable method to be impossible and replacing its vtable entry with a null value. This null function could be called post-mono. The new solver is expected to be less incomplete due to its correct handling of higher-ranked aliases in relate. This PR switches the `impossible_predicates` query to use the new solver, which patches this UB. r? lcnr
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/mod.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/mod.rs | 14 | 
1 files changed, 5 insertions, 9 deletions
| diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 5b938456e03..4738a538b29 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -690,8 +690,11 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>( /// used during analysis. pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec<ty::Clause<'tcx>>) -> bool { debug!("impossible_predicates(predicates={:?})", predicates); - let (infcx, param_env) = - tcx.infer_ctxt().build_with_typing_env(ty::TypingEnv::fully_monomorphized()); + let (infcx, param_env) = tcx + .infer_ctxt() + .with_next_trait_solver(true) + .build_with_typing_env(ty::TypingEnv::fully_monomorphized()); + let ocx = ObligationCtxt::new(&infcx); let predicates = ocx.normalize(&ObligationCause::dummy(), param_env, predicates); for predicate in predicates { @@ -704,13 +707,6 @@ pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec<ty::Clause return true; } - // Leak check for any higher-ranked trait mismatches. - // We only need to do this in the old solver, since the new solver already - // leak-checks. - if !infcx.next_trait_solver() && infcx.leak_check(ty::UniverseIndex::ROOT, None).is_err() { - return true; - } - false } | 
