From 4833972067c00170269c7ee7a04f1a8ce1e1d15b Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 1 Jan 2021 17:22:23 +0100 Subject: Add support for Rust 2021. --- crates/base_db/src/input.rs | 7 +++++-- crates/ide/src/runnables.rs | 2 +- crates/ide/src/syntax_highlighting/injection.rs | 2 +- crates/project_model/src/project_json.rs | 3 +++ crates/rust-analyzer/src/markdown.rs | 2 +- docs/user/manual.adoc | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 9567bcc42..2dd8fbe67 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -190,10 +190,11 @@ pub struct CrateData { pub proc_macro: Vec, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Edition { - Edition2018, Edition2015, + Edition2018, + Edition2021, } #[derive(Default, Debug, Clone, PartialEq, Eq)] @@ -393,6 +394,7 @@ impl FromStr for Edition { let res = match s { "2015" => Edition::Edition2015, "2018" => Edition::Edition2018, + "2021" => Edition::Edition2021, _ => return Err(ParseEditionError { invalid_input: s.to_string() }), }; Ok(res) @@ -404,6 +406,7 @@ impl fmt::Display for Edition { f.write_str(match self { Edition::Edition2015 => "2015", Edition::Edition2018 => "2018", + Edition::Edition2021 => "2021", }) } } diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 891183266..c893afc7c 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs @@ -230,7 +230,7 @@ impl TestAttr { const RUSTDOC_FENCE: &str = "```"; const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUNNABLE: &[&str] = - &["", "rust", "should_panic", "edition2015", "edition2018"]; + &["", "rust", "should_panic", "edition2015", "edition2018", "edition2021"]; fn has_runnable_doc_test(attrs: &hir::Attrs) -> bool { attrs.docs().map_or(false, |doc| { diff --git a/crates/ide/src/syntax_highlighting/injection.rs b/crates/ide/src/syntax_highlighting/injection.rs index 9eb184c74..3fd414f80 100644 --- a/crates/ide/src/syntax_highlighting/injection.rs +++ b/crates/ide/src/syntax_highlighting/injection.rs @@ -55,7 +55,7 @@ type RangesMap = BTreeMap; const RUSTDOC_FENCE: &'static str = "```"; const RUSTDOC_FENCE_TOKENS: &[&'static str] = - &["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018"]; + &["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018", "edition2021"]; /// Extracts Rust code from documentation comments as well as a mapping from /// the extracted source code back to the original source ranges. diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index aab279223..af884eb84 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs @@ -139,6 +139,8 @@ enum EditionData { Edition2015, #[serde(rename = "2018")] Edition2018, + #[serde(rename = "2021")] + Edition2021, } impl From for Edition { @@ -146,6 +148,7 @@ impl From for Edition { match data { EditionData::Edition2015 => Edition::Edition2015, EditionData::Edition2018 => Edition::Edition2018, + EditionData::Edition2021 => Edition::Edition2021, } } } diff --git a/crates/rust-analyzer/src/markdown.rs b/crates/rust-analyzer/src/markdown.rs index 968ea55f0..2f1dcc9a5 100644 --- a/crates/rust-analyzer/src/markdown.rs +++ b/crates/rust-analyzer/src/markdown.rs @@ -2,7 +2,7 @@ const RUSTDOC_FENCE: &str = "```"; const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] = - &["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018"]; + &["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018", "edition2021"]; pub(crate) fn format_docs(src: &str) -> String { let mut processed_lines = Vec::new(); diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index d4121b401..75445a02e 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc @@ -339,7 +339,7 @@ interface Crate { /// Path to the root module of the crate. root_module: string; /// Edition of the crate. - edition: "2015" | "2018"; + edition: "2015" | "2018" | "2021"; /// Dependencies deps: Dep[]; /// Should this crate be treated as a member of current "workspace". -- cgit v1.2.3