Skip to content

Refactored the Rustfmt tool to work cross-platform#1375

Merged
UebelAndre merged 6 commits intobazelbuild:mainfrom
UebelAndre:rustfmt
Jun 10, 2022
Merged

Refactored the Rustfmt tool to work cross-platform#1375
UebelAndre merged 6 commits intobazelbuild:mainfrom
UebelAndre:rustfmt

Conversation

@UebelAndre
Copy link
Copy Markdown
Collaborator

@UebelAndre UebelAndre commented Jun 4, 2022

This change updates the @rules_rust//tools/rustfmt tool to no longer rely on building and reading manifest files to determine what sources to query. bazel query is expressive enough to request the list of source files that should be formatted.

@UebelAndre UebelAndre changed the title Refactored rustfmt tool to work cross-platform Refactored the Rustfmt tool to work cross-platform Jun 4, 2022
@UebelAndre
Copy link
Copy Markdown
Collaborator Author

closes #872

@UebelAndre UebelAndre force-pushed the rustfmt branch 6 times, most recently from dceeddc to 34b3cc2 Compare June 4, 2022 15:26
@UebelAndre
Copy link
Copy Markdown
Collaborator Author

This change is blocked by:

@UebelAndre UebelAndre force-pushed the rustfmt branch 5 times, most recently from 4a8f039 to d0d6138 Compare June 8, 2022 15:45
@UebelAndre UebelAndre marked this pull request as ready for review June 9, 2022 13:00
@UebelAndre UebelAndre requested a review from illicitonion June 9, 2022 13:00
Comment thread tools/rustfmt/srcs/lib.rs Outdated
Comment thread tools/rustfmt/srcs/main.rs Outdated
Comment thread tools/rustfmt/srcs/main.rs Outdated
UebelAndre and others added 2 commits June 9, 2022 09:31
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
":src.rs",
],
edition = "2018",
tags = ["norustfmt"],
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

All the tagging here is to work around the following error when a target has a mix of local and generated source files.

Error writing files: failed to resolve mod `src`: /Users/user/Code/rules_rust/test/generated_inputs/src.rs does not exist
Error writing files: failed to resolve mod `src`: /Users/user/Code/rules_rust/test/generated_inputs/src.rs does not exist
Error writing files: failed to resolve mod `generated_in_different_cfg`: /Users/user/Code/rules_rust/test/generated_inputs/generated_in_different_cfg.rs does not exist

This error comes from rustfmt but given that the functionality for supporting generated sources in rules_rust is new, I'd rather try to account for this in a separate PR.

@UebelAndre UebelAndre requested a review from illicitonion June 9, 2022 17:29
@UebelAndre
Copy link
Copy Markdown
Collaborator Author

@illicitonion would you be able to take one more look at this PR?

Copy link
Copy Markdown
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

:shipit:

@UebelAndre UebelAndre merged commit 94e0044 into bazelbuild:main Jun 10, 2022
@UebelAndre UebelAndre deleted the rustfmt branch June 10, 2022 13:22
@UebelAndre
Copy link
Copy Markdown
Collaborator Author

The query introduced here is susceptible to what I believe is a bug in how certain files are represented:

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