Skip to content

Const predicates in where clauses - #1508

Draft
micahscopes wants to merge 2 commits into
argotorg:masterfrom
micahscopes:ctfe-where-predicates
Draft

Const predicates in where clauses#1508
micahscopes wants to merge 2 commits into
argotorg:masterfrom
micahscopes:ctfe-where-predicates

Conversation

@micahscopes

Copy link
Copy Markdown
Collaborator

No description provided.

…ompatible)

Complete the concrete-only half of CTFE where-clause const predicates: declaration-site evaluation of parameter-free predicates, concrete call-site discharge via first-class deferred obligations, and ADT well-formedness discharge at construction, signature, field, and body positions. All discharge runs via CTFE at the well-formedness/obligation layer, never inside the trait solver.

The abstract/assumption route (proving a predicate on a still-symbolic parameter via a caller's own where-clause assumptions) is intentionally dropped at the marked seam in ty_check/mod.rs for FCO to re-add. A symbolic-argument predicate is reported as a concrete-only deferred failure rather than being proven or ICEing.

Dropped scope, deferred to FCO: symbolic-parameter assumption discharge; impl-vs-trait method const-predicate compatibility; the ConstPredicateObligation call-origin metadata (re-added alongside the assumption route).

Route all well-formedness diagnostic consumers (parameter, field, type-alias, impl-assoc-type, and body-expression WF) through WellFormedness::into_diag so a refuted const predicate surfaces uniformly as error 8-0085. Render const predicates in where-clause pretty-print. Add concrete-only fixtures for pretty-print and type-check; drop the tree-sitter syntax_node fixture since the tree-sitter grammar does not model const-expression predicates.
The CST formatter walked only trait-bound predicates (`WhereClause::iter()`),
so `fe fmt` silently dropped where-clause const predicates (`where N > 0`,
`where T::SIZE >= 50`, and the brace form `where { .. }`). Render both predicate
kinds via a `where_clause_predicate_doc` helper plus a `ToDoc for
WhereConstPredicate` impl, and count const predicates in the where-clause
emptiness guards so a const-predicate-only clause is not skipped.

Guard the behavior with an inline formatter test rather than a `tests/fixtures`
`.fe` file, since the tree-sitter grammar does not yet model const-expression
predicates and a fixture would trip `tree_sitter_parse_strict` (grammar support
is a separate follow-up).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant