Skip to content

Commit

Permalink
Fix ICE when trying to suggest Type<> instead of Type()
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Nov 13, 2019
1 parent 695fe96 commit 4137263
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,15 +1860,16 @@ impl<'a> LoweringContext<'a> {
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
// Do not suggest going from `Trait()` to `Trait<>`
if data.inputs.len() > 0 {
let split = snippet.find('(').unwrap();
let trait_name = &snippet[0..split];
let args = &snippet[split + 1 .. snippet.len() - 1];
err.span_suggestion(
data.span,
"use angle brackets instead",
format!("{}<{}>", trait_name, args),
Applicability::MaybeIncorrect,
);
if let Some(split) = snippet.find('(') {
let trait_name = &snippet[0..split];
let args = &snippet[split + 1 .. snippet.len() - 1];
err.span_suggestion(
data.span,
"use angle brackets instead",
format!("{}<{}>", trait_name, args),
Applicability::MaybeIncorrect,
);
}
}
};
err.emit();
Expand Down

0 comments on commit 4137263

Please sign in to comment.