Rollup merge of #115077 - estebank:issue-115019, r=compiler-errors
Do not emit invalid suggestion in E0191 when spans overlap Fix #115019.
This commit is contained in:
commit
0e84d42a9e
3 changed files with 51 additions and 1 deletions
|
@ -597,7 +597,21 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
}
|
||||
}
|
||||
}
|
||||
if !suggestions.is_empty() {
|
||||
suggestions.sort_by_key(|&(span, _)| span);
|
||||
// There are cases where one bound points to a span within another bound's span, like when
|
||||
// you have code like the following (#115019), so we skip providing a suggestion in those
|
||||
// cases to avoid having a malformed suggestion.
|
||||
//
|
||||
// pub struct Flatten<I> {
|
||||
// inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::core,
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// | ^^^^^^^^^^^^^^^^^^^^^
|
||||
// | |
|
||||
// | associated types `Item`, `IntoIter` must be specified
|
||||
// associated types `Item`, `IntoIter` must be specified
|
||||
// }
|
||||
let overlaps = suggestions.windows(2).any(|pair| pair[0].0.overlaps(pair[1].0));
|
||||
if !suggestions.is_empty() && !overlaps {
|
||||
err.multipart_suggestion(
|
||||
format!("specify the associated type{}", pluralize!(types_count)),
|
||||
suggestions,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue