Skip to content

Commit 3719fa9

Browse files
authored
Unrolled build for rust-lang#134787
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)
2 parents 42591a4 + 454c09e commit 3719fa9

File tree

3 files changed

+223
-106
lines changed

3 files changed

+223
-106
lines changed

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,14 @@ fn parent_impl_constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness
1515
}
1616
}
1717

18-
/// Checks whether an item is considered to be `const`. If it is a constructor, it is const.
19-
/// If it is an assoc method or function,
20-
/// return if it has a `const` modifier. If it is an intrinsic, report whether said intrinsic
21-
/// has a `rustc_const_{un,}stable` attribute. Otherwise, panic.
18+
/// Checks whether a function-like definition is considered to be `const`.
2219
fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness {
2320
let node = tcx.hir_node_by_def_id(def_id);
2421

2522
match node {
26-
hir::Node::Ctor(hir::VariantData::Tuple(..))
27-
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) => {
28-
hir::Constness::Const
29-
}
30-
hir::Node::ForeignItem(_) => {
31-
// Foreign items cannot be evaluated at compile-time.
23+
hir::Node::Ctor(hir::VariantData::Tuple(..)) => hir::Constness::Const,
24+
hir::Node::ForeignItem(item) if let hir::ForeignItemKind::Fn(..) = item.kind => {
25+
// Foreign functions cannot be evaluated at compile-time.
3226
hir::Constness::NotConst
3327
}
3428
hir::Node::Expr(e) if let hir::ExprKind::Closure(c) = e.kind => c.constness,

0 commit comments

Comments
 (0)