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
74876ef4e9
commit
651f46376a
2 changed files with 2 additions and 2 deletions
|
|
@ -113,7 +113,7 @@ impl<'a> Parser<'a> {
|
|||
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||
let mut parser = new_parser_from_file(sess.inner(), path, Some(span));
|
||||
match parser.parse_mod(&TokenKind::Eof) {
|
||||
Ok((a, i, ast::ModSpans { inner_span })) => Some((a, i, inner_span)),
|
||||
Ok((a, i, ast::ModSpans { inner_span, inject_use_span: _ })) => Some((a, i, inner_span)),
|
||||
Err(mut e) => {
|
||||
e.emit();
|
||||
if sess.can_reset_errors() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue