Skip to content

Commit 935535d

Browse files
authored
Rollup merge of rust-lang#137837 - fee1-dead-contrib:push-pvqvwuvrnwsy, r=compiler-errors
Update `const_conditions` and `explicit_implied_const_bounds` docs Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`. r? project-const-traits
2 parents 878f383 + 2f4b9dd commit 935535d

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Diff for: compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,6 @@ impl<'tcx> ItemCtxt<'tcx> {
937937
}
938938
}
939939

940-
/// Compute the conditions that need to hold for a conditionally-const item to be const.
941-
/// That is, compute the set of `~const` where clauses for a given item.
942-
///
943-
/// This query also computes the `~const` where clauses for associated types, which are
944-
/// not "const", but which have item bounds which may be `~const`. These must hold for
945-
/// the `~const` item bound to hold.
946940
pub(super) fn const_conditions<'tcx>(
947941
tcx: TyCtxt<'tcx>,
948942
def_id: LocalDefId,
@@ -1060,7 +1054,9 @@ pub(super) fn explicit_implied_const_bounds<'tcx>(
10601054
def_id: LocalDefId,
10611055
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> {
10621056
if !tcx.is_conditionally_const(def_id) {
1063-
bug!("const_conditions invoked for item that is not conditionally const: {def_id:?}");
1057+
bug!(
1058+
"explicit_implied_const_bounds invoked for item that is not conditionally const: {def_id:?}"
1059+
);
10641060
}
10651061

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

Diff for: 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)