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

throws inserts method body for trait methods #39

Open
gmadrid opened this issue Apr 14, 2020 · 0 comments · May be fixed by #40
Open

throws inserts method body for trait methods #39

gmadrid opened this issue Apr 14, 2020 · 0 comments · May be fixed by #40

Comments

@gmadrid
Copy link

gmadrid commented Apr 14, 2020

This code:

trait Example {
    #[throws]
    fn foo();
}

expands to this:

trait Example {
    fn foo() -> ::core::result::Result<(), Error> {
        <_ as ::fehler::__internal::_Succeed>::from_ok(())
    }
}

This inserts a default method for the trait which has two annoying effects:

  1. Complaints about an extra semi-colon
  2. No complaints in trait implementations that don't provide what should be a required method.

This is using rust 1.42.0 with fehler 1.0.0.

The problem appears to be in Throws::fold because the trait method is parsed by parse for ImplItemMethod. The implementation of this function in syn includes this comment:

                // Accept methods without a body in an impl block because
                // rustc's *parser* does not reject them (the compilation error
                // is emitted later than parsing) and it can be useful for macro
                // DSLs.

which causes this problem.

@gmadrid gmadrid linked a pull request Apr 14, 2020 that will close this issue
Nemo157 added a commit to Nemo157/culpa that referenced this issue Jun 29, 2023
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.

1 participant