Rustc flag for edition=2018

Hi there,

I am from CodinGame.com where we have rust support for our programming games. For various reasons (no internet access from chroot, speed of execution) we are using rustc directly (i.e. not through Cargo).

I could not find a way to pass the "edition=2018" option from the Cargo.toml file to rustc. Does anyone have an idea what rustc flag to use to compile in "2018" mode?

Thanks.

1 Like

For me:

% rustc --version
rustc 1.35.0-nightly (3eb4890df 2019-03-19)
% rustc --help -v | grep edition
        --edition 2015|2018
                        Specify which edition of the compiler to use when
2 Likes

--edition 2018

Additionally, cargo build -v is useful for figuring out what cargo passes to rustc in different situations.

1 Like

FWIW, Cargo does not require network access. The playground does not have network access when compiling user-submitted code and it uses Cargo.

3 Likes

Thank you everyone

Thank you @dekellum for reminding me to do a --version . That was the root cause of my problem: I was looking at the help from the previous version, so could not find the edition flag. How stupid!

Thank you @kyrias for the cargo build -v tip. It will be very helpful moving forward.

@shepmaster, does this mean that some crates were preinstalled on the playground? I could use "rand" for example from the playground. So I am curious on how you did this.

Does this mean that some crates were preinstalled on the playground? I could use "rand" for example from the playground.

Yes. Here is a list of preinstalled crates: https://github.com/integer32llc/rust-playground/blob/master/top-crates/crate-modifications.toml

That is actually a list of manual modifications to the available crates. The precise list is https://github.com/integer32llc/rust-playground/blob/master/compiler/base/Cargo.toml

Basically, we pre-build all the crates we care about on a Docker image. This step has network access. At user submission time, we start the container without network access, pass the user input in, compile and run it.

Thanks @sanxiyn and @shepmaster I will try to replicate this behavior for our CodinGame.com users.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.