Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nightly clippy warnings #1563

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/analysis/enums.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use log::info;

use super::{function_parameters::TransformationType, imports::Imports, *};
use super::{
function_parameters::TransformationType, functions, imports::Imports, library,
special_functions,
};
use crate::{codegen::Visibility, config::gobjects::GObject, env::Env, nameutil::*, traits::*};

#[derive(Debug, Default)]
Expand Down Expand Up @@ -87,7 +90,7 @@ pub fn new(env: &Env, obj: &GObject, imports: &mut Imports) -> Option<Info> {
.unwrap();

if let TransformationType::ToGlibScalar { name, .. } = &mut t.transformation_type {
*name = "self".to_owned();
"self".clone_into(name);
} else {
panic!(
"Enumeration function instance param must be passed as scalar, not {:?}",
Expand Down
7 changes: 5 additions & 2 deletions src/analysis/flags.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use log::info;

use super::{function_parameters::TransformationType, imports::Imports, *};
use super::{
function_parameters::TransformationType, functions, imports::Imports, library,
special_functions,
};
use crate::{codegen::Visibility, config::gobjects::GObject, env::Env, nameutil::*, traits::*};

#[derive(Debug, Default)]
Expand Down Expand Up @@ -83,7 +86,7 @@ pub fn new(env: &Env, obj: &GObject, imports: &mut Imports) -> Option<Info> {
.unwrap();

if let TransformationType::ToGlibScalar { name, .. } = &mut t.transformation_type {
*name = "self".to_owned();
"self".clone_into(name);
} else {
panic!(
"Bitfield function instance param must be passed as scalar, not {:?}",
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/function_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl TransformationType {

pub fn set_to_glib_extra(&mut self, to_glib_extra_: &str) {
if let Self::ToGlibPointer { to_glib_extra, .. } = self {
*to_glib_extra = to_glib_extra_.to_owned();
to_glib_extra_.clone_into(to_glib_extra);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn find_callback_bound_to_destructor(
for call in callbacks {
if call.destroy_index == destroy_index {
destroy.nullable = call.nullable;
destroy.bound_name = call.bound_name.clone();
destroy.bound_name.clone_from(&call.bound_name);
return true;
}
}
Expand Down Expand Up @@ -512,7 +512,9 @@ fn analyze_callbacks(
for (pos, typ) in to_replace {
let ty = env.library.type_(typ);
params[pos].typ = typ;
params[pos].c_type = ty.get_glib_name().unwrap().to_owned();
ty.get_glib_name()
.unwrap()
.clone_into(&mut params[pos].c_type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These clone_into() are not really more readable IMHO. Let's maybe not do that unless this lint actually becomes stable (which it probably won't anytime soon).

}
let mut s = to_remove
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/info_base.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{imports::Imports, *};
use super::{functions, imports::Imports, special_functions};
use crate::{codegen::Visibility, library, version::Version};

#[derive(Debug, Default)]
Expand Down
5 changes: 3 additions & 2 deletions src/analysis/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::{borrow::Cow, ops::Deref};
use log::info;

use super::{
child_properties::ChildProperties, imports::Imports, info_base::InfoBase,
signatures::Signatures, *,
child_properties, child_properties::ChildProperties, class_builder, functions, general,
imports::Imports, info_base::InfoBase, properties, signals, signatures::Signatures,
special_functions, supertypes, Type, TypeId,
};
use crate::{
config::gobjects::{GObject, GStatus},
Expand Down
10 changes: 5 additions & 5 deletions src/analysis/record.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::ops::Deref;

use log::info;

use super::{imports::Imports, info_base::InfoBase, record_type::RecordType, *};
use super::{
functions, imports::Imports, info_base::InfoBase, record_type::RecordType, special_functions,
};
use crate::{
config::{
derives::{Derive, Derives},
Expand Down Expand Up @@ -70,7 +70,7 @@ fn filter_derives(derives: &[Derive], names: &[&str]) -> Derives {
}

pub fn new(env: &Env, obj: &GObject) -> Option<Info> {
info!("Analyzing record {}", obj.name);
log::info!("Analyzing record {}", obj.name);
let full_name = obj.name.clone();

let record_tid = env.library.find_type(0, &full_name)?;
Expand Down Expand Up @@ -191,7 +191,7 @@ pub fn new(env: &Env, obj: &GObject) -> Option<Info> {
"Have to use get_type function for {full_name} but version is higher than for the type ({get_type_version:?} > {version:?})"
);
} else {
error!("Missing memory management functions for {}", full_name);
log::error!("Missing memory management functions for {}", full_name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<'env> RustTypeBuilder<'env> {
mut self,
callback_parameters_config: &[CallbackParameter],
) -> Self {
self.callback_parameters_config = callback_parameters_config.to_owned();
callback_parameters_config.clone_into(&mut self.callback_parameters_config);
self
}

Expand Down
3 changes: 0 additions & 3 deletions src/chunk/conversion_from_glib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{
pub struct Mode {
pub typ: library::TypeId,
pub transfer: library::Transfer,
pub is_uninitialized: bool,
pub try_from_glib: TryFromGlib,
}

Expand All @@ -17,7 +16,6 @@ impl From<&parameter_ffi_call_out::Parameter> for Mode {
Mode {
typ: orig.typ,
transfer: orig.transfer,
is_uninitialized: orig.is_uninitialized,
try_from_glib: orig.try_from_glib.clone(),
}
}
Expand All @@ -28,7 +26,6 @@ impl From<&analysis::Parameter> for Mode {
Mode {
typ: orig.lib_par.typ,
transfer: orig.lib_par.transfer,
is_uninitialized: false,
try_from_glib: orig.try_from_glib.clone(),
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/codegen/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ trait FunctionLikeType {
fn doc_deprecated(&self) -> &Option<String>;
fn ret(&self) -> &Parameter;
fn parameters(&self) -> &[Parameter];
fn version(&self) -> &Option<Version>;
fn deprecated_version(&self) -> &Option<Version>;
}

Expand All @@ -82,9 +81,6 @@ macro_rules! impl_function_like_type {
fn parameters(&self) -> &[Parameter] {
&self.parameters
}
fn version(&self) -> &Option<Version> {
&self.version
}
fn deprecated_version(&self) -> &Option<Version> {
&self.deprecated_version
}
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/function_body_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Builder {
}

pub fn transformations(&mut self, transformations: &[Transformation]) -> &mut Self {
self.transformations = transformations.to_owned();
transformations.clone_into(&mut self.transformations);
self
}

Expand All @@ -151,7 +151,7 @@ impl Builder {
if !self.callbacks.is_empty() || !self.destroys.is_empty() {
for (pos, callback) in self.callbacks.iter().enumerate() {
let user_data_index = callback.user_data_index;
if group_by_user_data.get(&user_data_index).is_some() {
if group_by_user_data.contains_key(&user_data_index) {
continue;
}
let calls = self
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/return_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl ToReturnValue for library::Parameter {
&& self.direction == library::ParameterDirection::Return
&& is_gstring(&name)
{
name = "String".to_owned();
"String".clone_into(&mut name);
}
let type_str = match ConversionType::of(env, self.typ) {
ConversionType::Unknown => format!("/*Unknown conversion*/{name}"),
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/sys/cargo_toml.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashMap, fs::File, io::prelude::*};

use log::info;
use toml::{self, value::Table, Value};
use toml::{value::Table, Value};

use super::collect_versions;
use crate::{config::Config, env::Env, file_saver::save_to_file, nameutil, version::Version};
Expand Down
1 change: 0 additions & 1 deletion src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{
cmp::{Ord, Ordering, PartialOrd},
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
fmt,
iter::Iterator,
ops::{Deref, DerefMut},
str::FromStr,
};
Expand Down
2 changes: 1 addition & 1 deletion src/library_postprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Library {
return;
}
if let Some(s) = c_types.get(&tid) {
*c_type = s.clone();
c_type.clone_from(s);
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
pub use crate::config::{matchable::Matchable, parameter_matchable::ParameterMatchable};

pub trait AsStr {
fn as_str(&self) -> &str;
}

pub trait IntoString {
fn into_string(self) -> String;
}
Expand Down
1 change: 0 additions & 1 deletion src/xmlparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
};

use xml::{
self,
attribute::OwnedAttribute,
common::{Position, TextPosition},
name::OwnedName,
Expand Down
Loading