mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
janitor: Remove some unnecessary references
These are immediently dereferenced by the compiler according to clippy. Remove some now unnecessary muts to make things build again.
This commit is contained in:
parent
e99c1afa4b
commit
3e448f75eb
17 changed files with 57 additions and 68 deletions
|
@ -141,7 +141,7 @@ pub fn build_item_tree<T: ItemTreeBuilder>(
|
|||
if let Some(sub_component) = root_component.root_element.borrow().sub_component() {
|
||||
assert!(root_component.root_element.borrow().children.is_empty());
|
||||
let sub_compo_state =
|
||||
builder.enter_component(&root_component.root_element, &sub_component, 1, initial_state);
|
||||
builder.enter_component(&root_component.root_element, sub_component, 1, initial_state);
|
||||
builder.enter_component_children(
|
||||
&root_component.root_element,
|
||||
0,
|
||||
|
@ -156,7 +156,7 @@ pub fn build_item_tree<T: ItemTreeBuilder>(
|
|||
visit_children(
|
||||
initial_state,
|
||||
&root_component.root_element.borrow().children,
|
||||
&root_component,
|
||||
root_component,
|
||||
&root_component.root_element,
|
||||
0,
|
||||
0,
|
||||
|
@ -222,7 +222,7 @@ pub fn build_item_tree<T: ItemTreeBuilder>(
|
|||
visit_children(
|
||||
&sub_component_state,
|
||||
&nested_subcomponent.root_element.borrow().children,
|
||||
&nested_subcomponent,
|
||||
nested_subcomponent,
|
||||
&nested_subcomponent.root_element,
|
||||
parent_index,
|
||||
relative_parent_index,
|
||||
|
@ -242,7 +242,7 @@ pub fn build_item_tree<T: ItemTreeBuilder>(
|
|||
for child in children.iter() {
|
||||
if let Some(sub_component) = child.borrow().sub_component() {
|
||||
let sub_component_state =
|
||||
builder.enter_component(child, &sub_component, offset, state);
|
||||
builder.enter_component(child, sub_component, offset, state);
|
||||
visit_item(
|
||||
&sub_component_state,
|
||||
&sub_component.root_element,
|
||||
|
@ -321,7 +321,7 @@ pub fn build_item_tree<T: ItemTreeBuilder>(
|
|||
let base = item.borrow().sub_component().map(|c| {
|
||||
(
|
||||
c.root_element.clone(),
|
||||
builder.enter_component(&item, &c, children_offset, &component_state),
|
||||
builder.enter_component(&item, c, children_offset, &component_state),
|
||||
)
|
||||
});
|
||||
base
|
||||
|
|
|
@ -1173,8 +1173,8 @@ fn generate_component(
|
|||
base_component,
|
||||
self.component,
|
||||
repeater_count,
|
||||
&mut self.component_struct,
|
||||
&mut self.init,
|
||||
self.component_struct,
|
||||
self.init,
|
||||
&mut self.children_visitor_cases,
|
||||
self.diag,
|
||||
);
|
||||
|
@ -1194,7 +1194,7 @@ fn generate_component(
|
|||
) {
|
||||
let item = item_rc.borrow();
|
||||
if component_state.is_empty() {
|
||||
handle_item(item_rc, self.field_access, &mut self.component_struct);
|
||||
handle_item(item_rc, self.field_access, self.component_struct);
|
||||
}
|
||||
if item.is_flickable_viewport {
|
||||
self.tree_array.push(format!(
|
||||
|
@ -1231,7 +1231,7 @@ fn generate_component(
|
|||
let item = item_rc.borrow();
|
||||
// Sub-components don't have an entry in the item tree themselves, but we propagate their tree offsets through the constructors.
|
||||
if component_state.is_empty() {
|
||||
let class_name = self::component_id(&sub_component);
|
||||
let class_name = self::component_id(sub_component);
|
||||
let member_name = ident(&item.id).into_owned();
|
||||
|
||||
self.init.push(format!("{}.init(self_weak.into_dyn());", member_name));
|
||||
|
@ -1475,7 +1475,7 @@ fn generate_component(
|
|||
"(sixtyfps::Orientation o, [[maybe_unused]] const sixtyfps::private_api::WindowRc *window_handle) const -> sixtyfps::LayoutInfo"
|
||||
.into(),
|
||||
statements: Some(layout_info_function_body(
|
||||
&component,
|
||||
component,
|
||||
"auto self = this;".to_owned(),
|
||||
Some("window_handle"),
|
||||
)),
|
||||
|
@ -1693,7 +1693,7 @@ fn generate_component_vtable(
|
|||
"([[maybe_unused]] sixtyfps::private_api::ComponentRef component, sixtyfps::Orientation o) -> sixtyfps::LayoutInfo"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(layout_info_function_body(&component, format!(
|
||||
statements: Some(layout_info_function_body(component, format!(
|
||||
"[[maybe_unused]] auto self = reinterpret_cast<const {}*>(component.instance);",
|
||||
component_id
|
||||
), None)),
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn generate(doc: &Document, diag: &mut BuildDiagnostics) -> Option<TokenStre
|
|||
|
||||
let mut sub_compos = Vec::new();
|
||||
for sub_comp in doc.root_component.used_types.borrow().sub_components.iter() {
|
||||
sub_compos.push(generate_component(&sub_comp, &doc.root_component, diag)?);
|
||||
sub_compos.push(generate_component(sub_comp, &doc.root_component, diag)?);
|
||||
}
|
||||
|
||||
let compo = generate_component(&doc.root_component, &doc.root_component, diag)?;
|
||||
|
@ -333,7 +333,7 @@ fn generate_component(
|
|||
.popup_windows
|
||||
.borrow()
|
||||
.iter()
|
||||
.filter_map(|c| generate_component(&c.component, &root_component, diag))
|
||||
.filter_map(|c| generate_component(&c.component, root_component, diag))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let self_init = if !component.is_global() {
|
||||
|
@ -495,7 +495,7 @@ fn generate_component(
|
|||
let item = item_rc.borrow();
|
||||
let base_component = item.base_type.as_component();
|
||||
self.extra_components.push(
|
||||
generate_component(&*base_component, &self.root_component, self.diag)
|
||||
generate_component(&*base_component, self.root_component, self.diag)
|
||||
.unwrap_or_else(|| {
|
||||
assert!(self.diag.has_error());
|
||||
Default::default()
|
||||
|
@ -801,8 +801,8 @@ fn generate_component(
|
|||
repeated_element_names: vec![],
|
||||
repeated_visit_branch: vec![],
|
||||
repeated_element_components: vec![],
|
||||
generating_component: &component,
|
||||
root_component: &root_component,
|
||||
generating_component: component,
|
||||
root_component,
|
||||
root_ref_tokens,
|
||||
item_index_base_tokens,
|
||||
diag,
|
||||
|
@ -1190,7 +1190,7 @@ fn generate_component(
|
|||
None
|
||||
};
|
||||
|
||||
let root_component_id = self::inner_component_id(&root_component);
|
||||
let root_component_id = self::inner_component_id(root_component);
|
||||
let (root_field, root_initializer) = if component.is_sub_component() {
|
||||
(
|
||||
Some(
|
||||
|
|
|
@ -387,7 +387,7 @@ fn find_binding<R>(
|
|||
|
||||
/// Return a named reference to a property if a binding is set on that property
|
||||
fn binding_reference(element: &ElementRc, name: &str) -> Option<NamedReference> {
|
||||
find_binding(element, name, |_, _, _| NamedReference::new(&element, name))
|
||||
find_binding(element, name, |_, _, _| NamedReference::new(element, name))
|
||||
}
|
||||
|
||||
fn init_fake_property(
|
||||
|
|
|
@ -282,7 +282,7 @@ impl Component {
|
|||
self.exported_global_names
|
||||
.borrow()
|
||||
.iter()
|
||||
.filter(|name| name.as_str() != &self.root_element.borrow().id)
|
||||
.filter(|name| name.as_str() != self.root_element.borrow().id)
|
||||
.map(|name| name.original_name())
|
||||
.collect()
|
||||
}
|
||||
|
@ -1479,7 +1479,7 @@ pub fn recurse_elem_including_sub_components_no_borrow<State>(
|
|||
.borrow()
|
||||
.globals
|
||||
.iter()
|
||||
.for_each(|p| recurse_elem_including_sub_components_no_borrow(&p, state, vis));
|
||||
.for_each(|p| recurse_elem_including_sub_components_no_borrow(p, state, vis));
|
||||
}
|
||||
|
||||
/// This visit the binding attached to this element, but does not recurse in children elements
|
||||
|
|
|
@ -44,7 +44,7 @@ use crate::langtype::Type;
|
|||
pub async fn run_passes(
|
||||
doc: &crate::object_tree::Document,
|
||||
diag: &mut crate::diagnostics::BuildDiagnostics,
|
||||
mut type_loader: &mut crate::typeloader::TypeLoader<'_>,
|
||||
type_loader: &mut crate::typeloader::TypeLoader<'_>,
|
||||
compiler_config: &crate::CompilerConfiguration,
|
||||
) {
|
||||
if matches!(doc.root_component.root_element.borrow().base_type, Type::Invalid | Type::Void) {
|
||||
|
@ -78,7 +78,7 @@ pub async fn run_passes(
|
|||
.chain(std::iter::once(root_component))
|
||||
{
|
||||
compile_paths::compile_paths(component, &doc.local_registry, diag);
|
||||
lower_tabwidget::lower_tabwidget(component, &mut type_loader, diag).await;
|
||||
lower_tabwidget::lower_tabwidget(component, type_loader, diag).await;
|
||||
apply_default_properties_from_style::apply_default_properties_from_style(
|
||||
component,
|
||||
&style_metrics,
|
||||
|
@ -108,7 +108,7 @@ pub async fn run_passes(
|
|||
flickable::handle_flickable(component, &global_type_registry.borrow());
|
||||
repeater_component::process_repeater_components(component);
|
||||
lower_popups::lower_popups(component, &doc.local_registry, diag);
|
||||
lower_layout::lower_layouts(component, &mut type_loader, diag).await;
|
||||
lower_layout::lower_layouts(component, type_loader, diag).await;
|
||||
z_order::reorder_by_z_order(component, diag);
|
||||
transform_and_opacity::handle_transform_and_opacity(
|
||||
component,
|
||||
|
@ -125,7 +125,7 @@ pub async fn run_passes(
|
|||
visible::handle_visible(component, &global_type_registry.borrow());
|
||||
materialize_fake_properties::materialize_fake_properties(component);
|
||||
}
|
||||
collect_globals::collect_globals(&doc, diag);
|
||||
collect_globals::collect_globals(doc, diag);
|
||||
|
||||
if compiler_config.inline_all_elements {
|
||||
inlining::inline(doc, inlining::InlineSelection::InlineAllComponents);
|
||||
|
@ -155,7 +155,7 @@ pub async fn run_passes(
|
|||
remove_unused_properties::remove_unused_properties(component);
|
||||
}
|
||||
|
||||
collect_structs::collect_structs(&doc);
|
||||
collect_structs::collect_structs(doc);
|
||||
|
||||
for component in (root_component.used_types.borrow().sub_components.iter())
|
||||
.chain(std::iter::once(root_component))
|
||||
|
|
|
@ -47,13 +47,8 @@ fn embed_images_from_expression(
|
|||
}
|
||||
};
|
||||
|
||||
e.visit_mut(|mut e| {
|
||||
embed_images_from_expression(
|
||||
&mut e,
|
||||
global_embedded_resources,
|
||||
embed_files_by_default,
|
||||
diag,
|
||||
)
|
||||
e.visit_mut(|e| {
|
||||
embed_images_from_expression(e, global_embedded_resources, embed_files_by_default, diag)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -279,13 +279,13 @@ fn duplicate_sub_component(
|
|||
.map(|p| duplicate_popup(p, mapping))
|
||||
.collect();
|
||||
for p in new_component.popup_windows.borrow_mut().iter_mut() {
|
||||
fixup_reference(&mut p.x, &mapping);
|
||||
fixup_reference(&mut p.y, &mapping);
|
||||
fixup_reference(&mut p.x, mapping);
|
||||
fixup_reference(&mut p.y, mapping);
|
||||
}
|
||||
new_component
|
||||
.root_constraints
|
||||
.borrow_mut()
|
||||
.visit_named_references(&mut |nr| fixup_reference(nr, &mapping));
|
||||
.visit_named_references(&mut |nr| fixup_reference(nr, mapping));
|
||||
new_component
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn materialize_fake_properties(component: &Rc<Component>) {
|
|||
}
|
||||
});
|
||||
for prop in elem.borrow().bindings.keys() {
|
||||
let nr = NamedReference::new(&elem, &prop);
|
||||
let nr = NamedReference::new(elem, prop);
|
||||
if !to_materialize.contains_key(&nr) {
|
||||
let elem = elem.borrow();
|
||||
if let Some(ty) =
|
||||
|
|
|
@ -163,7 +163,7 @@ impl Expression {
|
|||
return Expression::Invalid;
|
||||
}
|
||||
};
|
||||
e.maybe_convert_to(ctx.property_type.clone(), &node, &mut ctx.diag)
|
||||
e.maybe_convert_to(ctx.property_type.clone(), &node, ctx.diag)
|
||||
}
|
||||
|
||||
fn from_codeblock_node(node: syntax_nodes::CodeBlock, ctx: &mut LookupCtx) -> Expression {
|
||||
|
@ -198,7 +198,7 @@ impl Expression {
|
|||
|
||||
exit_points_and_return_types.into_iter().for_each(|(index, _)| {
|
||||
let mut expr = std::mem::replace(&mut statements_or_exprs[index], Expression::Invalid);
|
||||
expr = expr.maybe_convert_to(common_return_type.clone(), &node, &mut ctx.diag);
|
||||
expr = expr.maybe_convert_to(common_return_type.clone(), &node, ctx.diag);
|
||||
statements_or_exprs[index] = expr;
|
||||
});
|
||||
|
||||
|
@ -214,7 +214,7 @@ impl Expression {
|
|||
Box::new(Self::from_expression_node(n, ctx).maybe_convert_to(
|
||||
return_type,
|
||||
&node,
|
||||
&mut ctx.diag,
|
||||
ctx.diag,
|
||||
))
|
||||
}))
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ impl Expression {
|
|||
Self::from_codeblock_node(node.CodeBlock(), ctx).maybe_convert_to(
|
||||
ctx.return_type().clone(),
|
||||
&node,
|
||||
&mut ctx.diag,
|
||||
ctx.diag,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ impl Expression {
|
|||
Box::new(Expression::from_expression_node(angle_expr.clone(), ctx).maybe_convert_to(
|
||||
Type::Angle,
|
||||
&angle_expr,
|
||||
&mut ctx.diag,
|
||||
ctx.diag,
|
||||
));
|
||||
|
||||
let mut stops = vec![];
|
||||
|
@ -405,15 +405,14 @@ impl Expression {
|
|||
};
|
||||
match std::mem::replace(&mut current_stop, Stop::Finished) {
|
||||
Stop::Empty => {
|
||||
current_stop =
|
||||
Stop::Color(e.maybe_convert_to(Type::Color, &n, &mut ctx.diag))
|
||||
current_stop = Stop::Color(e.maybe_convert_to(Type::Color, &n, ctx.diag))
|
||||
}
|
||||
Stop::Finished => {
|
||||
ctx.diag.push_error("Expected comma".into(), &n);
|
||||
break;
|
||||
}
|
||||
Stop::Color(col) => {
|
||||
stops.push((col, e.maybe_convert_to(Type::Float32, &n, &mut ctx.diag)))
|
||||
stops.push((col, e.maybe_convert_to(Type::Float32, &n, ctx.diag)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +515,7 @@ impl Expression {
|
|||
};
|
||||
|
||||
if let Some(depr) = result.deprecated() {
|
||||
ctx.diag.push_property_deprecation_warning(&first_str, &depr, &first);
|
||||
ctx.diag.push_property_deprecation_warning(&first_str, depr, &first);
|
||||
}
|
||||
|
||||
match result {
|
||||
|
@ -617,12 +616,7 @@ impl Expression {
|
|||
let function = match function {
|
||||
Expression::BuiltinMacroReference(mac, n) => {
|
||||
arguments.extend(sub_expr);
|
||||
return crate::builtin_macros::lower_macro(
|
||||
mac,
|
||||
n,
|
||||
arguments.into_iter(),
|
||||
&mut ctx.diag,
|
||||
);
|
||||
return crate::builtin_macros::lower_macro(mac, n, arguments.into_iter(), ctx.diag);
|
||||
}
|
||||
Expression::MemberFunction { base, base_node, member } => {
|
||||
arguments.push((*base, base_node));
|
||||
|
@ -648,7 +642,7 @@ impl Expression {
|
|||
arguments
|
||||
.into_iter()
|
||||
.zip(args.iter())
|
||||
.map(|((e, node), ty)| e.maybe_convert_to(ty.clone(), &node, &mut ctx.diag))
|
||||
.map(|((e, node), ty)| e.maybe_convert_to(ty.clone(), &node, ctx.diag))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
@ -706,7 +700,7 @@ impl Expression {
|
|||
let rhs = Self::from_expression_node(rhs_n.clone(), ctx);
|
||||
Expression::SelfAssignment {
|
||||
lhs: Box::new(lhs),
|
||||
rhs: Box::new(rhs.maybe_convert_to(expected_ty, &rhs_n, &mut ctx.diag)),
|
||||
rhs: Box::new(rhs.maybe_convert_to(expected_ty, &rhs_n, ctx.diag)),
|
||||
op,
|
||||
}
|
||||
}
|
||||
|
@ -773,7 +767,7 @@ impl Expression {
|
|||
rhs: Box::new(rhs.maybe_convert_to(
|
||||
Type::Float32,
|
||||
&rhs_n,
|
||||
&mut ctx.diag,
|
||||
ctx.diag,
|
||||
)),
|
||||
op,
|
||||
}
|
||||
|
@ -783,7 +777,7 @@ impl Expression {
|
|||
lhs: Box::new(lhs.maybe_convert_to(
|
||||
Type::Float32,
|
||||
&lhs_n,
|
||||
&mut ctx.diag,
|
||||
ctx.diag,
|
||||
)),
|
||||
rhs: Box::new(rhs),
|
||||
op,
|
||||
|
@ -797,8 +791,8 @@ impl Expression {
|
|||
}
|
||||
};
|
||||
Expression::BinaryExpression {
|
||||
lhs: Box::new(lhs.maybe_convert_to(expected_ty.clone(), &lhs_n, &mut ctx.diag)),
|
||||
rhs: Box::new(rhs.maybe_convert_to(expected_ty, &rhs_n, &mut ctx.diag)),
|
||||
lhs: Box::new(lhs.maybe_convert_to(expected_ty.clone(), &lhs_n, ctx.diag)),
|
||||
rhs: Box::new(rhs.maybe_convert_to(expected_ty, &rhs_n, ctx.diag)),
|
||||
op,
|
||||
}
|
||||
}
|
||||
|
@ -829,15 +823,15 @@ impl Expression {
|
|||
let condition = Self::from_expression_node(condition_n.clone(), ctx).maybe_convert_to(
|
||||
Type::Bool,
|
||||
&condition_n,
|
||||
&mut ctx.diag,
|
||||
ctx.diag,
|
||||
);
|
||||
let true_expr = Self::from_expression_node(true_expr_n.clone(), ctx);
|
||||
let false_expr = Self::from_expression_node(false_expr_n.clone(), ctx);
|
||||
let result_ty = Self::common_target_type_for_type_list(
|
||||
[true_expr.ty(), false_expr.ty()].iter().cloned(),
|
||||
);
|
||||
let true_expr = true_expr.maybe_convert_to(result_ty.clone(), &true_expr_n, &mut ctx.diag);
|
||||
let false_expr = false_expr.maybe_convert_to(result_ty, &false_expr_n, &mut ctx.diag);
|
||||
let true_expr = true_expr.maybe_convert_to(result_ty.clone(), &true_expr_n, ctx.diag);
|
||||
let false_expr = false_expr.maybe_convert_to(result_ty, &false_expr_n, ctx.diag);
|
||||
Expression::Condition {
|
||||
condition: Box::new(condition),
|
||||
true_expr: Box::new(true_expr),
|
||||
|
|
|
@ -255,7 +255,7 @@ fn handle_mouse_grab(
|
|||
let input_result = grabber.borrow().as_ref().input_event(event, window, &grabber);
|
||||
if input_result != InputEventResult::GrabMouse {
|
||||
mouse_input_state.grabbed = false;
|
||||
send_exit_events(&mouse_input_state, mouse_event.pos(), window);
|
||||
send_exit_events(mouse_input_state, mouse_event.pos(), window);
|
||||
}
|
||||
|
||||
true
|
||||
|
|
|
@ -247,7 +247,7 @@ impl Window {
|
|||
|
||||
if let MouseEvent::MousePressed { pos, .. } = &event {
|
||||
// close the popup if one press outside the popup
|
||||
let geom = ComponentRc::borrow_pin(&popup_component)
|
||||
let geom = ComponentRc::borrow_pin(popup_component)
|
||||
.as_ref()
|
||||
.get_item_ref(0)
|
||||
.as_ref()
|
||||
|
|
|
@ -507,7 +507,7 @@ impl FontCache {
|
|||
request
|
||||
.family
|
||||
.as_ref()
|
||||
.map(|family_name| self.available_families.contains(&family_name))
|
||||
.map(|family_name| self.available_families.contains(family_name))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ impl WinitWindow for GLWindow {
|
|||
|
||||
for (component, origin) in components {
|
||||
corelib::item_rendering::render_component_items(
|
||||
&component,
|
||||
component,
|
||||
&mut renderer,
|
||||
origin.clone(),
|
||||
);
|
||||
|
|
|
@ -759,7 +759,7 @@ impl ItemRenderer for GLItemRenderer {
|
|||
cache.borrow_mut().font(
|
||||
self.graphics_window.default_font_properties(),
|
||||
self.scale_factor,
|
||||
&string,
|
||||
string,
|
||||
)
|
||||
});
|
||||
let paint = font.init_paint(0.0, femtovg::Paint::color(to_femtovg_color(&color)));
|
||||
|
|
|
@ -284,7 +284,7 @@ fn prepare_scene(runtime_window: Rc<sixtyfps_corelib::window::Window>, size: Siz
|
|||
runtime_window.draw_contents(|components| {
|
||||
for (component, origin) in components {
|
||||
sixtyfps_corelib::item_rendering::render_component_items(
|
||||
&component,
|
||||
component,
|
||||
&mut prepare_scene,
|
||||
origin.clone(),
|
||||
);
|
||||
|
@ -317,7 +317,7 @@ impl PrepareScene {
|
|||
fn should_draw(&self, rect: &RectF) -> bool {
|
||||
!rect.size.is_empty()
|
||||
&& self.current_state.alpha > 0.01
|
||||
&& self.current_state.clip.intersects(&rect)
|
||||
&& self.current_state.clip.intersects(rect)
|
||||
}
|
||||
|
||||
fn new_scene_item(&mut self, geometry: RectF, command: SceneCommand) {
|
||||
|
|
|
@ -1132,7 +1132,7 @@ impl QtWindow {
|
|||
|
||||
for (component, origin) in components {
|
||||
sixtyfps_corelib::item_rendering::render_component_items(
|
||||
&component,
|
||||
component,
|
||||
&mut renderer,
|
||||
origin.clone(),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue