Fix use placement for suggestions near main.

This commit is contained in:
Eric Huss 2021-05-17 20:39:28 -07:00
parent 5f10d310f4
commit 1400cb0295
11 changed files with 167 additions and 20 deletions

View file

@ -330,15 +330,15 @@ impl UsePlacementFinder {
if self.span.map_or(true, |span| item.span < span)
&& !item.span.from_expansion()
{
self.span = Some(item.span.shrink_to_lo());
// don't insert between attributes and an item
if item.attrs.is_empty() {
self.span = Some(item.span.shrink_to_lo());
} else {
// find the first attribute on the item
for attr in &item.attrs {
if self.span.map_or(true, |span| attr.span < span) {
self.span = Some(attr.span.shrink_to_lo());
}
// find the first attribute on the item
// FIXME: This is broken for active attributes.
for attr in &item.attrs {
if !attr.span.is_dummy()
&& self.span.map_or(true, |span| attr.span < span)
{
self.span = Some(attr.span.shrink_to_lo());
}
}
}