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

Rustfmt deletes comments in 'use {}' #4708

Closed
darakshan opened this issue Feb 19, 2021 · 5 comments
Closed

Rustfmt deletes comments in 'use {}' #4708

darakshan opened this issue Feb 19, 2021 · 5 comments
Labels

Comments

@darakshan
Copy link

Describe the bug

To Reproduce
run rustfmt on the following code:

use {std::env::args /* this comment gets removed */};
fn main() {println!("hello from {}!", args().next().unwrap());}

Expected behavior

comment should be preserved

Meta

  • rustfmt version: rustfmt 1.4.30-stable (8c6769d 2021-01-18)
  • From where did you install rustfmt? :rustup
  • How do you run rustfmt: Cargo-fmt and VScode
@darakshan darakshan added the bug Panic, non-idempotency, invalid code, etc. label Feb 19, 2021
@calebcartwright calebcartwright added a-comments a-imports `use` syntax 1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release and removed bug Panic, non-idempotency, invalid code, etc. labels Feb 24, 2021
@kangalio
Copy link

kangalio commented Mar 7, 2021

Here's a slightly more common example of where this bug results in an annoyance:

pub use serenity::model::{
	// channel::{Message, Reaction, ReactionType},
	// gateway::Ready,
	// guild::{Member, Role},
	// id::{ChannelId, GuildId, MessageId, RoleId, UserId},
	// permissions::Permissions,
	prelude::*,
	// user::User,
};

Upon invoking rustfmt, all the commented-out lines disappeared

@karyon
Copy link
Contributor

karyon commented Oct 28, 2021

repro'd with 1.4.38

@calebcartwright calebcartwright removed the 1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release label Oct 30, 2021
@AndrewKvalheim
Copy link

Is this the same as #3984?

@ytmimi
Copy link
Contributor

ytmimi commented Apr 4, 2022

@AndrewKvalheim it seems like they are the same. Thanks for pointing that out 😁

@ytmimi
Copy link
Contributor

ytmimi commented Aug 31, 2023

This was completed in #5853

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants