Skip to content

Commit 20f0ecd

Browse files
authored
Update Rust edition to 2024 (#143)
1 parent 905d79d commit 20f0ecd

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ members = [
66

77
[workspace.package]
88
version = "0.8.0"
9-
edition = "2021"
9+
edition = "2024"
1010

1111

1212
[workspace.dependencies]

crates/cairo-profiler/src/profile_builder.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod perftools {
99
use anyhow::{Context, Result};
1010
use bytes::{Buf, BytesMut};
1111
use camino::Utf8PathBuf;
12-
use flate2::{bufread::GzEncoder, Compression};
12+
use flate2::{Compression, bufread::GzEncoder};
1313
use prost::Message;
1414
use std::collections::{HashMap, HashSet};
1515
use std::{fs, io::Read};
@@ -113,7 +113,10 @@ impl ProfilerContext {
113113
locations_ids.push(LocationId(location.id));
114114
} else {
115115
let mut location = match &function_stack[0] {
116-
FunctionCall::EntrypointCall(function_name) | FunctionCall::InternalFunctionCall(InternalFunctionCall::NonInlined(function_name) | Syscall(function_name)) => {
116+
FunctionCall::EntrypointCall(function_name)
117+
| FunctionCall::InternalFunctionCall(
118+
InternalFunctionCall::NonInlined(function_name) | Syscall(function_name),
119+
) => {
117120
let line = pprof::Line {
118121
function_id: self.function_id(function_name).into(),
119122
line: 0,
@@ -126,7 +129,11 @@ impl ProfilerContext {
126129
is_folded: true,
127130
}
128131
}
129-
FunctionCall::InternalFunctionCall(InternalFunctionCall::Inlined(_)) => unreachable!("First function in a function stack corresponding to a single location cannot be inlined")
132+
FunctionCall::InternalFunctionCall(InternalFunctionCall::Inlined(_)) => {
133+
unreachable!(
134+
"First function in a function stack corresponding to a single location cannot be inlined"
135+
)
136+
}
130137
};
131138

132139
for function in function_stack.get(1..).unwrap_or_default() {
@@ -144,7 +151,9 @@ impl ProfilerContext {
144151
| FunctionCall::InternalFunctionCall(
145152
InternalFunctionCall::NonInlined(_) | Syscall(_),
146153
) => {
147-
unreachable!("Only first function in a function stack corresponding to a single location can be not inlined")
154+
unreachable!(
155+
"Only first function in a function stack corresponding to a single location can be not inlined"
156+
)
148157
}
149158
}
150159
}

crates/cairo-profiler/src/profile_viewer.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::{Context, Result};
22
use camino::Utf8PathBuf;
33
use flate2::read::GzDecoder;
4-
use prettytable::{format, Table};
4+
use prettytable::{Table, format};
55
use prost::Message;
66
use std::collections::HashMap;
77
use std::fs;
@@ -133,7 +133,9 @@ pub fn print_profile(profile: &Profile, sample: &str, limit: NonZeroUsize) -> Re
133133
.context("Failed to get current percentage from profile data")?
134134
);
135135

136-
println!("\nShowing nodes accounting for {summary_resource_cost} {sample}, {cost_percentage} of {total_resource_count} {sample} total");
136+
println!(
137+
"\nShowing nodes accounting for {summary_resource_cost} {sample}, {cost_percentage} of {total_resource_count} {sample} total"
138+
);
137139
println!("Showing top {effective_limit} nodes out of {profile_length}\n");
138140

139141
let mut table = Table::new();

crates/cairo-profiler/src/sierra_loader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use anyhow::{anyhow, Context, Result};
1+
use anyhow::{Context, Result, anyhow};
2+
use cairo_annotations::annotations::TryFromDebugInfo;
23
use cairo_annotations::annotations::profiler::{
34
ProfilerAnnotationsV1, VersionedProfilerAnnotations,
45
};
5-
use cairo_annotations::annotations::TryFromDebugInfo;
66
use cairo_annotations::trace_data::{CallTraceNode, CallTraceV1};
77
use cairo_lang_sierra::debug_info::DebugInfo;
88
use cairo_lang_sierra::program::{Program, ProgramArtifact, VersionedProgram};

crates/cairo-profiler/src/trace_reader/function_trace_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::trace_reader::sample::{FunctionCall, InternalFunctionCall, Sample};
1010
use crate::versioned_constants_reader::OsResources;
1111
use cairo_annotations::annotations::profiler::{FunctionName, ProfilerAnnotationsV1};
1212
use cairo_annotations::trace_data::CasmLevelInfo;
13-
use cairo_annotations::{map_pcs_to_sierra_statement_ids, MappingResult};
13+
use cairo_annotations::{MappingResult, map_pcs_to_sierra_statement_ids};
1414
use cairo_lang_sierra::extensions::core::{CoreConcreteLibfunc, CoreLibfunc, CoreType};
1515
use cairo_lang_sierra::extensions::starknet::StarkNetConcreteLibfunc;
1616
use cairo_lang_sierra::program::{GenStatement, Program, StatementIdx};

crates/cairo-profiler/tests/e2e.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use assert_fs::fixture::PathCopy;
22
use indoc::indoc;
3-
use snapbox::cmd::{cargo_bin, Command as SnapboxCommand};
3+
use snapbox::cmd::{Command as SnapboxCommand, cargo_bin};
44
use std::str;
55
use test_case::test_case;
66

0 commit comments

Comments
 (0)