-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from nikomatsakis/fn-decls-match
check that fn decls in impls/traits match
- Loading branch information
Showing
5 changed files
with
188 additions
and
1 deletion.
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,34 @@ | ||
#lang racket | ||
(require redex/reduction-semantics | ||
"../grammar.rkt" | ||
"../prove.rkt" | ||
"../../ty/user-ty.rkt" | ||
"../../util.rkt" | ||
"libcore.rkt" | ||
) | ||
|
||
(module+ test | ||
(redex-let* | ||
formality-decl | ||
|
||
[(; trait Get { fn get<T>(&mut self) where T: Debug; } | ||
TraitDecl_Get | ||
(term (trait Get ((type Self)) where () | ||
{(fn get[(type T) (lifetime l)]((user-ty (&mut l Self))) -> (user-ty ()) where [(T : Debug[])] {}) | ||
})) | ||
) | ||
(; impl Get for () { fn get<T>(&mut self) where T: Debug; } | ||
TraitImplDecl_Get | ||
(term (impl[] (Get[(user-ty ())]) where [] | ||
{ | ||
(fn get[(type T) (lifetime l)]((user-ty (&mut l ()))) -> (user-ty ()) where [(T : Debug[])] {}) | ||
})) | ||
) | ||
] | ||
|
||
(traced '() | ||
(test-equal | ||
(term (decl:is-crate-ok [core-crate-decl (C (crate [TraitDecl_Get TraitImplDecl_Get]))] C)) | ||
#t)) | ||
) | ||
) |
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,37 @@ | ||
#lang racket | ||
(require redex/reduction-semantics | ||
"../grammar.rkt" | ||
"../prove.rkt" | ||
"../../ty/user-ty.rkt" | ||
"../../util.rkt" | ||
"libcore.rkt" | ||
) | ||
|
||
(module+ test | ||
(redex-let* | ||
formality-decl | ||
|
||
[(; trait Get { fn get<T>(&mut self) where T: Debug; } | ||
TraitDecl_Get | ||
(term (trait Get ((type Self)) where () | ||
{(fn get[(type T) (lifetime l)]((user-ty (&mut l Self))) -> (user-ty ()) where [(T : Debug[])] {}) | ||
})) | ||
) | ||
|
||
(; impl Get for () { fn get<T>(&self) where T: Debug; } | ||
; ----- ERROR | ||
TraitImplDecl_Get | ||
(term (impl[] (Get[(user-ty ())]) where [] | ||
{ | ||
(fn get[(type T) (lifetime l)]((user-ty (& l ()))) -> (user-ty ()) where [(T : Debug[])] {}) | ||
})) | ||
) | ||
] | ||
|
||
(traced '() | ||
(test-equal | ||
(term (decl:is-crate-ok [core-crate-decl (C (crate [TraitDecl_Get TraitImplDecl_Get]))] C)) | ||
#f)) | ||
) | ||
) | ||
|
36 changes: 36 additions & 0 deletions
36
src/decl/test/fn-in-impl-vs-trait-too-few-where-clause.rkt
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,36 @@ | ||
#lang racket | ||
(require redex/reduction-semantics | ||
"../grammar.rkt" | ||
"../prove.rkt" | ||
"../../ty/user-ty.rkt" | ||
"../../util.rkt" | ||
"libcore.rkt" | ||
) | ||
|
||
(module+ test | ||
(redex-let* | ||
formality-decl | ||
|
||
[(; trait Get { fn get<T>(&mut self) where T: Debug; } | ||
TraitDecl_Get | ||
(term (trait Get ((type Self)) where () | ||
{ | ||
(fn get[(type T) (lifetime l)]((user-ty (&mut l Self))) -> (user-ty ()) where [(T : Debug[])] {}) | ||
})) | ||
) | ||
|
||
(; impl Get for () { fn get<T>(&mut self) /* where T: Debug */ ; | ||
; -------------- OK} | ||
TraitImplDecl_Get | ||
(term (impl[] (Get[(user-ty ())]) where [] | ||
{(fn get[(type T) (lifetime l)]((user-ty (&mut l ()))) -> (user-ty ()) where [] {}) | ||
})) | ||
) | ||
] | ||
|
||
(traced '() | ||
(test-equal | ||
(term (decl:is-crate-ok [core-crate-decl (C (crate [TraitDecl_Get TraitImplDecl_Get]))] C)) | ||
#t)) | ||
) | ||
) |
39 changes: 39 additions & 0 deletions
39
src/decl/test/fn-in-impl-vs-trait-too-many-where-clause.rkt
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,39 @@ | ||
#lang racket | ||
(require redex/reduction-semantics | ||
"../grammar.rkt" | ||
"../prove.rkt" | ||
"../../ty/user-ty.rkt" | ||
"../../util.rkt" | ||
"libcore.rkt" | ||
) | ||
|
||
(module+ test | ||
(redex-let* | ||
formality-decl | ||
|
||
[(; trait Get { fn get<T>(&mut self) where T: Debug; } | ||
TraitDecl_Get | ||
(term (trait Get ((type Self)) where () | ||
{ | ||
(fn get[(type T) (lifetime l)]((user-ty (&mut l Self))) -> (user-ty ()) where [(T : Debug[])] {}) | ||
})) | ||
) | ||
|
||
(; impl Get for () { fn get<T>(&mut self) where T: Debug, T: Copy; | ||
; ------- ERROR} | ||
TraitImplDecl_Get | ||
(term (impl[] (Get[(user-ty ())]) where [] | ||
{(fn get[(type T) (lifetime l)]((user-ty (&mut l ()))) -> (user-ty ()) | ||
where [(T : Debug[]) | ||
(T : rust:Copy[]) | ||
] {}) | ||
})) | ||
) | ||
] | ||
|
||
(traced '() | ||
(test-equal | ||
(term (decl:is-crate-ok [core-crate-decl (C (crate [TraitDecl_Get TraitImplDecl_Get]))] C)) | ||
#f)) | ||
) | ||
) |