[WIP] [internal] introduce Rust backend with rustfmt support#15093
[WIP] [internal] introduce Rust backend with rustfmt support#15093tdyas wants to merge 4 commits intopantsbuild:mainfrom
rustfmt support#15093Conversation
| class RustCrateSourcesField(MultipleSourcesField): | ||
| default = ("Cargo.toml", "src/**/*.rs", "tests/**/*.rs") | ||
| uses_source_roots = False |
There was a problem hiding this comment.
So this is pretty tricky to model. We really have two types of sources fields going on - cargo.toml and the normal .RS files. It is very useful for those to be seen as completely separate fields, so that we can do things like be confident every single file is a rust file and it's safe to feed into rustc and rustfmt.
The issue is that we strongly assume there is only one sources field per target type. That is pretty crucial to have the target API Works when you say tgt.get(SourcesField). The safer thing to do would have been to have that return a tuple, but we intentionally return a single field or none.
There is one workaround I can think of, which is to use SecondaryOwnerMixin with a dedicated field for the cargo.toml. It is hacky, but I think would work.
--
How do you think we should handle cargo.lock?
|
Thanks a lot for this: both this one and #15092 are really exciting, but I feel like I need to do some research around prior art before diving in to review. This weekend hopefully? |
This is low priority, so take your time. Can elaborate on my choices as needed. |
rustfmt supportrustfmt support
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
Introduce Rust backend with
rustfmtandtailorsupport.The
rust_cratetarget type represents a Rust crate. The source globs currently only capturesrc/**/*.rsandtests/**/*.rs. The backend will eventually need a better way to capture all files that are part of the crate and not part of crates in subdirectories.Rustup is required to be installed. The backend will query Rustup for the path to a specific toolchain and binary (e.g.,
cargo,rustfmt, etc.)