-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Spruce up the docs of several queries related to the type/trait system and const eval #134787
Conversation
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
/// If it is an assoc method or function, | ||
/// return if it has a `const` modifier. If it is an intrinsic, report whether said intrinsic | ||
/// has a `rustc_const_{un,}stable` attribute. Otherwise, panic. | ||
/// Checks whether a function-like thing is considered to be `const`. | ||
fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness { | ||
let node = tcx.hir_node_by_def_id(def_id); | ||
|
||
match node { |
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.
f69e091
to
7cc7e6a
Compare
505d7e4
to
8d08447
Compare
This comment has been minimized.
This comment has been minimized.
8d08447
to
fbff86e
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.
r=me with or without nit
/// | ||
/// [`DefId`]: rustc_hir::def_id::DefId | ||
/// For type aliases (whether eager or lazy), this returns the underlying aliased type. |
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.
Want to mention that it reveals the hidden type of an opaque, but type_of_opaque could be used to detect cycles? Outside of that they're functionally the same, since type_of
just calls type_of_opaque
.
fbff86e
to
c21a3ea
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
c21a3ea
to
2cfb905
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
2cfb905
to
454c09e
Compare
@bors r=compiler-errors |
Rollup of 8 pull requests Successful merges: - rust-lang#134606 (ptr::copy: fix docs for the overlapping case) - rust-lang#134622 (Windows: Use WriteFile to write to a UTF-8 console) - rust-lang#134759 (compiletest: Remove the `-test` suffix from normalize directives) - rust-lang#134787 (Spruce up the docs of several queries related to the type/trait system and const eval) - rust-lang#134806 (rustdoc: use shorter paths as preferred canonical paths) - rust-lang#134815 (Sort triples by name in platform_support.md) - rust-lang#134816 (tools: fix build failure caused by PR rust-lang#134420) - rust-lang#134819 (Fix mistake in windows file open) r? `@ghost` `@rustbot` modify labels: rollup
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)
[`Self::$query`]
to cross-link queries. Indeed, such links are generally a bit brittle due to the existence ofTyCtxtFeed
which only contains a subset of queries. Therefore the docs offeedable
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 becomesfeedable
).Self::
is nicer thanTyCtxt::
(which would be more stable) since it accounts for other contexts likeTyCtxt{Feed,At,Ensure{,WithValue}}
#[rustc_*]
TEST attributeThe one non-doc change (it's internal and not observable):
Be even more defensive in
query constness
's impl (spiritual follow-up to #134122) (see self review comment).Fixes #133494.
r? any(compiler-errors, oli-obk)