public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] options: Add -frust-edition flag and possible values
@ 2022-06-08 12:26 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:26 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:46e0068fc0128207ac69bde5cb53d7eeb6943cbb
commit 46e0068fc0128207ac69bde5cb53d7eeb6943cbb
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Apr 7 15:30:49 2022 +0200
options: Add -frust-edition flag and possible values
Co-authored-by: liushuyu <liushuyu011@gmail.com>
Diff:
---
gcc/rust/lang.opt | 16 ++++++++++++++++
gcc/rust/rust-session-manager.cc | 4 ++++
gcc/rust/rust-session-manager.h | 12 ++++++++++++
3 files changed, 32 insertions(+)
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=<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 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<Edition> (raw_edition);
+ }
};
/* Defines a compiler session. This is for a single compiler invocation, so
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:26 [gcc/devel/rust/master] options: Add -frust-edition flag and possible values Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).