about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2023-08-04 00:14:13 +0800
committeryukang <moorekang@gmail.com>2023-08-04 00:14:13 +0800
commitcde8f06503d06d254aa4191438588ba9b2a36b77 (patch)
tree9bc0aaafcde9e11cb34e6639af0c8b8a3db222fc /compiler/rustc_trait_selection
parent3635b48973ee17951c81769e4a62b0a4891a2501 (diff)
downloadrust-cde8f06503d06d254aa4191438588ba9b2a36b77.tar.gz
rust-cde8f06503d06d254aa4191438588ba9b2a36b77.zip
enable suggest convert to slice for binary operation
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 46c31c77613..bde72c691dc 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -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;
         };