diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-08-02 06:22:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-02 06:22:48 +0200 |
| commit | bb3dee1a8a434f6647608d0d15c3d05b5029e930 (patch) | |
| tree | a59ee38760e23b9290366aa188e424ad7ed5e251 /compiler | |
| parent | 9cdca1884057b58962fd58880f01c824aca24536 (diff) | |
| parent | d21a335e8f8f9c05862e92887276cf5c7f9cd3d1 (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.rs | 3 |
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))), |
