-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Fixes to the Rust compiler - Support for newtypes wrapping other newtypes - Full conversions between newtypes and primitive types - Support for methods on newtypes - It also adds an attribute `{:rust_erased true/false}` for newtypes to override the default erasure setting for newtypes, which is: * Newtypes without members: Erased (so that we can see Rust's native types like u8, u32, etc.) * Newtypes with members: Not erased (to improve legibility of the code in Rust) - Support for general newtypes on booleans - Support in the generated Rust AST for metadata on types, to know if a type supports Copy or now. Previously it had to be known statically for primitive, but now with newtypes we need to embed this information into the tree. - Support for wrapping operations for bitvectors and newtypes based on bitvectors ### Fixes for new resolver - I fixed in the new resolver the case of ITEExpr where it was overriding the PreType of the test instead of constraining it. ### Refactoring - WrBuffer() makes it easy to handle buffers ### How has this been tested? - Modified the test comp/rust/newtypes.dfy to support all the new cases, including use of the attribute `{:rust_erased}` and various cases - Added test case newtypesrefresh.dfy for the newtypes on booleans - Had to fix the code to make existing tests to pass <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
- Loading branch information
1 parent
b998ed9
commit 435c669
Showing
26 changed files
with
4,088 additions
and
2,979 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
32 changes: 32 additions & 0 deletions
32
Source/DafnyCore.Test/GeneratedFromDafny/DafnyToRustCompilerCoverage.cs
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 @@ | ||
// Dafny program the_program compiled into C# | ||
// To recompile, you will need the libraries | ||
// System.Runtime.Numerics.dll System.Collections.Immutable.dll | ||
// but the 'dotnet' tool in net6.0 should pick those up automatically. | ||
// Optionally, you may want to include compiler switches like | ||
// /debug /nowarn:162,164,168,183,219,436,1717,1718 | ||
|
||
using System; | ||
using System.Numerics; | ||
using System.Collections; | ||
#pragma warning disable CS0164 // This label has not been referenced | ||
#pragma warning disable CS0162 // Unreachable code detected | ||
#pragma warning disable CS1717 // Assignment made to same variable | ||
|
||
namespace DafnyToRustCompilerCoverage { | ||
|
||
public partial class __default { | ||
public static void TestIsCopy() | ||
{ | ||
if (!(Defs.__default.IsNewtypeCopy(DAST.NewtypeRange.create_Bool()))) { | ||
throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-coverage.dfy(9,4): " + Dafny.Sequence<Dafny.Rune>.UnicodeFromString("expectation violation").ToVerbatimString(false));} | ||
if (!(Defs.__default.IsNewtypeCopy(DAST.NewtypeRange.create_U128(true)))) { | ||
throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-coverage.dfy(10,4): " + Dafny.Sequence<Dafny.Rune>.UnicodeFromString("expectation violation").ToVerbatimString(false));} | ||
if (!(Defs.__default.IsNewtypeCopy(DAST.NewtypeRange.create_U128(false)))) { | ||
throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-coverage.dfy(11,4): " + Dafny.Sequence<Dafny.Rune>.UnicodeFromString("expectation violation").ToVerbatimString(false));} | ||
if (!(!(Defs.__default.IsNewtypeCopy(DAST.NewtypeRange.create_BigInt())))) { | ||
throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-coverage.dfy(12,4): " + Dafny.Sequence<Dafny.Rune>.UnicodeFromString("expectation violation").ToVerbatimString(false));} | ||
if (!(!(Defs.__default.IsNewtypeCopy(DAST.NewtypeRange.create_NoRange())))) { | ||
throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-coverage.dfy(13,4): " + Dafny.Sequence<Dafny.Rune>.UnicodeFromString("expectation violation").ToVerbatimString(false));} | ||
} | ||
} | ||
} // end of namespace DafnyToRustCompilerCoverage |
165 changes: 0 additions & 165 deletions
165
Source/DafnyCore.Test/GeneratedFromDafny/DafnyToRustCompilerCoverage_RASTCoverage.cs
This file was deleted.
Oops, something went wrong.
165 changes: 165 additions & 0 deletions
165
Source/DafnyCore.Test/GeneratedFromDafny/RASTCoverage.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.