Skip to content

Commit 1baa772

Browse files
authored
Rollup merge of #66390 - estebank:parenice, r=Centril
Fix ICE when trying to suggest `Type<>` instead of `Type()` Fixes #66286, but the output has no span: ``` error[E0214]: parenthesized type parameters may only be used with a `Fn` trait error: aborting due to previous error For more information about this error, try `rustc --explain E0214`. ```
2 parents c8d8f52 + 4137263 commit 1baa772

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
@@ -1862,15 +1862,16 @@ impl<'a> LoweringContext<'a> {
18621862
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
18631863
// Do not suggest going from `Trait()` to `Trait<>`
18641864
if data.inputs.len() > 0 {
1865-
let split = snippet.find('(').unwrap();
1866-
let trait_name = &snippet[0..split];
1867-
let args = &snippet[split + 1 .. snippet.len() - 1];
1868-
err.span_suggestion(
1869-
data.span,
1870-
"use angle brackets instead",
1871-
format!("{}<{}>", trait_name, args),
1872-
Applicability::MaybeIncorrect,
1873-
);
1865+
if let Some(split) = snippet.find('(') {
1866+
let trait_name = &snippet[0..split];
1867+
let args = &snippet[split + 1 .. snippet.len() - 1];
1868+
err.span_suggestion(
1869+
data.span,
1870+
"use angle brackets instead",
1871+
format!("{}<{}>", trait_name, args),
1872+
Applicability::MaybeIncorrect,
1873+
);
1874+
}
18741875
}
18751876
};
18761877
err.emit();

0 commit comments

Comments
 (0)