On Wed, May 29, 2024 at 10:30:13PM +0800, Zhao Liu wrote: > Hi Stefan, > > On Tue, May 28, 2024 at 10:14:01AM -0400, Stefan Hajnoczi wrote: > > Date: Tue, 28 May 2024 10:14:01 -0400 > > From: Stefan Hajnoczi <stefa...@redhat.com> > > Subject: Re: [RFC 1/6] scripts/simpletrace-rust: Add the basic cargo > > framework > > > > On Tue, May 28, 2024 at 03:53:55PM +0800, Zhao Liu wrote: > > > Hi Stefan, > > > > > > [snip] > > > > > > > > diff --git a/scripts/simpletrace-rust/.rustfmt.toml > > > > > b/scripts/simpletrace-rust/.rustfmt.toml > > > > > new file mode 100644 > > > > > index 000000000000..97a97c24ebfb > > > > > --- /dev/null > > > > > +++ b/scripts/simpletrace-rust/.rustfmt.toml > > > > > @@ -0,0 +1,9 @@ > > > > > +brace_style = "AlwaysNextLine" > > > > > +comment_width = 80 > > > > > +edition = "2021" > > > > > +group_imports = "StdExternalCrate" > > > > > +imports_granularity = "item" > > > > > +max_width = 80 > > > > > +use_field_init_shorthand = true > > > > > +use_try_shorthand = true > > > > > +wrap_comments = true > > > > > > > > There should be QEMU-wide policy. That said, why is it necessary to > > > > customize rustfmt? > > > > > > Indeed, but QEMU's style for Rust is currently undefined, so I'm trying > > > to add this to make it easier to check the style...I will separate it > > > out as a style policy proposal. > > > > Why is a config file necessary? QEMU should use the default Rust style. > > > > There are some that may be overdone, but I think some basic may still > be necessary, like "comment_width = 80", "max_width = 80", > "wrap_comments". Is it necessary to specify the width? As C.
Let's agree to follow the Rust coding style from the start, then the problem is solved. My view is that deviating from the standard Rust coding style in order to make QEMU Rust code resemble QEMU C code is less helpful than following Rust conventions so our Rust code looks like Rust. > > And, "group_imports" and "imports_granularity" (refered from crosvm), > can also be used to standardize including styles and improve > readability, since importing can be done in many different styles. > > This fmt config is something like ./script/check_patch.pl for QEMU/linux. > Different programs have different practices, so I feel like that's an > open too! In languages like Rust that have a standard, let's follow the standard instead of inventing our own way of formatting code. > This certainly also depends on the maintainer's/your preferences, ;-) > in what way looks more comfortable/convenient that is the best, > completely according to the default is also good. This will probably affect all Rust code in QEMU so everyone's opinion counts. Stefan
signature.asc
Description: PGP signature