Kent Marete
Kent Marete

Reputation: 117

Why does compiling bitflags 1.0 produce an "expected ident, found #" error?

When I try to build a project in Rust with bitflags v1.0.1 in macOS Sierra 10.12.6 the code fails with the following error:

Compiling bitflags v1.0.1
error: expected ident, found #
   --> /Users/kenneth.marete/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.0.1/src/lib.rs:423:29
    |
423 |                               #[allow(deprecated)]
    |                               ^
    | 
   ::: /Users/kenneth.marete/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.0.1/src/example_generated.rs
    |
4   | / bitflags! {
5   | |     /// This is the same `Flags` struct defined in the [crate level example](../index.html#example).
6   | |     /// Note that this struct is just for documentation purposes only, it must not be used outside
7   | |     /// this crate.
...   |
13  | |     }
14  | | }
    | |_- in this macro invocation

I expected it to build successfully.

Upvotes: 2

Views: 391

Answers (1)

Kent Marete
Kent Marete

Reputation: 117

Some crates may fail to compile due to compiling with a version of Rust older than the minimum required. It has nothing to do with the OS version or the application itself.

I had rustc 1.19.0 (0ade33941 2017-07-17) while bitflags version 1.0.1 had a minimum supported Rust version of 1.20 due to the use of associated constants.

From time to time, update the Rust compiler by running rustup update.

Upvotes: 7

Related Questions