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

Give a better error message when not compiling on Windows #38

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

jyn514
Copy link
Contributor

@jyn514 jyn514 commented Oct 29, 2020

Before:

error[E0433]: failed to resolve: could not find `windows` in `os`
   --> src/lib.rs:121:14
    |
121 | use std::os::windows::ffi::OsStrExt;
    |              ^^^^^^^ could not find `windows` in `os`

error[E0433]: failed to resolve: could not find `shared` in `winapi`
   --> src/lib.rs:127:17
    |
127 | pub use winapi::shared::minwindef::HKEY;
    |                 ^^^^^^ could not find `shared` in `winapi`

... several dozen more errors ...

After:

$ cargo check
   Compiling winreg v0.7.0 (/home/joshua/src/rust/winreg-rs)
error: failed to run custom build command for `winreg v0.7.0 (/home/joshua/src/rust/winreg-rs)`

Caused by:
  process didn't exit successfully: `/home/joshua/.local/lib/cargo/target/debug/build/winreg-7bb8e6b8b363c511/build-script-build` (exit code: 1)
  --- stderr
  error: winreg is only supported on Windows platforms
  help: if your application is multi-platform, use `[target.'cfg(windows)'.dependencies] winreg = "..."`
  help: if your application is only supported on Windows, use `--target x86_64-pc-windows-gnu` or some other windows platform

Before:

```
error[E0433]: failed to resolve: could not find `windows` in `os`
   --> src/lib.rs:121:14
    |
121 | use std::os::windows::ffi::OsStrExt;
    |              ^^^^^^^ could not find `windows` in `os`

error[E0433]: failed to resolve: could not find `shared` in `winapi`
   --> src/lib.rs:127:17
    |
127 | pub use winapi::shared::minwindef::HKEY;
    |                 ^^^^^^ could not find `shared` in `winapi`

... several dozen more errors ...
```

After:

```
$ cargo check
   Compiling winreg v0.7.0 (/home/joshua/src/rust/winreg-rs)
error: failed to run custom build command for `winreg v0.7.0 (/home/joshua/src/rust/winreg-rs)`

Caused by:
  process didn't exit successfully: `/home/joshua/.local/lib/cargo/target/debug/build/winreg-7bb8e6b8b363c511/build-script-build` (exit code: 1)
  --- stderr
  error: winreg is only supported on Windows platforms
  help: if your application is multi-platform, use `[target.'cfg(windows)'.dependencies] winreg = "..."`
  help: if your application is only supported on Windows, use `--target x86_64-pc-windows-gnu` or some other windows platform
```
@gentoo90 gentoo90 merged commit 4c1de2c into gentoo90:master Dec 11, 2020
@gentoo90
Copy link
Owner

Thanks!

@jyn514 jyn514 deleted the compile-error branch December 11, 2020 17:48
@jyn514
Copy link
Contributor Author

jyn514 commented Dec 11, 2020

Note that if retep998/winapi-rs#949 ever gets merged, you could revert this and it would save you a build script. But this makes the error nicer until then.

@gentoo90
Copy link
Owner

Published to https://crates.io/crates/winreg/0.8.0

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