From 20151ca7169e9f94d9efe682eee4719d4b4ccdf3 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Wed, 25 Jul 2018 20:46:10 +0800 Subject: [PATCH] Suggest on method signature diff between impl and trait --- src/librustc_typeck/check/compare_method.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 220dd122b2679..55aa38d942efb 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -319,6 +319,17 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0053, "method `{}` has an incompatible type for trait", trait_m.ident); + if let TypeError::Mutability = terr { + if let Some(trait_err_span) = trait_err_span { + if let Ok(trait_err_str) = tcx.sess.codemap().span_to_snippet(trait_err_span) { + diag.span_suggestion( + impl_err_span, + "consider change the type to match the mutability in trait", + format!("{}", trait_err_str), + ); + } + } + } infcx.note_type_err(&mut diag, &cause,