Tenders McChiken
Tenders McChiken

Reputation: 1543

How do I specify the edition to use when compiling code using rustc?

I want to use rustc to compile a project written in Rust 2018 but I don't know how to switch the compiler from the default edition. The manpage for rustc mentions nothing about editions and the builtin attributes don't seem to contain anything relevant either. I'm using the Debian version of rustc (1.58.1) which was built earlier this year so it should support all three editions.

What do I need to do to get rustc to treat my code as Rust '18?

Upvotes: 2

Views: 925

Answers (1)

Tenders McChiken
Tenders McChiken

Reputation: 1543

At least on Debian, the manual page that ships with Rust is incomplete. Passing --help to rustc shows that the relavent flag to set is --edition:

Usage: rustc [OPTIONS] INPUT

Options:
    -h, --help          Display this message
        --cfg SPEC      Configure the compilation environment
[...]
        --edition 2015|2018|2021
                        Specify which edition of the compiler to use when
                        compiling code.

Upvotes: 2

Related Questions