Skip to content

Conversation

@Shourya742
Copy link
Contributor

Update PathInterner::intern to use FileId::MAX for id range checks, ensuring FileId MAX invariant.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 27, 2025
@Shourya742
Copy link
Contributor Author

I am curious why we don't use u32::MAX?

@Shourya742
Copy link
Contributor Author

cc: @ShoyuVanilla apologies to tag, just looking for a quick review on this.

@lnicola
Copy link
Member

lnicola commented Oct 7, 2025

I am curious why we don't use u32::MAX?

The file id bits are OR-ed with 8 edition bits and a reserved one and get passed to proc macros as a single EditionedFileId.

What I'm wondering is why EditionedFileId::MAX_FILE_ID is 0x007F_FFFF while FileId::MAX is 0x7FFF_FFFF.

@Shourya742
Copy link
Contributor Author

Shourya742 commented Oct 7, 2025

I am curious why we don't use u32::MAX?

The file id bits are OR-ed with 8 edition bits and a reserved one and get passed to proc macros as a single EditionedFileId.

What I'm wondering is why EditionedFileId::MAX_FILE_ID is 0x007F_FFFF while FileId::MAX is 0x7FFF_FFFF.

It’s interesting that FileId reserves one bit but doesn’t include any edition bits. Since FileId is expected to accommodate editions as well, the mask 0x7FFF_FFFF appears incomplete.

@Shourya742
Copy link
Contributor Author

@lnicola makes sense to update the FileId upper limit to 0x007F_FFFF, right? What do you think?

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

This is definitely more correct, not that we will ever observe issues from this given that r-a likely fails with that many files in memory anyways though. Thanks for finding this!

@Veykril Veykril added this pull request to the merge queue Oct 16, 2025
Merged via the queue into rust-lang:master with commit 0138b82 Oct 16, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 16, 2025
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