Skip to content
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

Support for 2018 edition? #35

Closed
matthewpflueger opened this issue Oct 9, 2018 · 3 comments · Fixed by #36
Closed

Support for 2018 edition? #35

matthewpflueger opened this issue Oct 9, 2018 · 3 comments · Fixed by #36

Comments

@matthewpflueger
Copy link

Hi, I recently tried using ructe in a 2018 edition project. Unfortunately the templates are generated with the old style absolute paths like:

error[E0432]: unresolved import `templates`
 --> /opt/jezila/ructe/examples/simple/target/debug/build/simple-3b5f8e3dc18a428a/out/templates/template_list.rs:4:7
  |
use ::templates::{Html,ToHtml};
  |       ^^^^^^^^^ Did you mean `crate::templates`?

Is there a way to tell ructe to generate with new style paths (that start with crate)? Please excuse my ignorance if there is an obvious answer - I'm pretty new with Rust...

Love the library btw!

@kaj
Copy link
Owner

kaj commented Oct 9, 2018

Thank you!

I havn't really looked at the 2018 edition concept yet, but yes, ideally ructe should recognize if the project it is a build dependency of has enabled the 2018 edition, and if so generate the new-style use lines. I don't know if that is possible.

If it can't be done "automagically", it could be either a parameter set in the build script or a feature defined on the dependency. I guess a future would be the best way then?

I'll look into it.

@kaj
Copy link
Owner

kaj commented Oct 9, 2018

I have asked for an environment variable to use at https://users.rust-lang.org/t/detect-edition-2018-from-cargo-build-rs/21134 .

Failing that, I now think it would be better to actually look for an edition setting in $CARGO_MANIFEST_DIR/Cargo.toml than to require a feature flag or a call parameter in build.rs itself.

kaj added a commit that referenced this issue Oct 10, 2018
A use-path was incompatible with rust edition 2018.  Express it in a
different way, that should be compatible with both rust edition 2015
and edition 2018.

This should fix #35.
kaj added a commit that referenced this issue Oct 10, 2018
A use-path was incompatible with rust edition 2018.  Express it in a
different way, that should be compatible with both rust edition 2015
and edition 2018.

This should fix #35.
@kaj
Copy link
Owner

kaj commented Oct 10, 2018

It seems that it is possible to formulate the use lines in such a way that they are compatible with both edition 2015 and edition 2018, so my current hope is that detecting edition 2018 should not be necessary. There are still some details that fails, but I hope to get back to it in a few hours.

kaj added a commit that referenced this issue Oct 10, 2018
A use-path was incompatible with rust edition 2018.  Express it in a
different way, that should be compatible with both rust edition 2015
and edition 2018.

This should fix #35.
@kaj kaj closed this as completed in #36 Oct 10, 2018
kaj added a commit that referenced this issue Nov 3, 2018
* Support multiple Content arguments.

  Impl Trait is used to make sub-templates as arguments less magic.
  This way we can also support more than one Content argument to the
  same template.

* PR #36 / Issue #35: Test and fix support for edition=2018.
  Module paths used by generated code are now compatible with the 2018
  edition.  Also, some code in examples and documentation use more
  2018-friendly module paths.

* PR 34: Use bytecount rather than simple counting, elide one lifetime.

* Update nom to 4.1.1, base64 to 0.10.0, bytecount to 0.4, and md5 to 0.5.

* Update iron to 0.6 and warp to 0.1.9 in examples.

* Minor cleanup in nickel example.

Thanks to @KlossPeter for PR #34 and @matthewpflueger for issue #35.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants