Skip to content
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

rustdoc search: find types containing some other type #130204

Closed
lolbinarycat opened this issue Sep 10, 2024 · 5 comments · Fixed by #131806
Closed

rustdoc search: find types containing some other type #130204

lolbinarycat opened this issue Sep 10, 2024 · 5 comments · Fixed by #131806
Assignees
Labels
A-rustdoc-search Area: Rustdoc's search feature C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

when searching through crates with many complicated and nested types, it is often useful to know how you can get an instance of some type. this is partially covered by the -> SomeType syntax, but in codebases where you are expected to directly access fields instead of using getter methods, this is insufficient.

there should be a syntax to search for all types that use a given type in a field (not necessarily a struct, it could also be a union or enum).

tangentially related: #118912

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 10, 2024
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. A-rustdoc-search Area: Rustdoc's search feature and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 11, 2024
@GuillaumeGomez
Copy link
Member

We could update structfield to handle other cases as well.

@lolbinarycat
Copy link
Contributor Author

it could probably use similar logic, but maybe we should have a different prefix, like has:

@notriddle
Copy link
Contributor

Personally, I would just treat (visible) fields as functions with one parameter and one return value. It's how fields work in Hoogle, and for good reason, since the "I have a TyCtxt and want an hir::Map" is a use case that hardly cares if it goes through a method, a free function, or a struct field.

@lolbinarycat
Copy link
Contributor Author

well, in haskell, field accessors are free functions. but yeah that's probably a good idea.

@lolbinarycat lolbinarycat self-assigned this Oct 2, 2024
@lolbinarycat
Copy link
Contributor Author

if we're treating fields as unary functions, we should probably also treat constants and statics as nullary functions.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 15, 2025
…-func, r=notriddle

Treat other items as functions for the purpose of type-based search

specifically, constants and statics are nullary functions, and struct fields are unary functions.

fixes rust-lang#130204

r? `@notriddle`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 17, 2025
…-func, r=notriddle

Treat other items as functions for the purpose of type-based search

specifically, constants and statics are nullary functions, and struct fields are unary functions.

fixes rust-lang#130204

r? `@notriddle`
@bors bors closed this as completed in e2d14ec Jan 17, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 17, 2025
Rollup merge of rust-lang#131806 - lolbinarycat:rustdoc-search-all-is-func, r=notriddle

Treat other items as functions for the purpose of type-based search

specifically, constants and statics are nullary functions, and struct fields are unary functions.

fixes rust-lang#130204

r? ``@notriddle``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants