Migrate to Rust edition 2024

This commit is contained in:
2025-03-04 22:31:38 -07:00
parent 8eef37e8df
commit 799971d54e
46 changed files with 154 additions and 207 deletions

View File

@@ -5,8 +5,8 @@ use std::{
path::{Path, PathBuf},
rc::Rc,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex, RwLock,
atomic::{AtomicBool, Ordering},
},
time::Instant,
};
@@ -14,11 +14,11 @@ use std::{
use filetime::FileTime;
use globset::Glob;
use objdiff_core::{
build::watcher::{create_watcher, Watcher},
build::watcher::{Watcher, create_watcher},
config::{
DEFAULT_WATCH_PATTERNS, ProjectConfig, ProjectConfigInfo, ProjectObject, ScratchConfig,
build_globset, default_watch_patterns, path::platform_path_serde_option,
save_project_config, ProjectConfig, ProjectConfigInfo, ProjectObject, ScratchConfig,
DEFAULT_WATCH_PATTERNS,
save_project_config,
},
diff::DiffObjConfig,
jobs::{Job, JobQueue, JobResult},
@@ -27,22 +27,22 @@ use time::UtcOffset;
use typed_path::{Utf8PlatformPath, Utf8PlatformPathBuf};
use crate::{
app_config::{deserialize_config, AppConfigVersion},
config::{load_project_config, ProjectObjectNode},
app_config::{AppConfigVersion, deserialize_config},
config::{ProjectObjectNode, load_project_config},
jobs::{create_objdiff_config, egui_waker, start_build},
views::{
appearance::{appearance_window, Appearance},
appearance::{Appearance, appearance_window},
config::{
arch_config_window, config_ui, general_config_ui, project_window, ConfigViewState,
CONFIG_DISABLED_TEXT,
CONFIG_DISABLED_TEXT, ConfigViewState, arch_config_window, config_ui,
general_config_ui, project_window,
},
debug::debug_window,
demangle::{demangle_window, DemangleViewState},
demangle::{DemangleViewState, demangle_window},
diff::diff_view_ui,
frame_history::FrameHistory,
graphics::{graphics_window, GraphicsConfig, GraphicsViewState},
graphics::{GraphicsConfig, GraphicsViewState, graphics_window},
jobs::{jobs_menu_ui, jobs_window},
rlwinm::{rlwinm_decode_window, RlwinmDecodeViewState},
rlwinm::{RlwinmDecodeViewState, rlwinm_decode_window},
symbol_diff::{DiffViewAction, DiffViewState, ResolvedNavigation, View},
},
};

View File

@@ -11,7 +11,7 @@ use objdiff_core::{
};
use typed_path::{Utf8PlatformPathBuf, Utf8UnixPathBuf};
use crate::app::{AppConfig, ObjectConfig, CONFIG_KEY};
use crate::app::{AppConfig, CONFIG_KEY, ObjectConfig};
#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct AppConfigVersion {

View File

@@ -1,6 +1,6 @@
use anyhow::Result;
use globset::Glob;
use objdiff_core::config::{try_project_config, DEFAULT_WATCH_PATTERNS};
use objdiff_core::config::{DEFAULT_WATCH_PATTERNS, try_project_config};
use typed_path::{Utf8UnixComponent, Utf8UnixPath};
use crate::app::{AppState, ObjectConfig};

View File

@@ -1,5 +1,5 @@
use egui::{
style::ScrollAnimation, vec2, Context, Key, KeyboardShortcut, Modifiers, PointerButton,
Context, Key, KeyboardShortcut, Modifiers, PointerButton, style::ScrollAnimation, vec2,
};
fn any_widget_focused(ctx: &Context) -> bool { ctx.memory(|mem| mem.focused().is_some()) }

View File

@@ -3,18 +3,18 @@ use std::{
task::{Wake, Waker},
};
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use jobs::create_scratch;
use objdiff_core::{
build::BuildConfig,
diff::MappingConfig,
jobs,
jobs::{check_update::CheckUpdateConfig, objdiff, update::UpdateConfig, Job, JobQueue},
jobs::{Job, JobQueue, check_update::CheckUpdateConfig, objdiff, update::UpdateConfig},
};
use crate::{
app::{AppConfig, AppState},
update::{build_updater, BIN_NAME_NEW, BIN_NAME_OLD},
update::{BIN_NAME_NEW, BIN_NAME_OLD, build_updater},
};
struct EguiWaker(egui::Context);

View File

@@ -17,12 +17,12 @@ use std::{
sync::{Arc, Mutex},
};
use anyhow::{ensure, Result};
use anyhow::{Result, ensure};
use cfg_if::cfg_if;
use time::UtcOffset;
use tracing_subscriber::EnvFilter;
use crate::views::graphics::{load_graphics_config, GraphicsBackend, GraphicsConfig};
use crate::views::graphics::{GraphicsBackend, GraphicsConfig, load_graphics_config};
fn load_icon() -> Result<egui::IconData> {
let decoder = png::Decoder::new(include_bytes!("../assets/icon_64.png").as_ref());
@@ -86,7 +86,7 @@ fn main() -> ExitCode {
}
#[cfg(feature = "wgpu")]
{
use eframe::egui_wgpu::{wgpu, WgpuSetup};
use eframe::egui_wgpu::{WgpuSetup, wgpu};
if graphics_config.desired_backend.is_supported() {
native_options.wgpu_options.wgpu_setup = match native_options.wgpu_options.wgpu_setup {
WgpuSetup::CreateNew(mut setup) => {

View File

@@ -1,6 +1,6 @@
use std::sync::Arc;
use egui::{text::LayoutJob, Color32, FontFamily, FontId, TextFormat, TextStyle, Widget};
use egui::{Color32, FontFamily, FontId, TextFormat, TextStyle, Widget, text::LayoutJob};
use time::UtcOffset;
use crate::fonts::load_font_if_needed;

View File

@@ -5,17 +5,17 @@ use std::{mem::take, path::MAIN_SEPARATOR};
#[cfg(all(windows, feature = "wsl"))]
use anyhow::{Context, Result};
use egui::{
output::OpenUrl, text::LayoutJob, CollapsingHeader, FontFamily, FontId, RichText,
SelectableLabel, TextFormat, Widget,
CollapsingHeader, FontFamily, FontId, RichText, SelectableLabel, TextFormat, Widget,
output::OpenUrl, text::LayoutJob,
};
use globset::Glob;
use objdiff_core::{
config::{path::check_path_buf, DEFAULT_WATCH_PATTERNS},
config::{DEFAULT_WATCH_PATTERNS, path::check_path_buf},
diff::{
ConfigEnum, ConfigEnumVariantInfo, ConfigPropertyId, ConfigPropertyKind,
ConfigPropertyValue, CONFIG_GROUPS,
CONFIG_GROUPS, ConfigEnum, ConfigEnumVariantInfo, ConfigPropertyId, ConfigPropertyKind,
ConfigPropertyValue,
},
jobs::{check_update::CheckUpdateResult, Job, JobQueue, JobResult},
jobs::{Job, JobQueue, JobResult, check_update::CheckUpdateResult},
};
use typed_path::Utf8PlatformPathBuf;
@@ -347,11 +347,7 @@ fn display_unit(
let color = if selected {
appearance.emphasized_text_color
} else if let Some(complete) = object.complete {
if complete {
appearance.insert_color
} else {
appearance.delete_color
}
if complete { appearance.insert_color } else { appearance.delete_color }
} else {
appearance.text_color
};

View File

@@ -1,11 +1,11 @@
use std::{cmp::min, default::Default, mem::take};
use egui::{text::LayoutJob, Label, Sense, Widget};
use egui::{Label, Sense, Widget, text::LayoutJob};
use objdiff_core::{
diff::{
data::resolve_relocation,
display::{relocation_context, relocation_hover, ContextItem, HoverItem},
DataDiff, DataDiffKind, DataRelocationDiff,
data::resolve_relocation,
display::{ContextItem, HoverItem, relocation_context, relocation_hover},
},
obj::Object,
};

View File

@@ -1,9 +1,9 @@
use egui::{text::LayoutJob, Id, Layout, RichText, ScrollArea, TextEdit, Ui, Widget};
use egui::{Id, Layout, RichText, ScrollArea, TextEdit, Ui, Widget, text::LayoutJob};
use objdiff_core::{
build::BuildStatus,
diff::{
display::{ContextItem, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind},
DiffObjConfig, ObjectDiff, SectionDiff, SymbolDiff,
display::{ContextItem, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind},
},
obj::{Object, Section, Symbol},
};
@@ -14,13 +14,12 @@ use crate::{
views::{
appearance::Appearance,
column_layout::{render_header, render_strips, render_table},
data_diff::{data_row_ui, split_diffs, BYTES_PER_ROW},
data_diff::{BYTES_PER_ROW, data_row_ui, split_diffs},
extab_diff::extab_ui,
function_diff::{asm_col_ui, FunctionDiffContext},
function_diff::{FunctionDiffContext, asm_col_ui},
symbol_diff::{
match_color_for_symbol, symbol_context_menu_ui, symbol_hover_ui, symbol_list_ui,
DiffViewAction, DiffViewNavigation, DiffViewState, SymbolDiffContext, SymbolRefByName,
View,
View, match_color_for_symbol, symbol_context_menu_ui, symbol_hover_ui, symbol_list_ui,
},
write_text,
},

View File

@@ -1,14 +1,14 @@
use std::{cmp::Ordering, default::Default};
use egui::{text::LayoutJob, Label, Response, Sense, Widget};
use egui::{Label, Response, Sense, Widget, text::LayoutJob};
use egui_extras::TableRow;
use objdiff_core::{
diff::{
display::{
display_row, instruction_context, instruction_hover, DiffText, DiffTextColor,
DiffTextSegment, HighlightKind,
},
DiffObjConfig, InstructionDiffKind, InstructionDiffRow, ObjectDiff,
display::{
DiffText, DiffTextColor, DiffTextSegment, HighlightKind, display_row,
instruction_context, instruction_hover,
},
},
obj::{InstructionArgValue, InstructionRef, Object},
util::ReallySigned,

View File

@@ -5,7 +5,7 @@ use std::{
};
use anyhow::Result;
use egui::{text::LayoutJob, Context, FontId, RichText, TextFormat, TextStyle, Window};
use egui::{Context, FontId, RichText, TextFormat, TextStyle, Window, text::LayoutJob};
use serde::{Deserialize, Serialize};
use crate::views::{appearance::Appearance, frame_history::FrameHistory};

View File

@@ -1,4 +1,4 @@
use egui::{text::LayoutJob, Color32, FontId, TextFormat};
use egui::{Color32, FontId, TextFormat, text::LayoutJob};
pub(crate) mod appearance;
pub(crate) mod column_layout;

View File

@@ -1,18 +1,18 @@
use std::mem::take;
use egui::{
style::ScrollAnimation, text::LayoutJob, CollapsingHeader, Color32, Id, OpenUrl, ScrollArea,
SelectableLabel, Ui, Widget,
CollapsingHeader, Color32, Id, OpenUrl, ScrollArea, SelectableLabel, Ui, Widget,
style::ScrollAnimation, text::LayoutJob,
};
use objdiff_core::{
diff::{
display::{
display_sections, symbol_context, symbol_hover, HighlightKind, SectionDisplay,
SymbolFilter, SymbolNavigationKind,
},
ObjectDiff, SymbolDiff,
display::{
HighlightKind, SectionDisplay, SymbolFilter, SymbolNavigationKind, display_sections,
symbol_context, symbol_hover,
},
},
jobs::{create_scratch::CreateScratchResult, objdiff::ObjDiffResult, Job, JobQueue, JobResult},
jobs::{Job, JobQueue, JobResult, create_scratch::CreateScratchResult, objdiff::ObjDiffResult},
obj::{Object, Section, SectionKind, Symbol, SymbolFlag},
};
use regex::{Regex, RegexBuilder};