-
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
Fix deref impl typedef #68093
Fix deref impl typedef #68093
Conversation
360624b
to
bd734fc
Compare
I like that the unwraps have transitioned to expects. |
@dns2utf8 This is a side-effect of my debugging (and I hate |
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.
This is now only including impls for the inner item_type
but we actually need the impls for the typedef itself as well. Take for example:
pub struct FooA;
pub type FooB = FooA;
pub type FooC = FooB;
impl FooA {
pub fn foo_a(&self) {}
}
impl FooB {
pub fn foo_b(&self) {}
}
impl FooC {
pub fn foo_c(&self) {}
}
pub struct Bar;
impl std::ops::Deref for Bar {
type Target = FooC;
fn deref(&self) -> &Self::Target { unimplemented!() }
}
Currently the docs for Bar
show only method foo_c
but with this PR it shows only foo_a
but what we really need is all of foo_a
, foo_b
and foo_c
to be included.
I'm not sure of the best way to do that but maybe Typedef
could contain a Vec<Type>
or Vec<DefId>
containing each inner type rather than just a single Option<Type>
.
src/librustdoc/html/render/cache.rs
Outdated
if item.name.is_none() { | ||
// this is most likely from a typedef | ||
continue; | ||
} |
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.
What is this change for? I can't see anything in this PR that would require this.
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.
It's not needed anymore, indeed! It was part of my debugging.
src/librustdoc/html/render/cache.rs
Outdated
crate_paths.push((short, fqp.last().expect("no fqp").clone())); | ||
} else { | ||
continue; | ||
} |
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.
Again, what is this change for?
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.
Same.
@ollie27 This is a great point: I didn't think about checking the type alias itself for implementations. I'll need to update the PR to extend it a bit. |
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.
I also appreciate the .unwrap()
-> .expect("...")
changes, and other than wondering about the same points as Ollie did in cache.rs
I think this is looking quite OK.
I wonder if, in the process of removing that additional debugging code you might fold the formatting fixes into the requisite commits though, to keep the history a bit cleaner?
90e0a90
to
d66457a
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
d66457a
to
e6ad49a
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
3da3171
to
8a9b951
Compare
Ok, fixed all the issues encountered. It now returns all implementations made on the type aliases. |
src/librustdoc/clean/mod.rs
Outdated
Some(DefKind::TyAlias) => Some(cx.tcx.type_of(did).clean(cx)), | ||
_ => None, | ||
}); | ||
if let Some(type_alias) = type_alias { |
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.
Can you try deduplicating the ret.push
with the one afterwards? Maybe for for_ in type_alias.into_iter().chain(self.for_.clean(cx)) {
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.
If we do it this way, we'll have to clone trait_
and items
one extra time. I'll write something else instead to avoid the duplication of code.
Updated! |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Fixed formatting. |
@bors r+ |
📌 Commit 482dc77 has been approved by |
…ef, r=oli-obk Fix deref impl typedef Fixes rust-lang#35295. r? @kinnison
…ef, r=oli-obk Fix deref impl typedef Fixes rust-lang#35295. r? @kinnison
…ef, r=oli-obk Fix deref impl typedef Fixes rust-lang#35295. r? @kinnison
Rollup of 9 pull requests Successful merges: - #66660 (Don't warn about snake case for field puns.) - #68093 (Fix deref impl typedef) - #68204 (Use named fields for `{ast,hir}::ItemKind::Impl`) - #68256 (Do not ICE on malformed suggestion spans) - #68279 (Clean up E0198 explanation) - #68291 (Update sanitizer tests) - #68312 (Add regression test for integer literals in generic arguments in where clauses) - #68314 (Stop treating `FalseEdges` and `FalseUnwind` as having semantic value for const eval) - #68317 (Clean up E0199 explanation) Failed merges: r? @ghost
Fixes #35295.
r? @kinnison