Also fix if in else
This commit is contained in:
parent
954419aab0
commit
af8d911d63
27 changed files with 223 additions and 291 deletions
|
@ -1323,23 +1323,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
label_or_note(span, terr.to_string(self.tcx));
|
||||
label_or_note(sp, msg);
|
||||
}
|
||||
} else {
|
||||
if let Some(values) = values
|
||||
&& let Some((e, f)) = values.ty()
|
||||
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
|
||||
{
|
||||
let e = self.tcx.erase_regions(e);
|
||||
let f = self.tcx.erase_regions(f);
|
||||
let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
|
||||
let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
|
||||
if expected == found {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
} else {
|
||||
label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
|
||||
}
|
||||
} else {
|
||||
} else if let Some(values) = values
|
||||
&& let Some((e, f)) = values.ty()
|
||||
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
|
||||
{
|
||||
let e = self.tcx.erase_regions(e);
|
||||
let f = self.tcx.erase_regions(f);
|
||||
let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
|
||||
let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
|
||||
if expected == found {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
} else {
|
||||
label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
|
||||
}
|
||||
} else {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
}
|
||||
|
||||
if let Some((expected, found, path)) = expected_found {
|
||||
|
|
|
@ -3237,16 +3237,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
// then the tuple must be the one containing capture types.
|
||||
let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) {
|
||||
false
|
||||
} else if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred);
|
||||
let nested_ty = parent_trait_ref.skip_binder().self_ty();
|
||||
matches!(nested_ty.kind(), ty::Coroutine(..))
|
||||
|| matches!(nested_ty.kind(), ty::Closure(..))
|
||||
} else {
|
||||
if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
|
||||
let parent_trait_ref =
|
||||
self.resolve_vars_if_possible(data.parent_trait_pred);
|
||||
let nested_ty = parent_trait_ref.skip_binder().self_ty();
|
||||
matches!(nested_ty.kind(), ty::Coroutine(..))
|
||||
|| matches!(nested_ty.kind(), ty::Closure(..))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
false
|
||||
};
|
||||
|
||||
if !is_upvar_tys_infer_tuple {
|
||||
|
|
|
@ -426,13 +426,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
} else if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
}
|
||||
} else if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
} else {
|
||||
if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
} else {
|
||||
// This stays ambiguous until kind+upvars are determined.
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
// This stays ambiguous until kind+upvars are determined.
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue