Skip to content

Commit 8abe8e8

Browse files
authored
Update Rust edition to 2024 and use stable rustfmt (#341)
1 parent 81a5fd1 commit 8abe8e8

File tree

6 files changed

+16
-51
lines changed

6 files changed

+16
-51
lines changed

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,9 @@ jobs:
6363
runs-on: ubuntu-latest
6464
steps:
6565
- uses: actions/checkout@v4
66-
- uses: dtolnay/rust-toolchain@master
67-
with:
68-
toolchain: nightly-2025-02-01
69-
components: rustfmt
7066
- uses: dtolnay/rust-toolchain@stable
7167
- uses: Swatinem/rust-cache@v2
72-
- run: cargo +nightly-2025-02-01 fmt --check
68+
- run: cargo fmt --check
7369
- run: cargo lint
7470
env:
7571
# Make sure CI fails on all warnings, including Clippy lints.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "cairo-language-server"
33
version = "2.10.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
authors = ["Software Mansion <contact@swmansion.com>", "StarkWare <info@starkware.co>"]
77
description = "The Cairo Language Server"

rustfmt.toml

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,2 @@
1-
edition = "2021"
2-
newline_style = "unix"
3-
use_field_init_shorthand = true
4-
use_small_heuristics = "Max"
5-
use_try_shorthand = true
6-
max_width = 100
7-
8-
# Unstable features below
9-
unstable_features = true
101
style_edition = "2024"
11-
comment_width = 100
12-
format_code_in_doc_comments = true
13-
format_macro_bodies = true
14-
format_macro_matchers = true
15-
format_strings = true
16-
imports_granularity = "Module"
17-
group_imports = "StdExternalCrate"
18-
normalize_comments = true
19-
normalize_doc_attributes = true
20-
wrap_comments = true
21-
22-
# To use these settings in vscode, add the following line to your settings:
23-
# "rust-analyzer.rustfmt.overrideCommand": [
24-
# "rustup",
25-
# "run",
26-
# "nightly-2025-02-01",
27-
# "--",
28-
# "rustfmt",
29-
# "--edition",
30-
# "2021",
31-
# "--"
32-
# ]
33-
# and run "rustup toolchain install nightly-2025-02-01".
2+
use_small_heuristics = "Max"

src/lang/proc_macros/plugins/downcast.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ use crate::lang::db::AnalysisDatabase;
1414
/// Safety: This function MUST only be invoked with an object that is of type
1515
/// [AnalysisDatabase]. Using it with any other type leads to undefined behavior.
1616
pub(super) unsafe fn unsafe_downcast_ref(db: &dyn SyntaxGroup) -> &AnalysisDatabase {
17-
// Replicated logic from `impl dyn Any downcast_ref_unchecked()`.
18-
// This approach works as long as `impl dyn Any downcast_ref_unchecked()` implementation is
19-
// unchanged and the caller can ensure that `db` is truly an instance of AnalysisDatabase.
20-
&*(db as *const dyn SyntaxGroup as *const AnalysisDatabase)
17+
unsafe {
18+
// Replicated logic from `impl dyn Any downcast_ref_unchecked()`.
19+
// This approach works as long as `impl dyn Any downcast_ref_unchecked()` implementation is
20+
// unchanged and the caller can ensure that `db` is truly an instance of AnalysisDatabase.
21+
&*(db as *const dyn SyntaxGroup as *const AnalysisDatabase)
22+
}
2123
}
2224

2325
#[cfg(test)]

src/project/crate_data.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,17 @@ impl Crate {
7979
inject_virtual_wrapper_lib(db, crate_id, file_stems);
8080
}
8181

82-
let plugins = self.builtin_plugins
82+
let plugins = self
83+
.builtin_plugins
8384
.iter()
8485
.map(BuiltinPlugin::suite)
8586
.chain(tricks()) // All crates should receive Tricks.
8687
.chain(enable_linter.then(cairo_lint_plugin_suite))
8788
.chain(proc_macro_plugin_suite)
88-
.fold(
89-
get_default_plugin_suite(),
90-
|mut acc, suite| {
91-
acc.add(suite);
92-
acc
93-
},
94-
);
89+
.fold(get_default_plugin_suite(), |mut acc, suite| {
90+
acc.add(suite);
91+
acc
92+
});
9593

9694
let interned_plugins = db.intern_plugin_suite(plugins);
9795
db.set_override_crate_plugins_from_suite(crate_id, interned_plugins);

src/project/manifest_registry/member_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl MemberConfig {
2323
}
2424

2525
fn merge_serde_json_value(a: &mut Value, b: &Value) {
26-
if let (Value::Object(ref mut a_map), Value::Object(ref b_map)) = (a, b) {
26+
if let (Value::Object(a_map), Value::Object(b_map)) = (a, b) {
2727
for (b_key, b_val) in b_map {
2828
if let Some(a_val) = a_map.get_mut(b_key) {
2929
if a_val.is_object() && b_val.is_object() {

0 commit comments

Comments
 (0)