about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-02 06:22:48 +0200
committerGitHub <noreply@github.com>2023-08-02 06:22:48 +0200
commitbb3dee1a8a434f6647608d0d15c3d05b5029e930 (patch)
treea59ee38760e23b9290366aa188e424ad7ed5e251 /compiler
parent9cdca1884057b58962fd58880f01c824aca24536 (diff)
parentd21a335e8f8f9c05862e92887276cf5c7f9cd3d1 (diff)
Rollup merge of #114199 - compiler-errors:dont-select-unsize-infer, r=lcnr
Don't unsize coerce infer vars in select in new solver

Otherwise we're too eagerly preferring the `T -> dyn Trait` branch during coercion.

r? `@lcnr`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
index 1aef9a885bc..8a3c7b22e32 100644
--- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
+++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
@@ -235,7 +235,10 @@ fn rematch_unsize<'tcx>(
         goal.param_env,
         &mut nested,
     );
+
     match (a_ty.kind(), b_ty.kind()) {
+        // Don't try to coerce `?0` to `dyn Trait`
+        (ty::Infer(ty::TyVar(_)), _) | (_, ty::Infer(ty::TyVar(_))) => Ok(None),
         // Stall any ambiguous upcasting goals, since we can't rematch those
         (ty::Dynamic(_, _, ty::Dyn), ty::Dynamic(_, _, ty::Dyn)) => match certainty {
             Certainty::Yes => Ok(Some(ImplSource::Builtin(source, nested))),