Skip to content

Commit

Permalink
Suggest on method signature diff between impl and trait
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Jul 26, 2018
1 parent 1398572 commit 20151ca
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 20151ca

Please sign in to comment.