Adjusted diagnostic output so that if there is no use
in a item sequence,
then we just suggest the first legal position where you could inject a use. To do this, I added `inject_use_span` field to `ModSpans`, and populate it in parser (it is the span of the first token found after inner attributes, if any). Then I rewrote the use-suggestion code to utilize it, and threw out some stuff that is now unnecessary with this in place. (I think the result is easier to understand.) Then I added a test of issue 87613.
This commit is contained in:
parent
b82795244e
commit
d37da1e332
13 changed files with 172 additions and 70 deletions
|
@ -55,6 +55,7 @@ impl<'a> Parser<'a> {
|
|||
let lo = self.token.span;
|
||||
let attrs = self.parse_inner_attributes()?;
|
||||
|
||||
let post_attr_lo = self.token.span;
|
||||
let mut items = vec![];
|
||||
while let Some(item) = self.parse_item(ForceCollect::No)? {
|
||||
items.push(item);
|
||||
|
@ -71,7 +72,9 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
Ok((attrs, items, ModSpans { inner_span: lo.to(self.prev_token.span) }))
|
||||
let inject_use_span = post_attr_lo.data().with_hi(post_attr_lo.lo());
|
||||
let mod_spans = ModSpans { inner_span: lo.to(self.prev_token.span), inject_use_span };
|
||||
Ok((attrs, items, mod_spans))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue