about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcsmoe <35686186+csmoe@users.noreply.github.com>2018-07-25 20:46:10 +0800
committercsmoe <35686186+csmoe@users.noreply.github.com>2018-07-26 21:08:44 +0800
commit20151ca7169e9f94d9efe682eee4719d4b4ccdf3 (patch)
treeb2c27a54130e1b894d29d426017d571404bb686c
parent13985724033467ab86da9136c43fe242092b294e (diff)
downloadrust-20151ca7169e9f94d9efe682eee4719d4b4ccdf3.tar.gz
rust-20151ca7169e9f94d9efe682eee4719d4b4ccdf3.zip
Suggest on method signature diff between impl and trait
-rw-r--r--src/librustc_typeck/check/compare_method.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs
index 220dd122b26..55aa38d942e 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,