diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-11 09:41:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-11 09:41:23 +0000 |
commit | 1b8d4521db39ca1c1610eb43ba9f7f9000054b5c (patch) | |
tree | 05b5e63cfa35230b4a3e9cf01d095fd55ae35111 | |
parent | 2669e80c17f4c9d8b534c73ae0c60a51de0b4659 (diff) | |
parent | 46e0068fc0128207ac69bde5cb53d7eeb6943cbb (diff) | |
download | gcc-1b8d4521db39ca1c1610eb43ba9f7f9000054b5c.zip gcc-1b8d4521db39ca1c1610eb43ba9f7f9000054b5c.tar.gz gcc-1b8d4521db39ca1c1610eb43ba9f7f9000054b5c.tar.bz2 |
Merge #1091
1091: Add -frust-edition flag and possible values r=CohenArthur a=CohenArthur
Closes #1072
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
-rw-r--r-- | gcc/rust/lang.opt | 16 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 4 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.h | 12 |
3 files changed, 32 insertions, 0 deletions
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index 86a063f..a6dabbf 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -83,6 +83,22 @@ frust-cfg= Rust Joined RejectNegative -frust-cfg=<name> Set a config expansion option +frust-edition= +Rust Joined RejectNegative Enum(frust_edition) Var(flag_rust_edition) +-frust-edition=[2015|2018|2021] Choose which edition to use when compiling rust code + +Enum +Name(frust_edition) Type(int) UnknownError(unknown rust edition %qs) + +EnumValue +Enum(frust_edition) String(2015) Value(0) + +EnumValue +Enum(frust_edition) String(2018) Value(1) + +EnumValue +Enum(frust_edition) String(2021) Value(2) + o Rust Joined Separate ; Documented in common.opt diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index f3010aa..6b1d030 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -373,6 +373,10 @@ Session::handle_option ( break; } + case OPT_frust_edition_: + options.set_edition (flag_rust_edition); + break; + default: break; } diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 99d1628..c5420db 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -184,6 +184,13 @@ struct CompileOptions bool enable_test = false; bool debug_assertions = false; bool proc_macro = false; + enum Edition + { + E2015 = 0, + E2018, + E2021, + } edition + = E2015; bool dump_option_enabled (DumpOption option) const { @@ -211,6 +218,11 @@ struct CompileOptions crate_name = std::move (name); return true; } + + void set_edition (int raw_edition) + { + edition = static_cast<Edition> (raw_edition); + } }; /* Defines a compiler session. This is for a single compiler invocation, so |