rust-lang/rustfix

Attributes applied to deleted items should also be deleted.

jrobsonchase opened this issue · 5 comments

For example, if I have

#[cfg(unix)]
extern crate nix;

mod foo;

and then run cargo fix --edition-idioms, currently only the extern crate nix; line gets deleted, which makes the #[cfg(unix)] attribute apply to mod foo;, which is not what was intended.

I'm currently using cargo-fix v0.4.1 from crates.io.

Wow, looks like a good catch!

That's actually a bug with the rust compiler, which outputs the diagnostic info, though. Can you open an issue at https://github.com/rust-lang/rust/issues? Otherwise I can do it.

@Manishearth y u so quick

Also, neither rustfix nor cargo-fix (which lives in the cargo repo) has no knowledge of the source code's semantics. cargo-fix will try to pass cfgs, though…

@jrobsonchase thanks so much for reporting this… twice! Closing this issue here in favor of rust-lang/rust#54400.