diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-07-29 14:12:37 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-07-29 14:17:26 +0900 |
| commit | 3ae669d758f7a7c0498d9208ef231718e50fb0ae (patch) | |
| tree | 026eef5196b0482fdc9d9b499d2059149c4dd063 /compiler | |
| parent | 06f89b7924af4657e847742bf0e40eafaaee52f9 (diff) | |
| download | rust-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.rs | 5 |
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, ); } } |
