4 /// The edition of the compiler (RFC 2052)
5 #[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable, Eq)]
7 // editions must be kept in order, oldest to newest
14 // when adding new editions, be sure to update:
16 // - Update the `ALL_EDITIONS` const
17 // - Update the EDITION_NAME_LIST const
18 // - add a `rust_####()` function to the session
19 // - update the enum in Cargo's sources as well
22 // must be in order from oldest to newest
23 pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018];
25 pub const EDITION_NAME_LIST: &str = "2015|2018";
27 pub const DEFAULT_EDITION: Edition = Edition::Edition2015;
29 impl fmt::Display for Edition {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 Edition::Edition2015 => "2015",
33 Edition::Edition2018 => "2018",
40 pub fn lint_name(&self) -> &'static str {
42 Edition::Edition2015 => "rust_2015_compatibility",
43 Edition::Edition2018 => "rust_2018_compatibility",
47 pub fn feature_name(&self) -> &'static str {
49 Edition::Edition2015 => "rust_2015_preview",
50 Edition::Edition2018 => "rust_2018_preview",
54 pub fn is_stable(&self) -> bool {
56 Edition::Edition2015 => true,
57 Edition::Edition2018 => true,
62 impl FromStr for Edition {
64 fn from_str(s: &str) -> Result<Self, ()> {
66 "2015" => Ok(Edition::Edition2015),
67 "2018" => Ok(Edition::Edition2018),