Skip to content

Commit 20151ca

Browse files
committed
Suggest on method signature diff between impl and trait
1 parent 1398572 commit 20151ca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/librustc_typeck/check/compare_method.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
319319
E0053,
320320
"method `{}` has an incompatible type for trait",
321321
trait_m.ident);
322+
if let TypeError::Mutability = terr {
323+
if let Some(trait_err_span) = trait_err_span {
324+
if let Ok(trait_err_str) = tcx.sess.codemap().span_to_snippet(trait_err_span) {
325+
diag.span_suggestion(
326+
impl_err_span,
327+
"consider change the type to match the mutability in trait",
328+
format!("{}", trait_err_str),
329+
);
330+
}
331+
}
332+
}
322333

323334
infcx.note_type_err(&mut diag,
324335
&cause,

0 commit comments

Comments
 (0)