Skip to content

Commit 4137263

Browse files
committed
Fix ICE when trying to suggest Type<> instead of Type()
1 parent 695fe96 commit 4137263

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/librustc/hir/lowering.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1860,15 +1860,16 @@ impl<'a> LoweringContext<'a> {
18601860
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
18611861
// Do not suggest going from `Trait()` to `Trait<>`
18621862
if data.inputs.len() > 0 {
1863-
let split = snippet.find('(').unwrap();
1864-
let trait_name = &snippet[0..split];
1865-
let args = &snippet[split + 1 .. snippet.len() - 1];
1866-
err.span_suggestion(
1867-
data.span,
1868-
"use angle brackets instead",
1869-
format!("{}<{}>", trait_name, args),
1870-
Applicability::MaybeIncorrect,
1871-
);
1863+
if let Some(split) = snippet.find('(') {
1864+
let trait_name = &snippet[0..split];
1865+
let args = &snippet[split + 1 .. snippet.len() - 1];
1866+
err.span_suggestion(
1867+
data.span,
1868+
"use angle brackets instead",
1869+
format!("{}<{}>", trait_name, args),
1870+
Applicability::MaybeIncorrect,
1871+
);
1872+
}
18721873
}
18731874
};
18741875
err.emit();

0 commit comments

Comments
 (0)