Skip to content

internal: Add minimal support for the 2024 edition #16151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ pub enum Edition {
Edition2015,
Edition2018,
Edition2021,
Edition2024,
}

impl Edition {
Expand Down Expand Up @@ -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)
Expand All @@ -796,6 +798,7 @@ impl fmt::Display for Edition {
Edition::Edition2015 => "2015",
Edition::Edition2018 => "2018",
Edition::Edition2021 => "2021",
Edition::Edition2024 => "2024",
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/hir-def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions crates/project-model/src/cargo_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions crates/project-model/src/project_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ enum EditionData {
Edition2018,
#[serde(rename = "2021")]
Edition2021,
#[serde(rename = "2024")]
Edition2024,
}

impl From<EditionData> for Edition {
Expand All @@ -221,6 +223,7 @@ impl From<EditionData> for Edition {
EditionData::Edition2015 => Edition::Edition2015,
EditionData::Edition2018 => Edition::Edition2018,
EditionData::Edition2021 => Edition::Edition2021,
EditionData::Edition2024 => Edition::Edition2024,
}
}
}
Expand Down