Skip to content

Commit 1b8d452

Browse files
Merge #1091
1091: Add -frust-edition flag and possible values r=CohenArthur a=CohenArthur Closes #1072 Co-authored-by: Arthur Cohen <[email protected]>
2 parents 2669e80 + 46e0068 commit 1b8d452

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

gcc/rust/lang.opt

+16
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ frust-cfg=
8383
Rust Joined RejectNegative
8484
-frust-cfg=<name> Set a config expansion option
8585

86+
frust-edition=
87+
Rust Joined RejectNegative Enum(frust_edition) Var(flag_rust_edition)
88+
-frust-edition=[2015|2018|2021] Choose which edition to use when compiling rust code
89+
90+
Enum
91+
Name(frust_edition) Type(int) UnknownError(unknown rust edition %qs)
92+
93+
EnumValue
94+
Enum(frust_edition) String(2015) Value(0)
95+
96+
EnumValue
97+
Enum(frust_edition) String(2018) Value(1)
98+
99+
EnumValue
100+
Enum(frust_edition) String(2021) Value(2)
101+
86102
o
87103
Rust Joined Separate
88104
; Documented in common.opt

gcc/rust/rust-session-manager.cc

+4
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ Session::handle_option (
373373
break;
374374
}
375375

376+
case OPT_frust_edition_:
377+
options.set_edition (flag_rust_edition);
378+
break;
379+
376380
default:
377381
break;
378382
}

gcc/rust/rust-session-manager.h

+12
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ struct CompileOptions
184184
bool enable_test = false;
185185
bool debug_assertions = false;
186186
bool proc_macro = false;
187+
enum Edition
188+
{
189+
E2015 = 0,
190+
E2018,
191+
E2021,
192+
} edition
193+
= E2015;
187194

188195
bool dump_option_enabled (DumpOption option) const
189196
{
@@ -211,6 +218,11 @@ struct CompileOptions
211218
crate_name = std::move (name);
212219
return true;
213220
}
221+
222+
void set_edition (int raw_edition)
223+
{
224+
edition = static_cast<Edition> (raw_edition);
225+
}
214226
};
215227

216228
/* Defines a compiler session. This is for a single compiler invocation, so

0 commit comments

Comments
 (0)