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

Attach to lib.rs does not notice attributes in lib.rs. #5934

Closed
smj389 opened this issue Aug 14, 2020 · 2 comments · Fixed by #5937
Closed

Attach to lib.rs does not notice attributes in lib.rs. #5934

smj389 opened this issue Aug 14, 2020 · 2 comments · Fixed by #5937
Assignees
Labels
bug subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc.

Comments

@smj389
Copy link

smj389 commented Aug 14, 2020

Environment

  • IntelliJ Rust plugin version: 0.3.128.3278-202
  • Rust toolchain version: 1.47.0-nightly (81dc88f88 2020-08-13) x86_64-pc-windows-msvc
  • IDE name and version: CLion 2020.2 (CL-202.6397.106)
  • Operating system: Windows 10 10.0

Steps to reproduce

  1. Imagine a lib.rs file like this:
#![allow(dead_code)]
#![feature(async_closure)]
mod one;
mod two;
  1. Create a new file in the crate, e.g. three.rs
  2. Plugin suggests "attach to lib.rs"
  3. Get following result:
mod three;

#![allow(dead_code)]
#![feature(async_closure)]
mod one;
mod two;
  1. Problem is, of course, that the attributes need to be at the top of the file.
  2. 😢
@Undin Undin added bug subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. labels Aug 14, 2020
@Undin
Copy link
Member

Undin commented Aug 14, 2020

@Kobzol I think it can be fixed together with #5903

Note, we already have similar logic in auto-import quick fix to insert use item. Probably, we can reuse it
See org.rust.ide.utils.import.ImportUtils#firstItem property

@Undin
Copy link
Member

Undin commented Aug 14, 2020

@smj389 Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants