Skip to content

Don't wrap parens around expr in remove_dbg assist if its in conditions #6595

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

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Nov 20, 2020

If the expr in the dbg! macro consists of multiple elements it won't remove the parentheses if its in a match or condition-using construct, as these are followed by siblings causing the is_leaf check to fail.

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

bors d+

Lgtm, one small nit, if you want to fix it.

@@ -49,14 +49,28 @@ fn adjusted_macro_contents(macro_call: &ast::MacroCall) -> Option<String> {
macro_text_with_brackets.len() - TextSize::of(')'),
));

let is_leaf = macro_call.syntax().next_sibling().is_none();
let is_leaf = is_leaf_or_control_flow_expr(macro_call);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the variable name now is a bit wrong.

IMO we can just inline it, it was extracted by me initially to document what macro_call().syntax().next_sibling().is_none() had meant, but now with a properly named function introduced it makes no sense anymore.

@bors
Copy link
Contributor

bors bot commented Nov 20, 2020

✌️ Veykril can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@Veykril
Copy link
Member Author

Veykril commented Nov 20, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 20, 2020

@bors bors bot merged commit 48bb4bf into rust-lang:master Nov 20, 2020
@Veykril Veykril deleted the remove_dbg_cond branch November 27, 2020 18:16
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.

2 participants