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

Automatically adding use imports should always go below inner attributes #688

Open
Nokel81 opened this issue Mar 9, 2021 · 2 comments
Open
Labels
enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions!

Comments

@Nokel81
Copy link

Nokel81 commented Mar 9, 2021

If in the playground you use a type that is not in scope, the compiler helpfully outputs some options to use:

Screen Shot 2021-03-09 at 8 36 07 AM

However, if you click on one of those (and you happen to be using some inner attributes such as #[no_std] or a #[feature(...)] then that use statement is still added before that attribute and the compiler complains about it the next time you build/run.

It would be great if the use statement was added after the attribute.

@shepmaster shepmaster added enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions! labels Mar 9, 2021
@shepmaster shepmaster changed the title [Feature]: Auto adding of use imports always goes above inner attributes Automatically adding use imports should always go above inner attributes Mar 9, 2021
@shepmaster
Copy link
Member

I agree! There are two paths I forsee:

  1. Quicker/hackier: Add some more regex logic.
  2. Better/harder: Switch to using rustc's JSON diagnostics which should provide locations to add the suggestion.

@Nokel81 Nokel81 changed the title Automatically adding use imports should always go above inner attributes Automatically adding use imports should always go below inner attributes Mar 9, 2021
@Nokel81
Copy link
Author

Nokel81 commented Mar 9, 2021

Didn't know that rustc had a JSON diagnostics mode. Cool (I edited the title to be what I think is what we want).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants