mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
Clear the remaining clippy warnings on the diff surface
This commit is contained in:
@@ -546,10 +546,10 @@ impl NodeRuntime {
|
||||
Some(())
|
||||
}
|
||||
});
|
||||
if result.is_err() {
|
||||
if let Err(_error) = result {
|
||||
// TODO: Fix the root of the issue causing the spam of this warning (this at least temporarily disables it in release builds)
|
||||
#[cfg(debug_assertions)]
|
||||
warn!("Failed to introspect monitor node {}", result.unwrap_err());
|
||||
warn!("Failed to introspect monitor node {}", _error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ impl DynamicExecutor {
|
||||
let result = self.tree.introspect(node_path)?;
|
||||
if result.downcast_ref::<core_types::context::CtxSnapshot>().is_some() {
|
||||
return self
|
||||
.introspect_with(node_path, |layout, batch, arena| graphic_types::boundary::batch_to_legacy(layout, batch, arena))
|
||||
.introspect_with(node_path, graphic_types::boundary::batch_to_legacy)
|
||||
.map(Arc::from);
|
||||
}
|
||||
Ok(result)
|
||||
|
||||
@@ -196,7 +196,7 @@ impl Arena {
|
||||
let count = COUNT.fetch_add(1, Ordering::Relaxed);
|
||||
if reserved.is_none() {
|
||||
eprintln!("arena> EXHAUSTED after {count} allocations, wanted {size} bytes\n{}", std::backtrace::Backtrace::force_capture());
|
||||
} else if count % 20000 == 0 {
|
||||
} else if count.is_multiple_of(20000) {
|
||||
eprintln!("arena> {count} allocations, offset {}, this {size} bytes", self.offset.load(Ordering::Relaxed));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,6 @@ mod tests {
|
||||
let scope = frames.scope();
|
||||
let mut claim = scope.claim(&layout);
|
||||
addresses.push(claim.dst() as usize);
|
||||
drop(claim);
|
||||
drop(scope);
|
||||
assert_eq!(frames.free_words(), free, "the scope returns its claims");
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ impl FieldWrite {
|
||||
unsafe { &*ptr.cast::<V>() }.cache_hash(&mut state);
|
||||
}
|
||||
unsafe fn content_eq<V: PartialEq>(a: *const u8, b: *const u8) -> bool {
|
||||
unsafe { &*a.cast::<V>() == &*b.cast::<V>() }
|
||||
unsafe { *a.cast::<V>() == *b.cast::<V>() }
|
||||
}
|
||||
Self {
|
||||
name: A::NAME,
|
||||
@@ -656,7 +656,7 @@ mod tests {
|
||||
#[derive(Clone, dyn_any::DynAny)]
|
||||
struct Opaque;
|
||||
|
||||
let hashed = (&ElementWritePick::<String>(std::marker::PhantomData)).element_write();
|
||||
let hashed = ElementWritePick::<String>(std::marker::PhantomData).element_write();
|
||||
assert!(hashed.content_hash.is_some() && hashed.content_eq.is_some());
|
||||
let plain = (&ElementWritePick::<Opaque>(std::marker::PhantomData)).element_write();
|
||||
assert!(plain.content_hash.is_none() && plain.content_eq.is_none());
|
||||
|
||||
@@ -97,7 +97,7 @@ where
|
||||
let Some(plan) = &self.plan else {
|
||||
return self.edge.serve(input, slot);
|
||||
};
|
||||
match serve_input(&self.edge, input, &mut slot.frames().reborrow()) {
|
||||
match serve_input(&self.edge, input, &slot.frames().reborrow()) {
|
||||
GPoll::Final(value) => {
|
||||
// SAFETY: the value came from this source, so it carries the
|
||||
// plan's source layout.
|
||||
|
||||
@@ -171,7 +171,7 @@ impl<'e> GroupItem<'e> {
|
||||
// A run already living in the target region needs no copy: the arena is
|
||||
// insert-only within a generation, so the lanes cannot move or change
|
||||
// while the adopting item borrows them.
|
||||
if batch.len() > 0 && arena.contains(batch.frames_ptr()) {
|
||||
if !batch.is_empty() && arena.contains(batch.frames_ptr()) {
|
||||
return Some(Self {
|
||||
layout,
|
||||
storage: ItemStorage::Resident(batch.frames_ptr()),
|
||||
|
||||
@@ -553,9 +553,9 @@ mod run_tests {
|
||||
|
||||
let arena = core_types::arena::Arena::new(1 << 16).unwrap();
|
||||
let mut builder = RunBuilder::new(&arena, element_write_hashed::<Vector>(), &[FieldWrite::of::<core_types::attribute::Transform>(0)], 2).unwrap();
|
||||
for lane in 0..2 {
|
||||
let lane = builder.push(vectors[lane].clone()).unwrap();
|
||||
builder.attr::<core_types::attribute::Transform>(lane, transforms[lane]);
|
||||
for (vector, transform) in vectors.iter().zip(transforms) {
|
||||
let lane = builder.push(vector.clone()).unwrap();
|
||||
builder.attr::<core_types::attribute::Transform>(lane, transform);
|
||||
}
|
||||
let item = builder.finish();
|
||||
let run = RunView::<Vector>::new(&item).expect("the run holds vector elements");
|
||||
|
||||
@@ -197,7 +197,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
let field_pushed_levels: Vec<u8> = regular_fields
|
||||
.iter()
|
||||
.map(|field| match &field.ty {
|
||||
ParsedFieldType::Regular(RegularParsedField { list_levels, .. }) if *list_levels > 0 => *list_levels as u8,
|
||||
ParsedFieldType::Regular(RegularParsedField { list_levels, .. }) if *list_levels > 0 => *list_levels,
|
||||
ParsedFieldType::Node(_) => pushed_levels,
|
||||
_ => 0,
|
||||
})
|
||||
@@ -2433,20 +2433,20 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(index, _)| ir::materialized_levels(&node, *index) == 0)
|
||||
.filter_map(|(_, field)| match &field.ty {
|
||||
.map(|(_, field)| match &field.ty {
|
||||
// The conditional arena-park moves a lend element once.
|
||||
ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => Some({
|
||||
ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => {
|
||||
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
|
||||
quote!(#ty: ::core::marker::Send + ::core::marker::Sync + 'static)
|
||||
}),
|
||||
ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({
|
||||
}
|
||||
ParsedFieldType::Regular(RegularParsedField { ty, .. }) => {
|
||||
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
|
||||
quote!(#ty: ::core::clone::Clone)
|
||||
}),
|
||||
ParsedFieldType::Node(NodeParsedField { output_type, .. }) => Some({
|
||||
}
|
||||
ParsedFieldType::Node(NodeParsedField { output_type, .. }) => {
|
||||
let output_type = &crate::codegen::classify::substitute_lifetimes(output_type, "'static");
|
||||
quote!(#output_type: ::core::clone::Clone)
|
||||
}),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let out = crate::codegen::classify::substitute_lifetimes(&slot_value_type(&parsed.output_type), "'static");
|
||||
|
||||
@@ -312,7 +312,7 @@ pub(crate) fn record_shape(parsed: &ParsedNodeFn) -> Option<RecordShape> {
|
||||
ParsedFieldType::Node(NodeParsedField { output_type, .. }) => is_served(output_type) || crate::codegen::ir::strip_ilist(output_type).1 > 0 || !field.attribute_reads.is_empty(),
|
||||
ParsedFieldType::Regular(_) => false,
|
||||
};
|
||||
if parsed.fields.iter().skip(lazy_carrier as usize).any(|field| unsupported_lazy_secondary(field)) {
|
||||
if parsed.fields.iter().skip(lazy_carrier as usize).any(unsupported_lazy_secondary) {
|
||||
return None;
|
||||
}
|
||||
let reads_well_placed = parsed.fields.iter().enumerate().all(|(index, field)| {
|
||||
@@ -575,7 +575,7 @@ pub(crate) fn routing_io(parsed: &ParsedNodeFn) -> Option<RoutingIo> {
|
||||
}
|
||||
}
|
||||
}
|
||||
(sources > 0).then(|| RoutingIo { generic: ident })
|
||||
(sources > 0).then_some(RoutingIo { generic: ident })
|
||||
}
|
||||
|
||||
pub(crate) fn bare_ident(ty: &Type) -> Option<&Ident> {
|
||||
|
||||
@@ -100,7 +100,7 @@ fn flip_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regular_field
|
||||
}
|
||||
}
|
||||
let alias_params: Vec<&GenericParam> = candidate_params.iter().zip(&kept).filter(|(_, kept)| **kept).map(|(param, _)| *param).collect();
|
||||
let alias_param_idents: Vec<Ident> = alias_params.iter().map(|param| param_ident(param)).collect();
|
||||
let alias_param_idents: Vec<Ident> = alias_params.iter().map(param_ident).collect();
|
||||
let alias_param_tokens: Vec<TokenStream2> = alias_params.iter().map(|param| quote!(#param)).collect();
|
||||
let output_alias = format_ident!("__{}_output", fn_name);
|
||||
let alias_def = match alias_param_tokens.is_empty() {
|
||||
|
||||
@@ -48,7 +48,7 @@ fn generics(parsed: &ParsedNodeFn) -> Vec<Generic> {
|
||||
|
||||
fn inputs(parsed: &ParsedNodeFn, fields: &[&ParsedField], generics: &[Ident]) -> Vec<Input> {
|
||||
let routing = routing_io(parsed);
|
||||
let carrier_subject = flip_carrier(parsed) || record_shape(parsed).map_or(false, |shape| !shape.skips_carrier());
|
||||
let carrier_subject = flip_carrier(parsed) || record_shape(parsed).is_some_and(|shape| !shape.skips_carrier());
|
||||
fields
|
||||
.iter()
|
||||
.enumerate()
|
||||
@@ -263,13 +263,16 @@ fn ilist_inner(ty: &Type) -> Option<Type> {
|
||||
/// caller since it is the one row-dependent facet; the rest folds from the node.
|
||||
pub(crate) fn layout_meta_tokens(node: &Node, element_spec: TokenStream2, core_types: &TokenStream2) -> TokenStream2 {
|
||||
let sources = layout_sources(node).into_iter().map(|index| index as u8);
|
||||
let reads = node.inputs.iter().enumerate().filter_map(|(index, input)| {
|
||||
(matches!(input.evaluation, Evaluation::Eager) && !input.shape.attrs.is_empty()).then(|| {
|
||||
let reads = node
|
||||
.inputs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, input)| matches!(input.evaluation, Evaluation::Eager) && !input.shape.attrs.is_empty())
|
||||
.map(|(index, input)| {
|
||||
let descs = field_writes(&input.shape.attrs, core_types);
|
||||
let index = index as u8;
|
||||
quote!(#core_types::record::InputReads { input: #index, reads: ::std::vec![#(#descs),*] })
|
||||
})
|
||||
});
|
||||
});
|
||||
let writes = field_writes(&node.output.shape.attrs, core_types);
|
||||
let removes = node.output.removes.iter().map(|attr| {
|
||||
let marker = &attr.marker;
|
||||
@@ -859,9 +862,7 @@ mod tests {
|
||||
let routing_source = |ty: &Type| generic.as_ref().is_some_and(|generic| crate::codegen::classify::routing_source_output(ty, generic));
|
||||
match &field.ty {
|
||||
ParsedFieldType::Regular(RegularParsedField { ty, lend, .. }) => {
|
||||
if record && !skips_carrier && index == 0 {
|
||||
"carrier"
|
||||
} else if carrier_flip && index == 0 {
|
||||
if index == 0 && ((record && !skips_carrier) || carrier_flip) {
|
||||
"carrier"
|
||||
} else if flip && lend.is_some() {
|
||||
"lend"
|
||||
|
||||
@@ -83,10 +83,7 @@ fn brush_stamp_generator(_: impl Ctx, #[unit(" px")] diameter: f64, color: Color
|
||||
|
||||
/// Used to efficiently paint brush strokes. Applies the same texture repeatedly at different positions with proper blending and boundary handling.
|
||||
#[node_macro::node(category(""), skip_impl)]
|
||||
fn blit<BlendFn>(_: impl Ctx, mut target: List<Raster<CPU>>, texture: Raster<CPU>, positions: Vec<DVec2>, blend_mode: BlendFn) -> List<Raster<CPU>>
|
||||
where
|
||||
BlendFn: Fn(Color, Color) -> Color,
|
||||
{
|
||||
fn blit<BlendFn: Fn(Color, Color) -> Color>(_: impl Ctx, mut target: List<Raster<CPU>>, texture: Raster<CPU>, positions: Vec<DVec2>, blend_mode: BlendFn) -> List<Raster<CPU>> {
|
||||
if positions.is_empty() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ fn read_gradient(ctx: impl Ctx + ExtractVarArgs) -> List<GradientStops> {
|
||||
}
|
||||
|
||||
/// The mapped row riding as vararg 0, in the production single-item shape.
|
||||
fn vararg_list<'a, T: 'static>(ctx: &'a impl ExtractVarArgs) -> Option<&'a List<T>> {
|
||||
fn vararg_list<T: 'static>(ctx: &impl ExtractVarArgs) -> Option<&List<T>> {
|
||||
let arg = ctx.vararg(0).ok()?;
|
||||
(arg as &dyn std::any::Any).downcast_ref::<List<T>>()
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ fn memoize<'e, 'l>(
|
||||
return serve(entry, slot);
|
||||
}
|
||||
if leveled {
|
||||
return match content.materialize_level(&ctx, ctx.arena()) {
|
||||
return match content.materialize_level(ctx, ctx.arena()) {
|
||||
LevelStatus::Batch(batch, finality) => {
|
||||
let layout = content.layout();
|
||||
// SAFETY: the batch came from this input, so it carries the input's layout.
|
||||
@@ -107,7 +107,7 @@ fn memoize<'e, 'l>(
|
||||
};
|
||||
}
|
||||
// The output layout is the content's, so the claim is the content's frame.
|
||||
let result = content.serve(&ctx, slot);
|
||||
let result = content.serve(ctx, slot);
|
||||
let publishable = match &result {
|
||||
GPoll::Final(served) => Some((served.record(), Finality::AllFinal)),
|
||||
GPoll::Partial(served) => Some((served.record(), Finality::Partial)),
|
||||
@@ -196,7 +196,7 @@ fn frame_memo<'e, 'l>(
|
||||
return serve(published.get(lane).rec().ptr(), finality, slot);
|
||||
}
|
||||
if leveled {
|
||||
return match content.materialize_level(&ctx, ctx.arena()) {
|
||||
return match content.materialize_level(ctx, ctx.arena()) {
|
||||
LevelStatus::Batch(batch, finality) => {
|
||||
// SAFETY: the batch came from this input, so it carries the input's layout.
|
||||
let span = unsafe { MaterializedSpan::to_persistent(&batch, &promotion) };
|
||||
@@ -212,7 +212,7 @@ fn frame_memo<'e, 'l>(
|
||||
};
|
||||
}
|
||||
// The output layout is the content's, so the claim is the content's frame.
|
||||
let result = content.serve(&ctx, slot);
|
||||
let result = content.serve(ctx, slot);
|
||||
let publishable = match &result {
|
||||
GPoll::Final(served) => Some((served.record(), Finality::AllFinal)),
|
||||
GPoll::Partial(served) => Some((served.record(), Finality::Partial)),
|
||||
@@ -246,7 +246,7 @@ fn monitor<'e, 'l>(
|
||||
if ctx.index() == 0 {
|
||||
*io.lock().unwrap() = Some(CtxSnapshot::capture(ctx));
|
||||
}
|
||||
content.serve(&ctx, slot)
|
||||
content.serve(ctx, slot)
|
||||
}
|
||||
|
||||
fn serialize_monitor(io: &MonitorValue) -> Option<Arc<dyn std::any::Any + Send + Sync>> {
|
||||
|
||||
@@ -2983,8 +2983,8 @@ mod tests {
|
||||
{
|
||||
let scope = scope_fixture(&generations, &first_arena).with_persistent(&persistent);
|
||||
let ctx = ContextImpl::root(&scope);
|
||||
let mut first = frames.reborrow();
|
||||
let GPoll::Final(_) = core_types::record::serve_input(&memo, &ctx, &mut first) else {
|
||||
let first = frames.reborrow();
|
||||
let GPoll::Final(_) = core_types::record::serve_input(&memo, &ctx, &first) else {
|
||||
panic!("expected a final record");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ where
|
||||
}
|
||||
let fill = park_paint(legacy.attribute::<Option<List<Graphic>>>(graphic_types::ATTR_FILL, source).cloned().flatten())?;
|
||||
let stroke = park_paint(legacy.attribute::<Option<List<Graphic>>>(graphic_types::ATTR_STROKE, source).cloned().flatten())?;
|
||||
let layer_path: Vec<NodeId> = legacy.attribute::<Vec<NodeId>>(ATTR_EDITOR_LAYER_PATH, source).map(|path| path.clone()).unwrap_or_default();
|
||||
let layer_path: Vec<NodeId> = legacy.attribute::<Vec<NodeId>>(ATTR_EDITOR_LAYER_PATH, source).cloned().unwrap_or_default();
|
||||
let layer_path = arena.alloc(layer_path).ok_or_else(exhausted)?.0;
|
||||
|
||||
Ok((
|
||||
|
||||
@@ -885,8 +885,7 @@ mod tests {
|
||||
let GPoll::Final(value) = record::serve_input(&wrapped, &ctx.promoted(&head, 0), &scope) else {
|
||||
panic!("expected a final record");
|
||||
};
|
||||
let group = unsafe { record::borrow_element::<Graphic>(wrap_out.rec(&value)) }.clone();
|
||||
group
|
||||
unsafe { record::borrow_element::<Graphic>(wrap_out.rec(&value)) }.clone()
|
||||
};
|
||||
|
||||
// One row holding the wrapped group flattens back to the lanes, the
|
||||
|
||||
@@ -78,7 +78,7 @@ fn boolean_core<'e>(
|
||||
use core_types::lane::LaneSource;
|
||||
let fill = park_paint(result_vector_list.attr::<Fill>(0).filter(|paint| is_paint_present(paint)).cloned())?;
|
||||
let stroke = park_paint(result_vector_list.attr::<Stroke>(0).filter(|paint| is_paint_present(paint)).cloned())?;
|
||||
let layer_path: Vec<NodeId> = result_vector_list.attribute::<Vec<NodeId>>(ATTR_EDITOR_LAYER_PATH, 0).map(|path| path.clone()).unwrap_or_default();
|
||||
let layer_path: Vec<NodeId> = result_vector_list.attribute::<Vec<NodeId>>(ATTR_EDITOR_LAYER_PATH, 0).cloned().unwrap_or_default();
|
||||
let layer_path = arena.alloc(layer_path).ok_or_else(exhausted)?.0;
|
||||
// Snapshot the input layers so the renderer can recurse into them for
|
||||
// editor click-target preservation.
|
||||
|
||||
@@ -433,7 +433,7 @@ mod tests {
|
||||
#[test]
|
||||
fn qr_code_test() {
|
||||
let qr = qr_code(&(), (), "https://graphite.art".to_string(), false, 1., QRCodeErrorCorrectionLevel::Low, true);
|
||||
assert!(qr.point_domain.ids().len() > 0);
|
||||
assert!(qr.segment_domain.ids().len() > 0);
|
||||
assert!(!qr.point_domain.ids().is_empty());
|
||||
assert!(!qr.segment_domain.ids().is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1577,7 +1577,7 @@ fn emit_legacy_lane<'e>(
|
||||
/// one group lane, lane 0's layer path stamped on the wrapper.
|
||||
fn wrap_vector_level(content: core_types::node::List<'_, Vector>) -> List<Graphic<'_>> {
|
||||
let item = content.as_group_item();
|
||||
let layer_path: Vec<NodeId> = match content.len() > 0 {
|
||||
let layer_path: Vec<NodeId> = match !content.is_empty() {
|
||||
true => content.lane(0).attr::<EditorLayerPath>().to_vec(),
|
||||
false => Vec::new(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user