Repository navigation
Closed
Labels
B-metaThis issue tracks the status of multiple, related pieces of workE-less-complexStraightforward. Recommended for a new contributor.I-cleanupNo impact; the issue is one of maintainability or tidiness.
Description
#8553 (comment) describes a configuration that respects some style settings that we care about. I think it's worth systematically formatting Servo's code crate by crate (or module by module in the case of particularly large crates) and then integrating the changes in #20617 to enforce proper style in our CI.
Components:
- allocator (Format component allocator #21428)
- atoms (Format components atoms #21440)
- bluetooth (Format components bluetooth and bluetooth_traits #21442)
- bluetooth_traits (Format components bluetooth and bluetooth_traits #21442)
- canvas (Format components canvas and canvas_traits #21373 #21538)
- canvas_traits (Format components canvas and canvas_traits #21373 #21538)
- compositing (Format component compositing #21373 #21551)
- config (Format components config #21373 #21578)
- constellation (Rustfmt the constellation #21225)
- debugger (Format components debugger and deny_public_fields #21373 #21567)
- deny_public_fields (Format components debugger and deny_public_fields #21373 #21567)
- devtools (Format components devtools and devtools_traits #21373 #21582)
- devtools_traits (Format components devtools and devtools_traits #21373 #21582)
- dom_struct (Format components dom_struct, domobject_derive and embedder_traits #21373 #21584)
- domobject_derive (Format components dom_struct, domobject_derive and embedder_traits #21373 #21584)
- embedder_traits (Format components dom_struct, domobject_derive and embedder_traits #21373 #21584)
- fallible (Format components fallible and geometry #21373 #21598)
- geometry (Format components fallible and geometry #21373 #21598)
- gfx (Format gfx platform #21373 #21610, Format gfx text #21373 #21630, Format the rest of gfx #21373 #21638)
- gfx_traits (Format gfx_traits and hashglobe #21373 #21648)
- hashglobe (Format gfx_traits and hashglobe #21373 #21648)
- jstraceable_derive (Format jstraceable_derive #21373 #21655)
- layout (Rustfmt layout crate #21509)
- layout_thread (Rustfmt layout_thread crate #21613)
- layout_traits (Rustfmt layout_traits crate #21614)
- malloc_size_of (Rustfmt malloc_size_of & derive #21615)
- malloc_size_of_derive (Rustfmt malloc_size_of & derive #21615)
- metrics (Format components metrics and msg #21373 #21672)
- msg (Format components metrics and msg #21373 #21672)
- net (Format net and net_traits crates #22099)
- net_traits (Format net and net_traits crates #22099)
- profile (format components/profile #21651)
- profile_traits (format components/profile_traits #21657)
- rand (no formatting required)
- range (format components/range using rustfmt #21685)
- remutex (format components/remutex #21686)
- script (Format script component #21737)
- script_layout_interface (format script_layout_interface #21687)
- script_plugins (Format components/script_plugins #21694)
- script_traits (Format components/script_traits #21693)
- selectors (format components/selectors #21679)
- servo (Format component servo #21664)
- servo_arc (no formatting required)
- size_of_test (Format component size_of_test #21661)
- style (Format component
style#21652) - style_derive (Format component of style_derive #21635)
- style_traits (Format component of style_traits #21620)
- url (Format component of url #21617)
- webdriver_server (Format component of webdriver_sever #21603)
- webvr (Format component of webvr #21373 #21597)
- webvr_traits (Format components webvr_traits #21373 #21593)
ports:
- libsimpleservo (Format ports/libsimpleservo #21675)
- servo (Format ports/servo #21676)
Reacted by Seiichi Uchida and pyfisch
Reacted by cybai, Gavin-John Noonan and Darkspirit
Metadata
Metadata
Assignees
Labels
B-metaThis issue tracks the status of multiple, related pieces of workE-less-complexStraightforward. Recommended for a new contributor.I-cleanupNo impact; the issue is one of maintainability or tidiness.
Activity
highfive commentedon Aug 10, 2018
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the
#servochannel in IRC.If you intend to work on this issue, then add
@highfive: assign meto your comment, and I'll assign this to you. 😄jdm commentedon Aug 10, 2018
We now have a
./mach rustfmt [path]command that can be used, and you'll want to runrustup component add rustfmt-previewto install rustfmt if you don't already have it.kingdido999 commentedon Aug 11, 2018
Hi, I would like to work on this and will probably start from formatting the first component on the top.
@highfive: assign me
highfive commentedon Aug 11, 2018
Hey @kingdido999! Thanks for your interest in working on this issue. It's now assigned to you!
kingdido999 commentedon Aug 11, 2018
So I've successfully built the project and ran
rustup component add rustfmt-previewsuccessfully. But when I do./mach rustfmt components/allocator/lib.rs, it says:So I look into the rustfmt command defined in
python/servo/devenv_commands.py#21374 , seems we have to pass in a--directoryargument. Then I do./mach rustfmt -d components/allocator, it returns:Despite the error, it does run the formatting but for all files in the project, which is not what we want. If I provide a file path instead of a directory path, no error is shown but it formats the entire project again. My best guess is that
--directoryis not a valid command for rustfmt, we could produce the same error if we runrustfmt components/allocator.Directly run
rustfmtagainst a file works properly:Here are the versions of
rustcandrustfmton my system:@jdm @JoshBrudnak Please let me know if I'm missing something when I do
./mach rustfmt [path], thanks!jdm commentedon Aug 14, 2018
I've verified that you're not missing anything.
cargo fmtdoes not appear to do what we want; it looks like we'll need to modify the./mach rustfmtcommand to recursively find all of the rust source files under the given directory and pass those as arguments torustfmtdirectly. Would you like to make that change?kingdido999 commentedon Aug 15, 2018
Sure I will work on it.
kingdido999 commentedon Aug 15, 2018
I'm trying to get a rough idea on the use cases of
/mach rustfmt [directory]other than resolving this particular issue (format crate one at a time). It seems to me that we can simply get away withrustfmtas a part of future CI build after all crates have been formatted. So if that is true, we don't necessarily need to invent an extra command to format a directory, we could do something like this instead:jdm commentedon Aug 15, 2018
Sure, that would work. I meant to make this issue possible for multiple people to work on in parallel since there are so many components, so I figured a mach command would be the easiest way to support that.
Format component allocator servo#21373
Auto merge of #21428 - kingdido999:rustfmt/allocator, r=jdm
70 remaining items
Auto merge of #21675 - chansuke:format_libsimpleservo, r=jdm
Auto merge of #21672 - kingdido999:master, r=jdm
Auto merge of #21672 - kingdido999:master, r=jdm
AnshulMalik commentedon Sep 12, 2018
randis already formatted.Auto merge of #21693 - chansuke:format_script_traits, r=jdm
Auto merge of #21694 - chansuke:format_script_plugins, r=jdm
Auto merge of #21737 - chansuke:format_script, r=jdm
pyfisch commentedon Oct 15, 2018
Hi, formatting is almost complete. I'd like to suggest that servo adopts a new formatting for
usestatements. Currently use statements are ordered alphabetically and split into multiple lines if they are longer than 100 characters.I would want to split the imports into 4 groups (std, third-party imports, workspace imports, imports from the same crate) and sort those groups individually. (See rust-lang/rustfmt#2979)
Additionally I prefer to use
merge_importsformatting. I can see at a glance which items are imported from a module and how the module hierarchy is structured. (example file)The grouping can be done with a script. This could either be added to
cargo fmtor the lines are grouped by a script once.Auto merge of #22099 - pyfisch:net-fmt, r=jdm
Auto merge of #22099 - pyfisch:net-fmt, r=jdm
Dmitry-Borodin commentedon Nov 5, 2018
@jdm I see the last components from the list net and net_traits was formatted in #22099.
Should this issue now be closed?
It's among the first options in https://starters.servo.org/ -)
atouchet commentedon Nov 5, 2018
#20617 still needs to be finished.
CYBAI commentedon Nov 7, 2018
Fixed in #22126