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

Switch datagen over to prettyplease #3363

Closed
wants to merge 3 commits into from

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Apr 20, 2023

Datagen can't rely on rustfmt existing in the PATH.

On the plus side, prettyplease has no qualms about formatting long line (rustfmt bails), so some of our databake has gotten prettier. Also according to benchmarks on prettyplease it's faster (though it's not apples-to-apples)

On the minus side, prettyplease doesn't group slice entries on the same line for large slices, so it can be a bit vertically sparse. I don't think this is too important.

Ideally we can get a patch release with this so I can use it in Google3, however we may be able to just let this ride the trains until later. Thoughts?

Datagen can't rely on rustfmt existing in the PATH.

On the plus side, `prettyplease` has no qualms about  formatting long lines (rustfmt bails), so some of our databake has gotten prettier. Also according to benchmarks on `prettyplease` it's faster (though it's not apples-to-apples)

On the minus side, `prettyplease` doesn't group slice  entries on the same line for large slices, so it can be a bit vertically sparse. I don't think this is too important.

Ideally we can get a patch release with this so I can use it in Google3, however we may be able to just let this ride the trains until later.
@Manishearth Manishearth requested review from sffc, robertbastian and a team as code owners April 20, 2023 16:45
)
.format_tokens(if is_expr {
// Rustfmt cannot format Rust expressions, only full files. We need to wrap expressions in a main function
let data = if is_expr {
Copy link
Member

Choose a reason for hiding this comment

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

I think prettyplease can work on arbitrary tokens.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it needs a syn::File. I tried that, it panics.

.ok_or_else(|| DataErrorKind::MissingLocale.with_req(::icu_timezone::provider::MetazonePeriodV1Marker::KEY, req))
}
}
($provider:path) => {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is why we moved to rustfmt. I think it's a lot more important that this is readable than the .rs.data files.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, yeah, i hadn't looked at this file. That's fair.

@sffc
Copy link
Member

sffc commented Apr 20, 2023

Discussion: we can eliminate the rust-format crate dependency by pulling the rustfmt call site into datagen itself. Then --pretty will just return an error if the binary is not in the PATH.

@sffc sffc closed this Apr 20, 2023
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.

3 participants