Skip to content

Commit

Permalink
Reporting with span_suggestion_short.
Browse files Browse the repository at this point in the history
  • Loading branch information
ysiraichi committed Mar 18, 2018
1 parent f6bffd1 commit c1ba5ac
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/librustc/traits/error_reporting.rs
Expand Up @@ -914,22 +914,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
new_trait_ref.to_predicate());

if selcx.evaluate_obligation(&new_obligation) {
let mut remove_refs = refs_remaining + 1;

let suggest_snippet = snippet.chars()
.skip_while(|c| c.is_whitespace() || {
if *c == '&' && remove_refs > 0 {
true
} else {
false
}
})
.collect::<String>();
let remove_refs = refs_remaining + 1;

err.span_suggestion(span,
&format!("consider removing {} references `&`",
remove_refs),
format!("{}", suggest_snippet));
err.span_suggestion_short(span,
&format!("consider removing {} leading `&`-references",
remove_refs),
String::from(""));

break;
}
Expand Down

0 comments on commit c1ba5ac

Please sign in to comment.