Skip to content

Commit

Permalink
Rollup merge of #66390 - estebank:parenice, r=Centril
Browse files Browse the repository at this point in the history
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`.
```
  • Loading branch information
JohnTitor committed Nov 15, 2019
2 parents c8d8f52 + 4137263 commit 1baa772
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 @@ -1862,15 +1862,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

1 comment on commit 1baa772

@DDR0
Copy link

@DDR0 DDR0 commented on 1baa772 Nov 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Please sign in to comment.