Skip to content

Commit

Permalink
Fix nightly clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Aug 25, 2023
1 parent 33ab47b commit 0ec853f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn analyze(env: &mut Env, tid: TypeId, deps: &[TypeId]) {
}
}

fn is_all_deps_analyzed(env: &mut Env, deps: &[TypeId]) -> bool {
fn is_all_deps_analyzed(env: &Env, deps: &[TypeId]) -> bool {
for tid in deps {
let full_name = tid.full_name(&env.library);
if !env.analysis.objects.contains_key(&full_name) {
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 @@ -685,7 +685,7 @@ impl Builder {
trampoline: &AsyncTrampoline,
) {
chunks.push(Chunk::Custom(String::from(
r###"
r#"
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
Expand All @@ -695,7 +695,7 @@ impl Builder {
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
"###,
"#,
)));

chunks.push(Chunk::Let {
Expand Down
34 changes: 22 additions & 12 deletions src/codegen/general.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::BTreeMap,
fmt::Display,
fmt::{Display, Write as FmtWrite},
io::{Result, Write},
ops::Index,
};
Expand Down Expand Up @@ -35,19 +35,21 @@ pub fn start_comments(w: &mut dyn Write, conf: &Config) -> Result<()> {
pub fn start_comments_no_version(w: &mut dyn Write, conf: &Config) -> Result<()> {
writeln!(
w,
"// This file was generated by gir (https://github.com/gtk-rs/gir)
{}// DO NOT EDIT",
"// This file was generated by gir (https://github.com/gtk-rs/gir) {}
// DO NOT EDIT",
conf.girs_version
.iter()
.map(|info| {
format!(
.fold(String::new(), |mut output, info| {
write!(

Check failure on line 43 in src/codegen/general.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-20.04, stable)

using `write!()` with a format string that ends in a single newline
output,
"// from {}{}\n",
info.gir_dir.display(),
info.get_repository_url()
.map_or_else(String::new, |url| format!(" ({url})")),
)
.unwrap();
output
})
.collect::<String>()
)
}

Expand All @@ -60,22 +62,30 @@ pub fn single_version_file(w: &mut dyn Write, conf: &Config, prefix: &str) -> Re
VERSION,
conf.girs_version
.iter()
.map(|info| {
.fold(String::new(), |mut output, info| {
match (info.get_repository_url(), info.get_hash()) {
(Some(url), Some(hash)) => format!(
(Some(url), Some(hash)) => write!(

Check failure on line 67 in src/codegen/general.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-20.04, stable)

using `write!()` with a format string that ends in a single newline
output,
"{}from {} ({} @ {})\n",
prefix,
info.gir_dir.display(),
url,
hash,
),
(None, Some(hash)) => {
format!("{}from {} (@ {})\n", prefix, info.gir_dir.display(), hash,)
write!(

Check failure on line 76 in src/codegen/general.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-20.04, stable)

using `write!()` with a format string that ends in a single newline
output,
"{}from {} (@ {})\n",
prefix,
info.gir_dir.display(),
hash,
)
}
_ => format!("{}from {}\n", prefix, info.gir_dir.display()),
_ => write!(output, "{}from {}\n", prefix, info.gir_dir.display()),

Check failure on line 84 in src/codegen/general.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-20.04, stable)

using `write!()` with a format string that ends in a single newline
}
})
.collect::<String>(),
.unwrap();
output
}),
)
}

Expand Down
8 changes: 4 additions & 4 deletions src/codegen/sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fn generate_build_script(w: &mut dyn Write, env: &Env, split_build_rs: bool) ->
writeln!(
w,
"{}",
r##"#[cfg(not(docsrs))]
use std::process;"##
r#"#[cfg(not(docsrs))]
use std::process;"#
)?;

if split_build_rs {
Expand All @@ -51,7 +51,7 @@ use std::process;"##
write!(
w,
"{}",
r##"
r#"
#[cfg(docsrs)]
fn main() {} // prevent linking libraries to avoid documentation failure
Expand All @@ -62,7 +62,7 @@ fn main() {
process::exit(1);
}
}
"##
"#
)
}

Expand Down
16 changes: 8 additions & 8 deletions src/codegen/sys/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fn generate_constant_c(
writeln!(
w,
"{}",
r####"
r#"
#define PRINT_CONSTANT(CONSTANT_NAME) \
printf("%s;", #CONSTANT_NAME); \
printf(_Generic((CONSTANT_NAME), \
Expand All @@ -274,7 +274,7 @@ fn generate_constant_c(
long double: "%ld"), \
CONSTANT_NAME); \
printf("\n");
"####
"#
)?;

writeln!(w, "{}", r"int main() {")?;
Expand Down Expand Up @@ -325,7 +325,7 @@ fn generate_abi_rs(
writeln!(
w,
"{}",
r####"
r#"
#[derive(Clone, Debug)]
struct Compiler {
pub args: Vec<String>,
Expand Down Expand Up @@ -515,7 +515,7 @@ fn get_c_output(name: &str) -> Result<String, Box<dyn Error>> {
Ok(String::from_utf8(out.stdout)?)
}
const RUST_LAYOUTS: &[(&str, Layout)] = &["####
const RUST_LAYOUTS: &[(&str, Layout)] = &["#
)?;
for ctype in ctypes {
general::cfg_condition(w, ctype.cfg_condition.as_ref(), false, 1)?;
Expand All @@ -525,9 +525,9 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &["####
writeln!(
w,
"{}",
r##"];
r#"];
const RUST_CONSTANTS: &[(&str, &str)] = &["##
const RUST_CONSTANTS: &[(&str, &str)] = &["#
)?;
for cconst in cconsts {
writeln!(
Expand All @@ -540,8 +540,8 @@ const RUST_CONSTANTS: &[(&str, &str)] = &["##
writeln!(
w,
"{}",
r##"];
r#"];
"##
"#
)
}
2 changes: 1 addition & 1 deletion src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ macro_rules! impl_lexical_ord {

impl PartialOrd for $name {
fn partial_cmp(&self, other: &$name) -> Option<Ordering> {
self.$field.partial_cmp(&other.$field)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ impl Library {

fn read_object_c_type<'a>(
&mut self,
parser: &mut XmlParser<'_>,
parser: &XmlParser<'_>,
elem: &'a Element,
) -> Result<&'a str, String> {
elem.attr("type")
Expand Down

0 comments on commit 0ec853f

Please sign in to comment.