Skip to content

Commit 7ce5226

Browse files
estebankMark-Simulacrum
authored andcommitted
Fix ICE when trying to suggest Type<> instead of Type()
1 parent 944dece commit 7ce5226

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/librustc/hir/lowering.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,15 +1874,16 @@ impl<'a> LoweringContext<'a> {
18741874
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
18751875
// Do not suggest going from `Trait()` to `Trait<>`
18761876
if data.inputs.len() > 0 {
1877-
let split = snippet.find('(').unwrap();
1878-
let trait_name = &snippet[0..split];
1879-
let args = &snippet[split + 1 .. snippet.len() - 1];
1880-
err.span_suggestion(
1881-
data.span,
1882-
"use angle brackets instead",
1883-
format!("{}<{}>", trait_name, args),
1884-
Applicability::MaybeIncorrect,
1885-
);
1877+
if let Some(split) = snippet.find('(') {
1878+
let trait_name = &snippet[0..split];
1879+
let args = &snippet[split + 1 .. snippet.len() - 1];
1880+
err.span_suggestion(
1881+
data.span,
1882+
"use angle brackets instead",
1883+
format!("{}<{}>", trait_name, args),
1884+
Applicability::MaybeIncorrect,
1885+
);
1886+
}
18861887
}
18871888
};
18881889
err.emit();

0 commit comments

Comments
 (0)