Create and apply rustfmt policy #221
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/artiq-zynq#221
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "esavkin/artiq-zynq:rustfmt-policy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Run
cargo fmt
as a test after building the firmware.Proposed to solve such problems #217 (comment).
Cargo fmt can be also integrated to the major IDEs such as VS Code and Clion (see https://github.com/rust-lang/rustfmt#running-rustfmt-from-your-editor)
Code style settings are subject of discuss.
With this change, incorrect formatting will result in such output on running
nix develop
:A new test on Hydra (flake.nix) is probably better.
@ -79,12 +74,10 @@ pub fn resolve(required: &[u8]) -> Option<u32> {
api!(now_mu = rtio::now_mu),
api!(at_mu = rtio::at_mu),
api!(delay_mu = rtio::delay_mu),
We want those blank lines.
It can be skipped by
#[rustfmt::skip]
attributeThat would skip too much or create noise, no? What about simply using one or two empty comments instead?
No, it skips only one block, for this case - array only
Ok, sounds good.
636fbf9748
to873f012351
873f012351
to81878a077f
WIP: Create and apply rustfmt policyto Create and apply rustfmt policy@ -149,7 +149,10 @@
echo file binary-dist $out/${fwtype}.elf >> $out/nix-support/hydra-build-products
'';
doCheck = false;
Separate derivation with just this test is probably better. For example we don't need to run it every time for every variant.
81878a077f
todbf44ddf89
@ -256,0 +257,4 @@
name = "fmt_check";
nativeBuildInputs = [
rustPlatform.rust.rustc
Do we actually need rustc?
@ -253,6 +253,23 @@
'';
};
fmt_check = pkgs.stdenv.mkDerivation {
-
as ingateware-sim
@ -256,0 +265,4 @@
buildPhase =
''
(cd ${self}/src && cargo fmt -- --check)
Why this combination? Just write two lines.
@ -9,2 +9,2 @@
buffer: MutexGuard<'a, LogBuffer<&'static mut [u8]>>,
old_log_level: LevelFilter
buffer: MutexGuard<'a, LogBuffer<&'static mut [u8]>>,
old_log_level: LevelFilter,
It's a bit weird that it would require commas here on the last element, but remove the semicolon on
return Err("Neither MCP23017 nor PCA9539 io expander found.")
aboveOk, I guess it's because of https://stackoverflow.com/questions/62637801/why-is-the-semicolon-after-the-return-statement-optional
It can be configured. For now I moved back trailing semicolon, but left trailing commas for
Vertical
itemsdbf44ddf89
tofb4c9bb131
fb4c9bb131
to938f7e33a7