2

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.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Kent Marete
  • 117
  • 1
  • 6
  • 1
    Part of the template you were provided with says: *Paste the part of the code that shows the problem*, but you seem to have forgotten that step. We can't provide any information without that. – Shepmaster Dec 06 '17 at 20:39
  • What version of Rust are you using? – Shepmaster Dec 06 '17 at 20:39
  • What does the code look like? – takendarkk Dec 06 '17 at 20:39
  • Why would OP have source code handy for vendored code that is failing to compile – Matt Dec 06 '17 at 20:41
  • 1
    @Matt (1) bitflags is an open-source project (2) I'm not asking for the source code of bitflags but for the project configuration and code that OP used to trigger the error (3) If OP can't provide a way for an answerer to reproduce the error (an [MCVE]), then the question is unlikely to be a good fit for Stack Overflow. – Shepmaster Dec 06 '17 at 20:46
  • Trust me I am familiar with the SO culture for this. Still think it's weird you are citing _Paste the part of the code that shows the problem_ - Just asking him to post Rust version etc would've been far better advice. People are too trigger-happy on the downvotes too, sheesh – Matt Dec 06 '17 at 20:48
  • 1
    @Matt and many people believe that downvotes cannot be removed once a question or answer has been improved. I'll downvote when a Q or A is in bad shape and remove it once it's fixed — all a part of signaling to the OP and other readers the relative quality of a given post. – Shepmaster Dec 06 '17 at 21:01

1 Answers1

7

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.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Kent Marete
  • 117
  • 1
  • 6