forked from rust-lang/a-mir-formality
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#lang racket | ||
(require redex/reduction-semantics | ||
"../../decl-to-clause.rkt" | ||
"../../decl-ok.rkt" | ||
"../../grammar.rkt" | ||
"../../prove.rkt" | ||
"../../../util.rkt") | ||
|
||
(module+ test | ||
;; Program: | ||
;; | ||
;; struct Foo; | ||
;; trait Bar<const N: usize> {} | ||
;; impl<const M: usize> Bar<M> for Foo {} | ||
(redex-let* | ||
formality-decl | ||
((KindedVarId_M (term ((CtKind (scalar-ty usize)) M))) | ||
(TraitDecl (term (Bar (trait ((TyKind Self) ((CtKind (scalar-ty usize)) N)) () ())))) | ||
(AdtDecl_Foo (term (Foo (struct () () ((Foo ())))))) | ||
(CtKind_M (term M)) | ||
(Ct_M (term ((scalar-ty usize) CtKind_M))) | ||
(TraitRef_Bar (term (Bar ((TyRigid Foo ()) Ct_M)))) | ||
(TraitImplDecl (term (impl (KindedVarId_M) TraitRef_Bar () ()))) | ||
(CrateDecl (term (TheCrate (crate (TraitDecl AdtDecl_Foo TraitImplDecl))))) | ||
(Env (term (env-for-crate-decl CrateDecl))) | ||
|
||
;; `TheCrate` can prove `forall<const M: usize> Bar<M>: Foo` | ||
(Goal (term (ForAll (KindedVarId_M) (Implemented TraitRef_Bar)))) | ||
) | ||
(traced '() | ||
(decl:test-can-prove Env Goal))) | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,12 @@ | |
;; lifetime, etc) | ||
;; | ||
;; Overridden from formality-logic. | ||
(ParameterKind ::= TyKind LtKind) | ||
(ParameterKind ::= TyKind LtKind (CtKind Ty)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lcnr
Author
Owner
|
||
|
||
;; Parameter: value for a generic parameter | ||
;; | ||
;; Overridden from formality-logic. | ||
(Parameter ::= Ty Lt) | ||
(Parameter ::= Ty Lt Ct) | ||
|
||
;; ANCHOR:Predicates | ||
;; `Predicate` -- the atomic items that we can prove | ||
|
@@ -99,6 +99,15 @@ | |
;; Treat ABIs as opaque strings (for now, at least) | ||
(Abi ::= string) | ||
|
||
;; Ct -- Rust constants in the type system. | ||
;; | ||
;; TODO: Also add non-leaf things here. | ||
(Ct ::= (Ty CtKind)) | ||
(CtKind ::= | ||
(Leaf number) ; A value tree leaf. | ||
VarId ; Bound, existential (inference), or universal (placeholder) variable. | ||
) | ||
|
||
;; Lt -- Rust lifetimes | ||
;; | ||
;; Very similar to types `Ty` in terms of how they are represented | ||
|
@@ -124,7 +133,7 @@ | |
(VarInequality ::= (Parameters_lb <= VarId <= Parameters_ub)) | ||
|
||
;; Scalars -- numbers, booleans | ||
(ScalarId ::= i8 u8 i16 u16 i32 u32 i64 u64 i128 u128 bool) | ||
(ScalarId ::= i8 u8 i16 u16 i32 u32 i64 u64 i128 u128 isize usize bool) | ||
|
||
;; Identifiers -- these are all equivalent, but we give them fresh names to help | ||
;; clarify their purpose | ||
|
I do wonder if we want
CtKind Ty
-- this is an interesting question. I somewhat think this should be encoded as a predicate (ConstHasTy Const Ty
or something like that). Some parts of the code assume thatParameterKind
is an atom, and I think that's a pretty valid assumption.