Skip to content

rustc invocation does not work with panic=abort configurations #47

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

Closed
Wilfred opened this issue Dec 26, 2016 · 2 comments
Closed

rustc invocation does not work with panic=abort configurations #47

Wilfred opened this issue Dec 26, 2016 · 2 comments

Comments

@Wilfred
Copy link

Wilfred commented Dec 26, 2016

I have a rust project that contains the following in its Cargo.toml:

# Allow unwinding in functions called from C. See
# https://www.reddit.com/r/rust/comments/565q1f/wrote_a_blogpost_from_my_experiences_the_arduous/d8h053m/
[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

The command that gets run is:

$ cargo rustc --lib -- -Z no-trans -Z unstable-options --error-format=json --test 
   Compiling remacs v0.1.0 (file:///home/wilfred/projects/remacs/rust_src)
{"message":"the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort`","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":null}
error: Could not compile `remacs`.

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

This can't be parsed by flycheck:

Suspicious state from syntax checker rust-cargo: Flycheck checker rust-cargo returned non-zero exit code 101, but its output contained no errors:
fmdkdd added a commit to flycheck/flycheck that referenced this issue Dec 27, 2016
Errors reported by rustc may not have any associated position in a file, for
instance if the error is related to the project as a whole (see
flycheck/flycheck-rust#47).

Previously, we did not collect any error without spans, thus not only
misreporting errors from rustc, but also raising a suspicious checker state.

This commit enhances `flycheck-parse-rust` to collect errors without associated
spans.  By default, these errors are bound to the position (0,0) of the current
buffer.
@fmdkdd
Copy link
Member

fmdkdd commented Dec 27, 2016

When I try the above settings on a test crate, I can indeed reproduce the issue. Thanks for the report 👍

cargo build reports no error. And removing the --test flag to cargo rustc makes the error go away. I don't really understand why rustc reports an error here, but I haven't looked into custom panic handles in Rust.

Regardless, we should be able to report the error as-is in Flycheck. It seems the suspicious state stems from not collecting errors that have empty spans (no filename info).

I've sent a PR which should fix this issue.

fmdkdd added a commit to flycheck/flycheck that referenced this issue Jan 1, 2017
Errors reported by rustc may not have any associated position in a file, for
instance if the error is related to the project as a whole (see
flycheck/flycheck-rust#47).

Previously, we did not collect any error without spans, thus not only
misreporting errors from rustc, but also raising a suspicious checker state.

This commit enhances `flycheck-parse-rust` to collect errors without associated
spans.  By default, these errors are bound to the position (0,0) of the current
buffer.
@fmdkdd
Copy link
Member

fmdkdd commented Mar 22, 2017

Fixed in flycheck/flycheck#1182.

@fmdkdd fmdkdd closed this as completed Mar 22, 2017
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

No branches or pull requests

2 participants