options: Add -frust-edition flag and possible values

Co-authored-by: liushuyu <liushuyu011@gmail.com>
This commit is contained in:
Arthur Cohen 2022-04-07 15:30:49 +02:00
parent b829e7c0a2
commit 46e0068fc0
3 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -373,6 +373,10 @@ Session::handle_option (
break;
}
case OPT_frust_edition_:
options.set_edition (flag_rust_edition);
break;
default:
break;
}

View File

@ -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