-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 Item::from_def_id_and_kind
to reduce duplication in rustdoc
#77820
Conversation
@petrochenkov do you understand this error?
I can change it to use the |
It's coming from this code: impl Clean<Item> for doctree::Struct<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Item {
Item::from_hir_id_and_kind(
self.id,
StructItem(Struct {
struct_type: self.struct_type,
generics: self.generics.clean(cx),
fields: self.fields.clean(cx),
fields_stripped: false,
}),
cx,
)
}
} |
Hmm, this comes from |
Looks like the crate that should provide this is
|
IIRC, the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
#78077 has landed. |
Rebased and updated. This is still panicking on most tests:
Backtrace:
I think the issue is that rust/compiler/rustc_middle/src/ty/mod.rs Lines 2793 to 2797 in cee5521
rust/compiler/rustc_middle/src/ty/mod.rs Lines 2919 to 2934 in cee5521
I'll try rewriting item_name in terms of opt_item_name and see if that helps.
|
@Manishearth FYI - Guillaume and I discussed offline that there's no way to get precisely the previous behavior back. I can recover |
Yeah that's fine, I care about self and super only, the others are rare enough |
@bors r=petrochenkov rollup=never I want to be able to bisect if this causes regressions. |
📌 Commit 46a99790cdf4dc633fe8b295b506b15c7ad72f1c has been approved by |
This comment has been minimized.
This comment has been minimized.
Visibility needs much less information than a full path, since modules can never have generics. This allows constructing a Visibility from only a DefId. Note that this means that paths are now normalized to their DefPath. In other words, `pub(self)` or `pub(super)` now always shows `pub(in path)` instead of preserving the original text.
This also uses an exhaustive match to avoid future similar bugs.
- Add `Item::from_hir_id_and_kind` convenience wrapper - Make name parameter mandatory `tcx.opt_item_name` doesn't handle renames, so this is necessary for any item that could be renamed, which is almost all of them. - Override visibilities to be `Inherited` for enum variants `tcx.visibility` returns the effective visibility, not the visibility that was written in the source code. `pub enum E { A, B }` always has public variants `A` and `B`, so there's no sense printing `pub` again. - Don't duplicate handling of `Visibility::Crate` Instead, represent it as just another `Restricted` path.
It was completely unused.
@bors r=petrochenkov rollup=never |
📌 Commit 0e1a302 has been approved by |
☀️ Test successful - checks-actions |
@petrochenkov thank you so much for all your help, I wouldn't have been able to do this without you :) |
This makes it harder to make typos, and also makes it much more clear what's intentionally different rather than a typo (look for
what_rustc_thinks
).Found this while working on #76998, I really didn't want to add
const_visibility
in 20 different places.r? @GuillaumeGomez