Upgrade to the Rust 2024 edition (#2367)

* Update to rust 2024 edition

* Fixes

* Clean up imports

* Cargo fmt again

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2025-03-12 17:29:12 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent 927d7dd9b2
commit beb1c6ae64
253 changed files with 980 additions and 1371 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
use std::{fs, path::PathBuf};
use std::fs;
use std::path::PathBuf;
fn main() {
// Directory required for compilation, but not tracked by git if empty.
+2 -2
View File
@@ -2,9 +2,9 @@
name = "graphite-wasm"
publish = false
version = "0.0.0"
rust-version = "1.79"
rust-version = "1.85"
authors = ["Graphite Authors <contact@graphite.rs>"]
edition = "2021"
edition = "2024"
readme = "../../README.md"
homepage = "https://graphite.rs"
repository = "https://github.com/GraphiteEditor/Graphite"
+6 -7
View File
@@ -5,8 +5,7 @@
// on the dispatcher messaging system and more complex Rust data types.
//
use crate::helpers::translate_key;
use crate::{Error, EDITOR, EDITOR_HANDLE, EDITOR_HAS_CRASHED};
use crate::{EDITOR, EDITOR_HANDLE, EDITOR_HAS_CRASHED, Error};
use editor::application::Editor;
use editor::consts::FILE_SAVE_SUFFIX;
use editor::messages::input_mapper::utility_types::input_keyboard::ModifierKeys;
@@ -18,7 +17,6 @@ use editor::messages::prelude::*;
use editor::messages::tool::tool_messages::tool_prelude::WidgetId;
use graph_craft::document::NodeId;
use graphene_core::raster::color::Color;
use serde::Serialize;
use serde_wasm_bindgen::{self, from_value};
use std::cell::RefCell;
@@ -757,10 +755,11 @@ impl EditorHandle {
use editor::messages::portfolio::document::graph_operation::transform_utils::*;
use editor::messages::portfolio::document::graph_operation::utility_types::*;
use editor::messages::portfolio::document::node_graph::document_node_definitions::resolve_document_node_type;
use editor::node_graph_executor::replace_node_runtime;
use editor::node_graph_executor::NodeRuntime;
use editor::node_graph_executor::replace_node_runtime;
use graph_craft::document::DocumentNodeImplementation;
use graph_craft::document::NodeInput;
use graph_craft::document::{value::TaggedValue, DocumentNodeImplementation};
use graph_craft::document::value::TaggedValue;
use graphene_core::vector::*;
let (_, request_receiver) = std::sync::mpsc::channel();
@@ -989,7 +988,7 @@ fn set_timeout(f: &Closure<dyn FnMut()>, delay: Duration) {
fn editor<T: Default>(callback: impl FnOnce(&mut editor::application::Editor) -> T) -> T {
EDITOR.with(|editor| {
let mut guard = editor.try_lock();
let Ok(Some(ref mut editor)) = guard.as_deref_mut() else { return T::default() };
let Ok(Some(editor)) = guard.as_deref_mut() else { return T::default() };
callback(editor)
})
@@ -1000,7 +999,7 @@ pub(crate) fn editor_and_handle(mut callback: impl FnMut(&mut Editor, &mut Edito
EDITOR_HANDLE.with(|editor_handle| {
editor(|editor| {
let mut guard = editor_handle.try_lock();
let Ok(Some(ref mut editor_handle)) = guard.as_deref_mut() else {
let Ok(Some(editor_handle)) = guard.as_deref_mut() else {
log::error!("Failed to borrow editor handle");
return;
};
+2 -3
View File
@@ -8,10 +8,9 @@ pub mod editor_api;
pub mod helpers;
use editor::messages::prelude::*;
use std::panic;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
use wasm_bindgen::prelude::*;
// Set up the persistent editor backend state
@@ -72,7 +71,7 @@ pub fn panic_hook(info: &panic::PanicHookInfo) {
EDITOR_HANDLE.with(|editor_handle| {
let mut guard = editor_handle.lock();
if let Ok(Some(ref mut handle)) = guard.as_deref_mut() {
if let Ok(Some(handle)) = guard.as_deref_mut() {
handle.send_frontend_message_to_js_rust_proxy(FrontendMessage::DisplayDialogPanic { panic_info: info.to_string() });
}
});