-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Don't document impossible to call default trait items on impls #100221
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
cc @notriddle, would appreciate a review on the rustdoc part! |
the impl looks good, leaving the final review to rustdoc r? rustdoc |
The code seems fine to me, but I’d like confirmation from at least one other rustdoc team member that this is the right solution at all. That we actually want to hide these methods, instead of doing something else, like slapping a label on them. |
75ed056
to
b3b23aa
Compare
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 seems like the right approach to me. From the user's perspective, it's as if the method doesn't exist for that type. I think still displaying the method but adding a label would be more confusing.
@bors r=lcnr,notriddle,camelid |
Inherent methods with impossible bounds (e.g. pub struct Bar([u8]);
impl Bar {
fn needs_sized(&self) where Self: Sized {}
}
|
@camelid: I actually meant trait items provided by an impl explicitly, like: trait Foo {
fn needs_sized() where Self: Sized;
}
struct Unsized([u8]);
impl Foo for Unsized {
fn needs_sized() where Self: Sized {}
} But that's also impossible to write currently, lol
|
Rollup of 7 pull requests Successful merges: - rust-lang#96478 (Implement `#[rustc_default_body_unstable]`) - rust-lang#99787 (Rustdoc-Json: Document HRTB's on DynTrait) - rust-lang#100181 (add method to get the mutability of an AllocId) - rust-lang#100221 (Don't document impossible to call default trait items on impls) - rust-lang#100228 (Don't ICE while suggesting updating item path.) - rust-lang#100301 (Avoid `&str` to `String` conversions) - rust-lang#100305 (Suggest adding an appropriate missing pattern excluding comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Closes #100176
This only skips documenting default trait items on impls, not ones that are written inside the impl block. This is a conservative approach, since I think we should document all items written in an impl block (I guess unless hidden or whatever), but the existence of this new query I added makes this easy to extend to other rustdoc cases.