-
Notifications
You must be signed in to change notification settings - Fork 279
Feat: Add --rust-module-name to specify a module name #5747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Compiler now can write to a concrete syntax tree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation LGTM, but would love a test case to verify what this unlocks.
@@ -1675,7 +1675,9 @@ module {:extern "DCOMP"} DafnyToRustCompiler { | |||
ASSIGNED_PREFIX + "_" + rustName | |||
} | |||
|
|||
datatype ObjectType = RawPointers | RcMut | |||
datatype PointerType = Raw | RcMut | |||
datatype CharType = UTF16 | Unicode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Unicode" is too vague to be much help, consider UTF32 instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be too much to ask for a test case of a manually-written Rust crate, with manually-written Rust code and a Cargo.toml, where you use dafny translate
to add additional code under a given --rust-module-name
, and use cargo test
to verify that all works?
That's the killer application of this option by itself: not forcing the output of Dafny to be the top level namespace, and enabling incremental adoption of Dafny into an existing Rust project!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test written. I removed the other one since it was obsolete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
Fixes partially #5641
This PR adds
--rust-module-name
so that all absolute paths from crate insert the given module name after "crate" if the option is provided.Description
I could have made it a boolean option since it should match the name of the generated file, but by consistency with other backends, I made it so that the option accepts any string. Let me know if you think a boolean would be better.
How has this been tested?
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.