Skip to content

Commit

Permalink
Update Rust edition to 2024
Browse files Browse the repository at this point in the history
commit-id:c0d0c885
  • Loading branch information
ksew1 committed Feb 21, 2025
1 parent 249b1cf commit efb6272
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [

[workspace.package]
version = "0.8.0"
edition = "2021"
edition = "2024"


[workspace.dependencies]
Expand Down
17 changes: 13 additions & 4 deletions crates/cairo-profiler/src/profile_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod perftools {
use anyhow::{Context, Result};
use bytes::{Buf, BytesMut};
use camino::Utf8PathBuf;
use flate2::{bufread::GzEncoder, Compression};
use flate2::{Compression, bufread::GzEncoder};
use prost::Message;
use std::collections::{HashMap, HashSet};
use std::{fs, io::Read};
Expand Down Expand Up @@ -113,7 +113,10 @@ impl ProfilerContext {
locations_ids.push(LocationId(location.id));
} else {
let mut location = match &function_stack[0] {
FunctionCall::EntrypointCall(function_name) | FunctionCall::InternalFunctionCall(InternalFunctionCall::NonInlined(function_name) | Syscall(function_name)) => {
FunctionCall::EntrypointCall(function_name)
| FunctionCall::InternalFunctionCall(
InternalFunctionCall::NonInlined(function_name) | Syscall(function_name),
) => {
let line = pprof::Line {
function_id: self.function_id(function_name).into(),
line: 0,
Expand All @@ -126,7 +129,11 @@ impl ProfilerContext {
is_folded: true,
}
}
FunctionCall::InternalFunctionCall(InternalFunctionCall::Inlined(_)) => unreachable!("First function in a function stack corresponding to a single location cannot be inlined")
FunctionCall::InternalFunctionCall(InternalFunctionCall::Inlined(_)) => {
unreachable!(
"First function in a function stack corresponding to a single location cannot be inlined"
)
}
};

for function in function_stack.get(1..).unwrap_or_default() {
Expand All @@ -144,7 +151,9 @@ impl ProfilerContext {
| FunctionCall::InternalFunctionCall(
InternalFunctionCall::NonInlined(_) | Syscall(_),
) => {
unreachable!("Only first function in a function stack corresponding to a single location can be not inlined")
unreachable!(
"Only first function in a function stack corresponding to a single location can be not inlined"
)
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/cairo-profiler/src/profile_viewer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use camino::Utf8PathBuf;
use flate2::read::GzDecoder;
use prettytable::{format, Table};
use prettytable::{Table, format};
use prost::Message;
use std::collections::HashMap;
use std::fs;
Expand Down Expand Up @@ -133,7 +133,9 @@ pub fn print_profile(profile: &Profile, sample: &str, limit: NonZeroUsize) -> Re
.context("Failed to get current percentage from profile data")?
);

println!("\nShowing nodes accounting for {summary_resource_cost} {sample}, {cost_percentage} of {total_resource_count} {sample} total");
println!(
"\nShowing nodes accounting for {summary_resource_cost} {sample}, {cost_percentage} of {total_resource_count} {sample} total"
);
println!("Showing top {effective_limit} nodes out of {profile_length}\n");

let mut table = Table::new();
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-profiler/src/sierra_loader.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use anyhow::{anyhow, Context, Result};
use anyhow::{Context, Result, anyhow};
use cairo_annotations::annotations::TryFromDebugInfo;
use cairo_annotations::annotations::profiler::{
ProfilerAnnotationsV1, VersionedProfilerAnnotations,
};
use cairo_annotations::annotations::TryFromDebugInfo;
use cairo_annotations::trace_data::{CallTraceNode, CallTraceV1};
use cairo_lang_sierra::debug_info::DebugInfo;
use cairo_lang_sierra::program::{Program, ProgramArtifact, VersionedProgram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::trace_reader::sample::{FunctionCall, InternalFunctionCall, Sample};
use crate::versioned_constants_reader::OsResources;
use cairo_annotations::annotations::profiler::{FunctionName, ProfilerAnnotationsV1};
use cairo_annotations::trace_data::CasmLevelInfo;
use cairo_annotations::{map_pcs_to_sierra_statement_ids, MappingResult};
use cairo_annotations::{MappingResult, map_pcs_to_sierra_statement_ids};
use cairo_lang_sierra::extensions::core::{CoreConcreteLibfunc, CoreLibfunc, CoreType};
use cairo_lang_sierra::extensions::starknet::StarkNetConcreteLibfunc;
use cairo_lang_sierra::program::{GenStatement, Program, StatementIdx};
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-profiler/tests/e2e.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use assert_fs::fixture::PathCopy;
use indoc::indoc;
use snapbox::cmd::{cargo_bin, Command as SnapboxCommand};
use snapbox::cmd::{Command as SnapboxCommand, cargo_bin};
use std::str;
use test_case::test_case;

Expand Down

0 comments on commit efb6272

Please sign in to comment.