[rustdoc] Fix how Deref items is handled. - #160915
Conversation
|
|
|
Oof, that's a big diff. It's mostly because of reindent, not much that we can do about. ^^' |
This comment has been minimized.
This comment has been minimized.
32c5654 to
e3fb18c
Compare
|
Fixed |
Fixed the typo. Correct sentence is:
|
| let for_ = clean_ty(impl_.self_ty, cx); | ||
|
|
There was a problem hiding this comment.
nit: Moving this let is now unnecessary. Better to move it back to where it's used.
| @@ -295,6 +295,8 @@ pub(crate) fn build_deref_target_impls( | |||
| inline::build_impls(cx, did, None, ret); | |||
| }); | |||
| } | |||
| } else { | |||
| break; | |||
There was a problem hiding this comment.
Why was this break added?
There was a problem hiding this comment.
Because it's actually looking for the Deref::Target item and doesn't do anything. So at that point, we can break as soon as we found it. Can remove it though, considering there are only 2 items, doesn't matter much.
There was a problem hiding this comment.
Also just realized that it shouldn't be in a else condition. Anyway, removing it.
| @@ -3150,3 +3174,30 @@ fn repr_attribute<'tcx>( | |||
|
|
|||
| (!result.is_empty()).then(|| format!("#[repr({})]", result.join(", ")).into()) | |||
| } | |||
|
|
|||
| pub(crate) fn compute_if_deref_target_implements_copy( | |||
| cx: &Context<'_>, | |||
There was a problem hiding this comment.
Let's have this take TyCtxt instead of Context and change the callers as well. It's better to take as little input as possible.
| AlsoCollectAssocFns { assoc_fns: &'r mut Vec<Link<'l>> }, | ||
| } | ||
|
|
||
| fn get_methods<'a>( | ||
| i: &'a clean::Impl, | ||
| mut mode: GetMethodsMode<'_, 'a>, | ||
| used_links: &mut FxHashSet<String>, | ||
| tcx: TyCtxt<'_>, | ||
| cx: &Context<'_>, |
There was a problem hiding this comment.
Ditto here.
ca399ba to
7a71fdf
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Applied suggestions. @rustbot ready |
View all comments
Fixes #160236.
This PR fixes a few things around how we handle
Deref:Deref, only methods should be keptDeref::Targetis a type implementingCopy, then methods takingselfwork and should be displayed.During thecleanpass, I store the itemDefIdon whichDerefis implemented in aDefIdSetif theDeref::TargetimplementsCopy. Then during rendering, we check if the "parent item" is in in theDefIdSet, and if so, we keep methods withself.Now you might wonder why the item and not the derefed item. It's because theDefIdwe get from the computed type doesn't match theDefIdof the actual type (that's where I spent most of my time, finding an ID (DefId/ItemId) I can use as key T_T).It computes in
html/renderif theDeref::Targetitem is copy before rendering it.So to resume:
&selfis always kept.&mut selfis kept ifDerefMutis implemented (nothing changed there).selfis kept only ifDeref::TargetisCopy.Deref.r? @camelid