1
Fork 0

Rollup merge of #106309 - compiler-errors:prefer-non-err-candidates, r=oli-obk

Prefer non-`[type error]` candidates during selection

Fixes #102130
Fixes #106351

r? types

note: Alternatively we could filter out error where-clauses during param-env construction? But we still need to filter out impls with errors during `match_impl`, I think.
This commit is contained in:
Matthias Krüger 2023-01-12 06:52:34 +01:00 committed by GitHub
commit 9b538e8e62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 58 additions and 66 deletions

View file

@ -174,7 +174,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.param_env
.caller_bounds()
.iter()
.filter_map(|o| o.to_opt_poly_trait_pred());
.filter_map(|p| p.to_opt_poly_trait_pred())
.filter(|p| !p.references_error());
// Micro-optimization: filter out predicates relating to different traits.
let matching_bounds =

View file

@ -2377,6 +2377,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let impl_substs = self.infcx.fresh_substs_for_item(obligation.cause.span, impl_def_id);
let impl_trait_ref = impl_trait_ref.subst(self.tcx(), impl_substs);
if impl_trait_ref.references_error() {
return Err(());
}
debug!(?impl_trait_ref);