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

empty struct fails with proc macro #101

Closed
drahnr opened this Issue Jul 4, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@drahnr

drahnr commented Jul 4, 2018

Hi djc,

not sure if this is a general rust issue or an implementation detail in askama (I might be just too silly to pass the right terms to my fav search engine).

#[derive(Template)];
struct Index; // no struct members
error: proc-macro derive panicked
  --> src/main.rs:18:10
   |
18 | #[derive(Template)]
   |          ^^^^^^^^
   |
   = help: message: derive(Template) only works for struct items

error: aborting due to previous error

error: Could not compile `cantaloupe`.

To learn more, run the command again with --verbose.

$ rustc --version
rustc 1.27.0 (3eda71b00 2018-06-19)
@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 4, 2018

Owner

This is Askama-specific. It probably works if you make it struct Index {};?

Owner

djc commented Jul 4, 2018

This is Askama-specific. It probably works if you make it struct Index {};?

@drahnr

This comment has been minimized.

Show comment
Hide comment
@drahnr

drahnr Jul 4, 2018

Yes indeed! Adding {} makes it compile (if I also add either a new or default impl since Index.render().unwrap() won't work anymore).

drahnr commented Jul 4, 2018

Yes indeed! Adding {} makes it compile (if I also add either a new or default impl since Index.render().unwrap() won't work anymore).

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 4, 2018

Owner

You can similarly do Index {}.render().unwrap() (maybe needs some extra parentheses).

Owner

djc commented Jul 4, 2018

You can similarly do Index {}.render().unwrap() (maybe needs some extra parentheses).

@drahnr

This comment has been minimized.

Show comment
Hide comment
@drahnr

drahnr Jul 4, 2018

True, didn't think of that.

EDIT:

Just verified: Works as expected.

drahnr commented Jul 4, 2018

True, didn't think of that.

EDIT:

Just verified: Works as expected.

@djc djc closed this in 191e56a Jul 4, 2018

djc added a commit that referenced this issue Jul 4, 2018

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 4, 2018

Owner

So I've decided to lift the restrictions here, so you can now use any kind of struct as the context.

Owner

djc commented Jul 4, 2018

So I've decided to lift the restrictions here, so you can now use any kind of struct as the context.

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 4, 2018

Owner

And thanks for reporting!

Owner

djc commented Jul 4, 2018

And thanks for reporting!

@drahnr

This comment has been minimized.

Show comment
Hide comment
@drahnr

drahnr Jul 4, 2018

Awesome, thank you! As always, incredible turn around times :)

drahnr commented Jul 4, 2018

Awesome, thank you! As always, incredible turn around times :)

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 4, 2018

Owner

It helps that we're timezone-aligned 😊

Owner

djc commented Jul 4, 2018

It helps that we're timezone-aligned 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment