Skip to content

Commit 2f4b9dd

Browse files
committed
Update const_conditions and explicit_implied_const_bounds docs
Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`.
1 parent aa3c2d7 commit 2f4b9dd

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -940,12 +940,6 @@ impl<'tcx> ItemCtxt<'tcx> {
940940
}
941941
}
942942

943-
/// Compute the conditions that need to hold for a conditionally-const item to be const.
944-
/// That is, compute the set of `~const` where clauses for a given item.
945-
///
946-
/// This query also computes the `~const` where clauses for associated types, which are
947-
/// not "const", but which have item bounds which may be `~const`. These must hold for
948-
/// the `~const` item bound to hold.
949943
pub(super) fn const_conditions<'tcx>(
950944
tcx: TyCtxt<'tcx>,
951945
def_id: LocalDefId,
@@ -1063,7 +1057,9 @@ pub(super) fn explicit_implied_const_bounds<'tcx>(
10631057
def_id: LocalDefId,
10641058
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> {
10651059
if !tcx.is_conditionally_const(def_id) {
1066-
bug!("const_conditions invoked for item that is not conditionally const: {def_id:?}");
1060+
bug!(
1061+
"explicit_implied_const_bounds invoked for item that is not conditionally const: {def_id:?}"
1062+
);
10671063
}
10681064

10691065
let bounds = match tcx.opt_rpitit_info(def_id.to_def_id()) {

compiler/rustc_middle/src/query/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,15 @@ rustc_queries! {
748748
}
749749
}
750750

751+
/// Compute the conditions that need to hold for a conditionally-const item to be const.
752+
/// That is, compute the set of `~const` where clauses for a given item.
753+
///
754+
/// This can be thought of as the `~const` equivalent of `predicates_of`. These are the
755+
/// predicates that need to be proven at usage sites, and can be assumed at definition.
756+
///
757+
/// This query also computes the `~const` where clauses for associated types, which are
758+
/// not "const", but which have item bounds which may be `~const`. These must hold for
759+
/// the `~const` item bound to hold.
751760
query const_conditions(
752761
key: DefId
753762
) -> ty::ConstConditions<'tcx> {
@@ -757,6 +766,11 @@ rustc_queries! {
757766
separate_provide_extern
758767
}
759768

769+
/// Compute the const bounds that are implied for a conditionally-const item.
770+
///
771+
/// This can be though of as the `~const` equivalent of `explicit_item_bounds`. These
772+
/// are the predicates that need to proven at definition sites, and can be assumed at
773+
/// usage sites.
760774
query explicit_implied_const_bounds(
761775
key: DefId
762776
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> {

0 commit comments

Comments
 (0)