Skip to content

style: updated rustfmt.toml guidelines - #490

Merged
alejandro-vaz merged 14 commits into
servo:v2from
alejandro-vaz:newstyle
Aug 30, 2026
Merged

style: updated rustfmt.toml guidelines#490
alejandro-vaz merged 14 commits into
servo:v2from
alejandro-vaz:newstyle

Conversation

@alejandro-vaz

@alejandro-vaz alejandro-vaz commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

this PR introduces the following changes to rustfmt.toml:

  1. changes import granularity to one, which means that all imports are grouped under a single use block
  2. cargo fmt --check errors on overflow and unformatted
  3. set one blank line as the maximum
  4. set float literals to only have trailing zeros if they don't have postfix
  5. allowed small functions to be written in a single line of code
  6. set import layout to vertical
  7. automatically convert /* ... */ comments to // ... comments
  8. allowed rustfmt to reorder implementations
  9. prohibited rustfmt to inline simple structs (it hurts readability)
  10. set style edition to 2024
  11. told rustfmt not to introduce trailing commas
  12. suggested rustfmt to prefer ? try shortcut
  13. allowed rustfmt to inline simple where clauses

effects

  • we can no longer use the vec! macro because rustfmt confounds the macro with the module, reducing the imports alloc::vec; alloc::vec::Vec to alloc::vec::{self, Vec} which is not valid
  • at line 2108, not being able to use the vec! macro means that we use iterator-collection specialization instead
  • saves 80 lines of code

@alejandro-vaz
alejandro-vaz requested a review from jdm August 29, 2026 14:19
@alejandro-vaz alejandro-vaz self-assigned this Aug 29, 2026
Comment thread src/lib.rs
};
#[cfg(feature = "std")]
use std::io;
use {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally I am not a fan of this style of writing imports, since they are harder to search for (eg when looking if a dependency is unused) and I find them harder to read. I will defer to you since you're actually working in the code, however.

Comment thread src/lib.rs Outdated
const unsafe fn as_ptr_heap(&self) -> *const T {
self.heap.0.as_ptr()
}
const unsafe fn as_ptr_heap(&self) -> *const T { self.heap.0.as_ptr() }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not convinced about the value of smashing methods into one line like this because it makes the visual syntactic noise much higher.

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.

I will revert that one then

alejandro-vaz and others added 11 commits August 30, 2026 14:40
Ports the implementation from the v1 branch to the v2 `SmallVec<T, const N>`
API, gated behind a new optional `arbitrary` feature. Delegates to
`Unstructured::arbitrary_iter` / `arbitrary_take_rest_iter` and collects via
the existing `FromIterator` impl. Adds a feature-gated test.

Closes servo#494

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>
@alejandro-vaz
alejandro-vaz added this pull request to the merge queue Aug 30, 2026
Merged via the queue into servo:v2 with commit 6223bce Aug 30, 2026
6 checks passed
alejandro-vaz added a commit to alejandro-vaz/rust-smallvec that referenced this pull request Aug 30, 2026
* fix: refined style

* refactor: new style

* fix: style

* revert: fn single line

* Turn all tests into integration tests (servo#495)

* Implement arbitrary::Arbitrary for SmallVec (servo#496)

Ports the implementation from the v1 branch to the v2 `SmallVec<T, const N>`
API, gated behind a new optional `arbitrary` feature. Delegates to
`Unstructured::arbitrary_iter` / `arbitrary_take_rest_iter` and collects via
the existing `FromIterator` impl. Adds a feature-gated test.

Closes servo#494

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>

* docs: told agents to link to servo contributing guidelines (servo#504)

* fix: added since and note for deprecations (servo#488)

* refactor: new style

* revert: fn single line

* fix: import errors solved

* fix: formatting

* fix: style again

---------

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>
Co-authored-by: Tobias Decking <Tobias.Decking@gmail.com>
Co-authored-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
alejandro-vaz added a commit to alejandro-vaz/rust-smallvec that referenced this pull request Aug 30, 2026
* fix: cargo warnings

* Turn all tests into integration tests (servo#495)

* Implement arbitrary::Arbitrary for SmallVec (servo#496)

Ports the implementation from the v1 branch to the v2 `SmallVec<T, const N>`
API, gated behind a new optional `arbitrary` feature. Delegates to
`Unstructured::arbitrary_iter` / `arbitrary_take_rest_iter` and collects via
the existing `FromIterator` impl. Adds a feature-gated test.

Closes servo#494

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>

* docs: told agents to link to servo contributing guidelines (servo#504)

* fix: added since and note for deprecations (servo#488)

* style: updated `rustfmt.toml` guidelines (servo#490)

* fix: refined style

* refactor: new style

* fix: style

* revert: fn single line

* Turn all tests into integration tests (servo#495)

* Implement arbitrary::Arbitrary for SmallVec (servo#496)

Ports the implementation from the v1 branch to the v2 `SmallVec<T, const N>`
API, gated behind a new optional `arbitrary` feature. Delegates to
`Unstructured::arbitrary_iter` / `arbitrary_take_rest_iter` and collects via
the existing `FromIterator` impl. Adds a feature-gated test.

Closes servo#494

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>

* docs: told agents to link to servo contributing guidelines (servo#504)

* fix: added since and note for deprecations (servo#488)

* refactor: new style

* revert: fn single line

* fix: import errors solved

* fix: formatting

* fix: style again

---------

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>
Co-authored-by: Tobias Decking <Tobias.Decking@gmail.com>
Co-authored-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>

* feat: added borsh serialize (servo#486)

* feat: added borsh serialize

* fix: formatting

* fix: style formatting

---------

Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>

* feat: implement `Format` for `SmallVec` (servo#472)

* feat: added defmt for smallvec

* fix: ran formatter

* refactor: removed API boundary

* fix: ran formatter

* fix: renamed imports to avoid namespace conflicts

* refactor: simplified format for smallvec

* fix: style formatting

* fix: imports

---------

Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>

* fix: cargo warnings

---------

Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>
Co-authored-by: Tobias Decking <Tobias.Decking@gmail.com>
Co-authored-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
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.

4 participants