Skip to content

Issue a better error message if the target is unsupported. #110

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

Merged
merged 1 commit into from
May 10, 2025

Conversation

sunfishcode
Copy link
Collaborator

Following an idea from in #76, add a sys.rs file, which only gets used if the target isn't recognized, and use compile_error to give a meaningful error message instead of cryptically failing on the compiler being unable to open sys.rs.

For example, using --target=wasm32-unknown-unknown now gets this error:

$ cargo check --target=wasm32-unknown-unknown
    Checking errno v0.3.11
error: The target OS is "unknown" or "none", so it's unsupported by the errno crate.
 --> src/sys.rs:8:1
  |
8 | compile_error!("The target OS is \"unknown\" or \"none\", so it's unsupported by the errno crate.");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `errno` (lib) due to 1 previous error

Following an idea from in lambda-fairy#76, add a sys.rs file, which only gets used
if the target isn't recognized, and use `compile_error` to give a
meaningful error message instead of cryptically failing on the compiler
being unable to open sys.rs.

For example, using --target=wasm32-unknown-unknown now gets this error:

```console
$ cargo check --target=wasm32-unknown-unknown
    Checking errno v0.3.11
error: The target OS is "unknown" or "none", so it's unsupported by the errno crate.
 --> src/sys.rs:8:1
  |
8 | compile_error!("The target OS is \"unknown\" or \"none\", so it's unsupported by the errno crate.");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `errno` (lib) due to 1 previous error
```
@lambda-fairy lambda-fairy merged commit a9bd71e into lambda-fairy:main May 10, 2025
12 checks passed
@lambda-fairy
Copy link
Owner

Looks great, thanks!

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 this pull request may close these issues.

2 participants