-
Notifications
You must be signed in to change notification settings - Fork 182
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
Conversation
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.
) | ||
.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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Discussion: we can eliminate the rust-format crate dependency by pulling the rustfmt call site into datagen itself. Then |
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 onprettyplease
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?