Const predicates in where clauses - #1508
Draft
micahscopes wants to merge 2 commits into
Draft
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.