diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index 86a063f000c..a6dabbfd727 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -83,6 +83,22 @@ frust-cfg= Rust Joined RejectNegative -frust-cfg= 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 f3010aa914e..6b1d03077f1 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 99d16287973..c5420db22ab 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 (raw_edition); + } }; /* Defines a compiler session. This is for a single compiler invocation, so