-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add {Local}ModDefId
to more more strongly type DefId
s
#110862
Conversation
This allows for better type safety in the compiler and also improves the documentation for many things, making it clear that they expect modules.
r? @lcnr (rustbot has picked a reviewer for you, use r? to override) |
I think this has to wait for the MCP to finish? Won't have time to get to this until the end of next week so please reassign if you want some progress until then |
}; | ||
} | ||
|
||
typed_def_id! { ModDefId, LocalModDefId } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for implementation: you'll need to add
impl DepNodeParams
for all the created types, mirroring the one onLocalDefId
. This is meant to allow the query system to directly force a query that takes a LocalModId, instead of starting at the last one that took a LocalDefId.
commented by @cjgillot on Zulip, mirroring it here to remember it
☔ The latest upstream changes (presumably #111153) made this pull request unmergeable. Please resolve the merge conflicts. |
…aber Add `{Local}ModDefId` to more strongly type DefIds` Based on rust-lang#110862 by `@Nilstrieb`
superseeded by #114772 |
…aber Add `{Local}ModDefId` to more strongly type DefIds` Based on rust-lang#110862 by `@Nilstrieb`
Currently, the compiler just uses
DefId
everywhere. This is bad for correctness (you just get ICEs instead of compiler errors when passing an ID of the wrong kind) and documentation (the type doesn't document which kinds are expected).Instead, we should be using more strongly typed versions.
This PR adds such versions for modules and uses them in a bunch of places (not everywhere though).
I will open an MCP with more detail for doing this more generally.