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

The issue of semicolons affecting the lifecycle #22

Closed
naqunmiemie opened this issue May 13, 2023 · 4 comments · Fixed by #23
Closed

The issue of semicolons affecting the lifecycle #22

naqunmiemie opened this issue May 13, 2023 · 4 comments · Fixed by #23

Comments

@naqunmiemie
Copy link

Input code

if let Some(left) = node.borrow().left.as_ref() {
                    deque.push_back(left.clone());
                };
                if let Some(right) = node.borrow().right.as_ref() {
                    deque.push_back(right.clone());
                };

Output code

if let Some(left) = node.borrow().left.as_ref() {
                    deque.push_back(left.clone());
                }
                if let Some(right) = node.borrow().right.as_ref() {
                    deque.push_back(right.clone());
                }

Additional context

image
image

@naqunmiemie
Copy link
Author

image

@jinxdash
Copy link
Owner

jinxdash commented May 17, 2023

Related: rust-lang/rust#70844

Per Rust spec those IfLet blocks are statements, hence semicolons should be meaningless and unnecessary.

My understanding is that this is a longstanding bug in the rust compiler whereby "if let" is syntax sugar that gets unrolled into some code that itself is missing a semicolon.

I'm inclined to say that the formatting is correct and that the issue is upstream. Maybe someone can correct me on that, otherwise I'd suggest adding // prettier-ignore above the if let blocks

@naqunmiemie
Copy link
Author

image
image
I noticed that the last expression needed a semicolon

@naqunmiemie
Copy link
Author

When the code is formatted, it doesn't compile properly. This may be unreasonable.

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 a pull request may close this issue.

2 participants