]>
git.proxmox.com Git - rustc.git/blob - src/libsyntax/edition.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use std
::str::FromStr
;
14 /// The edition of the compiler (RFC 2052)
15 #[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)]
18 // editions must be kept in order, newest to oldest
25 // when adding new editions, be sure to update:
27 // - Update the `ALL_EDITIONS` const
28 // - Update the EDITION_NAME_LIST const
29 // - add a `rust_####()` function to the session
30 // - update the enum in Cargo's sources as well
33 // must be in order from oldest to newest
34 pub const ALL_EDITIONS
: &[Edition
] = &[Edition
::Edition2015
, Edition
::Edition2018
];
36 pub const EDITION_NAME_LIST
: &'
static str = "2015|2018";
38 pub const DEFAULT_EDITION
: Edition
= Edition
::Edition2015
;
40 impl fmt
::Display
for Edition
{
41 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
43 Edition
::Edition2015
=> "2015",
44 Edition
::Edition2018
=> "2018",
51 pub fn lint_name(&self) -> &'
static str {
53 Edition
::Edition2015
=> "rust_2015_breakage",
54 Edition
::Edition2018
=> "rust_2018_breakage",
58 pub fn feature_name(&self) -> &'
static str {
60 Edition
::Edition2015
=> "rust_2015_preview",
61 Edition
::Edition2018
=> "rust_2018_preview",
65 pub fn is_stable(&self) -> bool
{
67 Edition
::Edition2015
=> true,
68 Edition
::Edition2018
=> false,
73 impl FromStr
for Edition
{
75 fn from_str(s
: &str) -> Result
<Self, ()> {
77 "2015" => Ok(Edition
::Edition2015
),
78 "2018" => Ok(Edition
::Edition2018
),