Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

example seems broken #70

Closed
m4b opened this issue Nov 23, 2016 · 11 comments
Closed

example seems broken #70

m4b opened this issue Nov 23, 2016 · 11 comments

Comments

@m4b
Copy link

m4b commented Nov 23, 2016

From the github README, I click on quickstart, look at the example.

I then copied the example with macro , except I added an errors.rs module, turn off default features, add the recursion limit, macro_use, bla bla, and put this inside errors.rs:

error_chain! {
    foreign_links {
        // An IO error can occur.
        Io(::std::io::Error);
    }
}

this won't compile with:

error: no rules expected the token `;`
 --> <error_chain macros>:8:42
  |
8 | types { $ error_name , $ error_kind_name ; } $ ( $ rest ) * }
  |                                          ^

error: Could not compile `goblin`.

Which is impossible for me to understand or debug.

If I remove the foreign link it compiles as expected.

Side note: I've tried to use this library about 3 times and I always end up rolling my own errors or just using something like quick_error because of issues like this.

I'm probably just dumb?

@zimond
Copy link

zimond commented Nov 23, 2016

ran into this too, so at least you are not alone

@zimond
Copy link

zimond commented Nov 23, 2016

Ok, I figured it out that the syntax has changed to:

foreign_links {
  ::std::io::Error, Io;
}

The quickstart's just outdated

@Yamakaky
Copy link
Contributor

Hum, in fact the quickstart is not outdated, it just compiles on master and not 0.6.

@colin-kiegel
Copy link

This is a Problem with looking up docs on GitHub. I strongly recommend using docs.rs https://docs.rs/error-chain :-)

@m4b
Copy link
Author

m4b commented Nov 23, 2016

@colin-kiegel See above comment

Also the code is from an example file... (The link redirects to the examples/quickstart.rs file)

@Yamakaky
Copy link
Contributor

I do, it's just that rust-lang/rust#15470

@Yamakaky
Copy link
Contributor

Yamakaky commented Nov 23, 2016

I could always copy it manually, but the advantage of examples/ is that it's compiled with cargo test, so that it's never outdated. Any idea?

@colin-kiegel
Copy link

The most recent readme from docs.rs does not link any example.rs on the master branch

https://docs.rs/crate/error-chain/0.6.1/source/README.md

What's your Cargo.toml? If you use the standard package from crates.io you should not consider any documentation on github, but rather docs.rs. Or are you downloading this crate from github?

@Yamakaky
Copy link
Contributor

Yeah, the link towards example.rs was added after 0.6.1.

I build the doc for master.

@m4b
Copy link
Author

m4b commented Nov 24, 2016

I literally have no idea what's going on here but:

  1. Everything I said above is still correct
  2. @daiheitan suggestion to change to new syntax works (thank you)
  3. The example somehow compiles despite this
  4. I have no idea why

I'd suggest someone to fix the example to match the syntax in the docs. That's what I'd do.

@m4b m4b closed this as completed Nov 24, 2016
@Yamakaky
Copy link
Contributor

In fact, e5c06b7 was added after 0.6.1, so 0.6.1 uses the old the syntax. The trouble is that when you go to https://github.com/brson/error-chain, you see the README for master, with the new syntax.
I think that at next release, I will keep master for the current release and indev for the unreleased stuff. That way, when you go to the repo, you see the README for the latest release.
Sorry for the inconvenience.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants