about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-07-29 14:12:37 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-07-29 14:17:26 +0900
commit3ae669d758f7a7c0498d9208ef231718e50fb0ae (patch)
tree026eef5196b0482fdc9d9b499d2059149c4dd063 /compiler
parent06f89b7924af4657e847742bf0e40eafaaee52f9 (diff)
downloadrust-3ae669d758f7a7c0498d9208ef231718e50fb0ae.tar.gz
rust-3ae669d758f7a7c0498d9208ef231718e50fb0ae.zip
check if T is slice
fix msg
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs5
1 files changed, 3 insertions, 2 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 c51f3dacd54..6ad7ee32a4f 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -2943,14 +2943,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
     ) {
         if let ObligationCauseCode::ImplDerivedObligation(_) = obligation.cause.code()
             && self.tcx.is_diagnostic_item(sym::SliceIndex, trait_pred.skip_binder().trait_ref.def_id)
+            && let ty::Slice(_) = trait_pred.skip_binder().trait_ref.substs.type_at(1).kind()
             && let ty::Ref(_, inner_ty, _) = trait_pred.skip_binder().self_ty().kind()
             && let ty::Uint(ty::UintTy::Usize) = inner_ty.kind()
         {
             err.span_suggestion_verbose(
                 obligation.cause.span.shrink_to_lo(),
-            "consider dereferencing here",
+            "dereference this index",
             '*',
-                Applicability::MaybeIncorrect,
+                Applicability::MachineApplicable,
             );
         }
     }