Skip to content

getrandom no longer compiles with cfg-if 1.0.2 #90

@sfackler

Description

@sfackler

Seems like something's broken with the macro parsing:

error[E0428]: the name `NonZeroRawOsError` is defined multiple times
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:17:9
   |
13 |         type NonZeroRawOsError = core::num::NonZeroUsize;
   |         ------------------------------------------------- previous definition of the type `NonZeroRawOsError` here
...
17 |         type NonZeroRawOsError = core::num::NonZeroI32;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `NonZeroRawOsError` redefined here
   |
   = note: `NonZeroRawOsError` must be defined only once in the type namespace of this module

error: expected `;`, found reserved identifier `$crate`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:201:68
    |
199 | /             cfg_if! {
200 | |                 if #[cfg(feature = "std")] {
201 | |                     std::io::Error::from_raw_os_error(errno).fmt(f)
    | |                                                                    ^ help: add `;` here
202 | |                 } else {
...   |
205 | |             }
    | |             -
    | |             |
    | |_____________unexpected token
    |               only `;` terminated statements or tail expressions are allowed after this attribute

error: expected `;`, found reserved identifier `$crate`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:203:53
    |
199 | /             cfg_if! {
200 | |                 if #[cfg(feature = "std")] {
201 | |                     std::io::Error::from_raw_os_error(errno).fmt(f)
202 | |                 } else {
203 | |                     write!(f, "OS Error: {}", errno)
    | |                                                     ^ help: add `;` here
204 | |                 }
205 | |             }
    | |             -
    | |             |
    | |_____________unexpected token
    |               only `;` terminated statements or tail expressions are allowed after this attribute

error[E0432]: unresolved import `__errno`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends/../util_libc.rs:22:13
   |
22 |         use __errno as errno_location;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `__errno`

error[E0432]: unresolved import `custom`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:12:17
   |
12 |         pub use custom::*;
   |                 ^^^^^^ use of unresolved module or unlinked crate `custom`
   |
   = help: if you wanted to use a crate named `custom`, use `cargo add custom` to add it to your `Cargo.toml`

error[E0432]: unresolved import `getrandom`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:15:17
   |
15 |         pub use getrandom::*;
   |                 ^^^^^^^^^ use of unresolved module or unlinked crate `getrandom`
   |
   = help: if you wanted to use a crate named `getrandom`, use `cargo add getrandom` to add it to your `Cargo.toml`

error[E0432]: unresolved import `linux_raw`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:18:17
   |
18 |         pub use linux_raw::*;
   |                 ^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw`
   |
   = help: if you wanted to use a crate named `linux_raw`, use `cargo add linux_raw` to add it to your `Cargo.toml`

error[E0432]: unresolved import `rdrand`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:21:17
   |
21 |         pub use rdrand::*;
   |                 ^^^^^^ use of unresolved module or unlinked crate `rdrand`
   |
   = help: if you wanted to use a crate named `rdrand`, use `cargo add rdrand` to add it to your `Cargo.toml`

error[E0432]: unresolved import `rndr`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:24:17
   |
24 |         pub use rndr::*;
   |                 ^^^^ use of unresolved module or unlinked crate `rndr`
   |
   = help: if you wanted to use a crate named `rndr`, use `cargo add rndr` to add it to your `Cargo.toml`

error[E0432]: unresolved import `efi_rng`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:27:17
   |
27 |         pub use efi_rng::*;
   |                 ^^^^^^^ use of unresolved module or unlinked crate `efi_rng`
   |
   = help: if you wanted to use a crate named `efi_rng`, use `cargo add efi_rng` to add it to your `Cargo.toml`

error[E0432]: unresolved import `linux_raw`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:43:17
   |
43 |         pub use linux_raw::*;
   |                 ^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw`
   |
   = help: if you wanted to use a crate named `linux_raw`, use `cargo add linux_raw` to add it to your `Cargo.toml`

error[E0432]: unresolved import `esp_idf`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:46:17
   |
46 |         pub use esp_idf::*;
   |                 ^^^^^^^ use of unresolved module or unlinked crate `esp_idf`
   |
   = help: if you wanted to use a crate named `esp_idf`, use `cargo add esp_idf` to add it to your `Cargo.toml`

error[E0432]: unresolved import `use_file`
  --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:54:17
   |
54 |         pub use use_file::*;
   |                 ^^^^^^^^ use of unresolved module or unlinked crate `use_file`
   |
   = help: if you wanted to use a crate named `use_file`, use `cargo add use_file` to add it to your `Cargo.toml`

error[E0432]: unresolved import `super::use_file`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends/linux_android_with_fallback.rs:2:5
    |
2   | use super::use_file;
    |     ^^^^^^^^^^^^^^^ no `use_file` in `backends`
    |
note: found an item that was configured out
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:53:13
    |
53  |         mod use_file;
    |             ^^^^^^^^
note: the item is gated here
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:9:1
    |
9   | / cfg_if! {
10  | |     if #[cfg(getrandom_backend = "custom")] {
11  | |         mod custom;
12  | |         pub use custom::*;
...   |
181 | | }
    | |_^
note: found an item that was configured out
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:100:13
    |
100 |         mod use_file;
    |             ^^^^^^^^
note: the item is gated here
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:9:1
    |
9   | / cfg_if! {
10  | |     if #[cfg(getrandom_backend = "custom")] {
11  | |         mod custom;
12  | |         pub use custom::*;
...   |
181 | | }
    | |_^
    = note: this error originates in the macro `$crate::cfg_if` which comes from the expansion of the macro `cfg_if` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0432]: unresolved import `getrandom`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:116:17
    |
116 |         pub use getrandom::*;
    |                 ^^^^^^^^^ use of unresolved module or unlinked crate `getrandom`
    |
    = help: if you wanted to use a crate named `getrandom`, use `cargo add getrandom` to add it to your `Cargo.toml`

error[E0432]: unresolved import `solaris`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:119:17
    |
119 |         pub use solaris::*;
    |                 ^^^^^^^ use of unresolved module or unlinked crate `solaris`
    |
    = help: if you wanted to use a crate named `solaris`, use `cargo add solaris` to add it to your `Cargo.toml`

error[E0432]: unresolved import `netbsd`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:122:17
    |
122 |         pub use netbsd::*;
    |                 ^^^^^^ use of unresolved module or unlinked crate `netbsd`
    |
    = help: if you wanted to use a crate named `netbsd`, use `cargo add netbsd` to add it to your `Cargo.toml`

error[E0432]: unresolved import `fuchsia`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:125:17
    |
125 |         pub use fuchsia::*;
    |                 ^^^^^^^ use of unresolved module or unlinked crate `fuchsia`
    |
    = help: if you wanted to use a crate named `fuchsia`, use `cargo add fuchsia` to add it to your `Cargo.toml`

error[E0432]: unresolved import `apple_other`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:133:17
    |
133 |         pub use apple_other::*;
    |                 ^^^^^^^^^^^ use of unresolved module or unlinked crate `apple_other`
    |
    = help: if you wanted to use a crate named `apple_other`, use `cargo add apple_other` to add it to your `Cargo.toml`

error[E0432]: unresolved import `hermit`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:151:17
    |
151 |         pub use hermit::*;
    |                 ^^^^^^ use of unresolved module or unlinked crate `hermit`
    |
    = help: if you wanted to use a crate named `hermit`, use `cargo add hermit` to add it to your `Cargo.toml`

error[E0432]: unresolved import `vxworks`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:154:17
    |
154 |         pub use vxworks::*;
    |                 ^^^^^^^ use of unresolved module or unlinked crate `vxworks`
    |
    = help: if you wanted to use a crate named `vxworks`, use `cargo add vxworks` to add it to your `Cargo.toml`

error[E0432]: unresolved import `solid`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:157:17
    |
157 |         pub use solid::*;
    |                 ^^^^^ use of unresolved module or unlinked crate `solid`
    |
    = help: if you wanted to use a crate named `solid`, use `cargo add solid` to add it to your `Cargo.toml`

error[E0432]: unresolved import `windows7`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:160:17
    |
160 |         pub use windows7::*;
    |                 ^^^^^^^^ use of unresolved module or unlinked crate `windows7`
    |
    = help: if you wanted to use a crate named `windows7`, use `cargo add windows7` to add it to your `Cargo.toml`

error[E0432]: unresolved import `windows`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:163:17
    |
163 |         pub use windows::*;
    |                 ^^^^^^^ use of unresolved module or unlinked crate `windows`
    |
    = help: if you wanted to use a crate named `windows`, use `cargo add windows` to add it to your `Cargo.toml`

error[E0432]: unresolved import `rdrand`
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:166:17
    |
166 |         pub use rdrand::*;
    |                 ^^^^^^ use of unresolved module or unlinked crate `rdrand`
    |
    = help: if you wanted to use a crate named `rdrand`, use `cargo add rdrand` to add it to your `Cargo.toml`

error[E0659]: `fill_inner` is ambiguous
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/lib.rs:99:19
    |
99  |         backends::fill_inner(dest)?;
    |                   ^^^^^^^^^^ ambiguous name
    |
    = note: ambiguous because of multiple glob imports of a name in the same module
note: `fill_inner` could refer to the function imported here
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:62:17
    |
62  |         pub use getentropy::*;
    |                 ^^^^^^^^^^^^^
    = help: consider adding an explicit import of `fill_inner` to disambiguate
note: `fill_inner` could also refer to the function imported here
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:102:17
    |
102 |         pub use linux_android_with_fallback::*;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: consider adding an explicit import of `fill_inner` to disambiguate

error[E0308]: mismatched types
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:56:47
    |
56  |             let code = NonZeroRawOsError::new(code).expect("`code` is negative");
    |                        ---------------------- ^^^^ expected `usize`, found `i32`
    |                        |
    |                        arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/sfackler/.rustup/toolchains/1.87.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:375:18
    |
375 |     pub const fn new(n: T) -> Option<Self> {
    |                  ^^^
help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit
    |
56  |             let code = NonZeroRawOsError::new(code.try_into().unwrap()).expect("`code` is negative");
    |                                                   ++++++++++++++++++++

error[E0308]: mismatched types
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:118:17
    |
88  |     pub fn raw_os_error(self) -> Option<RawOsError> {
    |                                  ------------------ expected `Option<i32>` because of return type
...
118 |                 code.checked_neg()
    |                 ^^^^^^^^^^^^^^^^^^ expected `Option<i32>`, found `Option<usize>`
    |
    = note: expected enum `Option<i32>`
               found enum `Option<usize>`

error[E0308]: mismatched types
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:120:22
    |
120 |                 Some(code)
    |                 ---- ^^^^ expected `i32`, found `usize`
    |                 |
    |                 arguments to this enum variant are incorrect
    |
help: the type constructed contains `usize` due to the type of the argument passed
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:120:17
    |
120 |                 Some(code)
    |                 ^^^^^----^
    |                      |
    |                      this argument influences the type of `Some`
note: tuple variant defined here
   --> /Users/sfackler/.rustup/toolchains/1.87.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:580:5
    |
580 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^
help: you can convert a `usize` to an `i32` and panic if the converted value doesn't fit
    |
120 |                 Some(code.try_into().unwrap())
    |                          ++++++++++++++++++++

error[E0308]: mismatched types
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:129:57
    |
129 |         Error(unsafe { NonZeroRawOsError::new_unchecked(code) })
    |                        -------------------------------- ^^^^ expected `usize`, found `i32`
    |                        |
    |                        arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/sfackler/.rustup/toolchains/1.87.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:391:25
    |
391 |     pub const unsafe fn new_unchecked(n: T) -> Self {
    |                         ^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> /Users/sfackler/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/error.rs:136:57
    |
136 |         Error(unsafe { NonZeroRawOsError::new_unchecked(code) })
    |                        -------------------------------- ^^^^ expected `usize`, found `i32`
    |                        |
    |                        arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/sfackler/.rustup/toolchains/1.87.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:391:25
    |
391 |     pub const unsafe fn new_unchecked(n: T) -> Self {
    |                         ^^^^^^^^^^^^^

Some errors have detailed explanations: E0308, E0428, E0432, E0659.
For more information about an error, try `rustc --explain E0308`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions