From fec0e04fc2a3d7dc3ef49f43aa31cdff0a5f4cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 18 Dec 2023 16:13:41 +0200 Subject: [PATCH] Add minimal support for the 2024 edition --- crates/base-db/src/input.rs | 3 +++ crates/hir-def/src/nameres/collector.rs | 2 ++ crates/project-model/src/cargo_workspace.rs | 1 + crates/project-model/src/project_json.rs | 3 +++ 4 files changed, 9 insertions(+) diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs index c2472363aa..b7e821b685 100644 --- a/crates/base-db/src/input.rs +++ b/crates/base-db/src/input.rs @@ -398,6 +398,7 @@ pub enum Edition { Edition2015, Edition2018, Edition2021, + Edition2024, } impl Edition { @@ -784,6 +785,7 @@ impl FromStr for Edition { "2015" => Edition::Edition2015, "2018" => Edition::Edition2018, "2021" => Edition::Edition2021, + "2024" => Edition::Edition2024, _ => return Err(ParseEditionError { invalid_input: s.to_string() }), }; Ok(res) @@ -796,6 +798,7 @@ impl fmt::Display for Edition { Edition::Edition2015 => "2015", Edition::Edition2018 => "2018", Edition::Edition2021 => "2021", + Edition::Edition2024 => "2024", }) } } diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs index b3a10a3869..a292207de7 100644 --- a/crates/hir-def/src/nameres/collector.rs +++ b/crates/hir-def/src/nameres/collector.rs @@ -545,6 +545,8 @@ impl DefCollector<'_> { Edition::Edition2015 => name![rust_2015], Edition::Edition2018 => name![rust_2018], Edition::Edition2021 => name![rust_2021], + // FIXME: update this when rust_2024 exists + Edition::Edition2024 => name![rust_2021], }; let path_kind = match self.def_map.data.edition { diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs index ca3d6e0596..d89c4598af 100644 --- a/crates/project-model/src/cargo_workspace.rs +++ b/crates/project-model/src/cargo_workspace.rs @@ -330,6 +330,7 @@ impl CargoWorkspace { cargo_metadata::Edition::E2015 => Edition::Edition2015, cargo_metadata::Edition::E2018 => Edition::Edition2018, cargo_metadata::Edition::E2021 => Edition::Edition2021, + cargo_metadata::Edition::_E2024 => Edition::Edition2024, _ => { tracing::error!("Unsupported edition `{:?}`", edition); Edition::CURRENT diff --git a/crates/project-model/src/project_json.rs b/crates/project-model/src/project_json.rs index 931eba1157..cf3231498f 100644 --- a/crates/project-model/src/project_json.rs +++ b/crates/project-model/src/project_json.rs @@ -213,6 +213,8 @@ enum EditionData { Edition2018, #[serde(rename = "2021")] Edition2021, + #[serde(rename = "2024")] + Edition2024, } impl From for Edition { @@ -221,6 +223,7 @@ impl From for Edition { EditionData::Edition2015 => Edition::Edition2015, EditionData::Edition2018 => Edition::Edition2018, EditionData::Edition2021 => Edition::Edition2021, + EditionData::Edition2024 => Edition::Edition2024, } } }