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

Produce a more useful error message when rustfmt can't be found. Fixes #1205 #1501

Merged
merged 2 commits into from
Jan 25, 2019

Conversation

luser
Copy link
Contributor

@luser luser commented Jan 25, 2019

Prior to this change bindgen would simply print any error that occurred
while attempting to run rustfmt straight to stderr using fmt::Debug.
Combined with the fact that rustfmt is enabled by default now this meant
that if rustfmt was missing or not working a cryptic error would be
printed.

Without this patch:

$ PATH= ./target/debug/bindgen /tmp/foo.h
Custom { kind: Other, error: StringError("Cannot find binary path") }
/* automatically generated by rust-bindgen */

With this patch:

$ PATH= ./target/debug/bindgen /tmp/foo.h
Failed to run rustfmt: Cannot find binary path (non-fatal, continuing)
/* automatically generated by rust-bindgen */

I changed the error handling to use fmt::Display instead, since this
is user-visible output, and also added "Failed to run rustfmt:" to make the
source of the error clearer. Additionally since bindgen does not treat this
as fatal I noted that in the output as well.

ripgrep was failing to search in the bindgen repo:
```
./.gitignore: line 19: error parsing glob '**.orig': invalid use of **; must be one path component
```

Per the gitignore docs it seems like ripgrep is correct and this line is
invalid: https://git-scm.com/docs/gitignore#_pattern_format
…rust-lang#1205

Prior to this change bindgen would simply print any error that occurred
while attempting to run rustfmt straight to stderr using fmt::Debug.
Combined with the fact that rustfmt is enabled by default now this meant that
if rustfmt was missing or not working a cryptic error would be printed.
Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@emilio emilio merged commit 3dddbbd into rust-lang:master Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants