Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover import instead of use in item #97819

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jun 7, 2022

When we definitely don't have a macro invocation (i.e. when we don't have import ::), then it's more productive to parse import as if it was incorrectly mistaken for use.

Not sure if this needs to be a verbose suggestion, but it renders strangely when it's not verbose:

error: expected item, found `import`
 --> /home/michael/test.rs:1:1
  |
1 | import std::{io::{self, Write}, rc::Rc};
  | ^^^^^^ help: items are imported using the `use` keyword: `use`

Happy to change it to span_suggestion instead of span_suggestion_verbose though.

Fixes #97788

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 7, 2022
@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 7, 2022
Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

r=me with or without feedback implemented

compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
compiler/rustc_span/src/symbol.rs Outdated Show resolved Hide resolved
@compiler-errors
Copy link
Member Author

@bors r=wesleywiser rollup

@bors
Copy link
Contributor

bors commented Jun 8, 2022

📌 Commit b7ed860 has been approved by wesleywiser

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 8, 2022
@ChayimFriedman2
Copy link
Contributor

Now what about dots instead of ::? :P

@compiler-errors
Copy link
Member Author

Now what about dots instead of ::? :P

That would be a separate and more complicated recovery than what we currently have. Feel free to file an issue or take a stab if you're interested.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 8, 2022
…ywiser

Recover `import` instead of `use` in item

When we definitely don't have a macro invocation (i.e. when we don't have `import ::`), then it's more productive to parse `import` as if it was incorrectly mistaken for `use`.

Not sure if this needs to be a verbose suggestion, but it renders strangely when it's not verbose:
```
error: expected item, found `import`
 --> /home/michael/test.rs:1:1
  |
1 | import std::{io::{self, Write}, rc::Rc};
  | ^^^^^^ help: items are imported using the `use` keyword: `use`
```

Happy to change it to `span_suggestion` instead of `span_suggestion_verbose` though.

Fixes rust-lang#97788
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 8, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#97595 (Remove unwrap from get_vtable)
 - rust-lang#97597 (Preserve unused pointer to address casts)
 - rust-lang#97819 (Recover `import` instead of `use` in item)
 - rust-lang#97823 (Recover missing comma after match arm)
 - rust-lang#97851 (Use repr(C) when depending on struct layout in ptr tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a64a982 into rust-lang:master Jun 8, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 8, 2022
@compiler-errors compiler-errors deleted the use-import branch August 11, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rust could suggest "use" if it finds something like "import ... crate::"
6 participants