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

(macro-hygiene) ramhorn derive codegen clashes with syn::Result #37

Closed
creativcoder opened this issue Oct 13, 2020 · 2 comments · Fixed by #39
Closed

(macro-hygiene) ramhorn derive codegen clashes with syn::Result #37

creativcoder opened this issue Oct 13, 2020 · 2 comments · Fixed by #39
Labels
good first issue Good for newcomers

Comments

@creativcoder
Copy link
Contributor

creativcoder commented Oct 13, 2020

Hi @maciejhirsz

Thank you for this library!

While using ramhorns in my project: I have a use case where I need to use both syn and ramhorn together.

Following is the minimal reproducible example:

use syn::Result;

use ramhorns::{Content};

#[derive(Content)]
struct Post<'a> {
    title: &'a str
}

But, On running cargo build, I get the following error:

error[E0107]: wrong number of type arguments: expected 1, found 2
  --> src/main.rs:53:10
   |
53 | #[derive(Content)]
   |          ^^^^^^^ unexpected type argument
   |
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error; 7 warnings emitted

For more information about this error, try `rustc --explain E0107`.

From what i understand, The code generated by ramhorn-derive generates Result<...> on Content's traits methods and that clashes with syn::Result. And as you can see the error message is also misleading.

What's the best way to solve this? I could alias my import of syn, but consider a larger project which imports ramhorn and derive and also has a syn::Result imported already, they might not know where to look for this error. As my example was small, I was able remove code incrementally and figured this out.

@maciejhirsz
Copy link
Owner

That should be fairly simple to fix, the derive macro just needs to explicitly produce std::result::Result instead of Result in the output token stream.

@creativcoder
Copy link
Contributor Author

Thanks, just made a PR for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants