rust icon indicating copy to clipboard operation
rust copied to clipboard

Trait methods with bounds on `Self` are shown on types that do not fulfill those bounds

Open notriddle opened this issue 2 years ago • 6 comments

Location

https://doc.rust-lang.org/std/collections/hash_map/struct.Keys.html#method.rev

Summary

Found in this topic on URLO.

It shows the method Iterator::rev on the page for hash_map::Keys. This is misleading, because you can't actually call that method, because Keys: !DoubleEndedIterator.

notriddle avatar Aug 05 '22 17:08 notriddle

@rustbot claim

chenyukang avatar Aug 05 '22 21:08 chenyukang

The same issue with partition_in_place and rposition.

@notriddle do you know how to exclude these options from hash_map? I'm still digging with it, if hash_map has this kind of issue, other data structures maybe have similar kind of issue.

I think we need to check the trait bounds when generating the doc.

chenyukang avatar Aug 05 '22 21:08 chenyukang

I expect you want to do it while cleaning — turning the rustc IR into rustdoc's own IR — or earlier. Doing it later would mean reimplementing parts of rustc's type checker using rustdoc's IR, and nobody wants to do that.

notriddle avatar Aug 05 '22 22:08 notriddle

For the record I was working on this, sorry for not claiming this... Anyways, let me know if you don't get around to this, and I'll pick it back up :smile_cat: . Seems like you've claimed a few issues in the past hours @chenyukang, so not sure which ones you've gotten started with.

compiler-errors avatar Aug 05 '22 23:08 compiler-errors

For the record I was working on this, sorry for not claiming this... Anyways, let me know if you don't get around to this, and I'll pick it back up 😸 . Seems like you've claimed a few issues in the past hours @chenyukang, so not sure which ones you've gotten started with.

I haven't started this one, released it, please go ahead. It's funny and also helpful to learn some Rust internals, I'm starting with some trivial fixes 😁

chenyukang avatar Aug 06 '22 02:08 chenyukang

Thank you @chenyukang. Sorry for the mistake, and I am excited for you to get involved more in the compiler :)

@rustbot claim

compiler-errors avatar Aug 06 '22 05:08 compiler-errors

This is a dupe of #80481

compiler-errors avatar Aug 06 '22 17:08 compiler-errors

Uh, sorry, actually not a dupe. That's impl level, this is method level. I think there were legitimate concerns with hiding whole impls in that other issue. Reopening this, andf I'll probably solve this first.

compiler-errors avatar Aug 06 '22 18:08 compiler-errors