Skip to content

Format the last statement as an expression #3624

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

Closed
topecongiro opened this issue Jun 12, 2019 · 0 comments
Closed

Format the last statement as an expression #3624

topecongiro opened this issue Jun 12, 2019 · 0 comments
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors

Comments

@topecongiro
Copy link
Contributor

Replace ExprType::Statement with ExprType::SubExpression if the statement is the last statement within its enclosing block.

format_expr(ex, ExprType::Statement, context, shape).map(|s| s + suffix)

One way to implement this is to add a wrapper type over ast::Stmt which holds the information about whether it's the last statement or not:

struct Statement<'ast> {
    stmt: &'ast ast::Stmt,
    is_last: bool,
}

cc #3614.

@topecongiro topecongiro added the good first issue Issues up for grabs, also good candidates for new rustfmt contributors label Jun 12, 2019
@scampi scampi closed this as completed Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors
Projects
None yet
Development

No branches or pull requests

2 participants