diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/base_db/src/input.rs | 7 | ||||
-rw-r--r-- | crates/ide/src/runnables.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/injection.rs | 13 | ||||
-rw-r--r-- | crates/project_model/src/project_json.rs | 3 | ||||
-rw-r--r-- | crates/rust-analyzer/src/markdown.rs | 13 |
5 files changed, 31 insertions, 7 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 { | |||
190 | pub proc_macro: Vec<ProcMacro>, | 190 | pub proc_macro: Vec<ProcMacro>, |
191 | } | 191 | } |
192 | 192 | ||
193 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 193 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
194 | pub enum Edition { | 194 | pub enum Edition { |
195 | Edition2018, | ||
196 | Edition2015, | 195 | Edition2015, |
196 | Edition2018, | ||
197 | Edition2021, | ||
197 | } | 198 | } |
198 | 199 | ||
199 | #[derive(Default, Debug, Clone, PartialEq, Eq)] | 200 | #[derive(Default, Debug, Clone, PartialEq, Eq)] |
@@ -393,6 +394,7 @@ impl FromStr for Edition { | |||
393 | let res = match s { | 394 | let res = match s { |
394 | "2015" => Edition::Edition2015, | 395 | "2015" => Edition::Edition2015, |
395 | "2018" => Edition::Edition2018, | 396 | "2018" => Edition::Edition2018, |
397 | "2021" => Edition::Edition2021, | ||
396 | _ => return Err(ParseEditionError { invalid_input: s.to_string() }), | 398 | _ => return Err(ParseEditionError { invalid_input: s.to_string() }), |
397 | }; | 399 | }; |
398 | Ok(res) | 400 | Ok(res) |
@@ -404,6 +406,7 @@ impl fmt::Display for Edition { | |||
404 | f.write_str(match self { | 406 | f.write_str(match self { |
405 | Edition::Edition2015 => "2015", | 407 | Edition::Edition2015 => "2015", |
406 | Edition::Edition2018 => "2018", | 408 | Edition::Edition2018 => "2018", |
409 | Edition::Edition2021 => "2021", | ||
407 | }) | 410 | }) |
408 | } | 411 | } |
409 | } | 412 | } |
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 { | |||
230 | 230 | ||
231 | const RUSTDOC_FENCE: &str = "```"; | 231 | const RUSTDOC_FENCE: &str = "```"; |
232 | const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUNNABLE: &[&str] = | 232 | const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUNNABLE: &[&str] = |
233 | &["", "rust", "should_panic", "edition2015", "edition2018"]; | 233 | &["", "rust", "should_panic", "edition2015", "edition2018", "edition2021"]; |
234 | 234 | ||
235 | fn has_runnable_doc_test(attrs: &hir::Attrs) -> bool { | 235 | fn has_runnable_doc_test(attrs: &hir::Attrs) -> bool { |
236 | attrs.docs().map_or(false, |doc| { | 236 | 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..6cbd683c6 100644 --- a/crates/ide/src/syntax_highlighting/injection.rs +++ b/crates/ide/src/syntax_highlighting/injection.rs | |||
@@ -54,8 +54,17 @@ pub(super) fn highlight_injection( | |||
54 | type RangesMap = BTreeMap<TextSize, TextSize>; | 54 | type RangesMap = BTreeMap<TextSize, TextSize>; |
55 | 55 | ||
56 | const RUSTDOC_FENCE: &'static str = "```"; | 56 | const RUSTDOC_FENCE: &'static str = "```"; |
57 | const RUSTDOC_FENCE_TOKENS: &[&'static str] = | 57 | const RUSTDOC_FENCE_TOKENS: &[&'static str] = &[ |
58 | &["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018"]; | 58 | "", |
59 | "rust", | ||
60 | "should_panic", | ||
61 | "ignore", | ||
62 | "no_run", | ||
63 | "compile_fail", | ||
64 | "edition2015", | ||
65 | "edition2018", | ||
66 | "edition2021", | ||
67 | ]; | ||
59 | 68 | ||
60 | /// Extracts Rust code from documentation comments as well as a mapping from | 69 | /// Extracts Rust code from documentation comments as well as a mapping from |
61 | /// the extracted source code back to the original source ranges. | 70 | /// 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 { | |||
139 | Edition2015, | 139 | Edition2015, |
140 | #[serde(rename = "2018")] | 140 | #[serde(rename = "2018")] |
141 | Edition2018, | 141 | Edition2018, |
142 | #[serde(rename = "2021")] | ||
143 | Edition2021, | ||
142 | } | 144 | } |
143 | 145 | ||
144 | impl From<EditionData> for Edition { | 146 | impl From<EditionData> for Edition { |
@@ -146,6 +148,7 @@ impl From<EditionData> for Edition { | |||
146 | match data { | 148 | match data { |
147 | EditionData::Edition2015 => Edition::Edition2015, | 149 | EditionData::Edition2015 => Edition::Edition2015, |
148 | EditionData::Edition2018 => Edition::Edition2018, | 150 | EditionData::Edition2018 => Edition::Edition2018, |
151 | EditionData::Edition2021 => Edition::Edition2021, | ||
149 | } | 152 | } |
150 | } | 153 | } |
151 | } | 154 | } |
diff --git a/crates/rust-analyzer/src/markdown.rs b/crates/rust-analyzer/src/markdown.rs index 968ea55f0..a49a58c00 100644 --- a/crates/rust-analyzer/src/markdown.rs +++ b/crates/rust-analyzer/src/markdown.rs | |||
@@ -1,8 +1,17 @@ | |||
1 | //! Transforms markdown | 1 | //! Transforms markdown |
2 | 2 | ||
3 | const RUSTDOC_FENCE: &str = "```"; | 3 | const RUSTDOC_FENCE: &str = "```"; |
4 | const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] = | 4 | const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] = &[ |
5 | &["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018"]; | 5 | "", |
6 | "rust", | ||
7 | "should_panic", | ||
8 | "ignore", | ||
9 | "no_run", | ||
10 | "compile_fail", | ||
11 | "edition2015", | ||
12 | "edition2018", | ||
13 | "edition2021", | ||
14 | ]; | ||
6 | 15 | ||
7 | pub(crate) fn format_docs(src: &str) -> String { | 16 | pub(crate) fn format_docs(src: &str) -> String { |
8 | let mut processed_lines = Vec::new(); | 17 | let mut processed_lines = Vec::new(); |