这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@unexge
Copy link
Contributor

@unexge unexge commented Jan 15, 2021

Closes #7185

Comment on lines 35 to 49
let new_use = ast::make::use_(
use_.visibility(),
ast::make::use_tree(path, None, tree.rename(), tree.star_token().is_some()),
);

let mut rewriter = SyntaxRewriter::default();
rewriter += tree.remove();
rewriter.insert_after(use_.syntax(), &ast::make::tokens::single_newline());
if let ident_level @ 1..=usize::MAX = use_.indent_level().0 as usize {
rewriter.insert_after(
use_.syntax(),
&ast::make::tokens::whitespace(&" ".repeat(4 * ident_level)),
);
}
rewriter.insert_after(use_.syntax(), new_use.syntax());
Copy link
Contributor

Choose a reason for hiding this comment

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

This part should go into the |builder| closure, to avoid unnecessary computation.

Copy link
Contributor

@matklad matklad 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 a test mark!

bors r+

Comment on lines +28 to +29
if tree_list.use_trees().count() < 2 {
return None;
Copy link
Contributor

Choose a reason for hiding this comment

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

this could use mark::hit! call (see the mark module).

@bors
Copy link
Contributor

bors bot commented Jan 15, 2021

@bors bors bot merged commit d93d3d6 into rust-lang:master Jan 15, 2021
@matklad
Copy link
Contributor

matklad commented Jan 15, 2021

ah, this should've been d+

could you send a followup?

@unexge
Copy link
Contributor Author

unexge commented Jan 15, 2021

sent it #7290

bors bot added a commit that referenced this pull request Jan 15, 2021
7290: Add test mark for skipping single use item in Unmerge use assist r=Veykril a=unexge

followup for #7289

Co-authored-by: unexge <unexge@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assist: Unmerge use

2 participants