Closed
Description
Right now, rustdoc has a whole mess of awful hacks to be able to add DefIds for things that aren't definitions:
Lines 131 to 140 in 4c10c84
It's unfortunate that these are needed at all, but it's really unfortunate that these have the same type as normal
DefId
s - they are not valid and cannot be passed to rustc APIs; trying to do so will usually panic. It also leads to lots of other hacks, like giving primitives DefIds: #83083 (comment)
A better alternative is to add a new wrapper type, something like
// clean/type.rs
enum DefId {
Real(rustc_span::def_id::DefId),
Fake(usize),
}
That makes it clear that the two are very different, and doesn't require hacks in rustdoc or rustc.
Things that can be removed once this is implemented:
Line 68 in 4c10c84
Line 145 in 4c10c84
Line 172 in 4c10c84
rust/src/librustdoc/clean/types.rs
Line 98 in 4c10c84
rust/src/librustdoc/clean/types.rs
Line 316 in 4c10c84
Metadata
Metadata
Assignees
Labels
Category: PRs that clean code up or issues documenting cleanup.Call for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the rustdoc team, which will review and decide on the PR/issue.