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

TyCtxt::variances_of is misdocumented as applying to a generic parameter #133494

Closed
btj opened this issue Nov 26, 2024 · 1 comment · Fixed by #134787
Closed

TyCtxt::variances_of is misdocumented as applying to a generic parameter #133494

btj opened this issue Nov 26, 2024 · 1 comment · Fixed by #134787
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-variance Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@btj
Copy link

btj commented Nov 26, 2024

Location

https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.variances_of

Summary

This method returns the variances of the generic parameters of the struct with the given def_id. Contrary to what the documentation suggests, when given the def_id of a generic parameter of a struct, it returns an empty slice.

@btj btj added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Nov 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 26, 2024
@fmease fmease added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 26, 2024
@fmease
Copy link
Member

fmease commented Nov 26, 2024

Good catch, feel free to submit a patch!

Small correction: ... of the *item given by the DefId [where item refers to ADTs, lazy type aliases, free and associated functions].

@fmease fmease added A-variance Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html) and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Nov 26, 2024
@fmease fmease self-assigned this Nov 27, 2024
@bors bors closed this as completed in 72ef16f Dec 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 27, 2024
Rollup merge of rust-lang#134787 - fmease:spruce-up-queries, r=compiler-errors

Spruce up the docs of several queries related to the type/trait system and const eval

- Editorial
  - Proper rustdoc summary/synopsis line by making use of extra paragraphs: Leads to better rendered output on module pages, in search result lists and overall, too
  - Use rustdoc warning blocks for admonitions of the form "do not call / avoid calling this query directly"
  - Use intra-doc links of the form ``[`Self::$query`]`` to cross-link queries. Indeed, such links are generally a bit brittle due to the existence of `TyCtxtFeed` which only contains a subset of queries. Therefore the docs of `feedable` queries cannot cross-link to non-`feedable` ones. I'd say it's fine to use intra-doc links despite the potential/unlikely occasional future breakage (if a query with the aforementioned characteristics becomes `feedable`). `Self::` is nicer than `TyCtxt::` (which would be more stable) since it accounts for other contexts like `TyCtxt{Feed,At,Ensure{,WithValue}}`
- Informative
  - Generally add, flesh out and correct some doc comments
  - Add *Panic* sections (to a few selected queries only). The lists of panics aren't necessarily exhaustive and focus on the more "obvious" or "important" panics.
  - Where applicable add a paragraph calling attention to the relevant [`#[rustc_*]` TEST attribute](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html#rustc_-test-attributes)

The one non-doc change (it's internal and not observable):
Be even more defensive in `query constness`'s impl (spiritual follow-up to rust-lang#134122) (see self review comment).

Fixes rust-lang#133494.

r\? **any**(compiler-errors, oli-obk)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-variance Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants