Skip to content

refactor: rename lifetimes to be descriptive (#735) - #758

Merged
alejandro-vaz merged 2 commits into
servo:v2from
Ankit-cs:issue-735-lifetimes
Oct 15, 2026
Merged

alejandro-vaz merged 2 commits into
servo:v2from
Ankit-cs:issue-735-lifetimes

Conversation

@Ankit-cs

@Ankit-cs Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR resolves issue #735 by renaming all single-character generic lifetimes ('a) across the codebase to be more descriptive and easier to relate to their context.

Changes Made

  • tests/main.rs: Renamed 'a to 'cell for CountDrop and DropCounter, as it explicitly represents the lifetime of the referenced Cell.
  • benches/bench.rs: Renamed 'a to 'slice within the Vector trait to clarify it represents the lifetime of the referenced slice (&[T]).
  • fuzz/fuzz_targets/main.rs: Renamed 'a to 'data to clearly denote the lifetime of the unstructured fuzzing data buffer used by the Arbitrary trait.
  • Added clarifying doc comments to the modified structs, traits, and functions to further explain the purpose of these bounds.

Closes #735

@Ankit-cs

Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

looking for all the feedbacks to work @alejandro-vaz

@alejandro-vaz alejandro-vaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

honestly I'd just rename all of them to 'valid

like it doesn't give the developer any information that the lifetime is of the slice, for example. that's just self-explanatory

the information the lifetime conveys in these cases is for how long is it valid

this is not the case in all rust, but it is in our codebase

@Ankit-cs

Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

ok i will do according to the feedback

@Ankit-cs
Ankit-cs force-pushed the issue-735-lifetimes branch from 37b383e to 886c8a7 Compare October 9, 2026 18:03
@Ankit-cs

Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

if this is the required update so i can update the other files also acc to the above naming convention

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

yeah it is that

you also have to run rustfmt

@Ankit-cs

Ankit-cs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

OK sir I will that I will try to complete this in the morning

@Ankit-cs

Copy link
Copy Markdown
Contributor Author

l Have worked on the above feedback

I've pushed a new update that addresses all of your points:

Lifetime Renaming: I have globally renamed all single-character lifetimes across the codebase to 'valid as you suggested, as it perfectly conveys how long the references remain valid without needing arbitrary context-specific names.

Removed Doc Comments: I have deleted all the doc comments you pointed out in tests/main.rs, fuzz_targets/main.rs, and bench.rs since they aren't necessary right now.

Fixed Failing Checks: The compiler checks were failing due to a lifetime name collision where DropGuard in drain.rs ended up with two identical generic parameters ('valid, 'valid). I fixed this by separating them into 'guard and 'valid.

Formatting: I've run cargo fmt globally across the codebase.

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

you have to run nightly rustfmt, otherwise CI fails

make sure you have the latest nightly as well

@Ankit-cs

Copy link
Copy Markdown
Contributor Author

Ok @alejandro-vaz i will do it today i was busy with interview stuff

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

👍 no worries

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

alright I'm back with this

you have to rebase to the v2 branch and then do cargo fmt --all, making sure that you have rust nightly installed

you there??

@GauravPawar101

Copy link
Copy Markdown
Contributor

@Ankit-cs use +nightly or maybe register a hook

Replaces custom lifetimes (e.g., 'slice, 'data, 'cell) in benches, fuzz targets, and tests with the standard 'valid lifetime to ensure codebase consistency as per maintainer feedback.
@Ankit-cs
Ankit-cs force-pushed the issue-735-lifetimes branch from c8474f4 to 35414d3 Compare October 15, 2026 05:19
@Ankit-cs

Copy link
Copy Markdown
Contributor Author

@alejandro-vaz I have rebased onto latest v2 and formatted the entire codebase with the latest cargo +nightly fmt --all. All checks should pass cleanly now!

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

thanks @Ankit-cs

@alejandro-vaz
alejandro-vaz added this pull request to the merge queue Oct 15, 2026
Merged via the queue into servo:v2 with commit eaf9488 Oct 15, 2026
8 checks passed
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.

rename lifetimes to be descriptive

3 participants