enable suggest convert to slice for binary operation

This commit is contained in:
yukang 2023-08-04 00:14:13 +08:00
parent 3635b48973
commit cde8f06503
1 changed files with 5 additions and 3 deletions

View File

@ -3953,9 +3953,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
candidate_impls: &[ImplCandidate<'tcx>],
span: Span,
) {
// We can only suggest the slice coersion for function arguments since the suggestion
// would make no sense in turbofish or call
let ObligationCauseCode::FunctionArgumentObligation { .. } = obligation.cause.code() else {
// We can only suggest the slice coersion for function and binary operation arguments,
// since the suggestion would make no sense in turbofish or call
let (ObligationCauseCode::BinOp { .. }
| ObligationCauseCode::FunctionArgumentObligation { .. }) = obligation.cause.code()
else {
return;
};