1 use crate::symbol::{sym, Symbol};
5 use rustc_macros::HashStable_Generic;
7 /// The edition of the compiler (RFC 2052)
21 // editions must be kept in order, oldest to newest
26 // when adding new editions, be sure to update:
28 // - Update the `ALL_EDITIONS` const
29 // - Update the EDITION_NAME_LIST const
30 // - add a `rust_####()` function to the session
31 // - update the enum in Cargo's sources as well
34 // must be in order from oldest to newest
35 pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018];
37 pub const EDITION_NAME_LIST: &str = "2015|2018";
39 pub const DEFAULT_EDITION: Edition = Edition::Edition2015;
41 impl fmt::Display for Edition {
42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 Edition::Edition2015 => "2015",
45 Edition::Edition2018 => "2018",
52 pub fn lint_name(&self) -> &'static str {
54 Edition::Edition2015 => "rust_2015_compatibility",
55 Edition::Edition2018 => "rust_2018_compatibility",
59 pub fn feature_name(&self) -> Symbol {
61 Edition::Edition2015 => sym::rust_2015_preview,
62 Edition::Edition2018 => sym::rust_2018_preview,
66 pub fn is_stable(&self) -> bool {
68 Edition::Edition2015 => true,
69 Edition::Edition2018 => true,
74 impl FromStr for Edition {
76 fn from_str(s: &str) -> Result<Self, ()> {
78 "2015" => Ok(Edition::Edition2015),
79 "2018" => Ok(Edition::Edition2018),