mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Fix all Clippy warnings (#1936)
* Fix all Clippy warnings * More fixes * Bump criterion version --------- Co-authored-by: dennis@kobert.dev <dennis@kobert.dev>
This commit is contained in:
parent
858efb65bb
commit
15d125d8e7
13 changed files with 97 additions and 121 deletions
|
@ -1,8 +1,8 @@
|
|||
name: Clippy Check with PR Comments
|
||||
name: Clippy Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
clippy:
|
||||
|
@ -13,7 +13,7 @@ jobs:
|
|||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
@ -24,7 +24,7 @@ jobs:
|
|||
|
||||
- name: Install Deps
|
||||
run: sudo apt-get install libgtk-3-dev libsoup2.4-dev libjavascriptcoregtk-4.0-dev libwebkit2gtk-4.0-dev
|
||||
|
||||
|
||||
- name: Run Clippy
|
||||
id: clippy
|
||||
run: |
|
||||
|
@ -49,11 +49,11 @@ jobs:
|
|||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
|
||||
|
||||
const botComments = comments.filter(comment =>
|
||||
comment.user.type === 'Bot' && comment.body.includes('Clippy Warnings/Errors')
|
||||
);
|
||||
|
||||
|
||||
for (const comment of botComments) {
|
||||
await github.rest.issues.deleteComment({
|
||||
owner: context.repo.owner,
|
||||
|
@ -61,7 +61,7 @@ jobs:
|
|||
comment_id: comment.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
- name: Comment PR
|
||||
if: steps.clippy.outputs.CLIPPY_ISSUES_FOUND == 'true'
|
||||
uses: actions/github-script@v6
|
||||
|
@ -70,9 +70,9 @@ jobs:
|
|||
script: |
|
||||
const clippy_output = ${{ steps.clippy.outputs.CLIPPY_OUTPUT }};
|
||||
const output = `
|
||||
<details>
|
||||
<details open>
|
||||
|
||||
<summary> Found Clippy warnings </summary>
|
||||
<summary>Found Clippy warnings</summary>
|
||||
|
||||
#### Clippy Warnings/Errors
|
||||
|
||||
|
@ -82,11 +82,10 @@ jobs:
|
|||
|
||||
</details>
|
||||
`;
|
||||
|
||||
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: output
|
||||
})
|
||||
|
145
Cargo.lock
generated
145
Cargo.lock
generated
|
@ -124,6 +124,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anes"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.14"
|
||||
|
@ -456,17 +462,6 @@ version = "1.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.3.0"
|
||||
|
@ -941,16 +936,57 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
name = "ciborium"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"ciborium-io",
|
||||
"ciborium-ll",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ciborium-io"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
|
||||
|
||||
[[package]]
|
||||
name = "ciborium-ll"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
|
||||
dependencies = [
|
||||
"ciborium-io",
|
||||
"half",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "5.4.0"
|
||||
|
@ -1200,24 +1236,24 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "criterion"
|
||||
version = "0.3.6"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f"
|
||||
checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"anes",
|
||||
"cast",
|
||||
"ciborium",
|
||||
"clap",
|
||||
"criterion-plot",
|
||||
"csv",
|
||||
"is-terminal",
|
||||
"itertools 0.10.5",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"oorandom",
|
||||
"plotters",
|
||||
"rayon",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_cbor",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"tinytemplate",
|
||||
|
@ -1226,9 +1262,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "criterion-plot"
|
||||
version = "0.4.5"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876"
|
||||
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||
dependencies = [
|
||||
"cast",
|
||||
"itertools 0.10.5",
|
||||
|
@ -1311,27 +1347,6 @@ dependencies = [
|
|||
"syn 2.0.72",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "csv"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe"
|
||||
dependencies = [
|
||||
"csv-core",
|
||||
"itoa 1.0.11",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "csv-core"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.2.8"
|
||||
|
@ -2470,7 +2485,7 @@ dependencies = [
|
|||
"bytemuck",
|
||||
"dyn-any",
|
||||
"glam",
|
||||
"half 2.4.1",
|
||||
"half",
|
||||
"image 0.25.2",
|
||||
"js-sys",
|
||||
"kurbo",
|
||||
|
@ -2724,12 +2739,6 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403"
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.4.1"
|
||||
|
@ -2794,15 +2803,6 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
|
@ -5637,16 +5637,6 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_cbor"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
|
||||
dependencies = [
|
||||
"half 1.8.3",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.204"
|
||||
|
@ -6633,15 +6623,6 @@ dependencies = [
|
|||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thin-slice"
|
||||
version = "0.1.1"
|
||||
|
@ -7713,7 +7694,7 @@ dependencies = [
|
|||
"glam",
|
||||
"gpu-executor",
|
||||
"graphene-core",
|
||||
"half 2.4.1",
|
||||
"half",
|
||||
"log",
|
||||
"node-macro",
|
||||
"num-traits",
|
||||
|
|
|
@ -381,7 +381,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
|
|||
let document_name = document_name.replace("__DO_NOT_UPGRADE__", "");
|
||||
|
||||
let document = DocumentMessageHandler::deserialize_document(&document_serialized_content).map(|mut document| {
|
||||
document.name = document_name.clone();
|
||||
document.name.clone_from(&document_name);
|
||||
document
|
||||
});
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ impl NodeRuntime {
|
|||
|
||||
assert_ne!(proto_network.nodes.len(), 0, "No proto nodes exist?");
|
||||
self.executor.update(proto_network).await.map_err(|e| {
|
||||
self.node_graph_errors = e.clone();
|
||||
self.node_graph_errors.clone_from(&e);
|
||||
format!("{e:?}")
|
||||
})
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ web-sys = { workspace = true, features = [
|
|||
# Optional workspace dependencies
|
||||
ron = { workspace = true, optional = true }
|
||||
|
||||
|
||||
[package.metadata.wasm-pack.profile.dev]
|
||||
wasm-opt = false
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ pub fn decode_a100<R: Read + Seek>(ifd: Ifd, file: &mut TiffRead<R>) -> RawImage
|
|||
width: image_width,
|
||||
height: image_height,
|
||||
cfa_pattern: todo!(),
|
||||
#[allow(unreachable_code)]
|
||||
maximum: (1 << 12) - 1,
|
||||
black: SubtractBlack::None,
|
||||
camera_to_xyz: None,
|
||||
|
|
|
@ -307,7 +307,8 @@ fn _test_final_image(content: &[u8], raw_image: RawImage) -> Result<(), String>
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// #[test]
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn extract_data_from_dng_images() {
|
||||
read_dir(BASE_PATH)
|
||||
.unwrap()
|
||||
|
|
|
@ -508,6 +508,7 @@ where
|
|||
H: BuildHasher + Default,
|
||||
{
|
||||
struct HashMapVisitor<K, V, H> {
|
||||
#[allow(clippy::type_complexity)]
|
||||
marker: std::marker::PhantomData<fn() -> HashMap<K, V, H>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -50,15 +50,13 @@ wasm-bindgen-futures = { workspace = true }
|
|||
# Workspace dependencies
|
||||
winit = { workspace = true }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.3", features = ["html_reports"] }
|
||||
criterion = { version = "0.5", features = ["html_reports"] }
|
||||
glob = "0.3"
|
||||
pprof = { version = "0.13", features = ["flamegraph"] }
|
||||
serde_json = { workspace = true }
|
||||
graph-craft = { workspace = true, features = ["serde"] }
|
||||
|
||||
|
||||
[[bench]]
|
||||
name = "compile_demo_art"
|
||||
harness = false
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use graph_craft::{document::NodeNetwork, graphene_compiler::Compiler, proto::ProtoNetwork};
|
||||
use graph_craft::document::NodeNetwork;
|
||||
use graph_craft::graphene_compiler::Compiler;
|
||||
use graph_craft::proto::ProtoNetwork;
|
||||
|
||||
pub fn compile_to_proto(c: &mut Criterion) {
|
||||
let artworks = glob::glob("../../demo-artwork/*.graphite").expect("failed to read glob pattern");
|
||||
|
@ -14,9 +16,8 @@ pub fn compile_to_proto(c: &mut Criterion) {
|
|||
}
|
||||
|
||||
fn load_network(document_string: &str) -> NodeNetwork {
|
||||
let document: serde_json::Value = serde_json::from_str(&document_string).expect("Failed to parse document");
|
||||
let network = serde_json::from_value::<NodeNetwork>(document["network_interface"]["network"].clone()).expect("Failed to parse document");
|
||||
network
|
||||
let document: serde_json::Value = serde_json::from_str(document_string).expect("Failed to parse document");
|
||||
serde_json::from_value::<NodeNetwork>(document["network_interface"]["network"].clone()).expect("Failed to parse document")
|
||||
}
|
||||
fn compile(network: NodeNetwork) -> ProtoNetwork {
|
||||
let compiler = Compiler {};
|
||||
|
|
|
@ -2,12 +2,12 @@ use crate::document::value::TaggedValue;
|
|||
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
|
||||
|
||||
use dyn_any::{DynAny, StaticType};
|
||||
use glam::IVec2;
|
||||
use graphene_core::memo::MemoHashGuard;
|
||||
pub use graphene_core::uuid::generate_uuid;
|
||||
use graphene_core::{Cow, MemoHash, ProtoNodeIdentifier, Type};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use glam::IVec2;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -1026,7 +1026,7 @@ impl NodeNetwork {
|
|||
Self::replace_value_inputs_with_nodes(
|
||||
&mut inner_network.exports,
|
||||
&mut inner_network.nodes,
|
||||
&node.original_location.path.as_ref().unwrap_or(&vec![]),
|
||||
node.original_location.path.as_ref().unwrap_or(&vec![]),
|
||||
gen_id,
|
||||
map_ids,
|
||||
id,
|
||||
|
@ -1058,9 +1058,8 @@ impl NodeNetwork {
|
|||
NodeInput::Node { node_id, output_index, lambda } => {
|
||||
let skip = node.original_location.skip_inputs;
|
||||
nested_node.populate_first_network_input(node_id, output_index, nested_input_index, lambda, node.original_location.inputs(*import_index), skip);
|
||||
if let input_node = self.nodes.get_mut(&node_id).unwrap() {
|
||||
input_node.original_location.dependants[output_index].push(nested_node_id);
|
||||
};
|
||||
let input_node = self.nodes.get_mut(&node_id).unwrap();
|
||||
input_node.original_location.dependants[output_index].push(nested_node_id);
|
||||
}
|
||||
NodeInput::Network { import_index, .. } => {
|
||||
let parent_input_index = import_index;
|
||||
|
@ -1276,8 +1275,7 @@ impl NodeNetwork {
|
|||
|
||||
/// Creates a proto network for evaluating each output of this network.
|
||||
pub fn into_proto_networks(self) -> impl Iterator<Item = ProtoNetwork> {
|
||||
// let input_node = self.nodes.iter().find_map(|(node_id, node)| if node.name == "SetNode" { Some(node_id.clone()) } else { None });
|
||||
let mut nodes: Vec<_> = self.nodes.into_iter().map(|(id, node)| (id, node.resolve_proto_node())).collect();
|
||||
let nodes: Vec<_> = self.nodes.into_iter().map(|(id, node)| (id, node.resolve_proto_node())).collect();
|
||||
|
||||
// Create a network to evaluate each output
|
||||
if self.exports.len() == 1 {
|
||||
|
@ -1285,7 +1283,7 @@ impl NodeNetwork {
|
|||
return vec![ProtoNetwork {
|
||||
inputs: Vec::new(),
|
||||
output: node_id,
|
||||
nodes: nodes,
|
||||
nodes,
|
||||
}]
|
||||
.into_iter();
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::document::{NodeId, OriginalLocation};
|
|||
|
||||
use dyn_any::DynAny;
|
||||
use graphene_core::*;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
#[cfg(feature = "serde")]
|
||||
use std::borrow::Cow;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
@ -430,10 +430,7 @@ impl ProtoNetwork {
|
|||
}
|
||||
|
||||
fn collect_inwards_edges_with_mapping(&self) -> (Vec<Vec<usize>>, FxHashMap<NodeId, usize>) {
|
||||
let mut id_map = FxHashMap::with_capacity_and_hasher(self.nodes.len(), Default::default());
|
||||
|
||||
// Create dense mapping
|
||||
id_map = self.nodes.iter().enumerate().map(|(idx, (id, _))| (*id, idx)).collect();
|
||||
let id_map: FxHashMap<_, _> = self.nodes.iter().enumerate().map(|(idx, (id, _))| (*id, idx)).collect();
|
||||
|
||||
// Collect inwards edges using dense indices
|
||||
let mut inwards_edges = vec![Vec::new(); self.nodes.len()];
|
||||
|
@ -584,7 +581,7 @@ impl ProtoNetwork {
|
|||
|
||||
/// Sort the nodes vec so it is in a topological order. This ensures that no node takes an input from a node that is found later in the list.
|
||||
fn reorder_ids(&mut self) -> Result<(), String> {
|
||||
let (order, id_map) = self.topological_sort()?;
|
||||
let (order, _id_map) = self.topological_sort()?;
|
||||
|
||||
// // Map of node ids to their current index in the nodes vector
|
||||
// let current_positions: FxHashMap<_, _> = self.nodes.iter().enumerate().map(|(pos, (id, _))| (*id, pos)).collect();
|
||||
|
|
|
@ -370,7 +370,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
|
|||
prompt: prompt.await,
|
||||
seed: seed.await,
|
||||
steps: samples.await,
|
||||
cfg_scale: prompt_guidance.await as f64,
|
||||
cfg_scale: prompt_guidance.await,
|
||||
width: res.x,
|
||||
height: res.y,
|
||||
restore_faces: improve_faces.await,
|
||||
|
@ -385,7 +385,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
|
|||
override_settings: Default::default(),
|
||||
|
||||
init_images: vec![base64_data],
|
||||
denoising_strength: image_creativity.await as f64 * 0.01,
|
||||
denoising_strength: image_creativity.await * 0.01,
|
||||
mask: None,
|
||||
};
|
||||
let url = join_url(&base_url, SDAPI_IMAGE_TO_IMAGE)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue